From ba176a3ba9a6ef1e1b38159ff6aefa4c84976572 Mon Sep 17 00:00:00 2001 From: Sean Shaffer Date: Mon, 16 Nov 2026 05:58:00 -0600 Subject: [PATCH 1/5] Record the 1.15.32 and 1.15.33 field test as passed SEAN reported every checklist step passed, including the new restricted-aura check from the wow-addon-api audit. Co-Authored-By: Claude Opus 5.5 --- QUALITY.md | 3 ++- docs/DECISIONS.md | 14 ++++++++++++++ docs/FOREVER_RELEASE_CHECKLIST.md | 8 ++++++++ docs/PARITY.md | 4 ++-- docs/RISK_MATRIX.md | 5 ++--- editions/forever/FEATURES.md | 7 ++++--- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/QUALITY.md b/QUALITY.md index 9affd92..6f367c4 100644 --- a/QUALITY.md +++ b/QUALITY.md @@ -49,7 +49,8 @@ Re-checked on 2026-11-16 after SEAN reported that every release through 1.15.31 passed in game: the UX field-test waiver is **closed**. UX moves 2→4 and Correctness 4→5, as this scorecard set out; **total 69→74**. Multi-user coordination is covered by that report. 1.15.32 -(Shadowguard watch) and 1.15.33 (input hardening) are Unverified in game. +(Shadowguard watch) and 1.15.33 (input hardening) passed their checklist +steps in game later the same day (SEAN); no score changes. Re-scored the same day against the current tree (1.15.32): stale rows that still described the single-file layout, the parked items and the 1.10.0 corpus were brought up to date. Feature completeness 3→4 (program done, diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index f386c52..f6ca099 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -296,6 +296,20 @@ split, then Briefs 2, 3, 4 — nothing else built; file-split Slices B 3 -> 4); maintainability stays 3 because `BuffRadar.lua` has grown back to ~9,700 lines. +## 2026-11-16 — Field test passed for 1.15.32 and 1.15.33 (SEAN) + +- SEAN reported "all steps passed" for the 1.15.33 and 1.15.32 checklist + sections: ignore-name refusal, the 16 KiB import cap, group and raid + scans, and the Shadowguard watch. Both are now Verified in game on + Forever; the client build was not recorded. +- An API audit against the `wow-addon-api` server (Forever 1.60.1.70755, + source commit 17ed2c3e) found BuffRadar's handling of `UnitExists`, + `UnitGUID`, `UnitClass`, `UnitName` and the `C_UnitAuras` reads matches + their secret-value and aura-access metadata. Its one open question + (could a restricted aura read pass as a definitive "absent"?) became a + checklist step, and it passed: an ungrouped player's existing buff + never showed as missing. + ## 2026-11-16 — Risk matrix and robustness pass - SEAN asked for an exhaustive use-case / risk / test matrix, defensive diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index ba1d71d..67c50b2 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -4,15 +4,23 @@ Run this against the exact candidate ZIP after CI passes. Record the version, cl ## 1.15.33 Input hardening +Result: **passed** — SEAN, reported 2026-11-16 (client build not recorded). + - Run `/br ignore |cffff0000Red|r` and check that it is refused. Run `/br ignore` with a plain name and check that it is added. - Import an ignore-list string over 16 KiB and check that it is refused with nothing added. Import a normal `BRI1;` string and check that it works. - In a 5-player group and a raid, check that the list still fills and updates as normal while you buff, including pets and the tooltip. +- With friendly nameplates on, stand near an ungrouped player who already + has one of your buffs and run `/br why `. The buff must read as + present or unverified, never as missing (a restricted aura read must not + pass as a definitive "absent"). ## 1.15.32 Shadowguard watch +Result: **passed** — SEAN, reported 2026-11-16 (client build not recorded). + - On a priest who knows Shadowguard, run `/br buffs` and check that `SHADOWGUARD` is listed and on. Let Shadowguard expire and verify you are listed as missing it; cast it and verify the row clears. diff --git a/docs/PARITY.md b/docs/PARITY.md index c23fa42..8e2bf7c 100644 --- a/docs/PARITY.md +++ b/docs/PARITY.md @@ -11,8 +11,8 @@ further SEAN-requested customization batch (10 items) shipped in "Complete" below names its test evidence. In-game status: **1.12.0 verified by SEAN on Forever 1.60.1.70862** (2026-11-08), and SEAN reported on 2026-11-16 that every -release through **1.15.31** passed in game. Only 1.15.32 (Shadowguard -watch) and 1.15.33 (input hardening) remain Unverified. +release through **1.15.31** passed in game; 1.15.32 (Shadowguard watch) +and 1.15.33 (input hardening) passed the same day. | Area | Target | State | Evidence (test / corpus) | Gap | |---|---|---|---|---| diff --git a/docs/RISK_MATRIX.md b/docs/RISK_MATRIX.md index 24ea68e..a1ac5d5 100644 --- a/docs/RISK_MATRIX.md +++ b/docs/RISK_MATRIX.md @@ -7,7 +7,7 @@ marked `coord:` (`tools/coordination51.py`) or `gate` (`tools/gate.sh` / This matrix does not claim the addon is flawless. Every test runs in a fake game client. In-game behaviour is only as verified as the maintainer's field -passes, and the last one covered releases through 1.15.31. +passes, and the last one covered releases through 1.15.33. **Status key** - **Covered:** mitigated, with an automated test that fails if the mitigation is removed. @@ -149,8 +149,7 @@ passes, and the last one covered releases through 1.15.31. - **Fake client:** taint, real frame timing, server-side addon-message throttling and real secret-value behaviour can't be reproduced offline. A passing gate is evidence, not proof. -- **In-game verification:** releases through 1.15.31 are field-verified. - 1.15.32 and 1.15.33 are Unverified in game. +- **In-game verification:** releases through 1.15.33 are field-verified. - **Fuzzing is sampled:** about 1,000 inputs per parser, 3,000 messages, 1,500 commands, 250 corrupt saves and 200 API-chaos rounds per setup. It finds shallow-to-medium defects; it can't prove their absence. The diff --git a/editions/forever/FEATURES.md b/editions/forever/FEATURES.md index 91a4c61..5d57e5c 100644 --- a/editions/forever/FEATURES.md +++ b/editions/forever/FEATURES.md @@ -373,9 +373,10 @@ stays hidden on those characters. ## Verification status -**Field test through 1.15.31:** on 2026-11-16 the maintainer reported that +**Field test through 1.15.33:** on 2026-11-16 the maintainer reported that every release up to and including 1.15.31 passed in-game testing in WoW: -Forever. 1.15.32 (Shadowguard watch) and 1.15.33 (input hardening) are not yet verified in game. +Forever, and later that day that 1.15.32 (Shadowguard watch) and 1.15.33 +(input hardening) passed their checklist steps too. **Current stable release:** 1.15.16. The maintainer confirmed live verification in WoW: Forever on 2026-11-14 using field-test build `d05115bdb03d`. @@ -390,7 +391,7 @@ WoW: Forever on 2026-11-14. 2026-10-20. **1.12.0 was verified in game by SEAN on Forever 1.60.1.70862** (2026-11-08) — that run covers the cumulative 1.3.2–1.12.0 feature set on the Forever client. 1.13.0 through - 1.15.31 were verified in game by the maintainer (reported + 1.15.33 were verified in game by the maintainer (reported 2026-11-16). A first in-game look at 1.15.0 (2026-11-11) found settings-window layout faults, fixed in 1.15.1. The Retail edition ended at 1.7.0 (Interface 120105), a separate zip from the same source with its From 07cb6be6db9c1044a20e63a99d69f921ba66504b Mon Sep 17 00:00:00 2001 From: Sean Shaffer Date: Mon, 16 Nov 2026 06:09:40 -0600 Subject: [PATCH 2/5] Split coordination and wizard code out of BuffRadar.lua File split Slices E and F: cast sync, caster coordination, chat requests, context checks and the join digest move to Coordination.lua; the setup wizard, themes, alert flash, range and fall checks, /br why, history/stats text and the export dialog move to Wizard.lua. Both reach the main file through X.coordAPI / X.wizAPI and receive the settings table through X.dbSinks. BuffRadar.lua: 9,741 -> 8,017 lines. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 6 +- BuffRadar/BuffRadar.lua | 1814 +---------------------------- BuffRadar/BuffRadar.toc | 2 + BuffRadar/Coordination.lua | 1173 +++++++++++++++++++ BuffRadar/Wizard.lua | 671 +++++++++++ QUALITY.md | 2 +- README.md | 3 +- docs/DECISIONS.md | 29 + docs/FOREVER_RELEASE_CHECKLIST.md | 16 + docs/RISK_MATRIX.md | 2 +- editions/forever/BuffRadar.toc | 2 + tools/check.ps1 | 2 +- tools/gate.sh | 2 +- tools/smoke51.py | 40 +- 14 files changed, 1985 insertions(+), 1779 deletions(-) create mode 100644 BuffRadar/Coordination.lua create mode 100644 BuffRadar/Wizard.lua diff --git a/AGENTS.md b/AGENTS.md index fc85885..b0a4220 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ Purpose in one line: a click-to-buff list addon for World of Warcraft — it sho every nearby player who is missing one of your buffs; click a name (or press one key) to buff them. -Frozen foundation: one shared Lua source (`BuffRadar/Data.lua` + `BuffRadar/BuffRadar.lua` + `BuffRadar/Config.lua` + `BuffRadar/Slash.lua` + `BuffRadar/Extras.lua` + `BuffRadar/Recaps.lua` + `BuffRadar/Profiles.lua`) builds both +Frozen foundation: one shared Lua source (`BuffRadar/Data.lua` + `BuffRadar/BuffRadar.lua` + `BuffRadar/Coordination.lua` + `BuffRadar/Wizard.lua` + `BuffRadar/Config.lua` + `BuffRadar/Slash.lua` + `BuffRadar/Extras.lua` + `BuffRadar/Recaps.lua` + `BuffRadar/Profiles.lua`) builds both editions; editions differ only in their `.toc` and bundled docs (`BuffRadar/` = Retail docs, `editions/forever/` = Forever docs). Every feature is reachable as a `/br` slash command — the slash surface is the operation @@ -30,8 +30,8 @@ lands with steps in every setup it applies to. Budgets: the host's per-frame budget governs — scanning is event-driven plus a throttled ticker; no per-frame polling. Lua 5.1 hard limits enforced by -`tools/lualimits.py`: ≤200 top-level locals (currently 194), ≤60 upvalues per -function (currently 59 peak). New state goes in the `X` table or methods, never +`tools/lualimits.py`: ≤200 top-level locals (currently 176 in `BuffRadar.lua`), ≤60 upvalues per +function (currently 58 peak, `HandleSlash`). New state goes in the `X` table or methods, never new file-scope locals, unless the budget is re-checked in the same change. Coverage floors: every user-visible capability has smoke evidence before it is diff --git a/BuffRadar/BuffRadar.lua b/BuffRadar/BuffRadar.lua index a397f69..b813af2 100644 --- a/BuffRadar/BuffRadar.lua +++ b/BuffRadar/BuffRadar.lua @@ -4329,7 +4329,7 @@ local BuildMinimapButton, RefreshMinimapButton -- assigned in the minimap secti local footerText -- (X.sessionCasts, the cast tracking, the double-buffered listed sets and -- X.recentlyGone live on X since 1.4.0 -- see the enhancement state block.) -local lastSoundAt = 0 +X.lastSoundAt = 0 -- shared with Coordination.lua (Slice E) local function InInstanceNow() if IsInInstance then @@ -4694,1144 +4694,10 @@ end end -- cast tracking --------------------------------------------------------------------------- --- Coordination (1.5.0): cast sync between BuffRadar users, chat buff --- requests, and a one-line summary when you join a group. +-- Coordination (cast sync, caster coordination, chat requests, context +-- checks, join digest) lives in Coordination.lua since 1.15.34 (file split +-- Slice E); it reaches this file's locals through X.coordAPI (bottom). --------------------------------------------------------------------------- -function X.InitSync() - if X.syncReg then return end - X.syncReg = true - if _G.C_ChatInfo and _G.C_ChatInfo.RegisterAddonMessagePrefix then - pcall(_G.C_ChatInfo.RegisterAddonMessagePrefix, "BuffRadar") - elseif _G.RegisterAddonMessagePrefix then - pcall(_G.RegisterAddonMessagePrefix, "BuffRadar") - end -end - -local function SyncChannel() - if InRaid() then return "RAID" end - if InGroup() then return "PARTY" end -end - --- One broadcast to the group's BuffRadar users (party or raid channel). -function X.Broadcast(msg) - if not db or not db.sync then return false end - local channel = SyncChannel() - local send = (_G.C_ChatInfo and _G.C_ChatInfo.SendAddonMessage) or _G.SendAddonMessage - if not channel or not send then return false end - local ok, result = pcall(send, "BuffRadar", msg, channel) - if not ok then return false end - if type(result) == "nil" then return true end -- legacy API has no return value - if not Readable(result) then return false end - if type(result) == "number" then - local success = _G.Enum and _G.Enum.SendAddonMessageResult and _G.Enum.SendAddonMessageResult.Success - return result == (success or 0) - end - return result ~= false -end - --- Tell the other BuffRadar users in the group "I just cast KEY on GUID", --- so their lists sink that player instead of double-casting the same buff. -function X.SyncSend(key, guid) - local message = "CAST;" .. key .. ";" .. guid - if CLASSIC_FEATURES then X.SendScopedSync(message) else X.Broadcast(message) end -end - --- Cover-me handoff (1.7.0): while you're dead or AFK, tell the other --- BuffRadar users so your duties pass to them; tell them when you're --- back. Broadcasts on state change, and re-sends every couple of --- minutes while you're still away so their cover doesn't lapse. -function X.SendCover() - if not db then return end - local me = Ignore.UnitNames("player") - if not me then return end - local covered = X.PlayerSuspended() or X.ReadUnitBool(_G.UnitIsAFK, "player") == true - if X.myCover == covered and not covered then return end - if X.myCover == covered and GetTime() - (X.coverSentAt or 0) < 120 then return end - X.myCover = covered - X.coverSentAt = GetTime() - X.Broadcast((covered and "COVER;" or "BACK;") .. me) -end - --- Do two player names refer to the same user? Names ride the wire as --- typed (often the bare short name), while identity checks use full --- "Name-Realm" strings. Same when the full names match, or the short --- names match and neither side names a conflicting realm — the same --- rule the ignore list has always used for bare names. -function X.SameUser(a, b) - if not a or not b then return false end - if Ignore.Key(a) == Ignore.Key(b) then return true end - local as, ar = a:match("^([^%-]+)%-?(.*)$") - local bs, br = b:match("^([^%-]+)%-?(.*)$") - if Ignore.Key(as or "") ~= Ignore.Key(bs or "") then return false end - if ar and ar ~= "" and br and br ~= "" - and Ignore.Key(ar) ~= Ignore.Key(br) then return false end - return true -end - -do - local supportedKeys = { BLESSINGS = true } - for _, def in ipairs(BUFF_DEFS) do supportedKeys[def.key] = true end - for _, def in ipairs(X.AURA_DEFS or {}) do supportedKeys[def.key] = true end - - local function ReadText(value) - return type(value) == "string" and Readable(value) - end - - local function ValidName(name) - return ReadText(name) and #name <= 128 and name:find("%S") and not name:find("[%c;|]") - end - - local function ValidBuffKey(key) - return supportedKeys[key] or (#key <= 16 and key:match("^CUSTOM[1-9]%d*$")) - end - - -- A refused realm is different from a readable empty realm, which means local. - -- The ignore list can fall back to a short name, but roster authorization - -- must never fill in a realm the game withheld. - local function RosterNames(unit) - local ok, name, realm = pcall(UnitFullName or UnitName, unit) - if not ok or not ValidName(name) then return end - if type(realm) ~= "nil" and (not ReadText(realm) or (realm ~= "" and not ValidName(realm))) then return end - if not realm or realm == "" then - if GetNormalizedRealmName then - local realmOK, localRealm = pcall(GetNormalizedRealmName) - if realmOK and ValidName(localRealm) then realm = localRealm end - end - end - return realm and realm ~= "" and name .. "-" .. realm:gsub("%s+", "") or name, name - end - - -- Match a full name exactly, or accept a bare name only if it is unique - -- across the readable roster. The raid list already includes the player. - function X.SenderUnit(sender) - if not ValidName(sender) then return end - local key = Ignore.Key(sender) - local qualified = key:find("-", 1, true) - local raid = InRaid() - local roster = raid and RAID or PARTY - local found, canonical - for i = raid and 1 or 0, #roster do - local unit = roster[i] or "player" - if X.ReadUnitBool(UnitExists, unit) == true then - local full, short = RosterNames(unit) - if not full then - if not qualified then return end - elseif key == Ignore.Key(qualified and full or short) then - if found then return end - found, canonical = unit, full - end - end - end - return found, canonical - end - - local function PlanRank(unit) - local leader = X.ReadUnitBool(_G.UnitIsGroupLeader, unit) - if leader == true then return 2 end - local assistant = X.ReadUnitBool(_G.UnitIsGroupAssistant, unit) - local idx = unit:match("^raid(%d+)$") - if idx and GetRaidRosterInfo then - local ok, _, rank = pcall(GetRaidRosterInfo, tonumber(idx)) - if ok and type(rank) == "number" and Readable(rank) and rank == 2 then return 2 end - if ok and type(rank) == "number" and Readable(rank) and rank == 1 then return 1 end - if assistant == true then return 1 end - if ok and type(rank) == "number" and Readable(rank) and rank == 0 then return 0 end - end - if assistant == true then return 1 end - if leader == false and (assistant == false or not InRaid()) then return 0 end - end - - local function HasPlanRole(unit, forBless) - if (PlanRank(unit) or 0) > 0 then return true end - if forBless then - local ok, _, class = pcall(UnitClass, unit) - return ok and ReadText(class) and class == "PALADIN" - end - return false - end - - function X.SenderTrusted(sender, forBless) - local unit = X.SenderUnit(sender) - return unit ~= nil and HasPlanRole(unit, forBless) - end - - function X.AmLead() - if HasPlanRole("player") then return true end - if InRaid() then - for i = 1, #RAID do - if X.IsSelf(RAID[i]) == true then return HasPlanRole(RAID[i]) end - end - end - return false - end - - function X.PruneSyncRoster() - if not next(X.peers) and not next(X.cover) then return end - local roster = InRaid() and RAID or PARTY - local present = {} - for _, unit in ipairs(roster) do - if X.ReadUnitBool(UnitExists, unit) == true then - local full = RosterNames(unit) - if full then present[Ignore.Key(full)] = true end - end - end - for key in pairs(X.peers) do - if not present[key] then X.peers[key] = nil end - end - for name in pairs(X.cover) do - if not present[Ignore.Key(name)] then X.cover[name] = nil end - end - end - - local function RememberCast(guid, key, now) - if not X.handled[guid] then - local count, oldestGuid, oldestTime = 0, nil, now - for seenGuid, handled in pairs(X.handled) do - count = count + 1 - if not oldestGuid or handled.t < oldestTime then - oldestGuid, oldestTime = seenGuid, handled.t - end - end - if count >= 128 then X.handled[oldestGuid] = nil end - end - X.handled[guid] = { key = key, t = now } - end - - local function OtherSyncSender(sender, channel) - local unit, name = X.SenderUnit(sender) - if not unit or unit == "player" then return end - local me, senderKey = RosterNames("player"), Ignore.Key(name) - if me and senderKey == Ignore.Key(me) then return end - if channel == "RAID" then - local isSelf = X.IsSelf(unit) - if isSelf == true or (isSelf == nil and not me) then return end - end - return unit, name, senderKey, me - end - - do - local active, sequence, generation, token = nil, 0, 0, 0 - local resetReason - local scope, nonceSerial - local departedScopes, departedCount = {}, 0 - local retired, retirementOrder, retirementSlot = {}, {}, 1 - local statusLabels = { sent = "Awaiting acknowledgement", acknowledged = "Acknowledged", - failed = "Send failed", localOnly = "Assigned locally" } - - local function SetSession(session, rosterChanged) - active = session - resetReason = rosterChanged and "Caster coordination was cleared because the group or its leadership changed." or nil - generation = generation + 1 - token = token + 1 - end - - local function NotifyCoordination() - token = token + 1 - if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end - end - - local function CoordinationGUID(unit) - local ok, guid = pcall(UnitGUID, unit) - if ok and ReadText(guid) and #guid <= 85 and guid:match("^Player%-%w[%w%-]*$") then return guid end - end - - local function CoordinationRoster() - local channel = SyncChannel() - if not channel then return end - local members, ids, leaders = {}, {}, 0 - local size = X.ReadUnitNumber(GetNumGroupMembers) - X.ForReportRoster(function(unit, exists) - local guid = exists and CoordinationGUID(unit) - local name = guid and RosterNames(unit) - local rank = name and PlanRank(unit) - if rank ~= nil and not members[guid] then - members[guid] = { name = name, unit = unit } - ids[#ids + 1] = guid .. "=" .. rank - if rank == 2 then leaders = leaders + 1 end - end - end) - if size ~= #ids or leaders ~= 1 then return end - table_sort(ids) - return members, channel .. ":" .. table.concat(ids, ",") - end - - local function SyncDigest(identity) - local first, second = 0, 0 - for i = 1, #identity do - local byte = identity:byte(i) - first = (first * 131 + byte) % 2147483647 - second = (second * 137 + byte) % 2147483629 - end - return string_format("%08x%08x", first, second) - end - - local function NewSyncNonce() - nonceSerial = (nonceSerial or 0) + 1 - return string_format("%06x%06x%06x%06x", math.random(0, 0xffffff), math.random(0, 0xffffff), - math_floor(GetTime() * 1000) % 0x1000000, nonceSerial % 0x1000000) - end - - local function RetireSyncEpoch(guid, epoch) - if not epoch then return end - local key = guid .. ":" .. epoch - if retired[key] then return end - local oldest = retirementOrder[retirementSlot] - if oldest then retired[oldest] = nil end - retired[key] = true - retirementOrder[retirementSlot] = key - retirementSlot = retirementSlot % 160 + 1 - end - - local function RememberDepartedScope(identity) - if not departedScopes or departedScopes[identity] then return end - if departedCount >= 64 then - -- Once the history is full, require a fresh proof floor on every entry. - departedScopes = nil - return - end - departedScopes[identity] = true - departedCount = departedCount + 1 - end - - local function BroadcastSyncWarmup(current, now) - local nonce = NewSyncNonce() - if not X.Broadcast("SYNC;3;B;" .. current.digest .. ";" .. nonce) then return false end - current.priorWarmNonce, current.warmNonce, current.warmExpires = current.warmNonce, nonce, now + 3 - return true - end - - local function RetrySyncWarmup(current) - if not current or scope ~= current or not current.warmRetryAt then return end - local now = GetTime() - if now < current.warmRetryAt then return end - current.warmRetryAt = nil - if not db or not db.sync then return end - local members, identity = CoordinationRoster() - local me = CoordinationGUID("player") - if identity ~= current.identity or not me or not members[me] then return end - for guid in pairs(members) do - local peer = current.peers[guid] - if guid ~= me and not (peer and peer.epoch) then - if BroadcastSyncWarmup(current, now) then - -- Reordered data can still be proved by either broadcast. Keep - -- only the existing bounded queues for this one extra window. - for _, unresolved in pairs(current.peers) do - if not unresolved.epoch and unresolved.pending then - for _, pending in ipairs(unresolved.pending) do - if not pending.challenge then pending.expires = current.warmExpires end - end - end - end - end - return - end - end - end - - local function StartSyncWarmup(current) - if not current or not current.requireProofFloor or current.warmAttempted or not db or not db.sync then return end - current.warmAttempted = true - local now = GetTime() - BroadcastSyncWarmup(current, now) - current.warmRetryAt = now + 3 - if C_Timer and C_Timer.After then - C_Timer.After(3, function() RetrySyncWarmup(current) end) - end - end - - function X.RunDueSyncWarmupRetry() - RetrySyncWarmup(scope) - end - - local function UpdateSyncScope(force) - if not CLASSIC_FEATURES then return end - local members, identity = CoordinationRoster() - if scope and scope.identity == identity and not force then - StartSyncWarmup(scope) - return scope, members - end - if scope then - RememberDepartedScope(scope.identity) - -- Remember epochs seen in the last scope in case this roster returns. - for guid, peer in pairs(scope.peers) do - RetireSyncEpoch(guid, peer.epoch) - if peer.observed then - for _, epoch in ipairs(peer.observed) do RetireSyncEpoch(guid, epoch) end - end - end - wipe(X.handled) - end - if active and (force or active.identity ~= identity) then SetSession(nil, true) end - scope = identity and { identity = identity, digest = SyncDigest(identity), epoch = NewSyncNonce(), - requireProofFloor = not departedScopes or departedScopes[identity], seq = 0, peers = {} } or nil - StartSyncWarmup(scope) - return scope, members - end - - function X.SendScopedSync(payload) - if not db or not db.sync then return false end - local current = UpdateSyncScope() - if not current then return false end - local seq = current.seq + 1 - local message = "SYNC;3;D;" .. current.digest .. ";" .. current.epoch .. ";" .. seq .. ";" .. payload - if #message > 255 or not X.Broadcast(message) then return false end - current.seq = seq - return true - end - - local function Session() - if not active then return end - if not db or not db.sync then SetSession(nil); return end - local _, members = UpdateSyncScope() - return active, members - end - - local function LearnedKeys() - local keys = {} - for _, buff in ipairs(myBuffs) do - if supportedKeys[buff.key] and not buff.self and not buff.custom - and IsOn(buff.key, buff.default) and X.ContextOK(buff.key) then keys[buff.key] = true end - end - if X.HasKnownBlessings() and IsOn("BLESSINGS", true) and X.ContextOK("BLESSINGS") then - keys.BLESSINGS = true - end - return keys - end - - local function SortedKeys(keys) - local list = {} - for key in pairs(keys) do list[#list + 1] = key end - table_sort(list) - return list - end - - local function KeyList(keys) - return table.concat(SortedKeys(keys), ",") - end - - local function ParseKeys(list) - if list == "-" then return {} end - if not list:match("^[%u_]+[,_%u]*$") then return end - local keys = {} - for key in list:gmatch("[%u_]+") do - if keys[key] or not supportedKeys[key] then return end - keys[key] = true - end - if KeyList(keys) == list then return keys end - end - - local function SendCoord(kind, id, recipient, list) - local message = "COORD;1;" .. kind .. ";" .. id - if recipient then message = message .. ";" .. recipient end - if list then message = message .. ";" .. (list ~= "" and list or "-") end - return X.SendScopedSync(message) - end - - local function NextCoordID() - sequence = sequence + 1 - return string_format("%d.%d", math_floor(GetTime() * 1000), sequence) - end - - local function DraftPlan(session, members, localGUID, localKeys) - local demand, ordered, rows, loads = {}, {}, {}, {} - for key in pairs(session.requested) do demand[key] = true end - for guid, report in pairs(session.reports) do - if members[guid] then - if guid == localGUID then report = localKeys end - for key in pairs(report) do demand[key] = true end - end - end - for key in pairs(demand) do ordered[#ordered + 1] = key end - table_sort(ordered) - for _, key in ipairs(ordered) do - local manual = X.assign[key] - local choice - if not manual then - for guid, report in pairs(session.reports) do - if guid == localGUID then report = localKeys end - if members[guid] and report[key] then - local load, existing = loads[guid] or 0, loads[choice] or 0 - if not choice or load < existing or (load == existing and guid < choice) then choice = guid end - end - end - end - rows[#rows + 1] = { key = key, guid = choice, manual = manual } - if choice then loads[choice] = (loads[choice] or 0) + 1 end - end - return rows - end - - local function SamePlan(a, b) - if #a ~= #b then return false end - for i, row in ipairs(a) do - local other = b[i] - if row.key ~= other.key or row.guid ~= other.guid or row.manual ~= other.manual then return false end - end - return true - end - - local function PlanNames(row, members) - local before = row.manual or L["Unassigned"] - local after = row.guid and members[row.guid].name or row.manual or L["Provider unavailable"] - return before, after - end - - local function ReviewPlan(session, members) - local me = CoordinationGUID("player") - if me then session.reports[me] = LearnedKeys() end - session.draft = DraftPlan(session, members) - Print(L["Review Caster Plan"]) - if #session.draft == 0 then Print(L["No learned buff capabilities have been reported."]) end - for _, row in ipairs(session.draft) do - local before, after = PlanNames(row, members) - Print(string_format(L["%s: %s -> %s"], row.key, before, after)) - end - end - - local function ParsePlanRest(value) - local revision, target, list = value:match("^(%d+%.%d+);([^;]+);([^;]+)$") - if revision and #revision <= 32 then return revision, target, ParseKeys(list) end - end - - local function NewerRevision(revision, previous) - if not previous then return true end - local millis, order = revision:match("^(%d+)%.(%d+)$") - local oldMillis, oldOrder = previous:match("^(%d+)%.(%d+)$") - return tonumber(millis) > tonumber(oldMillis) - or (tonumber(millis) == tonumber(oldMillis) and tonumber(order) > tonumber(oldOrder)) - end - - local function PendingPlan(session, members, now) - local pending = session.pending - local coordinator = pending and members[pending.sender] - local reply = coordinator and session.replies[pending.sender] - if reply and reply.id == pending.id and now - reply.time <= 180 and HasPlanRole(coordinator.unit) then - return pending, reply.time + 180 - end - end - - function X.CoordinationSnapshot() - local snapshot = { generation = generation, token = token, reports = {}, sent = {} } - if not CLASSIC_FEATURES then - snapshot.reason = "Caster Coordination is available in WoW: Forever." - return snapshot - end - if not db or not db.sync or not SyncChannel() or InCombatLockdown() or X.PlayerSuspended() then - snapshot.reason = "Caster Coordination needs cast sync and a group outside combat." - return snapshot - end - local session, members = Session() - snapshot.generation, snapshot.token, snapshot.available = generation, token, true - if not session then - local _, identity = CoordinationRoster() - if not identity then - snapshot.available, snapshot.reason = false, "Roster information is unavailable." - else - snapshot.reason = resetReason - end - return snapshot - end - local now = GetTime() - local function Deadline(time) - if time and time > now and (not snapshot.nextRefreshAt or time < snapshot.nextRefreshAt) then - snapshot.nextRefreshAt = time - end - end - snapshot.active, snapshot.leader = true, X.AmLead() - local pending, pendingAt = PendingPlan(session, members, now) - if pending then - snapshot.pending = { name = pending.name, keys = SortedKeys(pending.keys), - revision = pending.revision, reviewed = pending.reviewed == true } - Deadline(pendingAt + 0.01) - end - if session.accepted and now <= session.accepted.expires then - snapshot.accepted = { keys = SortedKeys(session.accepted.keys) } - Deadline(session.accepted.expires + 0.01) - end - if not snapshot.leader then return snapshot end - local readyAt = session.requestAt and session.requestAt + 10 - snapshot.canRequest = not readyAt or now >= readyAt - Deadline(readyAt) - snapshot.reportRequest = session.request ~= nil and now <= session.expires - if snapshot.reportRequest then - Deadline(session.expires + 0.01) - local currentReports = {} - for guid, member in pairs(members) do - local keys = session.reports[guid] - currentReports[#currentReports + 1] = { name = member.name, keys = keys and SortedKeys(keys) } - end - table_sort(currentReports, function(a, b) return a.name < b.name end) - snapshot.reports = currentReports - if session.draft then - snapshot.draft = {} - for _, row in ipairs(session.draft) do - local before, after = PlanNames(row, members) - snapshot.draft[#snapshot.draft + 1] = { key = row.key, before = before, after = after } - end - snapshot.canPublish = SamePlan(session.draft, DraftPlan(session, members, CoordinationGUID("player"), LearnedKeys())) - end - end - if session.sent and now <= session.sent.expires then - Deadline(session.sent.expires + 0.01) - for _, guid in ipairs(session.sent.order) do - snapshot.sent[#snapshot.sent + 1] = { name = members[guid].name, status = session.sent.recipients[guid] } - end - end - return snapshot - end - - local function OnCoordMessage(body, unit, name, now) - local kind, id, rest = body:match("^;(%u+);(%d+%.%d+)(.*)$") - if not kind or #id > 32 then return end - local session, members = Session() - local guid = session and CoordinationGUID(unit) - local me = guid and CoordinationGUID("player") - if not me or not members[guid] then return end - if kind == "REQ" and rest == "" and HasPlanRole(unit) then - if session.replies[guid] and now - session.replies[guid].time < 10 then return end - session.replies[guid] = { id = id, time = now } - SendCoord("REPORT", id, guid, KeyList(LearnedKeys())) - if session.pending and session.pending.sender == guid then NotifyCoordination() end - elseif kind == "REPORT" and session.request == id and now <= session.expires and X.AmLead() then - local target, list = rest:match("^;([^;]+);([^;]+)$") - if not list or target ~= me or session.reports[guid] then return end - local keys = ParseKeys(list) - if not keys then return end - session.reports[guid] = keys - NotifyCoordination() - elseif kind == "PLAN" and HasPlanRole(unit) then - if rest:sub(1, 1) ~= ";" then return end - local reply = session.replies[guid] - local revision, target, keys = ParsePlanRest(rest:sub(2)) - if not reply or reply.id ~= id or now - reply.time > 180 or target ~= me or not keys - or not NewerRevision(revision, reply.revision) then return end - local learned = LearnedKeys() - for key in pairs(keys) do if not learned[key] then return end end - reply.revision = revision - session.pending = { sender = guid, name = name, id = id, revision = revision, keys = keys } - Print(string_format(L["Caster plan from %s. Use /br coordinate inbox to review it."], name)) - NotifyCoordination() - elseif kind == "ACK" and session.sent and now <= session.sent.expires and id == session.sent.revision and rest == "" then - if session.sent.recipients[guid] == "sent" then - session.sent.recipients[guid] = "acknowledged" - NotifyCoordination() - end - end - end - - function X.OnCoordinationRoster(force) - UpdateSyncScope(force) - if active and (not db or not db.sync) then SetSession(nil) end - if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end - end - - function X.StopCoordination() - SetSession(nil) - if scope and (not db or not db.sync) then - scope.warmRetryAt = nil - scope.warmNonce, scope.priorWarmNonce, scope.warmExpires = nil, nil, nil - for _, peer in pairs(scope.peers) do peer.pending = nil end - end - if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end - end - - function X.CoordinatedHolder(key) - local accepted = active and db.sync and active.accepted - if accepted and GetTime() <= accepted.expires then return accepted.keys[key] and accepted.name end - end - - local function Coordinate(command, argument) - if not CLASSIC_FEATURES then Print(L["Caster Coordination is available in WoW: Forever."]); return end - if command == "off" then - X.StopCoordination() - if QueueRefresh then QueueRefresh() end - Print(L["Caster Coordination is off."]) - return - end - if command == "" then - Print(L["Use /br coordinate panel|on|off|request|need|review|publish|status|inbox|accept|decline."]) - return - end - if not db or not db.sync or not SyncChannel() or InCombatLockdown() or X.PlayerSuspended() then - Print(L["Caster Coordination needs cast sync and a group outside combat."]); return - end - if command == "on" then - local current = UpdateSyncScope() - if not current then Print(L["Roster information is unavailable."]); return end - SetSession({ identity = current.identity, reports = {}, replies = {}, requested = {} }) - Print(L["Caster Coordination is on for this group."]); return - end - local session, members = Session() - if not session then Print(L["Use /br coordinate on to join this group's caster planning."]); return end - local me = CoordinationGUID("player") - local now = GetTime() - if not me or not members[me] then Print(L["Roster information is unavailable."]); return end - if command == "inbox" or command == "accept" or command == "decline" then - local pending = PendingPlan(session, members, now) - if not pending then - session.pending = nil; Print(L["No current caster plan to review."]); return - end - if command == "inbox" then - pending.reviewed = true - Print(string_format(L["Caster plan from %s: %s. Use /br coordinate accept or decline."], - pending.name, next(pending.keys) and KeyList(pending.keys) or L["No assigned buffs"])) - elseif command == "decline" then - session.pending = nil - elseif not pending.reviewed then - Print(L["Review the caster plan with /br coordinate inbox first."]) - else - local learned = LearnedKeys() - for key in pairs(pending.keys) do - if not learned[key] or X.assign[key] and not X.SameUser(X.assign[key], members[me].name) then - Print(L["Your learned buffs or existing assignments changed. Ask for a new caster plan."]); return - end - end - if not SendCoord("ACK", pending.revision) then Print(L["The caster message could not be sent."]); return end - session.accepted = next(pending.keys) and { keys = pending.keys, name = members[me].name, - coordinator = pending.sender, expires = now + 180 } or nil - session.pending = nil - Print(L["Caster duties accepted."]) - if QueueRefresh then QueueRefresh() end - end - return - end - if not X.AmLead() then Print(L["Only the group leader or an assistant can manage caster plans."]); return end - if command == "request" then - if session.requestAt and now - session.requestAt < 10 then return end - local id = NextCoordID() - if not SendCoord("REQ", id) then Print(L["The caster message could not be sent."]); return end - session.request, session.requestAt, session.expires = id, now, now + 180 - session.reports, session.draft = { [me] = LearnedKeys() }, nil - Print(L["Asked group members for their learned buffs."]) - elseif command == "need" then - local key = argument and argument:upper() - if not key or not supportedKeys[key] then Print(L["Use /br coordinate need ."]); return end - session.requested[key] = true - session.draft = nil - elseif command == "status" and session.sent then - for _, guid in ipairs(session.sent.order) do - local status = session.sent.recipients[guid] - Print(string_format(L["%s: %s"], members[guid].name, L[statusLabels[status]])) - end - elseif not session.request or now > session.expires then - Print(L["Request fresh caster reports with /br coordinate request."]) - elseif command == "publish" then - if not session.draft then Print(L["Review the caster plan with /br coordinate review first."]); return end - session.reports[me] = LearnedKeys() - local fresh = DraftPlan(session, members) - if not SamePlan(session.draft, fresh) then - Print(L["Caster reports or assignments changed. Review the updated draft before publishing."]) - ReviewPlan(session, members); return - end - local plan, order, revision = {}, {}, NextCoordID() - for _, row in ipairs(fresh) do - if row.guid then - if not plan[row.guid] then plan[row.guid] = {}; order[#order + 1] = row.guid end - plan[row.guid][row.key] = true - end - end - if session.sent then - for _, guid in ipairs(session.sent.order) do - if not plan[guid] and session.reports[guid] then plan[guid] = {}; order[#order + 1] = guid end - end - end - if not next(plan) then Print(L["No new caster duties to send."]); return end - table_sort(order) - local sent = { revision = revision, order = order, recipients = {}, expires = now + 180 } - for _, guid in ipairs(order) do - local keys = plan[guid] - if guid == me then - session.accepted = next(keys) and { keys = keys, name = members[guid].name, - coordinator = me, expires = now + 180 } or nil - sent.recipients[guid] = "localOnly" - else - -- Include the report request and a separate publication revision. - local target = revision .. ";" .. guid - sent.recipients[guid] = SendCoord("PLAN", session.request, target, KeyList(keys)) and "sent" or "failed" - end - end - session.sent, session.draft = sent, nil - if QueueRefresh then QueueRefresh() end - Coordinate("status") - else - ReviewPlan(session, members) - end - end - - function X.Coordinate(command, argument, expectedToken) - if expectedToken ~= nil then - Session() - if expectedToken ~= token then - if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end - return - end - end - Coordinate(command, argument) - NotifyCoordination() - end - - local function ScopedPayload(payload) - local first, guid = payload:match("^CAST;([%w_]+);([%a]+%-%w[%w%-]*)$") - if guid and #guid <= 85 and ValidBuffKey(first) then return first, guid end - local body = payload:match("^COORD;1(;.+)$") - if body and active and not InCombatLockdown() and not X.PlayerSuspended() then - return body - end - end - - local function ApplyScopedPacket(packet, unit, name, senderKey, now) - local first, guid = ScopedPayload(packet.payload) - if not first then return end - if guid then - RememberCast(guid, first, now) - local presence = X.peers[senderKey] or {} - presence.t, presence.name = now, name - X.peers[senderKey] = presence - if QueueRefresh then QueueRefresh() end - elseif packet.generation == generation then - OnCoordMessage(first, unit, name, now) - end - end - - local function SyncControl(kind, current, epoch, challenge, target) - local message = "SYNC;3;" .. kind .. ";" .. current.digest .. ";" .. epoch .. ";" .. challenge .. ";" .. target - if kind == "P" then message = message .. ";" .. current.seq end - return X.Broadcast(message) - end - - local function NewSyncSequence(window, seq) - -- Broadcast plan rows can arrive out of order. A fixed receive window - -- accepts that reordering without replaying a previously seen packet. - local slot = seq % 32 - if seq <= window.floor or seq <= window.high - 32 or window[slot] == seq then return false end - window.high = math_max(window.high, seq) - window[slot] = seq - return true - end - - local function FindSyncPending(peer, epoch, now) - if not peer or not peer.pending then return end - for i = #peer.pending, 1, -1 do - local pending = peer.pending[i] - if now > pending.expires then - table.remove(peer.pending, i) - elseif pending.epoch == epoch then - return pending - end - end - end - - local function ObserveSyncEpoch(peer, epoch) - local observed = peer.observed or {} - for _, previous in ipairs(observed) do if previous == epoch then return end end - if #observed >= 4 then table.remove(observed, 1) end - observed[#observed + 1] = epoch - peer.observed = observed - end - - function X.HandleScopedSync(version, rest, channel, source, now) - if not CLASSIC_FEATURES or version ~= "3" then return end - local kind, digest, epoch, field, payload = rest:match("^;([DQP]);([%da-f]+);([%da-f]+);([^;]+);(.+)$") - if not kind then - digest, field = rest:match("^;B;([%da-f]+);([%da-f]+)$") - if not digest or #field ~= 24 then return end - kind = "B" - end - if #digest ~= 16 or (epoch and #epoch ~= 24) then return end - local me = CoordinationGUID("player") - if not me then return end - local proofFloor - if kind == "P" or kind == "Q" then - local target = payload - if kind == "P" then - local floor - target, floor = payload:match("^([^;]+);([^;]+)$") - if not floor or #floor > 10 or (floor ~= "0" and not floor:match("^[1-9]%d*$")) then return end - proofFloor = tonumber(floor) - end - if target ~= me or #field ~= 24 or not field:match("^[%da-f]+$") then return end - end - local unit, name, senderKey = OtherSyncSender(source, channel) - local sender = unit and CoordinationGUID(unit) - if not sender then return end - local current, members = UpdateSyncScope() - if not current or current.digest ~= digest or not members[sender] or not members[me] then return end - local peer = current.peers[sender] or {} - local warmActive = current.warmExpires and now <= current.warmExpires - if kind == "B" then - if peer.warmReplyAt and now - peer.warmReplyAt < 1 then return end - local answered = peer.warmReplies or {} - for _, nonce in ipairs(answered) do if nonce == field then return end end - if SyncControl("P", current, current.epoch, field, sender) then - if #answered >= 4 then table.remove(answered, 1) end - answered[#answered + 1] = field - peer.warmReplies, peer.warmReplyAt = answered, now - current.peers[sender] = peer - end - elseif kind == "Q" then - if epoch == current.epoch and peer.answered ~= field and SyncControl("P", current, epoch, field, sender) then - peer.answered = field - current.peers[sender] = peer - end - elseif kind == "P" then - local pending = FindSyncPending(peer, epoch, now) - local isWarm = field == current.warmNonce or field == current.priorWarmNonce - if isWarm then - if not warmActive or peer.epoch then return end - else - if not pending or pending.challenge ~= field then return end - if current.requireProofFloor and proofFloor < pending.challengeSeq then return end - if not current.requireProofFloor and retired[sender .. ":" .. epoch] then return end - end - if peer.epoch ~= epoch then RetireSyncEpoch(sender, peer.epoch) end - -- A sender may have missed the transition back to this exact roster. - -- Accept only traffic it produced after answering the new challenge. - local window = pending and pending.window or { high = 0, floor = 0 } - if current.requireProofFloor then window.floor = proofFloor end - peer.epoch, peer.window, peer.pending = epoch, window, nil - current.peers[sender] = peer - if pending then - table_sort(pending.packets, function(a, b) return a.seq < b.seq end) - for _, packet in ipairs(pending.packets) do - if packet.seq > window.floor then ApplyScopedPacket(packet, unit, name, senderKey, now) end - end - end - else - if #field > 10 or not field:match("^[1-9]%d*$") or not ScopedPayload(payload) then return end - local seq = tonumber(field) - local packet = { payload = payload, generation = generation, seq = seq } - if peer.epoch == epoch then - if not NewSyncSequence(peer.window, seq) then return end - ApplyScopedPacket(packet, unit, name, senderKey, now) - else - if not current.requireProofFloor and retired[sender .. ":" .. epoch] then return end - local pending = FindSyncPending(peer, epoch, now) - if not pending then - local challenge, expires - if warmActive and not peer.epoch then - -- Let the broadcast proof arrive before issuing a targeted - -- challenge that would count these held packets in its floor. - expires = current.warmExpires - else - challenge, expires = NewSyncNonce(), now + 5 - if not SyncControl("Q", current, epoch, challenge, sender) then return end - end - pending = { epoch = epoch, challenge = challenge, challengeSeq = seq, expires = expires, - window = { high = 0, floor = 0 }, packets = {} } - peer.pending = peer.pending or {} - if #peer.pending >= 2 then table.remove(peer.pending, 1) end - peer.pending[#peer.pending + 1] = pending - current.peers[sender] = peer - ObserveSyncEpoch(peer, epoch) - end - local replace - if #pending.packets >= 8 then - if pending.challenge then return end - -- A burst of stale packets must not crowd newer cast or plan data - -- out of the queue before the broadcast proof supplies its floor. - local lowest = seq - for index, held in ipairs(pending.packets) do - if held.seq < lowest then replace, lowest = index, held.seq end - end - if not replace then return end - end - if not NewSyncSequence(pending.window, seq) then return end - pending.packets[replace or #pending.packets + 1] = packet - return - end - end - end - end - - function X.OnAddonMsg(prefix, msg, channel, sender) - if not db or not db.sync or not ReadText(prefix) or prefix ~= "BuffRadar" then return end - if not ReadText(channel) or channel ~= SyncChannel() then return end - if not ReadText(msg) or #msg > 255 then return end - local kind, first, rest = msg:match("^([A-Z]+);([^;]+)(.*)$") - if not kind then return end - local now = GetTime() - if kind == "SYNC" then - X.HandleScopedSync(first, rest, channel, sender, now) - return - end - - local unit, name, senderKey, me = OtherSyncSender(sender, channel) - if not unit then return end - if kind == "CAST" then - if CLASSIC_FEATURES then return end - local guid = rest:match("^;([%a]+%-%w[%w%-]*)$") - if not guid or #guid > 85 or not ValidBuffKey(first) then return end - RememberCast(guid, first, now) - elseif kind == "ASSIGN" then - local holder = rest:match("^;([^;]+)$") - if not ValidBuffKey(first) or not ValidName(holder) or not HasPlanRole(unit) then return end - if holder:lower() == "none" then X.assign[first] = nil else X.assign[first] = holder end - elseif kind == "BLESS" then - local key, holder = rest:match("^;([%w_]+);([^;]+)$") - if not key or not X.BLESSING_CLASSES[first] or not ValidName(holder) - or (key ~= "NONE" and not BLESSINGS[key]) or not HasPlanRole(unit, true) then return end - if key == "NONE" or holder == "none" then - X.blessPlan[first] = nil - else - X.blessPlan[first] = { key = key, name = holder, mine = me ~= nil and X.SameUser(holder, me) } - end - elseif kind == "COVER" or kind == "BACK" or kind == "HELLO" or kind == "HERE" then - if rest ~= "" or not ValidName(first) or not X.SameUser(first, name) then return end - if kind == "COVER" then X.cover[name] = now + 300 end - if kind == "BACK" then X.cover[name] = nil end - else - return - end - - local peer = X.peers[senderKey] or {} - peer.t, peer.name = now, name - X.peers[senderKey] = peer - if kind == "HELLO" and me and (not peer.replyAt or now - peer.replyAt >= 10) then - peer.replyAt = now - X.Broadcast("HERE;" .. me) - end - if kind == "ASSIGN" and X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end - if QueueRefresh then QueueRefresh() end - end -end - --- A whisper or a nearby "buff ..." marks that player's row while it is up. -function X.OnChatAsk(text, author) - if not db or not db.requests or X.PlayerSuspended() then return end - if type(text) ~= "string" or not Readable(text) - or type(author) ~= "string" or not Readable(author) then return end - if not text:lower():find("buff", 1, true) then return end - local short = author:match("^[^%-]+") or author - local ka, ks = Ignore.Key(author), Ignore.Key(short) - for i = 1, nEntries do - local e = entries[i] - if e and (Ignore.Key(e.fullName or "") == ka or Ignore.Key(e.sortName or "") == ks) then - if (not X.asked[e.guid] or GetTime() - X.asked[e.guid] > 30) - and db.playSound and GetTime() - lastSoundAt > 1 then - lastSoundAt = GetTime() - PlayAlert("ask") - end - X.asked[e.guid] = GetTime() - if QueueRefresh then QueueRefresh() end - return - end - end -end - --- Does one of my equipped weapons lack a temporary enchant (a shaman --- imbue, a rogue poison, an oil or a sharpening stone)? (1.7.0) --- GetWeaponEnchantInfo is the game's own answer; a hand only counts --- when a weapon is actually equipped in it. --- Per-buff context (1.8.0): a buff can be limited to raids or to --- instances (dungeons, raids, battlegrounds) and is then simply not --- offered anywhere else. Set with /br context KEY raid|instance|always. --- On Forever, Shadow Protection ships with the instance limit as its --- default (the resistance-context rule) until the user changes it. -function X.ContextOK(key) - local c = db and db.buffContext and db.buffContext[key] - if not c then return true end - if c == "raid" then return InRaid() end - if c == "instance" then return InInstanceNow() ~= nil end - return true -end - -function X.WeaponEnchantMissing() - local fn = _G.GetWeaponEnchantInfo - if not fn then return false end - local ok, hasMH, _, _, _, hasOH = pcall(fn) - if not ok or not Readable(hasMH) or not Readable(hasOH) then return false end - local function equipped(slot) - if not _G.GetInventoryItemID then return true end - local okI, id = pcall(_G.GetInventoryItemID, "player", slot) - return okI and Readable(id) and id ~= nil - end - if not hasMH and equipped(16) then return true end - if not hasOH and equipped(17) then return true end - return false -end - --- Instance-entry reminder (1.7.0): stepping into a dungeon, raid or --- battleground with buffs still missing gets one clear line, once per --- entry — the run-start counterpart of the join digest. -function X.InstanceCheck() - if not db then return end - local ctx = X.Context() - local inside = ctx == "dungeon" or ctx == "raid" or ctx == "pvp" - if inside and not X.wasInside and db.enterFlash and InGroup() and hasAnyBuff - and not X.PlayerSuspended() then - local report = X.GroupBuffReport() - local people = #report.people - if people > 0 then - Print(string.format("Entered the %s with buffs missing: %d %s still need buffs (%d buffs needed).", - ctx == "dungeon" and "dungeon" or (ctx == "raid" and "raid" or "battleground"), - people, people == 1 and "person" or "people", report.buffs)) - end - end - X.wasInside = inside -end - --- One line in chat: how much buffing the group (or the run) still needs. --- Counts everyone, ignoring the window's role filter. -function X.JoinDigest(why) - if not db or not InGroup() or X.PlayerSuspended() then return end - local report = X.GroupBuffReport() - local people = #report.people - if people == 0 then return end - Print(string.format("%s: %d %s missing buffs (%d buffs needed).", - why == "run" and "Run starting" or "Joined a group", - people, people == 1 and "person is" or "people are", report.buffs)) -end - --- Roster events: only the step from solo to grouped triggers the join --- summary, not every roster shuffle afterwards. -function X.OnRoster() - local g = InGroup() - if not g and X.CloseRaidPreparation then X.CloseRaidPreparation() end - if not InRaid() then X.subgroupDuties = nil end - X.PruneBlessingExceptions() - X.PruneAssignmentRoleOverrides() - X.PruneBlockerUndo() - if db then X.SendCover() end -- roster changes refresh a live cover (1.7.0) - if X.inGroupPrev == false and g and db and db.joinDigest and hasAnyBuff then - if C_Timer and C_Timer.After then - C_Timer.After(1.5, function() X.JoinDigest("join") end) - else - X.JoinDigest("join") - end - end - -- Presence (1.6.0): say hello (throttled) so other users know a buddy is - -- here; assignments and plans belong to the group, so they end with it. - if g and db and db.sync and GetTime() - (X.helloAt or 0) > 10 then - X.helloAt = GetTime() - local me = Ignore.UnitNames("player") - if me then X.Broadcast("HELLO;" .. me) end - end - if g then - X.PruneSyncRoster() - else - wipe(X.assign) - wipe(X.blessPlan) - wipe(X.peers) - wipe(X.cover) - wipe(X.handled) - X.upTotal, X.upFull = 0, 0 -- the run is over (1.6.0) - -- Repeat-offender history (1.8.0): the session that just ended - -- counts once for everyone who was seen unbuffed during it. - if db then - for name in pairs(X.offNow) do - db.offenders[name] = (db.offenders[name] or 0) + 1 - end - local orows = {} - for nm, c in pairs(db.offenders) do orows[#orows + 1] = { nm = nm, c = c } end - if #orows > 50 then -- keep the worst 50 only - table_sort(orows, function(a, b) return a.c > b.c end) - for i = 51, #orows do db.offenders[orows[i].nm] = nil end - end - end - wipe(X.offNow) - end - X.inGroupPrev = g -end local rows = {} local built = false @@ -6481,636 +5347,12 @@ do end --------------------------------------------------------------------------- --- Setup wizard (1.9.0): a three-page first-run walkthrough — play --- style (a shipped preset), window look, and your buff list — so a --- new user lands on sane settings without facing the full settings --- window cold. /br wizard runs it again at any time. Defined here: --- it needs ApplyGeometry / ApplyAppearance, which exist from here on. +-- The setup wizard, saved themes, alert flash, range and fall checks, +-- /br why and the Nearby Player explanations, history / stats text and +-- the export dialog live in Wizard.lua since 1.15.34 (file split +-- Slice F); it reaches this file's locals through X.wizAPI (bottom). --------------------------------------------------------------------------- -function X.WizardPage(n) - local w = X.wizardFrame - if not w then return end - w.page = n - for i = 1, 3 do w.choice[i]:Hide() end - w.back:SetShown(n > 1) - if n == 1 then - w.title:SetText("BuffRadar setup — step 1 of 3") - w.body:SetText("How do you mostly play? Each answer applies a starting preset; every setting can be changed later in Settings.") - local styles = { - { "Mostly solo", "solo" }, { "In a party", "dungeon" }, { "In raids", "raid" }, - } - for i, s in ipairs(styles) do - local b = w.choice[i] - b:SetText(s[1]) - b:SetScript("OnClick", function() - if X.ApplyPreset(s[2]) then - ApplyGeometry() - ApplyAppearance() - X.ApplyRowLayout() - if RefreshConfig then RefreshConfig() end - if QueueRefresh then QueueRefresh() end - Print("Setup wizard: the " .. s[2] .. " preset is applied.") - end - X.WizardPage(2) - end) - b:Show() - end - w.next:Hide() - elseif n == 2 then - w.title:SetText("BuffRadar setup — step 2 of 3") - w.body:SetText("The window's look. Click the theme button to cycle the color schemes; scale, width and more live in Settings > Window.") - local b = w.choice[1] - local function themeLabel() - return "Theme: " .. X.ThemeLabel(true) - end - b:SetText(themeLabel()) - b:SetScript("OnClick", function() - local order = X.ThemeOrder() - local cur = 1 - for i, k in ipairs(order) do if k:lower() == (db.theme or ""):lower() then cur = i end end - X.ApplyTheme(order[cur % #order + 1]) - if RefreshConfig then RefreshConfig() end - b:SetText(themeLabel()) - end) - b:Show() - w.next:SetText("Next") - w.next:Show() - else - w.title:SetText("BuffRadar setup — step 3 of 3") - local names = {} - for _, bf in ipairs(myBuffs) do names[#names + 1] = bf.name end - w.body:SetText(#names > 0 - and ("You can cast: " .. table.concat(names, ", ") - .. ". Toggle any of them in Settings > Buffs, or with /br toggle ." - .. " Press Finish — then just click a name on the list to buff them.") - or "You don't know any buffs BuffRadar handles yet; the list appears once you learn one. Press Finish to close.") - local b = w.choice[1] - b:SetText("Open settings") - b:SetScript("OnClick", function() OpenConfig() end) - b:Show() - w.next:SetText("Finish") - w.next:Show() - end - w.pageText:SetText("Step " .. n .. " of 3") -end - -function X.OpenWizard() - if not db or X.PlayerSuspended() then return end - if InCombatLockdown() then - Print("The setup wizard can't open during combat — try again when it ends.") - return - end - local w = X.wizardFrame - if not w then - w = CreateFrame("Frame", "BuffRadarWizard", UIParent, "BackdropTemplate") - X.wizardFrame = w - w:SetSize(370, 260) - w:SetPoint("CENTER") - w:SetFrameStrata("DIALOG") - if w.SetBackdrop then - w:SetBackdrop({ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", - edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", - tile = true, tileSize = 32, edgeSize = 24, - insets = { left = 8, right = 8, top = 8, bottom = 8 } }) - end - if w.SetBackdropColor then w:SetBackdropColor(0, 0, 0, 0.9) end - w.title = w:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") - w.title:SetPoint("TOP", 0, -16) - w.body = w:CreateFontString(nil, "OVERLAY", "GameFontHighlight") - w.body:SetPoint("TOPLEFT", 20, -48) - w.body:SetPoint("TOPRIGHT", -20, -48) - w.body:SetJustifyH("LEFT") - w.body:SetWordWrap(true) - w.pageText = w:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - w.pageText:SetPoint("BOTTOM", 0, 16) - w.choice = {} - for i = 1, 3 do - local b = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") - b:SetSize(210, 24) - b:SetPoint("TOP", w, "TOP", 0, -104 - (i - 1) * 32) - w.choice[i] = b - end - w.back = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") - w.back:SetSize(90, 22) - w.back:SetPoint("BOTTOMLEFT", 16, 12) - w.back:SetText("Back") - w.back:SetScript("OnClick", function() X.WizardPage(math_max(1, (w.page or 1) - 1)) end) - w.next = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") - w.next:SetSize(110, 22) - w.next:SetPoint("BOTTOMRIGHT", -16, 12) - w.next:SetScript("OnClick", function() - if (w.page or 1) >= 3 then - db.wizardSeen = true - w:Hide() - Print("Setup done — /br wizard runs it again, /br config opens all settings.") - else - X.WizardPage((w.page or 1) + 1) - end - end) - local close = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") - close:SetSize(24, 24) - close:SetText("X") - close:SetPoint("TOPRIGHT", -10, -10) - close:SetScript("OnClick", function() - db.wizardSeen = true - w:Hide() - end) - end - X.WizardPage(1) - w:Show() -end - --- Apply a color theme (1.8.0). Defined here because it needs --- ApplyAppearance, which only exists from this point on. -function X.ApplyTheme(name) - if name and name:lower() == "auto" and not X.SavedTheme(name) then name = X.AUTO_THEME_ID end - local t = X.ThemeDef(name) - if not t then return false end - local id = name:lower() - db.theme = X.THEMES[id] and id or t.label - if id ~= X.AUTO_THEME_ID then db.bgColor = { t.bg[1], t.bg[2], t.bg[3] } end - if not X.ResolveAutoTheme() then - ApplyAppearance() - if RefreshConfig then RefreshConfig() end - end - return true -end - --- Save the current look (background + the border now in effect) as one --- of your themes (1.10.0). Returns the name, or nil plus a reason. -function X.SaveTheme(name) - name = (name or ""):match("^%s*(.-)%s*$") - if X.THEMES[name:lower()] or name:lower() == "custom" then return nil, "taken" end - if not name:match("^[%w%-]+$") or #name > 24 then return nil, "name" end - local c, b = X.ThemeBackground(), X.ThemeBorder() - local entry = { name = name, - bg = { c[1], c[2], c[3] }, - border = { b[1], b[2], b[3] } } - db.customThemes = db.customThemes or {} - for i, t in ipairs(db.customThemes) do - if t.name:lower() == name:lower() then - db.customThemes[i] = entry - return name - end - end - if #db.customThemes >= 4 then return nil, "full" end - db.customThemes[#db.customThemes + 1] = entry - return name -end - -function X.DeleteTheme(name) - if not db or not name then return false end - for i, t in ipairs(db.customThemes or {}) do - if t.name:lower() == name:lower() then - table.remove(db.customThemes, i) - if not X.THEMES[name:lower()] and (db.theme or ""):lower() == name:lower() then - db.theme = "custom" - ApplyAppearance() - if RefreshConfig then RefreshConfig() end - end - return true - end - end - return false -end - --- One border pulse; restores the normal border shortly after. Assigned --- here because frame / ApplyAppearance only exist from this point on. -function X.Flash() - if not frame or not frame.SetBackdropBorderColor or InCombatLockdown() or db.reduceMotion then return end - frame:SetBackdropBorderColor(1, 0.35, 0.35, 1) - if C_Timer and C_Timer.After then - C_Timer.After(0.7, function() if frame then ApplyAppearance() end end) - else - X.flashPending = true -- no timer API: Refresh() restores it next pass - end -end - --- Watched-buff drop alert (1.5.0): your single-target buff (Earth Shield) --- was on someone at the last scan and is gone now, while that player is --- still around -- say so instead of silently re-offering it. The alert --- fires once per drop: prevHolder only refills when the buff is seen on --- someone again. A holder change (you recast it on someone else) is a --- move, not a drop. Runs after each CollectEntries in Refresh. -X.farNow, X.farPrev = {}, {} --- Range watch (1.12.0): a player who needed a buff and was out of range --- last scan, and is in range now, still needs it -> one chat line + the --- alert sound. The game does not allow casting automatically, so this --- only tells you; the click is yours. -function X.CheckRange() - if not db.rangeWatch then - wipe(X.farPrev); wipe(X.farNow); return - end - for i = 1, nEntries do - local e = entries[i] - local g = e.guid - if g and X.farPrev[g] and not e.outOfRange and not e.pet then - local name = X.farPrev[g] == true and e.name or X.farPrev[g] - Print(string_format("%s is in range now and still needs a buff.", name)) - PlayAlert("new") - end - end - X.farPrev, X.farNow = X.farNow, X.farPrev - wipe(X.farNow) -end - --- Buff-fell-off alert (1.15.0, #33): Consider's expiry tracking spots a --- watched group buff that was up when a fight started and is gone at the --- first scan after it; this plays the "fall" alert kind once for that --- scan, telling a mid-fight drop apart from a fresh arrival (the --- new-name alert cannot). Detection lands after combat because the list --- is frozen during it -- which is also when rebuffing becomes possible. -function X.CheckFalls() - if X.fallPending then - X.fallPending = nil - if db and db.fallSound then PlayAlert("fall") end - end -end - --- /br why (1.15.0): explain, in plain words, why a player is or --- is not on the list. Reuse cast eligibility rules without updating coverage tallies. -function X.Why(name) - if not db then return end - local want = (name or ""):lower() - if want == "" then return end - local selected, best, ambiguous - local function try(u, grp) - if X.ReadUnitBool(UnitExists, u) ~= true or X.ReadUnitBool(UnitIsPlayer, u) ~= true - or X.ReadUnitBool(UnitCanAssist, "player", u) == false and u ~= "player" then return end - local f, s = Ignore.UnitNames(u) - if not f then return end - local fl, sl = f:lower(), (s or ""):lower() - local score = fl == want and 3 or sl == want and 2 or fl:find(want, 1, true) and 1 or 0 - if score == 0 or best and score < best then return end - local ok, raw = pcall(UnitGUID, u) - local guid = ok and SafeString(raw) or nil - if not best or score > best then - selected, best, ambiguous = { unit = u, full = f, short = s, group = grp, guid = guid }, score, false - elseif (guid and selected.guid and guid ~= selected.guid) or selected.full:lower() ~= fl then - ambiguous = true - end - end - local list = InRaid() and RAID or PARTY - try("player", true) - for i = 1, #list do try(list[i], true) end - try("target", false) - try("mouseover", false) - for i = 1, #PLATES do try(PLATES[i], false) end - if ambiguous then - Print("Why: more than one player matches. Use their full name, including realm.") - return - end - if not selected then - Print("Why: no readable player matches '" .. name .. "'. Target or mouse over them, or enable friendly nameplates with /br plates.") - return - end - X.ExplainPlayer(selected, Print) -end - -function X.ExplainPlayer(selected, emit, showUnknown) - local unit, full, short, isGroup, guid = selected.unit, selected.full, selected.short, selected.group, selected.guid - local disp = short or full - local function printRule(detail) - if CLASSIC_FEATURES then - local rule = detail.rule or L["Rule unavailable"] - if detail.blessing then rule = rule .. " · " .. detail.blessing end - emit(string_format(L["Applied rule for %s: %s."], disp, rule)) - end - end - local function printInactiveRule() - local ok, _, class = pcall(UnitClass, unit) - class = ok and SafeString(class) or nil - local assignment, source, role, _, manual = X.AssignmentForUnit(class, unit, isGroup, X.IsSelf(unit)) - printRule({ rule = X.AssignmentRuleText(class, role, source, assignment, isGroup, manual) }) - end - if Ignore.Has(full, short) then - printInactiveRule() - emit(disp .. " is on your ignore list, so they are never listed. /br unignore " .. disp .. " undoes it.") - return - end - if X.SessionHas(full, short) then - printInactiveRule() - emit(disp .. " is ignored for this session only (Shift+right-click on a row). It clears when you reload.") - return - end - local valid, isSelf = Valid(unit) - if not valid then - printInactiveRule() - emit(disp .. " can't be buffed right now (dead, offline, in combat, charmed or in another phase), so they are not listed.") - return - end - local allMiss, miss = {}, {} - local detail = { cooldown = {}, cooldowns = {} } - local n, unknown, checked = Missing(unit, allMiss, isGroup, isSelf, "why", detail) - printRule(detail) - -- The fallback aura index is rebuilt on demand after a diagnostic scan. - X.scanUnit = nil - if n == 0 then - if unknown then - emit(disp .. ": buff information is unavailable.") - elseif #detail.cooldown > 0 then - emit(disp .. " needs " .. table.concat(detail.cooldown, ", ") .. ", but those spells are on cooldown.") - elseif not checked then - emit(disp .. (detail.assignment and ": no enabled buffs apply under the selected class or role assignment." - or ": no enabled buffs apply to this player.")) - else - emit(disp .. " already has every buff you can give them.") - end - return - end - local inRange, _, rangeUnknown, rankLimited = X.FilterInRange(unit, allMiss, miss, isSelf, true) - if showUnknown then - if unknown then emit(L["Some buff information is unavailable."]) end - if rangeUnknown and (inRange > 0 or rankLimited) then emit(L["Range could not be confirmed; the list may be incomplete."]) end - end - if inRange == 0 then - emit(disp .. " needs " .. table.concat(allMiss, ", ") .. (rankLimited - and ", but no learned rank fits their level, or another needed spell is out of range." - or rangeUnknown - and ", but the game could not confirm cast range. Move closer and check again." - or " but none are in cast range; move closer before buffing.")) - return - end - if guid and X.failedTargets[guid] and X.failedTargets[guid] > GetTime() then - local failure = X.lastTargetCastProblem - emit(disp .. " was temporarily skipped after a failed cast." - .. (failure and failure.guid == guid and " " .. failure.message or "") .. " Try again in a few seconds.") - return - end - for i = 1, nEntries do - if guid and entries[i].guid == guid then - local shown = false - for r = 1, MAX_ROWS do - if rows[r] and rows[r].entry == entries[i] then shown = true break end - end - if shown then - emit(disp .. " is on the list (row " .. i .. "), missing: " .. table.concat(miss, ", ") .. ".") - elseif db.viewMode == "people" and X.rowView == entries - and (i <= (X.rowOffset or 0) or i > (X.rowOffset or 0) + MAX_ROWS) then - emit(disp .. " is outside the visible rows. " .. L["Use the mouse wheel to see more rows."]) - else - emit(disp .. " needs " .. table.concat(miss, ", ") .. " and is collected, but the row is not shown -- the role filter under the title is the usual reason.") - end - return - end - end - if X.search and X.search ~= "" and not (disp:lower():find(X.search, 1, true)) then - emit(disp .. " needs " .. table.concat(miss, ", ") .. ", but the name finder ('" .. X.search .. "') hides them. Clear the finder text to see everyone.") - return - end - if not guid then - emit(disp .. ": the game did not expose a readable player identity. Target them and check again.") - return - end - emit(disp .. " is not on the list right now; they need: " .. table.concat(miss, ", ") .. ".") -end - -function X.ExplainCurrentTarget(emit) - local exists = X.ReadUnitBool(UnitExists, "target") - if exists ~= true then - emit(L[exists == false and "Select a friendly player to check." or "Current target information is unavailable."]) - return - end - local player = X.ReadUnitBool(UnitIsPlayer, "target") - local self = X.IsSelf("target") - local assist = self or X.ReadUnitBool(UnitCanAssist, "player", "target") - if player == false or assist == false then - emit(L["Select a friendly player to check."]) - return - end - local function readGUID(unit) - local ok, guid = pcall(UnitGUID, unit) - if ok and type(guid) == "string" and Readable(guid) and guid ~= "" then return guid end - end - local full, short = Ignore.UnitNames("target") - local guid = readGUID("target") - if player == nil or assist == nil or not full or not guid then - emit(L["Current target information is unavailable."]) - return - end - local unit = "target" - if self then - unit = "player" - elseif InGroup() then - local roster = InRaid() and RAID or PARTY - for _, member in ipairs(roster) do - if readGUID(member) == guid then unit = member; break end - end - end - X.ExplainPlayer({ unit = unit, full = full, short = short, group = unit ~= "target", guid = guid }, emit, true) -end - -function X.EnableFriendlyNameplates(emit) - if InCombatLockdown() then emit(L["Can't change nameplate settings during combat."]); return end - if X.PlayerSuspended() then emit(L["Nameplate settings are unavailable while dead."]); return end - local enabled, name = X.FriendlyPlatesOn() - local setter = (C_CVar and C_CVar.SetCVar) or SetCVar - if not name or not setter then - emit(L["Couldn't find a supported friendly nameplate setting on this client."]) - return - end - if not enabled then pcall(setter, name, "1") end - if X.FriendlyPlatesOn() ~= true then - emit(L["Couldn't turn on friendly nameplates. Check the game's nameplate settings."]) - return - end - if X.ReadBooleanCVar("nameplateShowAll") == false then - pcall(setter, "nameplateShowAll", "1") - if X.ReadBooleanCVar("nameplateShowAll") ~= true then - emit(L["Friendly nameplates are enabled. The game may still hide them outside combat."]) - return - end - end - emit(L["Friendly nameplates turned on, so nearby non-group players can be listed."]) -end - -function X.CheckDrops() - local lookup = C_UnitAuras and C_UnitAuras.GetAuraDataBySpellName - local uncertain = {} - if db.watchDrop then - for key, prev in pairs(X.prevHolder) do - if not Single.holder[key] and prev.unit and X.UnitPresent(prev.unit) and lookup then - local aura, definitive = X.QueryNamedAura(lookup, prev.unit, Single.spell[key] or key, "HELPFUL|PLAYER") - if definitive and not aura then - Print(string_format("%s dropped off %s.", Single.spell[key] or key, prev.name)) - PlayAlert("drop") - X.Flash() - else - uncertain[key] = prev - end - end - end - end - X.prevHolder = uncertain - for key, unit in pairs(Single.holder) do - X.prevHolder[key] = { unit = unit, name = X.UnitNameOf(unit) or unit } - end -end - --- Copyable settings string window for /br export and /br import. --- The recent-casts list for /br history, newest first (1.7.0). -function X.HistoryText() - local h = db.history or {} - if #h == 0 then - return "No casts recorded yet. Buffs you cast through BuffRadar will be listed here." - end - local lines = {} - for i = #h, 1, -1 do - local e = h[i] - local when = "" - if e.t and e.t > 0 and date then - local okd, s = pcall(date, "%H:%M", e.t) - if okd and s then when = s .. " " end - end - lines[#lines + 1] = when .. (e.spell or "?") .. " -> " .. (e.who or "?") - end - return table.concat(lines, "\n") -end - --- Stats export (1.8.0): the cast statistics as copyable text. -function X.StatsText() - local lines = { "BuffRadar cast statistics" } - lines[#lines + 1] = string_format("Casts: %d this session, %d all-time", - X.sessionCasts, db.castsTotal or 0) - if X.upTotal > 0 then - lines[#lines + 1] = string_format("Coverage uptime this run: %d%% (%d of %d scans fully buffed)", - math_floor(100 * X.upFull / X.upTotal + 0.5), X.upFull, X.upTotal) - end - local srows = {} - for k, n in pairs(db.stats or {}) do srows[#srows + 1] = { k = k, n = n } end - table.sort(srows, function(a, b) return a.n > b.n end) - if #srows > 0 then - lines[#lines + 1] = "By spell:" - for i = 1, math_min(10, #srows) do - lines[#lines + 1] = string_format(" %s: %d", srows[i].k, srows[i].n) - end - end - return table.concat(lines, "\n") -end - --- Per-buff summary (1.13.0): how many casts of each buff the group --- still needs, biggest first. Counts everyone, ignoring the role filter. -function X.SummaryLines() - local report = X.GroupBuffReport() - local per = {} - for _, person in ipairs(report.people) do - for _, name in ipairs(person.buffs) do - per[name] = (per[name] or 0) + 1 - end - end - local counts = {} - for n, c in pairs(per) do counts[#counts + 1] = { n = n, c = c } end - table_sort(counts, function(a, b) if a.c ~= b.c then return a.c > b.c end return a.n < b.n end) - return counts, #report.people, X.GroupCoverageNote(report) -end - --- Discord summary (1.8.0): the group's buff state as a small markdown --- block, ready to paste into a Discord message. -function X.DiscordText() - local report = X.GroupBuffReport() - local note = X.GroupCoverageNote(report) - local lines = { "**BuffRadar — group buff check**" } - if #report.people == 0 and not note then - lines[#lines + 1] = "All checked buffs are present." - elseif #report.people > 0 then - lines[#lines + 1] = "Still needs buffs:" - for _, person in ipairs(report.people) do - lines[#lines + 1] = "- " .. person.name .. " — " .. table.concat(person.buffs, ", ") - end - end - if note then lines[#lines + 1] = note end - if X.upTotal >= 10 then - lines[#lines + 1] = string_format("Coverage uptime this run: %d%%", - math_floor(100 * X.upFull / X.upTotal + 0.5)) - end - return table.concat(lines, "\n") -end - -function X.ShowExport(text, forImport, titleText, mode) - if X.PlayerSuspended() then return end - if InCombatLockdown() then Print("Can't open that during combat."); return end - local f = X.exportFrame - if not f then - f = CreateFrame("Frame", "BuffRadarExportFrame", UIParent, - BackdropTemplateMixin and "BackdropTemplate" or nil) - X.exportFrame = f - f:SetSize(440, 150) - f:SetPoint("CENTER") - f:SetFrameStrata("DIALOG") - if f.SetBackdrop then - f:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 12, - insets = { left = 3, right = 3, top = 3, bottom = 3 }, - }) - f:SetBackdropColor(0.04, 0.05, 0.09, 0.97) - f:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) - end - f:EnableMouse(true) - f:SetMovable(true) - f:RegisterForDrag("LeftButton") - f:SetScript("OnDragStart", function(self) self:StartMoving() end) - f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) - f.title = f:CreateFontString(nil, "OVERLAY", "GameFontNormal") - f.title:SetPoint("TOPLEFT", 12, -10) - local close = CreateFrame("Button", nil, f, "UIPanelCloseButton") - close:SetSize(22, 22) - close:SetPoint("TOPRIGHT", 0, 0) - close:SetScript("OnClick", function() f:Hide() end) - local eb = CreateFrame("EditBox", nil, f) - eb:SetPoint("TOPLEFT", 12, -34) - eb:SetPoint("BOTTOMRIGHT", -12, 36) - eb:SetMultiLine(true) - if eb.SetAutoFocus then eb:SetAutoFocus(false) end - if eb.SetFontObject and ChatFontNormal then eb:SetFontObject(ChatFontNormal) end - eb:SetScript("OnEscapePressed", function(self) if self.ClearFocus then self:ClearFocus() end end) - f.editBox = eb - local acc = CreateFrame("Button", nil, f, "UIPanelButtonTemplate") - acc:SetSize(110, 22) - acc:SetPoint("BOTTOMRIGHT", -12, 8) - acc:SetText("Import") - acc:SetScript("OnClick", function() - local ok, msg - if f.importMode == "plan" then - ok, msg = X.PlanImport(f.editBox:GetText()) - elseif f.importMode == "profile" then - ok, msg = X.ProfileImport(f.editBox:GetText()) - elseif f.importMode == "ignore" then - ok, msg = X.IgnoreImport(f.editBox:GetText()) - else - local txt = f.editBox:GetText() - if X.PrintDiff then X.PrintDiff(txt, "This import") end -- what it changes, before it does (1.12.0) - ok, msg = X.Import(txt) - end - Print(msg) - if ok then - f:Hide() - ApplyGeometry() - ApplyAppearance() - if RefreshConfig then RefreshConfig() end - if QueueRefresh then QueueRefresh() end - end - end) - f.accept = acc - if UISpecialFrames then UISpecialFrames[#UISpecialFrames + 1] = "BuffRadarExportFrame" end - f:Hide() - end - f.title:SetText(titleText or (forImport and "BuffRadar -- paste a settings string, then Import" - or "BuffRadar -- your settings string (select all, copy)")) - f.importMode = mode or "settings" -- what the Import button applies (1.8.0) - f.editBox:SetText(text or "") - f.accept:SetShown(forImport and true or false) - f:Show() - if f.editBox.SetFocus then f.editBox:SetFocus() end - if f.editBox.HighlightText then f.editBox:HighlightText() end -end - --- Your own "Name-Realm", for per-character settings. -function X.CharKey() - local full = Ignore.UnitNames("player") - return full -end +X.farNow, X.farPrev = {}, {} -- range-watch sets; the scan writes X.farNow -- Compact rows + list text scale (1.4.0). Re-anchors every row; height -- changes are not combat-safe on secure buttons, so this no-ops in combat @@ -8833,8 +7075,8 @@ local function Refresh() if now - t > 60 then X.recentlyGone[guid] = nil end end X.listedBefore = listedNow - if newName and db.playSound and now - lastSoundAt > 1 then - lastSoundAt = now + if newName and db.playSound and now - X.lastSoundAt > 1 then + X.lastSoundAt = now PlayAlert("new") end @@ -9410,6 +7652,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) end BuffRadarDB = SanitizeDB(BuffRadarDB) db = BuffRadarDB + X.ShareDB() db.showOutOfRange, db.hideInCombat = false, true local preVersion = db.dbVersion or 0 -- the version the save came from (1.9.0 wizard gate) Ignore.Rebuild() @@ -9488,6 +7731,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if not db then BuffRadarDB = SanitizeDB(BuffRadarDB) db = BuffRadarDB + X.ShareDB() Ignore.Rebuild() end X.ResolveAutoTheme() @@ -9723,6 +7967,38 @@ X.slashAPI = { setSessionShow = function(v) sessionShow = v end, } X.GetDB = function() return db end +-- Split files that keep their own `db` local (Coordination.lua, Wizard.lua) +-- register a setter in X.dbSinks; the settings table is handed to them +-- here the moment it exists. +X.ShareDB = function() + for _, sink in ipairs(X.dbSinks or {}) do sink(db) end +end + +-- Handed to Coordination.lua (file split Slice E): stable values by +-- value; the two counters this file reassigns through accessors. +X.coordAPI = { + L = L, Print = Print, PlayAlert = PlayAlert, QueueRefresh = QueueRefresh, + Ignore = Ignore, Readable = Readable, IsOn = IsOn, + InRaid = InRaid, InGroup = InGroup, InInstanceNow = InInstanceNow, + BLESSINGS = BLESSINGS, BUFF_DEFS = BUFF_DEFS, CLASSIC_FEATURES = CLASSIC_FEATURES, + RAID = RAID, PARTY = PARTY, myBuffs = myBuffs, entries = entries, + nEntries = function() return nEntries end, + hasAnyBuff = function() return hasAnyBuff end, +} + +-- Handed to Wizard.lua (file split Slice F): stable values by value; +-- the list length through an accessor, the window through X.GetFrame. +X.wizAPI = { + L = L, Print = Print, PlayAlert = PlayAlert, QueueRefresh = QueueRefresh, + RefreshConfig = RefreshConfig, OpenConfig = OpenConfig, + ApplyAppearance = ApplyAppearance, ApplyGeometry = ApplyGeometry, + Ignore = Ignore, Readable = Readable, SafeString = SafeString, + Single = Single, Missing = Missing, Valid = Valid, + InGroup = InGroup, InRaid = InRaid, RAID = RAID, PARTY = PARTY, PLATES = PLATES, + myBuffs = myBuffs, entries = entries, rows = rows, + CLASSIC_FEATURES = CLASSIC_FEATURES, MAX_ROWS = MAX_ROWS, + nEntries = function() return nEntries end, +} X.SanitizeDB, X.IsProfileName, X.PROFILE_MAX_BYTES = SanitizeDB, IsProfileName, PROFILE_MAX_BYTES X.Esc, X.Unesc, X.DEFAULTS = Esc, Unesc, DEFAULTS -- for Profiles.lua X.InGroup, X.InRaid = InGroup, InRaid -- for Recaps.lua diff --git a/BuffRadar/BuffRadar.toc b/BuffRadar/BuffRadar.toc index 58b6cae..0fbf742 100644 --- a/BuffRadar/BuffRadar.toc +++ b/BuffRadar/BuffRadar.toc @@ -11,6 +11,8 @@ Locales\deDE.lua Data.lua BuffRadar.lua +Coordination.lua +Wizard.lua Config.lua Slash.lua Recaps.lua diff --git a/BuffRadar/Coordination.lua b/BuffRadar/Coordination.lua new file mode 100644 index 0000000..9b460a7 --- /dev/null +++ b/BuffRadar/Coordination.lua @@ -0,0 +1,1173 @@ +-- BuffRadar - Coordination: cast sync between BuffRadar users (1.5.0), +-- caster coordination (1.15.26), chat buff requests, per-buff context +-- checks and the join digest. +-- Loaded after BuffRadar.lua through the .toc. This is file-split Slice E +-- (1.15.34): the code below moved verbatim from BuffRadar.lua and reaches +-- that file's locals through X.coordAPI, which BuffRadar.lua fills in +-- before this file loads. The settings table arrives through X.dbSinks +-- once it exists; the two counters the main file reassigns (list length, +-- whether any buff is known) are read through accessors. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, NS = ... +local X = NS and NS.X +if not X or not X.coordAPI then return end +local A = X.coordAPI + +local db = X.GetDB and X.GetDB() -- nil until ADDON_LOADED; X.dbSinks updates it +X.dbSinks = X.dbSinks or {} +X.dbSinks[#X.dbSinks + 1] = function(value) db = value end + +local L, Print, PlayAlert, QueueRefresh = A.L, A.Print, A.PlayAlert, A.QueueRefresh +local Ignore, Readable, IsOn = A.Ignore, A.Readable, A.IsOn +local InRaid, InGroup, InInstanceNow = A.InRaid, A.InGroup, A.InInstanceNow +local BLESSINGS, BUFF_DEFS, CLASSIC_FEATURES = A.BLESSINGS, A.BUFF_DEFS, A.CLASSIC_FEATURES +local RAID, PARTY, myBuffs, entries = A.RAID, A.PARTY, A.myBuffs, A.entries +local pairs, ipairs, next, type, pcall = pairs, ipairs, next, type, pcall +local tonumber = tonumber +local math_floor, math_max = math.floor, math.max +local string_format = string.format +local table_sort = table.sort +local wipe = wipe or function(t) for k in pairs(t) do t[k] = nil end return t end +local GetTime, InCombatLockdown = GetTime, InCombatLockdown +local UnitExists, UnitGUID, UnitClass, UnitName = UnitExists, UnitGUID, UnitClass, UnitName + +--------------------------------------------------------------------------- +-- Coordination (1.5.0): cast sync between BuffRadar users, chat buff +-- requests, and a one-line summary when you join a group. +--------------------------------------------------------------------------- +function X.InitSync() + if X.syncReg then return end + X.syncReg = true + if _G.C_ChatInfo and _G.C_ChatInfo.RegisterAddonMessagePrefix then + pcall(_G.C_ChatInfo.RegisterAddonMessagePrefix, "BuffRadar") + elseif _G.RegisterAddonMessagePrefix then + pcall(_G.RegisterAddonMessagePrefix, "BuffRadar") + end +end + +local function SyncChannel() + if InRaid() then return "RAID" end + if InGroup() then return "PARTY" end +end + +-- One broadcast to the group's BuffRadar users (party or raid channel). +function X.Broadcast(msg) + if not db or not db.sync then return false end + local channel = SyncChannel() + local send = (_G.C_ChatInfo and _G.C_ChatInfo.SendAddonMessage) or _G.SendAddonMessage + if not channel or not send then return false end + local ok, result = pcall(send, "BuffRadar", msg, channel) + if not ok then return false end + if type(result) == "nil" then return true end -- legacy API has no return value + if not Readable(result) then return false end + if type(result) == "number" then + local success = _G.Enum and _G.Enum.SendAddonMessageResult and _G.Enum.SendAddonMessageResult.Success + return result == (success or 0) + end + return result ~= false +end + +-- Tell the other BuffRadar users in the group "I just cast KEY on GUID", +-- so their lists sink that player instead of double-casting the same buff. +function X.SyncSend(key, guid) + local message = "CAST;" .. key .. ";" .. guid + if CLASSIC_FEATURES then X.SendScopedSync(message) else X.Broadcast(message) end +end + +-- Cover-me handoff (1.7.0): while you're dead or AFK, tell the other +-- BuffRadar users so your duties pass to them; tell them when you're +-- back. Broadcasts on state change, and re-sends every couple of +-- minutes while you're still away so their cover doesn't lapse. +function X.SendCover() + if not db then return end + local me = Ignore.UnitNames("player") + if not me then return end + local covered = X.PlayerSuspended() or X.ReadUnitBool(_G.UnitIsAFK, "player") == true + if X.myCover == covered and not covered then return end + if X.myCover == covered and GetTime() - (X.coverSentAt or 0) < 120 then return end + X.myCover = covered + X.coverSentAt = GetTime() + X.Broadcast((covered and "COVER;" or "BACK;") .. me) +end + +-- Do two player names refer to the same user? Names ride the wire as +-- typed (often the bare short name), while identity checks use full +-- "Name-Realm" strings. Same when the full names match, or the short +-- names match and neither side names a conflicting realm — the same +-- rule the ignore list has always used for bare names. +function X.SameUser(a, b) + if not a or not b then return false end + if Ignore.Key(a) == Ignore.Key(b) then return true end + local as, ar = a:match("^([^%-]+)%-?(.*)$") + local bs, br = b:match("^([^%-]+)%-?(.*)$") + if Ignore.Key(as or "") ~= Ignore.Key(bs or "") then return false end + if ar and ar ~= "" and br and br ~= "" + and Ignore.Key(ar) ~= Ignore.Key(br) then return false end + return true +end + +do + local supportedKeys = { BLESSINGS = true } + for _, def in ipairs(BUFF_DEFS) do supportedKeys[def.key] = true end + for _, def in ipairs(X.AURA_DEFS or {}) do supportedKeys[def.key] = true end + + local function ReadText(value) + return type(value) == "string" and Readable(value) + end + + local function ValidName(name) + return ReadText(name) and #name <= 128 and name:find("%S") and not name:find("[%c;|]") + end + + local function ValidBuffKey(key) + return supportedKeys[key] or (#key <= 16 and key:match("^CUSTOM[1-9]%d*$")) + end + + -- A refused realm is different from a readable empty realm, which means local. + -- The ignore list can fall back to a short name, but roster authorization + -- must never fill in a realm the game withheld. + local function RosterNames(unit) + local ok, name, realm = pcall(UnitFullName or UnitName, unit) + if not ok or not ValidName(name) then return end + if type(realm) ~= "nil" and (not ReadText(realm) or (realm ~= "" and not ValidName(realm))) then return end + if not realm or realm == "" then + if GetNormalizedRealmName then + local realmOK, localRealm = pcall(GetNormalizedRealmName) + if realmOK and ValidName(localRealm) then realm = localRealm end + end + end + return realm and realm ~= "" and name .. "-" .. realm:gsub("%s+", "") or name, name + end + + -- Match a full name exactly, or accept a bare name only if it is unique + -- across the readable roster. The raid list already includes the player. + function X.SenderUnit(sender) + if not ValidName(sender) then return end + local key = Ignore.Key(sender) + local qualified = key:find("-", 1, true) + local raid = InRaid() + local roster = raid and RAID or PARTY + local found, canonical + for i = raid and 1 or 0, #roster do + local unit = roster[i] or "player" + if X.ReadUnitBool(UnitExists, unit) == true then + local full, short = RosterNames(unit) + if not full then + if not qualified then return end + elseif key == Ignore.Key(qualified and full or short) then + if found then return end + found, canonical = unit, full + end + end + end + return found, canonical + end + + local function PlanRank(unit) + local leader = X.ReadUnitBool(_G.UnitIsGroupLeader, unit) + if leader == true then return 2 end + local assistant = X.ReadUnitBool(_G.UnitIsGroupAssistant, unit) + local idx = unit:match("^raid(%d+)$") + if idx and GetRaidRosterInfo then + local ok, _, rank = pcall(GetRaidRosterInfo, tonumber(idx)) + if ok and type(rank) == "number" and Readable(rank) and rank == 2 then return 2 end + if ok and type(rank) == "number" and Readable(rank) and rank == 1 then return 1 end + if assistant == true then return 1 end + if ok and type(rank) == "number" and Readable(rank) and rank == 0 then return 0 end + end + if assistant == true then return 1 end + if leader == false and (assistant == false or not InRaid()) then return 0 end + end + + local function HasPlanRole(unit, forBless) + if (PlanRank(unit) or 0) > 0 then return true end + if forBless then + local ok, _, class = pcall(UnitClass, unit) + return ok and ReadText(class) and class == "PALADIN" + end + return false + end + + function X.SenderTrusted(sender, forBless) + local unit = X.SenderUnit(sender) + return unit ~= nil and HasPlanRole(unit, forBless) + end + + function X.AmLead() + if HasPlanRole("player") then return true end + if InRaid() then + for i = 1, #RAID do + if X.IsSelf(RAID[i]) == true then return HasPlanRole(RAID[i]) end + end + end + return false + end + + function X.PruneSyncRoster() + if not next(X.peers) and not next(X.cover) then return end + local roster = InRaid() and RAID or PARTY + local present = {} + for _, unit in ipairs(roster) do + if X.ReadUnitBool(UnitExists, unit) == true then + local full = RosterNames(unit) + if full then present[Ignore.Key(full)] = true end + end + end + for key in pairs(X.peers) do + if not present[key] then X.peers[key] = nil end + end + for name in pairs(X.cover) do + if not present[Ignore.Key(name)] then X.cover[name] = nil end + end + end + + local function RememberCast(guid, key, now) + if not X.handled[guid] then + local count, oldestGuid, oldestTime = 0, nil, now + for seenGuid, handled in pairs(X.handled) do + count = count + 1 + if not oldestGuid or handled.t < oldestTime then + oldestGuid, oldestTime = seenGuid, handled.t + end + end + if count >= 128 then X.handled[oldestGuid] = nil end + end + X.handled[guid] = { key = key, t = now } + end + + local function OtherSyncSender(sender, channel) + local unit, name = X.SenderUnit(sender) + if not unit or unit == "player" then return end + local me, senderKey = RosterNames("player"), Ignore.Key(name) + if me and senderKey == Ignore.Key(me) then return end + if channel == "RAID" then + local isSelf = X.IsSelf(unit) + if isSelf == true or (isSelf == nil and not me) then return end + end + return unit, name, senderKey, me + end + + do + local active, sequence, generation, token = nil, 0, 0, 0 + local resetReason + local scope, nonceSerial + local departedScopes, departedCount = {}, 0 + local retired, retirementOrder, retirementSlot = {}, {}, 1 + local statusLabels = { sent = "Awaiting acknowledgement", acknowledged = "Acknowledged", + failed = "Send failed", localOnly = "Assigned locally" } + + local function SetSession(session, rosterChanged) + active = session + resetReason = rosterChanged and "Caster coordination was cleared because the group or its leadership changed." or nil + generation = generation + 1 + token = token + 1 + end + + local function NotifyCoordination() + token = token + 1 + if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end + end + + local function CoordinationGUID(unit) + local ok, guid = pcall(UnitGUID, unit) + if ok and ReadText(guid) and #guid <= 85 and guid:match("^Player%-%w[%w%-]*$") then return guid end + end + + local function CoordinationRoster() + local channel = SyncChannel() + if not channel then return end + local members, ids, leaders = {}, {}, 0 + local size = X.ReadUnitNumber(GetNumGroupMembers) + X.ForReportRoster(function(unit, exists) + local guid = exists and CoordinationGUID(unit) + local name = guid and RosterNames(unit) + local rank = name and PlanRank(unit) + if rank ~= nil and not members[guid] then + members[guid] = { name = name, unit = unit } + ids[#ids + 1] = guid .. "=" .. rank + if rank == 2 then leaders = leaders + 1 end + end + end) + if size ~= #ids or leaders ~= 1 then return end + table_sort(ids) + return members, channel .. ":" .. table.concat(ids, ",") + end + + local function SyncDigest(identity) + local first, second = 0, 0 + for i = 1, #identity do + local byte = identity:byte(i) + first = (first * 131 + byte) % 2147483647 + second = (second * 137 + byte) % 2147483629 + end + return string_format("%08x%08x", first, second) + end + + local function NewSyncNonce() + nonceSerial = (nonceSerial or 0) + 1 + return string_format("%06x%06x%06x%06x", math.random(0, 0xffffff), math.random(0, 0xffffff), + math_floor(GetTime() * 1000) % 0x1000000, nonceSerial % 0x1000000) + end + + local function RetireSyncEpoch(guid, epoch) + if not epoch then return end + local key = guid .. ":" .. epoch + if retired[key] then return end + local oldest = retirementOrder[retirementSlot] + if oldest then retired[oldest] = nil end + retired[key] = true + retirementOrder[retirementSlot] = key + retirementSlot = retirementSlot % 160 + 1 + end + + local function RememberDepartedScope(identity) + if not departedScopes or departedScopes[identity] then return end + if departedCount >= 64 then + -- Once the history is full, require a fresh proof floor on every entry. + departedScopes = nil + return + end + departedScopes[identity] = true + departedCount = departedCount + 1 + end + + local function BroadcastSyncWarmup(current, now) + local nonce = NewSyncNonce() + if not X.Broadcast("SYNC;3;B;" .. current.digest .. ";" .. nonce) then return false end + current.priorWarmNonce, current.warmNonce, current.warmExpires = current.warmNonce, nonce, now + 3 + return true + end + + local function RetrySyncWarmup(current) + if not current or scope ~= current or not current.warmRetryAt then return end + local now = GetTime() + if now < current.warmRetryAt then return end + current.warmRetryAt = nil + if not db or not db.sync then return end + local members, identity = CoordinationRoster() + local me = CoordinationGUID("player") + if identity ~= current.identity or not me or not members[me] then return end + for guid in pairs(members) do + local peer = current.peers[guid] + if guid ~= me and not (peer and peer.epoch) then + if BroadcastSyncWarmup(current, now) then + -- Reordered data can still be proved by either broadcast. Keep + -- only the existing bounded queues for this one extra window. + for _, unresolved in pairs(current.peers) do + if not unresolved.epoch and unresolved.pending then + for _, pending in ipairs(unresolved.pending) do + if not pending.challenge then pending.expires = current.warmExpires end + end + end + end + end + return + end + end + end + + local function StartSyncWarmup(current) + if not current or not current.requireProofFloor or current.warmAttempted or not db or not db.sync then return end + current.warmAttempted = true + local now = GetTime() + BroadcastSyncWarmup(current, now) + current.warmRetryAt = now + 3 + if C_Timer and C_Timer.After then + C_Timer.After(3, function() RetrySyncWarmup(current) end) + end + end + + function X.RunDueSyncWarmupRetry() + RetrySyncWarmup(scope) + end + + local function UpdateSyncScope(force) + if not CLASSIC_FEATURES then return end + local members, identity = CoordinationRoster() + if scope and scope.identity == identity and not force then + StartSyncWarmup(scope) + return scope, members + end + if scope then + RememberDepartedScope(scope.identity) + -- Remember epochs seen in the last scope in case this roster returns. + for guid, peer in pairs(scope.peers) do + RetireSyncEpoch(guid, peer.epoch) + if peer.observed then + for _, epoch in ipairs(peer.observed) do RetireSyncEpoch(guid, epoch) end + end + end + wipe(X.handled) + end + if active and (force or active.identity ~= identity) then SetSession(nil, true) end + scope = identity and { identity = identity, digest = SyncDigest(identity), epoch = NewSyncNonce(), + requireProofFloor = not departedScopes or departedScopes[identity], seq = 0, peers = {} } or nil + StartSyncWarmup(scope) + return scope, members + end + + function X.SendScopedSync(payload) + if not db or not db.sync then return false end + local current = UpdateSyncScope() + if not current then return false end + local seq = current.seq + 1 + local message = "SYNC;3;D;" .. current.digest .. ";" .. current.epoch .. ";" .. seq .. ";" .. payload + if #message > 255 or not X.Broadcast(message) then return false end + current.seq = seq + return true + end + + local function Session() + if not active then return end + if not db or not db.sync then SetSession(nil); return end + local _, members = UpdateSyncScope() + return active, members + end + + local function LearnedKeys() + local keys = {} + for _, buff in ipairs(myBuffs) do + if supportedKeys[buff.key] and not buff.self and not buff.custom + and IsOn(buff.key, buff.default) and X.ContextOK(buff.key) then keys[buff.key] = true end + end + if X.HasKnownBlessings() and IsOn("BLESSINGS", true) and X.ContextOK("BLESSINGS") then + keys.BLESSINGS = true + end + return keys + end + + local function SortedKeys(keys) + local list = {} + for key in pairs(keys) do list[#list + 1] = key end + table_sort(list) + return list + end + + local function KeyList(keys) + return table.concat(SortedKeys(keys), ",") + end + + local function ParseKeys(list) + if list == "-" then return {} end + if not list:match("^[%u_]+[,_%u]*$") then return end + local keys = {} + for key in list:gmatch("[%u_]+") do + if keys[key] or not supportedKeys[key] then return end + keys[key] = true + end + if KeyList(keys) == list then return keys end + end + + local function SendCoord(kind, id, recipient, list) + local message = "COORD;1;" .. kind .. ";" .. id + if recipient then message = message .. ";" .. recipient end + if list then message = message .. ";" .. (list ~= "" and list or "-") end + return X.SendScopedSync(message) + end + + local function NextCoordID() + sequence = sequence + 1 + return string_format("%d.%d", math_floor(GetTime() * 1000), sequence) + end + + local function DraftPlan(session, members, localGUID, localKeys) + local demand, ordered, rows, loads = {}, {}, {}, {} + for key in pairs(session.requested) do demand[key] = true end + for guid, report in pairs(session.reports) do + if members[guid] then + if guid == localGUID then report = localKeys end + for key in pairs(report) do demand[key] = true end + end + end + for key in pairs(demand) do ordered[#ordered + 1] = key end + table_sort(ordered) + for _, key in ipairs(ordered) do + local manual = X.assign[key] + local choice + if not manual then + for guid, report in pairs(session.reports) do + if guid == localGUID then report = localKeys end + if members[guid] and report[key] then + local load, existing = loads[guid] or 0, loads[choice] or 0 + if not choice or load < existing or (load == existing and guid < choice) then choice = guid end + end + end + end + rows[#rows + 1] = { key = key, guid = choice, manual = manual } + if choice then loads[choice] = (loads[choice] or 0) + 1 end + end + return rows + end + + local function SamePlan(a, b) + if #a ~= #b then return false end + for i, row in ipairs(a) do + local other = b[i] + if row.key ~= other.key or row.guid ~= other.guid or row.manual ~= other.manual then return false end + end + return true + end + + local function PlanNames(row, members) + local before = row.manual or L["Unassigned"] + local after = row.guid and members[row.guid].name or row.manual or L["Provider unavailable"] + return before, after + end + + local function ReviewPlan(session, members) + local me = CoordinationGUID("player") + if me then session.reports[me] = LearnedKeys() end + session.draft = DraftPlan(session, members) + Print(L["Review Caster Plan"]) + if #session.draft == 0 then Print(L["No learned buff capabilities have been reported."]) end + for _, row in ipairs(session.draft) do + local before, after = PlanNames(row, members) + Print(string_format(L["%s: %s -> %s"], row.key, before, after)) + end + end + + local function ParsePlanRest(value) + local revision, target, list = value:match("^(%d+%.%d+);([^;]+);([^;]+)$") + if revision and #revision <= 32 then return revision, target, ParseKeys(list) end + end + + local function NewerRevision(revision, previous) + if not previous then return true end + local millis, order = revision:match("^(%d+)%.(%d+)$") + local oldMillis, oldOrder = previous:match("^(%d+)%.(%d+)$") + return tonumber(millis) > tonumber(oldMillis) + or (tonumber(millis) == tonumber(oldMillis) and tonumber(order) > tonumber(oldOrder)) + end + + local function PendingPlan(session, members, now) + local pending = session.pending + local coordinator = pending and members[pending.sender] + local reply = coordinator and session.replies[pending.sender] + if reply and reply.id == pending.id and now - reply.time <= 180 and HasPlanRole(coordinator.unit) then + return pending, reply.time + 180 + end + end + + function X.CoordinationSnapshot() + local snapshot = { generation = generation, token = token, reports = {}, sent = {} } + if not CLASSIC_FEATURES then + snapshot.reason = "Caster Coordination is available in WoW: Forever." + return snapshot + end + if not db or not db.sync or not SyncChannel() or InCombatLockdown() or X.PlayerSuspended() then + snapshot.reason = "Caster Coordination needs cast sync and a group outside combat." + return snapshot + end + local session, members = Session() + snapshot.generation, snapshot.token, snapshot.available = generation, token, true + if not session then + local _, identity = CoordinationRoster() + if not identity then + snapshot.available, snapshot.reason = false, "Roster information is unavailable." + else + snapshot.reason = resetReason + end + return snapshot + end + local now = GetTime() + local function Deadline(time) + if time and time > now and (not snapshot.nextRefreshAt or time < snapshot.nextRefreshAt) then + snapshot.nextRefreshAt = time + end + end + snapshot.active, snapshot.leader = true, X.AmLead() + local pending, pendingAt = PendingPlan(session, members, now) + if pending then + snapshot.pending = { name = pending.name, keys = SortedKeys(pending.keys), + revision = pending.revision, reviewed = pending.reviewed == true } + Deadline(pendingAt + 0.01) + end + if session.accepted and now <= session.accepted.expires then + snapshot.accepted = { keys = SortedKeys(session.accepted.keys) } + Deadline(session.accepted.expires + 0.01) + end + if not snapshot.leader then return snapshot end + local readyAt = session.requestAt and session.requestAt + 10 + snapshot.canRequest = not readyAt or now >= readyAt + Deadline(readyAt) + snapshot.reportRequest = session.request ~= nil and now <= session.expires + if snapshot.reportRequest then + Deadline(session.expires + 0.01) + local currentReports = {} + for guid, member in pairs(members) do + local keys = session.reports[guid] + currentReports[#currentReports + 1] = { name = member.name, keys = keys and SortedKeys(keys) } + end + table_sort(currentReports, function(a, b) return a.name < b.name end) + snapshot.reports = currentReports + if session.draft then + snapshot.draft = {} + for _, row in ipairs(session.draft) do + local before, after = PlanNames(row, members) + snapshot.draft[#snapshot.draft + 1] = { key = row.key, before = before, after = after } + end + snapshot.canPublish = SamePlan(session.draft, DraftPlan(session, members, CoordinationGUID("player"), LearnedKeys())) + end + end + if session.sent and now <= session.sent.expires then + Deadline(session.sent.expires + 0.01) + for _, guid in ipairs(session.sent.order) do + snapshot.sent[#snapshot.sent + 1] = { name = members[guid].name, status = session.sent.recipients[guid] } + end + end + return snapshot + end + + local function OnCoordMessage(body, unit, name, now) + local kind, id, rest = body:match("^;(%u+);(%d+%.%d+)(.*)$") + if not kind or #id > 32 then return end + local session, members = Session() + local guid = session and CoordinationGUID(unit) + local me = guid and CoordinationGUID("player") + if not me or not members[guid] then return end + if kind == "REQ" and rest == "" and HasPlanRole(unit) then + if session.replies[guid] and now - session.replies[guid].time < 10 then return end + session.replies[guid] = { id = id, time = now } + SendCoord("REPORT", id, guid, KeyList(LearnedKeys())) + if session.pending and session.pending.sender == guid then NotifyCoordination() end + elseif kind == "REPORT" and session.request == id and now <= session.expires and X.AmLead() then + local target, list = rest:match("^;([^;]+);([^;]+)$") + if not list or target ~= me or session.reports[guid] then return end + local keys = ParseKeys(list) + if not keys then return end + session.reports[guid] = keys + NotifyCoordination() + elseif kind == "PLAN" and HasPlanRole(unit) then + if rest:sub(1, 1) ~= ";" then return end + local reply = session.replies[guid] + local revision, target, keys = ParsePlanRest(rest:sub(2)) + if not reply or reply.id ~= id or now - reply.time > 180 or target ~= me or not keys + or not NewerRevision(revision, reply.revision) then return end + local learned = LearnedKeys() + for key in pairs(keys) do if not learned[key] then return end end + reply.revision = revision + session.pending = { sender = guid, name = name, id = id, revision = revision, keys = keys } + Print(string_format(L["Caster plan from %s. Use /br coordinate inbox to review it."], name)) + NotifyCoordination() + elseif kind == "ACK" and session.sent and now <= session.sent.expires and id == session.sent.revision and rest == "" then + if session.sent.recipients[guid] == "sent" then + session.sent.recipients[guid] = "acknowledged" + NotifyCoordination() + end + end + end + + function X.OnCoordinationRoster(force) + UpdateSyncScope(force) + if active and (not db or not db.sync) then SetSession(nil) end + if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end + end + + function X.StopCoordination() + SetSession(nil) + if scope and (not db or not db.sync) then + scope.warmRetryAt = nil + scope.warmNonce, scope.priorWarmNonce, scope.warmExpires = nil, nil, nil + for _, peer in pairs(scope.peers) do peer.pending = nil end + end + if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end + end + + function X.CoordinatedHolder(key) + local accepted = active and db.sync and active.accepted + if accepted and GetTime() <= accepted.expires then return accepted.keys[key] and accepted.name end + end + + local function Coordinate(command, argument) + if not CLASSIC_FEATURES then Print(L["Caster Coordination is available in WoW: Forever."]); return end + if command == "off" then + X.StopCoordination() + if QueueRefresh then QueueRefresh() end + Print(L["Caster Coordination is off."]) + return + end + if command == "" then + Print(L["Use /br coordinate panel|on|off|request|need|review|publish|status|inbox|accept|decline."]) + return + end + if not db or not db.sync or not SyncChannel() or InCombatLockdown() or X.PlayerSuspended() then + Print(L["Caster Coordination needs cast sync and a group outside combat."]); return + end + if command == "on" then + local current = UpdateSyncScope() + if not current then Print(L["Roster information is unavailable."]); return end + SetSession({ identity = current.identity, reports = {}, replies = {}, requested = {} }) + Print(L["Caster Coordination is on for this group."]); return + end + local session, members = Session() + if not session then Print(L["Use /br coordinate on to join this group's caster planning."]); return end + local me = CoordinationGUID("player") + local now = GetTime() + if not me or not members[me] then Print(L["Roster information is unavailable."]); return end + if command == "inbox" or command == "accept" or command == "decline" then + local pending = PendingPlan(session, members, now) + if not pending then + session.pending = nil; Print(L["No current caster plan to review."]); return + end + if command == "inbox" then + pending.reviewed = true + Print(string_format(L["Caster plan from %s: %s. Use /br coordinate accept or decline."], + pending.name, next(pending.keys) and KeyList(pending.keys) or L["No assigned buffs"])) + elseif command == "decline" then + session.pending = nil + elseif not pending.reviewed then + Print(L["Review the caster plan with /br coordinate inbox first."]) + else + local learned = LearnedKeys() + for key in pairs(pending.keys) do + if not learned[key] or X.assign[key] and not X.SameUser(X.assign[key], members[me].name) then + Print(L["Your learned buffs or existing assignments changed. Ask for a new caster plan."]); return + end + end + if not SendCoord("ACK", pending.revision) then Print(L["The caster message could not be sent."]); return end + session.accepted = next(pending.keys) and { keys = pending.keys, name = members[me].name, + coordinator = pending.sender, expires = now + 180 } or nil + session.pending = nil + Print(L["Caster duties accepted."]) + if QueueRefresh then QueueRefresh() end + end + return + end + if not X.AmLead() then Print(L["Only the group leader or an assistant can manage caster plans."]); return end + if command == "request" then + if session.requestAt and now - session.requestAt < 10 then return end + local id = NextCoordID() + if not SendCoord("REQ", id) then Print(L["The caster message could not be sent."]); return end + session.request, session.requestAt, session.expires = id, now, now + 180 + session.reports, session.draft = { [me] = LearnedKeys() }, nil + Print(L["Asked group members for their learned buffs."]) + elseif command == "need" then + local key = argument and argument:upper() + if not key or not supportedKeys[key] then Print(L["Use /br coordinate need ."]); return end + session.requested[key] = true + session.draft = nil + elseif command == "status" and session.sent then + for _, guid in ipairs(session.sent.order) do + local status = session.sent.recipients[guid] + Print(string_format(L["%s: %s"], members[guid].name, L[statusLabels[status]])) + end + elseif not session.request or now > session.expires then + Print(L["Request fresh caster reports with /br coordinate request."]) + elseif command == "publish" then + if not session.draft then Print(L["Review the caster plan with /br coordinate review first."]); return end + session.reports[me] = LearnedKeys() + local fresh = DraftPlan(session, members) + if not SamePlan(session.draft, fresh) then + Print(L["Caster reports or assignments changed. Review the updated draft before publishing."]) + ReviewPlan(session, members); return + end + local plan, order, revision = {}, {}, NextCoordID() + for _, row in ipairs(fresh) do + if row.guid then + if not plan[row.guid] then plan[row.guid] = {}; order[#order + 1] = row.guid end + plan[row.guid][row.key] = true + end + end + if session.sent then + for _, guid in ipairs(session.sent.order) do + if not plan[guid] and session.reports[guid] then plan[guid] = {}; order[#order + 1] = guid end + end + end + if not next(plan) then Print(L["No new caster duties to send."]); return end + table_sort(order) + local sent = { revision = revision, order = order, recipients = {}, expires = now + 180 } + for _, guid in ipairs(order) do + local keys = plan[guid] + if guid == me then + session.accepted = next(keys) and { keys = keys, name = members[guid].name, + coordinator = me, expires = now + 180 } or nil + sent.recipients[guid] = "localOnly" + else + -- Include the report request and a separate publication revision. + local target = revision .. ";" .. guid + sent.recipients[guid] = SendCoord("PLAN", session.request, target, KeyList(keys)) and "sent" or "failed" + end + end + session.sent, session.draft = sent, nil + if QueueRefresh then QueueRefresh() end + Coordinate("status") + else + ReviewPlan(session, members) + end + end + + function X.Coordinate(command, argument, expectedToken) + if expectedToken ~= nil then + Session() + if expectedToken ~= token then + if X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end + return + end + end + Coordinate(command, argument) + NotifyCoordination() + end + + local function ScopedPayload(payload) + local first, guid = payload:match("^CAST;([%w_]+);([%a]+%-%w[%w%-]*)$") + if guid and #guid <= 85 and ValidBuffKey(first) then return first, guid end + local body = payload:match("^COORD;1(;.+)$") + if body and active and not InCombatLockdown() and not X.PlayerSuspended() then + return body + end + end + + local function ApplyScopedPacket(packet, unit, name, senderKey, now) + local first, guid = ScopedPayload(packet.payload) + if not first then return end + if guid then + RememberCast(guid, first, now) + local presence = X.peers[senderKey] or {} + presence.t, presence.name = now, name + X.peers[senderKey] = presence + if QueueRefresh then QueueRefresh() end + elseif packet.generation == generation then + OnCoordMessage(first, unit, name, now) + end + end + + local function SyncControl(kind, current, epoch, challenge, target) + local message = "SYNC;3;" .. kind .. ";" .. current.digest .. ";" .. epoch .. ";" .. challenge .. ";" .. target + if kind == "P" then message = message .. ";" .. current.seq end + return X.Broadcast(message) + end + + local function NewSyncSequence(window, seq) + -- Broadcast plan rows can arrive out of order. A fixed receive window + -- accepts that reordering without replaying a previously seen packet. + local slot = seq % 32 + if seq <= window.floor or seq <= window.high - 32 or window[slot] == seq then return false end + window.high = math_max(window.high, seq) + window[slot] = seq + return true + end + + local function FindSyncPending(peer, epoch, now) + if not peer or not peer.pending then return end + for i = #peer.pending, 1, -1 do + local pending = peer.pending[i] + if now > pending.expires then + table.remove(peer.pending, i) + elseif pending.epoch == epoch then + return pending + end + end + end + + local function ObserveSyncEpoch(peer, epoch) + local observed = peer.observed or {} + for _, previous in ipairs(observed) do if previous == epoch then return end end + if #observed >= 4 then table.remove(observed, 1) end + observed[#observed + 1] = epoch + peer.observed = observed + end + + function X.HandleScopedSync(version, rest, channel, source, now) + if not CLASSIC_FEATURES or version ~= "3" then return end + local kind, digest, epoch, field, payload = rest:match("^;([DQP]);([%da-f]+);([%da-f]+);([^;]+);(.+)$") + if not kind then + digest, field = rest:match("^;B;([%da-f]+);([%da-f]+)$") + if not digest or #field ~= 24 then return end + kind = "B" + end + if #digest ~= 16 or (epoch and #epoch ~= 24) then return end + local me = CoordinationGUID("player") + if not me then return end + local proofFloor + if kind == "P" or kind == "Q" then + local target = payload + if kind == "P" then + local floor + target, floor = payload:match("^([^;]+);([^;]+)$") + if not floor or #floor > 10 or (floor ~= "0" and not floor:match("^[1-9]%d*$")) then return end + proofFloor = tonumber(floor) + end + if target ~= me or #field ~= 24 or not field:match("^[%da-f]+$") then return end + end + local unit, name, senderKey = OtherSyncSender(source, channel) + local sender = unit and CoordinationGUID(unit) + if not sender then return end + local current, members = UpdateSyncScope() + if not current or current.digest ~= digest or not members[sender] or not members[me] then return end + local peer = current.peers[sender] or {} + local warmActive = current.warmExpires and now <= current.warmExpires + if kind == "B" then + if peer.warmReplyAt and now - peer.warmReplyAt < 1 then return end + local answered = peer.warmReplies or {} + for _, nonce in ipairs(answered) do if nonce == field then return end end + if SyncControl("P", current, current.epoch, field, sender) then + if #answered >= 4 then table.remove(answered, 1) end + answered[#answered + 1] = field + peer.warmReplies, peer.warmReplyAt = answered, now + current.peers[sender] = peer + end + elseif kind == "Q" then + if epoch == current.epoch and peer.answered ~= field and SyncControl("P", current, epoch, field, sender) then + peer.answered = field + current.peers[sender] = peer + end + elseif kind == "P" then + local pending = FindSyncPending(peer, epoch, now) + local isWarm = field == current.warmNonce or field == current.priorWarmNonce + if isWarm then + if not warmActive or peer.epoch then return end + else + if not pending or pending.challenge ~= field then return end + if current.requireProofFloor and proofFloor < pending.challengeSeq then return end + if not current.requireProofFloor and retired[sender .. ":" .. epoch] then return end + end + if peer.epoch ~= epoch then RetireSyncEpoch(sender, peer.epoch) end + -- A sender may have missed the transition back to this exact roster. + -- Accept only traffic it produced after answering the new challenge. + local window = pending and pending.window or { high = 0, floor = 0 } + if current.requireProofFloor then window.floor = proofFloor end + peer.epoch, peer.window, peer.pending = epoch, window, nil + current.peers[sender] = peer + if pending then + table_sort(pending.packets, function(a, b) return a.seq < b.seq end) + for _, packet in ipairs(pending.packets) do + if packet.seq > window.floor then ApplyScopedPacket(packet, unit, name, senderKey, now) end + end + end + else + if #field > 10 or not field:match("^[1-9]%d*$") or not ScopedPayload(payload) then return end + local seq = tonumber(field) + local packet = { payload = payload, generation = generation, seq = seq } + if peer.epoch == epoch then + if not NewSyncSequence(peer.window, seq) then return end + ApplyScopedPacket(packet, unit, name, senderKey, now) + else + if not current.requireProofFloor and retired[sender .. ":" .. epoch] then return end + local pending = FindSyncPending(peer, epoch, now) + if not pending then + local challenge, expires + if warmActive and not peer.epoch then + -- Let the broadcast proof arrive before issuing a targeted + -- challenge that would count these held packets in its floor. + expires = current.warmExpires + else + challenge, expires = NewSyncNonce(), now + 5 + if not SyncControl("Q", current, epoch, challenge, sender) then return end + end + pending = { epoch = epoch, challenge = challenge, challengeSeq = seq, expires = expires, + window = { high = 0, floor = 0 }, packets = {} } + peer.pending = peer.pending or {} + if #peer.pending >= 2 then table.remove(peer.pending, 1) end + peer.pending[#peer.pending + 1] = pending + current.peers[sender] = peer + ObserveSyncEpoch(peer, epoch) + end + local replace + if #pending.packets >= 8 then + if pending.challenge then return end + -- A burst of stale packets must not crowd newer cast or plan data + -- out of the queue before the broadcast proof supplies its floor. + local lowest = seq + for index, held in ipairs(pending.packets) do + if held.seq < lowest then replace, lowest = index, held.seq end + end + if not replace then return end + end + if not NewSyncSequence(pending.window, seq) then return end + pending.packets[replace or #pending.packets + 1] = packet + return + end + end + end + end + + function X.OnAddonMsg(prefix, msg, channel, sender) + if not db or not db.sync or not ReadText(prefix) or prefix ~= "BuffRadar" then return end + if not ReadText(channel) or channel ~= SyncChannel() then return end + if not ReadText(msg) or #msg > 255 then return end + local kind, first, rest = msg:match("^([A-Z]+);([^;]+)(.*)$") + if not kind then return end + local now = GetTime() + if kind == "SYNC" then + X.HandleScopedSync(first, rest, channel, sender, now) + return + end + + local unit, name, senderKey, me = OtherSyncSender(sender, channel) + if not unit then return end + if kind == "CAST" then + if CLASSIC_FEATURES then return end + local guid = rest:match("^;([%a]+%-%w[%w%-]*)$") + if not guid or #guid > 85 or not ValidBuffKey(first) then return end + RememberCast(guid, first, now) + elseif kind == "ASSIGN" then + local holder = rest:match("^;([^;]+)$") + if not ValidBuffKey(first) or not ValidName(holder) or not HasPlanRole(unit) then return end + if holder:lower() == "none" then X.assign[first] = nil else X.assign[first] = holder end + elseif kind == "BLESS" then + local key, holder = rest:match("^;([%w_]+);([^;]+)$") + if not key or not X.BLESSING_CLASSES[first] or not ValidName(holder) + or (key ~= "NONE" and not BLESSINGS[key]) or not HasPlanRole(unit, true) then return end + if key == "NONE" or holder == "none" then + X.blessPlan[first] = nil + else + X.blessPlan[first] = { key = key, name = holder, mine = me ~= nil and X.SameUser(holder, me) } + end + elseif kind == "COVER" or kind == "BACK" or kind == "HELLO" or kind == "HERE" then + if rest ~= "" or not ValidName(first) or not X.SameUser(first, name) then return end + if kind == "COVER" then X.cover[name] = now + 300 end + if kind == "BACK" then X.cover[name] = nil end + else + return + end + + local peer = X.peers[senderKey] or {} + peer.t, peer.name = now, name + X.peers[senderKey] = peer + if kind == "HELLO" and me and (not peer.replyAt or now - peer.replyAt >= 10) then + peer.replyAt = now + X.Broadcast("HERE;" .. me) + end + if kind == "ASSIGN" and X.QueueCoordinationRefresh then X.QueueCoordinationRefresh() end + if QueueRefresh then QueueRefresh() end + end +end + +-- A whisper or a nearby "buff ..." marks that player's row while it is up. +function X.OnChatAsk(text, author) + if not db or not db.requests or X.PlayerSuspended() then return end + if type(text) ~= "string" or not Readable(text) + or type(author) ~= "string" or not Readable(author) then return end + if not text:lower():find("buff", 1, true) then return end + local short = author:match("^[^%-]+") or author + local ka, ks = Ignore.Key(author), Ignore.Key(short) + for i = 1, A.nEntries() do + local e = entries[i] + if e and (Ignore.Key(e.fullName or "") == ka or Ignore.Key(e.sortName or "") == ks) then + if (not X.asked[e.guid] or GetTime() - X.asked[e.guid] > 30) + and db.playSound and GetTime() - X.lastSoundAt > 1 then + X.lastSoundAt = GetTime() + PlayAlert("ask") + end + X.asked[e.guid] = GetTime() + if QueueRefresh then QueueRefresh() end + return + end + end +end + +-- Does one of my equipped weapons lack a temporary enchant (a shaman +-- imbue, a rogue poison, an oil or a sharpening stone)? (1.7.0) +-- GetWeaponEnchantInfo is the game's own answer; a hand only counts +-- when a weapon is actually equipped in it. +-- Per-buff context (1.8.0): a buff can be limited to raids or to +-- instances (dungeons, raids, battlegrounds) and is then simply not +-- offered anywhere else. Set with /br context KEY raid|instance|always. +-- On Forever, Shadow Protection ships with the instance limit as its +-- default (the resistance-context rule) until the user changes it. +function X.ContextOK(key) + local c = db and db.buffContext and db.buffContext[key] + if not c then return true end + if c == "raid" then return InRaid() end + if c == "instance" then return InInstanceNow() ~= nil end + return true +end + +function X.WeaponEnchantMissing() + local fn = _G.GetWeaponEnchantInfo + if not fn then return false end + local ok, hasMH, _, _, _, hasOH = pcall(fn) + if not ok or not Readable(hasMH) or not Readable(hasOH) then return false end + local function equipped(slot) + if not _G.GetInventoryItemID then return true end + local okI, id = pcall(_G.GetInventoryItemID, "player", slot) + return okI and Readable(id) and id ~= nil + end + if not hasMH and equipped(16) then return true end + if not hasOH and equipped(17) then return true end + return false +end + +-- Instance-entry reminder (1.7.0): stepping into a dungeon, raid or +-- battleground with buffs still missing gets one clear line, once per +-- entry — the run-start counterpart of the join digest. +function X.InstanceCheck() + if not db then return end + local ctx = X.Context() + local inside = ctx == "dungeon" or ctx == "raid" or ctx == "pvp" + if inside and not X.wasInside and db.enterFlash and InGroup() and A.hasAnyBuff() + and not X.PlayerSuspended() then + local report = X.GroupBuffReport() + local people = #report.people + if people > 0 then + Print(string.format("Entered the %s with buffs missing: %d %s still need buffs (%d buffs needed).", + ctx == "dungeon" and "dungeon" or (ctx == "raid" and "raid" or "battleground"), + people, people == 1 and "person" or "people", report.buffs)) + end + end + X.wasInside = inside +end + +-- One line in chat: how much buffing the group (or the run) still needs. +-- Counts everyone, ignoring the window's role filter. +function X.JoinDigest(why) + if not db or not InGroup() or X.PlayerSuspended() then return end + local report = X.GroupBuffReport() + local people = #report.people + if people == 0 then return end + Print(string.format("%s: %d %s missing buffs (%d buffs needed).", + why == "run" and "Run starting" or "Joined a group", + people, people == 1 and "person is" or "people are", report.buffs)) +end + +-- Roster events: only the step from solo to grouped triggers the join +-- summary, not every roster shuffle afterwards. +function X.OnRoster() + local g = InGroup() + if not g and X.CloseRaidPreparation then X.CloseRaidPreparation() end + if not InRaid() then X.subgroupDuties = nil end + X.PruneBlessingExceptions() + X.PruneAssignmentRoleOverrides() + X.PruneBlockerUndo() + if db then X.SendCover() end -- roster changes refresh a live cover (1.7.0) + if X.inGroupPrev == false and g and db and db.joinDigest and A.hasAnyBuff() then + if C_Timer and C_Timer.After then + C_Timer.After(1.5, function() X.JoinDigest("join") end) + else + X.JoinDigest("join") + end + end + -- Presence (1.6.0): say hello (throttled) so other users know a buddy is + -- here; assignments and plans belong to the group, so they end with it. + if g and db and db.sync and GetTime() - (X.helloAt or 0) > 10 then + X.helloAt = GetTime() + local me = Ignore.UnitNames("player") + if me then X.Broadcast("HELLO;" .. me) end + end + if g then + X.PruneSyncRoster() + else + wipe(X.assign) + wipe(X.blessPlan) + wipe(X.peers) + wipe(X.cover) + wipe(X.handled) + X.upTotal, X.upFull = 0, 0 -- the run is over (1.6.0) + -- Repeat-offender history (1.8.0): the session that just ended + -- counts once for everyone who was seen unbuffed during it. + if db then + for name in pairs(X.offNow) do + db.offenders[name] = (db.offenders[name] or 0) + 1 + end + local orows = {} + for nm, c in pairs(db.offenders) do orows[#orows + 1] = { nm = nm, c = c } end + if #orows > 50 then -- keep the worst 50 only + table_sort(orows, function(a, b) return a.c > b.c end) + for i = 51, #orows do db.offenders[orows[i].nm] = nil end + end + end + wipe(X.offNow) + end + X.inGroupPrev = g +end diff --git a/BuffRadar/Wizard.lua b/BuffRadar/Wizard.lua new file mode 100644 index 0000000..bedb0e7 --- /dev/null +++ b/BuffRadar/Wizard.lua @@ -0,0 +1,671 @@ +-- BuffRadar - Wizard: the first-run setup wizard (1.9.0) and the +-- tools around it that only the slash commands, settings and timers call: +-- saved themes, the alert flash, range and fall checks, /br why and the +-- Nearby Player explanations, history / stats / Discord text and the +-- export dialog. +-- Loaded after BuffRadar.lua through the .toc. This is file-split Slice F +-- (1.15.34): the code below moved verbatim from BuffRadar.lua and reaches +-- that file's locals through X.wizAPI, which BuffRadar.lua fills in +-- before this file loads. The settings table arrives through X.dbSinks; +-- the window comes from X.GetFrame() and the list length from an accessor. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, NS = ... +local X = NS and NS.X +if not X or not X.wizAPI then return end +local A = X.wizAPI + +local db = X.GetDB and X.GetDB() -- nil until ADDON_LOADED; X.dbSinks updates it +X.dbSinks = X.dbSinks or {} +X.dbSinks[#X.dbSinks + 1] = function(value) db = value end + +local L, Print, PlayAlert, QueueRefresh = A.L, A.Print, A.PlayAlert, A.QueueRefresh +local RefreshConfig, OpenConfig = A.RefreshConfig, A.OpenConfig +local ApplyAppearance, ApplyGeometry = A.ApplyAppearance, A.ApplyGeometry +local Ignore, Readable, SafeString = A.Ignore, A.Readable, A.SafeString +local Single, Missing, Valid = A.Single, A.Missing, A.Valid +local InGroup, InRaid = A.InGroup, A.InRaid +local RAID, PARTY, PLATES = A.RAID, A.PARTY, A.PLATES +local myBuffs, entries, rows = A.myBuffs, A.entries, A.rows +local CLASSIC_FEATURES = A.CLASSIC_FEATURES +local MAX_ROWS = A.MAX_ROWS +local pairs, ipairs, type, pcall = pairs, ipairs, type, pcall +local math_min, math_max, math_floor = math.min, math.max, math.floor +local string_format = string.format +local table_sort = table.sort +local wipe = wipe or function(t) for k in pairs(t) do t[k] = nil end return t end +local GetTime, InCombatLockdown = GetTime, InCombatLockdown +local UnitExists, UnitGUID, UnitClass = UnitExists, UnitGUID, UnitClass +local UnitIsPlayer, UnitCanAssist = UnitIsPlayer, UnitCanAssist + +--------------------------------------------------------------------------- +-- Setup wizard (1.9.0): a three-page first-run walkthrough — play +-- style (a shipped preset), window look, and your buff list — so a +-- new user lands on sane settings without facing the full settings +-- window cold. /br wizard runs it again at any time. Defined here: +-- it needs ApplyGeometry / ApplyAppearance, which exist from here on. +--------------------------------------------------------------------------- +function X.WizardPage(n) + local w = X.wizardFrame + if not w then return end + w.page = n + for i = 1, 3 do w.choice[i]:Hide() end + w.back:SetShown(n > 1) + if n == 1 then + w.title:SetText("BuffRadar setup — step 1 of 3") + w.body:SetText("How do you mostly play? Each answer applies a starting preset; every setting can be changed later in Settings.") + local styles = { + { "Mostly solo", "solo" }, { "In a party", "dungeon" }, { "In raids", "raid" }, + } + for i, s in ipairs(styles) do + local b = w.choice[i] + b:SetText(s[1]) + b:SetScript("OnClick", function() + if X.ApplyPreset(s[2]) then + ApplyGeometry() + ApplyAppearance() + X.ApplyRowLayout() + if RefreshConfig then RefreshConfig() end + if QueueRefresh then QueueRefresh() end + Print("Setup wizard: the " .. s[2] .. " preset is applied.") + end + X.WizardPage(2) + end) + b:Show() + end + w.next:Hide() + elseif n == 2 then + w.title:SetText("BuffRadar setup — step 2 of 3") + w.body:SetText("The window's look. Click the theme button to cycle the color schemes; scale, width and more live in Settings > Window.") + local b = w.choice[1] + local function themeLabel() + return "Theme: " .. X.ThemeLabel(true) + end + b:SetText(themeLabel()) + b:SetScript("OnClick", function() + local order = X.ThemeOrder() + local cur = 1 + for i, k in ipairs(order) do if k:lower() == (db.theme or ""):lower() then cur = i end end + X.ApplyTheme(order[cur % #order + 1]) + if RefreshConfig then RefreshConfig() end + b:SetText(themeLabel()) + end) + b:Show() + w.next:SetText("Next") + w.next:Show() + else + w.title:SetText("BuffRadar setup — step 3 of 3") + local names = {} + for _, bf in ipairs(myBuffs) do names[#names + 1] = bf.name end + w.body:SetText(#names > 0 + and ("You can cast: " .. table.concat(names, ", ") + .. ". Toggle any of them in Settings > Buffs, or with /br toggle ." + .. " Press Finish — then just click a name on the list to buff them.") + or "You don't know any buffs BuffRadar handles yet; the list appears once you learn one. Press Finish to close.") + local b = w.choice[1] + b:SetText("Open settings") + b:SetScript("OnClick", function() OpenConfig() end) + b:Show() + w.next:SetText("Finish") + w.next:Show() + end + w.pageText:SetText("Step " .. n .. " of 3") +end + +function X.OpenWizard() + if not db or X.PlayerSuspended() then return end + if InCombatLockdown() then + Print("The setup wizard can't open during combat — try again when it ends.") + return + end + local w = X.wizardFrame + if not w then + w = CreateFrame("Frame", "BuffRadarWizard", UIParent, "BackdropTemplate") + X.wizardFrame = w + w:SetSize(370, 260) + w:SetPoint("CENTER") + w:SetFrameStrata("DIALOG") + if w.SetBackdrop then + w:SetBackdrop({ bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", + edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", + tile = true, tileSize = 32, edgeSize = 24, + insets = { left = 8, right = 8, top = 8, bottom = 8 } }) + end + if w.SetBackdropColor then w:SetBackdropColor(0, 0, 0, 0.9) end + w.title = w:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") + w.title:SetPoint("TOP", 0, -16) + w.body = w:CreateFontString(nil, "OVERLAY", "GameFontHighlight") + w.body:SetPoint("TOPLEFT", 20, -48) + w.body:SetPoint("TOPRIGHT", -20, -48) + w.body:SetJustifyH("LEFT") + w.body:SetWordWrap(true) + w.pageText = w:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + w.pageText:SetPoint("BOTTOM", 0, 16) + w.choice = {} + for i = 1, 3 do + local b = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") + b:SetSize(210, 24) + b:SetPoint("TOP", w, "TOP", 0, -104 - (i - 1) * 32) + w.choice[i] = b + end + w.back = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") + w.back:SetSize(90, 22) + w.back:SetPoint("BOTTOMLEFT", 16, 12) + w.back:SetText("Back") + w.back:SetScript("OnClick", function() X.WizardPage(math_max(1, (w.page or 1) - 1)) end) + w.next = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") + w.next:SetSize(110, 22) + w.next:SetPoint("BOTTOMRIGHT", -16, 12) + w.next:SetScript("OnClick", function() + if (w.page or 1) >= 3 then + db.wizardSeen = true + w:Hide() + Print("Setup done — /br wizard runs it again, /br config opens all settings.") + else + X.WizardPage((w.page or 1) + 1) + end + end) + local close = CreateFrame("Button", nil, w, "UIPanelButtonTemplate") + close:SetSize(24, 24) + close:SetText("X") + close:SetPoint("TOPRIGHT", -10, -10) + close:SetScript("OnClick", function() + db.wizardSeen = true + w:Hide() + end) + end + X.WizardPage(1) + w:Show() +end + +-- Apply a color theme (1.8.0). Defined here because it needs +-- ApplyAppearance, which only exists from this point on. +function X.ApplyTheme(name) + if name and name:lower() == "auto" and not X.SavedTheme(name) then name = X.AUTO_THEME_ID end + local t = X.ThemeDef(name) + if not t then return false end + local id = name:lower() + db.theme = X.THEMES[id] and id or t.label + if id ~= X.AUTO_THEME_ID then db.bgColor = { t.bg[1], t.bg[2], t.bg[3] } end + if not X.ResolveAutoTheme() then + ApplyAppearance() + if RefreshConfig then RefreshConfig() end + end + return true +end + +-- Save the current look (background + the border now in effect) as one +-- of your themes (1.10.0). Returns the name, or nil plus a reason. +function X.SaveTheme(name) + name = (name or ""):match("^%s*(.-)%s*$") + if X.THEMES[name:lower()] or name:lower() == "custom" then return nil, "taken" end + if not name:match("^[%w%-]+$") or #name > 24 then return nil, "name" end + local c, b = X.ThemeBackground(), X.ThemeBorder() + local entry = { name = name, + bg = { c[1], c[2], c[3] }, + border = { b[1], b[2], b[3] } } + db.customThemes = db.customThemes or {} + for i, t in ipairs(db.customThemes) do + if t.name:lower() == name:lower() then + db.customThemes[i] = entry + return name + end + end + if #db.customThemes >= 4 then return nil, "full" end + db.customThemes[#db.customThemes + 1] = entry + return name +end + +function X.DeleteTheme(name) + if not db or not name then return false end + for i, t in ipairs(db.customThemes or {}) do + if t.name:lower() == name:lower() then + table.remove(db.customThemes, i) + if not X.THEMES[name:lower()] and (db.theme or ""):lower() == name:lower() then + db.theme = "custom" + ApplyAppearance() + if RefreshConfig then RefreshConfig() end + end + return true + end + end + return false +end + +-- One border pulse; restores the normal border shortly after. Assigned +-- here because frame / ApplyAppearance only exist from this point on. +function X.Flash() + local frame = X.GetFrame() + if not frame or not frame.SetBackdropBorderColor or InCombatLockdown() or db.reduceMotion then return end + frame:SetBackdropBorderColor(1, 0.35, 0.35, 1) + if C_Timer and C_Timer.After then + C_Timer.After(0.7, function() if frame then ApplyAppearance() end end) + else + X.flashPending = true -- no timer API: Refresh() restores it next pass + end +end + +-- Watched-buff drop alert (1.5.0): your single-target buff (Earth Shield) +-- was on someone at the last scan and is gone now, while that player is +-- still around -- say so instead of silently re-offering it. The alert +-- fires once per drop: prevHolder only refills when the buff is seen on +-- someone again. A holder change (you recast it on someone else) is a +-- move, not a drop. Runs after each CollectEntries in Refresh. +-- Range watch (1.12.0): a player who needed a buff and was out of range +-- last scan, and is in range now, still needs it -> one chat line + the +-- alert sound. The game does not allow casting automatically, so this +-- only tells you; the click is yours. +function X.CheckRange() + if not db.rangeWatch then + wipe(X.farPrev); wipe(X.farNow); return + end + for i = 1, A.nEntries() do + local e = entries[i] + local g = e.guid + if g and X.farPrev[g] and not e.outOfRange and not e.pet then + local name = X.farPrev[g] == true and e.name or X.farPrev[g] + Print(string_format("%s is in range now and still needs a buff.", name)) + PlayAlert("new") + end + end + X.farPrev, X.farNow = X.farNow, X.farPrev + wipe(X.farNow) +end + +-- Buff-fell-off alert (1.15.0, #33): Consider's expiry tracking spots a +-- watched group buff that was up when a fight started and is gone at the +-- first scan after it; this plays the "fall" alert kind once for that +-- scan, telling a mid-fight drop apart from a fresh arrival (the +-- new-name alert cannot). Detection lands after combat because the list +-- is frozen during it -- which is also when rebuffing becomes possible. +function X.CheckFalls() + if X.fallPending then + X.fallPending = nil + if db and db.fallSound then PlayAlert("fall") end + end +end + +-- /br why (1.15.0): explain, in plain words, why a player is or +-- is not on the list. Reuse cast eligibility rules without updating coverage tallies. +function X.Why(name) + if not db then return end + local want = (name or ""):lower() + if want == "" then return end + local selected, best, ambiguous + local function try(u, grp) + if X.ReadUnitBool(UnitExists, u) ~= true or X.ReadUnitBool(UnitIsPlayer, u) ~= true + or X.ReadUnitBool(UnitCanAssist, "player", u) == false and u ~= "player" then return end + local f, s = Ignore.UnitNames(u) + if not f then return end + local fl, sl = f:lower(), (s or ""):lower() + local score = fl == want and 3 or sl == want and 2 or fl:find(want, 1, true) and 1 or 0 + if score == 0 or best and score < best then return end + local ok, raw = pcall(UnitGUID, u) + local guid = ok and SafeString(raw) or nil + if not best or score > best then + selected, best, ambiguous = { unit = u, full = f, short = s, group = grp, guid = guid }, score, false + elseif (guid and selected.guid and guid ~= selected.guid) or selected.full:lower() ~= fl then + ambiguous = true + end + end + local list = InRaid() and RAID or PARTY + try("player", true) + for i = 1, #list do try(list[i], true) end + try("target", false) + try("mouseover", false) + for i = 1, #PLATES do try(PLATES[i], false) end + if ambiguous then + Print("Why: more than one player matches. Use their full name, including realm.") + return + end + if not selected then + Print("Why: no readable player matches '" .. name .. "'. Target or mouse over them, or enable friendly nameplates with /br plates.") + return + end + X.ExplainPlayer(selected, Print) +end + +function X.ExplainPlayer(selected, emit, showUnknown) + local unit, full, short, isGroup, guid = selected.unit, selected.full, selected.short, selected.group, selected.guid + local disp = short or full + local function printRule(detail) + if CLASSIC_FEATURES then + local rule = detail.rule or L["Rule unavailable"] + if detail.blessing then rule = rule .. " · " .. detail.blessing end + emit(string_format(L["Applied rule for %s: %s."], disp, rule)) + end + end + local function printInactiveRule() + local ok, _, class = pcall(UnitClass, unit) + class = ok and SafeString(class) or nil + local assignment, source, role, _, manual = X.AssignmentForUnit(class, unit, isGroup, X.IsSelf(unit)) + printRule({ rule = X.AssignmentRuleText(class, role, source, assignment, isGroup, manual) }) + end + if Ignore.Has(full, short) then + printInactiveRule() + emit(disp .. " is on your ignore list, so they are never listed. /br unignore " .. disp .. " undoes it.") + return + end + if X.SessionHas(full, short) then + printInactiveRule() + emit(disp .. " is ignored for this session only (Shift+right-click on a row). It clears when you reload.") + return + end + local valid, isSelf = Valid(unit) + if not valid then + printInactiveRule() + emit(disp .. " can't be buffed right now (dead, offline, in combat, charmed or in another phase), so they are not listed.") + return + end + local allMiss, miss = {}, {} + local detail = { cooldown = {}, cooldowns = {} } + local n, unknown, checked = Missing(unit, allMiss, isGroup, isSelf, "why", detail) + printRule(detail) + -- The fallback aura index is rebuilt on demand after a diagnostic scan. + X.scanUnit = nil + if n == 0 then + if unknown then + emit(disp .. ": buff information is unavailable.") + elseif #detail.cooldown > 0 then + emit(disp .. " needs " .. table.concat(detail.cooldown, ", ") .. ", but those spells are on cooldown.") + elseif not checked then + emit(disp .. (detail.assignment and ": no enabled buffs apply under the selected class or role assignment." + or ": no enabled buffs apply to this player.")) + else + emit(disp .. " already has every buff you can give them.") + end + return + end + local inRange, _, rangeUnknown, rankLimited = X.FilterInRange(unit, allMiss, miss, isSelf, true) + if showUnknown then + if unknown then emit(L["Some buff information is unavailable."]) end + if rangeUnknown and (inRange > 0 or rankLimited) then emit(L["Range could not be confirmed; the list may be incomplete."]) end + end + if inRange == 0 then + emit(disp .. " needs " .. table.concat(allMiss, ", ") .. (rankLimited + and ", but no learned rank fits their level, or another needed spell is out of range." + or rangeUnknown + and ", but the game could not confirm cast range. Move closer and check again." + or " but none are in cast range; move closer before buffing.")) + return + end + if guid and X.failedTargets[guid] and X.failedTargets[guid] > GetTime() then + local failure = X.lastTargetCastProblem + emit(disp .. " was temporarily skipped after a failed cast." + .. (failure and failure.guid == guid and " " .. failure.message or "") .. " Try again in a few seconds.") + return + end + for i = 1, A.nEntries() do + if guid and entries[i].guid == guid then + local shown = false + for r = 1, MAX_ROWS do + if rows[r] and rows[r].entry == entries[i] then shown = true break end + end + if shown then + emit(disp .. " is on the list (row " .. i .. "), missing: " .. table.concat(miss, ", ") .. ".") + elseif db.viewMode == "people" and X.rowView == entries + and (i <= (X.rowOffset or 0) or i > (X.rowOffset or 0) + MAX_ROWS) then + emit(disp .. " is outside the visible rows. " .. L["Use the mouse wheel to see more rows."]) + else + emit(disp .. " needs " .. table.concat(miss, ", ") .. " and is collected, but the row is not shown -- the role filter under the title is the usual reason.") + end + return + end + end + if X.search and X.search ~= "" and not (disp:lower():find(X.search, 1, true)) then + emit(disp .. " needs " .. table.concat(miss, ", ") .. ", but the name finder ('" .. X.search .. "') hides them. Clear the finder text to see everyone.") + return + end + if not guid then + emit(disp .. ": the game did not expose a readable player identity. Target them and check again.") + return + end + emit(disp .. " is not on the list right now; they need: " .. table.concat(miss, ", ") .. ".") +end + +function X.ExplainCurrentTarget(emit) + local exists = X.ReadUnitBool(UnitExists, "target") + if exists ~= true then + emit(L[exists == false and "Select a friendly player to check." or "Current target information is unavailable."]) + return + end + local player = X.ReadUnitBool(UnitIsPlayer, "target") + local self = X.IsSelf("target") + local assist = self or X.ReadUnitBool(UnitCanAssist, "player", "target") + if player == false or assist == false then + emit(L["Select a friendly player to check."]) + return + end + local function readGUID(unit) + local ok, guid = pcall(UnitGUID, unit) + if ok and type(guid) == "string" and Readable(guid) and guid ~= "" then return guid end + end + local full, short = Ignore.UnitNames("target") + local guid = readGUID("target") + if player == nil or assist == nil or not full or not guid then + emit(L["Current target information is unavailable."]) + return + end + local unit = "target" + if self then + unit = "player" + elseif InGroup() then + local roster = InRaid() and RAID or PARTY + for _, member in ipairs(roster) do + if readGUID(member) == guid then unit = member; break end + end + end + X.ExplainPlayer({ unit = unit, full = full, short = short, group = unit ~= "target", guid = guid }, emit, true) +end + +function X.EnableFriendlyNameplates(emit) + if InCombatLockdown() then emit(L["Can't change nameplate settings during combat."]); return end + if X.PlayerSuspended() then emit(L["Nameplate settings are unavailable while dead."]); return end + local enabled, name = X.FriendlyPlatesOn() + local setter = (C_CVar and C_CVar.SetCVar) or SetCVar + if not name or not setter then + emit(L["Couldn't find a supported friendly nameplate setting on this client."]) + return + end + if not enabled then pcall(setter, name, "1") end + if X.FriendlyPlatesOn() ~= true then + emit(L["Couldn't turn on friendly nameplates. Check the game's nameplate settings."]) + return + end + if X.ReadBooleanCVar("nameplateShowAll") == false then + pcall(setter, "nameplateShowAll", "1") + if X.ReadBooleanCVar("nameplateShowAll") ~= true then + emit(L["Friendly nameplates are enabled. The game may still hide them outside combat."]) + return + end + end + emit(L["Friendly nameplates turned on, so nearby non-group players can be listed."]) +end + +function X.CheckDrops() + local lookup = C_UnitAuras and C_UnitAuras.GetAuraDataBySpellName + local uncertain = {} + if db.watchDrop then + for key, prev in pairs(X.prevHolder) do + if not Single.holder[key] and prev.unit and X.UnitPresent(prev.unit) and lookup then + local aura, definitive = X.QueryNamedAura(lookup, prev.unit, Single.spell[key] or key, "HELPFUL|PLAYER") + if definitive and not aura then + Print(string_format("%s dropped off %s.", Single.spell[key] or key, prev.name)) + PlayAlert("drop") + X.Flash() + else + uncertain[key] = prev + end + end + end + end + X.prevHolder = uncertain + for key, unit in pairs(Single.holder) do + X.prevHolder[key] = { unit = unit, name = X.UnitNameOf(unit) or unit } + end +end + +-- Copyable settings string window for /br export and /br import. +-- The recent-casts list for /br history, newest first (1.7.0). +function X.HistoryText() + local h = db.history or {} + if #h == 0 then + return "No casts recorded yet. Buffs you cast through BuffRadar will be listed here." + end + local lines = {} + for i = #h, 1, -1 do + local e = h[i] + local when = "" + if e.t and e.t > 0 and date then + local okd, s = pcall(date, "%H:%M", e.t) + if okd and s then when = s .. " " end + end + lines[#lines + 1] = when .. (e.spell or "?") .. " -> " .. (e.who or "?") + end + return table.concat(lines, "\n") +end + +-- Stats export (1.8.0): the cast statistics as copyable text. +function X.StatsText() + local lines = { "BuffRadar cast statistics" } + lines[#lines + 1] = string_format("Casts: %d this session, %d all-time", + X.sessionCasts, db.castsTotal or 0) + if X.upTotal > 0 then + lines[#lines + 1] = string_format("Coverage uptime this run: %d%% (%d of %d scans fully buffed)", + math_floor(100 * X.upFull / X.upTotal + 0.5), X.upFull, X.upTotal) + end + local srows = {} + for k, n in pairs(db.stats or {}) do srows[#srows + 1] = { k = k, n = n } end + table.sort(srows, function(a, b) return a.n > b.n end) + if #srows > 0 then + lines[#lines + 1] = "By spell:" + for i = 1, math_min(10, #srows) do + lines[#lines + 1] = string_format(" %s: %d", srows[i].k, srows[i].n) + end + end + return table.concat(lines, "\n") +end + +-- Per-buff summary (1.13.0): how many casts of each buff the group +-- still needs, biggest first. Counts everyone, ignoring the role filter. +function X.SummaryLines() + local report = X.GroupBuffReport() + local per = {} + for _, person in ipairs(report.people) do + for _, name in ipairs(person.buffs) do + per[name] = (per[name] or 0) + 1 + end + end + local counts = {} + for n, c in pairs(per) do counts[#counts + 1] = { n = n, c = c } end + table_sort(counts, function(a, b) if a.c ~= b.c then return a.c > b.c end return a.n < b.n end) + return counts, #report.people, X.GroupCoverageNote(report) +end + +-- Discord summary (1.8.0): the group's buff state as a small markdown +-- block, ready to paste into a Discord message. +function X.DiscordText() + local report = X.GroupBuffReport() + local note = X.GroupCoverageNote(report) + local lines = { "**BuffRadar — group buff check**" } + if #report.people == 0 and not note then + lines[#lines + 1] = "All checked buffs are present." + elseif #report.people > 0 then + lines[#lines + 1] = "Still needs buffs:" + for _, person in ipairs(report.people) do + lines[#lines + 1] = "- " .. person.name .. " — " .. table.concat(person.buffs, ", ") + end + end + if note then lines[#lines + 1] = note end + if X.upTotal >= 10 then + lines[#lines + 1] = string_format("Coverage uptime this run: %d%%", + math_floor(100 * X.upFull / X.upTotal + 0.5)) + end + return table.concat(lines, "\n") +end + +function X.ShowExport(text, forImport, titleText, mode) + if X.PlayerSuspended() then return end + if InCombatLockdown() then Print("Can't open that during combat."); return end + local f = X.exportFrame + if not f then + f = CreateFrame("Frame", "BuffRadarExportFrame", UIParent, + BackdropTemplateMixin and "BackdropTemplate" or nil) + X.exportFrame = f + f:SetSize(440, 150) + f:SetPoint("CENTER") + f:SetFrameStrata("DIALOG") + if f.SetBackdrop then + f:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 16, edgeSize = 12, + insets = { left = 3, right = 3, top = 3, bottom = 3 }, + }) + f:SetBackdropColor(0.04, 0.05, 0.09, 0.97) + f:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) + end + f:EnableMouse(true) + f:SetMovable(true) + f:RegisterForDrag("LeftButton") + f:SetScript("OnDragStart", function(self) self:StartMoving() end) + f:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end) + f.title = f:CreateFontString(nil, "OVERLAY", "GameFontNormal") + f.title:SetPoint("TOPLEFT", 12, -10) + local close = CreateFrame("Button", nil, f, "UIPanelCloseButton") + close:SetSize(22, 22) + close:SetPoint("TOPRIGHT", 0, 0) + close:SetScript("OnClick", function() f:Hide() end) + local eb = CreateFrame("EditBox", nil, f) + eb:SetPoint("TOPLEFT", 12, -34) + eb:SetPoint("BOTTOMRIGHT", -12, 36) + eb:SetMultiLine(true) + if eb.SetAutoFocus then eb:SetAutoFocus(false) end + if eb.SetFontObject and ChatFontNormal then eb:SetFontObject(ChatFontNormal) end + eb:SetScript("OnEscapePressed", function(self) if self.ClearFocus then self:ClearFocus() end end) + f.editBox = eb + local acc = CreateFrame("Button", nil, f, "UIPanelButtonTemplate") + acc:SetSize(110, 22) + acc:SetPoint("BOTTOMRIGHT", -12, 8) + acc:SetText("Import") + acc:SetScript("OnClick", function() + local ok, msg + if f.importMode == "plan" then + ok, msg = X.PlanImport(f.editBox:GetText()) + elseif f.importMode == "profile" then + ok, msg = X.ProfileImport(f.editBox:GetText()) + elseif f.importMode == "ignore" then + ok, msg = X.IgnoreImport(f.editBox:GetText()) + else + local txt = f.editBox:GetText() + if X.PrintDiff then X.PrintDiff(txt, "This import") end -- what it changes, before it does (1.12.0) + ok, msg = X.Import(txt) + end + Print(msg) + if ok then + f:Hide() + ApplyGeometry() + ApplyAppearance() + if RefreshConfig then RefreshConfig() end + if QueueRefresh then QueueRefresh() end + end + end) + f.accept = acc + if UISpecialFrames then UISpecialFrames[#UISpecialFrames + 1] = "BuffRadarExportFrame" end + f:Hide() + end + f.title:SetText(titleText or (forImport and "BuffRadar -- paste a settings string, then Import" + or "BuffRadar -- your settings string (select all, copy)")) + f.importMode = mode or "settings" -- what the Import button applies (1.8.0) + f.editBox:SetText(text or "") + f.accept:SetShown(forImport and true or false) + f:Show() + if f.editBox.SetFocus then f.editBox:SetFocus() end + if f.editBox.HighlightText then f.editBox:HighlightText() end +end + +-- Your own "Name-Realm", for per-character settings. +function X.CharKey() + local full = Ignore.UnitNames("player") + return full +end diff --git a/QUALITY.md b/QUALITY.md index 6f367c4..747b82f 100644 --- a/QUALITY.md +++ b/QUALITY.md @@ -70,7 +70,7 @@ are named below as waivers with owners and follow-ups, not hidden. | Robustness (11) | 4 | Pass | SavedVariables migration chain v2→v20 smoke-tested, including corrupt-save replacement and repair of corrupt custom-spell / auto-profile entries; a strict sanitizer rebuilds settings on load; handlers are pcall-wrapped so one bad event can't kill the addon. | | Feature completeness (9) | 4 | Pass | Core purpose complete. The approved 50-item program is **complete** with **nothing parked**: 44 shipped by 1.9.0, three duplicates replaced in-batch (#23, #10, #15), and the three parked items built later (#8 and #19 in 1.14.0, #33 in 1.15.0). Three further suggestion lists are done except one platform limit recorded in `docs/SUGGESTIONS.md` (#13: the game does not let addons auto-cast, so out-of-range players get a notice instead). Not 5: that limit. | | Performance (8) | 4 | Pass (waiver closed 2026-11-16) | Budget defined 2026-11-16 (`docs/DECISIONS.md`) and enforced by the trial run on every push: a worst-case scan (every player missing every buff) reads ≤8 auras per player, grows linearly from 20 to 40 players, and averages <5 ms in the fake client (measured: ~5.75 reads per player, ~0.7 ms for 40 players). Scans are event-driven, coalesced to one per 0.1 s and ticked every 0.4 s; rows are pooled. Not 5: the in-game target (`/br perf` average ≤2 ms, worst ≤8 ms in a 40-player raid) has no field numbers yet. | -| Maintainability (7) | 3 | **Waiver** (minor) | The source is split across seven files (Data, BuffRadar, Config, Slash, Extras, Recaps, Profiles; 17.2k lines), but `BuffRadar.lua` is ~9,700 lines again, above the prompt's file-length target. Lua 5.1 limits are tool-enforced on every file: main chunk 182/200 locals, `HandleSlash` 58/60 upvalues, `Refresh` 53/60. Follow-up: move the next feature-sized section out of `BuffRadar.lua` before either ceiling is hit. | +| Maintainability (7) | 3 | **Waiver** (minor) | The source is split across nine files (Data, BuffRadar, Coordination, Wizard, Config, Slash, Extras, Recaps, Profiles; 17.3k lines). Slices E and F (2026-11-16) moved coordination and the wizard/diagnostics tools out, so `BuffRadar.lua` dropped from ~9,700 to ~8,000 lines, but it is still above the prompt's file-length target. Lua 5.1 limits are tool-enforced on every file: main chunk 176/200 locals, `HandleSlash` 58/60 upvalues, `Refresh` 50/60. Follow-up: the toggle strip, cast buttons and `BuildUI` (Slice G) are the next feature-sized section; they touch the secure cast path, so they need their own field test. | | Modularity (6) | 3 | Pass | Seven load-ordered files; sections stay one-way (data → scan → render → UI → commands), shared state lives in one `X` registry table, and the split files reach main state only through bridge tables (`X.cfgAPI`, `X.slashAPI`). Every capability is a named slash operation before it is a settings control. Not 4: the bridge tables are a wide coupling surface, checked by review only. | | UX & accessibility (6) | 4 | Pass (waiver closed 2026-11-16) | The UI is complete in code and smoke, and SEAN's in-game field test passed for every release through 1.15.31 on Forever (reported 2026-11-16). Not 5: no accessibility audit beyond the tag-symbol, reduced-motion and text-scale options. | | Scalability (5) | 3 | Pass | Host caps group size (40); scan cost is linear in roster size and throttled; the row pool is capped at 15 with overflow counted on the coverage line. 10x/100x testing is not applicable to a host-capped addon; the cap behaviour is smoke-tested. | diff --git a/README.md b/README.md index 300e6cc..a9aa581 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,8 @@ BuffRadar has targeted Forever since 1.8.0. The last Retail release was ## Source and Contributions -- [Runtime](BuffRadar/BuffRadar.lua), [settings](BuffRadar/Config.lua), +- [Runtime](BuffRadar/BuffRadar.lua), [coordination](BuffRadar/Coordination.lua), + [setup wizard and diagnostics](BuffRadar/Wizard.lua), [settings](BuffRadar/Config.lua), [slash commands](BuffRadar/Slash.lua), [profiles](BuffRadar/Profiles.lua), and [translations](BuffRadar/Locales). - [Report a bug or request a feature](https://github.com/SeanShaffer88/BuffRadar/issues/new/choose). diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index f6ca099..184a775 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -296,6 +296,35 @@ split, then Briefs 2, 3, 4 — nothing else built; file-split Slices B 3 -> 4); maintainability stays 3 because `BuffRadar.lua` has grown back to ~9,700 lines. +## 2026-11-16 — File split Slices E and F (SEAN: "E + F") + +- Slice E: cast sync, caster coordination, chat buff requests, per-buff + context checks and the join digest moved verbatim into + `Coordination.lua` (about 1,140 lines). Slice F: the setup wizard, + saved themes, alert flash, range and fall checks, `/br why` and the + Nearby Player explanations, history / stats / Discord text and the + export dialog moved into `Wizard.lua` (about 630 lines). Both load + straight after `BuffRadar.lua`. +- Bridges follow Slices B–D: `X.coordAPI` and `X.wizAPI` carry stable + values; the list length and "any buff known" flag the main file + reassigns go through accessors; the window comes from `X.GetFrame()`. + The settings table reaches both files through `X.dbSinks`, which the + main file calls (`X.ShareDB`) the moment `db` is set. +- The only non-verbatim edits: those accessor reads, one + `local frame = X.GetFrame()` in `X.Flash`, and the sound throttle + `lastSoundAt` moving from a main-file local to `X.lastSoundAt` because + both files write it. `X.farNow`/`X.farPrev` stay initialised in the + main file, since the scan writes them. +- Kept in the main file on purpose: `X.ApplyClickThrough` and + `X.ApplyRowLayout` (window layout on secure rows), and Slice G (toggle + strip, next/group buttons, `BuildUI`), which needs its own field pass. +- `BuffRadar.lua`: 9,741 -> 8,017 lines; main chunk 182 -> 176 locals; + `Refresh` 51 -> 50 upvalues. The trial run gained two load steps and a + step proving both files read the live settings table (mutation-checked: + breaking the hand-off fails it). +- Unverified in game until the next field pass. No settings or saved + data change, so `dbVersion` stays 20. + ## 2026-11-16 — Field test passed for 1.15.32 and 1.15.33 (SEAN) - SEAN reported "all steps passed" for the 1.15.33 and 1.15.32 checklist diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index 67c50b2..28fe22f 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -2,6 +2,22 @@ Run this against the exact candidate ZIP after CI passes. Record the version, client build, tester, and pass/fail for each check. Do not mark a build field-tested until the applicable checks pass. +## Next release: file split Slices E and F + +Code moved into `Coordination.lua` and `Wizard.lua`; nothing should look or +behave differently. Check that both files load (no Lua error at login, and +`/br selftest` runs) and then: + +- **Coordination.lua:** with a second BuffRadar user in the group and cast + sync on, buff a player and check that their row clears on the other + client. Whisper yourself "buff" from a listed player and check that the row + is marked and the alert sound plays once. Join a group with buffs missing + and check the join digest line. Open Caster Coordination and request reports. +- **Wizard.lua:** run `/br wizard` through all three pages. Save, apply and + delete a theme. Run `/br why ` on a nearby player and open the + Nearby Player panel with **?**. Check `/br history`, `/br stats` and an + export dialog. With alerts on, check that the window border flashes. + ## 1.15.33 Input hardening Result: **passed** — SEAN, reported 2026-11-16 (client build not recorded). diff --git a/docs/RISK_MATRIX.md b/docs/RISK_MATRIX.md index a1ac5d5..81de695 100644 --- a/docs/RISK_MATRIX.md +++ b/docs/RISK_MATRIX.md @@ -98,7 +98,7 @@ passes, and the last one covered releases through 1.15.33. | F1 | Runtime error inside a scan | List stops updating | `SafeRefresh` wraps the scan in `pcall`; the error is printed once, not per frame | robustness fuzz | Covered | | F2 | Cast fails (line of sight, range, invalid target) | Queue stuck on one player | Target-failure messages skip that player for 30 s; other errors stay pending | range and invalid-target failures skip the current player; empty-state steps | Covered | | F3 | Roster changes between render and key press | Buffs the wrong person | Slot occupant check clears a stale binding | 1.15.31 checklist; cast-next steps | Covered | -| F4 | Lua 5.1 local or upvalue ceilings | Addon fails to load after an edit | `tools/lualimits.py` in the gate | gate | Covered (main chunk 182/200, `HandleSlash` 58/60 upvalues) | +| F4 | Lua 5.1 local or upvalue ceilings | Addon fails to load after an edit | `tools/lualimits.py` in the gate | gate | Covered (main chunk 176/200, `HandleSlash` 58/60 upvalues) | | F5 | Locale string with a mismatched placeholder | `string.format` error | `localecheck` checks placeholder parity | gate | Covered | | F6 | Package missing a file or in the wrong load order | Addon broken on install | `checkpackage.py` loads the ZIP in TOC order; release assets hash-verified after upload | gate; release workflow | Covered | | F7 | Chat send refused (throttle or channel) | Silent report failure | Send result checked; 255-byte cap | group reports respect ignored players and chat refusal | Covered | diff --git a/editions/forever/BuffRadar.toc b/editions/forever/BuffRadar.toc index 0804b83..de4994e 100644 --- a/editions/forever/BuffRadar.toc +++ b/editions/forever/BuffRadar.toc @@ -15,6 +15,8 @@ Locales\ruRU.lua Locales\zhCN.lua Data.lua BuffRadar.lua +Coordination.lua +Wizard.lua Config.lua Slash.lua Extras.lua diff --git a/tools/check.ps1 b/tools/check.ps1 index cd0cf4e..0297927 100644 --- a/tools/check.ps1 +++ b/tools/check.ps1 @@ -60,7 +60,7 @@ function Section($name) { Write-Host "`n== $name" } # 1. luacheck: accidental globals, unused or shadowed variables, unreachable code Section 'luacheck' Push-Location $project -try { & $luacheck 'BuffRadar\Data.lua' 'BuffRadar\BuffRadar.lua' 'BuffRadar\Config.lua' 'BuffRadar\Slash.lua' 'BuffRadar\Extras.lua' 'BuffRadar\Recaps.lua' 'BuffRadar\Profiles.lua' 'BuffRadar\Locales' --no-color --codes; if ($LASTEXITCODE -ne 0) { $failed += 'luacheck' } } +try { & $luacheck 'BuffRadar\Data.lua' 'BuffRadar\BuffRadar.lua' 'BuffRadar\Coordination.lua' 'BuffRadar\Wizard.lua' 'BuffRadar\Config.lua' 'BuffRadar\Slash.lua' 'BuffRadar\Extras.lua' 'BuffRadar\Recaps.lua' 'BuffRadar\Profiles.lua' 'BuffRadar\Locales' --no-color --codes; if ($LASTEXITCODE -ne 0) { $failed += 'luacheck' } } finally { Pop-Location } # 2. Compile with real Lua 5.1 (the language WoW runs) diff --git a/tools/gate.sh b/tools/gate.sh index 531b6ad..4790403 100644 --- a/tools/gate.sh +++ b/tools/gate.sh @@ -12,7 +12,7 @@ for candidate in python3 python; do if "$candidate" -c "import sys" >/dev/null 2>&1; then PY=$candidate; break; fi done [ -n "$PY" ] || { echo "No working python3 or python found."; exit 1; } -LUA="BuffRadar/Data.lua BuffRadar/BuffRadar.lua BuffRadar/Config.lua BuffRadar/Slash.lua BuffRadar/Extras.lua BuffRadar/Recaps.lua BuffRadar/Profiles.lua" +LUA="BuffRadar/Data.lua BuffRadar/BuffRadar.lua BuffRadar/Coordination.lua BuffRadar/Wizard.lua BuffRadar/Config.lua BuffRadar/Slash.lua BuffRadar/Extras.lua BuffRadar/Recaps.lua BuffRadar/Profiles.lua" LOC="$(ls BuffRadar/Locales/*.lua)" echo "== luacheck51"; "$PY" -I tools/luacheck51.py $LUA $LOC echo "== lualimits"; for f in $LUA; do "$PY" -I tools/lualimits.py "$f"; done diff --git a/tools/smoke51.py b/tools/smoke51.py index 9271fd2..15e2054 100644 --- a/tools/smoke51.py +++ b/tools/smoke51.py @@ -12,7 +12,7 @@ lua = lua51.LuaRuntime(unpack_returned_tuples=True) lua.execute(open(stub_path, encoding="utf-8").read()) -harness = lua.eval(r"""function(addonSrc, withTimer, noTemplates, forever, german, localeSrc, extrasSrc, dataSrc, configSrc, slashSrc, recapsSrc, profilesSrc) +harness = lua.eval(r"""function(addonSrc, withTimer, noTemplates, forever, german, localeSrc, extrasSrc, dataSrc, configSrc, slashSrc, recapsSrc, profilesSrc, coordSrc, wizardSrc) local chat = {} local env = WOWSTUB(chat, withTimer, noTemplates, forever, german) local unitIsUnit = env.UnitIsUnit @@ -91,6 +91,23 @@ end) end step("load file (main chunk)", function() chunk("BuffRadar", NS) end) +-- File split Slices E and F (1.15.34) load straight after the main file (.toc order). +if coordSrc then + step("load Coordination.lua", function() + local och = assert(loadstring(coordSrc, "=Coordination.lua")) + setfenv(och, env) + och("BuffRadar", NS) + assert(NS.X.InitSync and NS.X.OnAddonMsg and NS.X.OnRoster, "Coordination.lua did not publish its entry points") + end) +end +if wizardSrc then + step("load Wizard.lua", function() + local wch = assert(loadstring(wizardSrc, "=Wizard.lua")) + setfenv(wch, env) + wch("BuffRadar", NS) + assert(NS.X.WizardPage, "Wizard.lua did not publish its entry points") + end) +end if configSrc then step("load Config.lua", function() local cch = assert(loadstring(configSrc, "=Config.lua")) @@ -8074,6 +8091,21 @@ for _, fs in ipairs(env.__fontstrings) do if fs.text == "Kampf" then found = true end end assert(found, "combat label not translated ('Kampf' not found)") end) +step("split files share the live settings (Slices E and F)", function() + local X, db = NS.X, NS.X.GetDB() + assert(db, "settings not loaded") + local savedCtx, savedHistory, savedRaid = db.buffContext, db.history, env.IsInRaid + db.buffContext = { SPLITTEST = "raid" } + env.IsInRaid = function() return false end + local outside = X.ContextOK("SPLITTEST") + db.buffContext, env.IsInRaid = savedCtx, savedRaid + assert(outside == false, "Coordination.lua does not read the live settings table") + db.history = { { t = 0, who = "Splitcheck", spell = "Test" } } + local text = X.HistoryText() + db.history = savedHistory + assert(type(text) == "string" and text:find("Splitcheck", 1, true), "Wizard.lua does not read the live settings table") + assert(X.coordAPI.nEntries() == X.wizAPI.nEntries(), "list-length accessors disagree") +end) step("right-click a row (ignore path)", function() local row = env.BuffRadarRow1 row.entry = { name = "Testshaman", fullName = "Testshaman-TestRealm", missing = { "Skyfury" }, unit = "player" } @@ -8098,6 +8130,10 @@ rc_src = open(rc_path, encoding="utf-8").read() if os.path.exists(rc_path) else None pf_path = os.path.join(os.path.dirname(os.path.abspath(addon_path)), "Profiles.lua") pf_src = open(pf_path, encoding="utf-8").read() if os.path.exists(pf_path) else None +co_path = os.path.join(os.path.dirname(os.path.abspath(addon_path)), "Coordination.lua") +co_src = open(co_path, encoding="utf-8").read() if os.path.exists(co_path) else None +wz_path = os.path.join(os.path.dirname(os.path.abspath(addon_path)), "Wizard.lua") +wz_src = open(wz_path, encoding="utf-8").read() if os.path.exists(wz_path) else None sl_src = open(sl_path, encoding="utf-8").read() if os.path.exists(sl_path) else None setups = [ ("Retail: modern client (C_Timer, UI templates)", True, False, False, False), @@ -8110,7 +8146,7 @@ setups.append(("Retail: German client (Locales/deDE.lua)", True, False, False, True)) failed = False for label, with_timer, no_templates, forever, german in setups: - results, chat = harness(src, with_timer, no_templates, forever, german, de_src if german else None, ex_src, da_src, cf_src, sl_src, rc_src, pf_src) + results, chat = harness(src, with_timer, no_templates, forever, german, de_src if german else None, ex_src, da_src, cf_src, sl_src, rc_src, pf_src, co_src, wz_src) bad = 0 for i in range(1, len(results) + 1): name, status = results[i][1], results[i][2] From 206df7cef61833a33922458d1aaac2eb917ad82a Mon Sep 17 00:00:00 2001 From: Sean Shaffer Date: Mon, 16 Nov 2026 06:15:23 -0600 Subject: [PATCH 3/5] Split the window builder and cast buttons into Window.lua File split Slice G: BuildUI, the toggle strip, filter chips, idle fade, Cast Next / group buttons with their secure bindings and the scale / edge drag helpers move to Window.lua. BuildUI hands the window handles back to the main file through X.winAPI.setUI before any main-file code reads them; a new trial step proves the hand-back. BuffRadar.lua: 8,017 -> 7,215 lines. Releases held: no version bump. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 4 +- BuffRadar/BuffRadar.lua | 884 ++---------------------------- BuffRadar/BuffRadar.toc | 1 + BuffRadar/Window.lua | 884 ++++++++++++++++++++++++++++++ QUALITY.md | 2 +- README.md | 2 +- docs/DECISIONS.md | 27 + docs/FOREVER_RELEASE_CHECKLIST.md | 12 +- docs/RISK_MATRIX.md | 2 +- editions/forever/BuffRadar.toc | 1 + tools/check.ps1 | 2 +- tools/gate.sh | 2 +- tools/smoke51.py | 27 +- 13 files changed, 995 insertions(+), 855 deletions(-) create mode 100644 BuffRadar/Window.lua diff --git a/AGENTS.md b/AGENTS.md index b0a4220..7f14103 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -8,7 +8,7 @@ Purpose in one line: a click-to-buff list addon for World of Warcraft — it sho every nearby player who is missing one of your buffs; click a name (or press one key) to buff them. -Frozen foundation: one shared Lua source (`BuffRadar/Data.lua` + `BuffRadar/BuffRadar.lua` + `BuffRadar/Coordination.lua` + `BuffRadar/Wizard.lua` + `BuffRadar/Config.lua` + `BuffRadar/Slash.lua` + `BuffRadar/Extras.lua` + `BuffRadar/Recaps.lua` + `BuffRadar/Profiles.lua`) builds both +Frozen foundation: one shared Lua source (`BuffRadar/Data.lua` + `BuffRadar/BuffRadar.lua` + `BuffRadar/Coordination.lua` + `BuffRadar/Wizard.lua` + `BuffRadar/Window.lua` + `BuffRadar/Config.lua` + `BuffRadar/Slash.lua` + `BuffRadar/Extras.lua` + `BuffRadar/Recaps.lua` + `BuffRadar/Profiles.lua`) builds both editions; editions differ only in their `.toc` and bundled docs (`BuffRadar/` = Retail docs, `editions/forever/` = Forever docs). Every feature is reachable as a `/br` slash command — the slash surface is the operation @@ -30,7 +30,7 @@ lands with steps in every setup it applies to. Budgets: the host's per-frame budget governs — scanning is event-driven plus a throttled ticker; no per-frame polling. Lua 5.1 hard limits enforced by -`tools/lualimits.py`: ≤200 top-level locals (currently 176 in `BuffRadar.lua`), ≤60 upvalues per +`tools/lualimits.py`: ≤200 top-level locals (currently 165 in `BuffRadar.lua`), ≤60 upvalues per function (currently 58 peak, `HandleSlash`). New state goes in the `X` table or methods, never new file-scope locals, unless the budget is re-checked in the same change. diff --git a/BuffRadar/BuffRadar.lua b/BuffRadar/BuffRadar.lua index b813af2..1798b3a 100644 --- a/BuffRadar/BuffRadar.lua +++ b/BuffRadar/BuffRadar.lua @@ -5446,835 +5446,12 @@ function X.ApplyRowLayout() end --------------------------------------------------------------------------- --- Toggle strip, filter chips and idle fade (1.5.0). The bar under the --- title carries one icon button per buff you can cast (click toggles it, --- like the Buffs tab) and the role filter chips on the right. +-- The window builder (BuildUI), toggle strip, filter chips, idle fade, +-- Cast Next / group buttons and the scale / edge drag helpers live in +-- Window.lua since 1.15.34 (file split Slice G). It reaches this file's +-- locals through X.winAPI (bottom) and hands the window handles back +-- through X.winAPI.setUI. --------------------------------------------------------------------------- -function X.BarHeight() - return (db and db.showStrip and hasAnyBuff) and 18 or 0 -end - -function X.RefreshStrip() - if not X.stripBtns or not db then return end - local parts = {} - for _, b in ipairs(myBuffs) do parts[#parts + 1] = b.key .. (IsOn(b.key, b.default) and "1" or "0") end - if next(myBlessing) then parts[#parts + 1] = "BLESSINGS" .. (IsOn("BLESSINGS", true) and "1" or "0") end - local sig = table.concat(parts, ",") .. "|" .. bookCount - if sig == X.stripSig then return end - X.stripSig = sig - local i = 0 - local function place(key, name, default) - i = i + 1 - local b = X.stripBtns[i] - if not b then return end - b.buffKey, b.buffName, b.buffDefault = key, name, default - local on = IsOn(key, default) - b.tex:SetTexture(SpellIcon(name)) - b.tex:SetAlpha(on and 1 or 0.3) - if b.tex.SetDesaturated then b.tex:SetDesaturated(not on) end - b:Show() - end - for _, b in ipairs(myBuffs) do place(b.key, b.name, b.default) end - if next(myBlessing) then - local _, anyB = next(myBlessing) - if anyB then place("BLESSINGS", anyB.name, true) end - end - for j = i + 1, #X.stripBtns do X.stripBtns[j]:Hide() end -end - -function X.RefreshChips() - if not X.chipBtns or not db then return end - for _, b in ipairs(X.chipBtns) do - if b.roleKey == db.roleFilter then b.fs:SetTextColor(1, 0.85, 0.3) - else b.fs:SetTextColor(0.55, 0.55, 0.55) end - end -end - --- Idle fade: while the mouse is elsewhere the whole window goes partly --- see-through; moving the mouse over it brings it back. Polled from the --- refresh ticker (no per-frame work). -function X.UpdateFade() - if not frame or not db then return end - local close = X.closeButton - local over = (frame.IsMouseOver and frame:IsMouseOver()) - or (close and close:IsShown() and close.IsMouseOver and close:IsMouseOver()) - if close and not InCombatLockdown() then - local visible = frame:IsShown() and over and not (db.clickThrough and db.locked) - and not X.PlayerSuspended() - if visible then - -- Above a titleless window where space permits; otherwise only the - -- hovered button overlays its corner. - local above = false - if not db.showTitle then - local ceiling, top = UIParent:GetTop(), frame:GetTop() - above = ceiling and top - and ceiling * UIParent:GetEffectiveScale() - top * frame:GetEffectiveScale() - >= 22 * close:GetEffectiveScale() - end - local anchor = above and "BOTTOMRIGHT" or "TOPRIGHT" - if close.hoverAnchor ~= anchor then - close.hoverAnchor = anchor - close:ClearAllPoints() - close:SetPoint(anchor, frame, "TOPRIGHT", 0, 0) - end - end - if close:IsShown() ~= (visible and true or false) then close:SetShown(visible and true or false) end - end - local target = 1 - if db.idleFade and db.idleFade > 0 and not db.reduceMotion and not frame.isMoving and not (grip and grip.isSizing) - and not (X.gripL and X.gripL.isSizing) and not (X.edge and X.edge.isSizing) then - if not over then target = 1 - db.idleFade / 100 end - end - if X.curAlpha ~= target then - X.curAlpha = target - frame:SetAlpha(target) - end -end - --- The keybind / macro button. Like the rows, it's set up between clicks (never during one). --- It casts on press when "ActionButtonUseKeyDown" is on and on release otherwise, so one --- key press = one cast. It clears itself after each use and whenever combat starts. -local function ApplyNextRegistration() - if not nextBtn or InCombatLockdown() then return end - if GetCVarBool and GetCVarBool("ActionButtonUseKeyDown") then - nextBtn:RegisterForClicks("LeftButtonDown") - else - nextBtn:RegisterForClicks("LeftButtonUp") - end - if X.groupBtn then - if GetCVarBool and GetCVarBool("ActionButtonUseKeyDown") then - X.groupBtn:RegisterForClicks("LeftButtonDown") - else - X.groupBtn:RegisterForClicks("LeftButtonUp") - end - end -end - -local nextWrapped, nextCombatDriver = false, false - -local function ClearNext() - if not nextBtn or InCombatLockdown() then return end - nextBtn.entry = nil - if nextBtn.isClear then return end -- already disarmed: skip four protected writes - nextBtn:SetAttribute("type", nil) - nextBtn:SetAttribute("spell", nil) - nextBtn:SetAttribute("unit", nil) - nextBtn:SetAttribute("macrotext", nil) - nextBtn:SetAttribute("shift-type1", nil) - nextBtn:SetAttribute("shift-spell1", nil) - nextBtn:SetAttribute("shift-unit1", nil) - nextBtn:SetAttribute("shift-macrotext1", nil) - nextBtn.isClear = true - nextBtn.bGuid = nil -end - -local function ClearGroup() - if not X.groupBtn or InCombatLockdown() then return end - X.groupBtn.entry = nil - if X.groupBtn.isClear then return end -- already disarmed: skip the protected writes - X.groupBtn:SetAttribute("type", nil) - X.groupBtn:SetAttribute("spell", nil) - X.groupBtn:SetAttribute("unit", nil) - X.groupBtn:SetAttribute("macrotext", nil) - X.groupBtn.isClear = true - X.groupBtn.bGuid = nil -end -X.ClearGroup = ClearGroup - -function X.DisarmStaleKeybind(button, mouseButton, clear) - if mouseButton == "LeftButton" and not InCombatLockdown() and button:GetAttribute("type") - and not X.RowTargetMatches(button.entry) then - clear() - if QueueRefresh then QueueRefresh() end - end -end - - --- Group-cast keybind (1.15.0): the group button's plain attribute family --- carries the GROUP version of the head row's buff, so one key press --- casts it. When the buff has no group version the button falls back to --- the plain cast -- the key is never dead, same as the next-buff key. --- Mirrors Bind's cast-method branches for the single spell it writes; --- Bind itself is untouched (rows and the next-buff button keep their --- proven path). -local function BindGroup(btn, unit, gspell, isSelf, pick) - local method = db.castMethod - if method == "target" then - btn:SetAttribute("type", nil) - btn:SetAttribute("unit", nil) - btn:SetAttribute("spell", nil) - btn:SetAttribute("macrotext", nil) - if isSelf then - btn:SetAttribute("type", "spell") - btn:SetAttribute("spell", (pick and pick.id) or gspell) - btn:SetAttribute("unit", "player") - return - end - if unit:match("^party%d+$") or unit:match("^raid%d+$") then - btn:SetAttribute("type", "spell") - btn:SetAttribute("spell", (pick and pick.id) or gspell) - btn:SetAttribute("unit", unit) - return - end - local ok, name = pcall(GetUnitName or UnitName, unit, true) - name = ok and SafeString(name) or nil -- a protected name can't build a macro: no cast - if name and name ~= "" then - btn:SetAttribute("type", "macro") - btn:SetAttribute("macrotext", "/targetexact " .. name .. "\n/cast " .. X.CastText(gspell, pick) .. "\n/targetlasttarget") - end - elseif method == "id" and pick and pick.id then - btn:SetAttribute("type", "spell") - btn:SetAttribute("unit", unit) - btn:SetAttribute("spell", pick.id) - btn:SetAttribute("macrotext", nil) - else - local text = (method == "rank") and X.CastText(gspell, pick) or gspell - btn:SetAttribute("type", "macro") - btn:SetAttribute("unit", nil) - btn:SetAttribute("spell", nil) - btn:SetAttribute("macrotext", "/cast [@" .. unit .. ",help,nodead] " .. text) - end -end - -local function BindGroupCached(btn, unit, spell, guid) - if not btn.combatDriver then return false end - local isSelf = X.IsSelf(unit) - if isSelf == nil then ClearGroup(); return false end - local offer, item, count, reason, _, blocker = X.GroupOffer(spell, unit) - local gspell = offer or spell - local method = db.castMethod - local lvl = X.ReadUnitNumber(UnitLevel, unit) or 0 - local pick = X.BindingRank(gspell, unit, lvl, method) - if pick == false then ClearGroup(); return false end - local id = pick and pick.id - btn.bOfferReason = X.GroupOfferReason(item, count, reason, blocker) - btn.bOfferSummary = blocker and X.GroupOfferReason(item, count, reason, blocker, true) or btn.bOfferReason - if btn.bGuid == guid and btn.bUnit == unit and btn.bSpell == gspell - and btn.bMethod == method and btn.bLevel == lvl and btn.bSelf == isSelf and btn.bRankID == id then - return btn:GetAttribute("type") ~= nil - end - BindGroup(btn, unit, gspell, isSelf, pick) - btn.bGuid, btn.bUnit, btn.bSpell, btn.bMethod, btn.bLevel = guid, unit, gspell, method, lvl - btn.bSelf = isSelf - btn.bRankID, btn.bActionID, btn.bSpellText = id, id, X.CastText(gspell, pick) - if method == "macro" then btn.bActionID, btn.bSpellText = nil, gspell end - btn.isClear = false - return btn:GetAttribute("type") ~= nil -end - -function X.ClearRowCast(btn) - if InCombatLockdown() then return end - btn:SetAttribute("type", nil) - btn:SetAttribute("spell", nil) - btn:SetAttribute("unit", nil) - btn:SetAttribute("macrotext", nil) - btn:SetAttribute("shift-type1", nil) - btn:SetAttribute("shift-spell1", nil) - btn:SetAttribute("shift-unit1", nil) - btn:SetAttribute("shift-macrotext1", nil) - btn.bGuid = nil -end - --- Secure attribute writes only when what the button should cast actually changed. -local function BindCached(btn, unit, spell, guid) - if not btn.combatDriver then return false end - local isSelf = X.IsSelf(unit) - if isSelf == nil then - if btn.bGuid ~= nil then X.ClearRowCast(btn) end - return false - end - local method = db.castMethod - local lvl = X.ReadUnitNumber(UnitLevel, unit) or 0 - local pick = X.BindingRank(spell, unit, lvl, method) - if pick == false then X.ClearRowCast(btn); return false end - local gspell, item, count, reason, blocker - if db.modClick then - local _ - gspell, item, count, reason, _, blocker = X.GroupOffer(spell, unit) - end - if reason then gspell = spell end -- explicit Shift fallback mirrors the primary binding - local gpick = gspell and X.BindingRank(gspell, unit, lvl, method) - local id, gid = pick and pick.id, gpick and gpick.id - btn.bOfferReason = X.GroupOfferReason(item, count, reason, blocker) - if btn.bGuid == guid and btn.bUnit == unit and btn.bSpell == spell - and btn.bMethod == method and btn.bLevel == lvl and btn.bSelf == isSelf - and btn.bRankID == id and btn.bGroupSpell == gspell and btn.bGroupRankID == gid then - return btn:GetAttribute("type") ~= nil - end - Bind(btn, unit, spell, isSelf, pick, gspell, gpick) - btn.bGuid, btn.bUnit, btn.bSpell, btn.bMethod, btn.bLevel = guid, unit, spell, method, lvl - btn.bSelf = isSelf - btn.bRankID, btn.bGroupRankID, btn.bGroupSpell = id, gid, gspell - btn.bActionID, btn.bGroupID, btn.bSpellText = id, gid, X.CastText(spell, pick) - btn.bGroupText = gspell and X.CastText(gspell, gpick) - if method == "macro" then - btn.bActionID, btn.bGroupID, btn.bSpellText, btn.bGroupText = nil, nil, spell, gspell - end - btn.isClear = false - return btn:GetAttribute("type") ~= nil -end - --- Arm the group button with the head row (called from Refresh, which is --- at its upvalue ceiling and reaches the button only through X). -function X.ArmGroupBtn(first) - if not X.groupBtn then return end - X.groupBtn.entry = BindGroupCached(X.groupBtn, first.unit, first.missing[1], first.guid) and first or nil -end - -function X.NoCastReason(entry) - local group = X.groupBtn - if not entry then return X.groupFallback or (group and group.entry and group.bOfferReason) end - if group and group.entry == entry and group.bOfferReason then - return group.bOfferSummary - end - if X.groupFallbackEntry == entry then return X.groupFallbackSummary end -end - -function X.ShowNextPreview(owner) - if InCombatLockdown() or X.PlayerSuspended() or (db.locked and db.clickThrough) then return end - local entry = nextBtn and nextBtn.entry - if not entry or not nextBtn:GetAttribute("type") then return end - GameTooltip:SetOwner(owner, "ANCHOR_RIGHT") - GameTooltip:AddLine(string_format(L["Next buff: %s — %s"], entry.fullName or entry.name, - nextBtn.bSpellText or entry.missing[1]), 1, 1, 1, true) - local group = X.groupBtn - if group and group.entry == entry and group.bSpellText then - GameTooltip:AddLine(string_format(L["Group buff key: %s"], group.bSpellText), 0.8, 0.9, 1, true) - end - local reason = X.NoCastReason(entry) - if reason then GameTooltip:AddLine(reason, 1, 0.7, 0.3, true) end - GameTooltip:Show() -end - -local function BuildNextButton() - nextBtn = CreateFrame("Button", "BuffRadarNextButton", UIParent, - "SecureActionButtonTemplate,SecureHandlerStateTemplate") - nextBtn:SetSize(1, 1) - nextBtn:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) - nextBtn:SetAlpha(0) - nextBtn:EnableMouse(false) - nextBtn:Show() - ApplyNextRegistration() - -- Secure snippets clear the button the instant combat starts and right after each use. - -- Leave casting disarmed if the client cannot install combat clearing. - nextCombatDriver = X.InstallCombatDriver(nextBtn, [[ - if newstate == "combat" then - self:SetAttribute("type", nil) - self:SetAttribute("spell", nil) - self:SetAttribute("unit", nil) - self:SetAttribute("macrotext", nil) - self:SetAttribute("shift-type1", nil) - self:SetAttribute("shift-spell1", nil) - self:SetAttribute("shift-unit1", nil) - self:SetAttribute("shift-macrotext1", nil) - end - ]]) - nextBtn.combatDriver = nextCombatDriver - if SecureHandlerWrapScript then - nextWrapped = pcall(SecureHandlerWrapScript, nextBtn, "OnClick", nextBtn, [[ return nil, true ]], [[ - self:SetAttribute("type", nil) - self:SetAttribute("spell", nil) - self:SetAttribute("unit", nil) - self:SetAttribute("macrotext", nil) - self:SetAttribute("shift-type1", nil) - self:SetAttribute("shift-spell1", nil) - self:SetAttribute("shift-unit1", nil) - self:SetAttribute("shift-macrotext1", nil) - ]]) - end - nextBtn:HookScript("PreClick", function(self, button, down) - X.DisarmStaleKeybind(self, button, ClearNext) - X.BeginCastClick(self, button, down, "next-buff key") - end) - nextBtn:HookScript("PostClick", function(self, button, down) - X.EndCastClick(self, button, down, "next-buff key") - self.bGuid, self.isClear = nil, false -- attributes changed outside our cache - if not nextWrapped then ClearNext() end -- one press = one cast - end) -end - --- The group-cast keybind button (1.15.0): same hidden secure pattern as --- the next-buff button -- combat driver clears it, the wrap clears it --- after each use, PostClick books the cast that actually happened (the --- group version when there is one). -local function BuildGroupButton() - local btn = CreateFrame("Button", "BuffRadarGroupButton", UIParent, - "SecureActionButtonTemplate,SecureHandlerStateTemplate") - X.groupBtn = btn - btn:SetSize(1, 1) - btn:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) - btn:SetAlpha(0) - btn:EnableMouse(false) - btn:Show() - ApplyNextRegistration() - X.groupCombatDriver = X.InstallCombatDriver(btn, [[ - if newstate == "combat" then - self:SetAttribute("type", nil) - self:SetAttribute("spell", nil) - self:SetAttribute("unit", nil) - self:SetAttribute("macrotext", nil) - end - ]]) - btn.combatDriver = X.groupCombatDriver - if SecureHandlerWrapScript then - X.groupWrapped = pcall(SecureHandlerWrapScript, btn, "OnClick", btn, [[ return nil, true ]], [[ - self:SetAttribute("type", nil) - self:SetAttribute("spell", nil) - self:SetAttribute("unit", nil) - self:SetAttribute("macrotext", nil) - ]]) - end - btn:HookScript("PreClick", function(self, button, down) - X.DisarmStaleKeybind(self, button, ClearGroup) - X.BeginCastClick(self, button, down, "group-buff key") - end) - btn:HookScript("PostClick", function(self, button, down) - X.EndCastClick(self, button, down, "group-buff key") - self.bGuid, self.isClear = nil, false -- attributes changed outside our cache - if not X.groupWrapped then ClearGroup() end -- one press = one cast - end) -end - --- Scale drag (1.11.0). Cursor-driven; the OnUpdate runs only while a grip is --- held. Scale = the cursor's horizontal distance from the fixed bottom --- corner divided by the window's unscaled width. -X.SNAPS = { 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 } - -function X.ScaleFromCursor(g) - local cx = GetCursorPosition() / UIParent:GetEffectiveScale() - local w = g.baseW - if not w or w <= 0 then return db.scale or 1 end - local ns = (g.side == "RIGHT") and (cx - g.fixedX) / w or (g.fixedX - cx) / w - if db.gripSnap ~= false and IsShiftKeyDown and IsShiftKeyDown() then - local best, bd = ns, 0.06 -- Shift: snap to a preset within 6% - for _, p in ipairs(X.SNAPS) do - local d = math.abs(ns - p) - if d < bd then best, bd = p, d end - end - ns = best - end - if ns < 0.5 then ns = 0.5 elseif ns > 2 then ns = 2 end -- same bounds as RANGES.scale - return ns -end - -function X.PlaceScaled(g, ns) - local left = (g.side == "RIGHT") and g.fixedX or (g.fixedX - g.baseW * ns) - frame:SetScale(ns) - frame:ClearAllPoints() - if db.growUp then - frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left / ns, g.fixedY / ns) - else - frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", left / ns, g.fixedY / ns) - end -end - -function X.EndEdgeDrag(e) - if not e or not e.isSizing or InCombatLockdown() then return end - e.isSizing = false - frame:StopMovingOrSizing() - local cols = X.cols or 1 - local w = (frame:GetWidth() - (cols - 1) * 6) / cols - db.width = math.max(MIN_WIDTH, math.min(MAX_WIDTH, math_floor(w + 0.5))) - ApplyGeometry() - SavePosition() -end - -function X.BeginScaleDrag(g) - local s = frame:GetScale() or 1 - local l, r = frame:GetLeft(), frame:GetRight() - local y = db.growUp and frame:GetBottom() or frame:GetTop() - if not (l and r and y) then return end - g.baseW = frame:GetWidth() - g.fixedX = (g.side == "RIGHT") and l * s or r * s - g.fixedY = y * s - g.isSizing = true - g:SetScript("OnUpdate", function(self) - if InCombatLockdown() then X.EndScaleDrag(self); return end - local ns = X.ScaleFromCursor(self) - db.scale = ns - X.PlaceScaled(self, ns) - end) -end - -function X.EndScaleDrag(g) - if not g or not g.isSizing then return end - g:SetScript("OnUpdate", nil) - if InCombatLockdown() then return end - g.isSizing = false - local ns = math_floor((db.scale or 1) * 100 + 0.5) / 100 - db.scale = ns - X.PlaceScaled(g, ns) - SavePosition() - if RefreshConfig then RefreshConfig() end -end - -function X.EndWindowDrags() - if InCombatLockdown() then return end - if frame and frame.isMoving then - frame:StopMovingOrSizing() - frame.isMoving = false - SavePosition() - end - X.EndScaleDrag(grip) - X.EndScaleDrag(X.gripL) - X.EndEdgeDrag(X.edge) -end - -local function BuildUI() - if built or InCombatLockdown() then return end - - frame = CreateFrame("Frame", "BuffRadarFrame", UIParent, - BackdropTemplateMixin and "BackdropTemplate" or nil) - if X.PlayerSuspended() then frame:Hide() end - frame:SetSize(db.width or WIDTH, HEADER_H + 30) - -- Keep the client's default MEDIUM layer. Changing strata on the live - -- frame can be blocked by some Forever clients and is not needed for casts. - frame:SetClampedToScreen(true) - frame:SetMovable(true) - frame:SetResizable(true) - -- Only the width is user-sized (StartSizing("RIGHT")); the height bounds are - -- wide open because Refresh() sets the height to fit the list. - if frame.SetResizeBounds then - frame:SetResizeBounds(MIN_WIDTH, 1, MAX_WIDTH, 4000) - elseif frame.SetMinResize then - frame:SetMinResize(MIN_WIDTH, 1) - frame:SetMaxResize(MAX_WIDTH, 4000) - end - frame:EnableMouse(true) - frame:SetScript("OnMouseWheel", X.RowWheel) - frame:EnableMouseWheel(false) - frame:RegisterForDrag("LeftButton") - frame:SetScript("OnDragStart", function(self) - if not db.locked and not InCombatLockdown() then - self:StartMoving() - self.isMoving = true - end - end) - frame:SetScript("OnDragStop", function(self) - if not self.isMoving or InCombatLockdown() then return end - self:StopMovingOrSizing() - self.isMoving = false - SavePosition() - end) - if frame.SetBackdrop then - frame:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 12, - insets = { left = 3, right = 3, top = 3, bottom = 3 }, - }) - frame:SetBackdropColor(0.04, 0.05, 0.09, 0.92) - frame:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) - end - - title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") - title:SetPoint("TOPLEFT", 9, -7) - title:SetText("|cff33ccffBuff|rRadar") - - local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") - X.closeButton = close - close:SetSize(22, 22) - close:SetPoint("TOPRIGHT", 0, 0) - close.hoverAnchor = "TOPRIGHT" - close:SetFrameLevel((frame:GetFrameLevel() or 0) + 10) - close:Hide() - close:SetScript("OnClick", function() - if X.PlayerSuspended() or InCombatLockdown() or (db.clickThrough and db.locked) then return end - db.hidden, sessionShow = true, false - frame:Hide() - Print("Hidden. Type /br to show it again.") - end) - frame:HookScript("OnEnter", X.UpdateFade) - frame:HookScript("OnLeave", X.UpdateFade) - frame:HookScript("OnShow", X.UpdateFade) - frame:HookScript("OnHide", function() - if not InCombatLockdown() then - close:Hide() - if db.hidden then - wipe(X.rowMouseButtons) - X.rowLeftPress = nil - X.ClearRowViewport() - end - end - end) - close:HookScript("OnLeave", X.UpdateFade) - - local gear = CreateFrame("Button", nil, frame) - X.gear = gear - gear:SetSize(14, 14) - gear:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 20, 6) - gear:SetNormalTexture("Interface\\Buttons\\UI-OptionsButton") - gear:SetHighlightTexture("Interface\\Buttons\\UI-OptionsButton", "ADD") - gear:SetScript("OnClick", function() OpenConfig() end) - gear:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(L["BuffRadar settings"]) - GameTooltip:Show() - end) - gear:SetScript("OnLeave", function() GameTooltip:Hide() end) - - if CLASSIC_FEATURES then - local help = CreateFrame("Button", nil, frame) - X.nearbyButton = help - help:SetSize(14, 14) - help:SetPoint("LEFT", gear, "RIGHT", 4, 0) - help:SetNormalFontObject("GameFontNormal") - help:SetHighlightFontObject("GameFontHighlight") - help:SetText("?") - help:SetShown(not (db.clickThrough and db.locked)) - help:SetScript("OnClick", function() - if X.OpenNearbyDiagnostics then X.OpenNearbyDiagnostics() end - end) - help:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(L["Why Is Someone Missing?"]) - GameTooltip:Show() - end) - help:SetScript("OnLeave", function() GameTooltip:Hide() end) - end - - countText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - - combatText = frame:CreateFontString(nil, "OVERLAY", "GameFontRedSmall") - combatText:SetPoint("LEFT", title, "RIGHT", 6, 0) - combatText:SetText(L["combat"]) - combatText:Hide() - - emptyText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") - emptyText:SetPoint("TOPLEFT", 10, -HEADER_H - 3) - emptyText:SetText(L["No targets in the buff queue."]) - - overflowText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") - overflowText:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -HEADER_H) - - footerText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") - footerText:SetPoint("LEFT", X.nearbyButton or gear, "RIGHT", 5, 0) - footerText:SetPoint("RIGHT", frame, "BOTTOMRIGHT", -16, 13) -- clear of the resize grip - footerText:SetJustifyH("LEFT") - if footerText.SetWordWrap then footerText:SetWordWrap(false) end - X.footerText = footerText - if CLASSIC_FEATURES then - local preview = CreateFrame("Frame", nil, frame) - preview:SetPoint("TOPLEFT", footerText, "TOPLEFT", 0, 0) - preview:SetPoint("BOTTOMRIGHT", footerText, "BOTTOMRIGHT", 0, 0) - preview:EnableMouse(true) - preview:SetScript("OnEnter", X.ShowNextPreview) - preview:SetScript("OnLeave", function() GameTooltip:Hide() end) - X.nextPreview = preview - end - - -- Coverage line (1.4.0): "12/15 fully buffed · Fortitude 13/15 · ...", - -- directly above the footer; Refresh() grows the window when it's shown. - coverText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - coverText:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 9, FOOTER_H + 3) - coverText:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -16, FOOTER_H + 3) - coverText:SetJustifyH("LEFT") - if coverText.SetWordWrap then coverText:SetWordWrap(false) end - coverText:Hide() - - -- All-buffed pill (1.6.0): with /br pill on, the full window collapses to - -- this small button while the group is fully buffed. It sits where the - -- window's top-left corner is; clicking it peeks at the full window. - local pill = CreateFrame("Button", "BuffRadarPill", UIParent, - BackdropTemplateMixin and "BackdropTemplate" or nil) - if X.PlayerSuspended() then pill:Hide() end - pill:SetSize(150, 22) - pill:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) - if pill.SetBackdrop then - pill:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 12, - insets = { left = 3, right = 3, top = 3, bottom = 3 }, - }) - pill:SetBackdropColor(0.04, 0.05, 0.09, 0.92) - pill:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) - end - pill.text = pill:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - pill.text:SetPoint("CENTER", 0, 0) - pill.text:SetText(L["All buffed"]) - pill:SetScript("OnClick", function(self) - X.pillPeek = GetTime() + 5 - self:Hide() - if frame then frame:Show() end - end) - pill:Hide() - X.pill = pill - - -- Toggle strip + role filter bar (1.5.0), directly under the title: - -- your buff icons on the left (click one to toggle that buff), the role - -- filter chips on the right. ApplyRowLayout shows/hides the bar and - -- moves the rows below it. - local bar = CreateFrame("Frame", nil, frame) - bar:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -HEADER_H) - bar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -HEADER_H) - bar:SetHeight(18) - X.bar = bar - X.stripBtns = {} - for i = 1, 10 do - local b = CreateFrame("Button", "BuffRadarStrip" .. i, bar) - b:SetSize(16, 16) - b:SetPoint("LEFT", bar, "LEFT", (i - 1) * 17, 0) - b.tex = b:CreateTexture(nil, "ARTWORK") - b.tex:SetAllPoints(b) - b:SetScript("OnClick", function(self) - if InCombatLockdown() or not self.buffKey then return end - db.enabled[self.buffKey] = not IsOn(self.buffKey, self.buffDefault) - X.stripSig = nil - if QueueRefresh then QueueRefresh() end - end) - b:SetScript("OnEnter", function(self) - if not self.buffKey then return end - GameTooltip:SetOwner(self, "ANCHOR_RIGHT") - GameTooltip:AddLine(self.buffName or self.buffKey) - GameTooltip:AddLine(IsOn(self.buffKey, self.buffDefault) and "On -- click to turn off" - or "Off -- click to turn on", 0.7, 0.7, 0.7) - GameTooltip:Show() - end) - b:SetScript("OnLeave", function() GameTooltip:Hide() end) - b:Hide() - X.stripBtns[i] = b - end - X.chipBtns = {} - local chipDefs = { - { "ALL", "All", 26, -98 }, { "TANK", "Tank", 32, -64 }, - { "HEALER", "Heal", 32, -30 }, { "DAMAGER", "DPS", 28, 0 }, - } - for _, cd in ipairs(chipDefs) do - local b = CreateFrame("Button", "BuffRadarChip" .. cd[1], bar) - b:SetSize(cd[3], 16) - b:SetPoint("RIGHT", bar, "RIGHT", cd[4], 0) - b.roleKey = cd[1] - b.fs = b:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - b.fs:SetAllPoints(b) - b.fs:SetJustifyH("CENTER") - b.fs:SetText(cd[2]) - b:SetScript("OnClick", function(self) - db.roleFilter = self.roleKey - X.RefreshChips() - if QueueRefresh then QueueRefresh() end - end) - X.chipBtns[#X.chipBtns + 1] = b - end - X.RefreshChips() - - -- Scale grips (1.11.0): drag either bottom corner to rescale the whole - -- window (frame, rows, icons and text) together. The opposite bottom - -- corner stays put on screen; the top edge (or bottom edge when the list - -- grows up) stays put vertically. Width is set with /br width. - local function MakeScaleGrip(side) - local g = CreateFrame("Button", nil, frame) - g:SetSize(12, 12) - g.side = side - local right = side == "RIGHT" - g:SetPoint(right and "BOTTOMRIGHT" or "BOTTOMLEFT", frame, right and "BOTTOMRIGHT" or "BOTTOMLEFT", - right and -3 or 3, 3) - g:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up") - g:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down") - g:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight", "ADD") - if not right then -- mirror the right-corner art for the left corner - local texs = { g:GetNormalTexture(), g:GetPushedTexture(), g:GetHighlightTexture() } - for i = 1, 3 do - if texs[i] and texs[i].SetTexCoord then texs[i]:SetTexCoord(1, 0, 0, 1) end - end - end - g:SetScript("OnMouseDown", function(self, button) - if button ~= "LeftButton" or db.locked or InCombatLockdown() then return end - X.BeginScaleDrag(self) - end) - g:SetScript("OnMouseUp", function(self) X.EndScaleDrag(self) end) - g:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, right and "ANCHOR_RIGHT" or "ANCHOR_LEFT") - GameTooltip:AddLine(L["Drag to resize the window"]) - GameTooltip:AddLine(string.format("%d%%%s", math_floor((db.scale or 1) * 100 + 0.5), - db.scalePerSpec and (X.spec and (" (scale saved for " .. X.spec .. ")") or " (per-spec scale on)") or ""), - 0.8, 0.8, 0.8) - if db.gripSnap ~= false then GameTooltip:AddLine("Hold Shift to snap to 75 / 100 / 125 / 150%", 0.6, 0.6, 0.6) end - GameTooltip:Show() - end) - g:SetScript("OnLeave", function() GameTooltip:Hide() end) - return g - end - grip = MakeScaleGrip("RIGHT") - X.gripL = MakeScaleGrip("LEFT") - - -- Width handle (1.12.0): drag the right edge to change the list width, - -- the job the old corner grip did. Kept clear of the corner grip. - local edge = CreateFrame("Button", nil, frame) - edge:SetWidth(5) - edge:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -HEADER_H) - edge:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 18) - edge:SetScript("OnMouseDown", function(self, button) - if button ~= "LeftButton" or db.locked or InCombatLockdown() then return end - frame:StartSizing("RIGHT") - self.isSizing = true - end) - edge:SetScript("OnMouseUp", function(self) X.EndEdgeDrag(self) end) - edge:SetScript("OnEnter", function(self) - GameTooltip:SetOwner(self, "ANCHOR_CURSOR") - GameTooltip:AddLine("Drag to change the width") - GameTooltip:Show() - end) - edge:SetScript("OnLeave", function() GameTooltip:Hide() end) - X.edge = edge - - -- Name finder (1.8.0): a slim bar under the toggle strip holding one - -- edit box; while it has text, the list shows only matching names. - -- ApplyRowLayout positions and shows/hides it. - local findBar = CreateFrame("Frame", nil, frame) - findBar:SetHeight(16) - local findLabel = findBar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - findLabel:SetPoint("LEFT", 2, 0) - findLabel:SetText("Find:") - local findEdit = CreateFrame("EditBox", nil, findBar, "InputBoxTemplate") - findEdit:SetSize(130, 16) - findEdit:SetPoint("LEFT", findLabel, "RIGHT", 6, 0) - findEdit:SetAutoFocus(false) - findEdit:SetMaxLetters(24) - findEdit:SetScript("OnTextChanged", function(self) - X.search = (self:GetText() or ""):lower() - if QueueRefresh then QueueRefresh() end - end) - findEdit:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) - findEdit:SetScript("OnEscapePressed", function(self) - self:SetText("") - self:ClearFocus() - end) - findBar:Hide() - X.findBar, X.findEdit = findBar, findEdit - - -- Focus watch line (1.8.0): one line about your focus target's buffs, - -- directly above the coverage line. Refresh fills and shows it. - local focusText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") - focusText:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 9, FOOTER_H + 17) - focusText:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -16, FOOTER_H + 17) - focusText:SetJustifyH("LEFT") - if focusText.SetWordWrap then focusText:SetWordWrap(false) end - focusText:Hide() - X.focusText = focusText - - for i = 1, MAX_ROWS do CreateRow(i) end - - -- Hide securely during death or combat. Refresh owns the visible state. - if RegisterStateDriver then - local ok, accepted = pcall(RegisterStateDriver, frame, "visibility", "[@player,dead][combat] hide") - frame.visibilityDriver = ok and accepted ~= false - ok, accepted = pcall(RegisterStateDriver, pill, "visibility", "[@player,dead][combat] hide") - pill.visibilityDriver = ok and accepted ~= false - end - - local okNext, errNext = pcall(BuildNextButton) - pcall(BuildGroupButton) - if not okNext then Print("|cffff4040keybind button unavailable:|r " .. tostring(errNext)) end - - ApplyGeometry() - RestorePosition() - ApplyAppearance() - X.ApplyRowLayout() - UpdateCounter() - BuildMinimapButton() - built = true -end --------------------------------------------------------------------------- -- Minimap button + addon compartment (block-scoped: 200-local limit) @@ -6460,7 +5637,7 @@ function X.SuspendBuffUI() end if locked then return end X.EndWindowDrags() - ClearNext() + X.ClearNext() X.ClearGroup() if frame then SetShownIfChanged(frame, false) end if X.pill then SetShownIfChanged(X.pill, false) end @@ -6688,7 +5865,7 @@ local function RenderRow(row, e, cached) if row.bGuid ~= nil then X.ClearRowCast(row) end else row:SetAlpha(1) - BindCached(row, e.unit, m[1], e.castGuid or e.guid) + X.BindCached(row, e.unit, m[1], e.castGuid or e.guid) end if not row:IsShown() then row:Show() end end @@ -6816,7 +5993,6 @@ function X.BuildBuffView(list, n) end X.IsMajorCity, X.CurrentInstance = InMajorCity, InInstanceNow -X.BindCached = BindCached function X.ApplyRowWheel() if not frame or InCombatLockdown() then return end @@ -6902,7 +6078,7 @@ local function Refresh() if not hasAnyBuff then X.ClearRowViewport() refreshIdle = true - ClearNext() + X.ClearNext() X.ClearGroup() for i = 1, MAX_ROWS do ClearRow(rows[i]) end if sessionShow and not db.hidden then @@ -6920,7 +6096,7 @@ local function Refresh() if db.pauseInCities and X.IsMajorCity() then X.ClearRowViewport() refreshIdle = true - ClearNext() + X.ClearNext() X.ClearGroup() wipe(X.listedBefore) for i = 1, MAX_ROWS do ClearRow(rows[i]) end @@ -6937,7 +6113,7 @@ local function Refresh() if db.pauseInBG and (instType == "pvp" or instType == "arena") then X.ClearRowViewport() refreshIdle = true - ClearNext() + X.ClearNext() X.ClearGroup() wipe(X.listedBefore) for i = 1, MAX_ROWS do ClearRow(rows[i]) end @@ -6955,7 +6131,7 @@ local function Refresh() if ok and onTaxi then X.ClearRowViewport() refreshIdle = true - ClearNext() + X.ClearNext() X.ClearGroup() wipe(X.listedBefore) for i = 1, MAX_ROWS do ClearRow(rows[i]) end @@ -6971,7 +6147,7 @@ local function Refresh() -- Low-mana pause (optional): don't offer buffs you can't afford to cast. if db.lowMana and db.lowMana > 0 and X.LowMana() then X.ClearRowViewport() - ClearNext() + X.ClearNext() X.ClearGroup() wipe(X.listedBefore) for i = 1, MAX_ROWS do ClearRow(rows[i]) end @@ -7041,7 +6217,7 @@ local function Refresh() nextBtn.entry = X.BindCached(nextBtn, first.unit, first.missing[1], first.guid) and first or nil X.ArmGroupBtn(first) else - ClearNext() + X.ClearNext() X.ClearGroup() end @@ -7526,7 +6702,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) end if event == "CVAR_UPDATE" then if arg1 == "ActionButtonUseKeyDown" or arg1 == "ACTION_BUTTON_USE_KEY_DOWN" then - ApplyNextRegistration() + X.ApplyNextRegistration() if db then pcall(MakeMacro, true) end -- keep an existing BuffRadar macro in sync elseif type(arg1) == "string" then local name = arg1:lower() @@ -7743,7 +6919,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) local ok, err = pcall(BuildBuffList) if not ok then Print("|cffff4040error reading spellbook:|r " .. tostring(err)) end X.prioDirty = true - ok, err = pcall(BuildUI) + ok, err = pcall(X.BuildUI) if not ok then Print("|cffff4040error building window:|r " .. tostring(err)) end X.ApplyClickThrough() Print("loaded. Type /br to show the window.") @@ -7779,7 +6955,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if InCombatLockdown() then return end X.EndWindowDrags() if combatText then combatText:Hide() end - BuildUI() + X.BuildUI() if X.PlayerSuspended() then X.SuspendBuffUI() if db and X.WipeCheck then X.WipeCheck() end @@ -7793,7 +6969,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if X.appearancePending or X.flashPending then ApplyAppearance() end X.ApplyRowLayout() X.ApplyClickThrough() - ApplyNextRegistration() + X.ApplyNextRegistration() if db and X.WipeCheck then X.WipeCheck() end -- post-wipe report (1.9.0) Soon() elseif event == "SPELLS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" or event == "LEARNED_SPELL_IN_SKILL_LINE" then @@ -7949,7 +7125,7 @@ X.cfgAPI = { X.slashAPI = { Print = Print, Refresh = Refresh, RefreshConfig = RefreshConfig, OpenConfig = OpenConfig, PlayAlert = PlayAlert, ApplyAppearance = ApplyAppearance, ApplyGeometry = ApplyGeometry, - BuildBuffList = BuildBuffList, BuildUI = BuildUI, InvalidateRows = InvalidateRows, + BuildBuffList = BuildBuffList, BuildUI = function() return X.BuildUI() end, InvalidateRows = InvalidateRows, IsOn = IsOn, FriendlyPlatesOn = X.FriendlyPlatesOn, InGroup = InGroup, InInstanceNow = InInstanceNow, InMajorCity = InMajorCity, MakeMacro = MakeMacro, OpenKeybinds = OpenKeybinds, RefreshMinimapButton = RefreshMinimapButton, @@ -7962,7 +7138,8 @@ X.slashAPI = { getState = function() return { frame = frame, grip = grip, built = built, hasAnyBuff = hasAnyBuff, sessionShow = sessionShow, lastError = lastError, bookCount = bookCount, - nextWrapped = nextWrapped, nextCombatDriver = nextCombatDriver } + nextWrapped = (select(1, X.NextBindState())), + nextCombatDriver = (select(2, X.NextBindState())) } end, setSessionShow = function(v) sessionShow = v end, } @@ -7999,6 +7176,27 @@ X.wizAPI = { CLASSIC_FEATURES = CLASSIC_FEATURES, MAX_ROWS = MAX_ROWS, nEntries = function() return nEntries end, } + +-- Handed to Window.lua (file split Slice G): stable values by value; the +-- two counters this file reassigns through accessors; setUI takes the +-- window handles BuildUI creates there, setSessionShow the close button. +X.winAPI = { + L = L, Print = Print, IsOn = IsOn, QueueRefresh = QueueRefresh, + OpenConfig = OpenConfig, RefreshConfig = RefreshConfig, + ApplyAppearance = ApplyAppearance, ApplyGeometry = ApplyGeometry, + RestorePosition = RestorePosition, SavePosition = SavePosition, UpdateCounter = UpdateCounter, + Bind = Bind, CreateRow = CreateRow, BuildMinimapButton = BuildMinimapButton, + SafeString = SafeString, SpellIcon = SpellIcon, myBuffs = myBuffs, myBlessing = myBlessing, + CLASSIC_FEATURES = CLASSIC_FEATURES, MAX_ROWS = MAX_ROWS, WIDTH = WIDTH, + HEADER_H = HEADER_H, FOOTER_H = FOOTER_H, MIN_WIDTH = MIN_WIDTH, MAX_WIDTH = MAX_WIDTH, + hasAnyBuff = function() return hasAnyBuff end, + bookCount = function() return bookCount end, + setSessionShow = function(v) sessionShow = v end, + setUI = function(f, t, ct, et, ot, cbt, nb, cv, ft, g, b) + frame, title, countText, emptyText, overflowText, combatText = f, t, ct, et, ot, cbt + nextBtn, coverText, footerText, grip, built = nb, cv, ft, g, b + end, +} X.SanitizeDB, X.IsProfileName, X.PROFILE_MAX_BYTES = SanitizeDB, IsProfileName, PROFILE_MAX_BYTES X.Esc, X.Unesc, X.DEFAULTS = Esc, Unesc, DEFAULTS -- for Profiles.lua X.InGroup, X.InRaid = InGroup, InRaid -- for Recaps.lua diff --git a/BuffRadar/BuffRadar.toc b/BuffRadar/BuffRadar.toc index 0fbf742..3a4a04f 100644 --- a/BuffRadar/BuffRadar.toc +++ b/BuffRadar/BuffRadar.toc @@ -13,6 +13,7 @@ Data.lua BuffRadar.lua Coordination.lua Wizard.lua +Window.lua Config.lua Slash.lua Recaps.lua diff --git a/BuffRadar/Window.lua b/BuffRadar/Window.lua new file mode 100644 index 0000000..2fbf30b --- /dev/null +++ b/BuffRadar/Window.lua @@ -0,0 +1,884 @@ +-- BuffRadar - Window: the main window's builder (BuildUI), the toggle +-- strip, filter chips and idle fade (1.5.0), the Cast Next / group cast +-- buttons and their secure bindings, and the scale / edge drag helpers. +-- Loaded after BuffRadar.lua through the .toc. This is file-split Slice G +-- (1.15.34): the code below moved verbatim from BuffRadar.lua and reaches +-- that file's locals through X.winAPI, which BuffRadar.lua fills in +-- before this file loads. BuildUI creates the window handles here and +-- hands them back with PublishUI() before any main-file code reads them; +-- the settings table arrives through X.dbSinks. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, NS = ... +local X = NS and NS.X +if not X or not X.winAPI then return end +local A = X.winAPI + +local db = X.GetDB and X.GetDB() -- nil until ADDON_LOADED; X.dbSinks updates it +X.dbSinks = X.dbSinks or {} +X.dbSinks[#X.dbSinks + 1] = function(value) db = value end + +local L, Print, IsOn, QueueRefresh = A.L, A.Print, A.IsOn, A.QueueRefresh +local OpenConfig, RefreshConfig = A.OpenConfig, A.RefreshConfig +local ApplyAppearance, ApplyGeometry = A.ApplyAppearance, A.ApplyGeometry +local RestorePosition, SavePosition, UpdateCounter = A.RestorePosition, A.SavePosition, A.UpdateCounter +local Bind, CreateRow, BuildMinimapButton = A.Bind, A.CreateRow, A.BuildMinimapButton +local SafeString, SpellIcon = A.SafeString, A.SpellIcon +local myBuffs, myBlessing = A.myBuffs, A.myBlessing +local CLASSIC_FEATURES, MAX_ROWS, WIDTH = A.CLASSIC_FEATURES, A.MAX_ROWS, A.WIDTH +local HEADER_H, FOOTER_H, MIN_WIDTH, MAX_WIDTH = A.HEADER_H, A.FOOTER_H, A.MIN_WIDTH, A.MAX_WIDTH +local pairs, ipairs, pcall = pairs, ipairs, pcall +local math_floor = math.floor +local string_format = string.format +local wipe = wipe or function(t) for k in pairs(t) do t[k] = nil end return t end +local GetTime, InCombatLockdown = GetTime, InCombatLockdown +local UnitName, UnitLevel = UnitName, UnitLevel + +-- Window handles BuildUI creates. BuffRadar.lua keeps its own copies for +-- the scan and refresh; PublishUI() hands these over as soon as they exist. +local frame, title, countText, emptyText, overflowText, combatText, nextBtn, coverText +local footerText, grip +local built = false +local function PublishUI() + A.setUI(frame, title, countText, emptyText, overflowText, combatText, + nextBtn, coverText, footerText, grip, built) +end + +--------------------------------------------------------------------------- +-- Toggle strip, filter chips and idle fade (1.5.0). The bar under the +-- title carries one icon button per buff you can cast (click toggles it, +-- like the Buffs tab) and the role filter chips on the right. +--------------------------------------------------------------------------- +function X.BarHeight() + return (db and db.showStrip and A.hasAnyBuff()) and 18 or 0 +end + +function X.RefreshStrip() + if not X.stripBtns or not db then return end + local parts = {} + for _, b in ipairs(myBuffs) do parts[#parts + 1] = b.key .. (IsOn(b.key, b.default) and "1" or "0") end + if next(myBlessing) then parts[#parts + 1] = "BLESSINGS" .. (IsOn("BLESSINGS", true) and "1" or "0") end + local sig = table.concat(parts, ",") .. "|" .. A.bookCount() + if sig == X.stripSig then return end + X.stripSig = sig + local i = 0 + local function place(key, name, default) + i = i + 1 + local b = X.stripBtns[i] + if not b then return end + b.buffKey, b.buffName, b.buffDefault = key, name, default + local on = IsOn(key, default) + b.tex:SetTexture(SpellIcon(name)) + b.tex:SetAlpha(on and 1 or 0.3) + if b.tex.SetDesaturated then b.tex:SetDesaturated(not on) end + b:Show() + end + for _, b in ipairs(myBuffs) do place(b.key, b.name, b.default) end + if next(myBlessing) then + local _, anyB = next(myBlessing) + if anyB then place("BLESSINGS", anyB.name, true) end + end + for j = i + 1, #X.stripBtns do X.stripBtns[j]:Hide() end +end + +function X.RefreshChips() + if not X.chipBtns or not db then return end + for _, b in ipairs(X.chipBtns) do + if b.roleKey == db.roleFilter then b.fs:SetTextColor(1, 0.85, 0.3) + else b.fs:SetTextColor(0.55, 0.55, 0.55) end + end +end + +-- Idle fade: while the mouse is elsewhere the whole window goes partly +-- see-through; moving the mouse over it brings it back. Polled from the +-- refresh ticker (no per-frame work). +function X.UpdateFade() + if not frame or not db then return end + local close = X.closeButton + local over = (frame.IsMouseOver and frame:IsMouseOver()) + or (close and close:IsShown() and close.IsMouseOver and close:IsMouseOver()) + if close and not InCombatLockdown() then + local visible = frame:IsShown() and over and not (db.clickThrough and db.locked) + and not X.PlayerSuspended() + if visible then + -- Above a titleless window where space permits; otherwise only the + -- hovered button overlays its corner. + local above = false + if not db.showTitle then + local ceiling, top = UIParent:GetTop(), frame:GetTop() + above = ceiling and top + and ceiling * UIParent:GetEffectiveScale() - top * frame:GetEffectiveScale() + >= 22 * close:GetEffectiveScale() + end + local anchor = above and "BOTTOMRIGHT" or "TOPRIGHT" + if close.hoverAnchor ~= anchor then + close.hoverAnchor = anchor + close:ClearAllPoints() + close:SetPoint(anchor, frame, "TOPRIGHT", 0, 0) + end + end + if close:IsShown() ~= (visible and true or false) then close:SetShown(visible and true or false) end + end + local target = 1 + if db.idleFade and db.idleFade > 0 and not db.reduceMotion and not frame.isMoving and not (grip and grip.isSizing) + and not (X.gripL and X.gripL.isSizing) and not (X.edge and X.edge.isSizing) then + if not over then target = 1 - db.idleFade / 100 end + end + if X.curAlpha ~= target then + X.curAlpha = target + frame:SetAlpha(target) + end +end + +-- The keybind / macro button. Like the rows, it's set up between clicks (never during one). +-- It casts on press when "ActionButtonUseKeyDown" is on and on release otherwise, so one +-- key press = one cast. It clears itself after each use and whenever combat starts. +local function ApplyNextRegistration() + if not nextBtn or InCombatLockdown() then return end + if GetCVarBool and GetCVarBool("ActionButtonUseKeyDown") then + nextBtn:RegisterForClicks("LeftButtonDown") + else + nextBtn:RegisterForClicks("LeftButtonUp") + end + if X.groupBtn then + if GetCVarBool and GetCVarBool("ActionButtonUseKeyDown") then + X.groupBtn:RegisterForClicks("LeftButtonDown") + else + X.groupBtn:RegisterForClicks("LeftButtonUp") + end + end +end + +local nextWrapped, nextCombatDriver = false, false + +local function ClearNext() + if not nextBtn or InCombatLockdown() then return end + nextBtn.entry = nil + if nextBtn.isClear then return end -- already disarmed: skip four protected writes + nextBtn:SetAttribute("type", nil) + nextBtn:SetAttribute("spell", nil) + nextBtn:SetAttribute("unit", nil) + nextBtn:SetAttribute("macrotext", nil) + nextBtn:SetAttribute("shift-type1", nil) + nextBtn:SetAttribute("shift-spell1", nil) + nextBtn:SetAttribute("shift-unit1", nil) + nextBtn:SetAttribute("shift-macrotext1", nil) + nextBtn.isClear = true + nextBtn.bGuid = nil +end + +local function ClearGroup() + if not X.groupBtn or InCombatLockdown() then return end + X.groupBtn.entry = nil + if X.groupBtn.isClear then return end -- already disarmed: skip the protected writes + X.groupBtn:SetAttribute("type", nil) + X.groupBtn:SetAttribute("spell", nil) + X.groupBtn:SetAttribute("unit", nil) + X.groupBtn:SetAttribute("macrotext", nil) + X.groupBtn.isClear = true + X.groupBtn.bGuid = nil +end +X.ClearGroup = ClearGroup + +function X.DisarmStaleKeybind(button, mouseButton, clear) + if mouseButton == "LeftButton" and not InCombatLockdown() and button:GetAttribute("type") + and not X.RowTargetMatches(button.entry) then + clear() + if QueueRefresh then QueueRefresh() end + end +end + + +-- Group-cast keybind (1.15.0): the group button's plain attribute family +-- carries the GROUP version of the head row's buff, so one key press +-- casts it. When the buff has no group version the button falls back to +-- the plain cast -- the key is never dead, same as the next-buff key. +-- Mirrors Bind's cast-method branches for the single spell it writes; +-- Bind itself is untouched (rows and the next-buff button keep their +-- proven path). +local function BindGroup(btn, unit, gspell, isSelf, pick) + local method = db.castMethod + if method == "target" then + btn:SetAttribute("type", nil) + btn:SetAttribute("unit", nil) + btn:SetAttribute("spell", nil) + btn:SetAttribute("macrotext", nil) + if isSelf then + btn:SetAttribute("type", "spell") + btn:SetAttribute("spell", (pick and pick.id) or gspell) + btn:SetAttribute("unit", "player") + return + end + if unit:match("^party%d+$") or unit:match("^raid%d+$") then + btn:SetAttribute("type", "spell") + btn:SetAttribute("spell", (pick and pick.id) or gspell) + btn:SetAttribute("unit", unit) + return + end + local ok, name = pcall(GetUnitName or UnitName, unit, true) + name = ok and SafeString(name) or nil -- a protected name can't build a macro: no cast + if name and name ~= "" then + btn:SetAttribute("type", "macro") + btn:SetAttribute("macrotext", "/targetexact " .. name .. "\n/cast " .. X.CastText(gspell, pick) .. "\n/targetlasttarget") + end + elseif method == "id" and pick and pick.id then + btn:SetAttribute("type", "spell") + btn:SetAttribute("unit", unit) + btn:SetAttribute("spell", pick.id) + btn:SetAttribute("macrotext", nil) + else + local text = (method == "rank") and X.CastText(gspell, pick) or gspell + btn:SetAttribute("type", "macro") + btn:SetAttribute("unit", nil) + btn:SetAttribute("spell", nil) + btn:SetAttribute("macrotext", "/cast [@" .. unit .. ",help,nodead] " .. text) + end +end + +local function BindGroupCached(btn, unit, spell, guid) + if not btn.combatDriver then return false end + local isSelf = X.IsSelf(unit) + if isSelf == nil then ClearGroup(); return false end + local offer, item, count, reason, _, blocker = X.GroupOffer(spell, unit) + local gspell = offer or spell + local method = db.castMethod + local lvl = X.ReadUnitNumber(UnitLevel, unit) or 0 + local pick = X.BindingRank(gspell, unit, lvl, method) + if pick == false then ClearGroup(); return false end + local id = pick and pick.id + btn.bOfferReason = X.GroupOfferReason(item, count, reason, blocker) + btn.bOfferSummary = blocker and X.GroupOfferReason(item, count, reason, blocker, true) or btn.bOfferReason + if btn.bGuid == guid and btn.bUnit == unit and btn.bSpell == gspell + and btn.bMethod == method and btn.bLevel == lvl and btn.bSelf == isSelf and btn.bRankID == id then + return btn:GetAttribute("type") ~= nil + end + BindGroup(btn, unit, gspell, isSelf, pick) + btn.bGuid, btn.bUnit, btn.bSpell, btn.bMethod, btn.bLevel = guid, unit, gspell, method, lvl + btn.bSelf = isSelf + btn.bRankID, btn.bActionID, btn.bSpellText = id, id, X.CastText(gspell, pick) + if method == "macro" then btn.bActionID, btn.bSpellText = nil, gspell end + btn.isClear = false + return btn:GetAttribute("type") ~= nil +end + +function X.ClearRowCast(btn) + if InCombatLockdown() then return end + btn:SetAttribute("type", nil) + btn:SetAttribute("spell", nil) + btn:SetAttribute("unit", nil) + btn:SetAttribute("macrotext", nil) + btn:SetAttribute("shift-type1", nil) + btn:SetAttribute("shift-spell1", nil) + btn:SetAttribute("shift-unit1", nil) + btn:SetAttribute("shift-macrotext1", nil) + btn.bGuid = nil +end + +-- Secure attribute writes only when what the button should cast actually changed. +local function BindCached(btn, unit, spell, guid) + if not btn.combatDriver then return false end + local isSelf = X.IsSelf(unit) + if isSelf == nil then + if btn.bGuid ~= nil then X.ClearRowCast(btn) end + return false + end + local method = db.castMethod + local lvl = X.ReadUnitNumber(UnitLevel, unit) or 0 + local pick = X.BindingRank(spell, unit, lvl, method) + if pick == false then X.ClearRowCast(btn); return false end + local gspell, item, count, reason, blocker + if db.modClick then + local _ + gspell, item, count, reason, _, blocker = X.GroupOffer(spell, unit) + end + if reason then gspell = spell end -- explicit Shift fallback mirrors the primary binding + local gpick = gspell and X.BindingRank(gspell, unit, lvl, method) + local id, gid = pick and pick.id, gpick and gpick.id + btn.bOfferReason = X.GroupOfferReason(item, count, reason, blocker) + if btn.bGuid == guid and btn.bUnit == unit and btn.bSpell == spell + and btn.bMethod == method and btn.bLevel == lvl and btn.bSelf == isSelf + and btn.bRankID == id and btn.bGroupSpell == gspell and btn.bGroupRankID == gid then + return btn:GetAttribute("type") ~= nil + end + Bind(btn, unit, spell, isSelf, pick, gspell, gpick) + btn.bGuid, btn.bUnit, btn.bSpell, btn.bMethod, btn.bLevel = guid, unit, spell, method, lvl + btn.bSelf = isSelf + btn.bRankID, btn.bGroupRankID, btn.bGroupSpell = id, gid, gspell + btn.bActionID, btn.bGroupID, btn.bSpellText = id, gid, X.CastText(spell, pick) + btn.bGroupText = gspell and X.CastText(gspell, gpick) + if method == "macro" then + btn.bActionID, btn.bGroupID, btn.bSpellText, btn.bGroupText = nil, nil, spell, gspell + end + btn.isClear = false + return btn:GetAttribute("type") ~= nil +end + +-- Arm the group button with the head row (called from Refresh, which is +-- at its upvalue ceiling and reaches the button only through X). +function X.ArmGroupBtn(first) + if not X.groupBtn then return end + X.groupBtn.entry = BindGroupCached(X.groupBtn, first.unit, first.missing[1], first.guid) and first or nil +end + +function X.NoCastReason(entry) + local group = X.groupBtn + if not entry then return X.groupFallback or (group and group.entry and group.bOfferReason) end + if group and group.entry == entry and group.bOfferReason then + return group.bOfferSummary + end + if X.groupFallbackEntry == entry then return X.groupFallbackSummary end +end + +function X.ShowNextPreview(owner) + if InCombatLockdown() or X.PlayerSuspended() or (db.locked and db.clickThrough) then return end + local entry = nextBtn and nextBtn.entry + if not entry or not nextBtn:GetAttribute("type") then return end + GameTooltip:SetOwner(owner, "ANCHOR_RIGHT") + GameTooltip:AddLine(string_format(L["Next buff: %s — %s"], entry.fullName or entry.name, + nextBtn.bSpellText or entry.missing[1]), 1, 1, 1, true) + local group = X.groupBtn + if group and group.entry == entry and group.bSpellText then + GameTooltip:AddLine(string_format(L["Group buff key: %s"], group.bSpellText), 0.8, 0.9, 1, true) + end + local reason = X.NoCastReason(entry) + if reason then GameTooltip:AddLine(reason, 1, 0.7, 0.3, true) end + GameTooltip:Show() +end + +local function BuildNextButton() + nextBtn = CreateFrame("Button", "BuffRadarNextButton", UIParent, + "SecureActionButtonTemplate,SecureHandlerStateTemplate") + nextBtn:SetSize(1, 1) + nextBtn:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) + nextBtn:SetAlpha(0) + nextBtn:EnableMouse(false) + nextBtn:Show() + ApplyNextRegistration() + -- Secure snippets clear the button the instant combat starts and right after each use. + -- Leave casting disarmed if the client cannot install combat clearing. + nextCombatDriver = X.InstallCombatDriver(nextBtn, [[ + if newstate == "combat" then + self:SetAttribute("type", nil) + self:SetAttribute("spell", nil) + self:SetAttribute("unit", nil) + self:SetAttribute("macrotext", nil) + self:SetAttribute("shift-type1", nil) + self:SetAttribute("shift-spell1", nil) + self:SetAttribute("shift-unit1", nil) + self:SetAttribute("shift-macrotext1", nil) + end + ]]) + nextBtn.combatDriver = nextCombatDriver + if SecureHandlerWrapScript then + nextWrapped = pcall(SecureHandlerWrapScript, nextBtn, "OnClick", nextBtn, [[ return nil, true ]], [[ + self:SetAttribute("type", nil) + self:SetAttribute("spell", nil) + self:SetAttribute("unit", nil) + self:SetAttribute("macrotext", nil) + self:SetAttribute("shift-type1", nil) + self:SetAttribute("shift-spell1", nil) + self:SetAttribute("shift-unit1", nil) + self:SetAttribute("shift-macrotext1", nil) + ]]) + end + nextBtn:HookScript("PreClick", function(self, button, down) + X.DisarmStaleKeybind(self, button, ClearNext) + X.BeginCastClick(self, button, down, "next-buff key") + end) + nextBtn:HookScript("PostClick", function(self, button, down) + X.EndCastClick(self, button, down, "next-buff key") + self.bGuid, self.isClear = nil, false -- attributes changed outside our cache + if not nextWrapped then ClearNext() end -- one press = one cast + end) +end + +-- The group-cast keybind button (1.15.0): same hidden secure pattern as +-- the next-buff button -- combat driver clears it, the wrap clears it +-- after each use, PostClick books the cast that actually happened (the +-- group version when there is one). +local function BuildGroupButton() + local btn = CreateFrame("Button", "BuffRadarGroupButton", UIParent, + "SecureActionButtonTemplate,SecureHandlerStateTemplate") + X.groupBtn = btn + btn:SetSize(1, 1) + btn:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", 0, 0) + btn:SetAlpha(0) + btn:EnableMouse(false) + btn:Show() + ApplyNextRegistration() + X.groupCombatDriver = X.InstallCombatDriver(btn, [[ + if newstate == "combat" then + self:SetAttribute("type", nil) + self:SetAttribute("spell", nil) + self:SetAttribute("unit", nil) + self:SetAttribute("macrotext", nil) + end + ]]) + btn.combatDriver = X.groupCombatDriver + if SecureHandlerWrapScript then + X.groupWrapped = pcall(SecureHandlerWrapScript, btn, "OnClick", btn, [[ return nil, true ]], [[ + self:SetAttribute("type", nil) + self:SetAttribute("spell", nil) + self:SetAttribute("unit", nil) + self:SetAttribute("macrotext", nil) + ]]) + end + btn:HookScript("PreClick", function(self, button, down) + X.DisarmStaleKeybind(self, button, ClearGroup) + X.BeginCastClick(self, button, down, "group-buff key") + end) + btn:HookScript("PostClick", function(self, button, down) + X.EndCastClick(self, button, down, "group-buff key") + self.bGuid, self.isClear = nil, false -- attributes changed outside our cache + if not X.groupWrapped then ClearGroup() end -- one press = one cast + end) +end + +-- Scale drag (1.11.0). Cursor-driven; the OnUpdate runs only while a grip is +-- held. Scale = the cursor's horizontal distance from the fixed bottom +-- corner divided by the window's unscaled width. +X.SNAPS = { 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 } + +function X.ScaleFromCursor(g) + local cx = GetCursorPosition() / UIParent:GetEffectiveScale() + local w = g.baseW + if not w or w <= 0 then return db.scale or 1 end + local ns = (g.side == "RIGHT") and (cx - g.fixedX) / w or (g.fixedX - cx) / w + if db.gripSnap ~= false and IsShiftKeyDown and IsShiftKeyDown() then + local best, bd = ns, 0.06 -- Shift: snap to a preset within 6% + for _, p in ipairs(X.SNAPS) do + local d = math.abs(ns - p) + if d < bd then best, bd = p, d end + end + ns = best + end + if ns < 0.5 then ns = 0.5 elseif ns > 2 then ns = 2 end -- same bounds as RANGES.scale + return ns +end + +function X.PlaceScaled(g, ns) + local left = (g.side == "RIGHT") and g.fixedX or (g.fixedX - g.baseW * ns) + frame:SetScale(ns) + frame:ClearAllPoints() + if db.growUp then + frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", left / ns, g.fixedY / ns) + else + frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", left / ns, g.fixedY / ns) + end +end + +function X.EndEdgeDrag(e) + if not e or not e.isSizing or InCombatLockdown() then return end + e.isSizing = false + frame:StopMovingOrSizing() + local cols = X.cols or 1 + local w = (frame:GetWidth() - (cols - 1) * 6) / cols + db.width = math.max(MIN_WIDTH, math.min(MAX_WIDTH, math_floor(w + 0.5))) + ApplyGeometry() + SavePosition() +end + +function X.BeginScaleDrag(g) + local s = frame:GetScale() or 1 + local l, r = frame:GetLeft(), frame:GetRight() + local y = db.growUp and frame:GetBottom() or frame:GetTop() + if not (l and r and y) then return end + g.baseW = frame:GetWidth() + g.fixedX = (g.side == "RIGHT") and l * s or r * s + g.fixedY = y * s + g.isSizing = true + g:SetScript("OnUpdate", function(self) + if InCombatLockdown() then X.EndScaleDrag(self); return end + local ns = X.ScaleFromCursor(self) + db.scale = ns + X.PlaceScaled(self, ns) + end) +end + +function X.EndScaleDrag(g) + if not g or not g.isSizing then return end + g:SetScript("OnUpdate", nil) + if InCombatLockdown() then return end + g.isSizing = false + local ns = math_floor((db.scale or 1) * 100 + 0.5) / 100 + db.scale = ns + X.PlaceScaled(g, ns) + SavePosition() + if RefreshConfig then RefreshConfig() end +end + +function X.EndWindowDrags() + if InCombatLockdown() then return end + if frame and frame.isMoving then + frame:StopMovingOrSizing() + frame.isMoving = false + SavePosition() + end + X.EndScaleDrag(grip) + X.EndScaleDrag(X.gripL) + X.EndEdgeDrag(X.edge) +end + +local function BuildUI() + if built or InCombatLockdown() then return end + + frame = CreateFrame("Frame", "BuffRadarFrame", UIParent, + BackdropTemplateMixin and "BackdropTemplate" or nil) + if X.PlayerSuspended() then frame:Hide() end + frame:SetSize(db.width or WIDTH, HEADER_H + 30) + -- Keep the client's default MEDIUM layer. Changing strata on the live + -- frame can be blocked by some Forever clients and is not needed for casts. + frame:SetClampedToScreen(true) + frame:SetMovable(true) + frame:SetResizable(true) + -- Only the width is user-sized (StartSizing("RIGHT")); the height bounds are + -- wide open because Refresh() sets the height to fit the list. + if frame.SetResizeBounds then + frame:SetResizeBounds(MIN_WIDTH, 1, MAX_WIDTH, 4000) + elseif frame.SetMinResize then + frame:SetMinResize(MIN_WIDTH, 1) + frame:SetMaxResize(MAX_WIDTH, 4000) + end + frame:EnableMouse(true) + frame:SetScript("OnMouseWheel", X.RowWheel) + frame:EnableMouseWheel(false) + frame:RegisterForDrag("LeftButton") + frame:SetScript("OnDragStart", function(self) + if not db.locked and not InCombatLockdown() then + self:StartMoving() + self.isMoving = true + end + end) + frame:SetScript("OnDragStop", function(self) + if not self.isMoving or InCombatLockdown() then return end + self:StopMovingOrSizing() + self.isMoving = false + SavePosition() + end) + if frame.SetBackdrop then + frame:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 16, edgeSize = 12, + insets = { left = 3, right = 3, top = 3, bottom = 3 }, + }) + frame:SetBackdropColor(0.04, 0.05, 0.09, 0.92) + frame:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) + end + + title = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") + title:SetPoint("TOPLEFT", 9, -7) + title:SetText("|cff33ccffBuff|rRadar") + + local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") + X.closeButton = close + close:SetSize(22, 22) + close:SetPoint("TOPRIGHT", 0, 0) + close.hoverAnchor = "TOPRIGHT" + close:SetFrameLevel((frame:GetFrameLevel() or 0) + 10) + close:Hide() + close:SetScript("OnClick", function() + if X.PlayerSuspended() or InCombatLockdown() or (db.clickThrough and db.locked) then return end + db.hidden = true; A.setSessionShow(false) + frame:Hide() + Print("Hidden. Type /br to show it again.") + end) + frame:HookScript("OnEnter", X.UpdateFade) + frame:HookScript("OnLeave", X.UpdateFade) + frame:HookScript("OnShow", X.UpdateFade) + frame:HookScript("OnHide", function() + if not InCombatLockdown() then + close:Hide() + if db.hidden then + wipe(X.rowMouseButtons) + X.rowLeftPress = nil + X.ClearRowViewport() + end + end + end) + close:HookScript("OnLeave", X.UpdateFade) + + local gear = CreateFrame("Button", nil, frame) + X.gear = gear + gear:SetSize(14, 14) + gear:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 20, 6) + gear:SetNormalTexture("Interface\\Buttons\\UI-OptionsButton") + gear:SetHighlightTexture("Interface\\Buttons\\UI-OptionsButton", "ADD") + gear:SetScript("OnClick", function() OpenConfig() end) + gear:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(L["BuffRadar settings"]) + GameTooltip:Show() + end) + gear:SetScript("OnLeave", function() GameTooltip:Hide() end) + + if CLASSIC_FEATURES then + local help = CreateFrame("Button", nil, frame) + X.nearbyButton = help + help:SetSize(14, 14) + help:SetPoint("LEFT", gear, "RIGHT", 4, 0) + help:SetNormalFontObject("GameFontNormal") + help:SetHighlightFontObject("GameFontHighlight") + help:SetText("?") + help:SetShown(not (db.clickThrough and db.locked)) + help:SetScript("OnClick", function() + if X.OpenNearbyDiagnostics then X.OpenNearbyDiagnostics() end + end) + help:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(L["Why Is Someone Missing?"]) + GameTooltip:Show() + end) + help:SetScript("OnLeave", function() GameTooltip:Hide() end) + end + + countText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + + combatText = frame:CreateFontString(nil, "OVERLAY", "GameFontRedSmall") + combatText:SetPoint("LEFT", title, "RIGHT", 6, 0) + combatText:SetText(L["combat"]) + combatText:Hide() + + emptyText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + emptyText:SetPoint("TOPLEFT", 10, -HEADER_H - 3) + emptyText:SetText(L["No targets in the buff queue."]) + + overflowText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + overflowText:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -HEADER_H) + + footerText = frame:CreateFontString(nil, "OVERLAY", "GameFontDisableSmall") + footerText:SetPoint("LEFT", X.nearbyButton or gear, "RIGHT", 5, 0) + footerText:SetPoint("RIGHT", frame, "BOTTOMRIGHT", -16, 13) -- clear of the resize grip + footerText:SetJustifyH("LEFT") + if footerText.SetWordWrap then footerText:SetWordWrap(false) end + X.footerText = footerText + if CLASSIC_FEATURES then + local preview = CreateFrame("Frame", nil, frame) + preview:SetPoint("TOPLEFT", footerText, "TOPLEFT", 0, 0) + preview:SetPoint("BOTTOMRIGHT", footerText, "BOTTOMRIGHT", 0, 0) + preview:EnableMouse(true) + preview:SetScript("OnEnter", X.ShowNextPreview) + preview:SetScript("OnLeave", function() GameTooltip:Hide() end) + X.nextPreview = preview + end + + -- Coverage line (1.4.0): "12/15 fully buffed · Fortitude 13/15 · ...", + -- directly above the footer; Refresh() grows the window when it's shown. + coverText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + coverText:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 9, FOOTER_H + 3) + coverText:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -16, FOOTER_H + 3) + coverText:SetJustifyH("LEFT") + if coverText.SetWordWrap then coverText:SetWordWrap(false) end + coverText:Hide() + + -- All-buffed pill (1.6.0): with /br pill on, the full window collapses to + -- this small button while the group is fully buffed. It sits where the + -- window's top-left corner is; clicking it peeks at the full window. + local pill = CreateFrame("Button", "BuffRadarPill", UIParent, + BackdropTemplateMixin and "BackdropTemplate" or nil) + if X.PlayerSuspended() then pill:Hide() end + pill:SetSize(150, 22) + pill:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, 0) + if pill.SetBackdrop then + pill:SetBackdrop({ + bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", + edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", + tile = true, tileSize = 16, edgeSize = 12, + insets = { left = 3, right = 3, top = 3, bottom = 3 }, + }) + pill:SetBackdropColor(0.04, 0.05, 0.09, 0.92) + pill:SetBackdropBorderColor(0.35, 0.55, 0.8, 1) + end + pill.text = pill:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + pill.text:SetPoint("CENTER", 0, 0) + pill.text:SetText(L["All buffed"]) + pill:SetScript("OnClick", function(self) + X.pillPeek = GetTime() + 5 + self:Hide() + if frame then frame:Show() end + end) + pill:Hide() + X.pill = pill + + -- Toggle strip + role filter bar (1.5.0), directly under the title: + -- your buff icons on the left (click one to toggle that buff), the role + -- filter chips on the right. ApplyRowLayout shows/hides the bar and + -- moves the rows below it. + local bar = CreateFrame("Frame", nil, frame) + bar:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -HEADER_H) + bar:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -HEADER_H) + bar:SetHeight(18) + X.bar = bar + X.stripBtns = {} + for i = 1, 10 do + local b = CreateFrame("Button", "BuffRadarStrip" .. i, bar) + b:SetSize(16, 16) + b:SetPoint("LEFT", bar, "LEFT", (i - 1) * 17, 0) + b.tex = b:CreateTexture(nil, "ARTWORK") + b.tex:SetAllPoints(b) + b:SetScript("OnClick", function(self) + if InCombatLockdown() or not self.buffKey then return end + db.enabled[self.buffKey] = not IsOn(self.buffKey, self.buffDefault) + X.stripSig = nil + if QueueRefresh then QueueRefresh() end + end) + b:SetScript("OnEnter", function(self) + if not self.buffKey then return end + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:AddLine(self.buffName or self.buffKey) + GameTooltip:AddLine(IsOn(self.buffKey, self.buffDefault) and "On -- click to turn off" + or "Off -- click to turn on", 0.7, 0.7, 0.7) + GameTooltip:Show() + end) + b:SetScript("OnLeave", function() GameTooltip:Hide() end) + b:Hide() + X.stripBtns[i] = b + end + X.chipBtns = {} + local chipDefs = { + { "ALL", "All", 26, -98 }, { "TANK", "Tank", 32, -64 }, + { "HEALER", "Heal", 32, -30 }, { "DAMAGER", "DPS", 28, 0 }, + } + for _, cd in ipairs(chipDefs) do + local b = CreateFrame("Button", "BuffRadarChip" .. cd[1], bar) + b:SetSize(cd[3], 16) + b:SetPoint("RIGHT", bar, "RIGHT", cd[4], 0) + b.roleKey = cd[1] + b.fs = b:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + b.fs:SetAllPoints(b) + b.fs:SetJustifyH("CENTER") + b.fs:SetText(cd[2]) + b:SetScript("OnClick", function(self) + db.roleFilter = self.roleKey + X.RefreshChips() + if QueueRefresh then QueueRefresh() end + end) + X.chipBtns[#X.chipBtns + 1] = b + end + X.RefreshChips() + + -- Scale grips (1.11.0): drag either bottom corner to rescale the whole + -- window (frame, rows, icons and text) together. The opposite bottom + -- corner stays put on screen; the top edge (or bottom edge when the list + -- grows up) stays put vertically. Width is set with /br width. + local function MakeScaleGrip(side) + local g = CreateFrame("Button", nil, frame) + g:SetSize(12, 12) + g.side = side + local right = side == "RIGHT" + g:SetPoint(right and "BOTTOMRIGHT" or "BOTTOMLEFT", frame, right and "BOTTOMRIGHT" or "BOTTOMLEFT", + right and -3 or 3, 3) + g:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up") + g:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down") + g:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight", "ADD") + if not right then -- mirror the right-corner art for the left corner + local texs = { g:GetNormalTexture(), g:GetPushedTexture(), g:GetHighlightTexture() } + for i = 1, 3 do + if texs[i] and texs[i].SetTexCoord then texs[i]:SetTexCoord(1, 0, 0, 1) end + end + end + g:SetScript("OnMouseDown", function(self, button) + if button ~= "LeftButton" or db.locked or InCombatLockdown() then return end + X.BeginScaleDrag(self) + end) + g:SetScript("OnMouseUp", function(self) X.EndScaleDrag(self) end) + g:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, right and "ANCHOR_RIGHT" or "ANCHOR_LEFT") + GameTooltip:AddLine(L["Drag to resize the window"]) + GameTooltip:AddLine(string.format("%d%%%s", math_floor((db.scale or 1) * 100 + 0.5), + db.scalePerSpec and (X.spec and (" (scale saved for " .. X.spec .. ")") or " (per-spec scale on)") or ""), + 0.8, 0.8, 0.8) + if db.gripSnap ~= false then GameTooltip:AddLine("Hold Shift to snap to 75 / 100 / 125 / 150%", 0.6, 0.6, 0.6) end + GameTooltip:Show() + end) + g:SetScript("OnLeave", function() GameTooltip:Hide() end) + return g + end + grip = MakeScaleGrip("RIGHT") + X.gripL = MakeScaleGrip("LEFT") + + -- Width handle (1.12.0): drag the right edge to change the list width, + -- the job the old corner grip did. Kept clear of the corner grip. + local edge = CreateFrame("Button", nil, frame) + edge:SetWidth(5) + edge:SetPoint("TOPRIGHT", frame, "TOPRIGHT", 0, -HEADER_H) + edge:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 18) + edge:SetScript("OnMouseDown", function(self, button) + if button ~= "LeftButton" or db.locked or InCombatLockdown() then return end + frame:StartSizing("RIGHT") + self.isSizing = true + end) + edge:SetScript("OnMouseUp", function(self) X.EndEdgeDrag(self) end) + edge:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_CURSOR") + GameTooltip:AddLine("Drag to change the width") + GameTooltip:Show() + end) + edge:SetScript("OnLeave", function() GameTooltip:Hide() end) + X.edge = edge + + -- Name finder (1.8.0): a slim bar under the toggle strip holding one + -- edit box; while it has text, the list shows only matching names. + -- ApplyRowLayout positions and shows/hides it. + local findBar = CreateFrame("Frame", nil, frame) + findBar:SetHeight(16) + local findLabel = findBar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + findLabel:SetPoint("LEFT", 2, 0) + findLabel:SetText("Find:") + local findEdit = CreateFrame("EditBox", nil, findBar, "InputBoxTemplate") + findEdit:SetSize(130, 16) + findEdit:SetPoint("LEFT", findLabel, "RIGHT", 6, 0) + findEdit:SetAutoFocus(false) + findEdit:SetMaxLetters(24) + findEdit:SetScript("OnTextChanged", function(self) + X.search = (self:GetText() or ""):lower() + if QueueRefresh then QueueRefresh() end + end) + findEdit:SetScript("OnEnterPressed", function(self) self:ClearFocus() end) + findEdit:SetScript("OnEscapePressed", function(self) + self:SetText("") + self:ClearFocus() + end) + findBar:Hide() + X.findBar, X.findEdit = findBar, findEdit + + -- Focus watch line (1.8.0): one line about your focus target's buffs, + -- directly above the coverage line. Refresh fills and shows it. + local focusText = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + focusText:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 9, FOOTER_H + 17) + focusText:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -16, FOOTER_H + 17) + focusText:SetJustifyH("LEFT") + if focusText.SetWordWrap then focusText:SetWordWrap(false) end + focusText:Hide() + X.focusText = focusText + + PublishUI() -- CreateRow and the calls below read the main file's copies + for i = 1, MAX_ROWS do CreateRow(i) end + + -- Hide securely during death or combat. Refresh owns the visible state. + if RegisterStateDriver then + local ok, accepted = pcall(RegisterStateDriver, frame, "visibility", "[@player,dead][combat] hide") + frame.visibilityDriver = ok and accepted ~= false + ok, accepted = pcall(RegisterStateDriver, pill, "visibility", "[@player,dead][combat] hide") + pill.visibilityDriver = ok and accepted ~= false + end + + local okNext, errNext = pcall(BuildNextButton) + pcall(BuildGroupButton) + PublishUI() -- nextBtn now exists + if not okNext then Print("|cffff4040keybind button unavailable:|r " .. tostring(errNext)) end + + ApplyGeometry() + RestorePosition() + ApplyAppearance() + X.ApplyRowLayout() + UpdateCounter() + BuildMinimapButton() + built = true + PublishUI() +end + +-- Entry points BuffRadar.lua and Slash.lua call. +X.BuildUI, X.ApplyNextRegistration, X.ClearNext, X.BindCached = + BuildUI, ApplyNextRegistration, ClearNext, BindCached +X.NextBindState = function() return nextWrapped, nextCombatDriver end diff --git a/QUALITY.md b/QUALITY.md index 747b82f..6da1270 100644 --- a/QUALITY.md +++ b/QUALITY.md @@ -70,7 +70,7 @@ are named below as waivers with owners and follow-ups, not hidden. | Robustness (11) | 4 | Pass | SavedVariables migration chain v2→v20 smoke-tested, including corrupt-save replacement and repair of corrupt custom-spell / auto-profile entries; a strict sanitizer rebuilds settings on load; handlers are pcall-wrapped so one bad event can't kill the addon. | | Feature completeness (9) | 4 | Pass | Core purpose complete. The approved 50-item program is **complete** with **nothing parked**: 44 shipped by 1.9.0, three duplicates replaced in-batch (#23, #10, #15), and the three parked items built later (#8 and #19 in 1.14.0, #33 in 1.15.0). Three further suggestion lists are done except one platform limit recorded in `docs/SUGGESTIONS.md` (#13: the game does not let addons auto-cast, so out-of-range players get a notice instead). Not 5: that limit. | | Performance (8) | 4 | Pass (waiver closed 2026-11-16) | Budget defined 2026-11-16 (`docs/DECISIONS.md`) and enforced by the trial run on every push: a worst-case scan (every player missing every buff) reads ≤8 auras per player, grows linearly from 20 to 40 players, and averages <5 ms in the fake client (measured: ~5.75 reads per player, ~0.7 ms for 40 players). Scans are event-driven, coalesced to one per 0.1 s and ticked every 0.4 s; rows are pooled. Not 5: the in-game target (`/br perf` average ≤2 ms, worst ≤8 ms in a 40-player raid) has no field numbers yet. | -| Maintainability (7) | 3 | **Waiver** (minor) | The source is split across nine files (Data, BuffRadar, Coordination, Wizard, Config, Slash, Extras, Recaps, Profiles; 17.3k lines). Slices E and F (2026-11-16) moved coordination and the wizard/diagnostics tools out, so `BuffRadar.lua` dropped from ~9,700 to ~8,000 lines, but it is still above the prompt's file-length target. Lua 5.1 limits are tool-enforced on every file: main chunk 176/200 locals, `HandleSlash` 58/60 upvalues, `Refresh` 50/60. Follow-up: the toggle strip, cast buttons and `BuildUI` (Slice G) are the next feature-sized section; they touch the secure cast path, so they need their own field test. | +| Maintainability (7) | 3 | **Waiver** (minor) | The source is split across ten files (Data, BuffRadar, Coordination, Wizard, Window, Config, Slash, Extras, Recaps, Profiles; 17.4k lines). Slices E, F and G (2026-11-16) moved coordination, the wizard/diagnostics tools and the window builder with its cast buttons out, so `BuffRadar.lua` dropped from ~9,700 to ~7,200 lines, but it is still above the prompt's file-length target and Config.lua is ~4,100. Lua 5.1 limits are tool-enforced on every file: main chunk 165/200 locals, `HandleSlash` 58/60 upvalues, `Refresh` 49/60. The score stays 3 until the split passes a field test and the scan core (who is around, rank selection, Refresh) is the only large block left. Slice G touches the secure cast path, so it needs its own field test. | | Modularity (6) | 3 | Pass | Seven load-ordered files; sections stay one-way (data → scan → render → UI → commands), shared state lives in one `X` registry table, and the split files reach main state only through bridge tables (`X.cfgAPI`, `X.slashAPI`). Every capability is a named slash operation before it is a settings control. Not 4: the bridge tables are a wide coupling surface, checked by review only. | | UX & accessibility (6) | 4 | Pass (waiver closed 2026-11-16) | The UI is complete in code and smoke, and SEAN's in-game field test passed for every release through 1.15.31 on Forever (reported 2026-11-16). Not 5: no accessibility audit beyond the tag-symbol, reduced-motion and text-scale options. | | Scalability (5) | 3 | Pass | Host caps group size (40); scan cost is linear in roster size and throttled; the row pool is capped at 15 with overflow counted on the coverage line. 10x/100x testing is not applicable to a host-capped addon; the cap behaviour is smoke-tested. | diff --git a/README.md b/README.md index a9aa581..cb87ac1 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ BuffRadar has targeted Forever since 1.8.0. The last Retail release was ## Source and Contributions - [Runtime](BuffRadar/BuffRadar.lua), [coordination](BuffRadar/Coordination.lua), - [setup wizard and diagnostics](BuffRadar/Wizard.lua), [settings](BuffRadar/Config.lua), + [setup wizard and diagnostics](BuffRadar/Wizard.lua), [window](BuffRadar/Window.lua), [settings](BuffRadar/Config.lua), [slash commands](BuffRadar/Slash.lua), [profiles](BuffRadar/Profiles.lua), and [translations](BuffRadar/Locales). - [Report a bug or request a feature](https://github.com/SeanShaffer88/BuffRadar/issues/new/choose). diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 184a775..603f8e5 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -296,6 +296,33 @@ split, then Briefs 2, 3, 4 — nothing else built; file-split Slices B 3 -> 4); maintainability stays 3 because `BuffRadar.lua` has grown back to ~9,700 lines. +## 2026-11-16 — File split Slice G (SEAN: "complete next milestone, hold releases") + +- Slice G was the milestone QUALITY.md named. The window builder + (`BuildUI`), toggle strip, filter chips, idle fade, Cast Next / group + buttons with their secure bindings, and the scale / edge drag helpers + moved verbatim into `Window.lua` (about 830 lines), loaded after + `Wizard.lua`. +- `BuildUI` assigns 11 window handles the main file reads everywhere + (frame, title, the text lines, nextBtn, grip, built). Window.lua keeps + its own copies and hands them to the main file through + `X.winAPI.setUI` (`PublishUI()`) right before `CreateRow` and the other + main-file calls, again once the cast buttons exist, and once `built` + is true. The close button writes `sessionShow` through + `setSessionShow`. +- Main-file call sites now go through `X.BuildUI`, `X.ClearNext`, + `X.BindCached` and `X.ApplyNextRegistration`; `/br` state reads the + next-button flags through `X.NextBindState()`. The stray load-time + `X.BindCached = BindCached` line in the main file moved with it. +- `BuffRadar.lua`: 8,017 -> 7,215 lines; main chunk 176 -> 165 locals; + `Refresh` 50 -> 49 upvalues. New trial step: after `X.BuildUI()` the + main file sees `built`, the frame, the grip and the same next-button + flags (mutation-checked: dropping the hand-off fails it and 271 other + steps). +- Releases held at SEAN's request: no version bump, tag or release. The + checklist's "Next release" section covers Slices E-G in game, secure + cast path first. + ## 2026-11-16 — File split Slices E and F (SEAN: "E + F") - Slice E: cast sync, caster coordination, chat buff requests, per-buff diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index 28fe22f..d53f7d5 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -2,9 +2,9 @@ Run this against the exact candidate ZIP after CI passes. Record the version, client build, tester, and pass/fail for each check. Do not mark a build field-tested until the applicable checks pass. -## Next release: file split Slices E and F +## Next release: file split Slices E, F and G -Code moved into `Coordination.lua` and `Wizard.lua`; nothing should look or +Code moved into `Coordination.lua`, `Wizard.lua` and `Window.lua`; nothing should look or behave differently. Check that both files load (no Lua error at login, and `/br selftest` runs) and then: @@ -17,6 +17,14 @@ behave differently. Check that both files load (no Lua error at login, and delete a theme. Run `/br why ` on a nearby player and open the Nearby Player panel with **?**. Check `/br history`, `/br stats` and an export dialog. With alerts on, check that the window border flashes. +- **Window.lua (secure cast path, test this first):** with `/br clicks` on, + buff from a row click, the Cast Next Buff key and Shift-click / the group + key. Check each cast lands on the displayed player and the counter moves + once. Enter and leave combat: rows and both buttons disarm and rebind. + Toggle a buff on the strip, use a role chip, let the window idle-fade, + drag the scale grips and edges, and close the window with its button (it + stays hidden until reopened). Run `/reload` and check the window returns + where it was. ## 1.15.33 Input hardening diff --git a/docs/RISK_MATRIX.md b/docs/RISK_MATRIX.md index 81de695..04b3c3a 100644 --- a/docs/RISK_MATRIX.md +++ b/docs/RISK_MATRIX.md @@ -98,7 +98,7 @@ passes, and the last one covered releases through 1.15.33. | F1 | Runtime error inside a scan | List stops updating | `SafeRefresh` wraps the scan in `pcall`; the error is printed once, not per frame | robustness fuzz | Covered | | F2 | Cast fails (line of sight, range, invalid target) | Queue stuck on one player | Target-failure messages skip that player for 30 s; other errors stay pending | range and invalid-target failures skip the current player; empty-state steps | Covered | | F3 | Roster changes between render and key press | Buffs the wrong person | Slot occupant check clears a stale binding | 1.15.31 checklist; cast-next steps | Covered | -| F4 | Lua 5.1 local or upvalue ceilings | Addon fails to load after an edit | `tools/lualimits.py` in the gate | gate | Covered (main chunk 176/200, `HandleSlash` 58/60 upvalues) | +| F4 | Lua 5.1 local or upvalue ceilings | Addon fails to load after an edit | `tools/lualimits.py` in the gate | gate | Covered (main chunk 165/200, `HandleSlash` 58/60 upvalues) | | F5 | Locale string with a mismatched placeholder | `string.format` error | `localecheck` checks placeholder parity | gate | Covered | | F6 | Package missing a file or in the wrong load order | Addon broken on install | `checkpackage.py` loads the ZIP in TOC order; release assets hash-verified after upload | gate; release workflow | Covered | | F7 | Chat send refused (throttle or channel) | Silent report failure | Send result checked; 255-byte cap | group reports respect ignored players and chat refusal | Covered | diff --git a/editions/forever/BuffRadar.toc b/editions/forever/BuffRadar.toc index de4994e..1023650 100644 --- a/editions/forever/BuffRadar.toc +++ b/editions/forever/BuffRadar.toc @@ -17,6 +17,7 @@ Data.lua BuffRadar.lua Coordination.lua Wizard.lua +Window.lua Config.lua Slash.lua Extras.lua diff --git a/tools/check.ps1 b/tools/check.ps1 index 0297927..c8b1001 100644 --- a/tools/check.ps1 +++ b/tools/check.ps1 @@ -60,7 +60,7 @@ function Section($name) { Write-Host "`n== $name" } # 1. luacheck: accidental globals, unused or shadowed variables, unreachable code Section 'luacheck' Push-Location $project -try { & $luacheck 'BuffRadar\Data.lua' 'BuffRadar\BuffRadar.lua' 'BuffRadar\Coordination.lua' 'BuffRadar\Wizard.lua' 'BuffRadar\Config.lua' 'BuffRadar\Slash.lua' 'BuffRadar\Extras.lua' 'BuffRadar\Recaps.lua' 'BuffRadar\Profiles.lua' 'BuffRadar\Locales' --no-color --codes; if ($LASTEXITCODE -ne 0) { $failed += 'luacheck' } } +try { & $luacheck 'BuffRadar\Data.lua' 'BuffRadar\BuffRadar.lua' 'BuffRadar\Coordination.lua' 'BuffRadar\Wizard.lua' 'BuffRadar\Window.lua' 'BuffRadar\Config.lua' 'BuffRadar\Slash.lua' 'BuffRadar\Extras.lua' 'BuffRadar\Recaps.lua' 'BuffRadar\Profiles.lua' 'BuffRadar\Locales' --no-color --codes; if ($LASTEXITCODE -ne 0) { $failed += 'luacheck' } } finally { Pop-Location } # 2. Compile with real Lua 5.1 (the language WoW runs) diff --git a/tools/gate.sh b/tools/gate.sh index 4790403..2a2eab5 100644 --- a/tools/gate.sh +++ b/tools/gate.sh @@ -12,7 +12,7 @@ for candidate in python3 python; do if "$candidate" -c "import sys" >/dev/null 2>&1; then PY=$candidate; break; fi done [ -n "$PY" ] || { echo "No working python3 or python found."; exit 1; } -LUA="BuffRadar/Data.lua BuffRadar/BuffRadar.lua BuffRadar/Coordination.lua BuffRadar/Wizard.lua BuffRadar/Config.lua BuffRadar/Slash.lua BuffRadar/Extras.lua BuffRadar/Recaps.lua BuffRadar/Profiles.lua" +LUA="BuffRadar/Data.lua BuffRadar/BuffRadar.lua BuffRadar/Coordination.lua BuffRadar/Wizard.lua BuffRadar/Window.lua BuffRadar/Config.lua BuffRadar/Slash.lua BuffRadar/Extras.lua BuffRadar/Recaps.lua BuffRadar/Profiles.lua" LOC="$(ls BuffRadar/Locales/*.lua)" echo "== luacheck51"; "$PY" -I tools/luacheck51.py $LUA $LOC echo "== lualimits"; for f in $LUA; do "$PY" -I tools/lualimits.py "$f"; done diff --git a/tools/smoke51.py b/tools/smoke51.py index 15e2054..5d82707 100644 --- a/tools/smoke51.py +++ b/tools/smoke51.py @@ -12,7 +12,7 @@ lua = lua51.LuaRuntime(unpack_returned_tuples=True) lua.execute(open(stub_path, encoding="utf-8").read()) -harness = lua.eval(r"""function(addonSrc, withTimer, noTemplates, forever, german, localeSrc, extrasSrc, dataSrc, configSrc, slashSrc, recapsSrc, profilesSrc, coordSrc, wizardSrc) +harness = lua.eval(r"""function(addonSrc, withTimer, noTemplates, forever, german, localeSrc, extrasSrc, dataSrc, configSrc, slashSrc, recapsSrc, profilesSrc, coordSrc, wizardSrc, windowSrc) local chat = {} local env = WOWSTUB(chat, withTimer, noTemplates, forever, german) local unitIsUnit = env.UnitIsUnit @@ -91,7 +91,7 @@ end) end step("load file (main chunk)", function() chunk("BuffRadar", NS) end) --- File split Slices E and F (1.15.34) load straight after the main file (.toc order). +-- File split Slices E, F and G (1.15.34) load straight after the main file (.toc order). if coordSrc then step("load Coordination.lua", function() local och = assert(loadstring(coordSrc, "=Coordination.lua")) @@ -108,6 +108,15 @@ assert(NS.X.WizardPage, "Wizard.lua did not publish its entry points") end) end +if windowSrc then + step("load Window.lua", function() + local gch = assert(loadstring(windowSrc, "=Window.lua")) + setfenv(gch, env) + gch("BuffRadar", NS) + assert(NS.X.BuildUI and NS.X.ClearNext and NS.X.BindCached and NS.X.NextBindState, + "Window.lua did not publish its entry points") + end) +end if configSrc then step("load Config.lua", function() local cch = assert(loadstring(configSrc, "=Config.lua")) @@ -8106,6 +8115,16 @@ assert(type(text) == "string" and text:find("Splitcheck", 1, true), "Wizard.lua does not read the live settings table") assert(X.coordAPI.nEntries() == X.wizAPI.nEntries(), "list-length accessors disagree") end) +step("Window.lua hands the window back to the main file (Slice G)", function() + local X = NS.X + X.BuildUI() + local st = X.slashAPI.getState() + assert(st.built == true, "main file does not see the window as built") + assert(st.frame and st.frame == env.BuffRadarFrame and X.GetFrame() == st.frame, "main file did not receive the window frame") + assert(st.grip, "main file did not receive the resize grip") + local wrapped, driver = X.NextBindState() + assert(st.nextWrapped == wrapped and st.nextCombatDriver == driver, "next-button state differs between files") +end) step("right-click a row (ignore path)", function() local row = env.BuffRadarRow1 row.entry = { name = "Testshaman", fullName = "Testshaman-TestRealm", missing = { "Skyfury" }, unit = "player" } @@ -8134,6 +8153,8 @@ co_src = open(co_path, encoding="utf-8").read() if os.path.exists(co_path) else None wz_path = os.path.join(os.path.dirname(os.path.abspath(addon_path)), "Wizard.lua") wz_src = open(wz_path, encoding="utf-8").read() if os.path.exists(wz_path) else None +wn_path = os.path.join(os.path.dirname(os.path.abspath(addon_path)), "Window.lua") +wn_src = open(wn_path, encoding="utf-8").read() if os.path.exists(wn_path) else None sl_src = open(sl_path, encoding="utf-8").read() if os.path.exists(sl_path) else None setups = [ ("Retail: modern client (C_Timer, UI templates)", True, False, False, False), @@ -8146,7 +8167,7 @@ setups.append(("Retail: German client (Locales/deDE.lua)", True, False, False, True)) failed = False for label, with_timer, no_templates, forever, german in setups: - results, chat = harness(src, with_timer, no_templates, forever, german, de_src if german else None, ex_src, da_src, cf_src, sl_src, rc_src, pf_src, co_src, wz_src) + results, chat = harness(src, with_timer, no_templates, forever, german, de_src if german else None, ex_src, da_src, cf_src, sl_src, rc_src, pf_src, co_src, wz_src, wn_src) bad = 0 for i in range(1, len(results) + 1): name, status = results[i][1], results[i][2] From 10f064e0154b3e7967b1112f297e59683d871d66 Mon Sep 17 00:00:00 2001 From: Sean Shaffer Date: Mon, 16 Nov 2026 06:23:58 -0600 Subject: [PATCH 4/5] Give list rows a subtle theme-coloured hover highlight Rows used the bright yellow quest-title glow on hover. They now show a flat ADD-blended wash in the theme's border colour at 15% alpha, set when a row is built and re-tinted by ApplyAppearance on theme changes. The fake client keeps button highlight textures so a trial step can check the colour, the alpha and a theme switch. Co-Authored-By: Claude Opus 5.5 --- BuffRadar/BuffRadar.lua | 16 +++++++++++++++- docs/DECISIONS.md | 17 +++++++++++++++++ docs/FOREVER_RELEASE_CHECKLIST.md | 5 +++++ editions/forever/CHANGELOG.md | 8 ++++++++ editions/forever/FEATURES.md | 3 ++- tools/smoke51.py | 21 +++++++++++++++++++++ tools/wowstub.lua | 7 ++++++- 7 files changed, 74 insertions(+), 3 deletions(-) diff --git a/BuffRadar/BuffRadar.lua b/BuffRadar/BuffRadar.lua index 1798b3a..ec9f7f3 100644 --- a/BuffRadar/BuffRadar.lua +++ b/BuffRadar/BuffRadar.lua @@ -4962,6 +4962,18 @@ function X.RowWheel(_, delta) if delta ~= 0 then X.ScrollRows(delta < 0 and 1 or -1) end end +-- Row hover highlight (1.15.34): a faint wash in the theme's border colour +-- instead of the bright quest-title glow. The engine shows a button's +-- highlight texture only while the mouse is over it, so no script is +-- needed; ApplyAppearance re-tints every row when the theme changes. +X.ROW_HOVER_ALPHA = 0.15 +function X.TintRowHover(b) + local hl = b and b.GetHighlightTexture and b:GetHighlightTexture() + if not hl or not hl.SetVertexColor then return end + local bc = X.ThemeBorder() + hl:SetVertexColor(bc[1], bc[2], bc[3], X.ROW_HOVER_ALPHA) +end + local function CreateRow(i) local b = CreateFrame("Button", "BuffRadarRow" .. i, frame, "SecureActionButtonTemplate,SecureHandlerStateTemplate") @@ -4976,7 +4988,8 @@ local function CreateRow(i) else b:RegisterForClicks("AnyUp", "AnyDown") end - b:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD") + b:SetHighlightTexture("Interface\\Buttons\\WHITE8X8", "ADD") + X.TintRowHover(b) -- Right-click only ignores (see the OnClick hook below). Bind() sets the plain -- "type" attribute, which the secure template uses for EVERY mouse button -- unless a button-specific one exists; this "type2" override is a made-up @@ -5289,6 +5302,7 @@ local function ApplyAppearance() frame:SetBackdropColor(c[1], c[2], c[3], db.bgAlpha or 0.92) frame:SetBackdropBorderColor(bc[1], bc[2], bc[3], db.showBorder and 1 or 0) end + for i = 1, #rows do X.TintRowHover(rows[i]) end if X.pill and X.pill.SetBackdropColor then X.pill:SetBackdropColor(c[1], c[2], c[3], db.bgAlpha or 0.92) X.pill:SetBackdropBorderColor(bc[1], bc[2], bc[3], db.showBorder and 1 or 0) diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index 603f8e5..bda96a4 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -296,6 +296,23 @@ split, then Briefs 2, 3, 4 — nothing else built; file-split Slices B 3 -> 4); maintainability stays 3 because `BuffRadar.lua` has grown back to ~9,700 lines. +## 2026-11-16 — Subtle row hover highlight (SEAN) + +- Rows already highlighted on hover, with the game's quest-title glow: a + bright yellow wash that ignored the theme. It is now a flat texture + (`Interface\Buttons\WHITE8X8`, ADD blend) tinted with the theme's border + colour at 15% (`X.ROW_HOVER_ALPHA`). `X.TintRowHover` sets it when a row + is built; `ApplyAppearance` re-tints every row when the theme changes. +- Not a setting: a styling change with no on/off case, so no `dbVersion` + bump and no `/br` command. The engine shows the highlight only while the + mouse is over the row, so no OnEnter/OnLeave scripts were added to the + secure buttons. +- Forever 1.60.1.70755 Texture API (wow-addon-api): `SetVertexColor` and + `SetBlendMode` are not protected; both run only out of combat here + (row build, and `ApplyAppearance` defers in combat). +- Trial step added; the stub's buttons now keep their highlight texture. + Unverified in game. + ## 2026-11-16 — File split Slice G (SEAN: "complete next milestone, hold releases") - Slice G was the milestone QUALITY.md named. The window builder diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index d53f7d5..4ca9d0a 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -25,6 +25,11 @@ behave differently. Check that both files load (no Lua error at login, and drag the scale grips and edges, and close the window with its button (it stays hidden until reopened). Run `/reload` and check the window returns where it was. +- **Row hover highlight:** move the mouse over names in the list. Each row + should light with a faint wash in the theme's border colour (no yellow + glow), and only while the mouse is on it. Switch theme, including Auto + with a UI suite loaded, and check the wash follows. With click-through + on and the window locked, rows should not highlight. ## 1.15.33 Input hardening diff --git a/editions/forever/CHANGELOG.md b/editions/forever/CHANGELOG.md index 5c88d06..af4c81e 100644 --- a/editions/forever/CHANGELOG.md +++ b/editions/forever/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to BuffRadar are listed here. Newest first. +## Unreleased — WoW: Forever + +- Hovering a name now lights its row with a faint wash in your theme's + border colour, replacing the bright yellow glow. +- Move coordination code into `Coordination.lua`, the setup wizard and + diagnostics tools into `Wizard.lua`, and the window, toggle strip and + cast buttons into `Window.lua`. Nothing else changes. + ## 1.15.33 — WoW: Forever - Keep the list updating when the game refuses to read one player's name, diff --git a/editions/forever/FEATURES.md b/editions/forever/FEATURES.md index 5d57e5c..afc6f26 100644 --- a/editions/forever/FEATURES.md +++ b/editions/forever/FEATURES.md @@ -257,7 +257,8 @@ each needs in-game evidence or a sharper definition, recorded in ## Buffing - **Click-to-buff.** Click a name to buff that player; hovering a - name shows exactly what will be cast and what they still need. + name lights its row with a faint wash in the theme's border colour + and shows exactly what will be cast and what they still need. Since 1.3.2, buffing a group member no longer changes your target; for anyone else, BuffRadar targets them by name, casts, then switches back to your previous target. diff --git a/tools/smoke51.py b/tools/smoke51.py index 5d82707..02eb6ba 100644 --- a/tools/smoke51.py +++ b/tools/smoke51.py @@ -8115,6 +8115,27 @@ assert(type(text) == "string" and text:find("Splitcheck", 1, true), "Wizard.lua does not read the live settings table") assert(X.coordAPI.nEntries() == X.wizAPI.nEntries(), "list-length accessors disagree") end) +step("row hover highlight is a faint theme-coloured wash", function() + local X, db = NS.X, NS.X.GetDB() + X.BuildUI() + local row = env.BuffRadarRow1 + local hl = row and row:GetHighlightTexture() + assert(hl, "row has no hover highlight") + assert(hl.file == "Interface\\Buttons\\WHITE8X8" and hl.blend == "ADD", "hover highlight is not the flat wash") + local function matches() + local bc, c = X.ThemeBorder(), hl.vcolor + return c and c[1] == bc[1] and c[2] == bc[2] and c[3] == bc[3] and c[4] == X.ROW_HOVER_ALPHA + end + assert(matches(), "hover highlight does not use the theme border colour") + assert(X.ROW_HOVER_ALPHA > 0 and X.ROW_HOVER_ALPHA <= 0.2, "hover highlight is not subtle") + local saved = db.theme + db.theme = (saved == "crimson") and "forest" or "crimson" + X.ApplyAppearance() + local followed = matches() and hl.vcolor[1] == X.THEMES[db.theme].border[1] + db.theme = saved + X.ApplyAppearance() + assert(followed, "hover highlight did not follow a theme change") +end) step("Window.lua hands the window back to the main file (Slice G)", function() local X = NS.X X.BuildUI() diff --git a/tools/wowstub.lua b/tools/wowstub.lua index 7288ece..530ba1c 100644 --- a/tools/wowstub.lua +++ b/tools/wowstub.lua @@ -94,7 +94,12 @@ function WOWSTUB(chat, withTimer, noTemplates, forever, german) function methods.SetWidth(self, w) self.width = w end function methods.SetSize(self, w, h) self.size = { w, h } end function methods.SetFrameStrata(self, s) self.strata = s end - function methods.SetVertexColor(self, r, g, b) self.vcolor = { r, g, b } end + function methods.SetVertexColor(self, r, g, b, a) self.vcolor = { r, g, b, a } end + function methods.SetHighlightTexture(self, file, blend) + self.highlight = newObject("Texture") + self.highlight.file, self.highlight.blend = file, blend + end + function methods.GetHighlightTexture(self) return self.highlight end function methods.EnableMouse(self, v) self.mouseEnabled = v end function methods.EnableMouseWheel(self, v) self.wheelEnabled = v end function methods.IsMouseWheelEnabled(self) return not not self.wheelEnabled end From ee8d5c7c0740207470b6e813b4dfeb277342d4b1 Mon Sep 17 00:00:00 2001 From: Sean Shaffer Date: Mon, 16 Nov 2026 06:56:20 -0600 Subject: [PATCH 5/5] Prepare BuffRadar 1.15.34 for WoW: Forever Bump the Forever TOC to 1.15.34 (file split Slices E-G and the subtle row hover highlight), title its changelog and field checklist, and mark 1.15.34 as Unverified in game in FEATURES, PARITY, QUALITY and the risk matrix. Co-Authored-By: Claude Opus 5.5 --- QUALITY.md | 3 ++- docs/FOREVER_RELEASE_CHECKLIST.md | 2 +- docs/PARITY.md | 3 ++- docs/RISK_MATRIX.md | 3 ++- editions/forever/BuffRadar.toc | 2 +- editions/forever/CHANGELOG.md | 2 +- editions/forever/FEATURES.md | 3 ++- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/QUALITY.md b/QUALITY.md index 6da1270..0cf93b5 100644 --- a/QUALITY.md +++ b/QUALITY.md @@ -50,7 +50,8 @@ Re-checked on 2026-11-16 after SEAN reported that every release through 2→4 and Correctness 4→5, as this scorecard set out; **total 69→74**. Multi-user coordination is covered by that report. 1.15.32 (Shadowguard watch) and 1.15.33 (input hardening) passed their checklist -steps in game later the same day (SEAN); no score changes. +steps in game later the same day (SEAN); no score changes. 1.15.34 (file +split Slices E–G, subtle row hover highlight) is Unverified in game. Re-scored the same day against the current tree (1.15.32): stale rows that still described the single-file layout, the parked items and the 1.10.0 corpus were brought up to date. Feature completeness 3→4 (program done, diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index 4ca9d0a..a30a747 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -2,7 +2,7 @@ Run this against the exact candidate ZIP after CI passes. Record the version, client build, tester, and pass/fail for each check. Do not mark a build field-tested until the applicable checks pass. -## Next release: file split Slices E, F and G +## 1.15.34 File split (Slices E, F and G) and row hover highlight Code moved into `Coordination.lua`, `Wizard.lua` and `Window.lua`; nothing should look or behave differently. Check that both files load (no Lua error at login, and diff --git a/docs/PARITY.md b/docs/PARITY.md index 8e2bf7c..231bd38 100644 --- a/docs/PARITY.md +++ b/docs/PARITY.md @@ -12,7 +12,8 @@ further SEAN-requested customization batch (10 items) shipped in evidence. In-game status: **1.12.0 verified by SEAN on Forever 1.60.1.70862** (2026-11-08), and SEAN reported on 2026-11-16 that every release through **1.15.31** passed in game; 1.15.32 (Shadowguard watch) -and 1.15.33 (input hardening) passed the same day. +and 1.15.33 (input hardening) passed the same day. 1.15.34 (file split, +row hover highlight) is Unverified. | Area | Target | State | Evidence (test / corpus) | Gap | |---|---|---|---|---| diff --git a/docs/RISK_MATRIX.md b/docs/RISK_MATRIX.md index 04b3c3a..43d290d 100644 --- a/docs/RISK_MATRIX.md +++ b/docs/RISK_MATRIX.md @@ -149,7 +149,8 @@ passes, and the last one covered releases through 1.15.33. - **Fake client:** taint, real frame timing, server-side addon-message throttling and real secret-value behaviour can't be reproduced offline. A passing gate is evidence, not proof. -- **In-game verification:** releases through 1.15.33 are field-verified. +- **In-game verification:** releases through 1.15.33 are field-verified; + 1.15.34 is Unverified in game. - **Fuzzing is sampled:** about 1,000 inputs per parser, 3,000 messages, 1,500 commands, 250 corrupt saves and 200 API-chaos rounds per setup. It finds shallow-to-medium defects; it can't prove their absence. The diff --git a/editions/forever/BuffRadar.toc b/editions/forever/BuffRadar.toc index 1023650..8f1fe52 100644 --- a/editions/forever/BuffRadar.toc +++ b/editions/forever/BuffRadar.toc @@ -2,7 +2,7 @@ ## Title: |cff33ccffBuff|rRadar ## Notes: Clickable list of in-range players who can benefit from your buffs. Click a name, press a key or use a macro to buff them. ## Author: Malikor -## Version: 1.15.33 +## Version: 1.15.34 ## SavedVariables: BuffRadarDB ## IconTexture: Interface\AddOns\BuffRadar\Media\icon.png ## Category: Combat diff --git a/editions/forever/CHANGELOG.md b/editions/forever/CHANGELOG.md index af4c81e..f0aa2d3 100644 --- a/editions/forever/CHANGELOG.md +++ b/editions/forever/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to BuffRadar are listed here. Newest first. -## Unreleased — WoW: Forever +## 1.15.34 — WoW: Forever - Hovering a name now lights its row with a faint wash in your theme's border colour, replacing the bright yellow glow. diff --git a/editions/forever/FEATURES.md b/editions/forever/FEATURES.md index afc6f26..3ac68b0 100644 --- a/editions/forever/FEATURES.md +++ b/editions/forever/FEATURES.md @@ -377,7 +377,8 @@ stays hidden on those characters. **Field test through 1.15.33:** on 2026-11-16 the maintainer reported that every release up to and including 1.15.31 passed in-game testing in WoW: Forever, and later that day that 1.15.32 (Shadowguard watch) and 1.15.33 -(input hardening) passed their checklist steps too. +(input hardening) passed their checklist steps too. 1.15.34 (source +file split and the row hover highlight) is not yet verified in game. **Current stable release:** 1.15.16. The maintainer confirmed live verification in WoW: Forever on 2026-11-14 using field-test build `d05115bdb03d`.