Commit 2a3283bc authored by Blazeflack's avatar Blazeflack
Browse files

Simplified actionbar desaturation code

parent a5e92f04
......@@ -1128,19 +1128,8 @@ function AB:LAB_ButtonUpdate(button)
end
LAB.RegisterCallback(AB, "OnButtonUpdate", AB.LAB_ButtonUpdate)
local cStart, cDuration, cLeft
local function GetCooldownLeft(button)
cStart, cDuration = button:GetCooldown()
cLeft = (cStart + cDuration - GetTime())
return cLeft
end
local function DelayedSaturate(button)
--We probably need to check cooldown here again just in case something
--caused the action to come off cooldown early and we then activated it again
if GetCooldownLeft(button) <= 0.1 then --Allow some wiggle room
button.icon:SetDesaturated(false)
end
local function Saturate(cooldown)
cooldown:GetParent().icon:SetDesaturated(false)
end
local function OnCooldownUpdate(_, button, start, duration)
......@@ -1150,10 +1139,11 @@ local function OnCooldownUpdate(_, button, start, duration)
button.saturationLocked = true --Lock any new actions that are created after we activated desaturation option
button.icon:SetDesaturated(true)
--Calculate when the cooldown is finished and manually trigger an update then
E:Delay(GetCooldownLeft(button), DelayedSaturate, button)
else
button.icon:SetDesaturated(false)
--Hook cooldown done and add colors back
if not button.onCooldownDoneHooked then
button.onCooldownDoneHooked = true
AB:HookScript(button.cooldown, "OnCooldownDone", Saturate)
end
end
end
......@@ -1173,6 +1163,10 @@ function AB:ToggleDesaturation(value)
for button in pairs(LAB.actionButtons) do
button.saturationLocked = nil
button.icon:SetDesaturated(false)
if button.onCooldownDoneHooked then
AB:Unhook(button.cooldown, "OnCooldownDone")
button.onCooldownDoneHooked = nil
end
end
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment