mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-21 23:26:56 +00:00
73b409fb88
The RegisterSlashCommand helper in api/api.lua was effectively unused (only macrotweak called it); every other command hand-rolled the SLASH_*/SlashCmdList pair. Convert the existing manual registrations to the helper with force=true, preserving the current always-bind behavior while centralizing the pattern behind one code path (and its _G. and conflict-check handling). Left as-is: pfUI.lua's /rl, /pfui, /gm (registered before api.lua defines the helper) and the vendored libs' debug commands.
33 lines
1.0 KiB
Lua
33 lines
1.0 KiB
Lua
pfUI:RegisterModule("mouseover", function ()
|
|
pfUI.api.RegisterSlashCommand("PFCAST", { "/pfcast", "/pfmouse" }, function(msg)
|
|
local func = pfUI.api.TryMemoizedFuncLoadstringForSpellCasts(msg)
|
|
local unit = "mouseover"
|
|
|
|
if not UnitExists(unit) then
|
|
local frame = GetMouseFocus()
|
|
if frame.label and frame.id then
|
|
unit = frame.label .. frame.id
|
|
elseif UnitExists("target") then
|
|
unit = "target"
|
|
elseif GetCVar("autoSelfCast") == "1" then
|
|
unit = "player"
|
|
else
|
|
return
|
|
end
|
|
end
|
|
|
|
-- Spell-name path: Nampower's CastSpellByName takes a second unit
|
|
-- parameter directly, no target swap dance required.
|
|
if not func then
|
|
CastSpellByName(msg, unit)
|
|
return
|
|
end
|
|
|
|
-- Macro path: switch target so the macro's spell calls land on `unit`,
|
|
-- then restore.
|
|
local restore_target = not UnitIsUnit("target", unit)
|
|
if restore_target then TargetUnit(unit) end
|
|
func()
|
|
if restore_target then TargetLastTarget() end
|
|
end, true)
|
|
end) |