From e6664a4eb6c9b4b4ac8c9436a9d96181a0185237 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 21 Jun 2026 01:32:10 -0500 Subject: [PATCH] focus: hand /focus and /clearfocus to ClassicAPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- modules/focus.lua | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/modules/focus.lua b/modules/focus.lua index b4753d0f..22c8db9c 100644 --- a/modules/focus.lua +++ b/modules/focus.lua @@ -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")