superwow: add native guid based focus frames

This commit is contained in:
shagu
2025-01-12 12:00:06 +01:00
parent cc2b3b4a0e
commit 427461a1d4
+51
View File
@@ -32,6 +32,57 @@ pfUI:RegisterModule("superwow", "vanilla", function ()
DEFAULT_CHAT_FRAME:AddMessage("-> https://github.com/balakethelock/SuperWoW/releases/")
end
-- Add support for guid based focus frame
if SUPERWOW_VERSION and pfUI.uf and pfUI.uf.focus then
local focus = function(unitstr)
-- try to read target's unit guid
local _, guid = UnitExists(unitstr)
if guid and pfUI.uf.focus then
-- update focus frame
pfUI.uf.focus.unitname = nil
pfUI.uf.focus.label = guid
pfUI.uf.focus.id = ""
-- update focustarget frame
pfUI.uf.focustarget.unitname = nil
pfUI.uf.focustarget.label = guid .. "target"
pfUI.uf.focustarget.id = ""
end
return guid
end
-- extend the builtin /focus slash command
local legacyfocus = SlashCmdList.PFFOCUS
function SlashCmdList.PFFOCUS(msg)
-- try to perform guid based focus
local guid = focus("target")
-- run old focus emulation
if not guid then legacyfocus(msg) end
end
-- extend the builtin /swapfocus slash command
local legacyswapfocus = SlashCmdList.PFSWAPFOCUS
function SlashCmdList.PFSWAPFOCUS(msg)
-- save previous focus values
local oldlabel = pfUI.uf.focus.label or ""
local oldid = pfUI.uf.focus.id or ""
-- try to perform guid based focus
local guid = focus("target")
-- target old focus
if guid and oldlabel and oldid then
TargetUnit(oldlabel..oldid)
end
-- run old focus emulation
if not guid then legacyswapfocus(msg) end
end
end
local unitcast = CreateFrame("Frame")
unitcast:RegisterEvent("UNIT_CASTEVENT")
unitcast:SetScript("OnEvent", function()