Skip to content

Commit

Permalink
fix(overlays): resolve macros
Browse files Browse the repository at this point in the history
Blizzard has changed `GetActionInfo` for macros.
It now returns the spell id for spells and some random id for items.
We try to get the macro by name, which might collide though.
  • Loading branch information
Rainrider committed Nov 12, 2023
1 parent ee63ab9 commit 4247124
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion core/DebugTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local C_UnitAuras = _G.C_UnitAuras
local Enum = _G.Enum
local BreakUpLargeNumbers = _G.BreakUpLargeNumbers
local GetActionInfo = _G.GetActionInfo
local GetActionText = _G.GetActionText
local GetItemInfo = _G.GetItemInfo
local GetItemSpell = _G.GetItemSpell
local GetMacroInfo = _G.GetMacroInfo
Expand Down Expand Up @@ -88,7 +89,8 @@ local function AddActionInfo(tooltip, slot)
if actionType == "spell" then
return AddSpellInfo(tooltip, "action", id, true)
elseif actionType == "macro" then
return AddMacroInfo(tooltip, "macro", id)
-- this might return wrong info if macro names are not unique
return AddMacroInfo(tooltip, "macro", GetActionText(slot))
elseif actionType == "item" then
return AddItemInfo(tooltip, id, true)
end
Expand Down
21 changes: 15 additions & 6 deletions core/Overlays.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ local error = _G.error
local format = _G.format
local GetActionCooldown = _G.GetActionCooldown
local GetActionInfo = _G.GetActionInfo
local GetActionText = _G.GetActionText
local GetMacroBody = _G.GetMacroBody
local GetMacroItem = _G.GetMacroItem
local GetMacroSpell = _G.GetMacroSpell
Expand Down Expand Up @@ -163,20 +164,22 @@ end
-- Action handling
------------------------------------------------------------------------------

local function GetActionSpell(actionType, actionId)
local function GetActionSpell(actionType, actionId, actionSubType, action)
if not actionType or not actionId then return "empty" end

-- Resolve macros
local macroConditionals
if actionType == "macro" then
if actionType == "macro" and actionSubType ~= "spell" then
-- this might return wrong results if macro names are not unique
actionId = GetActionText(action)
macroConditionals = GetMacroConditionals(actionId)
actionType, actionId = GetMacroAction(actionId)
end

-- Resolve items and companions
if actionType == "item" then
return "item", actionId, macroConditionals
elseif actionType == "spell" or actionType == "companion" then
elseif actionType == "spell" or actionSubType == "spell" or actionType == "companion" then
return "spell", actionId, macroConditionals
end

Expand Down Expand Up @@ -260,9 +263,9 @@ end
overlayPrototype.PLAYER_ENTERING_WORLD = overlayPrototype.ForceUpdate

function overlayPrototype:UpdateAction(event)
local actionId, actionType = self:GetAction()
local actualType, actualId, macroConditionals = GetActionSpell(actionId, actionType)
self:Debug('UpdateAction', event, '|', actionId, actionType, '=>', actualId, macroConditionals)
local actionType, actionId, actionSubType = self:GetAction()
local actualType, actualId, macroConditionals = GetActionSpell(actionType, actionId, actionSubType, self:GetActionId())
self:Debug('UpdateAction', event, '|', actionType, actionSubType, actionId, '=>', actualId, macroConditionals)
return self:SetAction(event, actualType, actualId, macroConditionals)
end

Expand Down Expand Up @@ -614,6 +617,12 @@ function labSupportPrototype:GetAction()
end
end

function labSupportPrototype:GetActionId()
local _, actionId = self.button:GetAction()

return actionId
end

function labSupportPrototype:GetActionCooldown()
return self.button:GetCooldown()
end
Expand Down

0 comments on commit 4247124

Please sign in to comment.