Commit e8843034 authored by Simpy's avatar Simpy 🐹

let the spellbook tooltip update by cds

parent f84c6aea
...@@ -31,6 +31,7 @@ local UnitHealthMax = UnitHealthMax ...@@ -31,6 +31,7 @@ local UnitHealthMax = UnitHealthMax
local UnregisterStateDriver = UnregisterStateDriver local UnregisterStateDriver = UnregisterStateDriver
local VehicleExit = VehicleExit local VehicleExit = VehicleExit
local SPELLS_PER_PAGE = SPELLS_PER_PAGE local SPELLS_PER_PAGE = SPELLS_PER_PAGE
local TOOLTIP_UPDATE_TIME = TOOLTIP_UPDATE_TIME
local NUM_ACTIONBAR_BUTTONS = NUM_ACTIONBAR_BUTTONS local NUM_ACTIONBAR_BUTTONS = NUM_ACTIONBAR_BUTTONS
local COOLDOWN_TYPE_LOSS_OF_CONTROL = COOLDOWN_TYPE_LOSS_OF_CONTROL local COOLDOWN_TYPE_LOSS_OF_CONTROL = COOLDOWN_TYPE_LOSS_OF_CONTROL
local C_PetBattles_IsInBattle = C_PetBattles.IsInBattle local C_PetBattles_IsInBattle = C_PetBattles.IsInBattle
...@@ -756,19 +757,37 @@ function AB:SetNoopsi(frame) ...@@ -756,19 +757,37 @@ function AB:SetNoopsi(frame)
end end
local SpellBookTooltip = CreateFrame("GameTooltip", "ElvUISpellBookTooltip", E.UIParent, "GameTooltipTemplate") local SpellBookTooltip = CreateFrame("GameTooltip", "ElvUISpellBookTooltip", E.UIParent, "GameTooltipTemplate")
SpellBookTooltip.updateTooltip = TOOLTIP_UPDATE_TIME
function AB:SpellBookTooltipOnUpdate(elapsed)
self.updateTooltip = self.updateTooltip - elapsed
if self.updateTooltip > 0 then return end
self.updateTooltip = TOOLTIP_UPDATE_TIME
local owner = self:GetOwner()
if owner and owner.UpdateTooltip then
owner:UpdateTooltip()
elseif self.UpdateTooltip then
self:UpdateTooltip()
end
end
function AB:SpellButtonOnEnter(_, tt) function AB:SpellButtonOnEnter(_, tt)
-- copied from SpellBookFrame to remove: -- copied from SpellBookFrame to remove:
--- ActionBarController_UpdateAll, PetActionHighlightMarks, and BarHighlightMarks --- ActionBarController_UpdateAll, PetActionHighlightMarks, and BarHighlightMarks
-- TT:MODIFIER_STATE_CHANGED uses this function to safely update the spellbook tooltip when the actionbar module is disabled. -- TT:MODIFIER_STATE_CHANGED uses this function to safely update the spellbook tooltip when the actionbar module is disabled
if not tt then tt = SpellBookTooltip end if not tt then tt = SpellBookTooltip end
if tt:IsForbidden() then return end if tt:IsForbidden() then return end
tt:SetOwner(self, 'ANCHOR_RIGHT') tt:SetOwner(self, 'ANCHOR_RIGHT')
local slot = _G.SpellBook_GetSpellBookSlot(self) local slot = _G.SpellBook_GetSpellBookSlot(self)
local item = tt:SetSpellBookItem(slot, _G.SpellBookFrame.bookType) local needsUpdate = tt:SetSpellBookItem(slot, _G.SpellBookFrame.bookType) and tt == SpellBookTooltip
self.UpdateTooltip = (item and AB.SpellButtonOnEnter) or nil self.UpdateTooltip = (needsUpdate and AB.SpellButtonOnEnter) or nil
if needsUpdate then
tt:SetScript('OnUpdate', AB.SpellBookTooltipOnUpdate)
end
local highlight = self.SpellHighlightTexture local highlight = self.SpellHighlightTexture
if highlight and highlight:IsShown() then if highlight and highlight:IsShown() then
...@@ -779,8 +798,15 @@ function AB:SpellButtonOnEnter(_, tt) ...@@ -779,8 +798,15 @@ function AB:SpellButtonOnEnter(_, tt)
tt:Show() tt:Show()
end end
function AB:SpellButtonUpdateButton(event)
-- only need to check the shown state when its not called from TT:MODIFIER_STATE_CHANGED which already checks the shown state
local button = (not event or SpellBookTooltip:IsShown()) and SpellBookTooltip:GetOwner()
if button then AB.SpellButtonOnEnter(button) end
end
function AB:SpellButtonOnLeave() function AB:SpellButtonOnLeave()
SpellBookTooltip:Hide() SpellBookTooltip:Hide()
SpellBookTooltip:SetScript('OnUpdate', nil)
end end
function AB:DisableBlizzard() function AB:DisableBlizzard()
...@@ -796,7 +822,7 @@ function AB:DisableBlizzard() ...@@ -796,7 +822,7 @@ function AB:DisableBlizzard()
-- let spell book buttons work without tainting by replacing this function -- let spell book buttons work without tainting by replacing this function
for i = 1, SPELLS_PER_PAGE do for i = 1, SPELLS_PER_PAGE do
local button = _G['SpellButton' .. i] local button = _G['SpellButton'..i]
button:SetScript('OnEnter', AB.SpellButtonOnEnter) button:SetScript('OnEnter', AB.SpellButtonOnEnter)
button:SetScript('OnLeave', AB.SpellButtonOnLeave) button:SetScript('OnLeave', AB.SpellButtonOnLeave)
end end
...@@ -1151,7 +1177,15 @@ end ...@@ -1151,7 +1177,15 @@ end
function AB:Initialize() function AB:Initialize()
AB.db = E.db.actionbar AB.db = E.db.actionbar
if not E.private.actionbar.enable then return end if not E.private.actionbar.enable then
-- this is used by TT:MODIFIER_STATE_CHANGED to safely show the Spell ID in combat
for i = 1, SPELLS_PER_PAGE do
_G['SpellButton'..i]:HookScript('OnLeave', AB.SpellButtonOnLeave)
end
return
end
AB.Initialized = true AB.Initialized = true
LAB.RegisterCallback(AB, "OnButtonUpdate", AB.LAB_ButtonUpdate) LAB.RegisterCallback(AB, "OnButtonUpdate", AB.LAB_ButtonUpdate)
...@@ -1190,9 +1224,10 @@ function AB:Initialize() ...@@ -1190,9 +1224,10 @@ function AB:Initialize()
AB:ToggleCooldownOptions() AB:ToggleCooldownOptions()
AB:LoadKeyBinder() AB:LoadKeyBinder()
AB:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings") AB:RegisterEvent('UPDATE_BINDINGS', 'ReassignBindings')
AB:RegisterEvent("PET_BATTLE_CLOSE", "ReassignBindings") AB:RegisterEvent('PET_BATTLE_CLOSE', 'ReassignBindings')
AB:RegisterEvent('PET_BATTLE_OPENING_DONE', 'RemoveBindings') AB:RegisterEvent('PET_BATTLE_OPENING_DONE', 'RemoveBindings')
AB:RegisterEvent('SPELL_UPDATE_COOLDOWN', 'SpellButtonUpdateButton')
if C_PetBattles_IsInBattle() then if C_PetBattles_IsInBattle() then
AB:RemoveBindings() AB:RemoveBindings()
......
...@@ -667,8 +667,7 @@ function TT:MODIFIER_STATE_CHANGED() ...@@ -667,8 +667,7 @@ function TT:MODIFIER_STATE_CHANGED()
end end
if _G.ElvUISpellBookTooltip:IsShown() then if _G.ElvUISpellBookTooltip:IsShown() then
local button = _G.ElvUISpellBookTooltip:GetOwner() AB:SpellButtonUpdateButton()
if button then AB.SpellButtonOnEnter(button) end
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