mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-06 21:50:00 +00:00
superwow: add native guid based focus frames
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user