mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 15:46:56 +00:00
00292ca3b4
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.
287 lines
9.3 KiB
Lua
287 lines
9.3 KiB
Lua
pfUI:RegisterModule("raid", function ()
|
|
-- do not go further on disabled UFs
|
|
if C.unitframes.disable == "1" then return end
|
|
|
|
-- tell RaidFrame.lua pfUI replaces party frames
|
|
HookAddonOrVariable("Blizzard_RaidUI", function()
|
|
GROUP_REPLACE_PARTY = "1"
|
|
end)
|
|
|
|
pfUI.uf.raid = CreateFrame("Frame", "pfRaidUpdater", UIParent)
|
|
|
|
local maxraid = tonumber(C.unitframes.maxraid)
|
|
local rawborder, default_border = GetBorderSize("chat")
|
|
local cluster = CreateFrame("Frame", "pfRaidCluster", UIParent)
|
|
cluster:SetFrameLevel(20)
|
|
cluster:SetSize(120, 10)
|
|
cluster:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", default_border*2, C.chat.left.height + default_border*5)
|
|
UpdateMovable(cluster)
|
|
|
|
-- Separate, independently-movable block that mirrors the raid grid layout
|
|
-- for pet frames (raidpet1..40). Defaults to the right of the raid grid.
|
|
local petcluster = CreateFrame("Frame", "pfRaidPetCluster", UIParent)
|
|
petcluster:SetFrameLevel(20)
|
|
petcluster:SetSize(120, 10)
|
|
petcluster:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", default_border*2 + 300, C.chat.left.height + default_border*5)
|
|
UpdateMovable(petcluster)
|
|
|
|
-- flat pool of pet frames, laid out by LayoutPets (mirror or collapsed)
|
|
pfUI.uf.raid.pets = {}
|
|
|
|
-- 1-based grid slot -> (row, col) for the current fill direction, matching
|
|
-- the raid grid's own fill loops.
|
|
local function SlotToCoord(slot, fill, x, y)
|
|
slot = slot - 1
|
|
if fill == "VERTICAL" then
|
|
return floor(slot / y) + 1, mod(slot, y) + 1
|
|
else
|
|
return mod(slot, x) + 1, floor(slot / x) + 1
|
|
end
|
|
end
|
|
|
|
pfUI.uf.raid.tanksfirst = {
|
|
["PF_TANK_TOGGLE"] = { T["Toggle as Tank"], "toggleTank" }
|
|
}
|
|
|
|
-- no tank order for now, just "all tanks first"
|
|
pfUI.uf.raid.tankrole = { }
|
|
|
|
function pfUI.uf.raid:UpdateConfig()
|
|
local rawborder, default_border = GetBorderSize("unitframes")
|
|
maxraid = tonumber(C.unitframes.maxraid)
|
|
local showpets = C.unitframes.raidpet.visible == "1"
|
|
self.showpets = showpets
|
|
|
|
for i=1,maxraid do
|
|
pfUI.uf.raid[i] = pfUI.uf.raid[i] or pfUI.uf:CreateUnitFrame("Raid", i, C.unitframes.raid)
|
|
pfUI.uf.raid[i]:SetParent(cluster)
|
|
pfUI.uf.raid[i]:SetFrameLevel(5)
|
|
|
|
pfUI.uf.raid[i]:UpdateConfig()
|
|
pfUI.uf.raid[i]:UpdateFrameSize()
|
|
|
|
if showpets then
|
|
self.pets[i] = self.pets[i] or pfUI.uf:CreateUnitFrame("RaidPet", i, C.unitframes.raidpet, 0.5)
|
|
self.pets[i]:SetParent(petcluster)
|
|
self.pets[i]:SetFrameLevel(5)
|
|
self.pets[i]:UpdateConfig()
|
|
self.pets[i]:UpdateFrameSize()
|
|
elseif self.pets[i] then
|
|
self.pets[i]:UpdateConfig()
|
|
self.pets[i]:Hide()
|
|
RemoveMovable(self.pets[i])
|
|
end
|
|
end
|
|
|
|
local i = 1
|
|
local width = pfUI.uf.raid[1]:GetWidth()+2*default_border
|
|
local height = pfUI.uf.raid[1]:GetHeight()+2*default_border
|
|
local layout = pfUI.uf.raid[1].config.raidlayout
|
|
local padding = tonumber(pfUI.uf.raid[1].config.raidpadding)*GetPerfectPixel()
|
|
local fill = pfUI.uf.raid[1].config.raidfill
|
|
local _, _, x, y = string.find(layout,"(.+)x(.+)")
|
|
x, y = tonumber(x), tonumber(y)
|
|
|
|
if showpets then
|
|
local petcfg = C.unitframes.raidpet
|
|
local _, _, px, py = string.find(petcfg.raidlayout, "(.+)x(.+)")
|
|
self.petgrid = {
|
|
fill = petcfg.raidfill, x = tonumber(px), y = tonumber(py),
|
|
pad = tonumber(petcfg.raidpadding) * GetPerfectPixel(),
|
|
w = self.pets[1]:GetWidth()+2*default_border,
|
|
h = self.pets[1]:GetHeight()+2*default_border,
|
|
}
|
|
end
|
|
|
|
if fill == "VERTICAL" then
|
|
for r=1, x do for g=1, y do
|
|
if pfUI.uf.raid[i] then
|
|
pfUI.uf.raid[i]:ClearAllPoints()
|
|
pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1)*(padding+width), (g-1)*(padding+height))
|
|
UpdateMovable(pfUI.uf.raid[i], true)
|
|
end
|
|
i = i + 1
|
|
end end
|
|
else
|
|
for g=1, y do for r=1, x do
|
|
if pfUI.uf.raid[i] then
|
|
pfUI.uf.raid[i]:ClearAllPoints()
|
|
pfUI.uf.raid[i]:SetPoint("BOTTOMLEFT", (r-1)*(padding+width), (g-1)*(padding+height))
|
|
UpdateMovable(pfUI.uf.raid[i], true)
|
|
end
|
|
i = i + 1
|
|
end end
|
|
end
|
|
|
|
self:LayoutPets()
|
|
|
|
self:Show()
|
|
end
|
|
|
|
function pfUI.uf.raid:LayoutPets()
|
|
if not self.showpets or not self.petgrid then return end
|
|
local grid = self.petgrid
|
|
|
|
local function place(pet, cell, id)
|
|
pet.id = id
|
|
local r, g = SlotToCoord(cell, grid.fill, grid.x, grid.y)
|
|
pet:ClearAllPoints()
|
|
pet:SetPoint("BOTTOMLEFT", petcluster, "BOTTOMLEFT", (r-1)*(grid.pad+grid.w), (g-1)*(grid.pad+grid.h))
|
|
UpdateMovable(pet, true)
|
|
pet:UpdateVisibility()
|
|
end
|
|
|
|
if pfUI.uf.showall then
|
|
for id = 1, maxraid do
|
|
if self.pets[id] then place(self.pets[id], id, id) end
|
|
end
|
|
return
|
|
end
|
|
|
|
if C.unitframes.raidpet.collapse == "1" then
|
|
-- Pack the pets that exist into the leading cells, no gaps.
|
|
local k = 0
|
|
for id = 1, maxraid do
|
|
if UnitExists("raidpet"..id) and self.pets[k+1] then
|
|
k = k + 1
|
|
place(self.pets[k], k, id)
|
|
end
|
|
end
|
|
for j = k+1, maxraid do
|
|
if self.pets[j] then self.pets[j].id = 0 self.pets[j]:Hide() end
|
|
end
|
|
else
|
|
-- Mirror: cell N always shows raidpet<N> at a fixed position.
|
|
for id = 1, maxraid do
|
|
if self.pets[id] then place(self.pets[id], id, id) end
|
|
end
|
|
end
|
|
end
|
|
|
|
pfUI.uf.raid:UpdateConfig()
|
|
|
|
local function SetRaidIndex(frame, id)
|
|
frame.id = id
|
|
frame.label = "raid"
|
|
frame:UpdateVisibility()
|
|
end
|
|
|
|
-- add units to their groups; collapse packs everyone into the leading slots
|
|
function pfUI.uf.raid:AddUnitToGroup(index, group)
|
|
if C.unitframes.raid.collapse == "1" then
|
|
for ids = 1, maxraid do
|
|
if pfUI.uf.raid[ids] and pfUI.uf.raid[ids].id == 0 and pfUI.uf.raid[ids].config.visible == "1" then
|
|
SetRaidIndex(pfUI.uf.raid[ids], index)
|
|
return
|
|
end
|
|
end
|
|
else
|
|
for subindex = 1, 5 do
|
|
local ids = subindex + 5*(group-1)
|
|
if pfUI.uf.raid[ids] and pfUI.uf.raid[ids].id == 0 and pfUI.uf.raid[ids].config.visible == "1" then
|
|
SetRaidIndex(pfUI.uf.raid[ids], index)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
pfUI.uf.raid:Hide()
|
|
pfUI.uf.raid:RegisterEvent("RAID_ROSTER_UPDATE")
|
|
pfUI.uf.raid:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
|
pfUI.uf.raid:RegisterEvent("PARTY_LEADER_CHANGED")
|
|
pfUI.uf.raid:RegisterEvent("VARIABLES_LOADED")
|
|
pfUI.uf.raid:RegisterEvent("UNIT_PET")
|
|
pfUI.uf.raid:SetScript("OnEvent", function()
|
|
if event == "UNIT_PET" then
|
|
if this.showpets and C.unitframes.raidpet.collapse == "1" then
|
|
this:LayoutPets()
|
|
end
|
|
return
|
|
end
|
|
this:Show()
|
|
-- Debounce: delay update by 0.5s to batch rapid roster changes (mass swaps)
|
|
this.pendingUpdate = GetTime() + 0.5
|
|
end)
|
|
pfUI.uf.raid:SetScript("OnUpdate", function()
|
|
-- Wait for debounce: don't update until 0.5s after last event
|
|
if this.pendingUpdate and GetTime() < this.pendingUpdate then return end
|
|
-- Throttle raid roster updates to 1 FPS max
|
|
if (this.tick or 0) > GetTime() then return end
|
|
this.tick = GetTime() + 1.0
|
|
this.pendingUpdate = nil
|
|
|
|
-- don't proceed without raid
|
|
if not IsInRaid() then return end
|
|
|
|
-- clear all existing frames
|
|
for i=1, maxraid do SetRaidIndex(pfUI.uf.raid[i], 0) end
|
|
|
|
-- sort tanks into their groups
|
|
for i=1, GetNumRaidMembers() do
|
|
local name, _, subgroup = GetRaidRosterInfo(i)
|
|
if name and pfUI.uf.raid.tankrole[name] then
|
|
pfUI.uf.raid:AddUnitToGroup(i, subgroup)
|
|
end
|
|
end
|
|
|
|
-- sort players into roster
|
|
for i=1, GetNumRaidMembers() do
|
|
local name, _, subgroup = GetRaidRosterInfo(i)
|
|
if name and not pfUI.uf.raid.tankrole[name] then
|
|
pfUI.uf.raid:AddUnitToGroup(i, subgroup)
|
|
end
|
|
end
|
|
|
|
this:LayoutPets()
|
|
|
|
-- Smart GUID-based updates: only refresh frames where unit changed
|
|
if pfUI.uf.guidTracker then
|
|
local tracker = pfUI.uf.guidTracker
|
|
|
|
for i = 1, maxraid do
|
|
local frame = pfUI.uf.raid[i]
|
|
if frame and frame.id and frame.id > 0 then
|
|
local unit = "raid" .. frame.id
|
|
local newGuid = UnitGUID(unit)
|
|
local oldGuid = tracker.frameToGuid[frame]
|
|
|
|
if newGuid ~= oldGuid then
|
|
-- GUID changed = different player = need full update
|
|
tracker.frameToGuid[frame] = newGuid
|
|
frame.update_full = true
|
|
frame.update_aura = true -- Force aura refresh!
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-- rebuild unitmap after frame IDs are assigned
|
|
if pfUI.uf.RebuildUnitmap then
|
|
pfUI.uf.RebuildUnitmap()
|
|
end
|
|
|
|
this:Hide()
|
|
end)
|
|
|
|
-- raid popup option to toggle tank role
|
|
for _, menu in pairs({"RAID", "PARTY"}) do
|
|
for label, data in pairs(pfUI.uf.raid.tanksfirst) do
|
|
UnitPopupButtons[label] = { text = TEXT(data[1]), dist = 0 }
|
|
table.insert(UnitPopupMenus[menu], 3, label)
|
|
end
|
|
end
|
|
|
|
hooksecurefunc("UnitPopup_OnClick", function()
|
|
local dropdownFrame = UIDROPDOWNMENU_INIT_MENU and _G[UIDROPDOWNMENU_INIT_MENU]
|
|
if not dropdownFrame then return end
|
|
local button = this.value
|
|
local unit = dropdownFrame.unit
|
|
local name = dropdownFrame.name
|
|
|
|
if button and pfUI.uf.raid.tanksfirst[button] and name then
|
|
pfUI.uf.raid.tankrole[name] = not pfUI.uf.raid.tankrole[name]
|
|
pfUI.uf.raid:Show()
|
|
end
|
|
end)
|
|
end) |