a0c279f - Fix action button glow
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 17 Feb 2018 00:46:17 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Sat, 17 Feb 2018 00:46:17 +0000
OmaAB/ActionBars.lua

index 50a88b6..729ac4f 100644 (file)
@@ -232,22 +232,14 @@ local function updateState(button, slot)
     button:SetChecked(IsCurrentAction(slot) or IsAutoRepeatAction(slot));
 end
 
-local function updateGlow(button, slot, spell, hide)
+local function updateGlow(button, slot)
     local stype, id, _ = GetActionInfo(slot);
-    if stype == "spell" and (spell and id == spell or IsSpellOverlayed(id)) then
-        if hide then
-            button.glow:Hide();
-        else
-            button.glow:Show();
-        end
+    if stype == "spell" and IsSpellOverlayed(id) then
+        button.glow:Show();
     elseif stype == "macro" then
         local _, _, macroid = GetMacroSpell(id);
-        if macroid and (spell and macroid == spell or IsSpellOverlayed(macroid)) then
-            if hide then
-                button.glow:Hide();
-            else
-                button.glow:Show();
-            end
+        if macroid and IsSpellOverlayed(macroid) then
+            button.glow:Show();
         else
             button.glow:Hide();
         end
@@ -256,6 +248,32 @@ local function updateGlow(button, slot, spell, hide)
     end
 end
 
+local function startGlow(button, slot, spell)
+    local stype, id, _ = GetActionInfo(slot);
+    if stype == "spell" and id == spell then
+        button.glow:Show();
+    elseif stype == "macro" then
+        local _, _, macroid = GetMacroSpell(id);
+        if macroid and macroid == spell then
+            button.glow:Show();
+        end
+    end
+    -- TODO FlyoutHasSpell glow
+end
+
+local function stopGlow(button, slot, spell)
+    local stype, id, _ = GetActionInfo(slot);
+    if stype == "spell" and id == spell then
+        button.glow:Hide();
+    elseif stype == "macro" then
+        local _, _, macroid = GetMacroSpell(id);
+        if macroid and macroid == spell then
+            button.glow:Hide();
+        end
+    end
+    -- TODO FlyoutHasSpell glow
+end
+
 local function updateButton(button, slot)
     if HasAction(slot) then
         activeButtons[slot] = button;
@@ -458,8 +476,8 @@ local function createActionBar(parent, config)
         secure.autocastable:Hide();
         secure.glow = secure:CreateTexture(nil, "OVERLAY", nil, 1);
         secure.glow:SetPoint("CENTER");
-        secure.glow:SetWidth(config.size and config.size+20 or 52);
-        secure.glow:SetHeight(config.size and config.size+20 or 52);
+        secure.glow:SetWidth(config.size and config.size+26 or 53);
+        secure.glow:SetHeight(config.size and config.size+26 or 53);
         secure.glow:SetTexture("Interface\\SpellActivationOverlay\\IconAlert");
         secure.glow:SetTexCoord(0.00781250, 0.50781250, 0.27734375, 0.52634375);
         secure.glow:Hide();
@@ -594,17 +612,13 @@ local events = {
     ["SPELL_ACTIVATION_OVERLAY_GLOW_SHOW"] = function(spell)
         -- TODO create mapping from spellIDs to buttons
         for _, button in pairs(activeButtons) do
-            updateGlow(button, button.slot, spell);
-            -- CD update might be throttled, force it
-            updateCooldown(button, button.slot);
+            startGlow(button, button.slot, spell);
         end
     end,
     ["SPELL_ACTIVATION_OVERLAY_GLOW_HIDE"] = function(spell)
         -- TODO create mapping from spellIDs to buttons
         for _, button in pairs(activeButtons) do
-            updateGlow(button, button.slot, spell, true);
-            -- CD update might be throttled, force it
-            updateCooldown(button, button.slot);
+            stopGlow(button, button.slot, spell);
         end
     end,
     ["UPDATE_BINDINGS"] = function()
@@ -656,7 +670,6 @@ events["UNIT_ENTERED_VEHICLE"] = function(unit)
     if unit == "player" then events["ACTIONBAR_UPDATE_STATE"]() end
 end
 events["UNIT_EXITED_VEHICLE"] = events["UNIT_ENTERED_VEHICLE"];
--- TODO overlay glow ? don't exactly know what it does, proc highlight?
 -- tooltips
 
 ActionBars:RegisterEvent("ADDON_LOADED");