From fa95809af92b018eb0578e374ecb655b7b9d5315 Mon Sep 17 00:00:00 2001 From: pepopo978 Date: Mon, 27 May 2024 08:17:27 -0700 Subject: [PATCH] bugfixes --- core.lua | 1 + curses.lua | 54 +++++++++++++++++++++++++++++----------------------- settings.lua | 17 +---------------- ui.lua | 30 ++++++++++++++++++++--------- 4 files changed, 53 insertions(+), 49 deletions(-) diff --git a/core.lua b/core.lua index 728b0f0..7f1bce7 100644 --- a/core.lua +++ b/core.lua @@ -48,6 +48,7 @@ end Cursive.core:SetScript("OnEvent", function() if event == "ADDON_LOADED" and arg1 == "Cursive" then + Cursive.curses:LoadCurses() if Cursive.db.profile.enabled then Cursive.core.enable() end diff --git a/curses.lua b/curses.lua index 054a9ed..a494c4c 100644 --- a/curses.lua +++ b/curses.lua @@ -1,9 +1,12 @@ +if not Cursive.superwow then + return +end + local curses = { trackedCurseIds = {}, trackedCurseNamesToTextures = {}, guids = {}, } -Cursive.curses = curses -- combat events for curses local afflict_test = "^(.+) is afflicted by (.+) %((%d+)%)" -- for stacks 2-5 will be "Fire Vulnerability (2)". @@ -13,30 +16,31 @@ local resist_test = "Your (.+) was resisted by (.+)" local lastGuid = nil --- curses to track -local _, className = UnitClass("player") -if className == "WARLOCK" then - curses.trackedCurseIds = getWarlockSpells() -elseif className == "PRIEST" then - curses.trackedCurseIds = getPriestSpells() -elseif className == "MAGE" then - curses.trackedCurseIds = getMageSpells() -elseif className == "DRUID" then - curses.trackedCurseIds = getDruidSpells() -elseif className == "HUNTER" then - curses.trackedCurseIds = getHunterSpells() -elseif className == "ROGUE" then - curses.trackedCurseIds = getRogueSpells() -end +function curses:LoadCurses() + -- curses to track + local _, className = UnitClass("player") + if className == "WARLOCK" then + curses.trackedCurseIds = getWarlockSpells() + elseif className == "PRIEST" then + curses.trackedCurseIds = getPriestSpells() + elseif className == "MAGE" then + curses.trackedCurseIds = getMageSpells() + elseif className == "DRUID" then + curses.trackedCurseIds = getDruidSpells() + elseif className == "HUNTER" then + curses.trackedCurseIds = getHunterSpells() + elseif className == "ROGUE" then + curses.trackedCurseIds = getRogueSpells() + end -curses.trackedCurseNamesToTextures = {} -for id, data in pairs(curses.trackedCurseIds) do - -- get the texture - local name, rank, texture = SpellInfo(id) - -- update trackedCurseNamesToTextures - curses.trackedCurseNamesToTextures[data.name] = texture - -- update trackedCurseIds - curses.trackedCurseIds[id].texture = texture + for id, data in pairs(curses.trackedCurseIds) do + -- get the texture + local name, rank, texture = SpellInfo(id) + -- update trackedCurseNamesToTextures + curses.trackedCurseNamesToTextures[data.name] = texture + -- update trackedCurseIds + curses.trackedCurseIds[id].texture = texture + end end Cursive:RegisterEvent("UNIT_CASTEVENT", function(casterGuid, targetGuid, event, spellID, castDuration) @@ -98,3 +102,5 @@ end function curses:RemoveGuid(guid) curses.guids[guid] = nil end + +Cursive.curses = curses diff --git a/settings.lua b/settings.lua index c3ad034..7d66535 100644 --- a/settings.lua +++ b/settings.lua @@ -9,6 +9,7 @@ Cursive:RegisterDefaults("profile", { anchor = "CENTER", x = -240, y = 120, + maxcol = 1, -- editable scale = 1, @@ -16,7 +17,6 @@ Cursive:RegisterDefaults("profile", { height = 14, spacing = 4, maxrow = 10, - maxcol = 1, }) Cursive.cmdtable = { @@ -100,21 +100,6 @@ Cursive.cmdtable = { Cursive.db.profile.maxrow = v end, }, - ["maxcol"] = { - type = "range", - name = "Max Columns", - desc = "Max Columns", - order = 1, - min = 1, - max = 5, - step = 1, - get = function() - return Cursive.db.profile.maxcol - end, - set = function(v) - Cursive.db.profile.maxcol = v - end, - }, ["scale"] = { type = "range", name = "Scale", diff --git a/ui.lua b/ui.lua index 5abf0c7..1fdc1b7 100644 --- a/ui.lua +++ b/ui.lua @@ -92,7 +92,7 @@ ui.BarUpdate = function() local name = UnitName(this.guid) local hp = UnitHealth(this.guid) -- convert hp to k if > 1000 - if hp and hp > 1000 then + if hp and hp > 1000 then -- round to 1 decimal hp = math.floor(hp / 100) / 10 .. "k" end @@ -115,7 +115,7 @@ ui.BarUpdate = function() end -- show raid icon if existing - if GetRaidTargetIndex(this.guid) then + if GetRaidTargetIndex(this.guid) and Cursive.filter.alive(this.guid) then SetRaidTargetIconTexture(this.icon, GetRaidTargetIndex(this.guid)) this.icon:Show() else @@ -251,24 +251,29 @@ ui:SetScript("OnUpdate", function() -- run through all guids and fill with bars local title_size = 12 + config.spacing local width, height = config.width, config.height + title_size - local x, y, count = 0, 0, 0 + local x, y, rowCount, colCount = 0, 0, 0, 1 for guid, time in pairs(Cursive.core.guids) do -- apply filters local shouldDisplay = Cursive:ShouldDisplayGuid(guid) - local exists = UnitExists(guid) + local exists = UnitExists(guid) and Cursive.filter.alive(guid) -- display element if filters allow it if exists and shouldDisplay then - count = count + 1 + rowCount = rowCount + 1 - if count > config.maxrow then - count, x = 1, x + config.width + config.spacing - width = math.max(x + config.width, width) + if rowCount > config.maxrow then + if colCount < config.maxcol then + colCount = colCount + 1 + rowCount, x = 1, x + config.width + config.spacing + width = math.max(x + config.width, width) + else + break + end end - y = (count - 1) * (config.height + config.spacing) + title_size + y = (rowCount - 1) * (config.height + config.spacing) + title_size height = math.max(y + config.height + config.spacing, height) root.frames[guid] = root.frames[guid] or root:CreateBar(guid) @@ -287,6 +292,13 @@ ui:SetScript("OnUpdate", function() root.frames[guid].sizes = config.width .. config.height end + for i = 1, 3 do + if not root.frames[guid]["curse" .. i].sizes or root.frames[guid]["curse" .. i].sizes ~= config.width .. config.height then + root.frames[guid]["curse" .. i]:SetWidth(config.height) + root.frames[guid]["curse" .. i]:SetHeight(config.height) + end + end + -- update curses local curseNumber = 1