Skip to content

Commit

Permalink
Added support for ACTIVE_TALENT_GROUP_CHANGED
Browse files Browse the repository at this point in the history
event in Seasons of Discovery
Added timer to ACTIVE_TALENT_GROUP_CHANGED because
direct utilization didn't work as needed
(did not result in equip swap)
Changed implementation of OnEvent function - now
it can handle not only 1:1 events to handlers, but
1:many
  • Loading branch information
Alexey Surkov committed Dec 25, 2024
1 parent a36c7fc commit 0c02968
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions ItemRack/ItemRack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function ItemRack.IsCata()
return wowtoc > 40000 and wowtoc < 50000
end

function ItemRack.IsSod()
return wowtoc >= 11500 and wowtoc < 20000
end

-- [[ Season of Discovery Runes ]]
function ItemRack.IsEngravingActive()
return C_Engraving and C_Engraving.IsEngravingEnabled()
Expand Down Expand Up @@ -261,7 +265,8 @@ function ItemRack.InitEventHandlers()
handler.PLAYER_TALENT_UPDATE = ItemRack.UpdateClassSpecificStuff
handler.PLAYER_ENTERING_WORLD = ItemRack.OnEnterWorld
handler.PLAYER_LOGOUT = ItemRack.OnPlayerLogout
handler.ACTIVE_TALENT_GROUP_CHANGED = ItemRack.UpdateClassSpecificStuff
handler.ACTIVE_TALENT_GROUP_CHANGED = { ItemRack.UpdateClassSpecificStuff, ItemRack.OnActiveTalentGroupChanged }
--handler.ACTIVE_TALENT_GROUP_CHANGED = ItemRack.OnActiveTalentGroupChanged
-- handler.PET_BATTLE_OPENING_START = ItemRack.OnEnteringPetBattle
-- handler.PET_BATTLE_CLOSE = ItemRack.OnLeavingPetBattle
end
Expand All @@ -278,7 +283,14 @@ do
end

function ItemRack.OnEvent(self,event,...)
ItemRack.EventHandlers[event](self,event,...)
local handlers = ItemRack.EventHandlers[event];
if #(handlers) > 0 then
for _, handler in pairs(handlers) do
handler(self,event,...)
end
else
handlers[event](self,event,...)
end
end

--- Allows third-party addons to listen to ItemRack events, like saving and deleting a set.
Expand Down Expand Up @@ -359,6 +371,10 @@ function ItemRack.OnCastingStop(self,event,unit)
end
end

function ItemRack.OnActiveTalentGroupChanged()
ItemRack.StartTimer("ActiveTalentGroupChanged")
end

function ItemRack.OnItemLockChanged()
ItemRack.StartTimer("LocksChanged")
ItemRack.LocksHaveChanged = 1
Expand Down Expand Up @@ -562,6 +578,7 @@ function ItemRack.InitCore()
ItemRack.CreateTimer("TooltipUpdate",ItemRack.TooltipUpdate,1,1)
ItemRack.CreateTimer("CooldownUpdate",ItemRack.CooldownUpdate,1,1)
ItemRack.CreateTimer("LocksChanged",ItemRack.LocksChanged,.2)
ItemRack.CreateTimer("ActiveTalentGroupChanged", ItemRack.ActiveTalentGroupChanged, 1)
ItemRack.CreateTimer("DelayedCombatQueue",ItemRack.DelayedCombatQueue,.1)

for i=-2,11 do
Expand All @@ -587,6 +604,10 @@ function ItemRack.InitCore()
ItemRackFrame:RegisterEvent("PLAYER_TALENT_UPDATE")
ItemRackFrame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
end

if ItemRack.IsSod() then
ItemRackFrame:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
end
-- ItemRackFrame:RegisterEvent("PET_BATTLE_OPENING_START")
-- ItemRackFrame:RegisterEvent("PET_BATTLE_CLOSE")
--if not disable_delayed_swaps then
Expand Down Expand Up @@ -946,6 +967,13 @@ function ItemRack.IsSoulbound(bag,slot)
end
end

function ItemRack.ActiveTalentGroupChanged()
print("ActiveTalentGroupChanged")
if #(ItemRack.SetsWaiting)>0 and not ItemRack.AnythingLocked() then
ItemRack.ProcessSetsWaiting()
end
end

-- function happens .2 seconds after last ITEM_LOCK_CHANGE
function ItemRack.LocksChanged()
ItemRack.UpdateButtonLocks()
Expand Down

0 comments on commit 0c02968

Please sign in to comment.