mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-25 09:06:03 +00:00
Classic API Focus (#2)
* focus: migrate to FocusUnit / "focus" token / PLAYER_FOCUS_CHANGED
ClassicAPI now polyfills modern WoW's focus system: FocusUnit / ClearFocus
+ "focus" / "focustarget" unit tokens accepted by every UnitX function +
PLAYER_FOCUS_CHANGED event. Drop pfUI's GUID-juggling pseudo-frame.
- env/tables.lua: add "focus" and "focustarget" to pfValidUnits — the
focus frames now follow the standard event-driven CreateUnitFrame path
with f.label = "focus"
- modules/focus.lua: rewrite. Slash commands use FocusUnit / ClearFocus
directly; no more manual frame.label/unitname/id manipulation. /focus
<name> still does a target-swap to resolve names → units, then
FocusUnit("target") captures the GUID before the target is restored.
PLAYER_FOCUS_CHANGED triggers immediate frame refresh on assign/clear.
- api/unitframes.lua: delete the pseudo-focus block (per-tick "scan all
units for matching name" loop) and the "focus"/"focustarget" special-
case in the visibility branch — "focus" is now a real token.
- modules/castbar.lua: bind the focus castbar to unitstr = "focus" once;
drop the OnUpdate that synced pfUI.castbar.focus from
pfUI.uf.focus.label/unitname. UnitGUID("focus") resolves at read time.
- Drop C_Minimap.SetFocusByGUID / SetFocusByName / ClearFocus calls —
C_Minimap subscribes to PLAYER_FOCUS_CHANGED on its own.
Net -183 lines. Focus stops being a pfUI-special pseudo-frame and
becomes "just another unit token" — same treatment as target/player.
* add nameplate to valid units
---------
Co-authored-by: Brues <5278969+brues-code@users.noreply.github.com>
This commit is contained in:
+2
-47
@@ -356,7 +356,7 @@ function pfUI.uf:UpdateVisibility()
|
||||
end
|
||||
|
||||
-- vanilla visibility
|
||||
if self.unitname and self.unitname ~= "focus" and self.unitname ~= "focustarget" then
|
||||
if self.unitname then
|
||||
self:Show()
|
||||
elseif visibility == "hide" then
|
||||
self:Hide()
|
||||
@@ -1462,52 +1462,7 @@ function pfUI.uf.OnUpdate()
|
||||
end
|
||||
end
|
||||
|
||||
-- handle pseudo focus frames
|
||||
if this.unitname and this == pfFocus then
|
||||
local unitname = ( this.label and UnitName(this.label) ) or ""
|
||||
|
||||
if pfFocusTarget then -- update focus target
|
||||
pfFocusTarget.label = this.label and this.label .. "target" or nil
|
||||
local focustargetname = pfFocusTarget.label and UnitName(pfFocusTarget.label) or nil
|
||||
|
||||
if pfFocusTarget.lastUnit ~= focustargetname then
|
||||
pfFocusTarget.lastUnit = focustargetname
|
||||
pfFocusTarget.instantRefresh = true
|
||||
pfUI.uf:RefreshUnit(pfFocusTarget, "all")
|
||||
end
|
||||
end
|
||||
|
||||
-- break here on unset focus frames
|
||||
if not this.unitname or this.unitname == "focus" then return end
|
||||
|
||||
-- focus unit detection
|
||||
if this.unitname ~= strlower(unitname) then
|
||||
-- invalid focus frame
|
||||
for unit, bool in pairs(pfValidUnits) do
|
||||
local scan = UnitName(unit) or ""
|
||||
if this.unitname == strlower(scan) then
|
||||
this.label = unit
|
||||
if this.portrait then this.portrait.model.lastUnit = nil end
|
||||
this.instantRefresh = true
|
||||
pfUI.uf:RefreshUnit(this, "all")
|
||||
return
|
||||
end
|
||||
this.label = nil
|
||||
this.instantRefresh = true
|
||||
this.hp.bar:SetStatusBarColor(.2,.2,.2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- handle pseudo focus target visibility
|
||||
if this.unitname and this == pfFocusTarget then
|
||||
if pfFocus and not pfFocus.label or pfFocus.label == "" then
|
||||
this.label = nil
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if not this.label then return end
|
||||
if not this.label or this.label == "" then return end
|
||||
|
||||
-- update portrait on first visible frame
|
||||
if this.portrait and this.portrait.model and this.portrait.model.update then
|
||||
|
||||
Reference in New Issue
Block a user