+end
+
+local events = {
+ ["ACTIONBAR_UPDATE_COOLDOWN"] = function()
+ if not throttleCD then -- only update at most once/frame
+ throttleCD = true;
+ for _, button in pairs(activeButtons) do
+ updateCooldown(button, button.slot);
+ end
+ CTimerAfter(0.01, throttleCDDone); -- wait one frame
+ end
+ end,
+ ["SPELL_UPDATE_CHARGES"] = function()
+ for _, button in pairs(activeButtons) do
+ updateCount(button, button.slot);
+ end
+ end,
+ ["ACTIONBAR_SLOT_CHANGED"] = function(slot)
+ if buttons[slot] then buttons[slot]:ActionChanged() end
+ end,
+ ["ACTIONBAR_SHOWGRID"] = function()
+ for _, button in pairs(buttons) do
+ button.grid = true;
+ button.iconbase:Show();
+ if not activeButtons[button.slot] then button.base:Show() end
+ end
+ end,
+ ["ACTIONBAR_HIDEGRID"] = function()
+ for _, button in pairs(buttons) do
+ button.grid = nil;
+ button.iconbase:Hide();
+ if not activeButtons[button.slot] then button.base:Hide() end
+ end
+ end,
+ ["ACTIONBAR_UPDATE_STATE"] = function()
+ for _, button in pairs(activeButtons) do
+ updateState(button, button.slot);
+ end
+ end,
+ ["ACTIONBAR_UPDATE_USABLE"] = function()
+ for _, button in pairs(activeButtons) do
+ updateUsable(button, button.slot);
+ end
+ end,
+ ["UPDATE_OVERRIDE_ACTIONBAR"] = function()
+ if buttons[1] then -- called before PLAYER_LOGIN
+ for _, button in pairs(buttons) do
+ updateButton(button, button.slot);
+ 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
+ updateButton(button, button.slot);
+ end
+ end,
+ ["PLAYER_LOGIN"] = function()
+ 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"];
+events["PLAYER_SPECIALIZATION_CHANGED"] = events["UPDATE_ALL_BUTTONS"];
+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");
+ActionBars:RegisterEvent("PLAYER_LOGIN");
+ActionBars:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN");
+ActionBars:RegisterEvent("ACTIONBAR_UPDATE_USABLE");
+ActionBars:RegisterEvent("ACTIONBAR_UPDATE_STATE");
+ActionBars:RegisterEvent("ACTIONBAR_SLOT_CHANGED");
+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");
+ActionBars:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
+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);