mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-05 21:20:00 +00:00
Focus/Nameplates now respond solely to UNIT_* events
commit70b1e66c2dAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun Jul 26 18:30:18 2026 -0500 Use SetSize/SetShown and simplify minimap/map commit7b6bfe9975Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 11:27:14 2026 -0500 Include raidpet frames in /pftest test mode The unit-frame test toggle (showall) only previews frames that exist and are positioned. Raidpet frames are created when raidpet.visible == "1", but LayoutPets' collapse mode only positions pets whose raidpet<N> unit actually exists, so solo/in test mode they stayed hidden. Add a showall branch to LayoutPets that mirror-lays every pet cell and shows it (bypassing collapse and the roster gate), still guarded by the existing showpets check so nothing happens when raidpet is disabled. Call LayoutPets from the /pftest handler so the grid updates immediately on toggle-on and restores to the normal layout on toggle-off. commit4c65c38647Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 10:34:33 2026 -0500 Remove unused RangeCache local in UnitInRange commit6c96bbbe6cAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 10:34:33 2026 -0500 Use Clamp() for the two-sided clamps in ui-widgets Replace the hand-rolled math.min/math.max and if/elseif clamp idioms in the status bar and scroll frame with Clamp(). Equivalent for every value seen (min <= max always holds), just clearer. commit830e0a0be1Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 10:34:33 2026 -0500 Drop vanilla GetItemInfo shim for C_Item.GetItemInfo The compat/vanilla.lua GetItemInfo override reshaped vanilla's tuple into retail order by inserting nil at slot 4 (itemLevel), but truncated at 8 fields, dropping itemEquipLoc/itemTexture. ClassicAPI's global GetItemInfo keeps the vanilla shape (its hook only warms the item cache), so the shim stayed necessary but incomplete. Remove it and point the three callers at ClassicAPI's C_Item.GetItemInfo, which returns the full 18-field retail tuple. Positions 1-8 are identical to the old shim output, so bags/roll are unchanged; character.lua's itemSlot (equipLoc, field 9) was always nil under the truncating shim and now resolves correctly for ShaguScore. commitc0da63657dAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 10:09:34 2026 -0500 Various cleanup Removes version compatibility checks for TBC/Vanilla, consolidating code to target a single WoW version. Refactors repetitive SetWidth/SetHeight calls to SetSize for cleaner code. Removes duplicate function definitions from unitxp module and simplifies conditional show/hide operations using SetShown. commit11a6302c2dAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 09:53:37 2026 -0500 Delegate pfUI.api.strsplit to ClassicAPI's strsplit Replace the Lua pattern-based implementation with a thin wrapper around ClassicAPI's C-level strsplit. Keeps the pfUI.api.strsplit entry point for backwards compatibility with addons that call it, while dropping the redundant reimplementation. Behavioral note: the old version used ([^delim]+) which silently collapsed empty fields; delegating to real strsplit now preserves them ("a,,b" -> "a", "", "b"). All in-repo callers split numeric color tuples, version strings, or build name-keyed lookup tables, none of which are affected by empty-field preservation. commit67c126eac8Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 01:01:02 2026 -0500 Bump ClassicAPI minimum version to 1.8.0 commita6cf157518Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 00:49:50 2026 -0500 read spell rank via C_Spell.GetSpellSubtext The rank string comes from the spell subtext ("Rank N"), which ClassicAPI's C_Spell.GetSpellSubtext returns directly -- so drop nampower's GetSpellRecField(spellId, "rank") here. The existing "Rank " gsub parse is unchanged. commit4b1ba99b4fAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 00:33:20 2026 -0500 Move player info overlay onto ClassicAPI (drop Nampower) The haste/spell-power overlay read both values through Nampower and disabled itself entirely without it. Move both to ClassicAPI so it works on any ClassicAPI client: - Spell power: GetSpellPower("net") (nampower) -> GetSpellBonusDamage(i) (ClassicAPI, same per-school field). Merged the build+scan into one loop; the default school seeds the tiebreak so equal schools still favor it. - Haste: GetUnitField("player", "modCastSpeed") -> UnitSpellHaste("player"), which returns the haste percentage directly (the (1/modCastSpeed-1)*100 conversion is now baked in, off the same UNIT_MOD_CAST_SPEED field, signed). - Dropped the "if not GetUnitField then return" gate -- UpdateInfoText no longer touches Nampower, so the overlay runs everywhere. commit7df4aa6d50Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Sat Jul 25 00:32:44 2026 -0500 Hook the real global _G.UnitHealth for feign death Inside a RegisterModule body, `function UnitHealth(...)` defines UnitHealth on the pfUI environment, not the real global -- so the feign-death real-HP fix only reached callers that resolve UnitHealth through pfUI's env, and missed _G consumers (Blizzard frames, other addons). Hook _G.UnitHealth explicitly (and capture oldUnitHealth from _G) so the un-gate applies everywhere. commitb0bf2fd869Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri Jul 24 21:10:58 2026 -0500 Refactor nampower module Simplify reactive spell storage by using spell IDs instead of texture/name tables. Update to use modern C_Spell APIs (GetSpellTexture, GetSpellName) instead of manual texture paths. Consolidate SetWidth/SetHeight calls to SetSize and use print() instead of DEFAULT_CHAT_FRAME:AddMessage(). commit0b06961333Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri Jul 24 20:54:23 2026 -0500 Use GetNamePlateForUnit for target lookups; drop dead ScanGuid block - Replace the three GetNamePlateForGUID(UnitGUID("target")) round-trips with GetNamePlateForUnit("target"), which resolves the token to a GUID internally -- no UnitGUID string detour, and it returns nil for no-target/no-plate so the UnitExists guards collapse. GetNamePlateForGUID is left for raw-GUID cases. - Remove the dead libunitscan.ScanGuid nameplate block (ScanGuid was deleted from libunitscan long ago, so the guard was never true) -- it carried the last GetUnitField("npcFlags") read. commit3e6210086eAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri Jul 24 20:54:23 2026 -0500 Drop Nampower stats system and polling from unit frames GetUnitStats now reads health/power straight from UnitHealth/UnitPower (the descriptor fields the server broadcasts) -- for a real unit token GetUnitField read nothing different, so the whole Nampower-vs-fallback apparatus was measuring a distinction that no longer exists. Removed: - The stats system: pfUI.uf.stats, pfUIStatsFrame + UpdateStatsDisplay, the lastUnitStats change-cache, the /pfuistats slash command, and every counter increment (event/heartbeat/earlyReturn/throttledSkip/nampower/fallback). - All GetUnitField health reads (GetUnitStats, heal-prediction, health-gradient color) -- collapsed to the UnitHealth/UnitHealthMax they already fell back to. - The heartbeat-polling backstop and its fallbackThrottle/lastEventUpdate deps. Frames now refresh on events only; eventless frames still use their own tick, and range/aggro still run in the eventless-actions block. commit63001b7b0cAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri Jul 24 20:09:42 2026 -0500 Move nameplates onto ClassicAPI stable nameplate tokens ClassicAPI now assigns retail-exact, per-plate-stable "nameplateN" tokens and fires vanilla UNIT_* events for them, so the nameplate module can key off the token instead of Nampower/SuperWoW GUID primitives: - Events: UNIT_AURA_GUID/UNIT_FLAGS_GUID -> UNIT_AURA/UNIT_FLAGS, matched by the "nameplateN" token (guarded on the token prefix, since these also fire for target/party/raid). Registered unconditionally -- no GetUnitField gate. - Health: GetUnitField(guid, "health"/"maxHealth") -> UnitHealth/UnitHealthMax on the plate's cached token. Same UNIT_FIELD_HEALTH the server broadcasts (real HP on Turtle; the ~= 100 scaled-vs-real guard is unchanged). - Combat/target in GetCombatStateColor: GetUnitField("flags") + HasFlag -> UnitAffectingCombat(token); GetUnitField("target") + SuperWoW "<guid>target" -> the "nameplateNtarget" chain. Dropped the now-dead HasFlag, UNIT_FLAG_IN_COMBAT, and guidTargetTokenCache. - GetCastInfo now takes the token directly; every caller already holds it, so the UnitTokenFromGUID(guid) round-trip is gone (unused module-wide now). NAME_PLATE_UNIT_ADDED caches the token as plate.nameplate.unit alongside the GUID; REMOVED clears both. GUID is retained only as the stable cache key (debuffCache/threatMemory/combatColorCache). Only GetUnitField("npcFlags") remains -- it has no token/vanilla equivalent. commitce1c49fcbbAuthor: Brues <5278969+brues-code@users.noreply.github.com> Date: Fri Jul 24 18:20:06 2026 -0500 Make focus/focustarget event-driven via ClassicAPI unit events ClassicAPI now fires UNIT_* (health/mana/aura/...) with arg1 == "focus" and arg1 == "focustarget", observed per-unit like target/party/raid. Both frames already registered those events (focus/focustarget are in pfValidUnits) and their OnEvent already matches arg1 == label, so the 0.2s polling ticks were pure workarounds for the missing events. Drop both ticks; the frames now refresh on-event like target, with range/glow still on the shared 0.5s state pass and PLAYER_FOCUS_CHANGED still driving assign/clear.
This commit is contained in:
+71
-109
@@ -61,13 +61,11 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
|
||||
local raidGuidCache = {} -- guid -> name (rebuilt on RAID_ROSTER_UPDATE/PARTY_MEMBERS_CHANGED)
|
||||
|
||||
-- Resolve a plate GUID to its cast/channel info via C_Spell. Returns a
|
||||
-- Resolve a unit token to its cast/channel info via C_Spell. Returns a
|
||||
-- compact struct (spellName / icon / startTime / endTime / duration /
|
||||
-- isChannel) or nil when the unit isn't casting / the GUID can't map to a
|
||||
-- live token.
|
||||
local function GetCastInfo(guid)
|
||||
if not guid then return nil end
|
||||
local unit = UnitTokenFromGUID(guid)
|
||||
-- isChannel) or nil when the unit isn't casting. Callers already hold the
|
||||
-- nameplate token, so there's no GUID->token round-trip.
|
||||
local function GetCastInfo(unit)
|
||||
if not unit then return nil end
|
||||
local name, _, texture, startMs, endMs, _, _, _, spellID = C_Spell.UnitCastingInfo(unit)
|
||||
local isChannel
|
||||
@@ -87,7 +85,6 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
}
|
||||
end
|
||||
|
||||
local guidTargetTokenCache = {} -- guid -> "<guid>target" interned string
|
||||
local debuffCache = {} -- guid -> { [spellID] = { start, duration } }
|
||||
-- Reusable per-plate debuff display buffer (avoid GC churn from per-call table creation)
|
||||
local debuffDisplayBuf = {} -- [i] = { effect, texture, stacks, dtype, duration, timeleft }
|
||||
@@ -165,12 +162,6 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
-- cache default border color
|
||||
local er, eg, eb, ea = GetStringColor(pfUI_config.appearance.border.color)
|
||||
|
||||
-- Vanilla Lua 5.0 bitwise check: math.mod(math.floor(value / flag), 2) ~= 0
|
||||
local function HasFlag(flags, flag)
|
||||
return math.mod(math.floor(flags / flag), 2) ~= 0
|
||||
end
|
||||
|
||||
local UNIT_FLAG_IN_COMBAT = 524288 -- 0x00080000
|
||||
local NULL_GUID = "0x0000000000000000"
|
||||
|
||||
local function RebuildRaidGuidCache()
|
||||
@@ -189,10 +180,11 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
|
||||
local combatColorCache = {} -- guid -> { color, expires }
|
||||
|
||||
local function GetCombatStateColor(guid)
|
||||
local function GetCombatStateColor(guid, token)
|
||||
-- PERF: Quick exit if player not in combat
|
||||
if not UnitAffectingCombat("player") then return false end
|
||||
if UnitCanAssist("player", guid) then return false end
|
||||
if not token then return false end
|
||||
if UnitCanAssist("player", token) then return false end
|
||||
|
||||
-- PERF: 0.2s throttle per guid - color changes are not time-critical
|
||||
local now = frameState.now
|
||||
@@ -201,24 +193,17 @@ pfUI:RegisterModule("nameplates", function ()
|
||||
return cached.color
|
||||
end
|
||||
|
||||
local flags = GetUnitField and GetUnitField(guid, "flags")
|
||||
if not flags then return false end
|
||||
if not HasFlag(flags, UNIT_FLAG_IN_COMBAT) then return false end
|
||||
if not UnitAffectingCombat(token) then return false end
|
||||
|
||||
local mobTargetGuid = GetUnitField and GetUnitField(guid, "target")
|
||||
-- The mob's current target via the nameplate token chain (ClassicAPI):
|
||||
-- "nameplateNtarget" resolves to whatever this plate's unit is targeting,
|
||||
-- so no GetUnitField("target") or SuperWoW "<guid>target" token needed.
|
||||
local target = token .. "target"
|
||||
local mobTargetGuid = UnitGUID(target)
|
||||
local hasTarget = mobTargetGuid and mobTargetGuid ~= NULL_GUID
|
||||
|
||||
-- PERF: cache the SuperWoW-style "<guid>target" unit token. The concat
|
||||
-- intern-hits Lua's string pool every call; caching once per guid
|
||||
-- saves the hash+lookup. Cleared in NAME_PLATE_UNIT_REMOVED.
|
||||
local target = guidTargetTokenCache[guid]
|
||||
if not target then
|
||||
target = guid .. "target"
|
||||
guidTargetTokenCache[guid] = target
|
||||
end
|
||||
local color = false
|
||||
|
||||
local castInfo = GetCastInfo(guid)
|
||||
local castInfo = GetCastInfo(token)
|
||||
local isCasting = castInfo and castInfo.endTime and now < castInfo.endTime
|
||||
local targetingPlayer = hasTarget and UnitIsUnit(target, "player")
|
||||
|
||||
@@ -466,10 +451,8 @@ nameplates:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
||||
nameplates:RegisterEvent("NAME_PLATE_CREATED")
|
||||
nameplates:RegisterEvent("NAME_PLATE_UNIT_ADDED")
|
||||
nameplates:RegisterEvent("NAME_PLATE_UNIT_REMOVED")
|
||||
if GetUnitField then
|
||||
nameplates:RegisterEvent("UNIT_FLAGS_GUID")
|
||||
nameplates:RegisterEvent("UNIT_AURA_GUID")
|
||||
end
|
||||
nameplates:RegisterEvent("UNIT_AURA")
|
||||
nameplates:RegisterEvent("UNIT_FLAGS")
|
||||
|
||||
nameplates:SetScript("OnEvent", function()
|
||||
-- Stop event handling during logout to prevent crash 132
|
||||
@@ -542,10 +525,12 @@ end
|
||||
end
|
||||
|
||||
elseif event == "NAME_PLATE_UNIT_ADDED" then
|
||||
-- arg1 = "nameplateN" unit token; resolve to GUID for cache keys
|
||||
-- arg1 = "nameplateN" unit token. Cache the GUID for cache keys and the
|
||||
-- token itself for token-based UnitX reads (stable per plate lifetime).
|
||||
local plate = C_NamePlate.GetNamePlateForUnit(arg1)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.cachedGuid = UnitGUID(arg1)
|
||||
plate.nameplate.unit = arg1
|
||||
nameplates.OnShow(plate)
|
||||
end
|
||||
visiblePlateCount = visiblePlateCount + 1
|
||||
@@ -558,53 +543,54 @@ end
|
||||
if guid then
|
||||
if debuffCache[guid] then debuffCache[guid] = nil end
|
||||
if threatMemory[guid] then threatMemory[guid] = nil end
|
||||
if guidTargetTokenCache[guid] then guidTargetTokenCache[guid] = nil end
|
||||
if combatColorCache[guid] then combatColorCache[guid] = nil end
|
||||
local plate = C_NamePlate.GetNamePlateForUnit(arg1)
|
||||
if plate and plate.nameplate and plate.nameplate.cachedGuid == guid then
|
||||
plate.nameplate.cachedGuid = nil
|
||||
plate.nameplate.unit = nil
|
||||
end
|
||||
end
|
||||
|
||||
elseif event == "UNIT_FLAGS_GUID" then
|
||||
-- Nampower: fires instantly when any unit's flags change (e.g. stun, combat enter/leave)
|
||||
-- arg1 = guid — directly flag that nameplate for immediate update, bypassing throttle
|
||||
local plate = C_NamePlate.GetNamePlateForGUID(arg1)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.eventcache = true
|
||||
elseif event == "UNIT_FLAGS" then
|
||||
-- ClassicAPI: fires with arg1 == "nameplateN" when a unit's flags change
|
||||
-- (stun, combat enter/leave). Flag that plate for an immediate update,
|
||||
-- bypassing the throttle. Guard on the token prefix -- UNIT_FLAGS also
|
||||
-- fires for target/party/raid, which aren't ours to handle here.
|
||||
if arg1 and strfind(arg1, "^nameplate") then
|
||||
local plate = C_NamePlate.GetNamePlateForUnit(arg1)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.eventcache = true
|
||||
end
|
||||
end
|
||||
|
||||
elseif event == "UNIT_AURA_GUID" then
|
||||
-- Nampower: fires when a unit's aura set changes (add/remove/modify).
|
||||
-- arg1 = guid. Flag the matching plate so OnUpdate triggers a fresh
|
||||
-- C_UnitAuras read on the next tick instead of waiting on the 0.5s
|
||||
-- throttle — covers expirations, dispels, refreshes, and stack changes
|
||||
-- in one event.
|
||||
local plate = C_NamePlate.GetNamePlateForGUID(arg1)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.auraUpdate = true
|
||||
elseif event == "UNIT_AURA" then
|
||||
-- ClassicAPI: fires with arg1 == "nameplateN" when a unit's aura set
|
||||
-- changes (add/remove/modify). Flag the matching plate so OnUpdate does a
|
||||
-- fresh C_UnitAuras read next tick instead of waiting on the 0.5s
|
||||
-- throttle -- covers expirations, dispels, refreshes, and stack changes
|
||||
-- in one event. Guard on the token prefix (UNIT_AURA also fires for
|
||||
-- target/party/raid).
|
||||
if arg1 and strfind(arg1, "^nameplate") then
|
||||
local plate = C_NamePlate.GetNamePlateForUnit(arg1)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.auraUpdate = true
|
||||
end
|
||||
end
|
||||
|
||||
elseif event == "PLAYER_TARGET_CHANGED" then
|
||||
-- Flag target plate for update via GUID registry
|
||||
local targetGuid = UnitGUID("target")
|
||||
if targetGuid then
|
||||
local plate = C_NamePlate.GetNamePlateForGUID(targetGuid)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.targetUpdate = true
|
||||
end
|
||||
-- Flag the target's plate for update
|
||||
local plate = C_NamePlate.GetNamePlateForUnit("target")
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.targetUpdate = true
|
||||
end
|
||||
-- Also propagate to all plates for alpha/strata updates
|
||||
this.eventcache = true
|
||||
|
||||
elseif event == "PLAYER_COMBO_POINTS" or event == "UNIT_COMBO_POINTS" then
|
||||
-- Only flag the target plate for combo point update
|
||||
local targetGuid = UnitGUID("target")
|
||||
if targetGuid then
|
||||
local plate = C_NamePlate.GetNamePlateForGUID(targetGuid)
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.comboUpdate = true
|
||||
end
|
||||
-- Only flag the target's plate for combo point update
|
||||
local plate = C_NamePlate.GetNamePlateForUnit("target")
|
||||
if plate and plate.nameplate then
|
||||
plate.nameplate.comboUpdate = true
|
||||
end
|
||||
else
|
||||
this.eventcache = true
|
||||
@@ -986,16 +972,14 @@ end
|
||||
-- always make sure to keep plate visible
|
||||
plate:Show()
|
||||
|
||||
if target and cfg.targetglow then
|
||||
plate.glow:Show() else plate.glow:Hide()
|
||||
end
|
||||
plate.glow:SetShown(target and cfg.targetglow)
|
||||
|
||||
-- target indicator
|
||||
if cfg.outcombatstate then
|
||||
local guid = plate.cachedGuid or ""
|
||||
|
||||
-- determine color based on combat state
|
||||
local color = GetCombatStateColor(guid)
|
||||
local color = GetCombatStateColor(guid, plate.unit)
|
||||
if not color then color = combatstate.NONE end
|
||||
|
||||
-- set border color
|
||||
@@ -1070,7 +1054,7 @@ end
|
||||
|
||||
if guild and C.nameplates.showguildname == "1" then
|
||||
plate.guild:SetText(guild)
|
||||
if guild == GetGuildInfo("player") then
|
||||
if UnitIsInMyGuild(plate.unit) then
|
||||
plate.guild:SetTextColor(0, 0.9, 0, 1)
|
||||
else
|
||||
plate.guild:SetTextColor(0.8, 0.8, 0.8, 1)
|
||||
@@ -1089,15 +1073,15 @@ end
|
||||
|
||||
if cfg.showhp then
|
||||
local rhp, rhpmax, estimated
|
||||
local guid = plate.cachedGuid
|
||||
if guid and GetUnitField then
|
||||
local npHp = GetUnitField(guid, "health")
|
||||
local npMaxHp = GetUnitField(guid, "maxHealth")
|
||||
local unit = plate.unit
|
||||
if unit then
|
||||
local npHp = UnitHealth(unit)
|
||||
local npMaxHp = UnitHealthMax(unit)
|
||||
if npHp and npHp > 0 and npMaxHp and npMaxHp > 0 and npMaxHp ~= 100 then
|
||||
rhp, rhpmax = npHp, npMaxHp
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Fallback to existing methods
|
||||
if not rhp then
|
||||
if hpmax > 100 or (round(hpmax/100*hp) ~= hp) then
|
||||
@@ -1148,7 +1132,7 @@ end
|
||||
|
||||
if cfg.barcombatstate then
|
||||
local guid = plate.cachedGuid or ""
|
||||
local color = GetCombatStateColor(guid)
|
||||
local color = GetCombatStateColor(guid, plate.unit)
|
||||
|
||||
if color then
|
||||
r, g, b, a = color.r, color.g, color.b, color.a
|
||||
@@ -1268,19 +1252,7 @@ end
|
||||
end
|
||||
|
||||
nameplates.OnShow = function(frame)
|
||||
local frame = frame or this
|
||||
local nameplate = frame.nameplate
|
||||
|
||||
-- cachedGuid is set by NAME_PLATE_UNIT_ADDED before this fires
|
||||
local guid = nameplate.cachedGuid
|
||||
if guid and pfUI.api.libunitscan and pfUI.api.libunitscan.ScanGuid then
|
||||
-- notify libunitscan so it can cache unit data without mouseover
|
||||
local name = nameplate.original.name:GetText()
|
||||
local npcFlags = GetUnitField(guid, "npcFlags") or 0
|
||||
pfUI.api.libunitscan.ScanGuid(guid, name, npcFlags == 0)
|
||||
end
|
||||
|
||||
nameplates:OnDataChanged(nameplate)
|
||||
nameplates:OnDataChanged((frame or this).nameplate)
|
||||
end
|
||||
|
||||
nameplates.OnUpdate = function(frame, state)
|
||||
@@ -1300,7 +1272,7 @@ end
|
||||
-- smooth animation without overloading the central loop.
|
||||
local isCastingNonTarget = not target and nameplate.castbar and nameplate.castbar:IsShown()
|
||||
if not isCastingNonTarget and not target and cfg.showcastbar and nameplate.cachedGuid then
|
||||
local castInfo = GetCastInfo(nameplate.cachedGuid)
|
||||
local castInfo = GetCastInfo(nameplate.unit)
|
||||
if castInfo and castInfo.endTime > now then
|
||||
isCastingNonTarget = true
|
||||
end
|
||||
@@ -1372,8 +1344,7 @@ end
|
||||
|
||||
if C.nameplates["overlap"] == "1" then
|
||||
if frame:GetWidth() > 1 then
|
||||
frame:SetWidth(1)
|
||||
frame:SetHeight(1)
|
||||
frame:SetSize(1, 1)
|
||||
end
|
||||
else
|
||||
if not nameplate.dwidth then
|
||||
@@ -1381,8 +1352,9 @@ end
|
||||
end
|
||||
|
||||
if floor(frame:GetWidth()) ~= nameplate.dwidth then
|
||||
frame:SetWidth(nameplate:GetWidth() * UIParent:GetScale())
|
||||
frame:SetHeight(nameplate:GetHeight() * UIParent:GetScale())
|
||||
local nameW, nameH = nameplate:GetSize()
|
||||
local uiScale = UIParent:GetScale()
|
||||
frame:SetSize(nameW * uiScale, nameH * uiScale)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1439,13 +1411,7 @@ end
|
||||
|
||||
-- trigger update when name color changed (includes combat state check)
|
||||
local r, g, b = original.name:GetTextColor()
|
||||
local inCombatWithPlayer = false
|
||||
if cfg.namefightcolor then
|
||||
local guid = nameplate.cachedGuid
|
||||
if guid then
|
||||
inCombatWithPlayer = UnitAffectingCombat(guid) and UnitAffectingCombat("player")
|
||||
end
|
||||
end
|
||||
local inCombatWithPlayer = cfg.namefightcolor and UnitAffectingCombat(nameplate.unit) and UnitAffectingCombat("player")
|
||||
|
||||
if r + g + b ~= nameplate.cache.namecolor or (cfg.namefightcolor and nameplate.cache.inCombat ~= inCombatWithPlayer) then
|
||||
nameplate.cache.namecolor = r + g + b
|
||||
@@ -1493,7 +1459,7 @@ end
|
||||
nameplate.health.targetHeight = hc
|
||||
end
|
||||
|
||||
local w, h = nameplate.health:GetWidth(), nameplate.health:GetHeight()
|
||||
local w, h = nameplate.health:GetSize()
|
||||
local wc, hc = nameplate.health.targetWidth, nameplate.health.targetHeight
|
||||
|
||||
if wc and hc then
|
||||
@@ -1513,7 +1479,7 @@ end
|
||||
end
|
||||
end
|
||||
elseif nameplate.health.zoomed or nameplate.health.zoomTransition then
|
||||
local w, h = nameplate.health:GetWidth(), nameplate.health:GetHeight()
|
||||
local w, h = nameplate.health:GetSize()
|
||||
local wc = cfg.width
|
||||
local hc = cfg.heighthealth
|
||||
|
||||
@@ -1522,8 +1488,7 @@ end
|
||||
elseif h > hc + 0.5 then
|
||||
nameplate.health:SetHeight(h*0.95)
|
||||
else
|
||||
nameplate.health:SetWidth(wc)
|
||||
nameplate.health:SetHeight(hc)
|
||||
nameplate.health:SetSize(wc, hc)
|
||||
nameplate.health.zoomTransition = nil
|
||||
nameplate.health.zoomed = nil
|
||||
nameplate.health.targetWidth = nil
|
||||
@@ -1589,7 +1554,7 @@ end
|
||||
-- Shared castbar update logic (used by both dedicated frame and central loop)
|
||||
nameplates.UpdateCastbar = function(nameplate, now)
|
||||
if not nameplate or not nameplate.castbar then return end
|
||||
local castInfo = GetCastInfo(nameplate.cachedGuid)
|
||||
local castInfo = GetCastInfo(nameplate.unit)
|
||||
if not castInfo or castInfo.endTime < now then
|
||||
nameplate.castbar.isShown = nil
|
||||
nameplate.castbar.lastEndTime = nil
|
||||
@@ -1635,10 +1600,7 @@ end
|
||||
if (this.tick or 0) > now then return end
|
||||
this.tick = now + throttle
|
||||
|
||||
local targetGuid = UnitExists("target") and UnitGUID("target")
|
||||
if not targetGuid then return end
|
||||
|
||||
local frame = C_NamePlate.GetNamePlateForGUID(targetGuid)
|
||||
local frame = C_NamePlate.GetNamePlateForUnit("target")
|
||||
if not frame or not frame.nameplate then return end
|
||||
|
||||
nameplates.UpdateCastbar(frame.nameplate, now)
|
||||
|
||||
Reference in New Issue
Block a user