From 62c4606b8da69ddaf286b083ff95ee3959a7c389 Mon Sep 17 00:00:00 2001 From: SeanShaffer88 <252387677+SeanShaffer88@users.noreply.github.com> Date: Wed, 18 Nov 2026 23:28:41 +0000 Subject: [PATCH] Add BuffRadar readiness checks, forecasts, and Quick Setup Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- .luacheckrc | 1 + AGENTS.md | 3 +- BuffRadar/BuffRadar.lua | 569 ++++++++++++++++++++---------- BuffRadar/BuffRadar.toc | 4 + BuffRadar/Config.lua | 228 ++++++++++-- BuffRadar/Coordination.lua | 23 +- BuffRadar/Debuffs.lua | 257 ++++++++++++++ BuffRadar/Extras.lua | 72 ++-- BuffRadar/Intelligence.lua | 300 ++++++++++++++++ BuffRadar/Locales/deDE.lua | 119 +++++++ BuffRadar/Minimap.lua | 70 +++- BuffRadar/Profiles.lua | 20 +- BuffRadar/Readiness.lua | 133 +++++++ BuffRadar/Recaps.lua | 22 +- BuffRadar/SavedVariables.lua | 71 +++- BuffRadar/Slash.lua | 29 +- BuffRadar/Status.lua | 133 +++++++ BuffRadar/Window.lua | 19 +- BuffRadar/Wizard.lua | 180 +++++----- QUALITY.md | 4 +- README.md | 35 +- docs/DECISIONS.md | 11 + docs/FOREVER_RELEASE_CHECKLIST.md | 26 ++ docs/PARITY.md | 7 +- docs/ROADMAP.md | 13 + docs/STATUS_API.md | 60 ++++ docs/SUGGESTIONS.md | 7 + editions/forever/BuffRadar.toc | 4 + editions/forever/CHANGELOG.md | 14 + editions/forever/DESCRIPTION.md | 8 + editions/forever/FEATURES.md | 19 + editions/forever/README.md | 27 +- tools/smoke51.py | 529 ++++++++++++++++++++++++--- tools/wowstub.lua | 1 + 34 files changed, 2564 insertions(+), 454 deletions(-) create mode 100644 BuffRadar/Debuffs.lua create mode 100644 BuffRadar/Intelligence.lua create mode 100644 BuffRadar/Readiness.lua create mode 100644 BuffRadar/Status.lua create mode 100644 docs/ROADMAP.md create mode 100644 docs/STATUS_API.md diff --git a/.luacheckrc b/.luacheckrc index 5a8c4ef..5658d30 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -8,6 +8,7 @@ max_line_length = false -- reported: that catches accidental globals, like the RefreshMinimapButton -- leak fixed in 1.3.2. These are the globals BuffRadar is meant to create: globals = { + "BuffRadarAPI", -- versioned read-only integration "BuffRadarDB", -- saved variables (.toc) "BuffRadar_ToggleWindow", "BuffRadar_ToggleSound", -- called by Bindings.xml "SLASH_BUFFRADAR1", "SLASH_BUFFRADAR2", -- /br, /buffradar diff --git a/AGENTS.md b/AGENTS.md index 602d16d..4f5e30e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,8 +14,9 @@ module communication. `Data.lua` initializes the addon namespace, `SavedVariable owns the schema and publishes the live DB, `BuffRadar.lua` owns scanning and cast decisions, and `Window.lua` and `Minimap.lua` own their frames and caches. Keep implementation state local and share entry points through the addon table. +`BuffRadarAPI` is a versioned, read-only external interface, not a module bridge. Every feature is reachable through `/br` as well as through its settings control -where it has one. SavedVariables are versioned (`dbVersion`, currently 21) with +where it has one. SavedVariables are versioned (`dbVersion`, currently 22) with migration smoke fixtures; keep those fixtures in sync with format changes. Build: none (interpreted Lua 5.1). diff --git a/BuffRadar/BuffRadar.lua b/BuffRadar/BuffRadar.lua index 2b3aad9..1105d9f 100644 --- a/BuffRadar/BuffRadar.lua +++ b/BuffRadar/BuffRadar.lua @@ -553,6 +553,126 @@ local L = { ["Left-click: show / hide the window"] = "Left-click: show / hide the window", ["Right-click: settings"] = "Right-click: settings", ["Drag: move around the minimap"] = "Drag: move around the minimap", + -- Readiness, forecasts and Quick Setup. + ["%d broken · Lowest %d%%"] = "%d broken · Lowest %d%%", + ["%d cast targets · %d forecast buffs"] = "%d cast targets · %d forecast buffs", + ["%d ms"] = "%d ms", + ["Active pet"] = "Active pet", + ["Adaptive scan throttle"] = "Adaptive scan throttle", + ["Adaptive scan throttle: %s"] = "Adaptive scan throttle: %s", + ["An instance ID is required."] = "An instance ID is required.", + ["Apply here"] = "Apply here", + ["Briefly highlight the window or minimap without sound. Respects Reduced Motion."] = "Briefly highlight the window or minimap without sound. Respects Reduced Motion.", + ["Buff coverage could not be verified"] = "Buff coverage could not be verified", + ["Buff intelligence"] = "Buff intelligence", + ["Buff scan paused"] = "Buff scan paused", + ["Buff scan paused in combat"] = "Buff scan paused in combat", + ["Buff scan paused while dead"] = "Buff scan paused while dead", + ["BuffRadar memory: %.0f KB (game-reported total)."] = "BuffRadar memory: %.0f KB (game-reported total).", + ["BuffRadar memory: unavailable on this client."] = "BuffRadar memory: unavailable on this client.", + ["Buffs need attention"] = "Buffs need attention", + ["Checked buffs are covered"] = "Checked buffs are covered", + ["Choose your activity and role, then review the suggested settings. /br wizard"] = "Choose your activity and role, then review the suggested settings. /br wizard", + ["Consumable aura ID (0 = off)"] = "Consumable aura ID (0 = off)", + ["Copy buff status"] = "Copy buff status", + ["Copy the current buff status"] = "Copy the current buff status", + ["Copy the feedback link and open it in your browser."] = "Copy the feedback link and open it in your browser.", + ["Debuff rule saved."] = "Debuff rule saved.", + ["Debuff watch is paused in Lite mode."] = "Debuff watch is paused in Lite mode.", + ["Debuff watch limit reached."] = "Debuff watch limit reached.", + ["Debuff watch: %s"] = "Debuff watch: %s", + ["Dungeons / Mythic+"] = "Dungeons / Mythic+", + ["Enable forecasts before setting a timer."] = "Enable forecasts before setting a timer.", + ["Encounter %d"] = "Encounter %d", + ["Encounter ID (optional)"] = "Encounter ID (optional)", + ["Encounter debuffs"] = "Encounter debuffs", + ["Enter a consumable aura spell ID, or 0 to clear it."] = "Enter a consumable aura spell ID, or 0 to clear it.", + ["Enter a forecast time from 0 to 300 seconds (0 turns it off)."] = "Enter a forecast time from 0 to 300 seconds (0 turns it off).", + ["Equipment durability"] = "Equipment durability", + ["Feedback"] = "Feedback", + ["Focus"] = "Focus", + ["Forecast lead: %ds (0 = off)."] = "Forecast lead: %ds (0 = off).", + ["Forecast seconds (0 = off)"] = "Forecast seconds (0 = off)", + ["Forecast: %s on %s expires in %ds."] = "Forecast: %s on %s expires in %ds.", + ["Forecasts are paused in Lite mode."] = "Forecasts are paused in Lite mode.", + ["Healthstone in bags"] = "Healthstone in bags", + ["Important buff missing or expiring"] = "Important buff missing or expiring", + ["Instance %d: %s"] = "Instance %d: %s", + ["Instance rule limit reached."] = "Instance rule limit reached.", + ["Lite mode"] = "Lite mode", + ["Lite mode: %s"] = "Lite mode: %s", + ["Local preparation timer: %ds."] = "Local preparation timer: %ds.", + ["Lowest %d%%"] = "Lowest %d%%", + ["Memory usage"] = "Memory usage", + ["Minimap status: %s"] = "Minimap status: %s", + ["Missing"] = "Missing", + ["Most buffs needed"] = "Most buffs needed", + ["Name"] = "Name", + ["New to BuffRadar? Run /br wizard for Quick Setup."] = "New to BuffRadar? Run /br wizard for Quick Setup.", + ["No applicable buffs to check"] = "No applicable buffs to check", + ["No aura configured"] = "No aura configured", + ["No debuffs are being tracked."] = "No debuffs are being tracked.", + ["No durable equipment"] = "No durable equipment", + ["No instance priority rules saved."] = "No instance priority rules saved.", + ["No missing coating"] = "No missing coating", + ["Open personal checks"] = "Open personal checks", + ["Optional consumable"] = "Optional consumable", + ["Order: %s · Forecast: %ds (0 = off)"] = "Order: %s · Forecast: %ds (0 = off)", + ["Pause the checklist, forecasts, debuffs and optional aura watches without changing their settings."] = "Pause the checklist, forecasts, debuffs and optional aura watches without changing their settings.", + ["Performance & alerts"] = "Performance & alerts", + ["Periodic scan: %.1fs · Latency: %s"] = "Periodic scan: %.1fs · Latency: %s", + ["Personal"] = "Personal", + ["Personal consumable aura ID: %d (0 = off)."] = "Personal consumable aura ID: %d (0 = off).", + ["Player"] = "Player", + ["Present"] = "Present", + ["Press Enter to save."] = "Press Enter to save.", + ["Priority buff key for this instance"] = "Priority buff key for this instance", + ["Promote buffs for tanks, healers, recovery and your instance rules without changing eligibility."] = "Promote buffs for tanks, healers, recovery and your instance rules without changing eligibility.", + ["Queue rows: %d · Saved casts: %d · Debuff rules: %d"] = "Queue rows: %d · Saved casts: %d · Debuff rules: %d", + ["Quick Setup"] = "Quick Setup", + ["Quick Setup complete. Run /br wizard to make new choices."] = "Quick Setup complete. Run /br wizard to make new choices.", + ["Quick Setup is unavailable in combat."] = "Quick Setup is unavailable in combat.", + ["Quick Setup · Step %d of 3"] = "Quick Setup · Step %d of 3", + ["Quiet alerts and the minimap status are enabled. Buff selections and keybinds are kept."] = "Quiet alerts and the minimap status are enabled. Buff selections and keybinds are kept.", + ["Quiet visual alerts"] = "Quiet visual alerts", + ["Raid Preparation is available in WoW: Forever."] = "Raid Preparation is available in WoW: Forever.", + ["Raid Preparation is paused in Lite mode."] = "Raid Preparation is paused in Lite mode.", + ["Raids"] = "Raids", + ["Readiness"] = "Readiness", + ["Remove"] = "Remove", + ["Repair recommended"] = "Repair recommended", + ["Group only: %s · Group casts: %s · Pause in cities: %s"] = "Group only: %s · Group casts: %s · Pause in cities: %s", + ["Save watch"] = "Save watch", + ["Shift-right-click: Quick Setup"] = "Shift-right-click: Quick Setup", + ["Show watched debuffs"] = "Show watched debuffs", + ["Slow periodic scans at rest or with high latency. Event refreshes stay responsive."] = "Slow periodic scans at rest or with high latency. Event refreshes stay responsive.", + ["Smart buff priority"] = "Smart buff priority", + ["Smart priority: %s"] = "Smart priority: %s", + ["Solo play"] = "Solo play", + ["Some buff coverage could not be verified"] = "Some buff coverage could not be verified", + ["Some slots unknown"] = "Some slots unknown", + ["Soulwell availability cannot be checked."] = "Soulwell availability cannot be checked.", + ["Spell ID"] = "Spell ID", + ["Status on the minimap"] = "Status on the minimap", + ["Tanks first"] = "Tanks first", + ["Temporary weapon coating"] = "Temporary weapon coating", + ["That debuff is not on the watch list."] = "That debuff is not on the watch list.", + ["The game does not report memory by feature."] = "The game does not report memory by feature.", + ["Track up to eight harmful spell IDs on you or your focus, when the client exposes them."] = "Track up to eight harmful spell IDs on you or your focus, when the client exposes them.", + ["Use /br debuff on|off|list, add [player|focus] [encounter ID], or remove [player|focus]."] = "Use /br debuff on|off|list, add [player|focus] [encounter ID], or remove [player|focus].", + ["Use /br forecast timer <1-600|off>."] = "Use /br forecast timer <1-600|off>.", + ["Use /br readiness [personal|show|hide|next|prev] or aura ."] = "Use /br readiness [personal|show|hide|next|prev] or aura .", + ["Use /br smartprio [on|off|list], here , or instance ."] = "Use /br smartprio [on|off|list], here , or instance .", + ["Use a buff key from /br buffs."] = "Use a buff key from /br buffs.", + ["Use a key from /br buffs. Clear the field to remove the rule."] = "Use a key from /br buffs. Clear the field to remove the rule.", + ["Use a valid debuff spell ID, player or focus, and an optional encounter ID."] = "Use a valid debuff spell ID, player or focus, and an optional encounter ID.", + ["Visual alerts: %s"] = "Visual alerts: %s", + ["Waiting for a fresh buff scan"] = "Waiting for a fresh buff scan", + ["Watch unit"] = "Watch unit", + ["What do you play most often?"] = "What do you play most often?", + ["What is your primary role?"] = "What is your primary role?", + ["Your character only"] = "Your character only", + ["Your supported buffs: %s"] = "Your supported buffs: %s", } setmetatable(L, { __index = function(_, k) return k end }) do @@ -622,25 +742,15 @@ end end -- spellbook readers block local function InRaid() - if IsInRaid then return IsInRaid() end - return GetNumRaidMembers and GetNumRaidMembers() > 0 + local inRaid = X.ReadUnitBool(IsInRaid) + if inRaid ~= nil then return inRaid end + return (X.ReadUnitNumber(GetNumRaidMembers) or 0) > 0 end local function InGroup() - if IsInGroup then - local ok, v = pcall(IsInGroup) - if ok and v then return true end - end - if InRaid() then return true end - if GetNumGroupMembers then - local ok, n = pcall(GetNumGroupMembers) - if ok and type(n) == "number" and n > 0 then return true end - end - if GetNumPartyMembers then - local ok, n = pcall(GetNumPartyMembers) - if ok and type(n) == "number" and n > 0 then return true end - end - return false + if X.ReadUnitBool(IsInGroup) == true or InRaid() then return true end + return (X.ReadUnitNumber(GetNumGroupMembers) or 0) > 0 + or (X.ReadUnitNumber(GetNumPartyMembers) or 0) > 0 end -- Non-group players are only visible to addons through friendly nameplates, @@ -1182,25 +1292,34 @@ do end end -local function HasAny(unit, names, minLeft) +local scanHorizon -- coverage/forecast lookahead for the current list scan only +local function HasAny(unit, names, minLeft, measure) minLeft = minLeft or db.rebuff or 0 - local unknown = false + local ceiling = measure and math_max(minLeft, measure) or minLeft + local longest, unknown, untimed = 0, false, false for i = 1, #names do local rem, presence, uncertainTimer = X.Remaining(unit, names[i]) - if rem and rem > minLeft then return true end - if presence == "present" and rem == nil and minLeft == 0 then return true end + if rem and rem > ceiling then return true end + if rem and rem > longest then longest = rem end + if presence == "present" and rem == nil then + if minLeft == 0 and not measure then return true end + untimed = true + end if presence == "unknown" or (presence == "present" and (rem == nil or uncertainTimer)) then unknown = true end end - if unknown then return nil end - return false + -- When measuring, an unreadable or later equivalent can outlast the + -- shorter aura. Only forecast loss of coverage when the whole family ends. + local has = longest > minLeft or (minLeft == 0 and untimed) + if unknown then return has and true or nil end + return has, longest end --------------------------------------------------------------------------- -- What can I cast? --------------------------------------------------------------------------- -local known, myBuffs, myBlessing, blessKnown = {}, {}, {}, {} +local known, myBuffs, myBlessing, blessKnown, blessKeys = {}, {}, {}, {}, {} local ranks = {} -- ranks[name] = { {rank=n, sub="Rank n", id=spellID}, ... } ascending local hasAnyBuff = false local bookCount = 0 @@ -1277,6 +1396,7 @@ function BuildBuffList() end wipe(myBuffs) + X.nameKeyStamp = nil for _, d in ipairs(BUFF_DEFS) do local castName, names = nil, {} if d.choices then @@ -1346,7 +1466,7 @@ function BuildBuffList() local b = BLESSINGS[k] local name = SpellName(b.id, b.name) if KnowsSpell(b.id, name) then - myBlessing[class] = { name = name, + myBlessing[class] = { name = name, priorityKey = "BLESS_" .. k, names = { name, SpellName(b.greater[1], b.greater[2]) } } break end @@ -1356,10 +1476,12 @@ function BuildBuffList() -- Every blessing you know, by key: the blessing planner (1.6.0) picks -- from this instead of the per-class priority list when a plan is set. wipe(blessKnown) + wipe(blessKeys) for k, b in pairs(BLESSINGS) do local name = SpellName(b.id, b.name) if KnowsSpell(b.id, name) then - blessKnown[k] = { name = name, + blessKeys[name] = "BLESS_" .. k + blessKnown[k] = { name = name, priorityKey = blessKeys[name], names = { name, SpellName(b.greater[1], b.greater[2]) } } end end @@ -1859,6 +1981,15 @@ function X.TrackDeaths(list, extra) if extra then X.Track(extra) end end +local function MeasureExpiry(unit, key, name, has, left, observe, blessing) + if scanHorizon and left and observe and X.SubgroupAllows(key, unit, true) then + X.Intel.Observe(unit, key, name, left, blessing) + end + if has == true and left and left <= 300 then + X.expiryTally[key] = (X.expiryTally[key] or 0) + 1 + end +end + local function Missing(unit, out, isGroup, isSelf, report, detail) wipe(out) if not report then X.remainTmp, X.auraUnknown, X.auraNeedsBuff = nil, nil, nil end @@ -1873,7 +2004,7 @@ local function Missing(unit, out, isGroup, isSelf, report, detail) if report == "why" then detail.rule = L["Rule unavailable"] end return 0, true, false end - if not report and isGroup and db.consumables then + if not report and isGroup and db.consumables and not db.liteMode then for _, cd in ipairs(X.CONS_DEFS) do local t = X.consTally[cd.key] if not t then t = { total = 0, miss = 0 }; X.consTally[cd.key] = t end @@ -1935,7 +2066,7 @@ local function Missing(unit, out, isGroup, isSelf, report, detail) elseif eligible then local thr = report and report ~= "why" and 0 or (db.rebuffPer and db.rebuffPer[b.key]) or db.rebuff - local has = HasAny(unit, b.names, thr) + local has, left = HasAny(unit, b.names, thr, not report and isGroup and scanHorizon) if report then checked = true if has == nil then unknown = true end @@ -1946,102 +2077,79 @@ local function Missing(unit, out, isGroup, isSelf, report, detail) end if report == "ready" then X.RecordReadyAura(detail, unit, b.name, b.names, has, b.key) end else - if has == nil then X.auraUnknown = true - elseif has == false then X.auraNeedsBuff = true end - local t - if isGroup and has ~= nil then - t = X.tally[b.key] - if not t then t = { total = 0, miss = 0 }; X.tally[b.key] = t end - t.total = t.total + 1 - end - if not OnCooldown(b.name) then - if has == false then - n = n + 1 - out[n] = b.name - if t then t.miss = t.miss + 1 end - if n == 1 then -- still present but inside its rebuff window? - for _, nm2 in ipairs(b.names) do - local r = X.Remaining(unit, nm2) - if r and r > 0 and r < math_huge then X.remainTmp = r break end - end - end - elseif isGroup and has == true then - -- Group expiry watch (1.7.0): the buff is up, but inside its - -- last five minutes — count it toward the coverage warning. - local soonest = math_huge - for _, nm2 in ipairs(b.names) do - local r = X.Remaining(unit, nm2) - if r and r < soonest then soonest = r end - end - if soonest <= 300 then - X.expiryTally[b.key] = (X.expiryTally[b.key] or 0) + 1 - end - end - end + if has == nil then X.auraUnknown = true + elseif has == false then X.auraNeedsBuff = true end + local t + if isGroup and has ~= nil then + t = X.tally[b.key] + if not t then t = { total = 0, miss = 0 }; X.tally[b.key] = t end + t.total = t.total + 1 + MeasureExpiry(unit, b.key, b.name, has, left, not b.single) + end + if has == false and not OnCooldown(b.name) then + n = n + 1 + out[n] = b.name + if t then t.miss = t.miss + 1 end + if n == 1 and left and left > 0 then X.remainTmp = left end end end end - local bl, blessingSource - if CLASSIC_FEATURES then - bl, blessingSource = X.BlessingForClass(class, (isGroup or isSelf) and unit, assignment, proposal, member) - end - if report == "why" then - if blessingSource == "exception" then detail.blessing = L["Blessing: player exception"] - elseif blessingSource == "plan" then detail.blessing = L["Blessing: group plan"] - elseif blessingSource == "other" then detail.blessing = L["Blessing assigned to another Paladin"] end - end - local blessingEligible = (not subgroupKey or subgroupKey == "BLESSINGS") - and bl and IsOn("BLESSINGS", true) and (not isSelf or db.includeSelf) - and X.ContextOK("BLESSINGS") - if report == "raidCoverage" then - if blessingEligible then - local has - if detail.observable then has = HasAny(unit, bl.names, 0) end - detail.record(bl.name, has) - end - elseif reviewing and blessingEligible then - out[#out + 1] = bl.name - elseif blessingEligible then - local covered - if db.blessingComplement and not isGroup and isSelf == false and assignment == nil and not blessingSource then - local preferred = bl - bl, covered = X.ComplementWorldBlessing(unit, class, preferred) - if report == "why" and bl ~= preferred then detail.blessing = L["Blessing: complement another Paladin"] end - end - local has = covered or HasAny(unit, bl.names) - if report then - checked = true - if has == nil then unknown = true end - if has == false then n = n + 1; out[n] = bl.name end - if report == "ready" then X.RecordReadyAura(detail, unit, bl.name, bl.names, has, "BLESSINGS") end - else - if has == nil then X.auraUnknown = true end + end + + local bl, blessingSource + if CLASSIC_FEATURES then + bl, blessingSource = X.BlessingForClass(class, (isGroup or isSelf) and unit, assignment, proposal, member) + end + if report == "why" then + if blessingSource == "exception" then detail.blessing = L["Blessing: player exception"] + elseif blessingSource == "plan" then detail.blessing = L["Blessing: group plan"] + elseif blessingSource == "other" then detail.blessing = L["Blessing assigned to another Paladin"] end + end + local blessingEligible = (not subgroupKey or subgroupKey == "BLESSINGS") + and bl and IsOn("BLESSINGS", true) and (not isSelf or db.includeSelf) + and X.ContextOK("BLESSINGS") + if report == "raidCoverage" then + if blessingEligible then + local has + if detail.observable then has = HasAny(unit, bl.names, 0) end + detail.record(bl.name, has) + end + elseif reviewing and blessingEligible then + out[#out + 1] = bl.name + elseif blessingEligible then + local covered + if db.blessingComplement and not isGroup and isSelf == false and assignment == nil and not blessingSource then + local preferred = bl + bl, covered = X.ComplementWorldBlessing(unit, class, preferred) + if report == "why" and bl ~= preferred then detail.blessing = L["Blessing: complement another Paladin"] end + end + local has, left = covered, nil + if not has then + local thr = report and report ~= "why" and 0 or db.rebuff + has, left = HasAny(unit, bl.names, thr, not report and isGroup and scanHorizon) + end + if report then + checked = true + if has == nil then unknown = true end + if report == "why" and has == false and OnCooldown(bl.name, detail.cooldowns) then + detail.cooldown[#detail.cooldown + 1] = bl.name + elseif has == false then n = n + 1; out[n] = bl.name end + if report == "ready" then X.RecordReadyAura(detail, unit, bl.name, bl.names, has, "BLESSINGS") end + else + if has == nil then X.auraUnknown = true + elseif has == false then X.auraNeedsBuff = true end local t if isGroup and has ~= nil then t = X.tally.BLESSINGS if not t then t = { total = 0, miss = 0 }; X.tally.BLESSINGS = t end t.total = t.total + 1 + MeasureExpiry(unit, "BLESSINGS", bl.name, has, left, true, bl.priorityKey) end - if has == false then + if has == false and not OnCooldown(bl.name) then n = n + 1 out[n] = bl.name if t then t.miss = t.miss + 1 end - if n == 1 then - for _, nm2 in ipairs(bl.names) do - local r = X.Remaining(unit, nm2) - if r and r > 0 and r < math_huge then X.remainTmp = r break end - end - end - elseif isGroup and has == true then - -- Blessings count toward the group expiry watch too (1.7.0). - local soonest = math_huge - for _, nm2 in ipairs(bl.names) do - local r = X.Remaining(unit, nm2) - if r and r < soonest then soonest = r end - end - if soonest <= 300 then - X.expiryTally.BLESSINGS = (X.expiryTally.BLESSINGS or 0) + 1 - end + if n == 1 and left and left > 0 then X.remainTmp = left end end end end @@ -2110,6 +2218,9 @@ function X.RebuildPrio() for i, key in ipairs(db.buffPrio) do local nm = byKey[key] if nm and not X.prioIdx[nm] then X.prioIdx[nm] = i end + if key == "BLESSINGS" then + for name in pairs(blessKeys) do if not X.prioIdx[name] then X.prioIdx[name] = i end end + end end end @@ -2126,6 +2237,7 @@ local function EntryOrder(a, b) if (a.buddy or false) ~= (b.buddy or false) then return not a.buddy end if (a.handled or false) ~= (b.handled or false) then return not a.handled end if (a.pet or false) ~= (b.pet or false) then return not a.pet end + if a.smartTier ~= b.smartTier then return a.smartTier < b.smartTier end if db.sortMode == "need" and (a.prio1 or 999) ~= (b.prio1 or 999) then return (a.prio1 or 999) < (b.prio1 or 999) end @@ -2146,18 +2258,21 @@ end -- check / dungeon finder) or the raid MAINTANK/MAINASSIST flag — never a -- guess from class. local function RoleOf(unit, isSelf) - if isSelf then return 0 end - if AssignedRole(unit) == "TANK" then return 1 end + if isSelf then return 0, db.smartPriority and AssignedRole(unit) or nil end + local assigned = AssignedRole(unit) + if assigned == "TANK" then return 1, assigned end local idx = unit:match("^raid(%d+)$") if idx and GetRaidRosterInfo then - local ok, _, _, _, _, _, _, _, _, role = pcall(GetRaidRosterInfo, tonumber(idx)) - if ok and (role == "MAINTANK" or role == "MAINASSIST") then return 1 end + local ok, _, _, _, _, _, _, _, _, _, role = pcall(GetRaidRosterInfo, tonumber(idx)) + if ok and Readable(role) and (role == "MAINTANK" or role == "MAINASSIST") then + return 1, assigned or (role == "MAINTANK" and "TANK" or nil) + end end if UnitIsGroupLeader then local ok, leader = pcall(UnitIsGroupLeader, unit) - if ok and Readable(leader) and leader == true then return 2 end + if ok and Readable(leader) and leader == true then return 2, assigned end end - return 3 + return 3, assigned end --------------------------------------------------------------------------- @@ -2299,7 +2414,7 @@ local function Consider(unit, isGroup) -- Healer drinking (1.8.0, Forever): anyone in the group with a Drink -- aura is marked; healing classes also feed the coverage line count. X.scanUnit = nil - if isGroup and db.drinkWatch and CLASSIC_FEATURES + if isGroup and db.drinkWatch and not db.liteMode and CLASSIC_FEATURES and select(2, X.Remaining(unit, "Drink")) == "present" then X.drinkSet[guid] = true local dclass = X.UnitClassToken(unit) @@ -2320,13 +2435,12 @@ local function Consider(unit, isGroup) local auraUnknown = X.auraUnknown if auraUnknown then X.scanHasUnknownBuffs = true end if allN > 0 or X.auraNeedsBuff then X.scanHasMissingBuffs = true end - e.remain1 = X.remainTmp + e.remain1, e.expiringSpell = X.remainTmp, e.allMissing[1] if isGroup and not auraUnknown and allN == 0 then X.missNow[guid] = {} end local queue = e.allMissing if X.subgroupDuties and next(X.subgroupDuties) and InRaid() then e.subgroupMissing = e.subgroupMissing or {} queue = X.FilterSubgroupDuties(unit, isGroup, e.allMissing, e.subgroupMissing) - if queue[1] ~= e.allMissing[1] then e.remain1 = nil end end local n, approximate = X.FilterInRange(unit, queue, e.missing, isSelf) if #queue > 0 and n == 0 and db.rangeWatch then X.farNow[guid] = nm or true end @@ -2374,7 +2488,7 @@ local function Consider(unit, isGroup) e.rezzed = (rz and GetTime() - rz < 60) or nil e.outOfRange = false e.groupCast = false - e.role = RoleOf(unit, isSelf) + e.role, e.groupRole = RoleOf(unit, isSelf) e.pet = nil end @@ -2441,7 +2555,7 @@ function X.ConsiderPet(petUnit, ownerUnit) e.rangeBucket = 0 e.approximateRange = approximate e.marker = X.ReadRaidMarker(petUnit) - e.remain1 = nil + e.remain1, e.expiringSpell, e.groupRole = nil, nil, nil e.expired, e.rezzed = nil, nil e.outOfRange = false e.groupCast = false @@ -2451,8 +2565,33 @@ end -- Last-scan diagnostics for /br debug: how many nameplate units the client -- handed us on the latest pass, and how many of them were players. +local function MissingOrder(entry, spell) + local manual = X.prioIdx and X.prioIdx[spell] or 999 + local tier = db.smartPriority and X.Intel.Tier(entry, X.KeyOfName(spell), blessKeys[spell]) or 3 + return tier * 1000 + manual +end + +local function OrderMissing(entry) + local m = entry.missing + if db.smartPriority or (X.prioIdx and next(X.prioIdx)) then + for i = 2, #m do + local v, order = m[i], MissingOrder(entry, m[i]) + local j = i - 1 + while j >= 1 and MissingOrder(entry, m[j]) > order do + m[j + 1] = m[j] + j = j - 1 + end + m[j + 1] = v + end + end + entry.smartTier = math_floor(MissingOrder(entry, m[1]) / 1000) + entry.prio1 = X.prioIdx and X.prioIdx[m[1]] or nil + if entry.expiringSpell ~= m[1] then entry.remain1 = nil end +end + local function CollectEntries() local nowT = GetTime() + scanHorizon = X.Intel.BeginScan() for guid, untilTime in pairs(X.failedTargets) do if untilTime <= nowT then X.failedTargets[guid] = nil end end @@ -2478,7 +2617,7 @@ local function CollectEntries() for i = 1, #list do Consider(list[i], true) end Consider("player", true) -- Group pets (1.8.0): your pet and your group members' pets, as rows. - if db and db.pets then + if db.pets and not db.liteMode then X.ConsiderPet("pet", "player") if InRaid() then for i = 1, 40 do X.ConsiderPet("raidpet" .. i, RAID[i]) end @@ -2543,6 +2682,10 @@ local function CollectEntries() entryPool[#entryPool + 1] = entries[i] entries[i] = nil end + if X.prioDirty then X.RebuildPrio() end + -- Set the primary spell before classifying casts handled by another + -- player, assignments, and duration tags. All consume that same offer. + for i = 1, nEntries do OrderMissing(entries[i]) end -- Coordination marks (1.5.0): a player another BuffRadar user just buffed -- sinks in the order (see EntryOrder) and shows a tag; a player who asked -- for a buff in chat is tagged while the request is fresh. @@ -2562,7 +2705,7 @@ local function CollectEntries() e.weapon = nil -- set below, on your own row only (pooled entries) end -- Weapon watch (1.7.0): your own row carries the reminder tag. - if db and db.weaponWatch and X.WeaponEnchantMissing() then + if db.weaponWatch and not db.liteMode and X.WeaponEnchantMissing() then for i = 1, nEntries do if entries[i].isSelf then entries[i].weapon = true end end @@ -2626,32 +2769,13 @@ local function CollectEntries() if s % #users ~= myIdx - 1 then e.buddy = true end end end - -- your buff priority: each row offers its buffs in your order (the - -- first one is the click target and the first icon), and each row - -- remembers its best position for the "need" sort tiebreak - if X.prioDirty then X.RebuildPrio() end - if X.prioIdx and next(X.prioIdx) then - for i = 1, nEntries do - local e = entries[i] - local m = e.missing - for a = 2, #m do - local v, av = m[a], X.prioIdx[m[a]] or 999 - local bI = a - 1 - while bI >= 1 and (X.prioIdx[m[bI]] or 999) > av do - m[bI + 1] = m[bI] - bI = bI - 1 - end - m[bI + 1] = v - end - e.prio1 = X.prioIdx[m[1]] or 999 - end - end if nEntries > 1 then table_sort(entries, EntryOrder) end -- Cast queue highlight (1.6.0): right after one of your casts lands, the -- new top row is where the next cast should go. if nEntries > 0 and db and db.queueTag and nowT - (X.queueAt or 0) < 3 then entries[1].queued = true end + scanHorizon = nil return nEntries end @@ -3424,6 +3548,7 @@ function X.GroupOffer(spell, unit, preview) local pick = X.BindingRank(name, unit, X.ReadUnitNumber(UnitLevel, unit), db.castMethod) if pick == false or (baseID and not known[name] and not X.ReadUnitBool(_G.IsPlayerSpell, baseID) and not X.ReadUnitBool(_G.IsSpellKnown, baseID)) then return nil end + if not preview and OnCooldown(name) then return nil end local blocker, reason = X.GroupBlockersFor(spell, name, unit, greater, baseID, preview) if blocker then return nil, nil, nil, reason, nil, blocker end local exact = db.castMethod ~= "macro" and pick @@ -4360,6 +4485,7 @@ end local function SuspendBuffing() refreshIdle = true + X.Status.Unavailable("dead") X.ResetCastTracking() X.SuspendWindow() X.SyncCastMacro(true) @@ -4496,9 +4622,12 @@ local function AlertOnNewEntries(n) if now - t > 60 then recentlyGone[guid] = nil end end listedBefore = listedNow - if newName and db.playSound and now - X.lastSoundAt > 1 then - X.lastSoundAt = now - PlayAlert("new") + if newName then + X.VisualBuffAlert() + if db.playSound and now - X.lastSoundAt > 1 then + X.lastSoundAt = now + PlayAlert("new") + end end end @@ -4508,7 +4637,8 @@ local function Refresh() if not refreshIdle or not X.playerDead then X.UpdatePlayerLife() end return end - if InCombatLockdown() or X.HasHeldRow() then return end + if InCombatLockdown() then X.Status.Unavailable("combat"); return end + if X.HasHeldRow() then return end X.assignmentGroupConflicts = X.AssignmentEnabled() and next(db.buffAssignments) and {} or nil refreshIdle = false X.applyFilter = true -- the window honors the role filter; reports turn it off @@ -4520,6 +4650,7 @@ local function Refresh() if not hasAnyBuff then refreshIdle = true ClearCastQueue() + X.Status.Unavailable("inactive") X.ShowWindowStatus(sessionShow and not db.hidden and L["No supported buffs in your spellbook."]) return end @@ -4529,6 +4660,7 @@ local function Refresh() if reason then refreshIdle = idle or false ClearCastQueue() + X.Status.Unavailable("paused") wipe(listedBefore) local showStatus = not (db.hidden or groupHidden or db.autoHide) X.ShowWindowStatus(showStatus and reason, not showStatus) @@ -4550,10 +4682,11 @@ local function Refresh() X.ShowWindowStatus() wipe(listedBefore) if X.UpdateNearbyTargetAfterScan then X.UpdateNearbyTargetAfterScan() end - return + else + X.RenderQueue(entries, n, sessionShow, wasAfterCombat) + AlertOnNewEntries(n) end - AlertOnNewEntries(n) - X.RenderQueue(entries, n, sessionShow, wasAfterCombat) + X.Status.Publish(entries, n) end --------------------------------------------------------------------------- @@ -4573,9 +4706,13 @@ local function SafeRefresh() pf.n, pf.total, pf.last = pf.n + 1, pf.total + dt, dt if dt > pf.max then pf.max = dt end end - if not ok and err ~= lastError then - lastError = err - Print("|cffff4040error:|r " .. tostring(err)) + if not ok then + scanHorizon = nil + X.Status.Unavailable("updating") + if err ~= lastError then + lastError = err + Print("|cffff4040error:|r " .. tostring(err)) + end end end @@ -4584,26 +4721,18 @@ end -- How many players are in my group, me included (0 when solo)? local function GroupSize() if GetNumGroupMembers then - local ok, n = pcall(GetNumGroupMembers) - if ok and type(n) == "number" then return n end - end - if GetNumRaidMembers then - local ok, n = pcall(GetNumRaidMembers) - if ok and type(n) == "number" and n > 0 then return n end + local n = X.ReadUnitNumber(GetNumGroupMembers) + if n then return n end end - if GetNumPartyMembers then - local ok, n = pcall(GetNumPartyMembers) - if ok and type(n) == "number" then return n > 0 and n + 1 or 0 end - end - return 0 -end - --- Scan throttle (1.7.0): in very large groups the steady rescan runs at --- half rate. Event-driven refreshes are never throttled. -local function ScanThrottled() - return db and db.scanThrottle and GroupSize() > 20 + local raid = X.ReadUnitNumber(GetNumRaidMembers) + if raid and raid > 0 then return raid end + local party = X.ReadUnitNumber(GetNumPartyMembers) + return party and party > 0 and party + 1 or 0 end +-- Movement events and combat exit wake the steady ticker without delaying +-- event-driven refreshes. Scan policy is sampled at most once per cycle. +local scanTicksRemaining = 0 local Soon, StartTicker if C_Timer and C_Timer.NewTicker and C_Timer.After then -- Only the queued callback clears its own flag, so ticker refreshes can't spawn @@ -4627,11 +4756,13 @@ if C_Timer and C_Timer.NewTicker and C_Timer.After then if X.playerDead then return end if X.ExpireReadyCheck then X.ExpireReadyCheck() end X.UpdateFade() + X.TickMinimapPulse() if refreshIdle or InCombatLockdown() then return end - if ScanThrottled() then - X.tickSkip = not X.tickSkip - if X.tickSkip then return end + if db.scanThrottle and scanTicksRemaining > 0 then + scanTicksRemaining = scanTicksRemaining - 1 + return end + scanTicksRemaining = X.Intel.ScanTicks(GroupSize) - 1 SafeRefresh() end StartTicker = function() @@ -4650,8 +4781,11 @@ else if soonElapsed < SOON_DELAY then return end else if elapsed < UPDATE_INTERVAL then return end - interval = interval or (ScanThrottled() and UPDATE_INTERVAL * 2 or UPDATE_INTERVAL) - if elapsed < interval then return end + if not refreshIdle and not InCombatLockdown() then + if not db.scanThrottle then interval = UPDATE_INTERVAL end + interval = interval or UPDATE_INTERVAL * X.Intel.ScanTicks(GroupSize) + if elapsed < interval then return end + end end elapsed, soonElapsed, interval = 0, nil, nil X.RunDueSyncWarmupRetry() @@ -4661,7 +4795,8 @@ else if X.playerDead then return end if X.ExpireReadyCheck then X.ExpireReadyCheck() end X.UpdateFade() - if eventPending or not refreshIdle then SafeRefresh() end + X.TickMinimapPulse() + if not InCombatLockdown() and (eventPending or not refreshIdle) then SafeRefresh() end end) end Soon = function() @@ -4739,7 +4874,8 @@ for _, ev in ipairs({ "PLAYER_TALENT_UPDATE", "ACTIVE_TALENT_GROUP_CHANGED", "CHAT_MSG_ADDON", "CHAT_MSG_WHISPER", "CHAT_MSG_SAY", "CHALLENGE_MODE_START", "PLAYER_DEAD", "PLAYER_ALIVE", "PLAYER_UNGHOST", "PLAYER_FLAGS_CHANGED", - "PLAYER_FOCUS_CHANGED", + "PLAYER_FOCUS_CHANGED", "PLAYER_STARTED_MOVING", "PLAYER_STOPPED_MOVING", + "ENCOUNTER_START", "ENCOUNTER_END", "UPDATE_INVENTORY_DURABILITY", "PLAYER_EQUIPMENT_CHANGED", "UNIT_PET", }) do pcall(driver.RegisterEvent, driver, ev) end @@ -4780,7 +4916,10 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) end return end - if event == "UNIT_AURA" and not X.AuraEventNeedsRefresh(arg1, ...) then return end + if event == "UNIT_AURA" then + if X.QueuePersonalReadiness and Readable(arg1) and arg1 == "player" then X.QueuePersonalReadiness() end + if not X.AuraEventNeedsRefresh(arg1, ...) then return end + end Soon() return end @@ -4797,7 +4936,29 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if db and X.CastEvent(event, arg1, ...) then Soon() end return end - if event == "CVAR_UPDATE" then + if event == "PLAYER_STARTED_MOVING" or event == "PLAYER_STOPPED_MOVING" then + scanTicksRemaining = 0 + if db and db.scanThrottle and not refreshIdle and not InCombatLockdown() then Soon() end + return + elseif event == "ENCOUNTER_START" then + X.Intel.ClearPreparation() + X.Debuffs.Encounter(arg1) + if db and db.forecastSeconds > 0 and not InCombatLockdown() then Soon() end + return + elseif event == "ENCOUNTER_END" then + X.Debuffs.Encounter(nil) + local success = select(4, ...) + if Readable(success) and (success == 0 or success == false) then + X.Intel.MarkWipe() + if db and db.smartPriority and not InCombatLockdown() then Soon() end + end + return + elseif event == "UPDATE_INVENTORY_DURABILITY" or event == "PLAYER_EQUIPMENT_CHANGED" or event == "UNIT_PET" then + if X.QueuePersonalReadiness and (event ~= "UNIT_PET" or Readable(arg1) and arg1 == "player") then + X.QueuePersonalReadiness() + end + return + elseif event == "CVAR_UPDATE" then local name = type(arg1) == "string" and Readable(arg1) and arg1:lower() if name == "actionbuttonusekeydown" or name == "action_button_use_key_down" then X.ApplyNextRegistration() @@ -4819,15 +4980,18 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) return elseif event == "PLAYER_ROLES_ASSIGNED" then X.OnCoordinationRoster() - if X.AssignmentEnabled() then - X.assignmentGroupConflicts = nil - Soon() - end + local assignments = X.AssignmentEnabled() + if assignments then X.assignmentGroupConflicts = nil end + if db and (db.smartPriority or assignments) then Soon() end if X.QueueAssignmentPreviewRefresh then X.QueueAssignmentPreviewRefresh() end return elseif event == "GROUP_LEFT" then X.OnCoordinationRoster(true) - if not InGroup() and X.CloseRaidPreparation then X.CloseRaidPreparation() end + if not InGroup() then + X.Intel.ResetContext() + if X.CloseRaidPreparation then X.CloseRaidPreparation(true) end + end + X.Status.Unavailable("updating") if not InRaid() then X.subgroupDuties = nil end local size = X.ReadUnitNumber(GetNumGroupMembers) if (size and size <= 0) or (not size and not InGroup()) then @@ -4878,7 +5042,9 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) end if event == "PLAYER_DEAD" or event == "PLAYER_ALIVE" or event == "PLAYER_UNGHOST" then X.UpdatePlayerLife(event) + X.Debuffs.Refresh() if event == "PLAYER_DEAD" and db then + X.Intel.ClearPreparation() X.ClearReadyCheck() if X.DeathRecap then X.DeathRecap(db.deathRecap) end end @@ -4891,6 +5057,9 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if event == "PLAYER_LEAVING_WORLD" or event == "PLAYER_LOGOUT" then X.macroParked = true ClearCastQueue() + X.Status.Unavailable("updating") + X.Intel.ResetContext() + X.Debuffs.Clear() return end if event == "PLAYER_ENTERING_WORLD" then @@ -4900,6 +5069,9 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) X.ResetCastTracking() X.ClearReadyCheck() X.UpdatePlayerLife(event) + X.Status.Unavailable(X.playerDead and "dead" or "updating") + X.Intel.ResetContext() + X.Debuffs.Encounter(nil) Soon() return end @@ -4907,7 +5079,11 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) X.assignmentGroupConflicts = nil X.OnCoordinationRoster() if db then X.OnRoster() end - if not InGroup() then X.ClearReadyCheck() end + if not InGroup() then + X.ClearReadyCheck() + X.Intel.ResetContext() + end + if not InCombatLockdown() and not X.playerDead then X.Status.Unavailable("updating") end if db and X.AutoProfileCheck then X.AutoProfileCheck() end Soon() if X.QueueAssignmentPreviewRefresh then X.QueueAssignmentPreviewRefresh() end @@ -4931,6 +5107,7 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) return end X.Settings.Load(true) + X.Status.Unavailable("updating") Ignore.Rebuild() X.SpecSwap() X.ResolveAutoTheme() @@ -4953,10 +5130,11 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) ok, err = pcall(X.BuildUI) if not ok then Print("|cffff4040error building window:|r " .. tostring(err)) end X.ApplyClickThrough() + X.Debuffs.Apply() X.SyncCastMacro(true) -- migrate the built-in macro, but never arm a prior session's queue Print("loaded. Type /br to show the window.") if not db.wizardSeen then - Print("New to BuffRadar? /br wizard runs a one-minute setup.") + Print(L["New to BuffRadar? Run /br wizard for Quick Setup."]) end if X.FriendlyPlatesOn() == false then Print("friendly nameplates are |cffff4040off|r - nearby players outside your group can't be listed until they're on. Type /br plates to turn them on (or press Shift+V).") @@ -4973,9 +5151,16 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) X.ClearCastIntent() X.combatStart = GetTime() -- the wipe report times the fight from here (1.9.0) X.BeginWindowCombat() + X.Intel.ClearPreparation() + X.Status.Unavailable(X.playerDead and "dead" or "combat") + X.TickMinimapPulse() + X.Debuffs.Refresh() elseif event == "PLAYER_REGEN_ENABLED" then X.afterCombat = true -- Refresh() pulses the border if work is waiting if InCombatLockdown() then return end + scanTicksRemaining = 0 + X.Intel.WakeAfterCombat() + X.Debuffs.Refresh() X.SyncCastMacro(true) if not X.EndWindowCombat() then SuspendBuffing() @@ -4990,12 +5175,19 @@ driver:SetScript("OnEvent", function(_, event, arg1, ...) if (event == "PARTY_MEMBERS_CHANGED" or event == "RAID_ROSTER_UPDATE") and db then X.OnCoordinationRoster() X.OnRoster() + if not InGroup() then X.Intel.ResetContext() end + if not InCombatLockdown() and not X.playerDead then X.Status.Unavailable("updating") end if X.QueueAssignmentPreviewRefresh then X.QueueAssignmentPreviewRefresh() end end if (event == "ZONE_CHANGED_NEW_AREA" or event == "ZONE_CHANGED" or event == "ZONE_CHANGED_INDOORS") and db then if X.AutoProfileCheck then X.AutoProfileCheck() end - if event == "ZONE_CHANGED_NEW_AREA" then X.InstanceCheck() end + if event == "ZONE_CHANGED_NEW_AREA" then + X.Intel.ResetContext() + X.Debuffs.Encounter(nil) + if not InCombatLockdown() and not X.playerDead then X.Status.Unavailable("updating") end + X.InstanceCheck() + end end Soon() end @@ -5247,6 +5439,7 @@ X.Core = { OpenKeybinds = OpenKeybinds, MakeMacro = MakeMacro, NextBinding = NEXT_BINDING, + UpdateInterval = UPDATE_INTERVAL, Bind = Bind, SafeString = SafeString, SpellName = SpellName, diff --git a/BuffRadar/BuffRadar.toc b/BuffRadar/BuffRadar.toc index 3b0eda0..55184fa 100644 --- a/BuffRadar/BuffRadar.toc +++ b/BuffRadar/BuffRadar.toc @@ -12,6 +12,10 @@ Locales\deDE.lua Data.lua SavedVariables.lua BuffRadar.lua +Intelligence.lua +Status.lua +Debuffs.lua +Readiness.lua Minimap.lua Coordination.lua Window.lua diff --git a/BuffRadar/Config.lua b/BuffRadar/Config.lua index adc9be5..85015f2 100644 --- a/BuffRadar/Config.lua +++ b/BuffRadar/Config.lua @@ -1795,8 +1795,21 @@ function AssignmentUI.OpenCoverage(panel) AssignmentUI.RefreshCoverage(view) end +function X.QueuePersonalReadiness() + local view = cfg and cfg.assignmentPanel and cfg.assignmentPanel.preparation + if view and view.tab == "personal" then X.QueueAssignmentPreviewRefresh(true) end +end + +function AssignmentUI.PreparationAvailable(tab) + local settings = X.GetDB() + return settings and not settings.liteMode and not InCombatLockdown() and not X.PlayerSuspended() + and (tab == "personal" or X.InGroup()) +end + function AssignmentUI.DrawPreparation(view, rosterRefresh) - local report, lines = view.report, {} + local report = view.report + local personal = view.tab == "personal" + local lines = personal and report.personal or {} local attention, unknown = 0, 0 local oldExpandedIndex = view.expandedIndex local expandedIndex, expandedEnd @@ -1845,11 +1858,21 @@ function AssignmentUI.DrawPreparation(view, rosterRefresh) or (report.incomplete and L["Reagent needs could not be confirmed."] or L["No reagents required for the current checklist."]) } end - view.summary:SetText(string.format(L["%d Players · %d Need Attention · %d With Unknowns"], #report.members, attention, unknown)) - view.notice:SetText(report.incomplete and L["Some roster information could not be checked."] or "") - view.personalNote:SetText(report.personal or "") - if view.tab == "players" then view.players:Disable(); view.reagents:Enable() - else view.players:Enable(); view.reagents:Disable() end + view.summary:SetText(personal and L["Your character only"] + or string.format(L["%d Players · %d Need Attention · %d With Unknowns"], #report.members, attention, unknown)) + view.notice:SetText(personal and L["Soulwell availability cannot be checked."] + or report.incomplete and L["Some roster information could not be checked."] or "") + local grouped = X.InGroup() + view.players:SetShown(grouped) + view.reagents:SetShown(grouped) + view.back:SetShown(grouped) + view.personalTab:ClearAllPoints() + if grouped then view.personalTab:SetPoint("LEFT", view.reagents, "RIGHT", 8, 0) + else view.personalTab:SetPoint("TOPLEFT", 16, -75) end + for _, tab in ipairs({ "players", "reagents", "personal" }) do + local button = tab == "personal" and view.personalTab or view[tab] + if view.tab == tab then button:Disable() else button:Enable() end + end local pages = math.max(1, math.ceil(#lines / #view.rows)) view.page = math.max(1, math_min(view.page, pages)) view.pageLabel:SetText(string.format(L["Page %d of %d"], view.page, pages)) @@ -1886,21 +1909,20 @@ end function AssignmentUI.RefreshPreparation(view, rosterRefresh) if not view:IsVisible() then return end view.pendingRefresh = nil - if InCombatLockdown() or X.PlayerSuspended() or not X.InGroup() then view:Hide(); return end - view.report = X.RaidPreparationSnapshot(view.personal) + if not AssignmentUI.PreparationAvailable(view.tab) then view:Hide(); return end + view.report = X.RaidPreparationSnapshot(view.tab == "personal") if not view.report then view:Hide(); return end AssignmentUI.DrawPreparation(view, rosterRefresh) end -function X.CloseRaidPreparation() +function X.CloseRaidPreparation(groupOnly) local view = cfg and cfg.assignmentPanel and cfg.assignmentPanel.preparation - if view then view:Hide() end + if view and (not groupOnly or view.tab ~= "personal") then view:Hide() end end function X.MoveRaidPreparation(delta) local view = cfg and cfg.assignmentPanel and cfg.assignmentPanel.preparation - if not view or not view.report or not view:IsVisible() - or InCombatLockdown() or X.PlayerSuspended() or not X.InGroup() then return end + if not view or not view.report or not view:IsVisible() or not AssignmentUI.PreparationAvailable(view.tab) then return end view.page = view.page + delta AssignmentUI.DrawPreparation(view) end @@ -1919,18 +1941,18 @@ function AssignmentUI.BuildPreparation(panel) view.summary = text("GameFontHighlightSmall", 16, -44, 210) view.refresh = MakeButton(view, L["Refresh Preparation"], 182, function() AssignmentUI.RefreshPreparation(view, true) end) view.refresh:SetPoint("TOPRIGHT", -16, -37) - view.notice = text("GameFontHighlightSmall", 237, -82, 16) - view.personalNote = text("GameFontHighlightSmall", 16, -106, 16) + view.notice = text("GameFontHighlightSmall", 16, -104, 16) local function selectTab(tab) - if not view.report or view.tab == tab or not view:IsVisible() - or InCombatLockdown() or X.PlayerSuspended() or not X.InGroup() then return end + if not view.report or view.tab == tab or not view:IsVisible() or not AssignmentUI.PreparationAvailable(tab) then return end + local personalChanged = (view.tab == "personal") ~= (tab == "personal") view.tab, view.page, view.expanded, view.expandedIndex, view.expandedEnd = tab, 1, nil, nil, nil - AssignmentUI.DrawPreparation(view) + if personalChanged then AssignmentUI.RefreshPreparation(view) else AssignmentUI.DrawPreparation(view) end end view.players = MakeButton(view, L["Players"], 102, function() selectTab("players") end) view.players:SetPoint("TOPLEFT", 16, -75) view.reagents = MakeButton(view, L["Reagents"], 102, function() selectTab("reagents") end) view.reagents:SetPoint("LEFT", view.players, "RIGHT", 8, 0) + view.personalTab = MakeButton(view, L["Personal"], 120, function() selectTab("personal") end) view.rows = {} local function wheel(_, delta) X.MoveRaidPreparation(delta > 0 and -1 or 1) end view:EnableMouseWheel(true) @@ -1983,7 +2005,8 @@ function AssignmentUI.BuildPreparation(panel) end function X.OpenRaidPreparation(personal) - if not CLASSIC_FEATURES or not X.InGroup() or X.PlayerSuspended() or InCombatLockdown() then return end + local tab = personal and "personal" or "players" + if not CLASSIC_FEATURES or not AssignmentUI.PreparationAvailable(tab) then return end if not cfg or not cfg.assignmentPanel or not cfg.assignmentPanel:IsVisible() then X.OpenAssignments() end local panel = cfg.assignmentPanel panel.picker:Hide() @@ -1994,7 +2017,7 @@ function X.OpenRaidPreparation(personal) if panel.practice then panel.practice:Hide() end panel.preparation = panel.preparation or AssignmentUI.BuildPreparation(panel) local view = panel.preparation - view.personal, view.tab, view.page = personal, "players", 1 + view.tab, view.page = tab, 1 view.expanded, view.expandedIndex, view.expandedEnd = nil, nil, nil view:Show() AssignmentUI.RefreshPreparation(view) @@ -2677,6 +2700,147 @@ do end end +function AssignmentUI.BuildReadinessSettings(panel) + local r = { checks = {}, rules = {} } + local I, D = X.Intel, X.Debuffs + local function label(text, x, y, font) + local fs = panel:CreateFontString(nil, "OVERLAY", font or "GameFontHighlightSmall") + fs:SetPoint("TOPLEFT", x, y) + fs:SetText(text) + return fs + end + local function section(text, x, y) return label(L[text], x, y, "GameFontNormal") end + local function field(text, x, y, width, length, numeric, commit) + local box = CreateFrame("EditBox", nil, panel, "InputBoxTemplate") + box:SetSize(width, 20) + box:SetPoint("TOPLEFT", x, y) + box:SetAutoFocus(false) + box:SetMaxLetters(length) + if numeric then box:SetNumeric(true) end + box:SetScript("OnEnterPressed", function(self) + if commit then commit(self:GetText()) end + self:ClearFocus() + if commit then r.Update() end + end) + box:SetScript("OnEscapePressed", function(self) self:ClearFocus(); r.Update() end) + K.RegisterEdit(box, panel, L[text]) + RegisterSearch(box, panel, L[text]) + Tip(box, L[text], commit and L["Press Enter to save."] or nil) + return box + end + local function check(key, text, x, y, tip) + local cb = MakeCheck(panel, L[text], function() return db[key] end, function(value) + db[key] = value + I.SettingsChanged() + RefreshConfig() + end) + cb:SetPoint("TOPLEFT", x, y) + WrapCheckLabel(cb) + if tip then Tip(cb, L[text], L[tip]) end + r.checks[#r.checks + 1] = cb + end + + section("Buff intelligence", 14, -10) + label(L["Forecast seconds (0 = off)"], 15, -45) + r.forecast = field("Forecast seconds (0 = off)", 214, -40, 50, 3, true, + function(input) I.SetForecast(tonumber(input)) end) + check("smartPriority", "Smart buff priority", 10, -68, + "Promote buffs for tanks, healers, recovery and your instance rules without changing eligibility.") + label(L["Priority buff key for this instance"], 15, -104) + r.instance = field("Priority buff key for this instance", 18, -122, 152, 32, false) + local instance = MakeButton(panel, L["Apply here"], 98, function() + local key = r.instance:GetText():match("^%s*(.-)%s*$") + I.SetInstancePriority(I.InstanceID(), key == "" and "clear" or key) + r.instance:ClearFocus() + r.Update() + end) + instance:SetPoint("TOPLEFT", 174, -121) + Tip(instance, L["Apply here"], L["Use a key from /br buffs. Clear the field to remove the rule."]) + + section("Performance & alerts", 303, -10) + check("scanThrottle", "Adaptive scan throttle", 299, -35, + "Slow periodic scans at rest or with high latency. Event refreshes stay responsive.") + check("liteMode", "Lite mode", 299, -63, + "Pause the checklist, forecasts, debuffs and optional aura watches without changing their settings.") + check("statusMinimap", "Status on the minimap", 299, -91) + check("visualAlerts", "Quiet visual alerts", 299, -119, + "Briefly highlight the window or minimap without sound. Respects Reduced Motion.") + + section("Encounter debuffs", 14, -164) + check("debuffWatch", "Show watched debuffs", 10, -184, + "Track up to eight harmful spell IDs on you or your focus, when the client exposes them.") + label(L["Spell ID"], 16, -220) + label(L["Watch unit"], 111, -220) + label(L["Encounter ID (optional)"], 252, -220) + r.spell = field("Spell ID", 18, -238, 78, 7, true) + r.boss = field("Encounter ID (optional)", 254, -238, 121, 7, true) + r.unit = "player" + r.unitButton = MakeButton(panel, L["Player"], 123, function() + r.unit = r.unit == "player" and "focus" or "player" + r.unitButton:SetText(L[r.unit == "player" and "Player" or "Focus"]) + end) + r.unitButton:SetPoint("TOPLEFT", 111, -237) + r.unitButton.navigation.label = L["Watch unit"] + r.unitButton.navigation.value = function() return r.unitButton:GetText() end + local add = MakeButton(panel, L["Save watch"], 151, function() + local boss = r.boss:GetText() + if D.SetRule(tonumber(r.spell:GetText()), r.unit, boss == "" and 0 or tonumber(boss)) then + r.spell:SetText("") + r.boss:SetText("") + RefreshConfig() + end + end) + add:SetPoint("TOPLEFT", 402, -237) + r.noRules = label(L["No debuffs are being tracked."], 15, -276) + for i = 1, X.Settings.MaxDebuffRules do + local x, y = 16 + ((i - 1) % 2) * 278, -277 - math_floor((i - 1) / 2) * 30 + local row = { text = label("", x, y) } + row.text:SetWidth(186) + row.text:SetJustifyH("LEFT") + row.text:SetWordWrap(false) + row.remove = MakeButton(panel, L["Remove"], 79, function() + local rule = db.debuffRules[i] + if rule then D.Remove(rule.spellID, rule.unit); RefreshConfig() end + end) + row.remove:SetPoint("TOPLEFT", x + 188, y + 3) + row.remove.navigation.value = function() return row.full end + Tip(row.remove, L["Remove"], function() return row.full end) + r.rules[i] = row + end + + if CLASSIC_FEATURES then + label(L["Consumable aura ID (0 = off)"], 15, -424) + r.aura = field("Consumable aura ID (0 = off)", 232, -420, 80, 7, true, + function(input) X.Readiness.SetAura(tonumber(input)) end) + local personal = MakeButton(panel, L["Open personal checks"], 214, function() X.RaidPreparationCommand("personal") end) + personal:SetPoint("TOPLEFT", 339, -420) + end + r.memory = MakeButton(panel, L["Memory usage"], 152, I.MemoryReport) + r.memory:SetPoint("TOPLEFT", 14, -469) + local status = MakeButton(panel, L["Copy buff status"], 152, function() K.Stop(); X.ext.status("export") end) + status:SetPoint("LEFT", r.memory, "RIGHT", 10, 0) + r.feedback = MakeButton(panel, L["Feedback"], 152, function() K.Stop(); X.ShowFeedback() end) + r.feedback:SetPoint("LEFT", status, "RIGHT", 10, 0) + + function r.Update() + for _, cb in ipairs(r.checks) do cb:Update() end + if not r.forecast:HasFocus() then r.forecast:SetText(tostring(db.forecastSeconds)) end + if r.aura and not r.aura:HasFocus() then r.aura:SetText(tostring(db.readinessAura)) end + if not r.instance:HasFocus() then + local id = I.InstanceID() + r.instance:SetText(id and db.instancePriority[id] or "") + end + r.noRules:SetShown(#db.debuffRules == 0) + for i, row in ipairs(r.rules) do + local rule = db.debuffRules[i] + row.full = rule and D.RuleLabel(rule) + row.text:SetText(row.full or "") + row.remove:SetShown(rule ~= nil) + end + end + return r +end + local function BuildConfig() db = X.GetDB() -- Blizzard's standard window (title bar, BuffRadar icon in the portrait @@ -2735,15 +2899,15 @@ local function BuildConfig() K.Register(cfg.closeButton, cfg, L["Close settings"], "button") -- Tabs: Blizzard's bottom tabs on the standard window (named - -- BuffRadarConfigTab1..5, as PanelTemplates expects), otherwise the + -- BuffRadarConfigTab1..6, as PanelTemplates expects), otherwise the -- original row of buttons along the top. cfg.panels, cfg.tabBtns = {}, {} cfg.nativeTabs = native and PanelTemplates_SetNumTabs and PanelTemplates_SetTab and true or false local tabDefs = { - { "look", L["Window"] }, { "alerts", L["Alerts"] }, { "buffs", L["Buffs"] }, - { "behavior", L["Behavior"] }, { "data", L["Ignore & Stats"] }, + { "look", L["Window"], 75 }, { "alerts", L["Alerts"], 75 }, { "buffs", L["Buffs"], 70 }, + { "behavior", L["Behavior"], 98 }, { "data", L["Ignore & Stats"], 126 }, { "readiness", L["Readiness"], 106 }, } - local tabList, prevTab = {}, nil + local tabList, prevTab, fallbackX = {}, nil, 14 for i, td in ipairs(tabDefs) do local key, label = td[1], td[2] local function onClick() SelectTab(key); RefreshConfig() end @@ -2762,9 +2926,10 @@ local function BuildConfig() prevTab = btn tabList[i] = btn else - btn = MakeButton(cfg, "", 106, onClick) + btn = MakeButton(cfg, "", td[3], onClick) btn:SetText(label) - btn:SetPoint("TOPLEFT", 16 + (i - 1) * 112, -40) + btn:SetPoint("TOPLEFT", fallbackX, -40) + fallbackX = fallbackX + td[3] + 4 end K.Register(btn, cfg, label, "tab").key = key cfg.tabBtns[key] = btn @@ -2784,6 +2949,8 @@ local function BuildConfig() cfg:SetClampRectInsets(0, 0, 0, -NATIVE_TAB_DEPTH) end + cfg.readiness = AssignmentUI.BuildReadinessSettings(cfg.panels.readiness) + local function section(panel, text, x, y) local fs = panel:CreateFontString(nil, "OVERLAY", "GameFontNormal") fs:SetPoint("TOPLEFT", x, y) @@ -2944,7 +3111,7 @@ local function BuildConfig() function(v) db.twoCol = v; Refresh() end) cfg.twoColCheck:SetPoint("TOPLEFT", 10, -396) - cfg.wizardBtn = MakeButton(look, "Run the setup wizard", 150, function() + cfg.wizardBtn = MakeButton(look, L["Quick Setup"], 150, function() K.Stop() X.OpenWizard() end) @@ -3379,9 +3546,9 @@ local function BuildConfig() Tip(cfg.clickThroughCheck, "Click-through while locked", "While the window is locked, it and its rows stop catching mouse clicks, so clicks land on the game world behind them. Unlock with /br lock to move or use the window again.") - cfg.throttleCheck = MakeCheck(beh, L["Halve the rescan rate in big groups"], + cfg.throttleCheck = MakeCheck(beh, L["Adaptive scan throttle"], function() return db.scanThrottle end, - function(v) db.scanThrottle = v end) + function(v) db.scanThrottle = v; X.Intel.SettingsChanged(); RefreshConfig() end) cfg.throttleCheck:SetPoint("TOPLEFT", 10, -215) cfg.fastAuraCheck = MakeCheck(beh, L["Skip rescans for aura changes that touch no watched buff"], function() return db.fastAura end, @@ -3608,7 +3775,7 @@ local function BuildConfig() Tip(cfg.gapSlider, "Row spacing", "Extra empty space between the rows, 0 to 8. The window grows to fit. Same as /br rowgap <0-8>.") Tip(cfg.iconSlider, "Buff icon size", "How big the missing-buff icons on each row are, 10 to 24. At 0 the size is automatic (16, or 12 in compact rows). Same as /br iconsize <0|10-24>.") Tip(cfg.displayBtn, "More display options", "Opens a panel with the finer display choices: which parts the coverage line shows, colored edge marks on rows (your assignments, tanks, expiring soon, your buddy's rows), how much detail row tooltips carry, class-colored names, realm names and shortened names.") - Tip(cfg.wizardBtn, "Setup wizard", "Runs the three-page first-run setup again: how you play, the window theme, and your buffs. Same as /br wizard.") + Tip(cfg.wizardBtn, L["Quick Setup"], L["Choose your activity and role, then review the suggested settings. /br wizard"]) Tip(cfg.findCheck, "Name finder", "A small Find box on the window: while it holds text, only players whose name matches are listed. Same as /br findbox; /br find sets the text without the box.") Tip(cfg.cfgScaleDrop, "Settings window scale", "Makes this settings window bigger or smaller.") -- Alerts @@ -3637,7 +3804,7 @@ local function BuildConfig() Tip(cfg.enterCheck, "Instance-entry reminder", "One chat line when you step into a dungeon, raid or battleground while buffs are still missing: how many people still need buffs, and how many casts that is.") Tip(cfg.pullFlashCheck, "Pull-timer flash", "When a group pull timer starts (the game's /countdown, or a boss-mod pull timer from a trusted sender), the border flashes and chat shows the seconds and how many casts are still needed. Same as /br pullflash.") Tip(cfg.fastAuraCheck, "Fast aura updates", "Aura changes that touch no buff you can cast skip the rescan; the steady refresh still runs, and any doubtful payload rescans as before. Same as /br fastaura.") - Tip(cfg.throttleCheck, "Scan throttle", "In groups of more than 20 players, the steady background rescan runs half as often. Refreshes caused by events — a buff landing, someone joining — always happen immediately. For very large raids on slower machines.") + Tip(cfg.throttleCheck, L["Adaptive scan throttle"], L["Slow periodic scans at rest or with high latency. Event refreshes stay responsive."]) Tip(cfg.petsCheck, "Group pets", "Pets in your group get their own rows when they miss Fortitude, Mark of the Wild or Arcane Intellect — click the row to buff the pet. Pets never count in the coverage numbers. Same as /br pets.") Tip(cfg.auraCheck, "Aura / aspect watch", "Forever only: your own row flags it when no hunter aspect or paladin aura is up. Same as /br aura.") Tip(cfg.worldCheck, "World-buff watch", "Forever only: the coverage line lists your active world buffs (Dragonslayer, Warchief's Blessing, Songflower, ...) with the time left. Same as /br worldbuff.") @@ -3913,6 +4080,7 @@ RefreshConfig = function() if cfg.weaponCheck then cfg.weaponCheck:Update() end if cfg.enterCheck then cfg.enterCheck:Update() end if cfg.throttleCheck then cfg.throttleCheck:Update() end + if cfg.readiness and cfg.panels.readiness:IsShown() then cfg.readiness.Update() end if cfg.growCheck then cfg.growCheck:Update() end if cfg.twoColCheck then cfg.twoColCheck:Update() end if cfg.themeBtn then diff --git a/BuffRadar/Coordination.lua b/BuffRadar/Coordination.lua index e70528f..f817d79 100644 --- a/BuffRadar/Coordination.lua +++ b/BuffRadar/Coordination.lua @@ -1064,19 +1064,24 @@ function X.ContextOK(key) return true end -function X.WeaponEnchantMissing() +function X.WeaponEnchantMissing(strict) local fn = _G.GetWeaponEnchantInfo - if not fn then return false end + if not fn then return nil 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 + if not ok then return nil end + local function missing(has, slot) + if not Readable(has) then return nil end + if has == true or has == 1 then return false end + if has ~= false and has ~= 0 then return nil end + if not _G.GetInventoryItemID then return not strict or nil end local okI, id = pcall(_G.GetInventoryItemID, "player", slot) - return okI and Readable(id) and id ~= nil + if not okI then return nil end + if type(id) == "nil" then return false end + if Readable(id) and type(id) == "number" then return id > 0 end end - if not hasMH and equipped(16) then return true end - if not hasOH and equipped(17) then return true end - return false + local mh, oh = missing(hasMH, 16), missing(hasOH, 17) + if mh or oh then return true end + if mh == false and oh == false then return false end end -- Instance-entry reminder (1.7.0): stepping into a dungeon, raid or diff --git a/BuffRadar/Debuffs.lua b/BuffRadar/Debuffs.lua new file mode 100644 index 0000000..7e3a4e7 --- /dev/null +++ b/BuffRadar/Debuffs.lua @@ -0,0 +1,257 @@ +-- BuffRadar - optional, event-driven harmful aura strip. It never casts. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, ns = ... +local X = ns.X +local D, L, Print = {}, X.L, X.Print +X.Debuffs = D + +local db, frame, listening, encounter +local found, pending = { player = {}, focus = {} }, {} +local fallbackIcon = "Interface\\Icons\\INV_Misc_QuestionMark" +local unitLabels = { player = "Player", focus = "Focus" } +local function Wipe(t) for k in pairs(t) do t[k] = nil end end + +local function Fields(aura) return aura.spellId, aura.name, aura.icon, aura.applications end +local function Tuple(...) return select("#", ...), ... end +local function Legacy(lookup, unit, index) return Tuple(lookup(unit, index)) end + +-- An explicit nil at the end of a list is different from a refused read. +-- The same guarded exact-ID reader is used for the personal consumable check. +function D.ReadAura(unit, index, harmful) + local modern = C_UnitAuras and (harmful and C_UnitAuras.GetDebuffDataByIndex or not harmful and C_UnitAuras.GetBuffDataByIndex) + local indexed = C_UnitAuras and C_UnitAuras.GetAuraDataByIndex + local ok, id, name, icon, stacks + if modern or indexed then + local aura, answered = X.QueryAura(modern or indexed, unit, index, harmful and "HARMFUL" or "HELPFUL") + if not aura then return true, answered end + ok, id, name, icon, stacks = pcall(Fields, aura) + else + local legacyLookup = harmful and UnitDebuff or not harmful and UnitBuff + if type(legacyLookup) ~= "function" then return true, false end + local read, count, label, image, applications, _, _, _, _, _, _, spell = pcall(Legacy, legacyLookup, unit, index) + if not read or count == 0 then return true, false end + if type(label) == "nil" then return true, true end + ok, id, name, icon, stacks = read, spell, label, image, applications + end + if not ok or not X.Readable(id) or not X.Settings.PositiveID(id) then return false end + if not X.Readable(name) or type(name) ~= "string" then name = nil end + if not X.Readable(icon) or (type(icon) ~= "number" and type(icon) ~= "string") then icon = fallbackIcon end + if not X.Readable(stacks) or type(stacks) ~= "number" or not (stacks >= 0 and stacks <= 9999) then stacks = nil end + return false, nil, id, name, icon, stacks +end + +local function RuleActive(rule) + return rule.encounterID == 0 or rule.encounterID == encounter +end + +local function MakeIcon() + local icon = CreateFrame("Frame", nil, frame) + icon:SetSize(34, 34) + icon:EnableMouse(true) + icon.texture = icon:CreateTexture(nil, "ARTWORK") + icon.texture:SetAllPoints(icon) + icon.stacks = icon:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") + icon.stacks:SetPoint("BOTTOMRIGHT", -1, 1) + icon.unitLabel = icon:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + icon.unitLabel:SetPoint("TOP", icon, "BOTTOM", 0, -2) + icon:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_TOP") + GameTooltip:AddLine(self.title) + GameTooltip:AddLine(L[unitLabels[self.unit]]) + GameTooltip:Show() + end) + icon:SetScript("OnLeave", function() GameTooltip:Hide() end) + icon:SetScript("OnHide", function(self) + if GameTooltip.GetOwner and GameTooltip:GetOwner() == self then GameTooltip:Hide() end + end) + return icon +end + +local function Draw() + local n = 0 + for index, rule in ipairs(db.debuffRules) do + local aura = found[rule.unit][index] + if aura then + n = n + 1 + local icon = frame.icons[n] + if not icon then + icon = MakeIcon() + frame.icons[n] = icon + icon:SetPoint("LEFT", frame, "LEFT", (n - 1) * 54, 0) + end + icon.title, icon.unit = aura.name, rule.unit + icon.texture:SetTexture(aura.icon) + icon.stacks:SetText(aura.stacks and (aura.stacks > 0 and math.floor(aura.stacks) or "") or "?") + icon.unitLabel:SetText(L[unitLabels[rule.unit]]) + icon:Show() + end + end + for i = n + 1, #frame.icons do frame.icons[i]:Hide() end + frame:SetWidth(math.max(1, (n - 1) * 54 + 34)) + frame:SetShown(n > 0) +end + +local function Watches(unit) + for _, rule in ipairs(db.debuffRules) do + if rule.unit == unit and RuleActive(rule) then return true end + end + return false +end + +local function Scan(unit) + local result = found[unit] + Wipe(result) + if X.PlayerSuspended() or not Watches(unit) or not X.UnitPresent(unit) then return end + for i = 1, 40 do + local done, _, spell, name, icon, stacks = D.ReadAura(unit, i, true) + if done then break end + if spell then + for j, rule in ipairs(db.debuffRules) do + if rule.unit == unit and rule.spellID == spell and RuleActive(rule) + and (not result[j] or (stacks or 0) > (result[j].stacks or 0)) then + result[j] = { name = name or tostring(spell), icon = icon, stacks = stacks } + end + end + end + end +end + +function D.Clear() + Wipe(pending) + Wipe(found.player) + Wipe(found.focus) + if frame then + for _, icon in ipairs(frame.icons) do icon:Hide() end + frame:Hide() + end +end + +function D.Refresh() + if not listening then return end + Wipe(pending) + Scan("player") + Scan("focus") + Draw() +end + +local function RefreshUnit(unit) + pending[unit] = nil + Scan(unit) + Draw() +end + +local function OnEvent(_, event, unit) + if not listening then return end + if event == "PLAYER_FOCUS_CHANGED" then + RefreshUnit("focus") -- clear the old focus immediately + elseif X.Readable(unit) and (unit == "player" or unit == "focus") and Watches(unit) then + if pending[unit] then return end + if C_Timer and C_Timer.After then + local token = {} + pending[unit] = token + C_Timer.After(0.1, function() + if pending[unit] == token then RefreshUnit(unit) end + end) + else + RefreshUnit(unit) + end + end +end + +function D.Encounter(id) + encounter = X.Readable(id) and X.Settings.PositiveID(id) and id or nil + D.Refresh() +end + +function D.Apply() + local enable = db and db.debuffWatch and not db.liteMode and #db.debuffRules > 0 + if enable then + if not frame then + frame = CreateFrame("Frame", "BuffRadarDebuffWatch", UIParent) + frame:SetPoint("CENTER", UIParent, "CENTER", 0, -168) + frame:SetHeight(34) + frame:SetClampedToScreen(true) + frame.icons = {} + frame:SetScript("OnEvent", OnEvent) + frame:Hide() + end + if not listening then + local registered = frame.RegisterUnitEvent and pcall(frame.RegisterUnitEvent, frame, "UNIT_AURA", "player", "focus") + if not registered then pcall(frame.RegisterEvent, frame, "UNIT_AURA") end + pcall(frame.RegisterEvent, frame, "PLAYER_FOCUS_CHANGED") + listening = true + end + D.Refresh() + elseif listening then + listening = false + frame:UnregisterEvent("UNIT_AURA") + frame:UnregisterEvent("PLAYER_FOCUS_CHANGED") + D.Clear() + end +end + +function D.SetRule(id, unit, boss) + if not X.Settings.ValidDebuffRule(id, unit, boss) then + Print(L["Use a valid debuff spell ID, player or focus, and an optional encounter ID."]) + return false + end + for _, rule in ipairs(db.debuffRules) do + if rule.spellID == id and rule.unit == unit then + rule.encounterID = boss + D.Refresh() + return true + end + end + if #db.debuffRules >= X.Settings.MaxDebuffRules then Print(L["Debuff watch limit reached."]); return false end + db.debuffRules[#db.debuffRules + 1] = { spellID = id, unit = unit, encounterID = boss } + D.Apply() + return true +end + +function D.Remove(id, unit) + for i, rule in ipairs(db.debuffRules) do + if rule.spellID == id and rule.unit == unit then + table.remove(db.debuffRules, i) + D.Apply() + return true + end + end + Print(L["That debuff is not on the watch list."]) + return false +end + +function D.RuleLabel(rule) + local ok, name = pcall(X.Core.SpellName, rule.spellID) + local label = ok and X.Readable(name) and type(name) == "string" and (name .. " #" .. rule.spellID) or "#" .. rule.spellID + return label .. " · " .. L[unitLabels[rule.unit]] .. (rule.encounterID > 0 + and (" · " .. string.format(L["Encounter %d"], rule.encounterID)) or "") +end + +X.ext.debuff = function(rest) + local action, args = rest:lower():match("^(%S*)%s*(.-)$") + local id, unit, boss = args:match("^(%d+)%s*(%a*)%s*(%d*)$") + unit = unit == "" and "player" or unit + if (action == "on" or action == "off") and args == "" then + db.debuffWatch = action == "on" + Print(string.format(L["Debuff watch: %s"], L[db.debuffWatch and "On" or "Off"])) + if db.debuffWatch and db.liteMode then Print(L["Debuff watch is paused in Lite mode."]) end + D.Apply() + elseif action == "add" and id then + if D.SetRule(tonumber(id), unit, boss == "" and 0 or tonumber(boss)) then Print(L["Debuff rule saved."]) end + elseif action == "remove" and id and boss == "" then + D.Remove(tonumber(id), unit) + elseif (action == "" or action == "list") and args == "" then + if #db.debuffRules == 0 then Print(L["No debuffs are being tracked."]) end + for _, rule in ipairs(db.debuffRules) do Print(D.RuleLabel(rule)) end + else + Print(L["Use /br debuff on|off|list, add [player|focus] [encounter ID], or remove [player|focus]."]) + end + if X.RefreshConfig then X.RefreshConfig() end + return true +end + +X.OnDBLoaded(function(value) + db, encounter = value, nil + D.Apply() +end) diff --git a/BuffRadar/Extras.lua b/BuffRadar/Extras.lua index 1615e41..50154d2 100644 --- a/BuffRadar/Extras.lua +++ b/BuffRadar/Extras.lua @@ -441,13 +441,9 @@ function X.PerfReport() Print(string.format("Perf: UNIT_AURA payloads %d · skipped by fast aura %d", probe.seen, probe.skipped or 0)) end - local getMem = (C_AddOns and C_AddOns.GetAddOnMemoryUsage) or _G.GetAddOnMemoryUsage - local upd = (C_AddOns and C_AddOns.UpdateAddOnMemoryUsage) or _G.UpdateAddOnMemoryUsage - if getMem then - if upd then pcall(upd) end - local ok, kb = pcall(getMem, "BuffRadar") - if ok and type(kb) == "number" then Print(string.format("Perf: addon memory %.0f KB", kb)) end - end + local kb = X.Intel.MemoryKB() + if kb then Print(string.format("Perf: addon memory %.0f KB", kb)) end + Print(X.Intel.PaceText()) end --------------------------------------------------------------------------- @@ -559,28 +555,41 @@ X.pullProbe = { stSeen = 0, stTypes = {}, d5 = 0 } X.pull = nil function X.PullStart(secs, source) - if secs <= 0 then X.pull = nil; return end -- a zero timer is a cancel - local db = X.GetDB and X.GetDB() - if not db or not db.pullFlash then return end - if InCombatLockdown and InCombatLockdown() then return end + if not X.Readable(secs) or type(secs) ~= "number" or not (secs >= 0 and secs <= 600) then return end + if secs == 0 then + if X.pull and X.pull.source == source then + X.pull = nil + X.Core.QueueRefresh() + end + return + end + local db = X.GetDB() + if not db or (not db.pullFlash and not X.Intel.ForecastEnabled()) then return end + if InCombatLockdown() or X.PlayerSuspended() then return end local casts = 0 - for _, tt in pairs(X.tally or {}) do casts = casts + (tt.miss or 0) end - if casts <= 0 then return end - local pull = { endsAt = GetTime() + secs, source = source } + if db.pullFlash then + for _, tt in pairs(X.tally or {}) do casts = casts + (tt.miss or 0) end + end + local flash = casts > 0 + if not flash and not X.Intel.ForecastEnabled() then return end + local pull = { endsAt = GetTime() + secs, source = source, forecastOnly = not flash } X.pull = pull - Print(string.format("Pull in %ds (%s) -- %d casts still needed.", secs, source, casts)) - if X.Flash then X.Flash() end + if flash then + Print(string.format("Pull in %ds (%s) -- %d casts still needed.", secs, source, casts)) + if X.Flash then X.Flash() end + end + if X.Intel.ForecastEnabled() then X.Core.QueueRefresh() end if C_Timer and C_Timer.After then - if secs > 3 then + if flash and secs > 3 then C_Timer.After(secs - 3, function() - if X.pull == pull and X.Flash then X.Flash() end + if X.pull == pull and db.pullFlash and X.Flash then X.Flash() end end) end C_Timer.After(secs, function() if X.pull == pull then X.pull = nil - if X.Flash then X.Flash() end - if X.Refresh then X.Refresh() end + if flash and db.pullFlash and X.Flash then X.Flash() end + X.Core.QueueRefresh() end end) end @@ -590,9 +599,12 @@ do local pf = CreateFrame("Frame") X.pullFrame = pf pf:RegisterEvent("ADDON_LOADED") - pf:RegisterEvent("START_TIMER") + local playerCountdown = Enum and Enum.StartTimerType and Enum.StartTimerType.PlayerCountdown or 2 + for _, event in ipairs({ "START_TIMER", "START_PLAYER_COUNTDOWN", "CANCEL_PLAYER_COUNTDOWN", "STOP_TIMER_OF_TYPE" }) do + pcall(pf.RegisterEvent, pf, event) + end pf:RegisterEvent("CHAT_MSG_ADDON") - pf:SetScript("OnEvent", function(_, ev, a1, a2, a3, a4) + pf:SetScript("OnEvent", function(_, ev, a1, a2, _, a4) local probe = X.pullProbe if ev == "ADDON_LOADED" then if a1 == "BuffRadar" then @@ -605,17 +617,19 @@ do end if ev == "START_TIMER" then probe.stSeen = probe.stSeen + 1 - if a1 ~= nil then probe.stTypes[a1] = true end - local secs = (type(a2) == "number" and a2) or (type(a3) == "number" and a3) or 0 - X.PullStart(secs, "countdown") - return - end - if ev == "CHAT_MSG_ADDON" and X.Readable(a1) and a1 == "D5" + if X.Readable(a1) and type(a1) == "number" and a1 >= 0 and a1 <= 10 then probe.stTypes[a1] = true end + if X.Readable(a1) and a1 == playerCountdown then X.PullStart(a2, "countdown") end + elseif ev == "START_PLAYER_COUNTDOWN" then + -- Unlike START_TIMER, the first argument is the initiator's GUID. + X.PullStart(a2, "countdown") + elseif ev == "CANCEL_PLAYER_COUNTDOWN" or (ev == "STOP_TIMER_OF_TYPE" and X.Readable(a1) and a1 == playerCountdown) then + X.PullStart(0, "countdown") + elseif ev == "CHAT_MSG_ADDON" and X.Readable(a1) and a1 == "D5" and type(a2) == "string" and X.Readable(a2) then local sub, rest = a2:match("^(%u+)%s+(.+)$") if sub == "PT" then probe.d5 = probe.d5 + 1 - local secs = tonumber((rest or ""):match("(%d+)")) + local secs = tonumber(rest:match("^(%d+)%f[%s%z]")) if secs and X.SenderTrusted and X.SenderTrusted(a4) then X.PullStart(secs, "boss mod") end diff --git a/BuffRadar/Intelligence.lua b/BuffRadar/Intelligence.lua new file mode 100644 index 0000000..1b0faa7 --- /dev/null +++ b/BuffRadar/Intelligence.lua @@ -0,0 +1,300 @@ +-- BuffRadar - prediction, contextual priority and periodic scan policy. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, ns = ... +local X = ns.X +local I, L, Print = {}, X.L, X.Print +X.Intel = I + +local db +local wipeUntil, fastUntil, manualDeadline = 0, 0, nil +local nextLatencySample, latency, lastTicks = 0, nil, 1 +local scanAt, lead, horizon, instanceKey, grouped, recovering +local expiring, firstEnd, firstSpell, firstUnit, critical +local forecastWasCritical, noticedSpell, noticedEnd, notifyAfter +local CRITICAL_SECONDS = 15 +local defensive = { FORTITUDE = true, MARK_OF_THE_WILD = true, BLESS_KINGS = true, BLESS_SANCTUARY = true } +local mana = { ARCANE_INTELLECT = true, DIVINE_SPIRIT = true, BLESS_WISDOM = true } + +local function Deadline(now) + local ends = X.pull and X.pull.endsAt + if not ends or ends <= now then ends = 0 end + if manualDeadline and manualDeadline > now then ends = math.max(ends, manualDeadline) end + return ends > now and ends or nil +end + +function I.ForecastEnabled() + return db and not db.liteMode and db.forecastSeconds > 0 +end + +function I.InstanceID() + if type(GetInstanceInfo) ~= "function" then return end + local ok, _, kind, _, _, _, _, _, id = pcall(GetInstanceInfo) + if ok and X.Readable(kind) and (kind == "raid" or kind == "party") + and X.Readable(id) and X.Settings.PositiveID(id) then return id end +end + +function I.BeginScan() + scanAt = GetTime() + lead = I.ForecastEnabled() and db.forecastSeconds or 0 + local deadline = lead > 0 and Deadline(scanAt) + horizon = deadline and (deadline - scanAt + lead) or lead + local id = db.smartPriority and next(db.instancePriority) and I.InstanceID() + instanceKey = id and db.instancePriority[id] or nil + grouped = db.smartPriority and X.InGroup() + recovering = grouped and scanAt < wipeUntil + expiring, firstEnd, firstSpell, firstUnit, critical = 0, nil, nil, nil, false + -- The coverage line already watches the last five minutes. Reuse the same + -- family lookup and only extend it when a real preparation timer needs it. + return math.max(300, horizon) +end + +local function MatchesInstance(key, blessing) + return instanceKey and (instanceKey == key or instanceKey == blessing) +end + +function I.Observe(unit, key, spell, seconds, blessing) + if seconds == nil then return end + local important = defensive[blessing or key] or (db.smartPriority and MatchesInstance(key, blessing)) + if important and seconds <= CRITICAL_SECONDS then critical = true end + if seconds <= 0 or seconds > horizon then return end + local ends = scanAt + seconds + expiring = expiring + 1 + if not firstEnd or ends < firstEnd then firstEnd, firstSpell, firstUnit = ends, spell, unit end +end + +function I.ForecastText(spell, name, endsAt) + return string.format(L["Forecast: %s on %s expires in %ds."], spell, name, + math.max(1, math.ceil(endsAt - GetTime()))) +end + +function I.ScanResult() + local name = firstUnit and (X.UnitNameOf(firstUnit) or firstUnit) + -- Treat nearly simultaneous expiry of the same buff as one notice. Keep + -- the cooldown across roster refreshes; a different expiry can still warn + -- even if the forecast never became completely empty. + local notice = firstEnd and scanAt >= notifyAfter + and (not noticedEnd or firstSpell ~= noticedSpell or math.abs(firstEnd - noticedEnd) > 1) + if notice then + noticedSpell, noticedEnd, notifyAfter = firstSpell, firstEnd, scanAt + 5 + Print(I.ForecastText(firstSpell, name, firstEnd)) + end + local pulse = notice or (critical and not forecastWasCritical) + forecastWasCritical = critical + -- Round only the exported timestamp to avoid publishing tiny timer jitter. + return critical, expiring, firstSpell, name, firstEnd and math.ceil(firstEnd), pulse +end + +function I.ForgetAlerts() + forecastWasCritical = false +end + +-- Lower tiers win. The saved manual order breaks ties within a tier; +-- contextual promotion never writes to it or makes a new spell eligible. +function I.Tier(entry, key, blessing) + if not grouped or not entry.group or entry.pet then return 3 end + if MatchesInstance(key, blessing) then return 0 end + local family = blessing or key + if (recovering or entry.rezzed) and defensive[family] then return 1 end + if entry.groupRole == "TANK" and (defensive[family] or family == "FEAR_WARD" or family == "THORNS") then return 2 end + if entry.groupRole == "HEALER" and mana[family] then return 2 end + return 3 +end + +function I.MarkWipe() + if db and db.smartPriority and X.InGroup() then wipeUntil = GetTime() + 90 end +end + +function I.ClearPreparation() + manualDeadline, X.pull = nil, nil +end + +function I.ResetContext() + wipeUntil, noticedSpell, noticedEnd, notifyAfter = 0, nil, nil, 0 + I.ClearPreparation() + I.ForgetAlerts() +end + +function I.WakeAfterCombat() + fastUntil = GetTime() + 3 +end + +function I.ScanTicks(groupSize) + if not db or not db.scanThrottle then lastTicks = 1; return 1 end + local now = GetTime() + local deadline = Deadline(now) + if now < fastUntil or (deadline and deadline - now <= 10) then lastTicks = 1; return 1 end + if now >= nextLatencySample then + nextLatencySample = now + 5 + latency = nil + if type(GetNetStats) == "function" then + local ok, _, _, home, world = pcall(GetNetStats) + if ok then + for i = 1, 2 do + local v = i == 1 and home or world + if X.Readable(v) and type(v) == "number" and v >= 0 and v < math.huge then + latency = math.max(v, latency or 0) + end + end + end + end + end + local speed = X.ReadUnitNumber(GetUnitSpeed, "player") + if latency and latency >= 250 then + lastTicks = speed == 0 and 4 or 3 + elseif speed and speed > 0 then + lastTicks = 1 + else + local large = groupSize() > 20 + lastTicks = speed == 0 and (large and 3 or 2) or (large and 2 or 1) + end + return lastTicks +end + +function I.PaceText() + return string.format(L["Periodic scan: %.1fs · Latency: %s"], (db.scanThrottle and lastTicks or 1) * X.Core.UpdateInterval, + latency and string.format(L["%d ms"], math.floor(latency)) or L["Unknown"]) +end + +function I.MemoryKB() + local update = (C_AddOns and C_AddOns.UpdateAddOnMemoryUsage) or _G.UpdateAddOnMemoryUsage + local read = (C_AddOns and C_AddOns.GetAddOnMemoryUsage) or _G.GetAddOnMemoryUsage + if type(read) ~= "function" then return end + if type(update) == "function" then pcall(update) end + local kb = X.ReadUnitNumber(read, "BuffRadar") + if kb and kb >= 0 then return kb end +end + +function I.MemoryReport() + local kb = I.MemoryKB() + Print(kb and string.format(L["BuffRadar memory: %.0f KB (game-reported total)."], kb) + or L["BuffRadar memory: unavailable on this client."]) + Print(L["The game does not report memory by feature."]) + Print(string.format(L["Queue rows: %d · Saved casts: %d · Debuff rules: %d"], + X.Status.Count(), #db.history, #db.debuffRules)) + Print(string.format(L["Lite mode: %s"], L[db.liteMode and "On" or "Off"])) + Print(I.PaceText()) +end + +function I.SettingsChanged() + if not I.ForecastEnabled() then + manualDeadline, noticedSpell, noticedEnd, notifyAfter = nil, nil, nil, 0 + if X.pull and X.pull.forecastOnly then X.pull = nil end + end + if db.liteMode and X.CloseRaidPreparation then X.CloseRaidPreparation() end + if X.Debuffs then X.Debuffs.Apply() end + if X.UpdateMinimapStatus then X.UpdateMinimapStatus() end + if X.TickMinimapPulse then X.TickMinimapPulse() end + X.Core.QueueRefresh() +end + +function I.SetForecast(seconds) + if type(seconds) ~= "number" or seconds ~= math.floor(seconds) or seconds < 0 or seconds > 300 then + Print(L["Enter a forecast time from 0 to 300 seconds (0 turns it off)."]) + return false + end + I.ForgetAlerts() + db.forecastSeconds = seconds + I.SettingsChanged() + return true +end + +function I.SetInstancePriority(id, key) + if not X.Settings.PositiveID(id) then Print(L["An instance ID is required."]); return false end + if type(key) == "string" and key:lower() == "clear" then + db.instancePriority[id] = nil + else + key = type(key) == "string" and key:upper() or "" + if not X.Settings.PriorityKey(key) then Print(L["Use a buff key from /br buffs."]); return false end + if not db.instancePriority[id] then + local count = 0 + for _ in pairs(db.instancePriority) do count = count + 1 end + if count >= X.Settings.MaxInstanceRules then Print(L["Instance rule limit reached."]); return false end + end + db.instancePriority[id] = key + end + X.Core.QueueRefresh() + return true +end + +local function ShowForecast() + Print(string.format(L["Forecast lead: %ds (0 = off)."], db.forecastSeconds)) + if db.liteMode then Print(L["Forecasts are paused in Lite mode."]); return end + local status = X.Status.Summary() + if status.firstExpiry and status.firstExpiry.endsAt > GetTime() then + local entry = status.firstExpiry + Print(I.ForecastText(entry.spell, entry.name, entry.endsAt)) + end +end + +X.ext.forecast = function(rest) + local input = rest:lower() + local timer = input:match("^timer%s+(%S+)$") + if input == "" then ShowForecast() + elseif timer then + local seconds = tonumber(timer) + if timer == "off" or seconds == 0 then manualDeadline = nil + elseif not I.ForecastEnabled() then Print(L["Enable forecasts before setting a timer."]); return true + elseif not seconds or seconds ~= math.floor(seconds) or seconds < 1 or seconds > 600 then + Print(L["Use /br forecast timer <1-600|off>."]); return true + elseif InCombatLockdown() or X.PlayerSuspended() then return true + else + manualDeadline = GetTime() + seconds + Print(string.format(L["Local preparation timer: %ds."], seconds)) + end + X.Core.QueueRefresh() + elseif I.SetForecast(input == "off" and 0 or tonumber(input)) then + Print(string.format(L["Forecast lead: %ds (0 = off)."], db.forecastSeconds)) + end + if X.RefreshConfig then X.RefreshConfig() end + return true +end + +X.ext.smartprio = function(rest) + local input = rest:lower() + local here = input:match("^here%s+(%S+)$") + local id, key = input:match("^instance%s+(%d+)%s+(%S+)$") + if input == "" or input == "on" or input == "off" then + db.smartPriority = input == "on" or (input == "" and not db.smartPriority) + if not db.smartPriority then wipeUntil = 0 end + Print(string.format(L["Smart priority: %s"], L[db.smartPriority and "On" or "Off"])) + X.Core.QueueRefresh() + elseif here or id then + local instance = here and I.InstanceID() or tonumber(id) + if I.SetInstancePriority(instance, here or key) then + Print(string.format(L["Instance %d: %s"], instance, db.instancePriority[instance] or L["Default"])) + end + elseif input == "list" then + local ids = {} + for instance in pairs(db.instancePriority) do ids[#ids + 1] = instance end + table.sort(ids) + if #ids == 0 then Print(L["No instance priority rules saved."]) end + for _, instance in ipairs(ids) do Print(string.format(L["Instance %d: %s"], instance, db.instancePriority[instance])) end + else + Print(L["Use /br smartprio [on|off|list], here , or instance ."]) + end + if X.RefreshConfig then X.RefreshConfig() end + return true +end + +local function Toggle(setting, label, usage) + return function(rest) + local value = rest:lower() + if value ~= "" and value ~= "on" and value ~= "off" then Print(usage); return true end + db[setting] = value == "on" or (value == "" and not db[setting]) + Print(string.format(label, L[db[setting] and "On" or "Off"])) + I.SettingsChanged() + if X.RefreshConfig then X.RefreshConfig() end + return true + end +end +X.ext.lite = Toggle("liteMode", L["Lite mode: %s"], "/br lite [on|off]") +X.ext.minimapstatus = Toggle("statusMinimap", L["Minimap status: %s"], "/br minimapstatus [on|off]") +X.ext.visual = Toggle("visualAlerts", L["Visual alerts: %s"], "/br visual [on|off]") + +X.OnDBLoaded(function(value) + db = value + fastUntil = 0 + nextLatencySample, latency, lastTicks = 0, nil, 1 + I.ResetContext() +end) diff --git a/BuffRadar/Locales/deDE.lua b/BuffRadar/Locales/deDE.lua index 7ab7e89..c0f6e80 100644 --- a/BuffRadar/Locales/deDE.lua +++ b/BuffRadar/Locales/deDE.lua @@ -474,4 +474,123 @@ NS.Locales.deDE = { ["Find in this tab"] = "In diesem Reiter suchen", [" /br config navigate - keyboard navigation /br config narrate - keyboard navigation with speech"] = " /br config navigate - Tastaturnavigation /br config narrate - Tastaturnavigation mit Sprachausgabe", + ["%d broken · Lowest %d%%"] = "%d kaputt · Niedrigster Wert %d%%", + ["%d cast targets · %d forecast buffs"] = "%d Zauberziele · %d erwartete Ablaufwarnungen", + ["%d ms"] = "%d ms", + ["Active pet"] = "Aktiver Begleiter", + ["Adaptive scan throttle"] = "Adaptive Scan-Drosselung", + ["Adaptive scan throttle: %s"] = "Adaptive Scan-Drosselung: %s", + ["An instance ID is required."] = "Eine Instanz-ID ist erforderlich.", + ["Apply here"] = "Hier anwenden", + ["Briefly highlight the window or minimap without sound. Respects Reduced Motion."] = "Hebt das Fenster oder die Minikarte kurz und lautlos hervor. Berücksichtigt reduzierte Bewegung.", + ["Buff coverage could not be verified"] = "Buff-Abdeckung nicht überprüfbar", + ["Buff intelligence"] = "Buff-Prognose und Priorität", + ["Buff scan paused"] = "Buff-Suche pausiert", + ["Buff scan paused in combat"] = "Buff-Suche im Kampf pausiert", + ["Buff scan paused while dead"] = "Buff-Suche im Tod pausiert", + ["BuffRadar memory: %.0f KB (game-reported total)."] = "BuffRadar-Speicher: %.0f KB (Gesamtwert des Spiels).", + ["BuffRadar memory: unavailable on this client."] = "BuffRadar-Speicher: in diesem Client nicht verfügbar.", + ["Buffs need attention"] = "Buffs benötigen Aufmerksamkeit", + ["Checked buffs are covered"] = "Geprüfte Buffs sind aktiv", + ["Choose your activity and role, then review the suggested settings. /br wizard"] = "Wähle Spielweise und Rolle und prüfe danach die Vorschläge. /br wizard", + ["Consumable aura ID (0 = off)"] = "Verbrauchs-Aura-ID (0 = aus)", + ["Copy buff status"] = "Buff-Status kopieren", + ["Copy the current buff status"] = "Aktuellen Buff-Status kopieren", + ["Copy the feedback link and open it in your browser."] = "Kopiere den Feedback-Link und öffne ihn im Browser.", + ["Debuff rule saved."] = "Debuff-Regel gespeichert.", + ["Debuff watch is paused in Lite mode."] = "Die Debuff-Überwachung pausiert im Lite-Modus.", + ["Debuff watch limit reached."] = "Das Limit für überwachte Debuffs ist erreicht.", + ["Debuff watch: %s"] = "Debuff-Überwachung: %s", + ["Dungeons / Mythic+"] = "Dungeons / Mythisch+", + ["Enable forecasts before setting a timer."] = "Aktiviere die Prognose, bevor du einen Timer setzt.", + ["Encounter %d"] = "Begegnung %d", + ["Encounter ID (optional)"] = "Begegnungs-ID (optional)", + ["Encounter debuffs"] = "Begegnungs-Debuffs", + ["Enter a consumable aura spell ID, or 0 to clear it."] = "Gib eine Verbrauchs-Aura-ID ein oder lösche sie mit 0.", + ["Enter a forecast time from 0 to 300 seconds (0 turns it off)."] = "Gib eine Vorwarnzeit von 0 bis 300 Sekunden ein (0 = aus).", + ["Equipment durability"] = "Haltbarkeit der Ausrüstung", + ["Feedback"] = "Feedback", + ["Focus"] = "Fokus", + ["Forecast lead: %ds (0 = off)."] = "Vorwarnzeit: %d s (0 = aus).", + ["Forecast seconds (0 = off)"] = "Vorwarnzeit in Sekunden (0 = aus)", + ["Forecast: %s on %s expires in %ds."] = "Prognose: %s auf %s läuft in %d s ab.", + ["Forecasts are paused in Lite mode."] = "Prognosen pausieren im Lite-Modus.", + ["Healthstone in bags"] = "Gesundheitsstein in den Taschen", + ["Important buff missing or expiring"] = "Wichtiger Buff fehlt oder läuft aus", + ["Instance %d: %s"] = "Instanz %d: %s", + ["Instance rule limit reached."] = "Das Limit für Instanzregeln ist erreicht.", + ["Lite mode"] = "Lite-Modus", + ["Lite mode: %s"] = "Lite-Modus: %s", + ["Local preparation timer: %ds."] = "Persönlicher Vorbereitungstimer: %d s.", + ["Lowest %d%%"] = "Niedrigster Wert %d%%", + ["Memory usage"] = "Speicherverbrauch", + ["Minimap status: %s"] = "Minikartenstatus: %s", + ["Missing"] = "Fehlt", + ["Most buffs needed"] = "Meiste fehlende Buffs", + ["Name"] = "Name", + ["New to BuffRadar? Run /br wizard for Quick Setup."] = "Neu bei BuffRadar? Starte die Schnelleinrichtung mit /br wizard.", + ["No applicable buffs to check"] = "Keine passenden Buffs zu prüfen", + ["No aura configured"] = "Keine Aura eingerichtet", + ["No debuffs are being tracked."] = "Es werden keine Debuffs überwacht.", + ["No durable equipment"] = "Keine Ausrüstung mit Haltbarkeit", + ["No instance priority rules saved."] = "Keine Instanzprioritäten gespeichert.", + ["No missing coating"] = "Keine Beschichtung fehlt", + ["Open personal checks"] = "Persönliche Checks öffnen", + ["Optional consumable"] = "Optionaler Verbrauchsgegenstand", + ["Order: %s · Forecast: %ds (0 = off)"] = "Reihenfolge: %s · Vorwarnzeit: %d s (0 = aus)", + ["Pause the checklist, forecasts, debuffs and optional aura watches without changing their settings."] = "Pausiert Checkliste, Prognosen, Debuffs und optionale Aura-Checks, ohne ihre Einstellungen zu ändern.", + ["Performance & alerts"] = "Leistung & Warnungen", + ["Periodic scan: %.1fs · Latency: %s"] = "Regelmäßiger Scan: %.1f s · Latenz: %s", + ["Personal"] = "Persönlich", + ["Personal consumable aura ID: %d (0 = off)."] = "Persönliche Verbrauchs-Aura-ID: %d (0 = aus).", + ["Player"] = "Spieler", + ["Present"] = "Vorhanden", + ["Press Enter to save."] = "Mit Eingabetaste speichern.", + ["Priority buff key for this instance"] = "Vorrangiger Buff-Schlüssel in dieser Instanz", + ["Promote buffs for tanks, healers, recovery and your instance rules without changing eligibility."] = "Priorisiert Buffs für Tanks, Heiler, nach einem Wipe und nach Instanzregeln, ohne die Auswahl zu ändern.", + ["Queue rows: %d · Saved casts: %d · Debuff rules: %d"] = "Warteschlangenzeilen: %d · Gespeicherte Zauber: %d · Debuff-Regeln: %d", + ["Quick Setup"] = "Schnelleinrichtung", + ["Quick Setup complete. Run /br wizard to make new choices."] = "Schnelleinrichtung abgeschlossen. Mit /br wizard kannst du erneut wählen.", + ["Quick Setup is unavailable in combat."] = "Die Schnelleinrichtung ist im Kampf nicht verfügbar.", + ["Quick Setup · Step %d of 3"] = "Schnelleinrichtung · Schritt %d von 3", + ["Quiet alerts and the minimap status are enabled. Buff selections and keybinds are kept."] = "Lautlose Warnungen und der Minikartenstatus werden aktiviert. Buff-Auswahl und Tastenbelegung bleiben erhalten.", + ["Quiet visual alerts"] = "Lautlose visuelle Warnungen", + ["Raid Preparation is available in WoW: Forever."] = "Die Schlachtzugsvorbereitung ist in WoW: Forever verfügbar.", + ["Raid Preparation is paused in Lite mode."] = "Die Schlachtzugsvorbereitung pausiert im Lite-Modus.", + ["Raids"] = "Schlachtzüge", + ["Readiness"] = "Vorbereitung", + ["Remove"] = "Entfernen", + ["Repair recommended"] = "Reparatur empfohlen", + ["Group only: %s · Group casts: %s · Pause in cities: %s"] = "Nur Gruppe: %s · Gruppenzauber: %s · Stadtpause: %s", + ["Save watch"] = "Überwachung speichern", + ["Shift-right-click: Quick Setup"] = "Umschalt-Rechtsklick: Schnelleinrichtung", + ["Show watched debuffs"] = "Überwachte Debuffs anzeigen", + ["Slow periodic scans at rest or with high latency. Event refreshes stay responsive."] = "Verlangsamt regelmäßige Scans im Stillstand oder bei hoher Latenz. Ereignisse bleiben reaktionsschnell.", + ["Smart buff priority"] = "Intelligente Buff-Priorität", + ["Smart priority: %s"] = "Intelligente Priorität: %s", + ["Solo play"] = "Alleine", + ["Some buff coverage could not be verified"] = "Ein Teil der Buff-Abdeckung ist nicht überprüfbar", + ["Some slots unknown"] = "Einige Plätze unbekannt", + ["Soulwell availability cannot be checked."] = "Die Verfügbarkeit eines Seelenbrunnens ist nicht überprüfbar.", + ["Spell ID"] = "Zauber-ID", + ["Status on the minimap"] = "Status auf der Minikarte", + ["Tanks first"] = "Tanks zuerst", + ["Temporary weapon coating"] = "Temporäre Waffenbeschichtung", + ["That debuff is not on the watch list."] = "Dieser Debuff steht nicht auf der Überwachungsliste.", + ["The game does not report memory by feature."] = "Das Spiel meldet den Speicherverbrauch nicht pro Funktion.", + ["Track up to eight harmful spell IDs on you or your focus, when the client exposes them."] = "Überwacht bis zu acht schädliche Zauber-IDs auf dir oder deinem Fokus, sofern der Client sie bereitstellt.", + ["Use /br debuff on|off|list, add [player|focus] [encounter ID], or remove [player|focus]."] = "Verwende /br debuff on|off|list, add [player|focus] [Begegnungs-ID] oder remove [player|focus].", + ["Use /br forecast timer <1-600|off>."] = "Verwende /br forecast timer <1-600|off>.", + ["Use /br readiness [personal|show|hide|next|prev] or aura ."] = "Verwende /br readiness [personal|show|hide|next|prev] oder aura .", + ["Use /br smartprio [on|off|list], here , or instance ."] = "Verwende /br smartprio [on|off|list], here oder instance .", + ["Use a buff key from /br buffs."] = "Verwende einen Buff-Schlüssel aus /br buffs.", + ["Use a key from /br buffs. Clear the field to remove the rule."] = "Verwende einen Schlüssel aus /br buffs. Ein leeres Feld entfernt die Regel.", + ["Use a valid debuff spell ID, player or focus, and an optional encounter ID."] = "Gib eine gültige Debuff-Zauber-ID, player oder focus und optional eine Begegnungs-ID ein.", + ["Visual alerts: %s"] = "Visuelle Warnungen: %s", + ["Waiting for a fresh buff scan"] = "Warte auf einen neuen Buff-Scan", + ["Watch unit"] = "Überwachtes Ziel", + ["What do you play most often?"] = "Was spielst du am häufigsten?", + ["What is your primary role?"] = "Was ist deine Hauptrolle?", + ["Your character only"] = "Nur dein Charakter", + ["Your supported buffs: %s"] = "Deine unterstützten Buffs: %s", } diff --git a/BuffRadar/Minimap.lua b/BuffRadar/Minimap.lua index bf21e51..0ae780c 100644 --- a/BuffRadar/Minimap.lua +++ b/BuffRadar/Minimap.lua @@ -7,7 +7,58 @@ local L = X.L local db X.OnDBLoaded(function(value) db = value end) -local minimapBtn +local minimapBtn, pulseEnd, lastPulse +local badgeColors = { + covered = { 0.25, 1, 0.45, "+" }, attention = { 1, 0.82, 0.22, "!" }, + critical = { 1, 0.32, 0.28, "!!" }, unknown = { 0.72, 0.76, 0.8, "?" }, +} + +function X.UpdateMinimapStatus() + if not minimapBtn then return end + local badge = minimapBtn.statusMark + local state = db and db.statusMinimap and X.Status.State() + if badge.state == state then return end + badge.state = state + local style = badgeColors[state] + if style then + badge:SetText(style[4]) + badge:SetTextColor(style[1], style[2], style[3]) + end + badge:SetShown(style ~= nil) +end + +local function AddStatusTooltip() + if not db or not db.statusMinimap then return end + local summary = X.Status.Summary() + GameTooltip:AddLine(X.Status.Description(), 1, 1, 1) + if summary.partial and summary.state ~= "unknown" then + GameTooltip:AddLine(L["Some buff coverage could not be verified"], 0.75, 0.75, 0.75) + end + local expiry = summary.firstExpiry + if expiry and expiry.endsAt > GetTime() then + GameTooltip:AddLine(X.Intel.ForecastText(expiry.spell, expiry.name, expiry.endsAt), 1, 0.82, 0.35, true) + end +end + +function X.TickMinimapPulse() + if pulseEnd and (GetTime() >= pulseEnd or db.reduceMotion or not db.visualAlerts or InCombatLockdown()) then + pulseEnd = nil + minimapBtn.pulse:Hide() + end +end + +function X.VisualBuffAlert() + if not db.visualAlerts or db.reduceMotion or InCombatLockdown() or X.PlayerSuspended() then return end + local now = GetTime() + if lastPulse and now - lastPulse < 2 then return end + if db.showBorder and X.Flash(true) then + lastPulse = now + elseif minimapBtn and minimapBtn:IsVisible() then + lastPulse, pulseEnd = now, now + 0.65 + minimapBtn.pulse:Show() + if C_Timer and C_Timer.After then C_Timer.After(0.65, X.TickMinimapPulse) end + end +end local function MinimapRadii() local w = Minimap.GetWidth and Minimap:GetWidth() @@ -28,7 +79,10 @@ local function RefreshMinimapButton() if db and db.showMinimap and not X.PlayerSuspended() then minimapBtn:Show() PositionMinimapButton() + X.UpdateMinimapStatus() else + pulseEnd = nil + minimapBtn.pulse:Hide() minimapBtn.dragging = false minimapBtn:Hide() end @@ -36,7 +90,8 @@ end local function OnClick(_, button) if button == "RightButton" then - if X.OpenConfig then X.OpenConfig() end + if X.ReadUnitBool(IsShiftKeyDown) then X.OpenWizard() + elseif X.OpenConfig then X.OpenConfig() end else X.ToggleWindow() end @@ -58,11 +113,20 @@ local function BuildMinimapButton() border:SetSize(52, 52) border:SetPoint("TOPLEFT") border:SetTexture("Interface\\Minimap\\MiniMap-TrackingBorder") + b.pulse = b:CreateTexture(nil, "ARTWORK") + b.pulse:SetAllPoints(icon) + b.pulse:SetColorTexture(1, 0.76, 0.28, 0.45) + b.pulse:Hide() + b.statusMark = b:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") + b.statusMark:SetPoint("TOPRIGHT", 0, 0) + b.statusMark:Hide() b:SetScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_LEFT") GameTooltip:AddLine("|cff33ccffBuff|rRadar") + AddStatusTooltip() GameTooltip:AddLine(L["Left-click: show / hide the window"], 0.8, 0.8, 0.8) GameTooltip:AddLine(L["Right-click: settings"], 0.8, 0.8, 0.8) + GameTooltip:AddLine(L["Shift-right-click: Quick Setup"], 0.8, 0.8, 0.8) GameTooltip:AddLine(L["Drag: move around the minimap"], 0.8, 0.8, 0.8) GameTooltip:Show() end) @@ -107,8 +171,10 @@ local function BuildMinimapButton() if type(button) ~= "table" or X.PlayerSuspended() then return end GameTooltip:SetOwner(button, "ANCHOR_LEFT") GameTooltip:AddLine("|cff33ccffBuff|rRadar") + AddStatusTooltip() GameTooltip:AddLine(L["Left-click: show / hide the window"], 0.8, 0.8, 0.8) GameTooltip:AddLine(L["Right-click: settings"], 0.8, 0.8, 0.8) + GameTooltip:AddLine(L["Shift-right-click: Quick Setup"], 0.8, 0.8, 0.8) GameTooltip:Show() end, funcOnLeave = function() GameTooltip:Hide() end, diff --git a/BuffRadar/Profiles.lua b/BuffRadar/Profiles.lua index 26af3f0..410ac63 100644 --- a/BuffRadar/Profiles.lua +++ b/BuffRadar/Profiles.lua @@ -114,6 +114,14 @@ do scalarList[#scalarList + 1] = key end + -- Older BR2 profiles leave these controls unchanged. New snapshots carry + -- them explicitly. Instance/debuff/consumable IDs remain local settings. + local featureScalars = { forecastSeconds = true, smartPriority = true, statusMinimap = true, + visualAlerts = true, liteMode = true } + for key in pairs(featureScalars) do + scalarKeys[key] = true + scalarList[#scalarList + 1] = key + end local optionalFalse = { thornsAnyClassOutdoors = true, blessingComplement = true } local function Encode(value) @@ -268,7 +276,7 @@ do end if not patch.bgColor then return nil end for _, key in ipairs(scalarList) do - if not scalarFields[key] and key ~= "autoThemePriority" then + if not scalarFields[key] and key ~= "autoThemePriority" and not featureScalars[key] then if optionalFalse[key] or (key == "assumeRange" and scalarFields.strata) then patch[key] = false else @@ -290,7 +298,7 @@ do if (directImport or scalarFields.complete) and not complete then return nil end if scalarFields.complete then for key in pairs(legacyScalars) do - if not scalarFields[key] and key ~= "autoThemePriority" then return nil end + if not scalarFields[key] and key ~= "autoThemePriority" and not featureScalars[key] then return nil end end end if complete then @@ -312,13 +320,17 @@ do function X.ApplyProfile(patch) local db = X.GetDB() - local syncWasEnabled = db.sync + local syncWasEnabled, featuresChanged = db.sync, false -- Normalize the complete proposed state before changing the live settings. local candidate = {} for key, value in pairs(db) do candidate[key] = value end for key, value in pairs(patch) do candidate[key] = value end settings.Sanitize(candidate) - for key in pairs(patch) do db[key] = candidate[key] end + for key in pairs(patch) do + if featureScalars[key] and db[key] ~= candidate[key] then featuresChanged = true end + db[key] = candidate[key] + end + if featuresChanged then X.Intel.SettingsChanged() end if syncWasEnabled and not db.sync then X.StopCoordination() end X.blockerProfileRevision = (X.blockerProfileRevision or 0) + 1 X.assignmentGroupConflicts = nil diff --git a/BuffRadar/Readiness.lua b/BuffRadar/Readiness.lua new file mode 100644 index 0000000..b7e2f4b --- /dev/null +++ b/BuffRadar/Readiness.lua @@ -0,0 +1,133 @@ +-- BuffRadar - optional personal checks for the Raid Preparation panel. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, ns = ... +local X = ns.X +local R, L, Print = {}, X.L, X.Print +X.Readiness = R + +-- Ranked classic stones, including the Improved Healthstone variants. +local stones = { 5512, 19004, 19005, 5511, 19006, 19007, 5509, 19008, 19009, + 5510, 19010, 19011, 9421, 19012, 19013 } +local gearSlots = { 1, 3, 5, 6, 7, 8, 9, 10, 16, 17, 18 } + +local function Healthstone() + local modern = C_Item and C_Item.GetItemCount + local read = modern or GetItemCount + local incomplete = false + for _, id in ipairs(stones) do + local count + if modern then count = X.ReadUnitNumber(read, id, false, false, false, false) + else count = X.ReadUnitNumber(read, id, false, false) end + if count and count > 0 then return true end + if not count or count < 0 then incomplete = true end + end + if not incomplete then return false end +end + +local function Tuple(...) return select("#", ...), ... end +local function Durability(slot) return Tuple(GetInventoryItemDurability(slot)) end + +local function Repairs() + if type(GetInventoryItemDurability) ~= "function" then return L["Unknown"] end + local lowest, broken, incomplete = nil, 0, false + for _, slot in ipairs(gearSlots) do + local ok, n, current, maximum = pcall(Durability, slot) + if not ok or n == 0 then + incomplete = true + elseif type(current) ~= "nil" or type(maximum) ~= "nil" then + if X.Readable(current) and X.Readable(maximum) and type(current) == "number" and type(maximum) == "number" + and maximum > 0 and maximum < math.huge and current >= 0 and current <= maximum then + local percent = math.floor(current / maximum * 100) + lowest = math.min(lowest or 100, percent) + if current == 0 then broken = broken + 1 end + else + incomplete = true + end + end + end + if not lowest then return L[incomplete and "Unknown" or "No durable equipment"] end + local reading = broken > 0 and string.format(L["%d broken · Lowest %d%%"], broken, lowest) + or string.format(L["Lowest %d%%"], lowest) + if lowest <= 30 then reading = reading .. " · " .. L["Repair recommended"] end + return incomplete and (reading .. " · " .. L["Some slots unknown"]) or reading +end + +local function HasAuraID(id) + local complete = true + for i = 1, 40 do + local done, answered, spell = X.Debuffs.ReadAura("player", i, false) + if done then + if answered and complete then return false end + return nil + end + if spell == id then return true end + if not spell then complete = false end + end +end + +local function Presence(value) + if value == nil then return L["Unknown"] end + return L[value and "Present" or "Missing"] +end + +function R.Personal() + local db = X.GetDB() + if not X.classic or not db or db.liteMode or X.PlayerSuspended() or InCombatLockdown() then return end + local lines = {} + for _, def in ipairs(X.CONS_DEFS) do + lines[#lines + 1] = { text = L[def.label], hint = Presence(X.ConsHas("player", def)) } + end + if db.readinessAura > 0 then + local ok, name = pcall(X.Core.SpellName, db.readinessAura) + local label = ok and X.Readable(name) and type(name) == "string" and name or "#" .. db.readinessAura + lines[#lines + 1] = { text = L["Optional consumable"] .. " · " .. label, hint = Presence(HasAuraID(db.readinessAura)) } + else + lines[#lines + 1] = { text = L["Optional consumable"], hint = L["No aura configured"] } + end + lines[#lines + 1] = { text = L["Healthstone in bags"], hint = Presence(Healthstone()) } + lines[#lines + 1] = { text = L["Equipment durability"], hint = Repairs() } + local missing = X.WeaponEnchantMissing(true) + lines[#lines + 1] = { text = L["Temporary weapon coating"], hint = missing == nil and L["Unknown"] + or L[missing and "Missing" or "No missing coating"] } + local class = X.UnitClassToken("player") + if class == "HUNTER" or class == "WARLOCK" then + lines[#lines + 1] = { text = L["Active pet"], hint = Presence(X.ReadUnitBool(UnitExists, "pet")) } + end + return { members = {}, reagents = {}, personal = lines } +end + +function R.SetAura(id) + if id ~= 0 and not X.Settings.PositiveID(id) then + Print(L["Enter a consumable aura spell ID, or 0 to clear it."]) + return false + end + X.GetDB().readinessAura = id + if X.QueuePersonalReadiness then X.QueuePersonalReadiness() end + return true +end + +function X.ShowFeedback() + X.ShowExport("https://github.com/SeanShaffer88/BuffRadar/issues/new?template=feature_request.md", false, + L["Copy the feedback link and open it in your browser."]) +end + +X.ext.feedback = function() X.ShowFeedback(); return true end +X.ext.readiness = function(rest) + if not X.classic then X.RaidPreparationCommand("personal"); return true end + local input = rest:lower() + local id = input:match("^aura%s+(%S+)$") + if id then + if R.SetAura(id == "off" and 0 or tonumber(id)) then + Print(string.format(L["Personal consumable aura ID: %d (0 = off)."], X.GetDB().readinessAura)) + if X.RefreshConfig then X.RefreshConfig() end + end + elseif input == "" or input == "personal" then + X.RaidPreparationCommand("personal") + elseif input == "show" or input == "hide" or input == "next" or input == "prev" then + X.RaidPreparationCommand(input) + else + Print(L["Use /br readiness [personal|show|hide|next|prev] or aura ."]) + end + return true +end diff --git a/BuffRadar/Recaps.lua b/BuffRadar/Recaps.lua index 67b6867..ff8a14c 100644 --- a/BuffRadar/Recaps.lua +++ b/BuffRadar/Recaps.lua @@ -145,7 +145,10 @@ local function BuildReadyView() end function X.RaidPreparationSnapshot(personal) - if not X.classic or not X.InGroup() or InCombatLockdown() or X.PlayerSuspended() then return end + local db = X.GetDB() + if not X.classic or not db or db.liteMode or InCombatLockdown() or X.PlayerSuspended() then return end + if personal then return X.Readiness.Personal() end + if not X.InGroup() then return end local report = X.GroupBuffReport(false, true, true) local reagents, incomplete = X.ReagentEstimate(report) local snapshot = { members = {}, reagents = reagents, incomplete = incomplete } @@ -177,27 +180,20 @@ function X.RaidPreparationSnapshot(personal) status = attention and "attention" or (unknown and "unknown" or "clear"), unknown = not not unknown } end end - if personal then - local notices = {} - if X.WeaponEnchantMissing() then notices[#notices + 1] = L["Temporary weapon coating missing"] end - local ok, _, class = pcall(UnitClass, "player") - if ok and X.Readable(class) and (class == "HUNTER" or class == "WARLOCK") - and X.ReadUnitBool(UnitExists, "pet") == false then notices[#notices + 1] = L["No active pet"] end - snapshot.personal = #notices > 0 and table.concat(notices, " · ") or L["No personal reminders"] - end return snapshot end function X.RaidPreparationCommand(mode) - if not X.classic then return end + if not X.classic then Print(L["Raid Preparation is available in WoW: Forever."]); return end if mode == "hide" then X.CloseRaidPreparation(); return end + if X.GetDB().liteMode then Print(L["Raid Preparation is paused in Lite mode."]); return end if InCombatLockdown() or X.PlayerSuspended() then return end if mode == "next" or mode == "prev" then X.MoveRaidPreparation(mode == "next" and 1 or -1); return end if mode ~= "" and mode ~= "show" and mode ~= "personal" then Print(L["Use /br prep show, personal, hide, next, or prev."]) return end - if not X.InGroup() then Print(L["Join a party or raid to use Raid Preparation."]); return end + if mode ~= "personal" and not X.InGroup() then Print(L["Join a party or raid to use Raid Preparation."]); return end X.OpenRaidPreparation(mode == "personal") end @@ -331,7 +327,7 @@ function X.WipeCheck() X.combatStart = nil if not combatStart or GetTime() - combatStart < 8 then return end local db = X.GetDB() - if not db or not db.wipeReport or not X.InGroup() then return end + if not db or not (db.wipeReport or db.smartPriority) or not X.InGroup() then return end local total, dead = 0, 0 local unavailable = 0 X.ForReportRoster(function(unit, exists) @@ -341,6 +337,8 @@ function X.WipeCheck() elseif state == nil then unavailable = unavailable + 1 end end) if not (dead >= 3 or (total <= 5 and dead >= 2)) then return end + X.Intel.MarkWipe() + if not db.wipeReport then return end local report = X.GroupBuffReport(true) local lines, people = X.SnapshotMissing(report), #report.people local note = X.GroupCoverageNote(report) diff --git a/BuffRadar/SavedVariables.lua b/BuffRadar/SavedVariables.lua index d876f0e..45ec306 100644 --- a/BuffRadar/SavedVariables.lua +++ b/BuffRadar/SavedVariables.lua @@ -4,7 +4,7 @@ local _, ns = ... local X = ns.X -local DB_VERSION = 21 +local DB_VERSION = 22 local PROFILE_MAX_BYTES = 4000 local MIN_WIDTH, MAX_WIDTH = 180, 400 @@ -100,7 +100,16 @@ local DEFAULTS = { modClick = false, -- Shift-click a row casts the group version of its buff (1.14.0, Brief 3) pullFlash = false, -- flash + countdown line when a pull timer starts (1.14.0, Brief 4) enterFlash = true, -- print a reminder when entering an instance unbuffed (1.7.0) - scanThrottle = false, -- halve the steady rescan rate in groups over 20 (1.7.0) + scanThrottle = false, -- adapt only the periodic scan to movement, group size and latency + forecastSeconds = 0, -- lead time for confirmed expiry notices; 0 = off + smartPriority = false, + instancePriority = {}, -- instance ID -> buff key; local rules, not shared profiles + statusMinimap = true, + visualAlerts = false, + liteMode = false, + debuffWatch = false, + debuffRules = {}, -- bounded list of { spellID, unit, encounterID } + readinessAura = 0, -- optional personal consumable aura spell ID history = {}, -- last 50 casts through BuffRadar: { t, spell, who } (1.7.0) growUp = false, -- the list grows upward from a fixed bottom edge (1.8.0) hideInCombat = true, -- no buff targets are available while you are in combat @@ -140,12 +149,59 @@ local RANGES = { bgAlpha = { 0, 1 }, scale = { 0.5, 2 }, cfgScale = { 0.5, 2 }, width = { MIN_WIDTH, MAX_WIDTH }, rebuff = { 0, 3600 }, castsTotal = { 0, 1e9 }, groupCastMin = { 2, 40 }, minimapAngle = { 0, 360 }, lowMana = { 0, 100 }, textScale = { 0.8, 1.5 }, idleFade = { 0, 90 }, - rowGap = { 0, 8 }, iconSize = { 0, 24 }, nameTrim = { 0, 24 } } + rowGap = { 0, 8 }, iconSize = { 0, 24 }, nameTrim = { 0, 24 }, + forecastSeconds = { 0, 300 }, readinessAura = { 0, 2000000 } } local function IsNumber(v) return type(v) == "number" and v == v and v ~= math.huge and v ~= -math.huge end +local function PositiveID(v) + return IsNumber(v) and v > 0 and v <= 2000000 and v == math.floor(v) +end + +local MAX_DEBUFF_RULES, MAX_INSTANCE_RULES = 8, 24 + +local function ValidDebuffRule(id, unit, encounter) + return PositiveID(id) and (unit == "player" or unit == "focus") + and (encounter == 0 or PositiveID(encounter)) +end + +local function PriorityKey(key) + if type(key) ~= "string" or #key > 32 then return false end + if key == "BLESSINGS" then return X.classic end + local blessing = key:match("^BLESS_(%u+)$") + if X.classic and blessing and X.BLESSINGS[blessing] then return true end + for _, def in ipairs(X.BUFF_DEFS) do if def.key == key then return true end end + for _, def in ipairs(X.AURA_DEFS or {}) do if def.key == key then return true end end + return PositiveID(tonumber(key:match("^CUSTOM(%d+)$"))) +end + +local function CopyInstancePriority(value) + local clean, count = {}, 0 + for id, key in pairs(value) do + if PositiveID(id) and PriorityKey(key) then + clean[id], count = key, count + 1 + if count >= MAX_INSTANCE_RULES then break end + end + end + return clean +end + +local function CopyDebuffRules(value) + local clean, seen = {}, { player = {}, focus = {} } + for _, rule in ipairs(value) do + if type(rule) == "table" and ValidDebuffRule(rule.spellID, rule.unit, rule.encounterID) + and not seen[rule.unit][rule.spellID] then + local id = rule.spellID + clean[#clean + 1] = { spellID = id, unit = rule.unit, encounterID = rule.encounterID } + seen[rule.unit][id] = true + if #clean >= MAX_DEBUFF_RULES then break end + end + end + return clean +end + local function Clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end @@ -323,6 +379,8 @@ local TABLE_FIELDS = { return clean end, buffPrio = CopyBuffPriority, + instancePriority = CopyInstancePriority, + debuffRules = CopyDebuffRules, buffAssignments = X.CopyAssignments, plateRestore = CopyPlateRestore, blessingPreferences = function(value) @@ -389,7 +447,7 @@ local function CleanSetting(key, value, default) if not IsNumber(value) then value = default end local range = RANGES[key] if range then value = Clamp(value, range[1], range[2]) end - if key == "castsTotal" then value = math.floor(value) end + if key == "castsTotal" or key == "forecastSeconds" or key == "readinessAura" then value = math.floor(value) end elseif type(value) ~= kind then return default elseif kind == "string" then @@ -469,6 +527,11 @@ X.Settings = { MinWidth = MIN_WIDTH, MaxWidth = MAX_WIDTH, ProfileMaxBytes = PROFILE_MAX_BYTES, + MaxDebuffRules = MAX_DEBUFF_RULES, + MaxInstanceRules = MAX_INSTANCE_RULES, + PositiveID = PositiveID, + ValidDebuffRule = ValidDebuffRule, + PriorityKey = PriorityKey, IsProfileName = IsProfileName, ProfileScalarValid = ProfileScalarValid, AutoThemeOrder = OrderedAutoThemeAddons, diff --git a/BuffRadar/Slash.lua b/BuffRadar/Slash.lua index baae036..fd6ffec 100644 --- a/BuffRadar/Slash.lua +++ b/BuffRadar/Slash.lua @@ -345,6 +345,10 @@ local function HandleSlash(msg) byKey[b.key] = b.name if not seenK[b.key] then order[#order + 1] = b.key; seenK[b.key] = true end end + if X.HasKnownBlessings() then + byKey.BLESSINGS = L["Blessings"] + if not seenK.BLESSINGS then order[#order + 1] = "BLESSINGS" end + end if key then key = key:upper() local at @@ -704,8 +708,9 @@ local function HandleSlash(msg) else Print("Usage: /br preset raid|dungeon|solo") end - elseif cmd == "wizard" then + elseif cmd == "wizard" or cmd == "quicksetup" then X.OpenWizard() + return elseif cmd == "pill" then db.pill = not db.pill Print("All-buffed pill " .. OnOff(db.pill)) @@ -753,7 +758,8 @@ local function HandleSlash(msg) elseif cmd == "ready" then X.ReadyViewCommand(rest:match("^%s*(.-)%s*$"):lower()) elseif cmd == "prep" then - X.RaidPreparationCommand(rest:match("^%s*(.-)%s*$"):lower()) + X.RaidPreparationCommand(rest:lower()) + return elseif cmd == "subgroup" then if rest:match("^%s*(.-)%s*$"):lower() == "panel" and CLASSIC_FEATURES then X.OpenSubgroupResponsibilities() @@ -856,9 +862,13 @@ local function HandleSlash(msg) X.ShowExport(X.HistoryText(), false, "BuffRadar -- your recent casts (newest first)") end elseif cmd == "throttle" then - db.scanThrottle = not db.scanThrottle - Print("Scan throttle " .. OnOff(db.scanThrottle) - .. " — in groups over 20, the steady rescan runs half as often (event refreshes stay instant).") + local mode = rest:lower() + if mode ~= "" and mode ~= "on" and mode ~= "off" then Print("/br throttle [on|off]"); return end + db.scanThrottle = mode == "on" or (mode == "" and not db.scanThrottle) + Print(string.format(L["Adaptive scan throttle: %s"], L[db.scanThrottle and "On" or "Off"])) + X.Intel.SettingsChanged() + if RefreshConfig then RefreshConfig() end + return elseif cmd == "growup" then db.growUp = not db.growUp X.ApplyAnchor() @@ -1303,6 +1313,7 @@ local function HandleSlash(msg) RefreshMinimapButton() Print("Minimap button " .. OnOff(db.showMinimap)) elseif cmd == "stats" then + if rest:lower() == "memory" then X.Intel.MemoryReport(); return end if rest:lower() == "export" then X.ShowExport(X.StatsText(), false, "BuffRadar — cast statistics") return @@ -1402,7 +1413,7 @@ local function HandleSlash(msg) X.ChangeFriendlyNameplates(rest == "" and "on" or rest:lower(), Print) return elseif X.ext[cmd] then - X.ext[cmd](rest) + if X.ext[cmd](rest) then return end else Print("Commands:") Print(" /br - show/hide the window (/br debug if it won't appear)") @@ -1460,7 +1471,9 @@ local function HandleSlash(msg) Print(" /br wipe [show] - rebuff report after a wipe") Print(" /br pin - keep a player at the top /br pin none - clear the pin") Print(" /br weapon - watch your weapon enchant /br enterflash - instance-entry reminder") - Print(" /br history - your recent casts /br throttle - halve the rescan rate in big groups") + Print(" /br history - your recent casts /br throttle [on|off] - adaptive periodic scans") + Print(" /br forecast [seconds|off|timer] · /br smartprio · /br debuff · /br readiness") + Print(" /br minimapstatus · /br visual · /br lite · /br stats memory · /br status [export] · /br feedback") Print(" /br growup - list grows upward /br theme - color theme") Print(" Combat safety: the list hides and buff buttons are disabled until combat ends.") Print(" /br find | findbox - name finder /br bars - duration bars /br markers - raid markers") @@ -1474,7 +1487,7 @@ local function HandleSlash(msg) Print(" /br pill - all-buffed pill /br consumables - flask/food counts") Print(" /br custom add|remove|list - watch any buff spell you know") Print(" /br uptime - coverage uptime % /br preset raid|dungeon|solo") - Print(" /br wizard - run the one-minute setup wizard") + Print(" /br wizard (or /br quicksetup) - choose an activity and role") Print(" /br theme save - save your current colors as a theme") Print(L["Usage: /br theme priority [panel|list|up |down |reset]"]) Print(" /br rowgap <0-8> | iconsize <0|10-24>") diff --git a/BuffRadar/Status.lua b/BuffRadar/Status.lua new file mode 100644 index 0000000..e79e9cc --- /dev/null +++ b/BuffRadar/Status.lua @@ -0,0 +1,133 @@ +-- BuffRadar - last completed scan, shared by the minimap and read-only API. +-- Copyright (C) 2026 Malikor. GPLv3 or later. + +local _, ns = ... +local X = ns.X +local L, I = X.L, X.Intel +local S = {} +X.Status = S + +local rows, count, revision = {}, 0, 0 +local state, reason, partial = "unavailable", "inactive", false +local expiring, expirySpell, expiryName, expiryEnd = 0, nil, nil, nil +local labels = { covered = "Checked buffs are covered", attention = "Buffs need attention", + critical = "Important buff missing or expiring", unknown = "Buff coverage could not be verified" } +local reasons = { combat = "Buff scan paused in combat", dead = "Buff scan paused while dead", + paused = "Buff scan paused", updating = "Waiting for a fresh buff scan", inactive = "No applicable buffs to check" } + +local function Notify() + revision = revision + 1 + if X.UpdateMinimapStatus then X.UpdateMinimapStatus() end + -- Consumers can re-read after the queue has been committed. No dependency + -- or load-order requirement, and a consumer exception cannot break casting. + local bridge = _G.WeakAuras + if type(bridge) == "table" and type(bridge.ScanEvents) == "function" then + pcall(bridge.ScanEvents, "BUFFRADAR_STATUS_CHANGED") + end +end + +local function ClearRow(row) + row.unit, row.guid, row.name = nil, nil, nil + for i = #row.missing, 1, -1 do row.missing[i] = nil end +end + +function S.Unavailable(why) + I.ForgetAlerts() + if why == "updating" then + if X.PlayerSuspended() then why = "dead" + elseif InCombatLockdown() then why = "combat" end + end + if state == "unavailable" and reason == why then return end + for i = 1, count do ClearRow(rows[i]) end + count, state, reason, partial = 0, "unavailable", why, false + expiring, expirySpell, expiryName, expiryEnd = 0, nil, nil, nil + Notify() +end + +function S.Publish(entries, n) + local critical, pending, spell, name, ends, pulse = I.ScanResult() + local tracked = next(X.tally) ~= nil + local expected = X.ReadUnitNumber(GetNumGroupMembers) + local grouped = (expected and expected > 1) or X.ReadUnitBool(IsInGroup) == true + or X.ReadUnitBool(IsInRaid) == true or (expected == nil and X.InGroup()) + local incomplete = X.scanHasUnknownBuffs or X.scanNameFiltered or X.tallyUnknownUnits > 0 + or (grouped and (not expected or expected < 2 or X.tallyUnits ~= expected)) or false + local current = critical and "critical" or (n > 0 or X.scanHasMissingBuffs or pending > 0) and "attention" + or incomplete and "unknown" or tracked and "covered" or "unavailable" + local why = current == "unavailable" and "inactive" or nil + local changed = current ~= state or why ~= reason or incomplete ~= partial or n ~= count + or pending ~= expiring or spell ~= expirySpell or name ~= expiryName or ends ~= expiryEnd + for i = 1, n do + local entry, row = entries[i], rows[i] + if not row then row = { missing = {} }; rows[i] = row end + if row.unit ~= entry.unit or row.guid ~= entry.guid or row.name ~= entry.name then changed = true end + row.unit, row.guid, row.name = entry.unit, entry.guid, entry.name + local missing = row.missing + if #missing ~= #entry.missing then changed = true end + for j = 1, #entry.missing do + if missing[j] ~= entry.missing[j] then changed = true; missing[j] = entry.missing[j] end + end + for j = #missing, #entry.missing + 1, -1 do missing[j] = nil end + end + for i = n + 1, count do ClearRow(rows[i]) end + count, state, reason, partial = n, current, why, incomplete + expiring, expirySpell, expiryName, expiryEnd = pending, spell, name, ends + if changed then Notify() end + if pulse and X.VisualBuffAlert then X.VisualBuffAlert() end +end + +function S.State() return state end +function S.Count() return count end + +function S.Description() + return L[labels[state] or reasons[reason]] +end + +function S.Summary() + return { version = 1, revision = revision, state = state, reason = reason, partial = partial, + actionable = count, expiring = expiring, + firstExpiry = expiryEnd and { spell = expirySpell, name = expiryName, endsAt = expiryEnd } or nil } +end + +local function CopyRow(row) + local missing = {} + for i, spell in ipairs(row.missing) do missing[i] = spell end + return { unit = row.unit, guid = row.guid, name = row.name, missing = missing } +end + +local function GetStatus() + local snapshot = S.Summary() + local targets = {} + for i = 1, count do targets[i] = CopyRow(rows[i]) end + snapshot.targets = targets + return snapshot +end + +local function GetUnit(unit) + if count == 0 or not X.Readable(unit) or type(unit) ~= "string" or #unit > 40 then return end + local guid = X.UnitGUIDOf(unit) + if not guid then return end + for i = 1, count do + if rows[i].guid == guid then return CopyRow(rows[i]) end + end +end + +-- Public, versioned integration only. Addon modules use the private namespace. +BuffRadarAPI = { version = 1, GetStatus = GetStatus, GetUnit = GetUnit, GetSummary = S.Summary } + +X.ext.status = function(rest) + if rest ~= "" and rest:lower() ~= "export" then X.Print("/br status [export]"); return true end + local line = S.Description() .. " · " .. string.format(L["%d cast targets · %d forecast buffs"], count, expiring) + if rest == "" then + X.Print(line) + else + local lines = { line } + if expiryEnd and expiryEnd > GetTime() then lines[#lines + 1] = I.ForecastText(expirySpell, expiryName, expiryEnd) end + for i = 1, count do + local row = rows[i] + lines[#lines + 1] = row.name .. ": " .. table.concat(row.missing, ", ") + end + X.ShowExport(table.concat(lines, "\n"), false, L["Copy the current buff status"]) + end + return true +end diff --git a/BuffRadar/Window.lua b/BuffRadar/Window.lua index e534094..f802306 100644 --- a/BuffRadar/Window.lua +++ b/BuffRadar/Window.lua @@ -1067,14 +1067,17 @@ local function ApplyAppearance() end -- Briefly highlight the window when a pull ends or a countdown starts. -function X.Flash() +function X.Flash(soft) if not frame or not frame.SetBackdropBorderColor or InCombatLockdown() or db.reduceMotion then return end - frame:SetBackdropBorderColor(1, 0.35, 0.35, 1) + if soft and not frame:IsVisible() then return end + if soft then frame:SetBackdropBorderColor(1, 0.7, 0.28, 0.58) + else frame:SetBackdropBorderColor(1, 0.35, 0.35, 1) end if C_Timer and C_Timer.After then C_Timer.After(0.7, ApplyAppearance) else flashPending = true -- no timer API: Refresh() restores it next pass end + return true end do @@ -1109,10 +1112,6 @@ do X.autoThemeResolved, X.autoThemeAddon = resolved, selectedAddon ApplyAppearance() if X.RefreshConfig then X.RefreshConfig() end - local wizard = X.wizardFrame - if wizard and wizard:IsShown() and wizard.page == 2 then - wizard.choice[1]:SetText("Theme: " .. X.ThemeLabel(true)) - end return true end end @@ -1749,7 +1748,7 @@ local function RenderCoverage(entries, n) if CoverOn("expiry") then parts[#parts + 1] = ExpiringGroupBuffs() end -- Weapon watch (1.7.0): when your own row isn't on the list to -- carry the tag, the coverage line carries the reminder instead. - if db.weaponWatch and X.WeaponEnchantMissing() then + if db.weaponWatch and not db.liteMode and X.WeaponEnchantMissing() then local selfListed = false for i = 1, n do if entries[i].isSelf then selfListed = true break end @@ -1759,13 +1758,13 @@ local function RenderCoverage(entries, n) end end -- World-buff watch (1.8.0): your active world buffs, with time left. - if db.worldWatch and CoverOn("world") then + if db.worldWatch and not db.liteMode and CoverOn("world") then local wb = X.WorldBuffsText() if wb then parts[#parts + 1] = wb end end -- Healer drinking (1.8.0): healers sitting down to drink between -- pulls — the group waits for them, not the other way round. - if db.drinkWatch and CoverOn("drink") and (X.drinkHealers or 0) > 0 then + if db.drinkWatch and not db.liteMode and CoverOn("drink") and (X.drinkHealers or 0) > 0 then parts[#parts + 1] = X.drinkHealers == 1 and "Healer drinking" or string_format("%d healers drinking", X.drinkHealers) end @@ -1809,7 +1808,7 @@ function X.RenderQueue(entries, n, sessionShow, wasAfterCombat) SetShownIfChanged(emptyText, n == 0) local coverShown = RenderCoverage(entries, n) - local focusLine = db.focusWatch and focusText and core.FocusLine() + local focusLine = db.focusWatch and not db.liteMode and focusText and core.FocusLine() if focusText then if focusLine then SetTextIfChanged(focusText, focusLine) end SetShownIfChanged(focusText, focusLine and true or false) diff --git a/BuffRadar/Wizard.lua b/BuffRadar/Wizard.lua index 563918c..d8edd4e 100644 --- a/BuffRadar/Wizard.lua +++ b/BuffRadar/Wizard.lua @@ -17,7 +17,7 @@ local RAID, PARTY, PLATES = core.RAID, core.PARTY, core.PLATES local myBuffs, entries = core.Buffs, core.Entries local CLASSIC_FEATURES = X.classic local pairs, ipairs, type, pcall = pairs, ipairs, type, pcall -local math_min, math_max, math_floor = math.min, math.max, math.floor +local math_min, math_floor = math.min, 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 @@ -26,141 +26,135 @@ 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. +-- Quick Setup: stage both answers; only Finish changes live settings. --------------------------------------------------------------------------- +local activities = { { "solo", "Solo play" }, { "dungeon", "Dungeons / Mythic+" }, { "raid", "Raids" } } +local roles = { { "TANK", "Tank" }, { "HEALER", "Heal" }, { "DAMAGER", "DPS" } } + +local function DraftSettings(draft) + local group = draft.activity ~= "solo" + local support = draft.role ~= "DAMAGER" + return group and (support and "role" or "need") or "name", group and (support and 60 or 45) or 0, group +end + function X.WizardPage(n) local w = X.wizardFrame - if not w then return end + if not w or not w.draft then return end w.page = n - for i = 1, 3 do w.choice[i]:Hide() end + w.title:SetText(string.format(L["Quick Setup · Step %d of 3"], n)) 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 X.RefreshConfig then X.RefreshConfig() end - if QueueRefresh then QueueRefresh() end - Print("Setup wizard: the " .. s[2] .. " preset is applied.") - end - X.WizardPage(2) + w.next:SetShown(n == 3) + for i = 1, 3 do w.choice[i]:Hide() end + if n < 3 then + w.body:SetText(L[n == 1 and "What do you play most often?" or "What is your primary role?"]) + local field = n == 1 and "activity" or "role" + for i, option in ipairs(n == 1 and activities or roles) do + local button, id, label = w.choice[i], option[1], option[2] + button:SetText((w.draft[field] == id and "+ " or "") .. L[label]) + button:SetScript("OnClick", function() + w.draft[field], w.draft[field .. "Label"] = id, label + X.WizardPage(n + 1) 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) + button:Show() 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 X.RefreshConfig then X.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 sort, lead, group = DraftSettings(w.draft) + local preset = X.PRESETS[w.draft.activity] 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() X.OpenConfig() end) - b:Show() - w.next:SetText("Finish") - w.next:Show() - end - w.pageText:SetText("Step " .. n .. " of 3") + for i = 1, math_min(3, #myBuffs) do names[#names + 1] = myBuffs[i].name end + if X.HasKnownBlessings() then names[#names + 1] = L["Blessings"] end + if #myBuffs > 3 then names[#names + 1] = "…" end + local sortLabels = { role = "Tanks first", need = "Most buffs needed", name = "Name" } + local lines = { L[w.draft.activityLabel] .. " · " .. L[w.draft.roleLabel], + string.format(L["Order: %s · Forecast: %ds (0 = off)"], L[sortLabels[sort]], lead), + string.format(L["Smart priority: %s"], L[group and "On" or "Off"]) .. " · " + .. string.format(L["Adaptive scan throttle: %s"], L[w.draft.activity == "raid" and "On" or "Off"]), + string.format(L["Group only: %s · Group casts: %s · Pause in cities: %s"], + L[preset.groupOnly and "On" or "Off"], L[CLASSIC_FEATURES and preset.groupCast and "On" or "Off"], + L[preset.pauseInCities and "On" or "Off"]), + L["Quiet alerts and the minimap status are enabled. Buff selections and keybinds are kept."], + #names > 0 and string.format(L["Your supported buffs: %s"], table.concat(names, ", ")) + or L["No supported buffs in your spellbook."], + } + if db.liteMode and lead > 0 then lines[#lines + 1] = L["Forecasts are paused in Lite mode."] end + w.body:SetText(table.concat(lines, "\n\n")) + end +end + +local function FinishSetup(w) + if InCombatLockdown() or X.PlayerSuspended() or not w.draft or w.page ~= 3 then return end + X.ApplyPreset(w.draft.activity) + if not CLASSIC_FEATURES then db.groupCast = false end + db.sortMode, db.forecastSeconds, db.smartPriority = DraftSettings(w.draft) + db.scanThrottle = w.draft.activity == "raid" + db.visualAlerts, db.statusMinimap, db.wizardSeen = true, true, true + w:Hide() + ApplyGeometry() + ApplyAppearance() + X.ApplyRowLayout() + X.Intel.ForgetAlerts() + X.Intel.SettingsChanged() + if X.RefreshConfig then X.RefreshConfig() end + Print(L["Quick Setup complete. Run /br wizard to make new choices."]) 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.") + Print(L["Quick Setup is unavailable in combat."]) return end local w = X.wizardFrame if not w then - w = CreateFrame("Frame", "BuffRadarWizard", UIParent, "BackdropTemplate") + w = CreateFrame("Frame", "BuffRadarWizard", UIParent, BackdropTemplateMixin and "BackdropTemplate" or nil) X.wizardFrame = w - w:SetSize(370, 260) + w:SetSize(422, 334) w:SetPoint("CENTER") + w:SetClampedToScreen(true) w:SetFrameStrata("DIALOG") + w:EnableMouse(true) 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 + if w.SetBackdropColor then w:SetBackdropColor(0, 0, 0, 0.92) end w.title = w:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge") - w.title:SetPoint("TOP", 0, -16) + w.title:SetPoint("TOP", 0, -17) w.body = w:CreateFontString(nil, "OVERLAY", "GameFontHighlight") - w.body:SetPoint("TOPLEFT", 20, -48) - w.body:SetPoint("TOPRIGHT", -20, -48) + w.body:SetPoint("TOPLEFT", 20, -54) + w.body:SetPoint("TOPRIGHT", -20, -54) 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) + b:SetSize(252, 28) + b:SetPoint("TOP", w, "TOP", 0, -100 - (i - 1) * 38) 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.back:SetSize(94, 24) + w.back:SetPoint("BOTTOMLEFT", 16, 14) + w.back:SetText(L["Back"]) + w.back:SetScript("OnClick", function() X.WizardPage(w.page - 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) + w.next:SetSize(112, 24) + w.next:SetPoint("BOTTOMRIGHT", -16, 14) + w.next:SetText(L["Apply"]) + w.next:SetScript("OnClick", function() FinishSetup(w) end) + local close = CreateFrame("Button", nil, w, "UIPanelCloseButton") + close:SetPoint("TOPRIGHT", -5, -5) close:SetScript("OnClick", function() db.wizardSeen = true w:Hide() end) + w.close = close + w:SetScript("OnHide", function() w.draft = nil end) + if UISpecialFrames then table.insert(UISpecialFrames, "BuffRadarWizard") end end + w.draft = {} X.WizardPage(1) w:Show() end diff --git a/QUALITY.md b/QUALITY.md index 6cf0f58..8bc8599 100644 --- a/QUALITY.md +++ b/QUALITY.md @@ -68,7 +68,7 @@ are named below as waivers with owners and follow-ups, not hidden. |---|---|---|---| | Correctness (14) | 5 | Pass | Full gate green (Lua 5.1 compile, luacheck 0/0, locale, trial run × 7 fake-client setups, 0 errors) and every release through 1.15.31 passed in game (SEAN, 2026-11-16). | | Security & privacy (12) | 4 | Pass | Risk Tier 0: no network, no credentials, no data leaves the client; SavedVariables are local settings/stats only. Addon comms ride the game's group channel on one prefix; assignment/blessing-plan messages are trust-gated (leader/assistant; paladin for blessings). `SECURITY.md` present. | -| Robustness (11) | 4 | Pass | SavedVariables migration chain v2→v21 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. | +| Robustness (11) | 4 | Pass | SavedVariables migration chain v2→v22 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 TOC refactor moves window refresh, secure widgets, minimap, and the save schema out of the core. `BuffRadar.lua` is now ~5,300 lines, down from ~7,600 before the refactor; `Config.lua` is still ~4,100. All files compile with Lua 5.1's local and upvalue limits enforced. A Forever field test of the secure cast path is still required. | @@ -77,7 +77,7 @@ are named below as waivers with owners and follow-ups, not hidden. | 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. | | Idiomatic quality (5) | 4 | Pass | luacheck 1.2.0 at strict settings: 0 warnings / 0 errors; project checkers (compile, limits, locale) green; consistent style across the file. | | Test & corpus evidence (5) | 4 | Pass | Corpus = the trial run: 350/350 steps in five setups, 351/351 in the German setup at 1.15.32, plus the two-client coordination run, the package check, migration fixtures from real legacy save shapes, corrupt-data fixtures, a randomized roster/combat step and the performance-budget step. The corpus only grows. Line-coverage percentage is not measurable for this stack, so the corpus fraction is the recorded evidence. | -| Self-documentation (4) | 3 | Pass | Section banners and why-comments throughout; architecture and rules in `AGENTS.md`; module map in the root README's Layout table. No generated API reference — not applicable to an addon with no public API. | +| Self-documentation (4) | 3 | Pass | Section banners and why-comments throughout; architecture and rules in `AGENTS.md`; module map in the root README's Layout table. Versioned [status API](docs/STATUS_API.md) and [roadmap](docs/ROADMAP.md). | | Documentation (4) | 4 | Pass | Four-doc set per edition (README / FEATURES / DESCRIPTION / CHANGELOG) plus `tools/README.md`, in-game help covering every command, `SECURITY.md`, and `## TL;DR` openings on all three READMEs (added at adoption). Checked against the code at every release. | | Diagnostics & supportability (4) | 4 | Pass | `/br selftest` (versioned paste-able block), `/br debug`, `/br apicheck [export]` (client API probe), `/br buffcheck` (spell table vs live client), `/br perf` (scan ms, memory), `/br why ` (the deciding listing check) and the Nearby Player Diagnostics panel. Local only; nothing is sent anywhere. Not 5: no stable error IDs — the game's error frame carries those. | diff --git a/README.md b/README.md index 5472c0f..538cf4c 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,9 @@ macro to work through the list. Your character goes first by default. `/br macro` outside combat to create a cast-next macro for your action bar. On a controller, use `/br gamepad` to bind **Cast next buff** directly or activate the macro from your action bar. -- Open settings with `/br config`. Run `/br wizard` for guided setup or - `/br why ` for a player's eligibility and assignment. +- Open settings with `/br config`. Run `/br wizard` or Shift-right-click + the minimap button to choose your activity and role and review a starting + setup. Use `/br why ` for a player's eligibility and assignment. - Click **?** on the buff window or run `/br nearby` to check friendly nameplates, the last scan count, and your current target's eligibility. @@ -49,7 +50,7 @@ macro to work through the list. Your character goes first by default. | Queue order | Check yourself first, prioritize recently resurrected players, and pin one player. Sort by name, tanks and leaders, distance, or most buffs needed. Filter by name or by group role when the client supplies roles. Use `/br self`, `/br pin`, `/br sort`, `/br find`, and `/br filter`. | | List views | Use `/br view people\|buffs` for a row per player or per needed buff. The buff view shows how many players need each buff. Scroll long lists with the wheel or `/br scroll up\|down`. The cast-next key still uses the head of the full queue. | | Ignore lists | Right-click a row to save an ignore or Shift-right-click to ignore for this session. Manage entries under **Ignore & Stats** or with `/br ignore`, `/br unignore`, `/br signore`, and `/br unsignore`. Export or import the list with `/br ignorelist export` or `/br ignorelist import`. | -| Scan options | `/br throttle` reduces periodic scans in big groups. `/br fastaura` skips rescans when a readable aura change can be identified as unrelated to watched buffs. | +| Scan options | `/br throttle on` adjusts periodic scans to movement, group size, and latency without delaying event refreshes. `/br fastaura` skips rescans when a readable aura change can be identified as unrelated to watched buffs. | ### Casting @@ -57,7 +58,9 @@ macro to work through the list. Your character goes first by default. window, and mute or unmute alerts. Open them with `/br key`. - **Buff and rank selection.** Enable buffs individually, set priority with `/br prio`, and set a shared or per-buff rebuff threshold with `/br rebuff`. - Group equivalents satisfy the same underlying buff. BuffRadar skips spells + Group equivalents satisfy the same underlying buff. `/br smartprio on` + can promote eligible buffs for tank or healer roles, wipe recovery, and + saved instance rules. Manual priority breaks ties. BuffRadar skips spells on cooldown and can pick a recipient-eligible rank when the data is available. - **Cast preview.** Hover a row or the window footer to see the planned cast. The next-cast tooltip can show the target, spell rank, fallback reason, @@ -127,11 +130,12 @@ aura and Hunter aspect reminders with `/br aura`. | Feature | Controls and behavior | |---|---| | Raid Coverage | `/br coverage` opens a read-only report of confirmed, missing, and unknown buffs by subgroup. Select a buff to drill down to the affected players. | -| Raid Preparation | Open the read-only checklist from **Raid Coverage** or use `/br prep`. Expand a player for missing and expiring buffs, consumable checks, and unknown readings. **Reagents** compares carried quantities with estimated needs and flags shortfalls. Roster changes refresh the open checklist and preserve expansion for a player still present. Use **Refresh Preparation**, or `/br prep personal` for weapon and pet reminders. | +| Raid Preparation | Open the read-only checklist from **Raid Coverage** or use `/br prep`. Expand a player for missing and expiring buffs, consumable checks, and unknown readings. **Reagents** compares carried quantities with estimated needs and flags shortfalls. Roster changes refresh the open checklist and preserve expansion for a player still present. Open **Personal** with `/br readiness`, even solo, for food, flask, an optional consumable aura, carried Healthstones, durability, and applicable weapon and pet checks. | | Subgroup Responsibilities | Open from **Raid Coverage** or `/br subgroup panel`. Restrict a buff to selected raid groups, preview the affected roster, and see why a group cast may fall back to a single-target cast. For example, `/br subgroup FORTITUDE 1,2` assigns groups 1 and 2. Set **All** or **None** as needed. Rules clear when you leave the raid or reload. | | Ready Checks | `/br ready show` lists player responses, missing and expiring buffs, unknowns, and estimated group reagents. `/br readypost` lets leaders and assistants enable automatic group-chat summaries. | | Recaps and sharing | Get a death recap or post-wipe rebuff report and reprint them with `/br death show` and `/br wipe show`. Use `/br summary` for needs by buff, `/br announce` for party or raid chat, and `/br discord` for copyable Markdown. | | Coverage line | Pick visible parts with `/br cover` including progress, buffs and cooldowns, the active or away BuffRadar roster, group expiry, world buffs, drinking healers, and session uptime. `/br uptime` reports the share of grouped scans that found every checked player buffed. | +| Encounter debuffs | In Settings → **Readiness**, or with `/br debuff add [player\|focus] [encounter ID]` and `/br debuff on`, show readable auras and their stacks in a separate strip. An encounter ID restricts a rule to that fight. | | Extras to watch | Read flask and food counts for Forever, see your temporary weapon enchant, and track your focus target's buff needs, world buff timers, or drinking healers. Watch group pets for Fortitude, Mark of the Wild, and Arcane Intellect. Use `/br consumables`, `/br weapon`, `/br focus`, `/br worldbuff`, `/br drink`, or `/br pets`. | ### Group Coordination @@ -161,6 +165,11 @@ aura and Hunter aspect reminders with `/br aura`. Test and silence alerts in instances from the **Alerts** tab. The window can flash after combat or for a supported pull countdown. See `/br soundfor`, `/br watch`, `/br fallsound`, and `/br pullflash`. +- **Expiry forecasts.** `/br forecast 60` warns about confirmed expirations + within 60 seconds. A supported pull timer extends the window to include the + countdown plus the lead time; `/br forecast timer 30` sets a local deadline. + Use `/br forecast off` to disable notices. Forecasts do not infer boss + mechanics or arm casts earlier than `/br rebuff` allows. ### Display and Accessibility @@ -184,7 +193,10 @@ aura and Hunter aspect reminders with `/br aura`. - **Quick controls.** Toggle known buffs from the icon strip, add a name finder to the list, and show or hide the cast counter. Open settings from the gear icon, the movable minimap button, the add-on menu - where available, or `/br config`. + where available, or `/br config`. The minimap marks confirmed coverage + green (`+`), ordinary needs yellow (`!`), critical needs red (`!!`), and + unknown coverage gray (`?`). A paused scan has no mark. `/br visual on` + adds quiet highlights independently of sound and respects Reduced Motion. - **Accessible settings.** Search the active tab with `/br config find`. Use `/br config navigate` for keyboard controls or `/br config narrate` for the game's configured text-to-speech voice. Tab or Shift+Tab moves, @@ -199,11 +211,12 @@ aura and Hunter aspect reminders with `/br aura`. | Feature | Controls and behavior | |---|---| -| Presets and specialization | The setup wizard includes Raid, Dungeon, and Solo presets, also available through `/br preset`. Buff toggles and rebuff overrides can follow the active specialization when the client identifies it. | +| Presets and specialization | Quick Setup drafts a preset and alert preferences based on your activity and role. It applies them only on confirmation. Standalone presets are available through `/br preset`. Buff toggles and rebuff overrides can follow the active specialization when the client identifies it. | | Named profiles | Save, load, list, delete, and share profiles from **Ignore & Stats** or `/br profile`. Preview a saved profile's differences with `/br profile diff `. `/br autoprofile` can switch profiles for raids, dungeons, battlegrounds, grouped world play, or solo play. | | Import and export | Use `/br export` and `/br import` for settings strings and `/br diff ` to preview them. Share the Class & Role Assignments table with `/br profile share` and `/br profile import`. A shared profile can replace a saved profile of the same name and is applied when loaded. Use `/br plan export` and `/br plan import` to transfer and merge group buff assignments, the blessing plan, and auto-profile mappings. | | Casts and history | Show session and all-time totals, reset counters, see per-spell stats or export them, and review the last 50 tracked casts. See `/br count`, `/br resetcount`, `/br stats`, and `/br history`. `/br offenders` tracks players seen unbuffed across group sessions. | -| Troubleshooting | `/br why ` explains how a player is handled. `/br debug` reports client and window state, `/br clicks` logs cast attempts, `/br selftest` prints a report for bug reports, `/br apicheck export` produces a copyable API report, `/br buffcheck` checks spell IDs, and `/br perf` reports scan timings when the client provides a timer. | +| Troubleshooting | `/br why ` explains how a player is handled. `/br debug` reports client and window state, `/br clicks` logs cast attempts, `/br selftest` prints a report for bug reports, `/br apicheck export` produces a copyable API report, `/br buffcheck` checks spell IDs, and `/br perf` reports scan timings when available. `/br stats memory` reports the game's addon total, not per-feature estimates. `/br lite on` pauses forecasts, readiness, debuffs, and optional watches without changing their saved settings. | +| UI integration and feedback | Use the [read-only status API](docs/STATUS_API.md) or `/br status export`. Get a copyable feature-request link with `/br feedback` or see the [roadmap](docs/ROADMAP.md). | ## Player Guides @@ -234,6 +247,10 @@ The [Forever TOC](editions/forever/BuffRadar.toc) and the historical validates and migrates `BuffRadarDB` on load; [Profiles](BuffRadar/Profiles.lua) handles settings and plan imports and exports. - [Core](BuffRadar/BuffRadar.lua) scans and builds the cast queue. + [Intelligence](BuffRadar/Intelligence.lua) owns scan cadence, forecasts and + contextual priority. [Status](BuffRadar/Status.lua) publishes copies; + [Debuffs](BuffRadar/Debuffs.lua) and [Readiness](BuffRadar/Readiness.lua) + own optional aura and inventory checks. [Coordination](BuffRadar/Coordination.lua) handles group messages and plans. - [Window](BuffRadar/Window.lua) owns the main window and secure buttons. [Minimap](BuffRadar/Minimap.lua) owns the minimap and addon menu. @@ -255,7 +272,7 @@ The [Forever TOC](editions/forever/BuffRadar.toc) and the historical | `.luacheckrc` | luacheck settings used by the checks | | `AGENTS.md` | Project rule sheet (prompt in force, frozen foundation, gate) | | `QUALITY.md` | Quality scorecard, scored from evidence | -| `docs/` | `PARITY.md` (capability matrix) and `DECISIONS.md` (decision log) | +| `docs/` | Capability matrix, decision log, status API, and roadmap | | `SECURITY.md` | How to report a security problem, privately | ## Making a Release diff --git a/docs/DECISIONS.md b/docs/DECISIONS.md index db0fa87..7a71c6b 100644 --- a/docs/DECISIONS.md +++ b/docs/DECISIONS.md @@ -417,3 +417,14 @@ split, then Briefs 2, 3, 4 — nothing else built; file-split Slices B - The smoke harness follows both manifests and checks load order, replaced saves, secure driver refusal, and position-only resets. The Forever field test is still required on the candidate ZIP. + +## 2026-11-18 — Readiness signals do not drive secure actions + +Forecasts use the last confirmed coverage of an aura family, adjusted for a +real pre-pull countdown or a user-entered deadline. They do not guess at +upcoming encounter mechanics. Optional debuff checks listen for player/focus +changes without scanning the cast queue in combat. The public API returns +copies of the last completed scan, with no targets while the scan is paused. +Readiness checks use only exposed local data; a carried Healthstone is not +evidence about a placed Soulwell. These policies and the new UI still need +Forever field verification. diff --git a/docs/FOREVER_RELEASE_CHECKLIST.md b/docs/FOREVER_RELEASE_CHECKLIST.md index 97f69a0..eefacc2 100644 --- a/docs/FOREVER_RELEASE_CHECKLIST.md +++ b/docs/FOREVER_RELEASE_CHECKLIST.md @@ -2,6 +2,32 @@ 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. +## Unreleased: Readiness + +- Open Quick Setup with `/br wizard` and Shift-right-click on the minimap. + Select Raid and Tank. Go Back or close without applying; reopen and finish. + Only Apply should change settings, and buff toggles and bindings must survive. +- Set a forecast lead longer than the rebuff window. Watch a readable timed + buff with no cast offer. Start, replace and cancel a native pull countdown + while coverage is still active; test a longer equivalent aura and a local + timer. No forecast should create a cast or persist into combat as current. +- Enable smart priority with assigned tank/healer roles. Try a real wipe and an + instance rule in two different zones. Confirm priorities respect assignments, + range, spell knowledge and cooldowns and that off restores manual behavior. +- Watch a known player/focus debuff. Test stacks, focus replacement, scoped + encounters, unreadable combat auras, death, and Lite mode. Check that the + separate strip never interrupts Cast Next Buff. +- Open `/br readiness` solo and in a group. Move a Healthstone in or out of + bags; try damaged equipment, a temporary coating and a configured consumable + aura. Confirm event updates, unknown labels, and the existing group and + reagent tabs. Enable Lite and turn it back off without losing settings. +- Verify minimap symbols, a pulse with sound muted, and suppression with Reduced + Motion. Verify Readiness keyboard navigation and German labels. Copy Feedback; + it must not open a browser or submit data by itself. +- Read status from an integration after a scan, entering combat, and changing + a nameplate token's target. Record `/br perf` and `/br stats memory` at rest + and moving in a raid; an aura event must still refresh promptly. + ## 1.15.35 Nearby casting, controller input, blessings, and nameplates Result: **Unverified in game**. Run against the candidate ZIP, not a loose copy. diff --git a/docs/PARITY.md b/docs/PARITY.md index fb0efcc..5928638 100644 --- a/docs/PARITY.md +++ b/docs/PARITY.md @@ -28,9 +28,10 @@ and the TOC module refactor). | Coverage expansion | Built-in buffs + consumables + custom spells + uptime + weapon watch + pets + aura/aspect watch + per-buff context + world-buff watch + healer drinking | Complete (batches 1–3) | Consumable tally, custom add/remove/list, uptime scoring, weapon flag on/off steps; pet rows + report exclusion, context gating (incl. the SHADOW_PROT instance default), world-buff line, drinking tag + coverage count steps | Weapon watch reads temporary weapon enchants only (GetWeaponEnchantInfo); solo with no other row, the reminder waits for a row or a group. The aura/aspect watch's positive path (a hunter/paladin who knows an aspect/aura spell) is not smoke-covered — the harness spellbook is a priest's/shaman's; toggle + edition gating are covered | | Alerts | New-name alert, drop alert, post-combat flash, instance-entry reminder, group expiry warning, a sound per alert kind | Complete | Alert + flash steps; entry reminder fires-once step; expiry tally step (3 holders < 5 min); 1.10.0 per-kind sound step (save/change/master via `/br soundfor`) | #33 shipped in 1.15.0 as the fall alert (off by default, Unverified in game) | | Stats & reporting | Cast stats + export, cast history, announce, ready-check report + auto-post, join digest, selftest, repeat offenders, Discord summary, death recap, post-wipe report | Complete (batches 1–4) | Announce/ready/digest/selftest steps; auto-post step (leader posts to PARTY); history record + resetcount-clear step; offenders fold-on-group-end step; stats export + Discord render steps; death-recap step (PLAYER_DEAD print + reprint); wipe step (controllable clock: single death = no report, 2-of-3 dead after 20 s = report) | — | -| Settings & QoL | Tabs UI, export/import, named profiles + share-one-profile, per-spec profiles, presets, auto profiles, scan throttle, settings search, setup wizard | Complete (batches 1–4) | Settings-fire-every-control step, export/import round-trip, profile + preset + auto-profile steps, throttle toggle + 25-player tick step, profile share/import round-trip, settings-search dim step, wizard step (preset pick applies + advances, theme cycles, Finish marks seen) | — | -| Settings data safety | Versioned SavedVariables, migrations, corrupt-data repair | Complete | Migration fixture: legacy v2 save → v21, including defaults for v20 saves; invalid plate-restore keys and malformed settings are dropped | — | -| Localisation | deDE, frFR, esES, ruRU, zhCN complete for every user-facing string | Complete | `tools/localecheck.py`: 81/81 strings in each of the five locales; German setup runs the full trial run | New locales are machine-assisted translations; native-speaker review welcome | +| Settings & QoL | Tabs UI, export/import, named profiles + share-one-profile, per-spec profiles, presets, auto profiles, scan throttle, settings search, setup wizard | Complete (batches 1–4) | Settings-fire-every-control step, export/import round-trip, profile + preset + auto-profile steps, throttle toggle + 25-player tick step, profile share/import round-trip, settings-search dim step, Quick Setup step (draft, Back, cancel, then apply) | — | +| Settings data safety | Versioned SavedVariables, migrations, corrupt-data repair | Complete | Migration fixture: legacy v2 save → v22, including v21 readiness-setting validation; invalid plate-restore keys and malformed settings are dropped | — | +| Localisation | English and German keys, partial frFR, esES, ruRU, zhCN | Offline checked | `tools/localecheck.py` enforces German coverage; German setup runs the full trial run | Native-speaker review welcome | +| Readiness and forecasts | Confirmed expiry alerts, role/instance/wipe priority, player/focus debuffs, Personal checklist, status API, Quick Setup, minimap badges, and Lite mode | Implemented, unreleased | Lua 5.1 trial steps cover alternate aura expiry, pull cancellation, role/instance order, restricted aura data, solo checklist, API copies, and combat/Lite invalidation | Unverified in game; Soulwell and prospective boss-mechanic availability are not inferred | ## The 50-item program (SEAN approved 2026-10-25: add all 50) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 0000000..4389953 --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,13 @@ +# BuffRadar roadmap + +This is the public roadmap for BuffRadar on WoW: Forever. Priorities may change +with player feedback and client capabilities. To suggest a feature, use the +[feature request form](https://github.com/SeanShaffer88/BuffRadar/issues/new?template=feature_request.md) +or copy its link in **Settings → Readiness → Feedback** (`/br feedback`). + +| Status | Work | +| --- | --- | +| **Implemented, not yet released** | Confirmed buff expiry forecasts, contextual priority, personal readiness, player/focus debuff watches, a read-only status API, Quick Setup, minimap status, quiet visuals, adaptive scans, and Lite mode. | +| **Next: verify in Forever** | Walk the [release checklist](FOREVER_RELEASE_CHECKLIST.md) on the candidate build. Check a raid-sized roster, live countdown cancellation, combat aura visibility, and scan/memory diagnostics. | +| **Under consideration** | Shareable encounter presets after spell IDs and aura availability are confirmed, more options for placing the debuff strip, and community examples using the [status API](STATUS_API.md). | +| **Waiting on client data** | Confirming that a placed Soulwell is reachable and usable, and automatically predicting upcoming encounter mechanics. BuffRadar does not guess at data the client does not expose. | diff --git a/docs/STATUS_API.md b/docs/STATUS_API.md new file mode 100644 index 0000000..4b25abc --- /dev/null +++ b/docs/STATUS_API.md @@ -0,0 +1,60 @@ +# BuffRadar status API (version 1) + +`BuffRadarAPI` is a local, read-only integration point. It does not scan auras on +request, change settings, cast, or send messages. The table is available once +BuffRadar's Lua files are loaded; before the first completed scan its state is +`unavailable`. All returned tables, including nested `missing` lists, are +independent copies. + +## Read the current state + +```lua +local api = BuffRadarAPI +if api and api.version == 1 then + local summary = api.GetSummary() + local unit = api.GetUnit("nameplate1") + -- summary.state is suitable for an icon or label. + -- If unit exists, unit.missing[1] is the first offered spell for that unit. +end +``` + +| Call | Returns | +| --- | --- | +| `GetSummary()` | `version`, `revision`, `state`, `partial`, `actionable` (number of cast targets), `expiring` (number of confirmed buff forecasts), optional `firstExpiry = { spell, name, endsAt }`, and `reason` when unavailable. `endsAt` uses the game's `GetTime()` clock, rounded to seconds. | +| `GetStatus()` | The summary plus `targets`, an ordered array of `{ unit, guid, name, missing }`. `missing` lists the localized spell names offered by the queue, including a group version when one is offered. | +| `GetUnit(unitToken)` | A target record for the token's current readable GUID, or `nil`. This also works for a nameplate token representing a queued party or raid member. A stale or reassigned token does not inherit a former unit's status. | + +`state` is one of `covered`, `attention`, `critical`, `unknown`, or `unavailable`. +`attention` can mean an ordinary missing buff, an out-of-range need, or a +confirmed expiry forecast; it does not guarantee a cast target. `critical` +means a checked defensive buff (or a smart-priority instance buff) is +confirmed missing or has at most 15 seconds left. `partial` can be true even +when one need is known. `covered` applies only to the buffs BuffRadar was able +to check, not every buff in the game. `unavailable` has a `reason` of `inactive`, +`updating`, `paused`, `combat`, or `dead`. In these states the API does not +return old targets as current. + +## React to changes + +Compatible custom trigger hosts receive `BUFFRADAR_STATUS_CHANGED` when a +completed snapshot changes or is invalidated. Read the API on that event and on +initialization; the event carries no arguments. Other consumers can poll the +lightweight summary or `GetUnit(unitToken)` on their own normal update path. +Use `revision` to skip re-rendering unchanged data. For a custom trigger, +register `BUFFRADAR_STATUS_CHANGED` and use the same condition on initialization: + +```lua +function() + local api = BuffRadarAPI + if not api or api.version ~= 1 then return false end + local state = api.GetSummary().state + return state == "attention" or state == "critical" +end +``` + +For per-nameplate text, pass that plate's current unit token to `GetUnit`. +Use its `missing` array to build the label and clear it when `GetUnit` +returns `nil`; do not hold on to a result across nameplate reuse. + +For troubleshooting without a script, use `/br status` or `/br status export`. +The export is a local copy dialog; review names before posting it publicly. diff --git a/docs/SUGGESTIONS.md b/docs/SUGGESTIONS.md index bf0645f..c25fc2c 100644 --- a/docs/SUGGESTIONS.md +++ b/docs/SUGGESTIONS.md @@ -88,3 +88,10 @@ built, gated and in 1.15.0; verified in game with every release through | 5 | Custom group-cast pairs for modifier clicks | Done — /br grouppair, consulted by GroupSpellFor | | 6 | Group-cast keybind | Done — BuffRadarGroupButton, falls back to the plain cast | | 7 | Workflow upkeep (actions off the deprecated Node 20 runtime) | Done — checkout v5, setup-python v6 in both workflows | + +## Readiness follow-up + +The current [roadmap](ROADMAP.md) tracks forecasts, contextual priority, +readiness, debuff watches, setup, and the read-only status integration. +Use the Feedback button in Settings → Readiness or `/br feedback` to copy +the feature request link. diff --git a/editions/forever/BuffRadar.toc b/editions/forever/BuffRadar.toc index 7e4ace1..85ee4e3 100644 --- a/editions/forever/BuffRadar.toc +++ b/editions/forever/BuffRadar.toc @@ -16,6 +16,10 @@ Locales\zhCN.lua Data.lua SavedVariables.lua BuffRadar.lua +Intelligence.lua +Status.lua +Debuffs.lua +Readiness.lua Minimap.lua Coordination.lua Window.lua diff --git a/editions/forever/CHANGELOG.md b/editions/forever/CHANGELOG.md index af37621..4d8ae7a 100644 --- a/editions/forever/CHANGELOG.md +++ b/editions/forever/CHANGELOG.md @@ -2,6 +2,20 @@ All notable changes to BuffRadar are listed here. Newest first. +## Unreleased — Readiness + +- Add confirmed expiry forecasts with pull-countdown and local deadline + support, and contextual priority for roles, wipe recovery and instance rules. +- Show exact-ID player/focus debuff watches with optional encounter scope. + Provide a versioned read-only buff-status API and a copyable report. +- Expand raid preparation with a solo-accessible Personal tab for Healthstones, + durability and an optional consumable aura. +- Add role/activity Quick Setup, contextual minimap status and quiet visual + alerts, and a copyable feature-request link. +- Add adaptive periodic scans, total memory reporting, and Lite mode. Upgrade + existing settings from schema v21 to v22 without a reset. +- **Unverified in game.** + ## 1.15.36 — WoW: Forever - Refresh the Forever README with the v1.15.35 in-game player list and all five settings screenshots. diff --git a/editions/forever/DESCRIPTION.md b/editions/forever/DESCRIPTION.md index 82edcff..c57ea26 100644 --- a/editions/forever/DESCRIPTION.md +++ b/editions/forever/DESCRIPTION.md @@ -46,6 +46,14 @@ come first. of the main window on German clients (settings are English for now). +## In development: Readiness + +Choose your role and activity in Quick Setup, see what needs attention on the +minimap, and review consumables, Healthstones in bags, and gear durability in +Personal readiness. Optional forecasts warn about readable buff expirations. +Watched debuffs show stacks separately from the cast queue. Lite mode pauses +optional checks while keeping the main queue. This is not yet a live release. + ## How to use it 1. Move the `BuffRadar` folder into your Forever diff --git a/editions/forever/FEATURES.md b/editions/forever/FEATURES.md index 02c8370..6dbd369 100644 --- a/editions/forever/FEATURES.md +++ b/editions/forever/FEATURES.md @@ -11,6 +11,25 @@ client — and the Forever buff set itself is unchanged from 1.2.4. **From 1.8.0 BuffRadar is Forever-only**: Retail support was dropped 2026-10-25, and 1.7.0 is the last Retail release. +## Unreleased: Readiness + +- Forecast confirmed expiry using real aura durations and a supported pull or + local preparation timer, without changing cast eligibility. +- Reorder already eligible buffs with smart priority for tanks, healers, wipe + recovery and instance rules. The saved manual order still breaks ties. +- Keep player/focus debuff icons and stack counts separate from the cast queue. + An optional encounter ID restricts a watch to that boss fight. +- Open personal raid preparation even solo. See Healthstones in bags, gear + durability and an optional consumable aura alongside food, flask and weapon + checks. The client does not report placed Soulwell availability. +- Choose role and activity in Quick Setup. Enable contextual minimap symbols + and quiet visuals, with Reduced Motion support. +- Read or export buff status, adjust periodic scans, report total memory and + pause optional work with Lite mode. Feedback copies a feature-request link. + +**Verification:** fake-client Lua 5.1 and package checks. Live behavior remains +**Unverified** pending the Forever release checklist. + ## 1.15.16 - Diagnose why nearby players are absent from the buff list. diff --git a/editions/forever/README.md b/editions/forever/README.md index e0338b6..e12d9d0 100644 --- a/editions/forever/README.md +++ b/editions/forever/README.md @@ -54,6 +54,7 @@ anything outside the game. Version 1.15.36 · Interface 16001 · GPLv3. This is a docs-only release. Field-tested through v1.15.33; v1.15.34–v1.15.36 remain Unverified in game. +The Readiness update below is unreleased and has not been tested in WoW. **Forever-only from 1.8.0:** the Retail edition ended at 1.7.0 (dropped 2026-10-25). Both editions were built from the same source; this zip's `.toc` @@ -63,6 +64,30 @@ targets the Forever client, and BuffRadar picks the Forever buff set when it loa **Docs:** [Features](FEATURES.md) · [Description](DESCRIPTION.md) · [Changelog](CHANGELOG.md) +## Readiness update (unreleased) + +Open **Settings → Readiness** for the new controls. Combat restrictions on +click-to-buff casts still apply. + +| Command | What it does | +| --- | --- | +| `/br wizard` or `/br quicksetup` | Pick your activity and primary role, then review and apply the setup. You can also Shift-right-click the minimap button. | +| `/br forecast 60` | Warn about confirmed expiry within 60 seconds. A supported pull countdown adds to the lead time. `/br forecast timer 30` uses a local deadline; `/br forecast off` stops warnings. Forecasts don't change cast eligibility. | +| `/br smartprio on` | Promote defensive buffs for tanks and wipe recovery, and mana buffs for healers. `/br smartprio here ` gives one eligible buff priority in this instance; use `clear` to remove the rule. `/br smartprio instance ` sets a rule from outside it. Off restores manual priority. | +| `/br debuff add [player\|focus] [encounter ID]` | Save a watch, then use `/br debuff on` to show readable icons and stacks. Omit the unit for yourself and the encounter ID to watch anywhere. Use `/br debuff list` or `/br debuff remove [player\|focus]` to manage watches. | +| `/br readiness` | Open **Personal** checks, including carried Healthstones and gear durability, even when solo. `/br readiness aura ` watches a consumable aura such as an augment-rune equivalent. `/br prep` opens the group checklist. | +| `/br minimapstatus` and `/br visual on` | Toggle coverage symbols or enable brief highlights independent of sound. Visual alerts respect Reduced Motion. | +| `/br throttle on` and `/br stats memory` | Adjust periodic scans to movement, group size and latency, and see the game's reported total addon memory. Event refreshes stay responsive. | +| `/br lite on` | Pause forecasts, preparation, debuffs, and optional watches without losing their settings. The main cast queue still works. | +| `/br status export` and `/br feedback` | Copy a local status report or the feature-request link. No player data is attached to feedback. | + +The **Personal** tab checks Healthstones in bags, not in the bank. It can't +confirm a placed Soulwell. Durability shows the lowest readable gear slot +and recommends repairs at 30% or below. Forever has no assumed augment-rune +aura; enter the spell ID of an equivalent you use. See the +[status API](https://github.com/SeanShaffer88/BuffRadar/blob/main/docs/STATUS_API.md) +and [roadmap](https://github.com/SeanShaffer88/BuffRadar/blob/main/docs/ROADMAP.md). + ## Features - **Live list of who needs what.** Players stay listed until every buff you can cast @@ -354,7 +379,7 @@ outside a capital, or turn off the default city pause with `/br cities`. | `/br assign ` | Leader assigns a buff to one player (rows float/sink by owner) | | `/br buddy` · `/br pill` | Split the list with other BuffRadar users · all-buffed pill | | `/br pin ` · `/br readypost` | Pin a player to the top · post ready-check summaries | -| `/br weapon` · `/br enterflash` · `/br throttle` | Weapon enchant watch · instance-entry reminder · big-group scan throttle | +| `/br weapon` · `/br enterflash` · `/br throttle` | Weapon enchant watch · instance-entry reminder · adaptive periodic scan throttle | | `/br history` | Your last 50 casts through BuffRadar | | `/br consumables` · `/br uptime` | Flask/food counts on the coverage line · coverage uptime % | | `/br custom add\|remove\|list ` | Watch any buff spell you know | diff --git a/tools/smoke51.py b/tools/smoke51.py index 7b070a1..b3e80c2 100644 --- a/tools/smoke51.py +++ b/tools/smoke51.py @@ -75,7 +75,7 @@ local initialGlobals = {} for key in pairs(env) do initialGlobals[key] = true end local addonGlobals = { - BuffRadarDB = true, + BuffRadarDB = true, BuffRadarAPI = true, BuffRadar_ToggleWindow = true, BuffRadar_ToggleSound = true, SLASH_BUFFRADAR1 = true, SLASH_BUFFRADAR2 = true, BINDING_HEADER_BUFFRADAR = true, BINDING_CATEGORY_BUFFRADAR = true, @@ -165,7 +165,7 @@ local replacement = { dbVersion = 9, scale = 1.5, showMinimap = true } client.BuffRadarDB = replacement onEvent(startup, "ADDON_LOADED", "BuffRadar") - assert(X.GetDB() == replacement and replacement.dbVersion == 21 and replacement.wizardSeen, + assert(X.GetDB() == replacement and replacement.dbVersion == 22 and replacement.wizardSeen, "normal load did not migrate and publish the replacement") assert(not X.Ignore.Has("BeforeLogin", "BeforeLogin"), "ignore index retained a replaced save") X.ApplyGeometry() @@ -186,7 +186,7 @@ end step("ADDON_LOADED", function() fire("ADDON_LOADED", "BuffRadar") - assert(NS.X.GetDB() == env.BuffRadarDB and env.BuffRadarDB.dbVersion == 21, "live settings were not published") + assert(NS.X.GetDB() == env.BuffRadarDB and env.BuffRadarDB.dbVersion == 22, "live settings were not published") local pullFrame = NS.X.pullFrame if not NS.X.ApiCheck then return end -- not in the Retail TOC assert(pullFrame and pullFrame.events.ADDON_LOADED, "pull listener missing at startup") @@ -412,7 +412,7 @@ local cfg = env.BuffRadarConfig assert(not cfg.nativeTabs, "bottom tabs used without PanelTemplates") assert(cfg.template ~= "ButtonFrameTemplate", "template window kept without its members") - for _, key in ipairs({ "look", "alerts", "buffs", "behavior", "data" }) do + for _, key in ipairs({ "look", "alerts", "buffs", "behavior", "data", "readiness" }) do local btn = cfg.tabBtns[key] btn.scripts.OnClick(btn, "LeftButton") assert(cfg.panels[key].shown, "fallback tab " .. key .. " didn't show its panel") @@ -423,9 +423,9 @@ local cfg = env.BuffRadarConfig assert(cfg.template == "ButtonFrameTemplate", "template: " .. tostring(cfg.template)) assert(cfg.nativeTabs, "bottom tabs not used") - assert(cfg.numTabs == 5, "PanelTemplates_SetNumTabs not called with 5") - local keys = { "look", "alerts", "buffs", "behavior", "data" } - for i = 1, 5 do + assert(cfg.numTabs == 6, "PanelTemplates_SetNumTabs not called with 6") + local keys = { "look", "alerts", "buffs", "behavior", "data", "readiness" } + for i = 1, #keys do local tab = assert(env["BuffRadarConfigTab" .. i], "BuffRadarConfigTab" .. i .. " missing") assert(tab.template == "PanelTabButtonTemplate", "tab template") tab.scripts.OnClick(tab, "LeftButton") @@ -537,16 +537,16 @@ assert(diagnostic:find("START_TIMER seen 0", 1, true) and diagnostic:find("DBM PT seen 1", 1, true), "D5-only pull activity was missing from diagnostics") NS.X.tally = { FORTITUDE = { total = 5, miss = 2 } } - firePull("START_TIMER", 3, 10, 10) + firePull("START_TIMER", 2, 10, 10) assert(NS.X.pullProbe.stSeen == 1, "START_TIMER not counted by the probe") assert(NS.X.pull == nil, "flash state set while pullflash is off") env.SlashCmdList.BUFFRADAR("pullflash on") - firePull("START_TIMER", 3, 10, 10) + firePull("START_TIMER", 2, 10, 10) assert(NS.X.pull ~= nil, "pull state not set with pullflash on and casts outstanding") local found for _, line in ipairs(chat) do if line:find("Pull in 10s", 1, true) then found = line end end assert(found, "no countdown line printed: " .. table.concat(chat, " | ")) - firePull("START_TIMER", 3, 0, 0) + firePull("START_TIMER", 2, 0, 0) assert(NS.X.pull == nil, "zero timer did not cancel the pull state") firePull("CHAT_MSG_ADDON", "D5", "PT\t10", "RAID", "Nobody-Elsewhere") assert(NS.X.pullProbe.d5 == 2, "second DBM PT message not counted by the probe") @@ -567,10 +567,12 @@ X.SenderTrusted = function(sender) return sender == "Leader-TestRealm" end X.tally, db.pullFlash = { FORTITUDE = { miss = 1 } }, true local pf = X.pullFrame - pf.scripts.OnEvent(pf, "START_TIMER", 3, 8, 8) + pf.scripts.OnEvent(pf, "START_TIMER", 2, 8, 8) local timerA = X.pull pf.scripts.OnEvent(pf, "CHAT_MSG_ADDON", "D5", "PT\t12", "RAID", "Leader-TestRealm") local timerB = X.pull + pf.scripts.OnEvent(pf, "CANCEL_PLAYER_COUNTDOWN", "Player-Leader") + assert(X.pull == timerB, "an older native cancellation cleared the replacement provider") local q = env.__timers env.__timers = {} local scheduled = timerA and timerB and timerA ~= timerB and timerB.source == "boss mod" and #q == 4 @@ -1740,7 +1742,7 @@ assert(d.castMethod == "target", "pre-v3 castMethod not reset: " .. tostring(d.castMethod)) assert(d.clickReg == "both", "pre-v3 clickReg not reset: " .. tostring(d.clickReg)) assert(d.includeSelf == true, "pre-v4 includeSelf not forced on") - assert(d.dbVersion == 21, "dbVersion not migrated to 21: " .. tostring(d.dbVersion)) + assert(d.dbVersion == 22, "dbVersion not migrated to 21: " .. tostring(d.dbVersion)) assert(d.assignmentEnabled == false and next(d.buffAssignments) == nil, "migration activated assignments") assert(next(d.blessingPreferences) == nil, "existing character got a blessing override") assert(d.wizardSeen == false, "ancient save should still count as a new user for the wizard") @@ -1764,7 +1766,7 @@ env.BuffRadarDB = "junk" fire("ADDON_LOADED", "BuffRadar") d = env.BuffRadarDB - assert(type(d) == "table" and d.dbVersion == 21 and d.scale == 1, + assert(type(d) == "table" and d.dbVersion == 22 and d.scale == 1, "corrupt save not replaced with defaults") d.scale = 1 -- a 1.7.0-era save (dbVersion 9): an existing user — the wizard @@ -1772,22 +1774,22 @@ env.BuffRadarDB = { dbVersion = 9 } fire("ADDON_LOADED", "BuffRadar") d = env.BuffRadarDB - assert(d.dbVersion == 21 and d.wizardSeen == true, + assert(d.dbVersion == 22 and d.wizardSeen == true, "existing user not marked wizard-seen: " .. tostring(d.wizardSeen)) d.dbVersion, d.assignmentEnabled, d.thornsAnyClassOutdoors = 18, true, nil fire("ADDON_LOADED", "BuffRadar") d = env.BuffRadarDB - assert(d.dbVersion == 21 and d.thornsAnyClassOutdoors == false and d.assignmentEnabled, + assert(d.dbVersion == 22 and d.thornsAnyClassOutdoors == false and d.assignmentEnabled, "v18 settings did not gain an opt-in Thorns default while preserving assignments") d.dbVersion, d.autoThemePriority, d.theme = 19, nil, "ui.auto" fire("ADDON_LOADED", "BuffRadar") d = env.BuffRadarDB - assert(d.dbVersion == 21 and d.theme == "ui.auto" and d.autoThemePriority == "", + assert(d.dbVersion == 22 and d.theme == "ui.auto" and d.autoThemePriority == "", "v19 migration changed Auto opt-in or failed to default the priority order") d.dbVersion, d.blessingComplement, d.plateRestore = 20, nil, nil fire("ADDON_LOADED", "BuffRadar") d = env.BuffRadarDB - assert(d.dbVersion == 21 and d.blessingComplement == false and not next(d.plateRestore) and d.assignmentEnabled, + assert(d.dbVersion == 22 and d.blessingComplement == false and not next(d.plateRestore) and d.assignmentEnabled, "v20 migration turned on a new feature or lost an existing preference") d.blessingComplement = true d.plateRestore = { nameplateShowFriends = false, nameplateShowAll = true, @@ -2859,7 +2861,7 @@ refresh() local cover for _, fs in ipairs(env.__fontstrings) do - if type(fs.text) == "string" and fs.text:find("Flask", 1, true) then cover = fs.text end + if type(fs.text) == "string" and fs.text:find("Flask ", 1, true) then cover = fs.text end end assert(cover, "no consumables on the coverage line") assert(cover:find("Flask 1/3", 1, true), "flask count wrong: " .. cover) @@ -3233,6 +3235,8 @@ local onUpdate = driver.scripts.OnUpdate local db = env.BuffRadarDB local oldCount, oldThrottle, oldCity = env.GetNumGroupMembers, db.scanThrottle, db.pauseInCities + local oldTime = env.__over.GetTime + env.__over.GetTime = function() return 100000 end -- no recent combat recovery local calls = 0 env.GetNumGroupMembers = function() calls = calls + 1; return 25 end db.scanThrottle, db.pauseInCities = true, true @@ -3252,7 +3256,7 @@ local readsAtEvent = calls for _ = 1, 40 do onUpdate(driver, 0.01) end local nextHalfReads, noExtraRefresh = calls, env.__zoneCalls == refreshes + 1 - env.GetNumGroupMembers, db.scanThrottle, db.pauseInCities = oldCount, oldThrottle, oldCity + env.GetNumGroupMembers, db.scanThrottle, db.pauseInCities, env.__over.GetTime = oldCount, oldThrottle, oldCity, oldTime timerTick() assert(early and steps >= 10 and steps <= 11, ("fallback event took %d ms after 40 frames; group API calls %d/%d/%d") @@ -5854,32 +5858,41 @@ cleanup() end) -step("setup wizard walks a new user through (1.9.0)", function() +step("Quick Setup stages activity and role, supports Back and cancel, and applies only on Finish", function() local db = env.BuffRadarDB assert(db.wizardSeen == false, "wizard should start unseen on a fresh save") - env.SlashCmdList.BUFFRADAR("theme parchment") + local old = {} + for _, key in ipairs({ "sortMode", "groupOnly", "groupCast", "pauseInCities", "forecastSeconds", + "smartPriority", "scanThrottle", "visualAlerts", "statusMinimap" }) do old[key] = db[key] end + local theme, enabled = db.theme, db.enabled env.SlashCmdList.BUFFRADAR("wizard") local w = env.BuffRadarWizard - assert(w and w.shown, "wizard did not open") - -- Page 1: dirty the sort mode, then pick "In a party" (dungeon preset). - db.sortMode = "role" - w.choice[2].scripts.OnClick(w.choice[2]) - assert(db.sortMode == "need", "party preset not applied by the wizard: " .. tostring(db.sortMode)) - assert(db.groupOnly == true, "party preset did not set groupOnly") - assert(w.page == 2, "wizard did not advance to page 2") - -- Page 2: the theme button cycles the theme. - for _, label in ipairs({ "ElvUI", "EllesmereUI", "AnoUI+", "Wick's UI", "Ultimate Forever UI", "ForeverForge UI", - "DaylightUI", "MeredanUI", "NazgrelUI", "Reforged UI", "Auto (Midnight)" }) do - w.choice[1].scripts.OnClick(w.choice[1]) - assert(w.choice[1]:GetText() == "Theme: " .. label, "wizard skipped or mislabeled " .. label) - end - env.SlashCmdList.BUFFRADAR("theme midnight") - w.next.scripts.OnClick(w.next) - assert(w.page == 3, "wizard did not advance to page 3") - -- Page 3: Finish closes it and marks it seen. - w.next.scripts.OnClick(w.next) - assert(db.wizardSeen == true, "finishing did not mark the wizard seen") - assert(not w.shown, "wizard did not close on Finish") + assert(w and w.shown and w.page == 1, "wizard did not open") + w.choice[2]:Click() + assert(w.page == 2 and db.sortMode == old.sortMode and db.groupOnly == old.groupOnly, + "choosing an activity applied a preset before review") + w.choice[3]:Click() + assert(w.page == 3 and w.draft.role == "DAMAGER" and db.forecastSeconds == old.forecastSeconds, + "choosing a role modified the save before review") + w.back:Click() + assert(w.page == 2 and w.choice[3]:GetText():find("+ ", 1, true) == 1, "Back lost the selected role") + w.close:Click() + assert(not w.shown and not w.draft and db.sortMode == old.sortMode, "cancel applied drafted settings") + local shift = env.IsShiftKeyDown + env.IsShiftKeyDown = function() return true end + local button = env.BuffRadarMinimapButton + button.scripts.OnClick(button, "RightButton") + env.IsShiftKeyDown = shift + assert(w.shown and w.page == 1 and not w.draft.activity, "shift-right-click did not start a fresh wizard") + w.choice[3]:Click() + w.choice[1]:Click() + w.next:Click() + assert(db.wizardSeen and not w.shown and db.sortMode == "role" and db.smartPriority + and db.forecastSeconds == 60 and db.scanThrottle and db.visualAlerts and db.statusMinimap, + "Tank + Raid did not apply the reviewed setup") + assert(db.theme == theme and db.enabled == enabled, "Quick Setup changed the theme or selected buffs") + for key, value in pairs(old) do db[key] = value end + NS.X.Intel.SettingsChanged() end) step("two-column layout splits a long list (1.9.0)", function() @@ -6663,7 +6676,7 @@ assert(pf, "no frame registered START_TIMER") env.SlashCmdList.BUFFRADAR("pullflash on") refresh() -- a real scan, so the tally holds casts still needed - pf.scripts.OnEvent(pf, "START_TIMER", 3, 10, 10) + pf.scripts.OnEvent(pf, "START_TIMER", 2, 10, 10) assert(NS.X.pull ~= nil, "pull state not set") NS.X.Refresh() -- not refresh(): that drains queued timers, ending the pull local found @@ -6671,7 +6684,7 @@ if type(fs.text) == "string" and fs.text:find("Pull in ", 1, true) then found = fs.text end end assert(found, "no pull countdown on the coverage line") - pf.scripts.OnEvent(pf, "START_TIMER", 3, 0, 0) -- zero cancels + pf.scripts.OnEvent(pf, "START_TIMER", 2, 0, 0) -- zero cancels assert(NS.X.pull == nil, "pull state not cleared by the cancel") NS.X.Refresh() local gone = true @@ -7200,7 +7213,7 @@ for index = 3, 8 do model.reagents[index] = { name = "Reagent" .. index, carried = 4, needed = 1 } end X.RaidPreparationSnapshot = function(personal) calls = calls + 1 - model.personal = personal and "Personal reminder" or nil + if personal then return { members = {}, reagents = {}, personal = { { text = "Personal reminder" } } } end return model end slash("coverage") @@ -7247,7 +7260,8 @@ view.back:Click() assert(coverage:IsVisible() and not view:IsVisible(), "Back did not restore Raid Coverage") slash("prep personal") - assert(view:IsVisible() and view.personalNote:GetText() == "Personal reminder", "personal mode stopped working") + assert(view:IsVisible() and view.tab == "personal" and view.rows[1].heading:GetText() == "Personal reminder", + "personal mode stopped working") X.QueueAssignmentPreviewRefresh() slash("prep hide") local scanned = calls @@ -7353,8 +7367,8 @@ assert(unrestricted ~= "subgroup", "clearing the filter left broad casting blocked") slash("subgroup FORTITUDE 1") slash("prep personal") - local prep = X.RaidPreparationSnapshot(true) - assert(prep and #prep.members == 2 and prep.personal, "preparation required a ready check or dropped a subgroup") + local prep = X.RaidPreparationSnapshot() + assert(prep and #prep.members == 2, "preparation required a ready check or dropped a subgroup") assert(prep.members[2].name == "Zed-TestRealm" and prep.members[2].guid == env.UnitGUID("raid2") and prep.members[2].status == "attention" and table.concat(prep.members[2].details, ","):find("Food missing", 1, true), @@ -7967,7 +7981,7 @@ local n = #chat env.SlashCmdList.BUFFRADAR("selftest") assert(chatSince(n, "BuffRadar self-test"), "no self-test header") - assert(chatSince(n, "dbVersion 21"), "self-test missing dbVersion") + assert(chatSince(n, "dbVersion 22"), "self-test missing dbVersion") assert(chatSince(n, "role filter"), "self-test missing the 1.5.0 state line") assert(chatSince(n, "custom spells"), "self-test missing the 1.6.0 state line") assert(chatSince(n, "weapon watch"), "self-test missing the 1.7.0 state line") @@ -8461,7 +8475,7 @@ env.GetNumGroupMembers = nil X.assign, X.blessPlan, X.cover = {}, {}, {} local cmds = {} - for w in ("nearby coordinate buffassign undo coverage show hide group cities sync requests digest sound soundfor prio view scroll clickthrough counts macro keybind clicks mode clickreg debug lock self pvp autohide rebuff groupcast sort filter strip fade mana selftest compact text charpoint export import profile plan summary discord offenders preset fastaura modclick grouppair pullflash ready prep subgroup fallsound consumables custom assign pin history throttle growup cover rowcolor tooltip rowgap iconsize twocol find findbox bars markers focus pets aura thornsoutdoors worldbuff drink context theme weapon enterflash readypost death wipe buddy bless uptime autoprofile ignore unignore ignores bg taxi watch alertsound minimap stats specscale tagsymbols motion rangewatch assumerange snap scale width buffs toggle announce signore unsignore plates why apicheck buffcheck perf diff practice config"):gmatch("%S+") do + for w in ("nearby coordinate buffassign undo coverage show hide group cities sync requests digest sound soundfor prio view scroll clickthrough counts macro keybind clicks mode clickreg debug lock self pvp autohide rebuff groupcast sort filter strip fade mana selftest compact text charpoint export import profile plan summary discord offenders preset fastaura modclick grouppair pullflash ready prep subgroup fallsound consumables custom assign pin history throttle growup cover rowcolor tooltip rowgap iconsize twocol find findbox bars markers focus pets aura thornsoutdoors worldbuff drink context theme weapon enterflash readypost death wipe buddy bless uptime autoprofile ignore unignore ignores bg taxi watch alertsound minimap stats specscale tagsymbols motion rangewatch assumerange snap scale width buffs toggle announce signore unsignore plates why apicheck buffcheck perf diff practice config forecast smartprio status minimapstatus readiness debuff lite visual feedback"):gmatch("%S+") do cmds[#cmds + 1] = w end local args = { "", "on", "off", "toggle", "list", "add", "remove", "clear", "set", "save", "load", "delete", "export", @@ -8623,6 +8637,423 @@ error(#fails .. " finding(s) [" .. table.concat(st, " ") .. "]:\n " .. table.concat(fails, "\n ")) end end) +-- Fresh, clock-controlled clients for the intelligence and readiness features. +do + local function FeatureClient(saved, roster) + local client, messages = TestClient() + local O = client.__over + local now, due = 100, {} + O.GetTime = function() return now end + if client.C_Timer then + client.C_Timer.After = function(delay, callback) due[#due + 1] = { now + delay, callback } end + end + local units = { player = { "Me", "PRIEST" } } + if roster then units.party1, units.party2 = { "Alia", "PALADIN" }, { "Bren", "PRIEST" } end + O.UnitExists = function(unit) return units[unit] ~= nil end + O.UnitIsPlayer = O.UnitExists + O.UnitGUID = function(unit) return units[unit] and ("Player-1-" .. units[unit][1]) end + O.UnitName = function(unit) return units[unit] and units[unit][1] end + O.UnitFullName = function(unit) return O.UnitName(unit), "Realm" end + O.UnitClass = function(unit) local u = units[unit]; if u then return u[2], u[2] end end + client.IsInGroup = function() return roster == true end + client.GetNumGroupMembers = function() return roster and 3 or 0 end + client.IsSpellInRange = function() return 1 end + client.UnitGroupRolesAssigned = function(unit) + return unit == "party1" and "TANK" or unit == "party2" and "HEALER" or "NONE" + end + local mana = forever and "Divine Spirit" or "Arcane Intellect" + local manaKey = forever and "DIVINE_SPIRIT" or "ARCANE_INTELLECT" + client.IsPlayerSpell = function(id) return id == 1243 or id == (forever and 14752 or 1459) end + if not forever then client.GetSpellBookItemName = function() end end + saved.dbVersion, saved.wizardSeen, saved.playSound = saved.dbVersion or 22, true, false + saved.enabled = { INNER_FIRE = false, SHADOWGUARD = false } + client.BuffRadarDB = saved + local X, startup = LoadClient(client) + local function event(name, ...) + for i = 1, #client.__frames do + local frame = client.__frames[i] + local registered = frame.events and frame.events[name] + if registered and (type(registered) ~= "table" or registered[1] == (...) or registered[2] == (...)) then + frame.scripts.OnEvent(frame, name, ...) + end + end + end + local function advance(dt, tick) + now = now + dt + if client.C_Timer then + for _ = 1, 80 do + local index + for i, job in ipairs(due) do + if job[1] <= now and (not index or job[1] < due[index][1]) then index = i end + end + if not index then break end + table.remove(due, index)[2]() + end + if tick then client.__ticker() end + else + startup.scripts.OnUpdate(startup, dt) + end + end + event("ADDON_LOADED", "BuffRadar") + event("PLAYER_LOGIN") + return { client = client, X = X, api = client.BuffRadarAPI, db = X.GetDB(), event = event, advance = advance, + O = O, units = units, mana = mana, manaKey = manaKey, slash = client.SlashCmdList.BUFFRADAR, messages = messages } + end + + step("v21 upgrades to validated bounded readiness settings; named profiles leave local rules alone", function() + local f = FeatureClient({ dbVersion = 21, forecastSeconds = 900, smartPriority = "true", readinessAura = -12, + instancePriority = { [12] = "FORTITUDE", [11] = "NOT_A_BUFF", [0] = "FORTITUDE" }, + debuffRules = { { spellID = 700, unit = "focus", encounterID = 21 }, + { spellID = 700, unit = "focus", encounterID = 99 }, { spellID = 701, unit = "target", encounterID = 0 }, + { spellID = math.huge, unit = "player", encounterID = 0 } } }) + local db, X = f.db, f.X + assert(db.dbVersion == 22 and db.forecastSeconds == 300 and not db.smartPriority + and db.readinessAura == 0 and db.statusMinimap, "new scalar defaults or validation were wrong") + assert(db.instancePriority[12] == "FORTITUDE" and not db.instancePriority[0] and not db.instancePriority[11] + and #db.debuffRules == 1 and db.debuffRules[1].encounterID == 21, "invalid or duplicate rule survived sanitation") + for i = 1, 7 do assert(X.Debuffs.SetRule(i, "player", 0)) end + assert(not X.Debuffs.SetRule(12, "player", 0) and #db.debuffRules == 8, "watch limit was not enforced") + db.forecastSeconds, db.visualAlerts = 45, true + assert(X.SaveProfile("ReadinessTest"), "could not save a profile with new controls") + db.forecastSeconds, db.visualAlerts = 0, false + db.debuffRules[1].encounterID, db.instancePriority[12] = 45, f.manaKey + assert(X.LoadProfile("ReadinessTest") and db.forecastSeconds == 45 and db.visualAlerts + and db.debuffRules[1].encounterID == 45 and db.instancePriority[12] == f.manaKey, "profile lost settings or copied local rules") + local oldProfile = db.profiles.ReadinessTest + for _, key in ipairs({ "forecastSeconds", "smartPriority", "statusMinimap", "visualAlerts", "liteMode" }) do + oldProfile = oldProfile:gsub(";" .. key .. "=%d+", "") + end + db.forecastSeconds, db.visualAlerts, db.liteMode = 81, false, true + X.ApplyProfile(assert(X.ParseProfile(oldProfile))) + assert(db.forecastSeconds == 81 and not db.visualAlerts and db.liteMode, "an older BR2 profile changed new settings") + end) + + step("Forecasts use the last covering aura, real pull timers and a local deadline without adding casts", function() + local f = FeatureClient({ forecastSeconds = 35 }, true) + local c, X, A = f.client, f.X, f.api + local expiry, other, unreadable = 148, nil, {} + c.issecretvalue = function(v) return v == unreadable end + f.O.Aura = function(unit, spell) + if spell == "Power Word: Fortitude" then return { expirationTime = expiry } end + if spell == f.mana then return { expirationTime = 0 } end + if spell == "Prayer of Fortitude" and other then return { expirationTime = other } end + return nil + end + X.Refresh() + assert(A.GetSummary().state == "covered" and A.GetSummary().expiring == 0, "an aura outside the lead time warned") + f.slash("forecast timer 20") + f.advance(0.11) + local status = A.GetStatus() + assert(status.expiring == 3 and status.firstExpiry.spell == "Power Word: Fortitude" and status.firstExpiry.endsAt == 148 + and status.actionable == 0 and not c.BuffRadarNextButton:GetAttribute("type"), "forecast changed the cast queue or missed a deadline") + local notices = #f.messages + X.Refresh(); X.Refresh() + assert(#f.messages == notices, "the same forecast repeatedly alerted") + f.slash("forecast timer off") + f.advance(0.11) + assert(A.GetSummary().expiring == 0, "cancelled local deadline still affected forecasts") + if X.pullFrame then + f.event("START_TIMER", 0, 20, 20) + X.Refresh() + assert(not X.pull and A.GetSummary().expiring == 0, "a PvP countdown was mistaken for a pull") + f.event("START_TIMER", 2, unreadable, 20) + assert(not X.pull, "unreadable countdown fell back to an unrelated total timer length") + f.event("START_PLAYER_COUNTDOWN", "Player-1-Alia", 20, 20) + f.advance(0.11) + assert(X.pull and A.GetSummary().expiring == 3 and A.GetSummary().actionable == 0, + "native pull needed missing buffs or the flash setting to forecast") + f.event("STOP_TIMER_OF_TYPE", 1) + assert(X.pull, "challenge countdown stop cancelled a player countdown") + f.event("CANCEL_PLAYER_COUNTDOWN", "Player-1-Alia") + f.advance(0.11) + assert(not X.pull and A.GetSummary().expiring == 0, "cancelled pull stayed in the forecast") + f.event("START_TIMER", 2, 20, 20) + f.event("STOP_TIMER_OF_TYPE", 2) + assert(not X.pull, "stop-by-type did not cancel the player timer") + f.event("START_PLAYER_COUNTDOWN", "Player-1-Alia", 20, 20) + f.event("ENCOUNTER_START", 88) + assert(not X.pull, "encounter start left the preparation timer active") + end + expiry = 120 + if forever then + other = 0 + X.Refresh() + assert(A.GetSummary().expiring == 0, "permanent alternate coverage was ignored") + other = unreadable + X.Refresh() + assert(A.GetSummary().expiring == 0 and A.GetSummary().state == "unknown", + "a hidden alternate timer produced a false renew warning") + other = nil + end + f.db.rebuff = 0 + X.Refresh() + assert(A.GetSummary().expiring == 3 and A.GetSummary().actionable == 0, "a short known duration was not forecast without a cast") + expiry = unreadable + f.db.rebuff = 30 + X.Refresh() + assert(A.GetSummary().expiring == 0 and A.GetSummary().partial, "protected timer became a known expiry") + end) + + step("Smart priority promotes eligible role, instance and wipe-recovery buffs without rewriting manual priority", function() + local f = FeatureClient({ includeSelf = false, wipeReport = false }, true) + local c, X, A = f.client, f.X, f.api + f.db.buffPrio = { f.manaKey, "FORTITUDE" } + X.prioDirty = true + local function first(unit) + local row = A.GetUnit(unit) + return row and row.missing[1] + end + X.Refresh() + assert(first("party1") == f.mana and first("party2") == f.mana, "manual order was not applied") + f.slash("smartprio on"); X.Refresh() + assert(first("party1") == "Power Word: Fortitude" and first("party2") == f.mana, "tank/healer roles were not distinguished") + local instance = 71 + c.GetInstanceInfo = function() return "Dungeon", "party", 1, "Normal", 5, nil, false, instance end + f.slash("smartprio here " .. f.manaKey); X.Refresh() + assert(f.db.instancePriority[71] == f.manaKey and first("party1") == f.mana, "configured instance did not promote its buff") + instance = 72 + X.Refresh() + assert(first("party1") == "Power Word: Fortitude", "a rule leaked to another instance") + f.event("ENCOUNTER_END", 123, "Boss", 1, 3, 0) + X.Refresh() + assert(first("party2") == "Power Word: Fortitude", "failed encounter did not promote recovery buffs with wipe reports off") + f.advance(91); X.Refresh() + assert(first("party2") == f.mana, "wipe priority never expired") + f.db.enabled.FORTITUDE = false + X.Refresh() + assert(first("party1") == f.mana, "smart priority bypassed a disabled buff") + f.db.enabled.FORTITUDE = true + c.GetSpellCooldown = function(spell) + if spell == "Power Word: Fortitude" then return c.GetTime() - 1, 30 end + return 0, 0 + end + X.Refresh() + assert(first("party1") == f.mana, "smart priority offered a buff on cooldown") + c.GetSpellCooldown = nil + c.IsSpellInRange = function(spell) return spell == "Power Word: Fortitude" and 0 or 1 end + X.Refresh() + assert(first("party1") == f.mana, "smart priority offered an out-of-range buff") + c.IsSpellInRange = function() return 1 end + c.UnitGroupRolesAssigned = function(unit) return unit == "party2" and "TANK" or "HEALER" end + f.event("PLAYER_ROLES_ASSIGNED"); f.advance(0.11) + assert(first("party1") == f.mana and first("party2") == "Power Word: Fortitude", "role change did not refresh smart order") + f.slash("smartprio off"); X.Refresh() + assert(first("party1") == f.mana and f.db.buffPrio[1] == f.manaKey, "turning smart priority off did not restore manual behavior") + end) + + step("Read-only status exports queue copies, uses contextual symbols and quiet alerts, and invalidates in combat", function() + local f = FeatureClient({ hidden = true, visualAlerts = true, rebuff = 0 }, true) + local c, X, A = f.client, f.X, f.api + local button, events, hasMana, duration = c.BuffRadarMinimapButton, 0, true, 0 + c.WeakAuras = { ScanEvents = function(event) + assert(event == "BUFFRADAR_STATUS_CHANGED" and A.version == 1, "wrong integration event") + events = events + 1 + end } + f.O.Aura = function(unit, spell) + if spell == "Power Word: Fortitude" then return duration and { expirationTime = duration } or nil end + if spell == f.mana and (hasMana or unit ~= "party1") then return { expirationTime = 0 } end + return nil + end + X.Refresh() + assert(A.GetSummary().state == "covered" and button.statusMark:GetText() == "+", "covered minimap state was wrong") + local revision, notices = A.GetSummary().revision, events + X.Refresh() + assert(A.GetSummary().revision == revision and events == notices, "unchanged scan emitted duplicate event") + hasMana = false + X.Refresh() + assert(A.GetSummary().state == "attention" and button.statusMark:GetText() == "!", "ordinary missing buff was not yellow") + local snapshot = A.GetStatus() + local row = assert(A.GetUnit("party1")) + assert(snapshot.targets[1].guid == row.guid and row.missing[1] == f.mana, "API did not return the queued buff") + snapshot.targets[1].missing[1], row.name = "modified", "changed" + f.units.nameplate1 = f.units.party1 + assert(A.GetUnit("nameplate1").missing[1] == f.mana and A.GetUnit("party1").name == "Alia", + "integration could mutate live state or could not map a nameplate alias") + f.units.nameplate1 = { "Different", "PALADIN" } + assert(not A.GetUnit("nameplate1"), "reassigned token inherited someone else's queue status") + duration = c.GetTime() + 12 + X.Refresh() + assert(A.GetSummary().state == "critical" and button.statusMark:GetText() == "!!" and button.pulse:IsShown(), + "important short buff did not pulse with sound off, even though it was outside the rebuff window") + f.advance(0.7, true) + assert(not button.pulse:IsShown(), "short minimap pulse did not clear") + c.WeakAuras.ScanEvents = function() error("consumer failed") end + f.db.reduceMotion = true + duration = 0; X.Refresh(); f.advance(2.1) + duration = nil; X.Refresh() + assert(not button.pulse:IsShown(), "Reduced Motion did not suppress visual alerts") + c.__combat = true + f.event("PLAYER_REGEN_DISABLED") + assert(A.GetSummary().reason == "combat" and #A.GetStatus().targets == 0 and not A.GetUnit("party1") + and not button.statusMark:IsShown(), "stale status survived combat lockdown") + c.__combat = false + f.event("PLAYER_REGEN_ENABLED"); f.advance(0.11) + assert(A.GetSummary().state == "critical", "completed scan did not recover after combat") + f.slash("minimapstatus off") + assert(not button.statusMark:IsShown() and A.GetSummary().state == "critical", "minimap preference disabled the API") + end) + + step("Debuff strip is scoped to spell, unit and encounter; restricted or old focus auras never persist", function() + local f = FeatureClient({ fastAura = true }, true) + local c = f.client + local hidden, reads = {}, 0 + local auras = { player = { spellId = 700, name = "Test Debuff", icon = 14000, applications = 3 }, + focus = { spellId = 701, name = "Boss Debuff", icon = 14001, applications = 5 } } + f.units.focus = { "Focus", "WARRIOR" } + c.issecretvalue = function(value) return value == hidden end + c.C_UnitAuras.GetDebuffDataByIndex = function(unit, i) + assert(unit == "player" or unit == "focus", "debuff scan read another unit") + reads = reads + 1 + if i == 1 then return auras[unit] end + return nil + end + f.slash("debuff add 700") + f.slash("debuff add 701 focus 501") + assert(not c.BuffRadarDebuffWatch, "disabled debuffs built a frame") + f.slash("debuff on") + local strip = assert(c.BuffRadarDebuffWatch) + assert(strip:IsShown() and tonumber(strip.icons[1].stacks:GetText()) == 3 and not strip.icons[2], + "encounter rule was displayed outside its encounter or player stacks were wrong") + f.event("ENCOUNTER_START", 501) + assert(strip.icons[2].unit == "focus" and tonumber(strip.icons[2].stacks:GetText()) == 5, "scoped focus aura was not displayed") + c.__combat = true + f.event("PLAYER_REGEN_DISABLED") + local scans = c.__zoneCalls + auras.player.applications = 4 + f.event("UNIT_AURA", "player", { addedAuras = {} }) + f.advance(0.11, true) + assert(tonumber(strip.icons[1].stacks:GetText()) == 4 and c.__zoneCalls == scans, + "debuff updates depended on buff refreshes or scanned the combat queue") + auras.focus = { spellId = hidden, name = "Unreadable", applications = hidden } + f.event("PLAYER_FOCUS_CHANGED") + assert(not strip.icons[2]:IsShown(), "changed focus kept the previous aura or treated a secret ID as usable") + c.C_UnitAuras.GetDebuffDataByIndex = nil + c.UnitDebuff = function(unit, i) + reads = reads + 1 + if unit == "focus" and i == 1 then return "Legacy", 14001, 2, nil, nil, nil, nil, nil, nil, 701 end + return nil + end + f.event("PLAYER_FOCUS_CHANGED") + assert(strip.icons[2]:IsShown() and tonumber(strip.icons[2].stacks:GetText()) == 2, "legacy harmful-aura layout did not work") + f.event("ENCOUNTER_END", 501, "Boss", 1, 3, 1) + assert(not strip:IsShown(), "encounter ending did not clear the scoped icon") + c.__combat = false + f.event("PLAYER_REGEN_ENABLED") + f.slash("lite on") + assert(not strip.events.UNIT_AURA and not strip:IsShown() and #f.db.debuffRules == 2, "Lite mode dropped watch settings or kept a live listener") + local before = reads + f.event("UNIT_AURA", "focus"); f.advance(0.11) + assert(reads == before, "disabled watch still queried auras") + f.slash("lite off") + assert(strip.events.UNIT_AURA, "watch did not resume after leaving Lite mode") + f.slash("debuff remove 701 focus") + assert(#f.db.debuffRules == 1, "watch could not be removed") + end) + + step("Adaptive cadence follows movement, latency and combat recovery without delaying unit events", function() + local f = FeatureClient({ scanThrottle = true }, true) + local c, X = f.client, f.X + local speed, ping, samples = 0, 85, 0 + c.GetUnitSpeed = function() return speed end + c.GetNetStats = function() samples = samples + 1; return 0, 0, 21, ping end + local function group() return 30 end + f.advance(0.11) + assert(X.Intel.ScanTicks(group) == 3 and samples == 1, "stationary raid did not slow steady scans") + speed = 7 + f.event("PLAYER_STARTED_MOVING") + local before = c.__zoneCalls + f.advance(0.11) + assert(c.__zoneCalls == before + 1 and X.Intel.ScanTicks(group) == 1 and samples == 1, "moving event waited for periodic scan or resampled latency") + ping, speed = 300, 0 + f.advance(5.1) + assert(X.Intel.ScanTicks(group) == 4 and samples == 2, "high latency was not sampled or backed off") + before = c.__zoneCalls + f.event("UNIT_AURA", "player"); f.advance(0.11) + assert(c.__zoneCalls == before + 1, "aura event was delayed by adaptive backoff") + c.__combat = true + f.event("PLAYER_REGEN_DISABLED") + before = c.__zoneCalls + f.advance(0.41, true) + assert(c.__zoneCalls == before, "steady cast scan ran in combat") + c.__combat = false + f.event("PLAYER_REGEN_ENABLED"); f.advance(0.11) + assert(c.__zoneCalls == before + 1 and X.Intel.ScanTicks(group) == 1, "combat exit did not wake the scan or shorten cadence") + end) + + step("Personal readiness shows bag-only stones, durability, and the configured consumable aura", function() + if not forever then return end + local f = FeatureClient({}, false) + local c, X = f.client, f.X + local equipped, healthstone, unknown, auraState = 20, 1, {}, 171 + c.issecretvalue = function(v) return v == unknown end + c.C_Item.GetItemCount = function(id, bank, uses, reagents, account) + assert(bank == false and uses == false and reagents == false and account == false, "healthstone lookup included bank or uses") + return id == 19012 and healthstone or 0 + end + c.GetInventoryItemDurability = function(slot) + if slot == 1 then return equipped, 80 end + if slot == 17 then return unknown, 50 end + return nil, nil + end + c.GetWeaponEnchantInfo = function() return true, 15, 0, 1, false end + c.GetInventoryItemID = function(_, slot) return slot == 16 and 15 or nil end + f.O.AuraList = function(unit) if unit == "player" then return { + { spellId = auraState, name = "Ready Aura", expirationTime = 0 }, + } end end + c.GetSpellInfo = function(id) if id == 171 then return "Ready Aura" end end + X.GroupBuffReport = function() error("personal view scanned the group") end + f.slash("readiness aura 171") + f.slash("readiness") + local view = assert(c.BuffRadarRaidPreparation) + assert(view:IsVisible() and view.tab == "personal" and not view.players:IsShown(), "solo readiness required a roster") + assert(view.rows[3].heading:GetText():find("Ready Aura", 1, true) and view.rows[3].hint:GetText() == X.L["Present"], + "the configured consumable aura was not identified") + assert(view.rows[4].hint:GetText() == X.L["Present"] and view.rows[5].hint:GetText():find(X.L["Repair recommended"], 1, true) + and view.rows[5].hint:GetText():find(X.L["Some slots unknown"], 1, true), "healthstone or durability status was wrong") + equipped, healthstone = 0, unknown + f.event("BAG_UPDATE_DELAYED"); f.event("UPDATE_INVENTORY_DURABILITY"); f.advance(0.11) + assert(view.rows[4].hint:GetText() == X.L["Unknown"] and view.rows[5].hint:GetText():find("1 broken", 1, true), + "personal panel did not refresh or treated restricted bag data as zero") + auraState = unknown + f.event("UNIT_AURA", "player", { addedAuras = {}, removedAuraInstanceIDs = {} }); f.advance(0.11) + assert(view.rows[3].hint:GetText() == X.L["Unknown"], "restricted consumable was counted as absent or did not refresh") + f.slash("lite on") + assert(not view:IsShown() and not X.RaidPreparationSnapshot(true) and f.db.readinessAura == 171, + "Lite mode did not close readiness or erased a configured aura") + f.slash("lite off") + f.slash("prep personal") + assert(view:IsVisible(), "personal readiness did not resume") + end) + + step("Readiness settings expose feedback, reports, and validated watch controls without sending data", function() + local f = FeatureClient({}) + local c, X = f.client, f.X + local reads = 0 + c.GetAddOnMemoryUsage = function(addon) assert(addon == "BuffRadar"); return 420 end + c.UpdateAddOnMemoryUsage = function() reads = reads + 1 end + f.slash("stats memory") + local output = table.concat(f.messages, "\n") + assert(reads == 1 and output:find("420 KB", 1, true) and output:find(X.L["The game does not report memory by feature."], 1, true), + "memory report did not use addon-only data or implied per-feature estimates") + f.slash("config") + local cfg = assert(c.BuffRadarConfig) + cfg.tabBtns.readiness:Click() + local r = cfg.readiness + r.forecast:SetText("66") + r.forecast.scripts.OnEnterPressed(r.forecast) + assert(f.db.forecastSeconds == 66, "readiness tab did not save forecast lead") + r.memory:Click() + assert(reads == 2, "memory button did not share command behavior") + r.feedback:Click() + local export = assert(c.BuffRadarExportFrame) + assert(export:IsShown() and not export.accept:IsShown() + and export.editBox:GetText():find("issues/new?template=feature_request.md", 1, true), "feedback did not open a copy-only issue link") + f.slash("status export") + assert(export.editBox:GetText():find("BuffRadar/issues", 1, true) == nil, "status did not get its own export") + assert(#c.__sent == 0, "a read-only tool sent chat") + end) +end + step("German client uses the translation", function() if not env.__german then return end local found diff --git a/tools/wowstub.lua b/tools/wowstub.lua index 70928db..8f48217 100644 --- a/tools/wowstub.lua +++ b/tools/wowstub.lua @@ -108,6 +108,7 @@ function WOWSTUB(chat, withTimer, noTemplates, forever, german) function methods.SetBackdropBorderColor(self, r, g, b, a) self.borderColor = { r, g, b, a } end function methods.RegisterEvent(self, ev) self.events[ev] = true end function methods.UnregisterEvent(self, ev) self.events[ev] = nil end + function methods.RegisterUnitEvent(self, ev, ...) self.events[ev] = { ... } end -- DropdownButton (modern menu) API function methods.SetupMenu(self, gen) self.menuGen = gen end function methods.GenerateMenu(self)