mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
`Macro::Info` re-registered `GetMacroInfo` to answer with the icon a `?` macro's `#showtooltip` resolved to, so the Macro UI's list would match the action button. But the Macro UI seeds its icon selector from that same return -- `MacroFrame_Update` sets `MacroPopupFrame.selectedIconTexture` from it, and `MacroPopupFrame_Update` checks the grid button whose name matches -- so opening the selector on such a macro pre-selected an icon the player never picked, in the one place that edits the stored icon. Saving was never at risk (an unclicked selector leaves `selectedIcon` nil and `EditMacro` then leaves the icon alone), but the display was wrong. One return cannot serve both readers, and the one that edits state has the stronger claim, so `GetMacroInfo` goes back to the engine's: it is the read side of the icon `C_Macro.EditMacro` writes, and every addon that captures it now gets the stored icon. The icon a macro SHOWS becomes something a caller asks for, through `C_Macro.GetMacroIcon`. It reads the macro icon getter this DLL already hooks, so the `?` rule and the active-icon choice stay in one place and the answer matches what the action button and the drag cursor get. Util/MacroIconSelection.lua paints the Macro UI's list buttons from it after the stock update, which is additive -- an empty slot or a macro with a chosen icon answers with what stock already drew. Dropping the re-registration also takes a commonly captured global out of the override chain.
53 lines
1.8 KiB
Lua
53 lines
1.8 KiB
Lua
-- MacroIconSelection.lua -- the Macro UI's macro list shows the icon a
|
|
-- `#showtooltip` resolved to, the way the action button does.
|
|
--
|
|
-- `GetMacroInfo` reports the icon the macro STORES, and it has to keep
|
|
-- reporting that one: `MacroFrame_Update` seeds the icon selector from that
|
|
-- return, so answering with a resolved icon there would pre-select an icon the
|
|
-- player never picked, in the one place that edits the stored icon.
|
|
--
|
|
-- That leaves the list buttons showing the question mark for a macro whose
|
|
-- action button shows a spell. `C_Macro.GetMacroIcon` returns the icon a macro
|
|
-- currently shows, so paint the buttons from it once the stock update has
|
|
-- drawn them. An empty slot and a macro with a chosen icon both answer with
|
|
-- what stock already drew, so those are left alone.
|
|
|
|
local function ApplyIcon(texture, macroSlot)
|
|
if not texture then
|
|
return
|
|
end
|
|
local shown = C_Macro.GetMacroIcon(macroSlot)
|
|
if shown then
|
|
texture:SetTexture(shown)
|
|
end
|
|
end
|
|
|
|
local function PaintMacroList()
|
|
if not (MacroFrame and MacroFrame.macroBase) then
|
|
return
|
|
end
|
|
for i = 1, MAX_MACROS do
|
|
ApplyIcon(_G["MacroButton" .. i .. "Icon"], MacroFrame.macroBase + i)
|
|
end
|
|
if MacroFrame.selectedMacro then
|
|
ApplyIcon(MacroFrameSelectedMacroButtonIcon, MacroFrame.selectedMacro)
|
|
end
|
|
end
|
|
|
|
local function WrapMacroFrameUpdate()
|
|
if not MacroFrame_Update then
|
|
return
|
|
end
|
|
|
|
local original = MacroFrame_Update
|
|
-- No `...`: `MacroFrame_Update` takes no arguments, and Lua 5.0 would
|
|
-- build an `arg` table for every vararg call.
|
|
MacroFrame_Update = function()
|
|
original()
|
|
PaintMacroList()
|
|
end
|
|
end
|
|
|
|
-- Blizzard_MacroUI loads on demand.
|
|
EventUtil.ContinueOnAddOnLoaded("Blizzard_MacroUI", WrapMacroFrameUpdate)
|