local RegisterStateDriver = RegisterStateDriver;
local CooldownFrame_Set, CooldownFrame_Clear = CooldownFrame_Set, CooldownFrame_Clear;
local CTimerAfter = C_Timer.After;
-local GameTooltip = nil;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
local COOLDOWN_TYPE_LOSS_OF_CONTROL = COOLDOWN_TYPE_LOSS_OF_CONTROL;
local COOLDOWN_TYPE_NORMAL = COOLDOWN_TYPE_NORMAL;
local CDTexture = "Interface\\Cooldown\\edge";
local inheritedFrames =
"SecureActionButtonTemplate,SecureHandlerDragTemplate,SecureHandlerStateTemplate";
+local function showTooltip(secure)
+ GameTooltip_SetDefaultAnchor(GameTooltip, secure);
+ GameTooltip:SetAction(secure:GetAttribute("action"));
+end
+
+local function hideTooltip()
+ GameTooltip:Hide();
+end
+
local numChargeCDs = 0;
local function createChargeCD(parent)
numChargeCDs = numChargeCDs + 1;
end
if config.nomouse then
secure:EnableMouse(false);
+ else
+ -- only show tooltips for bars with mouse interaction
+ secure:SetScript("OnEnter", showTooltip);
+ secure:SetScript("OnLeave", hideTooltip);
end
secure:SetWidth(config.size or 32);
secure:SetHeight(config.size or 32);
end
local mounted = false;
-local throttleCD = false;
+-- throttleCD 3-state, nil -> false -> true -> nil
+-- this way there's not double update each time the first
+-- update event comes, instead the extra throttled update comes
+-- if there are >2 ACTIONBAR_UPDATE_COOLDOWN events in one frame
+local throttleCD = nil;
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 function throttleCDReset()
+ throttleCD = nil;
+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);
+ throttleCD = throttleCD == false and true or false;
+ if throttleCD then
+ CTimerAfter(0.01, throttleCDDone); -- wait one frame
+ else
+ for _, button in pairs(activeButtons) do
+ updateCooldown(button, button.slot);
+ end
+ CTimerAfter(0.01, throttleCDReset); -- wait one frame
end
- CTimerAfter(0.01, throttleCDDone); -- wait one frame
end
end,
["SPELL_UPDATE_CHARGES"] = function()
end
end,
["PLAYER_LOGIN"] = function()
- GameTooltip = _G["GameTooltip"]; -- TODO use PLAYER_ENTERING_WORLD with MoveAnything
+ GameTooltip = _G["GameTooltip"];
initialize();
end,
["ADDON_LOADED"] = function(addon)
if unit == "player" then events["ACTIONBAR_UPDATE_STATE"]() end
end
events["UNIT_EXITED_VEHICLE"] = events["UNIT_ENTERED_VEHICLE"];
--- tooltips
ActionBars:RegisterEvent("ADDON_LOADED");
ActionBars:RegisterEvent("PLAYER_LOGIN");