578ca7c - Most action bar functionality completed
authorAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Tue, 13 Feb 2018 22:12:33 +0000
committerAleksi Blinnikka <aleksi.blinnikka@gmail.com>
Tue, 13 Feb 2018 22:12:33 +0000
Tooltips to be done, otherwise essentially done

OmaAB/ActionBars.lua
OmaAB/BagBar.txt [new file with mode: 0644]
OmaAB/Bindings.xml [new file with mode: 0644]
OmaAB/OmaAB.toc

index 95d326e..50a88b6 100644 (file)
@@ -1,13 +1,18 @@
 -- ActionBars.lua
 local _;
 local pairs = pairs;
-local GetActionTexture = GetActionTexture;
+local format = string.format;
+local ssub = string.sub;
+local GetActionInfo, GetActionTexture = GetActionInfo, GetActionTexture;
 local GetActionLossOfControlCooldown = GetActionLossOfControlCooldown;
 local GetActionCooldown, GetActionCharges = GetActionCooldown, GetActionCharges;
 local IsConsumableAction, IsStackableAction = IsConsumableAction, IsStackableAction;
 local IsItemAction, GetActionCount = IsItemAction, GetActionCount;
+local IsSpellOverlayed, GetMacroSpell = IsSpellOverlayed, GetMacroSpell;
+local IsMounted = IsMounted;
 local HasAction, IsUsableAction = HasAction, IsUsableAction;
 local IsCurrentAction, IsAutoRepeatAction = IsCurrentAction, IsAutoRepeatAction;
+local CreateFrame = CreateFrame;
 local RegisterStateDriver = RegisterStateDriver;
 local CooldownFrame_Set, CooldownFrame_Clear = CooldownFrame_Set, CooldownFrame_Clear;
 local CTimerAfter = C_Timer.After;
@@ -17,64 +22,85 @@ local COOLDOWN_TYPE_NORMAL = COOLDOWN_TYPE_NORMAL;
 local CDTexture = "Interface\\Cooldown\\edge";
 local locCDTexture = "Interface\\Cooldown\\edge-LoC";
 
-local BUTTONLOCK = false; -- change to lock button dragging
+local BUTTONLOCK = true; -- change to lock button dragging
 
 local settings = {
-    ["OmaBT1"] = {
+    ["Oma1"] = {
+        bar = 1,
         start = 1,
         length = 12,
-        x = 1000,
-        y = 1000,
+        columns = 4,
+        size = 40,
+        x = 580,
+        y = 300,
+        nomouse = true,
     },
-    ["OmaBT2"] = {
+    ["Oma2"] = {
+        bar = 2,
         start = 13,
         length = 12,
-        x = 1000,
-        y = 960,
+        columns = 4,
+        size = 40,
+        x = 580,
+        y = 180,
+        nomouse = true,
     },
-    ["OmaBT3"] = {
+    ["Oma3"] = {
+        bar = 3,
         start = 25,
         length = 12,
-        x = 1000,
-        y = 920,
+        columns = 3,
+        x = 1824,
+        y = 128,
+        flyout = "LEFT",
     },
-    ["OmaBT4"] = {
+    ["Oma4"] = {
+        bar = 4,
         start = 37,
         length = 12,
-        x = 1000,
-        y = 880,
+        columns = 3,
+        x = 1824,
+        y = 256,
     },
-    ["OmaBT5"] = {
+    ["Oma5"] = {
+        bar = 5,
         start = 49,
         length = 12,
+        columns = 3,
         x = 1000,
         y = 840,
     },
-    ["OmaBT6"] = {
+    ["Oma6"] = {
+        bar = 6,
         start = 61,
         length = 12,
         x = 1000,
-        y = 800,
+        y = 600,
     },
-    ["OmaBT7"] = {
+    -- used as bonus bars for some classes
+    ["Oma7"] = {
+        bar = 7,
         start = 73,
         length = 12,
         x = 1000,
         y = 760,
     },
-    ["OmaBT8"] = {
+    ["Oma8"] = {
+        bar = 8,
         start = 85,
         length = 12,
         x = 1000,
         y = 720,
     },
-    ["OmaBT9"] = {
+    ["Oma9"] = {
+        bar = 9,
         start = 97,
         length = 12,
         x = 1000,
         y = 680,
     },
-    ["OmaBT10"] = {
+    ["Oma10"] = {
+        bar = 10,
         start = 109,
         length = 12,
         x = 1000,
@@ -82,11 +108,27 @@ local settings = {
     },
 };
 
+local usingBonusbars = {
+    --["WARRIOR"] = {[7]=true, [8]=true, [9]=true}, -- not using stance separated actionbars
+    ["DRUID"] = {[7]=true, [8]=true, [9]=true}, -- moonkin form page is usable anyway
+    --["DRUID"] = {[7]=true, [8]=true, [9]=true,[10]=true},
+    ["ROGUE"] = {[7]=true},
+    --["PRIEST"] = {[7]=true}, -- shadowform doesn't change abilities
+};
+
+local chars = {
+    ["Stormreaver"] = {
+        ["Vildan"] = {1, 2, 3, 4,},
+        ["Gedren"] = {1, 2, 3, 4,},
+    },
+};
+
 local buttons = {};
 local activeButtons = {};
 
 local ActionBars = CreateFrame("Frame", "OmaActionBars", UIParent);
-local inheritedFrames = "SecureActionButtonTemplate,SecureHandlerDragTemplate,SecureHandlerStateTemplate";
+local inheritedFrames =
+"SecureActionButtonTemplate,SecureHandlerDragTemplate,SecureHandlerStateTemplate";
 
 local numChargeCDs = 0;
 local function createChargeCD(parent)
@@ -163,12 +205,14 @@ local function updateCount(button, slot)
         else
             button.count:SetText(count);
         end
+        button.count:Show();
     else
         local charges, maxcharges = GetActionCharges(slot);
         if maxcharges > 1 then
             button.count:SetText(charges);
+            button.count:Show();
         else
-            button.count:SetText("");
+            button.count:Hide();
         end
     end
 end
@@ -185,10 +229,30 @@ local function updateUsable(button, slot)
 end
 
 local function updateState(button, slot)
-    if IsCurrentAction(slot) or IsAutoRepeatAction(slot) then
-        button:SetChecked(true);
-    else
-        button:SetChecked(false);
+    button:SetChecked(IsCurrentAction(slot) or IsAutoRepeatAction(slot));
+end
+
+local function updateGlow(button, slot, spell, hide)
+    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
+    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
+        else
+            button.glow:Hide();
+        end
+    else -- TODO FlyoutHasSpell glow
+        button.glow:Hide();
     end
 end
 
@@ -201,22 +265,166 @@ local function updateButton(button, slot)
         updateUsable(button, slot);
         updateState(button, slot);
         updateCount(button, slot);
+        updateGlow(button, slot);
+        if not IsConsumableAction(slot) and not IsStackableAction(slot) then
+            button.text:SetText(ssub(GetActionText(slot) or "", 1, 4));
+            button.text:Show();
+        end
+        if button.hotkey.shown then button.hotkey:Show() end
     else
         activeButtons[slot] = nil;
         if not button.grid then button.base:Hide() end
         button.icon:SetTexture(nil);
         button.cd:Hide();
-        button.count:SetText("");
+        button.count:Hide();
+        button.hotkey:Hide();
+        button.text:Hide();
+        button.glow:Hide();
+        button:SetChecked(false);
     end
 end
 
-local function createActionBar(parent, name, config)
+local function updateHotkeys(button)
+    local key = GetBindingKey(format("CLICK %s:LeftButton", button:GetName()));
+    if key and key ~= "" then
+        -- from LibKeyBound-1.0
+        key = key:upper();
+        key = key:gsub(" ", "");
+        key = key:gsub("ALT%-", "a");
+        key = key:gsub("CTRL%-", "c");
+        key = key:gsub("SHIFT%-", "s");
+        key = key:gsub("NUMPAD", "n");
+        button.hotkey:SetText(key);
+        button.hotkey.shown = true;
+        button.hotkey:Show();
+    else
+        button.hotkey.shown = nil;
+        button.hotkey:Hide();
+    end
+end
+
+local mainbartoggle = "[overridebar][possessbar][shapeshift]possess;";
+mainbartoggle = mainbartoggle.."[bonusbar:1,stealth:1]bonusbar2;"; -- prowl
+mainbartoggle = mainbartoggle.."[bonusbar:1]bonusbar1;[bonusbar:2]bonusbar2;"; -- cat form, unused
+mainbartoggle = mainbartoggle.."[bonusbar:3]bonusbar3;[bonusbar:4]bonusbar4;"; -- bear form, moonkin form
+mainbartoggle = mainbartoggle.."normal";
+local function setupSnippets(secure, slot)
+    -- FrameXML/SecureHandlers.lua has arguments and return value
+    -- args: self, button, kind, value, ... (kind, value, ... from GetCursorInfo())
+    -- returns: kind, target, detail
+    -- or: "clear", kind, target, detail
+    -- used for Pickup* functions
+    -- some of these snippets based on LibActionButton-1.0
+    secure:SetAttribute("_ondragstart", [=[
+        return "action", self:GetAttribute("action");
+    ]=]);
+    secure:SetAttribute("_onreceivedrag", [=[
+        if not kind or not value then return nil end
+        return "action", self:GetAttribute("action");
+    ]=]);
+    -- pre-wrapper can pass a message to post-wrapper
+    secure:WrapScript(secure, "OnDragStart", [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        return "message", format("%s|%s", tostring(kind), tostring(value));
+    ]=], [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+            self:CallMethod("ActionChanged");
+        end
+    ]=]);
+    secure:WrapScript(secure, "OnReceiveDrag", [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        return "message", format("%s|%s", tostring(kind), tostring(value));
+    ]=], [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+            self:CallMethod("ActionChanged");
+        end
+    ]=]);
+    function secure:UpdateState()
+        return updateState(self, self.slot);
+    end
+    secure:WrapScript(secure, "OnClick", [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        return nil, format("%s|%s", tostring(kind), tostring(value));
+    ]=], [=[
+        local kind, value = GetActionInfo(self:GetAttribute("action"));
+        if message ~= format("%s|%s", tostring(kind), tostring(value)) then
+            self:CallMethod("ActionChanged");
+        else
+            self:CallMethod("UpdateState");
+        end
+    ]=]);
+    if slot < 13 then
+        -- first action bar has possible states based on vehicle/possess etc.
+        secure:SetAttribute("origaction", slot);
+        secure:SetAttribute("_onstate-possess", [=[
+            local oldslot = self:GetAttribute("action");
+            if newstate == "possess" then
+                local slot;
+                if HasVehicleActionBar() then
+                    slot = (GetVehicleBarIndex()-1)*12+self:GetAttribute("origaction");
+                elseif HasOverrideActionBar() then
+                    slot = (GetOverrideBarIndex()-1)*12+self:GetAttribute("origaction");
+                elseif HasTempShapeshiftActionBar() then
+                    slot = (GetTempShapeshiftBarIndex()-1)*12+self:GetAttribute("origaction");
+                else
+                    -- something wrong, just revert to normal
+                    print("Possess bar index not found");
+                    slot = self:GetAttribute("origaction");
+                end
+                self:SetAttribute("action", slot);
+            elseif newstate == "bonusbar1" then
+                self:SetAttribute("action", 72+self:GetAttribute("origaction"));
+            elseif newstate == "bonusbar2" then
+                self:SetAttribute("action", 84+self:GetAttribute("origaction"));
+            elseif newstate == "bonusbar3" then
+                self:SetAttribute("action", 96+self:GetAttribute("origaction"));
+            elseif newstate == "bonusbar4" then
+                --self:SetAttribute("action", 108+self:GetAttribute("origaction"));
+                -- moonkin form, don't change actionbar
+                self:SetAttribute("action", self:GetAttribute("origaction"));
+            else
+                self:SetAttribute("action", self:GetAttribute("origaction"));
+            end
+            self:CallMethod("ActionChanged", oldslot);
+        ]=]);
+        RegisterStateDriver(secure, "possess", mainbartoggle);
+    else
+        function secure:ShowButton() if HasAction(slot) then activeButtons[slot] = self end end
+        function secure:HideButton() activeButtons[slot] = nil end
+        -- all other action bar are hidden if with overridebar or vehicleui (not shapeshift, possessbar)
+        -- default Bartender4 options
+        secure:SetAttribute("_onstate-possess", [=[
+            if newstate == "possess" then
+                self:Hide();
+                self:CallMethod("HideButton");
+            else
+                self:Show();
+                self:CallMethod("ShowButton");
+            end
+        ]=]);
+        RegisterStateDriver(secure, "possess", "[overridebar][vehicleui] possess; normal");
+    end
+end
+
+local function createActionBar(parent, config)
     local prev;
+    local i = 0;
+    local bar = CreateFrame("Frame", "OmaBTBar"..config.bar, parent, "SecureFrameTemplate");
+    bar:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", config.x, config.y);
+    bar:SetWidth(1);
+    bar:SetHeight(1);
+    if config.hidden then
+        bar:Hide();
+    end
     for slot = config.start, config.start+config.length-1 do
-        local secure = CreateFrame("CheckButton", name..slot, parent, inheritedFrames);
+        local secure = CreateFrame("CheckButton", "OmaBT"..slot, bar, inheritedFrames);
         secure.slot = slot;
         if slot == config.start then
-            secure:SetPoint("TOPLEFT", parent, "BOTTOMLEFT", config.x, config.y);
+            secure:SetPoint("TOPLEFT");
+        elseif config.columns and i % config.columns == 0 then
+            secure:SetPoint("TOPLEFT", _G["OmaBT"..(slot-config.columns)], "BOTTOMLEFT");
         else
             secure:SetPoint("TOPLEFT", prev, "TOPRIGHT");
         end
@@ -224,8 +432,11 @@ local function createActionBar(parent, name, config)
         if not BUTTONLOCK then
             secure:RegisterForDrag("LeftButton", "RightButton");
         end
-        secure:SetWidth(32);
-        secure:SetHeight(32);
+        if config.nomouse then
+            secure:EnableMouse(false);
+        end
+        secure:SetWidth(config.size or 32);
+        secure:SetHeight(config.size or 32);
         secure.base = secure:CreateTexture(nil, "BACKGROUND");
         secure.base:SetAllPoints();
         secure.base:SetColorTexture(0, 0, 0, 0.5);
@@ -239,117 +450,81 @@ local function createActionBar(parent, name, config)
         secure.icon:SetPoint("BOTTOMRIGHT", secure.iconbase, "BOTTOMRIGHT");
         secure.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93);
         secure:SetCheckedTexture("Interface\\Buttons\\CheckButtonHilight");
+        secure.autocastable = secure:CreateTexture(nil, "OVERLAY");
+        secure.autocastable:SetPoint("CENTER");
+        secure.autocastable:SetWidth(58);
+        secure.autocastable:SetHeight(58);
+        secure.autocastable:SetTexture("Interface\\Buttons\\UI-AutoCastableOverlay");
+        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:SetTexture("Interface\\SpellActivationOverlay\\IconAlert");
+        secure.glow:SetTexCoord(0.00781250, 0.50781250, 0.27734375, 0.52634375);
+        secure.glow:Hide();
         secure.hotkey = secure:CreateFontString(nil, "OVERLAY", "NumberFontNormalGray");
         secure.hotkey:SetPoint("TOPRIGHT", secure, "TOPRIGHT", 2, -1);
         secure.count = secure:CreateFontString(nil, "OVERLAY", "NumberFontNormal");
         secure.count:SetPoint("BOTTOMRIGHT", secure, "BOTTOMRIGHT", 2, -1);
-        secure.cd = CreateFrame("Cooldown", name..slot.."CD", secure, "CooldownFrameTemplate");
+        secure.text = secure:CreateFontString(nil, "OVERLAY", "NumberFontNormal");
+        secure.text:SetPoint("BOTTOMLEFT", secure, "BOTTOMLEFT", 2, -1);
+        secure.text:Hide();
+        secure.cd = CreateFrame("Cooldown", "OmaBTCD"..slot, secure, "CooldownFrameTemplate");
         secure.cd:SetAllPoints();
         secure:SetAttribute("type", "action");
         secure:SetAttribute("action", slot);
-        function secure:ActionChanged()
+        if config.flyout then
+            secure:SetAttribute("flyoutDirection", config.flyout);
+        end
+        function secure:ActionChanged(oldslot)
+            if oldslot then activeButtons[oldslot] = nil end
             self.slot = self:GetAttribute("action");
             return updateButton(self, self.slot);
         end
         secure:ActionChanged(); -- initial update
-        -- FrameXML/SecureHandlers.lua has arguments and return value
-        -- args: self, button, kind, value, ... (kind, value, ... from GetCursorInfo())
-        -- returns: kind, target, detail
-        -- or: "clear", kind, target, detail
-        -- used for Pickup* functions
-        -- some of these snippets based on LibActionButton-1.0
-        secure:SetAttribute("_ondragstart", [=[
-            return "action", self:GetAttribute("action");
-        ]=]);
-        secure:SetAttribute("_onreceivedrag", [=[
-            if not kind or not value then return nil end
-            return "action", self:GetAttribute("action");
-        ]=]);
-        -- pre-wrapper can pass a message to post-wrapper
-        secure:WrapScript(secure, "OnDragStart", [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            return "message", format("%s|%s", tostring(kind), tostring(value));
-        ]=], [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            if message ~= format("%s|%s", tostring(kind), tostring(value)) then
-                self:CallMethod("ActionChanged");
-            end
-        ]=]);
-        secure:WrapScript(secure, "OnReceiveDrag", [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            return "message", format("%s|%s", tostring(kind), tostring(value));
-        ]=], [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            if message ~= format("%s|%s", tostring(kind), tostring(value)) then
-                self:CallMethod("ActionChanged");
-            end
-        ]=]);
-        secure:WrapScript(secure, "OnClick", [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            return nil, format("%s|%s", tostring(kind), tostring(value));
-        ]=], [=[
-            local kind, value = GetActionInfo(self:GetAttribute("action"));
-            if message ~= format("%s|%s", tostring(kind), tostring(value)) then
-                self:CallMethod("ActionChanged");
-            end
-        ]=]);
-        if slot < 13 then
-            -- first action bar has possible states based on vehicle/possess etc.
-            secure:SetAttribute("origaction", slot);
-            secure:SetAttribute("_onstate-possess", [=[
-                if newstate == "possess" then
-                    local slot;
-                    if HasVehicleActionBar() then
-                        slot = (GetVehicleBarIndex()-1)*12+self:GetAttribute("origaction");
-                    elseif HasOverrideActionBar() then
-                        slot = (GetOverrideBarIndex()-1)*12+self:GetAttribute("origaction");
-                    elseif HasTempShapeshitftActionBar() then
-                        slot = (GetTempShapeshiftBarIndex()-1)*12+self:GetAttribute("origaction");
-                    else
-                        -- something wrong, just revert to normal
-                        print("Possess bar index not found");
-                        slot = self:GetAttribute("origaction");
-                    end
-                    self:SetAttribute("action", slot);
-                else
-                    self:SetAttribute("action", self:GetAttribute("origaction"));
-                end
-                self:CallMethod("ActionChanged");
-            ]=]);
-            RegisterStateDriver(secure, "possess", "[overridebar][possessbar][shapeshift] possess; normal");
-        else
-            function secure:ShowButton() if HasAction(slot) then activeButtons[slot] = self end end
-            function secure:HideButton() activeButtons[slot] = nil end
-            -- all other action bar are hidden if with overridebar or vehicleui (not shapeshift, possessbar)
-            -- default Bartender4 options
-            secure:SetAttribute("_onstate-possess", [=[
-                if newstate == "possess" then
-                    self:Hide();
-                    self:CallMethod("HideButton");
-                else
-                    self:Show();
-                    self:CallMethod("ShowButton");
-                end
-            ]=]);
-            RegisterStateDriver(secure, "possess", "[overridebar][vehicleui] possess; normal");
-        end
+        setupSnippets(secure, slot);
+        updateHotkeys(secure);
         buttons[slot] = secure;
         prev = secure;
+        i = i + 1;
     end
 end
 
 local function initialize()
+    local _, class = UnitClass("player");
+    local name, realm = UnitFullName("player");
     ActionBars:SetFrameStrata("LOW");
     ActionBars:SetPoint("BOTTOMLEFT");
     ActionBars:SetWidth(1);
     ActionBars:SetHeight(1);
-    for name, config in pairs(settings) do
-        createActionBar(ActionBars, name, config);
+    for _, config in pairs(settings) do
+        if (not usingBonusbars[class] or not usingBonusbars[class][config.bar]) and
+           (not chars[realm] or not chars[realm][name] or chars[realm][name][config.bar]) then
+            createActionBar(ActionBars, config);
+        end
+    end
+end
+
+local function setupBindings()
+    BINDING_HEADER_OmaAB = "Oma Action Bar";
+    for i = 1,10 do
+        _G["BINDING_HEADER_OMAABBLANK"..i] = "Bar "..i;
+        for j = 1,12 do
+            _G[format("BINDING_NAME_CLICK OmaBT%d:LeftButton", (i-1)*12+j)] = format("Bar %d Button %d", i, j);
+        end
     end
 end
 
+local mounted = false;
 local throttleCD = false;
-local function throttleCDDone() throttleCD = false end
+local function throttleCDDone()
+    throttleCD = false
+    -- update CD once more to confirm newest CD change is taken in even with some throttling
+    for _, button in pairs(activeButtons) do
+        updateCooldown(button, button.slot);
+    end
+end
 
 local events = {
     ["ACTIONBAR_UPDATE_COOLDOWN"] = function()
@@ -400,7 +575,53 @@ local events = {
             end
         end
     end,
+    ["START_AUTOREPEAT_SPELL"] = function()
+        for _, button in pairs(activeButtons) do
+            if IsAutoRepeatAction(button.slot) then
+                button.autorepeating = true;
+                button.icon:SetVertexColor(0, 1, 0.5);
+            end
+        end
+    end,
+    ["STOP_AUTOREPEAT_SPELL"] = function()
+        for _, button in pairs(activeButtons) do
+            if button.autorepeating then
+                button.autorepeating = nil;
+                updateUsable(button, button.slot);
+            end
+        end
+    end,
+    ["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);
+        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);
+        end
+    end,
     ["UPDATE_BINDINGS"] = function()
+        for _, button in pairs(buttons) do
+            updateHotkeys(button);
+        end
+    end,
+    ["UNIT_AURA"] = function(unit)
+        -- using UNIT_AURA instead of COMPANION_UPDATE to not update every time
+        -- someone mounts, tracking player mount status with COMPANION_UPDATE is
+        -- inconsistent
+        if (not mounted and IsMounted()) or (mounted and not IsMounted()) then
+            mounted = not mounted;
+            for _, button in pairs(activeButtons) do
+                updateState(button, button.slot);
+            end
+        end
     end,
     ["UPDATE_ALL_BUTTONS"] = function()
         for _, button in pairs(buttons) do
@@ -408,14 +629,25 @@ local events = {
         end
     end,
     ["PLAYER_LOGIN"] = function()
-        GameTooltip = _G["GameTooltip"];
+        GameTooltip = _G["GameTooltip"]; -- TODO use PLAYER_ENTERING_WORLD with MoveAnything
         initialize();
     end,
+    ["ADDON_LOADED"] = function(addon)
+        if addon == "OmaAB" then
+            setupBindings();
+            ActionBars:UnregisterEvent("ADDON_LOADED");
+        end
+    end,
 };
 events["LOSS_OF_CONTROL_ADDED"] = events["ACTIONBAR_UPDATE_COOLDOWN"];
 events["LOSS_OF_CONTROL_UPDATE"] = events["ACTIONBAR_UPDATE_COOLDOWN"]; -- TODO might change once tooltips are in
 events["PLAYER_MOUNT_DISPLAY_CHANGED"] = events["ACTIONBAR_UPDATE_USABLE"];
+events["TRADE_SKILL_SHOW"] = events["ACTIONBAR_UPDATE_STATE"];
+events["TRADE_SKILL_CLOSE"] = events["ACTIONBAR_UPDATE_STATE"];
+events["ARCHAEOLOGY_CLOSED"] = events["ACTIONBAR_UPDATE_STATE"];
+events["PLAYER_ENTERING_WORLD"] = events["UPDATE_ALL_BUTTONS"];
 events["UPDATE_VEHICLE_ACTIONBAR"] = events["UPDATE_ALL_BUTTONS"];
+events["UPDATE_SHAPESHIFT_FORM"] = events["UPDATE_ALL_BUTTONS"];
 events["SPELL_UPDATE_ICON"] = events["UPDATE_ALL_BUTTONS"];
 events["PET_STABLE_UPDATE"] = events["UPDATE_ALL_BUTTONS"];
 events["PET_STABLE_SHOW"] = events["UPDATE_ALL_BUTTONS"];
@@ -424,10 +656,10 @@ 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 COMPANION_UPDATE needed?
 -- TODO overlay glow ? don't exactly know what it does, proc highlight?
--- autorepeat, tooltips
+-- tooltips
 
+ActionBars:RegisterEvent("ADDON_LOADED");
 ActionBars:RegisterEvent("PLAYER_LOGIN");
 ActionBars:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
 ActionBars:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
@@ -437,6 +669,8 @@ ActionBars:RegisterEvent("ACTIONBAR_SHOWGRID");
 ActionBars:RegisterEvent("ACTIONBAR_HIDEGRID");
 ActionBars:RegisterEvent("SPELL_UPDATE_ICON");
 ActionBars:RegisterEvent("SPELL_UPDATE_CHARGES");
+ActionBars:RegisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_SHOW");
+ActionBars:RegisterEvent("SPELL_ACTIVATION_OVERLAY_GLOW_HIDE");
 ActionBars:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR");
 ActionBars:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR");
 ActionBars:RegisterEvent("PLAYER_MOUNT_DISPLAY_CHANGED");
@@ -445,6 +679,8 @@ ActionBars:RegisterEvent("UNIT_ENTERED_VEHICLE");
 ActionBars:RegisterEvent("UNIT_EXITED_VEHICLE");
 ActionBars:RegisterEvent("PET_STABLE_UPDATE");
 ActionBars:RegisterEvent("PET_STABLE_SHOW");
+ActionBars:RegisterEvent("UPDATE_BINDINGS");
+ActionBars:RegisterUnitEvent("UNIT_AURA", "player");
 ActionBars:SetScript("OnEvent", function(self, event, arg1)
     events[event](arg1);
 end);
diff --git a/OmaAB/BagBar.txt b/OmaAB/BagBar.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/OmaAB/Bindings.xml b/OmaAB/Bindings.xml
new file mode 100644 (file)
index 0000000..7ae37aa
--- /dev/null
@@ -0,0 +1,142 @@
+<Bindings>\r
+       <Binding name="CLICK OmaBT1:LeftButton" header="OMAABBLANK1" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT2:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT3:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT4:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT5:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT6:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT7:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT8:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT9:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT10:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT11:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT12:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT13:LeftButton" header="OMAABBLANK2" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT14:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT15:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT16:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT17:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT18:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT19:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT20:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT21:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT22:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT23:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT24:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT25:LeftButton" header="OMAABBLANK3" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT26:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT27:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT28:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT29:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT30:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT31:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT32:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT33:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT34:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT35:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT36:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT37:LeftButton" header="OMAABBLANK4" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT38:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT39:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT40:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT41:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT42:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT43:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT44:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT45:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT46:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT47:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT48:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT49:LeftButton" header="OMAABBLANK5" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT50:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT51:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT52:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT53:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT54:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT55:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT56:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT57:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT58:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT59:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT60:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT61:LeftButton" header="OMAABBLANK6" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT62:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT63:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT64:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT65:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT66:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT67:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT68:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT69:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT70:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT71:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT72:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT73:LeftButton" header="OMAABBLANK7" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT74:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT75:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT76:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT77:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT78:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT79:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT80:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT81:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT82:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT83:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT84:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT85:LeftButton" header="OMAABBLANK8" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT86:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT87:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT88:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT89:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT90:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT91:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT92:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT93:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT94:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT95:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT96:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT97:LeftButton" header="OMAABBLANK9" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT98:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT99:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT100:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT101:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT102:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT103:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT104:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT105:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT106:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT107:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT108:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT109:LeftButton" header="OMAABBLANK10" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT110:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT111:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT112:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT113:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT114:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT115:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT116:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT117:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT118:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT119:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK OmaBT120:LeftButton" category="OmaAB "/>\r
+    <!--<Binding name="CLICK BT4PetButton1:LeftButton" header="OMAABPET" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton2:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton3:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton4:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton5:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton6:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton7:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton8:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton9:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4PetButton10:LeftButton" category="OmaAB "/>\r
+    <Binding name="CLICK BT4StanceButton1:LeftButton" header="OMAABSTANCE" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton2:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton3:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton4:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton5:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton6:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton7:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton8:LeftButton" category="OmaAB "/>\r
+       <Binding name="CLICK BT4StanceButton9:LeftButton" category="OmaAB "/>\r
+    <Binding name="CLICK BT4StanceButton10:LeftButton" category="OmaAB "/>-->\r
+</Bindings>\r
index 2ee57ec..fb69886 100644 (file)
@@ -4,6 +4,7 @@
 ## Author: schyrio
 ## Notes: My action bars
 
+Bindings.xml
 ExpBar.lua
 TellMeWhen.lua
 ActionBars.lua