cooldown change to PixelGlow

This commit is contained in:
Sumsebrum 2022-08-17 14:22:05 +02:00
parent d385692cdc
commit 8e97bb32c6

View File

@ -60,6 +60,7 @@ local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
cooldownXOffset = 0, cooldownXOffset = 0,
cooldownSize = 30, cooldownSize = 30,
cooldownIconGlow = true, cooldownIconGlow = true,
cooldownIconGlowColor = {r = 0.95, g = 0.95, b = 0.32, a = 1},
cooldownIconZoomed = false, cooldownIconZoomed = false,
cooldownIconDesaturateOnCooldown = false, cooldownIconDesaturateOnCooldown = false,
cooldownIconAlphaOnCooldown = 1, cooldownIconAlphaOnCooldown = 1,
@ -153,6 +154,9 @@ function Cooldowns:CreateIcon()
icon.cooldownFont = icon.cooldownFrame:CreateFontString(nil, "OVERLAY") icon.cooldownFont = icon.cooldownFrame:CreateFontString(nil, "OVERLAY")
icon.cooldownFont:SetAllPoints(icon) icon.cooldownFont:SetAllPoints(icon)
icon.glow = CreateFrame("Frame", nil, icon)
icon.glow:SetAllPoints(icon)
self:UpdateIcon(icon) self:UpdateIcon(icon)
end end
return icon return icon
@ -165,6 +169,8 @@ function Cooldowns:UpdateIcon(icon)
icon.cooldown:SetFrameLevel(Gladdy.db.cooldownFrameLevel + 1) icon.cooldown:SetFrameLevel(Gladdy.db.cooldownFrameLevel + 1)
icon.cooldownFrame:SetFrameStrata(Gladdy.db.cooldownFrameStrata) icon.cooldownFrame:SetFrameStrata(Gladdy.db.cooldownFrameStrata)
icon.cooldownFrame:SetFrameLevel(Gladdy.db.cooldownFrameLevel + 2) icon.cooldownFrame:SetFrameLevel(Gladdy.db.cooldownFrameLevel + 2)
icon.glow:SetFrameStrata(Gladdy.db.cooldownFrameStrata)
icon.glow:SetFrameLevel(Gladdy.db.cooldownFrameLevel + 3)
icon:SetHeight(Gladdy.db.cooldownSize) icon:SetHeight(Gladdy.db.cooldownSize)
icon:SetWidth(Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor) icon:SetWidth(Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor)
@ -212,6 +218,9 @@ function Cooldowns:UpdateIcon(icon)
else else
icon.texture:SetAlpha(1) icon.texture:SetAlpha(1)
end end
if icon.timer and not icon.timer:IsCancelled() then
LCG.PixelGlow_Start(icon.glow, Gladdy:ColorAsArray(Gladdy.db.cooldownIconGlowColor), 12, 0.15, nil, 2)
end
end end
function Cooldowns:IconsSetPoint(button) function Cooldowns:IconsSetPoint(button)
@ -337,6 +346,11 @@ function Cooldowns:ClearIcon(button, index, spellId, icon)
end end
end end
end end
icon:Show()
LCG:PixelGlow_Stop(icon.glow)
if icon.timer then
icon.timer:Cancel()
end
icon:ClearAllPoints() icon:ClearAllPoints()
icon:SetParent(nil) icon:SetParent(nil)
icon:Hide() icon:Hide()
@ -345,7 +359,6 @@ function Cooldowns:ClearIcon(button, index, spellId, icon)
icon.cooldown:Hide() icon.cooldown:Hide()
icon.cooldownFont:SetText("") icon.cooldownFont:SetText("")
icon:SetScript("OnUpdate", nil) icon:SetScript("OnUpdate", nil)
LCG:ButtonGlow_Stop(icon)
tinsert(self.iconCache, icon) tinsert(self.iconCache, icon)
end end
@ -357,7 +370,7 @@ function Cooldowns:Test(unit)
if Gladdy.frame.testing then if Gladdy.frame.testing then
self:UpdateTestCooldowns(unit) self:UpdateTestCooldowns(unit)
end end
Cooldowns:AURA_GAIN(_, AURA_TYPE_BUFF, "22812", "Barkskin", _, 20, _, _, _, _, unit, true) Cooldowns:AURA_GAIN(_, AURA_TYPE_BUFF, 22812, "Barkskin", _, 20, _, _, _, _, unit, true)
end end
function Cooldowns:UpdateTestCooldowns(unit) function Cooldowns:UpdateTestCooldowns(unit)
@ -403,7 +416,7 @@ end
function Cooldowns:AURA_GAIN(_, auraType, spellID, spellName, _, duration, _, _, _, _, unitCaster, test) function Cooldowns:AURA_GAIN(_, auraType, spellID, spellName, _, duration, _, _, _, _, unitCaster, test)
local arenaUnit = test and unitCaster or Gladdy:GetArenaUnit(unitCaster, true) local arenaUnit = test and unitCaster or Gladdy:GetArenaUnit(unitCaster, true)
if not Gladdy.db.cooldownIconGlow or not arenaUnit or not Gladdy.buttons[arenaUnit] or auraType ~= AURA_TYPE_BUFF then if not Gladdy.db.cooldownIconGlow or not arenaUnit or not Gladdy.buttons[arenaUnit] or auraType ~= AURA_TYPE_BUFF or spellID == 26889 then
return return
end end
local cooldownFrame = Gladdy.buttons[arenaUnit].spellCooldownFrame local cooldownFrame = Gladdy.buttons[arenaUnit].spellCooldownFrame
@ -415,16 +428,21 @@ function Cooldowns:AURA_GAIN(_, auraType, spellID, spellName, _, duration, _, _,
for _,icon in pairs(cooldownFrame.icons) do for _,icon in pairs(cooldownFrame.icons) do
if (icon.spellId == spellId) then if (icon.spellId == spellId) then
if icon._ButtonGlow and not icon._ButtonGlow.animIn:IsPlaying() or not icon._ButtonGlow then Gladdy:Debug("INFO", "Cooldowns:AURA_GAIN", "PixelGlow_Start", spellID)
LCG.ButtonGlow_Start(icon, nil, 0.15) LCG.PixelGlow_Start(icon.glow, Gladdy:ColorAsArray(Gladdy.db.cooldownIconGlowColor), 12, 0.15, nil, 2)
icon.timer = C_Timer.NewTimer(duration, function() LCG.ButtonGlow_Stop(icon) end) if icon.timer then
icon.timer:Cancel()
end end
icon.timer = C_Timer.NewTimer(duration, function()
LCG.PixelGlow_Stop(icon.glow)
icon.timer:Cancel()
end)
end end
end end
end end
function Cooldowns:AURA_FADE(unit, spellID) function Cooldowns:AURA_FADE(unit, spellID)
if not Gladdy.buttons[unit] then if not Gladdy.buttons[unit] or Gladdy.buttons[unit].stealthed then
return return
end end
local cooldownFrame = Gladdy.buttons[unit].spellCooldownFrame local cooldownFrame = Gladdy.buttons[unit].spellCooldownFrame
@ -434,7 +452,7 @@ function Cooldowns:AURA_FADE(unit, spellID)
if icon.timer then if icon.timer then
icon.timer:Cancel() icon.timer:Cancel()
end end
LCG.ButtonGlow_Stop(icon) LCG.PixelGlow_Stop(icon.glow)
end end
end end
end end
@ -507,7 +525,7 @@ local function resetIcon(icon)
if icon.timer then if icon.timer then
icon.timer:Cancel() icon.timer:Cancel()
end end
--LCG.ButtonGlow_Stop(icon) LCG.PixelGlow_Stop(icon.glow)
end end
function Cooldowns:CooldownReady(button, spellId, frame) function Cooldowns:CooldownReady(button, spellId, frame)
@ -739,17 +757,10 @@ function Cooldowns:GetOptions()
name = L["Cooldown"], name = L["Cooldown"],
order = 2, order = 2,
}, },
cooldownIconGlow = Gladdy:option({
type = "toggle",
name = L["Glow Icon"],
desc = L["Glow the icon when cooldown active"],
order = 3,
width = "full",
}),
cooldownIconDesaturateOnCooldown = Gladdy:option({ cooldownIconDesaturateOnCooldown = Gladdy:option({
type = "toggle", type = "toggle",
name = L["Desaturate Icon"], name = L["Desaturate Icon"],
order = 4, order = 5,
width = "full", width = "full",
}), }),
cooldownIconAlphaOnCooldown = Gladdy:option({ cooldownIconAlphaOnCooldown = Gladdy:option({
@ -757,7 +768,7 @@ function Cooldowns:GetOptions()
name = L["Cooldown alpha on CD"], name = L["Cooldown alpha on CD"],
desc = L["Alpha of the icon when cooldown active"], desc = L["Alpha of the icon when cooldown active"],
desc = L["changes "], desc = L["changes "],
order = 5, order = 6,
min = 0, min = 0,
max = 1, max = 1,
step = 0.1, step = 0.1,
@ -766,12 +777,12 @@ function Cooldowns:GetOptions()
headerCircle = { headerCircle = {
type = "header", type = "header",
name = L["Cooldowncircle"], name = L["Cooldowncircle"],
order = 6, order = 10,
}, },
cooldownDisableCircle = Gladdy:option({ cooldownDisableCircle = Gladdy:option({
type = "toggle", type = "toggle",
name = L["No Cooldown Circle"], name = L["No Cooldown Circle"],
order = 8, order = 11,
width = "full", width = "full",
}), }),
cooldownCooldownAlpha = Gladdy:option({ cooldownCooldownAlpha = Gladdy:option({
@ -780,7 +791,7 @@ function Cooldowns:GetOptions()
min = 0, min = 0,
max = 1, max = 1,
step = 0.1, step = 0.1,
order = 9, order = 12,
width = "full", width = "full",
}), }),
cooldownCooldownNumberAlpha = { cooldownCooldownNumberAlpha = {
@ -789,7 +800,7 @@ function Cooldowns:GetOptions()
min = 0, min = 0,
max = 1, max = 1,
step = 0.1, step = 0.1,
order = 10, order = 13,
width = "full", width = "full",
set = function(info, value) set = function(info, value)
Gladdy.db.cooldownFontColor.a = value Gladdy.db.cooldownFontColor.a = value
@ -801,10 +812,48 @@ function Cooldowns:GetOptions()
}, },
}, },
}, },
glow = {
type = "group",
name = L["Glow"],
order = 3,
args = {
header = {
type = "header",
name = L["Glow"],
order = 1,
},
cooldownIconGlow = Gladdy:option({
type = "toggle",
name = L["Glow Icon"],
desc = L["Glow the icon when cooldown active"],
order = 2,
width = "full",
}),
cooldownIconGlowColor = Gladdy:colorOption({
disabled = function() return not Gladdy.db.cooldownIconGlow end,
type = "color",
hasAlpha = true,
name = L["Glow color"],
desc = L["Color of the glow"],
order = 3,
width = "full",
}),
resetGlow = {
type = "execute",
name = L["Reset Glow"],
desc = L["Reset Glow Color"],
func = function()
Gladdy.db.cooldownIconGlowColor = {r = 0.95, g = 0.95, b = 0.32, a = 1}
Gladdy:UpdateFrame()
end,
order = 3,
}
},
},
font = { font = {
type = "group", type = "group",
name = L["Font"], name = L["Font"],
order = 3, order = 4,
args = { args = {
header = { header = {
type = "header", type = "header",
@ -841,7 +890,7 @@ function Cooldowns:GetOptions()
position = { position = {
type = "group", type = "group",
name = L["Position"], name = L["Position"],
order = 5, order = 6,
args = { args = {
header = { header = {
type = "header", type = "header",
@ -905,7 +954,7 @@ function Cooldowns:GetOptions()
border = { border = {
type = "group", type = "group",
name = L["Border"], name = L["Border"],
order = 4, order = 5,
args = { args = {
header = { header = {
type = "header", type = "header",
@ -930,7 +979,7 @@ function Cooldowns:GetOptions()
frameStrata = { frameStrata = {
type = "group", type = "group",
name = L["Frame Strata and Level"], name = L["Frame Strata and Level"],
order = 6, order = 7,
args = { args = {
headerAuraLevel = { headerAuraLevel = {
type = "header", type = "header",