detach auras and interrupts

This commit is contained in:
Sumsebrum 2022-01-12 02:24:46 +01:00
parent 035942abbe
commit 5766484f92

View File

@ -41,7 +41,17 @@ local Auras = Gladdy:NewModule("Auras", nil, {
auraListDefault = defaultSpells(), auraListDefault = defaultSpells(),
auraListInterrupts = defaultInterrupts(), auraListInterrupts = defaultInterrupts(),
auraInterruptColorsEnabled = true, auraInterruptColorsEnabled = true,
auraInterruptColors = Gladdy:GetSpellSchoolColors() auraInterruptColors = Gladdy:GetSpellSchoolColors(),
auraDetached = false,
auraXOffset = 0,
auraYOffset = 0,
auraSize = 60 + 20 + 1,
auraWidthFactor = 0.9,
auraInterruptDetached = false,
auraInterruptXOffset = 0,
auraInterruptYOffset = 0,
auraInterruptSize = 60 + 20 + 1,
auraInterruptWidthFactor = 0.9,
}) })
function Auras:Initialize() function Auras:Initialize()
@ -57,25 +67,30 @@ function Auras:Initialize()
end end
function Auras:CreateFrame(unit) function Auras:CreateFrame(unit)
local auraFrame = CreateFrame("Frame", nil, Gladdy.modules["Class Icon"].frames[unit]) local auraFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])
auraFrame:EnableMouse(false) auraFrame:EnableMouse(false)
auraFrame:SetFrameStrata("MEDIUM") auraFrame:SetFrameStrata("MEDIUM")
auraFrame:SetFrameLevel(3) auraFrame:SetFrameLevel(3)
auraFrame.frame = CreateFrame("Frame", nil, auraFrame)
auraFrame.frame:SetPoint("TOPLEFT", auraFrame, "TOPLEFT")
auraFrame.frame:EnableMouse(false)
auraFrame.frame:SetFrameStrata("MEDIUM")
auraFrame.frame:SetFrameLevel(3)
auraFrame.cooldown = CreateFrame("Cooldown", nil, auraFrame, "CooldownFrameTemplate") auraFrame.cooldown = CreateFrame("Cooldown", nil, auraFrame.frame, "CooldownFrameTemplate")
auraFrame.cooldown.noCooldownCount = true auraFrame.cooldown.noCooldownCount = true
auraFrame.cooldown:SetFrameStrata("MEDIUM") auraFrame.cooldown:SetFrameStrata("MEDIUM")
auraFrame.cooldown:SetFrameLevel(4) auraFrame.cooldown:SetFrameLevel(4)
auraFrame.cooldown:SetReverse(true) auraFrame.cooldown:SetReverse(true)
auraFrame.cooldown:SetHideCountdownNumbers(true) auraFrame.cooldown:SetHideCountdownNumbers(true)
auraFrame.cooldownFrame = CreateFrame("Frame", nil, auraFrame) auraFrame.cooldownFrame = CreateFrame("Frame", nil, auraFrame.frame)
auraFrame.cooldownFrame:ClearAllPoints() auraFrame.cooldownFrame:ClearAllPoints()
auraFrame.cooldownFrame:SetAllPoints(auraFrame) auraFrame.cooldownFrame:SetAllPoints(auraFrame.frame)
auraFrame.cooldownFrame:SetFrameStrata("MEDIUM") auraFrame.cooldownFrame:SetFrameStrata("MEDIUM")
auraFrame.cooldownFrame:SetFrameLevel(5) auraFrame.cooldownFrame:SetFrameLevel(5)
auraFrame.icon = auraFrame:CreateTexture(nil, "BACKGROUND") auraFrame.icon = auraFrame.frame:CreateTexture(nil, "BACKGROUND")
auraFrame.icon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask") auraFrame.icon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
auraFrame.icon:SetAllPoints(auraFrame) auraFrame.icon:SetAllPoints(auraFrame)
@ -98,10 +113,10 @@ function Auras:CreateFrame(unit)
auraFrame:SetScript("OnUpdate", function(self, elapsed) auraFrame:SetScript("OnUpdate", function(self, elapsed)
if (self.active) then if (self.active) then
if (self.interruptFrame.priority and self.priority < self.interruptFrame.priority) then if (not Gladdy.db.auraInterruptDetached and not Gladdy.db.auraDetached and self.interruptFrame.priority and self.priority < self.interruptFrame.priority) then
self:SetAlpha(0.01) self.frame:SetAlpha(0.001)
else else
self:SetAlpha(1) self.frame:SetAlpha(1)
end end
if (self.timeLeft <= 0) then if (self.timeLeft <= 0) then
Auras:AURA_FADE(self.unit, self.track) Auras:AURA_FADE(self.unit, self.track)
@ -114,7 +129,7 @@ function Auras:CreateFrame(unit)
self.timeLeft = self.timeLeft - elapsed self.timeLeft = self.timeLeft - elapsed
end end
else else
self:SetAlpha(0.01) self.frame:SetAlpha(0.001)
end end
end) end)
@ -125,30 +140,35 @@ function Auras:CreateFrame(unit)
end end
function Auras:CreateInterrupt(unit) function Auras:CreateInterrupt(unit)
local interruptFrame = CreateFrame("Frame", nil, Gladdy.modules["Class Icon"].frames[unit]) local interruptFrame = CreateFrame("Frame", nil, Gladdy.buttons[unit])
interruptFrame:EnableMouse(false) interruptFrame:EnableMouse(false)
interruptFrame:SetFrameStrata("MEDIUM") interruptFrame:SetFrameStrata("MEDIUM")
interruptFrame:SetFrameLevel(3) interruptFrame:SetFrameLevel(3)
interruptFrame.frame = CreateFrame("Frame", nil, interruptFrame)
interruptFrame.frame:SetPoint("TOPLEFT", interruptFrame, "TOPLEFT")
interruptFrame.frame:EnableMouse(false)
interruptFrame.frame:SetFrameStrata("MEDIUM")
interruptFrame.frame:SetFrameLevel(3)
interruptFrame.cooldown = CreateFrame("Cooldown", nil, interruptFrame, "CooldownFrameTemplate") interruptFrame.cooldown = CreateFrame("Cooldown", nil, interruptFrame.frame, "CooldownFrameTemplate")
interruptFrame.cooldown.noCooldownCount = true interruptFrame.cooldown.noCooldownCount = true
interruptFrame.cooldown:SetFrameStrata("MEDIUM") interruptFrame.cooldown:SetFrameStrata("MEDIUM")
interruptFrame.cooldown:SetFrameLevel(4) interruptFrame.cooldown:SetFrameLevel(4)
interruptFrame.cooldown:SetReverse(true) interruptFrame.cooldown:SetReverse(true)
interruptFrame.cooldown:SetHideCountdownNumbers(true) interruptFrame.cooldown:SetHideCountdownNumbers(true)
interruptFrame.cooldownFrame = CreateFrame("Frame", nil, interruptFrame) interruptFrame.cooldownFrame = CreateFrame("Frame", nil, interruptFrame.frame)
interruptFrame.cooldownFrame:ClearAllPoints() interruptFrame.cooldownFrame:ClearAllPoints()
interruptFrame.cooldownFrame:SetAllPoints(interruptFrame) interruptFrame.cooldownFrame:SetAllPoints(interruptFrame.frame)
interruptFrame.cooldownFrame:SetFrameStrata("MEDIUM") interruptFrame.cooldownFrame:SetFrameStrata("MEDIUM")
interruptFrame.cooldownFrame:SetFrameLevel(5) interruptFrame.cooldownFrame:SetFrameLevel(5)
interruptFrame.icon = interruptFrame:CreateTexture(nil, "BACKGROUND") interruptFrame.icon = interruptFrame.frame:CreateTexture(nil, "BACKGROUND")
interruptFrame.icon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask") interruptFrame.icon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
interruptFrame.icon:SetAllPoints(interruptFrame) interruptFrame.icon:SetAllPoints(interruptFrame.frame)
interruptFrame.icon.overlay = interruptFrame.cooldownFrame:CreateTexture(nil, "OVERLAY") interruptFrame.icon.overlay = interruptFrame.cooldownFrame:CreateTexture(nil, "OVERLAY")
interruptFrame.icon.overlay:SetAllPoints(interruptFrame) interruptFrame.icon.overlay:SetAllPoints(interruptFrame.frame)
interruptFrame.icon.overlay:SetTexture(Gladdy.db.buttonBorderStyle) interruptFrame.icon.overlay:SetTexture(Gladdy.db.buttonBorderStyle)
local classIcon = Gladdy.modules["Class Icon"].frames[unit] local classIcon = Gladdy.modules["Class Icon"].frames[unit]
@ -166,23 +186,25 @@ function Auras:CreateInterrupt(unit)
interruptFrame:SetScript("OnUpdate", function(self, elapsed) interruptFrame:SetScript("OnUpdate", function(self, elapsed)
if (self.active) then if (self.active) then
if (Auras.frames[self.unit].priority and self.priority <= Auras.frames[self.unit].priority) then if (not Gladdy.db.auraInterruptDetached and Auras.frames[self.unit].priority and self.priority <= Auras.frames[self.unit].priority) then
self:SetAlpha(0.01) self.frame:SetAlpha(0.001)
else else
self:SetAlpha(1) self.frame:SetAlpha(1)
end end
if (self.timeLeft <= 0) then if (self.timeLeft <= 0) then
self.active = false self.active = false
self.priority = nil self.priority = nil
self.spellSchool = nil self.spellSchool = nil
self.cooldown:Clear() self.cooldown:Clear()
self:SetAlpha(0.01) self.frame:SetAlpha(0.001)
else else
self.timeLeft = self.timeLeft - elapsed self.timeLeft = self.timeLeft - elapsed
Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 10) Gladdy:FormatTimer(self.text, self.timeLeft, self.timeLeft < 10)
end end
else else
self:SetAlpha(0.01) self.priority = nil
self.spellSchool = nil
self.frame:SetAlpha(0.001)
end end
end) end)
@ -197,16 +219,40 @@ function Auras:UpdateFrame(unit)
return return
end end
local width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize local width, height
if Gladdy.db.auraDetached then
width, height = Gladdy.db.auraSize * Gladdy.db.auraWidthFactor, Gladdy.db.auraSize
auraFrame:ClearAllPoints()
Gladdy:SetPosition(auraFrame, unit, "auraXOffset", "auraYOffset", true, Auras)
if (unit == "arena1") then
Gladdy:CreateMover(auraFrame, "auraXOffset", "auraYOffset", L["Auras"],
{"TOPLEFT", "TOPLEFT"},
width,
height,
0,
0)
end
else
width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize
auraFrame:ClearAllPoints()
auraFrame:SetPoint("TOPLEFT", Gladdy.modules["Class Icon"].frames[unit], "TOPLEFT")
if auraFrame.mover then
auraFrame.mover:Hide()
end
end
auraFrame:SetWidth(width) auraFrame:SetWidth(width)
auraFrame:SetHeight(height) auraFrame:SetHeight(height)
auraFrame:SetAllPoints(Gladdy.modules["Class Icon"].frames[unit]) auraFrame.frame:SetWidth(height)
auraFrame.frame:SetHeight(height)
auraFrame.cooldownFrame:ClearAllPoints()
auraFrame.cooldownFrame:SetAllPoints(auraFrame)
auraFrame.cooldown:SetWidth(width - width/16)
auraFrame.cooldown:SetHeight(height - height/16)
auraFrame.cooldown:ClearAllPoints() auraFrame.cooldown:ClearAllPoints()
auraFrame.cooldown:SetPoint("CENTER", auraFrame, "CENTER") auraFrame.cooldown:SetPoint("CENTER", auraFrame, "CENTER")
auraFrame.cooldown:SetWidth(width - width/16)
auraFrame.cooldown:SetHeight(height - height/16)
auraFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha) auraFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha)
auraFrame.text:SetFont(Gladdy:SMFetch("font", "auraFont"), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE") auraFrame.text:SetFont(Gladdy:SMFetch("font", "auraFont"), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE")
@ -235,16 +281,49 @@ function Auras:UpdateInterruptFrame(unit)
return return
end end
local width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize local width, height
if Gladdy.db.auraInterruptDetached then
width, height = Gladdy.db.auraInterruptSize * Gladdy.db.auraInterruptWidthFactor, Gladdy.db.auraInterruptSize
interruptFrame:ClearAllPoints()
Gladdy:SetPosition(interruptFrame, unit, "auraInterruptXOffset", "auraInterruptYOffset", true, Auras)
if (unit == "arena1") then
Gladdy:CreateMover(interruptFrame, "auraInterruptXOffset", "auraInterruptYOffset", L["Interrupts"],
{"TOPLEFT", "TOPLEFT"},
width,
height,
0,
0)
end
else
if Gladdy.db.auraDetached then
width, height = Gladdy.db.auraSize * Gladdy.db.auraWidthFactor, Gladdy.db.auraSize
interruptFrame:ClearAllPoints()
interruptFrame:SetAllPoints(self.frames[unit])
if interruptFrame.mover then
interruptFrame.mover:Hide()
end
else
width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize
interruptFrame:ClearAllPoints()
interruptFrame:SetPoint("TOPLEFT", Gladdy.modules["Class Icon"].frames[unit], "TOPLEFT")
if interruptFrame.mover then
interruptFrame.mover:Hide()
end
end
end
interruptFrame:SetWidth(width) interruptFrame:SetWidth(width)
interruptFrame:SetHeight(height) interruptFrame:SetHeight(height)
interruptFrame:SetAllPoints(Gladdy.modules["Class Icon"].frames[unit]) interruptFrame.frame:SetWidth(width)
interruptFrame.frame:SetHeight(height)
interruptFrame.cooldownFrame:ClearAllPoints()
interruptFrame.cooldownFrame:SetAllPoints(interruptFrame.frame)
interruptFrame.cooldown:SetWidth(width - width/16)
interruptFrame.cooldown:SetHeight(height - height/16)
interruptFrame.cooldown:ClearAllPoints() interruptFrame.cooldown:ClearAllPoints()
interruptFrame.cooldown:SetPoint("CENTER", interruptFrame, "CENTER") interruptFrame.cooldown:SetPoint("CENTER", interruptFrame, "CENTER")
interruptFrame.cooldown:SetWidth(width - width/16)
interruptFrame.cooldown:SetHeight(height - height/16)
interruptFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha) interruptFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha)
interruptFrame.text:SetFont(Gladdy:SMFetch("font", "auraFont"), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE") interruptFrame.text:SetFont(Gladdy:SMFetch("font", "auraFont"), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE")
@ -265,9 +344,15 @@ function Auras:UpdateInterruptFrame(unit)
end end
function Auras:ResetUnit(unit) function Auras:ResetUnit(unit)
self.frames[unit]:UnregisterAllEvents() self.frames[unit].interruptFrame.active = false
self.frames[unit].active = false
self:AURA_FADE(unit, AURA_TYPE_DEBUFF) self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
self:AURA_FADE(unit, AURA_TYPE_BUFF) self:AURA_FADE(unit, AURA_TYPE_BUFF)
self.frames[unit]:UnregisterAllEvents()
self.frames[unit]:Hide()
self.frames[unit].interruptFrame:Hide()
self.frames[unit].interruptFrame.priority = nil
self.frames[unit].interruptFrame.spellSchool = nil
end end
function Auras:Test(unit) function Auras:Test(unit)
@ -275,6 +360,10 @@ function Auras:Test(unit)
self:AURA_FADE(unit, AURA_TYPE_BUFF) self:AURA_FADE(unit, AURA_TYPE_BUFF)
self:AURA_FADE(unit, AURA_TYPE_DEBUFF) self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
if not self.frames[unit]:IsShown() then
self.frames[unit]:Show()
self.frames[unit].interruptFrame:Show()
end
--Auras --Auras
local enabledDebuffs, enabledBuffs, testauras = {}, {} local enabledDebuffs, enabledBuffs, testauras = {}, {}
@ -310,6 +399,8 @@ function Auras:Test(unit)
self:AURA_GAIN(unit,v.value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration) self:AURA_GAIN(unit,v.value.track, spellid, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
end end
end end
-- /run LibStub("Gladdy").modules["Auras"]:Test("arena1")
-- /run LibStub("Gladdy"):JoinedArena()
--Interrupts --Interrupts
if (unit == "arena1" or unit == "arena3") then if (unit == "arena1" or unit == "arena3") then
@ -333,10 +424,15 @@ function Auras:Test(unit)
end end
function Auras:JOINED_ARENA() function Auras:JOINED_ARENA()
--[[for i=1, Gladdy.curBracket do for i=1, Gladdy.curBracket do
self.frames["arena" .. i]:RegisterUnitEvent("UNIT_AURA", "arena" .. i) local unit = "arena" .. i
self.frames["arena" .. i]:SetScript("OnEvent", Auras.OnEvent) self.frames[unit].interruptFrame.active = false
end--]] self.frames[unit].active = false
self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
self:AURA_FADE(unit, AURA_TYPE_BUFF)
self.frames[unit].frame:Show()
self.frames[unit].interruptFrame.frame:Show()
end
end end
function Auras:AURA_GAIN(unit, auraType, spellID, spellName, icon, duration, expirationTime, count, debuffType) function Auras:AURA_GAIN(unit, auraType, spellID, spellName, icon, duration, expirationTime, count, debuffType)
@ -418,7 +514,7 @@ end
function Auras:SPELL_INTERRUPT(unit,spellID,spellName,spellSchool,extraSpellId,extraSpellName,extraSpellSchool) function Auras:SPELL_INTERRUPT(unit,spellID,spellName,spellSchool,extraSpellId,extraSpellName,extraSpellSchool)
local auraFrame = self.frames[unit] local auraFrame = self.frames[unit]
local interruptFrame = auraFrame and auraFrame.interruptFrame local interruptFrame = auraFrame ~= nil and auraFrame.interruptFrame
local button = Gladdy.buttons[unit] local button = Gladdy.buttons[unit]
if (not interruptFrame) then if (not interruptFrame) then
return return
@ -532,6 +628,158 @@ function Auras:GetOptions()
name = L["Frame"], name = L["Frame"],
order = 3, order = 3,
args = { args = {
detachedAuraMode = {
type = "group",
name = L["Detached Aura"],
order = 4,
args = {
headerDetachedMode = {
type = "header",
name = L["Detached Mode"],
order = 1,
},
auraDetached = Gladdy:option({
type = "toggle",
name = L["Aura Detached"],
order = 2,
width = "full"
}),
headerAuraSize = {
type = "header",
name = L["Size"],
order = 10,
},
auraSize = Gladdy:option({
type = "range",
name = L["Aura size"],
disabled = function()
return not Gladdy.db.auraDetached
end,
min = 3,
max = 100,
step = 0.1,
order = 11,
width = "full",
}),
auraWidthFactor = Gladdy:option({
type = "range",
name = L["Aura width factor"],
disabled = function()
return not Gladdy.db.auraDetached
end,
min = 0.5,
max = 2,
step = 0.05,
order = 12,
width = "full",
}),
headerAuraPosition = {
type = "header",
name = L["Position"],
order = 20,
},
auraXOffset = Gladdy:option({
type = "range",
name = L["Aura X Offset"],
disabled = function()
return not Gladdy.db.auraDetached
end,
min = -1000,
max = 1000,
step = 0.01,
order = 21,
width = "full",
}),
auraYOffset = Gladdy:option({
type = "range",
name = L["Aura Y Offset"],
disabled = function()
return not Gladdy.db.auraDetached
end,
min = -1000,
max = 1000,
step = 0.01,
order = 22,
width = "full",
}),
}
},
detachedInterruptMode = {
type = "group",
name = L["Detached Interrupt"],
order = 5,
args = {
headerDetachedMode = {
type = "header",
name = L["Detached Mode"],
order = 1,
},
auraInterruptDetached = Gladdy:option({
type = "toggle",
name = L["Interrupt Detached"],
order = 2,
width = "full"
}),
headerAuraSize = {
type = "header",
name = L["Size"],
order = 10,
},
auraInterruptSize = Gladdy:option({
type = "range",
name = L["Interrupt size"],
disabled = function()
return not Gladdy.db.auraInterruptDetached
end,
min = 3,
max = 100,
step = 0.1,
order = 11,
width = "full",
}),
auraInterruptWidthFactor = Gladdy:option({
type = "range",
name = L["Interrupt width factor"],
disabled = function()
return not Gladdy.db.auraInterruptDetached
end,
min = 0.5,
max = 2,
step = 0.05,
order = 12,
width = "full",
}),
headerAuraPosition = {
type = "header",
name = L["Position"],
order = 20,
},
auraInterruptXOffset = Gladdy:option({
type = "range",
name = L["Interrupt X Offset"],
disabled = function()
return not Gladdy.db.auraInterruptDetached
end,
min = -1000,
max = 1000,
step = 0.01,
order = 21,
width = "full",
}),
auraInterruptYOffset = Gladdy:option({
type = "range",
name = L["Interrupt Y Offset"],
disabled = function()
return not Gladdy.db.auraInterruptDetached
end,
min = -1000,
max = 1000,
step = 0.01,
order = 22,
width = "full",
}),
}
},
cooldown = { cooldown = {
type = "group", type = "group",
name = L["Cooldown"], name = L["Cooldown"],