add interrupts to auras
This commit is contained in:
@ -18,6 +18,16 @@ local function defaultSpells(auraType)
|
||||
end
|
||||
return spells
|
||||
end
|
||||
local function defaultInterrupts()
|
||||
local spells = {}
|
||||
for k,v in pairs(Gladdy:GetInterrupts()) do
|
||||
spells[tostring(v.spellID)] = {}
|
||||
spells[tostring(v.spellID)].enabled = true
|
||||
spells[tostring(v.spellID)].priority = v.priority
|
||||
end
|
||||
return spells
|
||||
end
|
||||
|
||||
local Auras = Gladdy:NewModule("Auras", nil, {
|
||||
auraFont = "DorisPP",
|
||||
auraFontSizeScale = 1,
|
||||
@ -27,7 +37,10 @@ local Auras = Gladdy:NewModule("Auras", nil, {
|
||||
auraDebuffBorderColor = { r = 0, g = 1, b = 0, a = 1 },
|
||||
auraDisableCircle = false,
|
||||
auraCooldownAlpha = 1,
|
||||
auraListDefault = defaultSpells()
|
||||
auraListDefault = defaultSpells(),
|
||||
auraListInterrupts = defaultInterrupts(),
|
||||
auraInterruptColorsEnabled = true,
|
||||
auraInterruptColors = Gladdy:GetSpellSchoolColors()
|
||||
})
|
||||
|
||||
function Auras:Initialize()
|
||||
@ -39,6 +52,7 @@ function Auras:Initialize()
|
||||
self:RegisterMessage("UNIT_DEATH")
|
||||
self:RegisterMessage("AURA_GAIN")
|
||||
self:RegisterMessage("AURA_FADE")
|
||||
self:RegisterMessage("SPELL_INTERRUPT")
|
||||
end
|
||||
|
||||
function Auras:CreateFrame(unit)
|
||||
@ -83,17 +97,92 @@ function Auras:CreateFrame(unit)
|
||||
|
||||
auraFrame:SetScript("OnUpdate", function(self, elapsed)
|
||||
if (self.active) then
|
||||
if (self.interruptFrame.priority and self.priority < self.interruptFrame.priority) then
|
||||
self:SetAlpha(0.01)
|
||||
else
|
||||
self:SetAlpha(1)
|
||||
end
|
||||
if (self.timeLeft <= 0) then
|
||||
Auras:AURA_FADE(self.unit, self.track)
|
||||
else
|
||||
self.timeLeft = self.timeLeft - elapsed
|
||||
self.text:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
|
||||
end
|
||||
else
|
||||
self:SetAlpha(0.01)
|
||||
end
|
||||
end)
|
||||
|
||||
Gladdy.buttons[unit].aura = auraFrame
|
||||
self.frames[unit] = auraFrame
|
||||
self:CreateInterrupt(unit)
|
||||
self:ResetUnit(unit)
|
||||
end
|
||||
|
||||
function Auras:CreateInterrupt(unit)
|
||||
local interruptFrame = CreateFrame("Frame", nil, Gladdy.modules["Class Icon"].frames[unit])
|
||||
interruptFrame:EnableMouse(false)
|
||||
interruptFrame:SetFrameStrata("MEDIUM")
|
||||
interruptFrame:SetFrameLevel(3)
|
||||
|
||||
interruptFrame.cooldown = CreateFrame("Cooldown", nil, interruptFrame, "CooldownFrameTemplate")
|
||||
interruptFrame.cooldown.noCooldownCount = true
|
||||
interruptFrame.cooldown:SetFrameStrata("MEDIUM")
|
||||
interruptFrame.cooldown:SetFrameLevel(4)
|
||||
interruptFrame.cooldown:SetReverse(true)
|
||||
interruptFrame.cooldown:SetHideCountdownNumbers(true)
|
||||
|
||||
interruptFrame.cooldownFrame = CreateFrame("Frame", nil, interruptFrame)
|
||||
interruptFrame.cooldownFrame:ClearAllPoints()
|
||||
interruptFrame.cooldownFrame:SetAllPoints(interruptFrame)
|
||||
interruptFrame.cooldownFrame:SetFrameStrata("MEDIUM")
|
||||
interruptFrame.cooldownFrame:SetFrameLevel(5)
|
||||
|
||||
interruptFrame.icon = interruptFrame:CreateTexture(nil, "BACKGROUND")
|
||||
interruptFrame.icon:SetMask("Interface\\AddOns\\Gladdy\\Images\\mask")
|
||||
interruptFrame.icon:SetAllPoints(interruptFrame)
|
||||
|
||||
interruptFrame.icon.overlay = interruptFrame.cooldownFrame:CreateTexture(nil, "OVERLAY")
|
||||
interruptFrame.icon.overlay:SetAllPoints(interruptFrame)
|
||||
interruptFrame.icon.overlay:SetTexture(Gladdy.db.buttonBorderStyle)
|
||||
|
||||
local classIcon = Gladdy.modules["Class Icon"].frames[unit]
|
||||
interruptFrame:ClearAllPoints()
|
||||
interruptFrame:SetAllPoints(classIcon)
|
||||
|
||||
interruptFrame.text = interruptFrame.cooldownFrame:CreateFontString(nil, "OVERLAY")
|
||||
interruptFrame.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), 10, "OUTLINE")
|
||||
interruptFrame.text:SetTextColor(Gladdy.db.auraFontColor.r, Gladdy.db.auraFontColor.g, Gladdy.db.auraFontColor.b, Gladdy.db.auraFontColor.a)
|
||||
--auraFrame.text:SetShadowOffset(1, -1)
|
||||
--auraFrame.text:SetShadowColor(0, 0, 0, 1)
|
||||
interruptFrame.text:SetJustifyH("CENTER")
|
||||
interruptFrame.text:SetPoint("CENTER")
|
||||
interruptFrame.unit = unit
|
||||
|
||||
interruptFrame:SetScript("OnUpdate", function(self, elapsed)
|
||||
if (self.active) then
|
||||
if (Auras.frames[self.unit].priority and self.priority <= Auras.frames[self.unit].priority) then
|
||||
self:SetAlpha(0.01)
|
||||
else
|
||||
self:SetAlpha(1)
|
||||
end
|
||||
if (self.timeLeft <= 0) then
|
||||
self.active = false
|
||||
self.priority = nil
|
||||
self.spellSchool = nil
|
||||
self.cooldown:SetCooldown(GetTime(), 0)
|
||||
self:SetAlpha(0.01)
|
||||
else
|
||||
self.timeLeft = self.timeLeft - elapsed
|
||||
self.text:SetFormattedText("%.1f", self.timeLeft >= 0.0 and self.timeLeft or 0.0)
|
||||
end
|
||||
else
|
||||
self:SetAlpha(0.01)
|
||||
end
|
||||
end)
|
||||
|
||||
Gladdy.buttons[unit].interruptFrame = interruptFrame
|
||||
self.frames[unit].interruptFrame = interruptFrame
|
||||
self:ResetUnit(unit)
|
||||
end
|
||||
|
||||
@ -132,6 +221,42 @@ function Auras:UpdateFrame(unit)
|
||||
if Gladdy.db.auraDisableCircle then
|
||||
auraFrame.cooldown:SetAlpha(0)
|
||||
end
|
||||
self:UpdateInterruptFrame(unit)
|
||||
end
|
||||
|
||||
function Auras:UpdateInterruptFrame(unit)
|
||||
local interruptFrame = self.frames[unit] and self.frames[unit].interruptFrame
|
||||
if (not interruptFrame) then
|
||||
return
|
||||
end
|
||||
|
||||
local width, height = Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor, Gladdy.db.classIconSize
|
||||
|
||||
interruptFrame:SetWidth(width)
|
||||
interruptFrame:SetHeight(height)
|
||||
interruptFrame:SetAllPoints(Gladdy.modules["Class Icon"].frames[unit])
|
||||
|
||||
interruptFrame.cooldown:SetWidth(width - width/16)
|
||||
interruptFrame.cooldown:SetHeight(height - height/16)
|
||||
interruptFrame.cooldown:ClearAllPoints()
|
||||
interruptFrame.cooldown:SetPoint("CENTER", interruptFrame, "CENTER")
|
||||
interruptFrame.cooldown:SetAlpha(Gladdy.db.auraCooldownAlpha)
|
||||
|
||||
interruptFrame.text:SetFont(Gladdy.LSM:Fetch("font", Gladdy.db.auraFont), (width/2 - 1) * Gladdy.db.auraFontSizeScale, "OUTLINE")
|
||||
interruptFrame.text:SetTextColor(Gladdy.db.auraFontColor.r, Gladdy.db.auraFontColor.g, Gladdy.db.auraFontColor.b, Gladdy.db.auraFontColor.a)
|
||||
|
||||
interruptFrame.icon.overlay:SetTexture(Gladdy.db.auraBorderStyle)
|
||||
if interruptFrame.spellSchool then
|
||||
interruptFrame.icon.overlay:SetVertexColor(self:GetInterruptColor(interruptFrame.spellSchool))
|
||||
else
|
||||
interruptFrame.icon.overlay:SetVertexColor(0, 0, 0, 1)
|
||||
end
|
||||
if not interruptFrame.active then
|
||||
interruptFrame.icon.overlay:Hide()
|
||||
end
|
||||
if Gladdy.db.auraDisableCircle then
|
||||
interruptFrame.cooldown:SetAlpha(0)
|
||||
end
|
||||
end
|
||||
|
||||
function Auras:ResetUnit(unit)
|
||||
@ -147,12 +272,14 @@ function Auras:Test(unit)
|
||||
spellName, _, icon = GetSpellInfo(7922)
|
||||
self:AURA_FADE(unit, AURA_TYPE_BUFF)
|
||||
self:AURA_FADE(unit, AURA_TYPE_DEBUFF)
|
||||
self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 7922, spellName, icon, self.auras[spellName].duration + 2, GetTime() + self.auras[spellName].duration + 2)
|
||||
self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 7922, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
|
||||
self:SPELL_INTERRUPT(unit,19244, select(1, GetSpellInfo(19244)), "physical", 25396, select(1, GetSpellInfo(25396)), 64)
|
||||
elseif (unit == "arena2") then
|
||||
spellName, _, icon = GetSpellInfo(6770)
|
||||
self:AURA_FADE(unit, AURA_TYPE_BUFF)
|
||||
self:AURA_FADE(unit,AURA_TYPE_DEBUFF)
|
||||
self:AURA_GAIN(unit,AURA_TYPE_DEBUFF, 6770, spellName, icon, self.auras[spellName].duration, GetTime() + self.auras[spellName].duration)
|
||||
self:SPELL_INTERRUPT(unit,19244, select(1, GetSpellInfo(19244)), "physical", 25396, select(1, GetSpellInfo(25396)), 64)
|
||||
elseif (unit == "arena3") then
|
||||
spellName, _, icon = GetSpellInfo(31224)
|
||||
self:AURA_FADE(unit, AURA_TYPE_BUFF)
|
||||
@ -222,7 +349,7 @@ function Auras:AURA_FADE(unit, auraType)
|
||||
if auraFrame.active then
|
||||
auraFrame.cooldown:SetCooldown(GetTime(), 0)
|
||||
end
|
||||
auraFrame.cooldown:Hide()
|
||||
--auraFrame.cooldown:Hide()
|
||||
auraFrame.active = false
|
||||
auraFrame.name = nil
|
||||
auraFrame.timeLeft = 0
|
||||
@ -231,11 +358,123 @@ function Auras:AURA_FADE(unit, auraType)
|
||||
auraFrame.endTime = nil
|
||||
auraFrame.icon:SetTexture("")
|
||||
auraFrame.text:SetText("")
|
||||
auraFrame.icon.overlay:Hide()
|
||||
auraFrame.cooldownFrame:Hide()
|
||||
--auraFrame.icon.overlay:Hide()
|
||||
--auraFrame.cooldownFrame:Hide()
|
||||
end
|
||||
|
||||
function Auras:GetInterruptColor(extraSpellSchool)
|
||||
if not Gladdy.db.auraInterruptColorsEnabled then
|
||||
return Gladdy.db.auraDebuffBorderColor.r, Gladdy.db.auraDebuffBorderColor.g, Gladdy.db.auraDebuffBorderColor.b, Gladdy.db.auraDebuffBorderColor.a
|
||||
else
|
||||
local color = Gladdy.db.auraInterruptColors[extraSpellSchool] or Gladdy.db.auraInterruptColors["unknown"]
|
||||
return color.r, color.g, color.b, color.a
|
||||
end
|
||||
end
|
||||
|
||||
function Auras:SPELL_INTERRUPT(unit,spellID,spellName,spellSchool,extraSpellId,extraSpellName,extraSpellSchool)
|
||||
local auraFrame = self.frames[unit]
|
||||
local interruptFrame = auraFrame and auraFrame.interruptFrame
|
||||
local button = Gladdy.buttons[unit]
|
||||
if (not interruptFrame) then
|
||||
return
|
||||
end
|
||||
if not Gladdy.db.auraListInterrupts[tostring(Gladdy:GetInterrupts()[spellName].spellID)] or not Gladdy.db.auraListInterrupts[tostring(Gladdy:GetInterrupts()[spellName].spellID)].enabled then
|
||||
return
|
||||
end
|
||||
if (interruptFrame.priority and interruptFrame.priority > Gladdy.db.auraListInterrupts[tostring(Gladdy:GetInterrupts()[spellName].spellID)].priority) then
|
||||
return
|
||||
end
|
||||
local multiplier = ((button.spec == L["Restoration"] and button.class == "SHAMAN") or (button.spec == L["Holy"] and button.class == "PALADIN")) and 0.7 or 1
|
||||
|
||||
local duration = Gladdy:GetInterrupts()[spellName].duration * multiplier
|
||||
|
||||
interruptFrame.startTime = GetTime()
|
||||
interruptFrame.endTime = GetTime() + duration
|
||||
interruptFrame.name = spellName
|
||||
interruptFrame.timeLeft = duration
|
||||
interruptFrame.priority = Gladdy.db.auraListInterrupts[tostring(Gladdy:GetInterrupts()[spellName].spellID)].priority
|
||||
interruptFrame.icon:SetTexture(Gladdy:GetInterrupts()[spellName].texture)
|
||||
interruptFrame.spellSchool = extraSpellSchool
|
||||
interruptFrame.active = true
|
||||
interruptFrame.icon.overlay:Show()
|
||||
interruptFrame.cooldownFrame:Show()
|
||||
|
||||
interruptFrame.icon.overlay:SetVertexColor(self:GetInterruptColor(extraSpellSchool))
|
||||
|
||||
if not Gladdy.db.auraDisableCircle then
|
||||
interruptFrame.cooldown:Show()
|
||||
interruptFrame.cooldown:SetCooldown(interruptFrame.startTime, duration)
|
||||
end
|
||||
--interruptFrame:SetAlpha(1)
|
||||
end
|
||||
|
||||
function Auras:GetOptions()
|
||||
local borderArgs = {
|
||||
headerAuras = {
|
||||
type = "header",
|
||||
name = L["Border"],
|
||||
order = 2,
|
||||
},
|
||||
auraBorderStyle = Gladdy:option({
|
||||
type = "select",
|
||||
name = L["Border style"],
|
||||
order = 9,
|
||||
values = Gladdy:GetIconStyles(),
|
||||
}),
|
||||
auraBuffBorderColor = Gladdy:colorOption({
|
||||
type = "color",
|
||||
name = L["Buff color"],
|
||||
desc = L["Color of the text"],
|
||||
order = 10,
|
||||
hasAlpha = true,
|
||||
width = "0.8",
|
||||
}),
|
||||
auraDebuffBorderColor = Gladdy:colorOption({
|
||||
type = "color",
|
||||
name = L["Debuff color"],
|
||||
desc = L["Color of the text"],
|
||||
order = 11,
|
||||
hasAlpha = true,
|
||||
width = "0.8",
|
||||
}),
|
||||
headerColors = {
|
||||
type = "header",
|
||||
name = L["Interrupt Spells School Colors"],
|
||||
order = 12,
|
||||
},
|
||||
auraInterruptColorsEnabled = Gladdy:option({
|
||||
type = "toggle",
|
||||
name = L["Enable Interrupt Spell School Colors"],
|
||||
width = "full",
|
||||
desc = L["Will use Debuff Color if disabled"],
|
||||
order = 13,
|
||||
}),
|
||||
}
|
||||
local list = {}
|
||||
for k,v in pairs(Gladdy:GetSpellSchoolColors()) do
|
||||
tinsert(list, { key = k, val = v})
|
||||
end
|
||||
tbl_sort(list, function(a, b) return a.val.type < b.val.type end)
|
||||
for i,v in ipairs(list) do
|
||||
borderArgs["auraSpellSchool" .. v.key] = {
|
||||
type = "color",
|
||||
name = v.val.type,
|
||||
order = i + 13,
|
||||
hasAlpha = true,
|
||||
width = "0.8",
|
||||
set = function(info, r, g, b, a)
|
||||
Gladdy.db.auraInterruptColors[v.key].r = r
|
||||
Gladdy.db.auraInterruptColors[v.key].g = g
|
||||
Gladdy.db.auraInterruptColors[v.key].b = b
|
||||
Gladdy.db.auraInterruptColors[v.key].a = a
|
||||
end,
|
||||
get = function()
|
||||
local color = Gladdy.db.auraInterruptColors[v.key]
|
||||
return color.r, color.g, color.b, color.a
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
header = {
|
||||
type = "header",
|
||||
@ -316,35 +555,7 @@ function Auras:GetOptions()
|
||||
type = "group",
|
||||
name = L["Border"],
|
||||
order = 3,
|
||||
args = {
|
||||
headerAuras = {
|
||||
type = "header",
|
||||
name = L["Border"],
|
||||
order = 2,
|
||||
},
|
||||
auraBorderStyle = Gladdy:option({
|
||||
type = "select",
|
||||
name = L["Border style"],
|
||||
order = 9,
|
||||
values = Gladdy:GetIconStyles(),
|
||||
}),
|
||||
auraBuffBorderColor = Gladdy:colorOption({
|
||||
type = "color",
|
||||
name = L["Buff color"],
|
||||
desc = L["Color of the text"],
|
||||
order = 10,
|
||||
hasAlpha = true,
|
||||
width = "0.8",
|
||||
}),
|
||||
auraDebuffBorderColor = Gladdy:colorOption({
|
||||
type = "color",
|
||||
name = L["Debuff color"],
|
||||
desc = L["Color of the text"],
|
||||
order = 11,
|
||||
hasAlpha = true,
|
||||
width = "0.8",
|
||||
}),
|
||||
}
|
||||
args = borderArgs
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -361,6 +572,13 @@ function Auras:GetOptions()
|
||||
name = "Buffs",
|
||||
order = 5,
|
||||
args = Auras:GetAuraOptions(AURA_TYPE_BUFF)
|
||||
},
|
||||
interruptList = {
|
||||
type = "group",
|
||||
childGroups = "tree",
|
||||
name = "Interrupts",
|
||||
order = 6,
|
||||
args = Auras:GetInterruptOptions()
|
||||
}
|
||||
}
|
||||
end
|
||||
@ -440,4 +658,79 @@ function Auras:GetAuraOptions(auraType)
|
||||
}
|
||||
end
|
||||
return options
|
||||
end
|
||||
|
||||
function Auras:GetInterruptOptions()
|
||||
local options = {
|
||||
ckeckAll = {
|
||||
order = 1,
|
||||
width = "0.7",
|
||||
name = L["Check All"],
|
||||
type = "execute",
|
||||
func = function(info)
|
||||
for k,v in pairs(defaultInterrupts()) do
|
||||
Gladdy.db.auraListInterrupts[k].enabled = true
|
||||
end
|
||||
end,
|
||||
},
|
||||
uncheckAll = {
|
||||
order = 2,
|
||||
width = "0.7",
|
||||
name = L["Uncheck All"],
|
||||
type = "execute",
|
||||
func = function(info)
|
||||
for k,v in pairs(defaultInterrupts()) do
|
||||
Gladdy.db.auraListInterrupts[k].enabled = false
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
local auras = {}
|
||||
for k,v in pairs(Gladdy:GetInterrupts()) do
|
||||
tinsert(auras, v.spellID)
|
||||
end
|
||||
tbl_sort(auras, function(a, b) return GetSpellInfo(a) < GetSpellInfo(b) end)
|
||||
for i,k in ipairs(auras) do
|
||||
options[tostring(k)] = {
|
||||
type = "group",
|
||||
name = Gladdy:GetInterrupts()["Unstable Affliction Silence"]
|
||||
and Gladdy:GetInterrupts()["Unstable Affliction Silence"].spellID == k
|
||||
and Gladdy:GetInterrupts()["Unstable Affliction Silence"].altName
|
||||
or GetSpellInfo(k),
|
||||
order = i+2,
|
||||
icon = Gladdy:GetInterrupts()[GetSpellInfo(k)] and Gladdy:GetInterrupts()[GetSpellInfo(k)].texture or select(3, GetSpellInfo(k)),
|
||||
args = {
|
||||
enabled = {
|
||||
order = 1,
|
||||
name = L["Enabled"],
|
||||
type = "toggle",
|
||||
image = Gladdy:GetInterrupts()[GetSpellInfo(k)] and Gladdy:GetInterrupts()[GetSpellInfo(k)].texture or select(3, GetSpellInfo(k)),
|
||||
width = "2",
|
||||
set = function(info, value)
|
||||
Gladdy.db.auraListInterrupts[tostring(k)].enabled = value
|
||||
end,
|
||||
get = function(info)
|
||||
return Gladdy.db.auraListInterrupts[tostring(k)].enabled
|
||||
end
|
||||
},
|
||||
priority = {
|
||||
order = 2,
|
||||
name = L["Priority"],
|
||||
type = "range",
|
||||
min = 0,
|
||||
max = 50,
|
||||
width = "2",
|
||||
step = 1,
|
||||
get = function(info)
|
||||
return Gladdy.db.auraListInterrupts[tostring(k)].priority
|
||||
end,
|
||||
set = function(info, value)
|
||||
Gladdy.db.auraListInterrupts[tostring(k)].priority = value
|
||||
end,
|
||||
width = "full",
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
return options
|
||||
end
|
Reference in New Issue
Block a user