focus: hand /focus and /clearfocus to ClassicAPI

ClassicAPI's SlashCommandsRegistry now owns the canonical /focus and
/clearfocus commands (matching modern Blizzard's no-alias convention
and delegating to the engine's FocusUnit / ClearFocus polyfills).
pfUI no longer needs to register them.

The TargetByName-based name-resolution workflow that the old
SlashCmdList.PFFOCUS provided ("/focus Hogger" → swap-target, capture
focus) doesn't fit the modern /focus contract, which only takes unit
tokens. Move that behavior into a separate /focusname (alias
/pffocusname) so users who relied on typed names still have a path —
just under a different command name.
This commit is contained in:
Brues
2026-06-21 01:32:10 -05:00
parent 740940dece
commit e6664a4eb6
+9 -15
View File
@@ -26,21 +26,21 @@ pfUI:RegisterModule("focus", function ()
end)
end)
SLASH_PFFOCUS1, SLASH_PFFOCUS2 = '/focus', '/pffocus'
function SlashCmdList.PFFOCUS(msg)
if msg == "" then
FocusUnit("target")
return
end
-- /focus and /clearfocus live in ClassicAPI's SlashCommandsRegistry now.
-- /focusname is pfUI-specific because the engine has no name→GUID
-- lookup for off-screen units — we resolve via a short target-swap.
SLASH_PFFOCUSNAME1, SLASH_PFFOCUSNAME2 = '/focusname', '/pffocusname'
function SlashCmdList.PFFOCUSNAME(msg)
if msg == "" then return end
-- Resolve name → unit via short target-swap, capturing focus during the swap.
local prevGUID = UnitGUID("target")
local prevPlayer = UnitIsUnit("target", "player")
-- Suppress "Unknown unit" errors during targeting attempts (fired async)
-- Suppress async "Unknown unit" errors fired by TargetByName misses.
UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE")
-- Try exact match first, then prefix match via /tar
-- Try exact match first, then prefix match via /target.
TargetByName(msg, true)
if not UnitExists("target") then
SlashCmdList.TARGET(msg)
@@ -50,7 +50,6 @@ function SlashCmdList.PFFOCUS(msg)
FocusUnit("target")
end
-- Re-enable errors next frame
local restore = CreateFrame("Frame")
restore:SetScript("OnUpdate", function()
UIErrorsFrame:RegisterEvent("UI_ERROR_MESSAGE")
@@ -66,11 +65,6 @@ function SlashCmdList.PFFOCUS(msg)
end
end
SLASH_PFCLEARFOCUS1, SLASH_PFCLEARFOCUS2 = '/clearfocus', '/pfclearfocus'
function SlashCmdList.PFCLEARFOCUS(msg)
ClearFocus()
end
SLASH_PFCASTFOCUS1, SLASH_PFCASTFOCUS2 = '/castfocus', '/pfcastfocus'
function SlashCmdList.PFCASTFOCUS(msg)
local focusGUID = UnitGUID("focus")