This commit is contained in:
pepopo978
2024-05-27 08:17:27 -07:00
parent be8d708e99
commit fa95809af9
4 changed files with 53 additions and 49 deletions
+1
View File
@@ -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
+30 -24
View File
@@ -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
+1 -16
View File
@@ -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",
+21 -9
View File
@@ -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