From e8c96ae8a5dfaed9eb309c6dbdb74c0bf6034c72 Mon Sep 17 00:00:00 2001 From: SeanShaffer88 <252387677+SeanShaffer88@users.noreply.github.com> Date: Thu, 19 Nov 2026 05:55:48 +0000 Subject: [PATCH 1/2] Release LifeTimeStats 1.27.0 for Forever Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- Backup.lua | 145 ++++++++++++++++++++++------- CHANGELOG.md | 18 ++++ Core.lua | 29 +++++- LifeTimeStats.toc | 2 +- Options.lua | 42 +++++---- README.md | 8 +- Trackers.lua | 2 + UI.lua | 233 ++++++++++++++++++++++++++++++++-------------- Upkeep.lua | 34 +++++++ Widgets.lua | 92 ++++++++++++------ tests/history.py | 7 +- tests/run.py | 108 +++++++++++++++++++++ tests/sections.py | 16 ++++ 13 files changed, 575 insertions(+), 161 deletions(-) diff --git a/Backup.lua b/Backup.lua index 68ec788..182529d 100644 --- a/Backup.lua +++ b/Backup.lua @@ -44,12 +44,16 @@ local function SortedKeys(t) return keys end -local function CaptureLegacyBody(rec) +local function CaptureLegacyBody(rec, progress) local parts = {} + local function Emit(part) + parts[#parts + 1] = part + if progress and #parts % 512 == 0 then progress("Encoding statistics", #parts) end + end for _, sec in ipairs(FLAT) do local t = rec[sec] or {} for _, k in ipairs(SortedKeys(t)) do - if type(t[k]) ~= "table" then parts[#parts + 1] = sec .. "." .. Esc(k) .. "=" .. Val(t[k]) end + if type(t[k]) ~= "table" then Emit(sec .. "." .. Esc(k) .. "=" .. Val(t[k])) end end end for _, sec in ipairs(NESTED) do @@ -59,7 +63,7 @@ local function CaptureLegacyBody(rec) if type(inner) == "table" then for _, k in ipairs(SortedKeys(inner)) do if type(inner[k]) ~= "table" then - parts[#parts + 1] = sec .. "." .. Esc(g) .. "." .. Esc(k) .. "=" .. Val(inner[k]) + Emit(sec .. "." .. Esc(g) .. "." .. Esc(k) .. "=" .. Val(inner[k])) end end end @@ -176,10 +180,27 @@ function ns.ReadLegacyBackup(text, finished, status) end function ns.WriteLegacyBackup(rec, finished, status) - -- Capture without yielding so counters cannot change during collection. - local ok, body = pcall(CaptureLegacyBody, rec) - if not ok then finished(nil, body); return end - return RunBackupJob(body, EncodeLegacyBody, EncodeLegacyBody, finished, status) + local function CopyScalars(source) + local out = {} + for k, v in pairs(type(source) == "table" and source or {}) do + local kind = type(v) + if kind == "number" or kind == "string" or kind == "boolean" then out[k] = v end + end + return out + end + local captured = {} + for _, field in ipairs(FLAT) do captured[field] = CopyScalars(rec[field]) end + for _, field in ipairs(NESTED) do + local out = {} + for group, bucket in pairs(rec[field] or {}) do + if type(bucket) == "table" then out[group] = CopyScalars(bucket) end + end + captured[field] = out + end + local function Encode(input, progress) + return EncodeLegacyBody(CaptureLegacyBody(input, progress), progress) + end + return RunBackupJob(captured, Encode, Encode, finished, status) end local function MergeHistory(dst, src) @@ -791,7 +812,7 @@ function ns.IsFullBackup(text) return type(text) == "string" and not IsSecret(text) and text:match("^%s*LTS3|") ~= nil end -local function CaptureFullSnapshot() +local function FullSnapshotSource() Require(ns.ValidRecord(ns.char) and Key(ns.charKey), "The active character is unavailable.") local record = { meta = {} } for _, field in ipairs(FULL_FIELDS) do @@ -801,7 +822,11 @@ local function CaptureFullSnapshot() end end for field in pairs(FULL_META) do record.meta[field] = ns.char.meta[field] end - local snapshot = StageFullSnapshot({ character = ns.charKey, savedAt = time(), record = record }, true) + return { character = ns.charKey, savedAt = time(), record = record } +end + +local function ValidateExport(source, progress) + local snapshot = StageFullSnapshot(source, true, progress) snapshot.noteCount = nil -- Derived during preview, never trusted from a pasted backup. return snapshot end @@ -812,15 +837,37 @@ local function EncodeFullSnapshot(snapshot, progress) end function ns.SerializeFullBackup() - return Attempt(function() return EncodeFullSnapshot(CaptureFullSnapshot()) end) + return Attempt(function() return EncodeFullSnapshot(ValidateExport(FullSnapshotSource())) end) end function ns.WriteFullBackup(finished, status) - -- Validation makes a detached snapshot. Only encoding that copy may yield. - local snapshot, why = Attempt(CaptureFullSnapshot) - if not snapshot then finished(nil, why); return end - return RunBackupJob(snapshot, EncodeFullSnapshot, function(input) - return Attempt(function() return EncodeFullSnapshot(input) end) + -- Only copy mutable tables in the click handler. Validate and format the + -- detached values later, so events cannot change an export mid-job. + local captured, why = Attempt(function() + local count, active = 0, {} + local function Copy(value, depth) + Require(not IsSecret(value), "The full backup contains unreadable data.") + if type(value) ~= "table" then return value end + Require(PlainTable(value) and not active[value] and depth <= MAX_FULL_DEPTH, + "The full backup contains invalid data.") + active[value] = true + local out = {} + for key, item in pairs(value) do + count = count + 1 + Require(count <= MAX_FULL_NODES, "The full backup contains too many entries.") + out[key] = Copy(item, depth + 1) + end + active[value] = nil + return out + end + return Copy(FullSnapshotSource(), 1) + end) + if not captured then finished(nil, why); return end + local function Encode(input, progress) + return EncodeFullSnapshot(ValidateExport(input, progress), progress) + end + return RunBackupJob(captured, Encode, function(input) + return Attempt(function() return Encode(input) end) end, finished, status) end @@ -843,26 +890,24 @@ function ns.DeserializeFullBackup(text) return Attempt(function() return ReadFullSnapshot(text) end) end -function ns.ReadFullBackup(text, finished, status) - return RunBackupJob(text, ReadFullSnapshot, ns.DeserializeFullBackup, finished, status) -end - -function ns.RestoreFullBackup(snapshot) - local destination, character = ns.char, ns.charKey - local staged, reason = Attempt(function() - Require(ns.ValidRecord(destination) and Key(character) and type(ns.db) == "table" - and type(ns.db.chars) == "table" and type(LifeTimeStatsCharDB) == "table", "The active character is unavailable.") - Require(PlainTable(snapshot) and snapshot.character == character, "This full backup belongs to a different character.") - return StageFullSnapshot(snapshot).record - end) - if not staged then return false, reason end - - local uniqueCounts = {} - for set, values in pairs(staged.u) do +local function CountFullUniques(record, progress) + local uniqueCounts, total = {}, 0 + for set, values in pairs(record.u) do local count = 0 - for _ in pairs(values) do count = count + 1 end + for _ in pairs(values) do + count, total = count + 1, total + 1 + if progress and total % 512 == 0 then progress("Counting discoveries", total) end + end uniqueCounts[set] = count end + return uniqueCounts +end + +local function CommitFullBackup(destination, character, staged, uniqueCounts) + if not ns.ValidRecord(destination) or ns.char ~= destination or ns.charKey ~= character + or type(ns.db) ~= "table" or type(ns.db.chars) ~= "table" or type(LifeTimeStatsCharDB) ~= "table" then + return false, "The active character changed or is unavailable." + end local session = ns.session local liveID = session and ID(session.id) and session.id local serial = ID(destination.meta.sessionSerial) and destination.meta.sessionSerial or 0 @@ -896,6 +941,42 @@ function ns.RestoreFullBackup(snapshot) return true end +-- The preview holds a summary and a one-shot closure, not a mutable record. +-- The closure privately owns the validated record; confirmation therefore +-- need not copy or revalidate it. Session collision checks still use live data. +function ns.ReadFullBackup(text, finished, status) + local destination, character = ns.char, ns.charKey + local function Prepare(input, progress) + local snapshot = ReadFullSnapshot(input, progress) + local record = snapshot.record + local counts = CountFullUniques(record, progress) + return { + character = snapshot.character, savedAt = snapshot.savedAt, + noteCount = snapshot.noteCount, journalCount = #record.journal, sessionCount = #record.sessionlog, + apply = function() + if not record then return false, "This preview has already been used." end + local staged = record + record = nil + return CommitFullBackup(destination, character, staged, counts) + end, + } + end + return RunBackupJob(text, Prepare, function(input) + return Attempt(function() return Prepare(input) end) + end, finished, status) +end + +function ns.RestoreFullBackup(snapshot) + local destination, character = ns.char, ns.charKey + local staged, reason = Attempt(function() + Require(Key(character) and PlainTable(snapshot) and snapshot.character == character, + "This full backup belongs to a different character.") + return StageFullSnapshot(snapshot).record + end) + if not staged then return false, reason end + return CommitFullBackup(destination, character, staged, CountFullUniques(staged)) +end + -- Portable account preferences, deliberately separate from character backups. -- Do not include geometry, identity, notes, diagnostic flags or screenshot settings. local PREFS = { diff --git a/CHANGELOG.md b/CHANGELOG.md index 9681de6..9ec0569 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All notable changes to LifeTimeStats. Format: [Keep a Changelog](https://keepachangelog.com/), versions follow [SemVer](https://semver.org/). +## [1.27.0-forever] - 2026-11-19 + +Prerelease for WoW: Forever 1.60.1 (Interface 16001). Offline regression suites pass; live client testing is pending. + +### Added +- Portable account preference backups with a confirmation preview, separate from character history and window placement. +- Progress and cancellation for large backup reads and exports, and a preview before applying stats-only restores. +- Date-filtered history CSV exports, `/lts resetwindow`, and German translations for selected controls and backup progress messages. + +### Changed +- Window scale adapts to a smaller UI canvas without replacing the saved preference. +- Search, section tabs, Top Lists, and pooled table rows avoid repeated work when their data or presentation is unchanged. +- Full-character restore validates and counts discoveries before confirmation rather than repeating that work on apply. + +### Fixed +- More resilient save recovery, session continuity, malformed history handling, and legacy backup validation. +- Safer chat sharing and spreadsheet exports, and stricter release checks for TOC and media references. + ## [1.26.1-forever] - 2026-11-17 Prerelease. Offline regression suites pass; not yet checked in the live client. From in-game screenshots of 1.26.0. diff --git a/Core.lua b/Core.lua index b05e397..494221c 100644 --- a/Core.lua +++ b/Core.lua @@ -627,8 +627,24 @@ end local TALLY_CAP, DAY_KEEP = 400, 40 local tallySizes = setmetatable({}, { __mode = "k" }) +local tallyVersions = setmetatable({}, { __mode = "k" }) +local tallyMembership = setmetatable({}, { __mode = "k" }) +function ns.TallyVersion(bucket) + return bucket and tallyVersions[bucket] or 0 +end + +function ns.TallyMembershipVersion(bucket) + return bucket and tallyMembership[bucket] or 0 +end + +function ns.MarkTallyChanged(bucket, membershipChanged) + tallyVersions[bucket] = (tallyVersions[bucket] or 0) + 1 + if membershipChanged then tallyMembership[bucket] = (tallyMembership[bucket] or 0) + 1 end +end + local function AddTally(bucket, name, n) - if bucket[name] == nil then + local isNew = bucket[name] == nil + if isNew then local size = tallySizes[bucket] if not size then size = 0 @@ -641,7 +657,10 @@ local function AddTally(bucket, name, n) tallySizes[bucket] = size + 1 end local value = CounterValue(bucket[name]) + n - if not Bad(value) then bucket[name] = value end + if not Bad(value) and bucket[name] ~= value then + bucket[name] = value + ns.MarkTallyChanged(bucket, isNew) + end end function ns.Tally(tbl, name, n) @@ -777,11 +796,12 @@ end function ns.TrimTallyBuckets(rec) for _, bucket in pairs(rec.t) do if type(bucket) == "table" then - local count = 0 + local count, changed = 0, false for key, value in pairs(bucket) do - if Bad(value) then bucket[key] = nil else count = count + 1 end + if Bad(value) then bucket[key], changed = nil, true else count = count + 1 end end if count > TALLY_CAP then + changed = true local list = {} for key, value in pairs(bucket) do list[#list + 1] = { key, value } end table.sort(list, function(a, b) @@ -791,6 +811,7 @@ function ns.TrimTallyBuckets(rec) for i = TALLY_CAP + 1, count do bucket[list[i][1]] = nil end end tallySizes[bucket] = math.min(count, TALLY_CAP) + if changed then ns.MarkTallyChanged(bucket, true) end end end end diff --git a/LifeTimeStats.toc b/LifeTimeStats.toc index 1691497..0057c88 100644 --- a/LifeTimeStats.toc +++ b/LifeTimeStats.toc @@ -2,7 +2,7 @@ ## Title: |cffffb238LifeTime|r|cffefe6d2Stats|r ## Notes: Lifetime cumulative statistics for your character: steps, jumps, kills, deaths, gold, quests, dungeons and lots more. ## Author: Malikor -## Version: 1.26.1 +## Version: 1.27.0 ## IconTexture: Interface\AddOns\LifeTimeStats\Media\icon ## OptionalDeps: ElvUI, Tukui, EllesmereUI ## SavedVariables: LifeTimeStatsDB diff --git a/Options.lua b/Options.lua index dd3e950..3630c72 100644 --- a/Options.lua +++ b/Options.lua @@ -2,7 +2,7 @@ -- Copyright (C) 2026 Malikor. Licensed under GPL-3.0-or-later (see LICENSE). local _, ns = ... -local T = ns.THEME +local T, Lang = ns.THEME, ns.L local panel, category StaticPopupDialogs["LIFETIMESTATS_RESET_CHAR"] = { @@ -51,10 +51,10 @@ local function Toggle(parent, x, y, w, label, desc, get, set) r.hl = W.Fill(r, T.tileHi); r.hl:SetAllPoints(); r.hl:Hide() local box = W.Panel(r, T.bg, T.edge); box:SetSize(14, 14); box:SetPoint("TOPLEFT", 6, -4) local fill = W.Fill(box, T.amber, "ARTWORK"); fill:SetPoint("TOPLEFT", 3, -3); fill:SetPoint("BOTTOMRIGHT", -3, 3) - local l = W.Text(r, 12, T.text); l:SetPoint("TOPLEFT", 28, -4); l:SetText(label) + local l = W.Text(r, 12, T.text); l:SetPoint("TOPLEFT", 28, -4); l:SetText(Lang[label]) local d = W.Text(r, 10, T.dim); d:SetPoint("TOPLEFT", 28, -20); d:SetPoint("RIGHT", -4, 0); d:SetJustifyH("LEFT") d:SetJustifyV("TOP"); d:SetWordWrap(true); if d.SetMaxLines then d:SetMaxLines(2) end - d:SetText(desc) + d:SetText(Lang[desc]) function r:Sync() fill:SetShown(get() and true or false) end r:SetScript("OnClick", function(self) set(not get()); self:Sync() end) r:SetScript("OnEnter", function() r.hl:Show() end) @@ -66,9 +66,9 @@ end -- Label on the left, control on the right. local function RowLabel(parent, x, y, label, desc) - local l = W.Text(parent, 12, T.text); l:SetPoint("TOPLEFT", x + 6, -Y(y) - 4); l:SetText(label) + local l = W.Text(parent, 12, T.text); l:SetPoint("TOPLEFT", x + 6, -Y(y) - 4); l:SetText(Lang[label]) if desc then - local d = W.Text(parent, 10, T.dim); d:SetPoint("TOPLEFT", x + 6, -Y(y) - 20); d:SetText(desc) + local d = W.Text(parent, 10, T.dim); d:SetPoint("TOPLEFT", x + 6, -Y(y) - 20); d:SetText(Lang[desc]) return l, d end return l @@ -132,7 +132,7 @@ local function FlatSlider(parent, w, minV, maxV, stepV, get, set, fmt) end local function Button(parent, label, w, tip, fn, danger) - local b = W.FlatButton(parent, label, w, 24, label, tip) + local b = W.FlatButton(parent, Lang[label], w, 24, Lang[label], tip and Lang[tip]) if danger then b.text:SetTextColor(W.C.rust[1], W.C.rust[2], W.C.rust[3]); W.Color(b.edge, W.C.rust) end b:SetScript("OnClick", fn) return b @@ -201,7 +201,7 @@ function ns.CreateOptions() local function Track(r) rows[#rows + 1] = r return r end -- APPEARANCE (left) ----------------------------------------------- - local ap = W.Card(c, "Appearance", "dashboard", L, y0, colW, Y(296)) + local ap = W.Card(c, Lang["Appearance"], "dashboard", L, y0, colW, Y(296)) local b = ap.body RowLabel(b, 0, 0, "Theme", "Applies after /reload") local sw = Swatches(b); sw:SetPoint("TOPLEFT", 6, -Y(36) - 2) @@ -226,16 +226,17 @@ function ns.CreateOptions() Track(Toggle(b, 0, 56, ap.bw, "Class colour accent", "Use your class colour for numbers and charts. Applies after /reload.", function() return S.classColor end, function(v) S.classColor = v; reload:Show() end)) RowLabel(b, 0, 98, "Window size", "Fill screen shows more rows; applies after /reload") - local sizeSeg = W.Segmented(b, { - { id = "normal", label = "Normal", tip = "1140 x 740, scaled to fit your screen." }, - { id = "fill", label = "Fill screen", tip = "As large as your screen allows: taller tables and wider pages. Window scale still makes the text bigger or smaller." }, + local sizeSeg + sizeSeg = W.Segmented(b, { + { id = "normal", label = Lang["Normal"], tip = "1140 x 740, scaled to fit your screen." }, + { id = "fill", label = Lang["Fill screen"], tip = "As large as your screen allows: taller tables and wider pages. Window scale still makes the text bigger or smaller." }, }, function(id) ns.SetWindowSize(id); sizeSeg:Select(S.window.size or "normal") end) sizeSeg:SetPoint("TOPRIGHT", -2, -Y(98)) sizeSeg:Select(S.window.size or "normal") sizeSeg.Sync = function(self) self:Select(S.window.size or "normal") end Track(sizeSeg) RowLabel(b, 0, 132, "Window scale") - local sl = FlatSlider(b, 130, 0.6, 1.6, 0.05, function() return S.window.scale or 1 end, + local sl = FlatSlider(b, 130, 0.6, 1.5, 0.05, function() return S.window.scale or 1 end, function(v) S.window.scale = math.floor(v * 100 + 0.5) / 100; ns.ApplyWindowSettings() end, function(v) return string.format("%d%%", v * 100 + 0.5) end) sl:SetPoint("TOPRIGHT", -52, -Y(134)) Track(sl) @@ -245,7 +246,7 @@ function ns.CreateOptions() function() return not S.minimap.hide end, function(v) S.minimap.hide = not v; ns.UpdateMinimapButton() end)) -- SCREENSHOTS (left) ---------------------------------------------- - local ss = W.Card(c, "Screenshots", "star", L, y0 + Y(306), colW, Y(150)) + local ss = W.Card(c, Lang["Screenshots"], "star", L, y0 + Y(306), colW, Y(150)) b = ss.body Track(Toggle(b, 0, 0, ss.bw, "On level-up", "A moment after each new level.", function() return S.shotLevel end, function(v) S.shotLevel = v end)) @@ -255,7 +256,7 @@ function ns.CreateOptions() function() return S.shotAch end, function(v) S.shotAch = v end)) -- CHAT & DISPLAY (right) ------------------------------------------ - local cd = W.Card(c, "Chat and display", "social", R, y0, colW, Y(298)) + local cd = W.Card(c, Lang["Chat and display"], "social", R, y0, colW, Y(298)) b = cd.body Track(Toggle(b, 0, 0, cd.bw, "Session column", "Show how much each value grew this session.", function() return S.showSession end, function(v) S.showSession = v; ns.RefreshWindow() end)) @@ -270,11 +271,12 @@ function ns.CreateOptions() Track(Toggle(b, 0, 170, cd.bw, "Record new highs in the journal", "Add meaningful new records to your local adventure chronicle; no live chat spam.", function() return S.recordMoments end, function(v) S.recordMoments = v end)) RowLabel(b, 0, 205, "Achievement alerts", nil) - local alerts = W.Segmented(b, { - { id = "off", label = "Off", tip = "Only a 'new' count on the sidebar." }, - { id = "chat", label = "Chat", tip = "A chat line." }, - { id = "toast", label = "Toast", tip = "A small pop-up you can click to open the page." }, - { id = "both", label = "Both", tip = "Chat line and toast." }, + local alerts + alerts = W.Segmented(b, { + { id = "off", label = Lang["Off"], tip = "Only a 'new' count on the sidebar." }, + { id = "chat", label = Lang["Chat"], tip = "A chat line." }, + { id = "toast", label = Lang["Toast"], tip = "A small pop-up you can click to open the page." }, + { id = "both", label = Lang["Both"], tip = "Chat line and toast." }, }, function(id) S.achAnnounce = id; alerts:Select(id) end) alerts:SetPoint("TOPLEFT", 6, -Y(225)) alerts:Select(S.achAnnounce or "off") @@ -283,7 +285,7 @@ function ns.CreateOptions() -- TRACKING (right) ------------------------------------------------ -- below Chat and display (298 tall), so the alerts row is not covered - local tr = W.Card(c, "Tracking and title", "records", R, y0 + Y(308), colW, Y(114)) + local tr = W.Card(c, Lang["Tracking and title"], "records", R, y0 + Y(308), colW, Y(114)) b = tr.body Track(Toggle(b, 0, 0, tr.bw, "Count pet and guardian damage", "Include your pet's damage, kills and misses.", function() return S.countPet end, function(v) S.countPet = v end)) @@ -295,7 +297,7 @@ function ns.CreateOptions() Track(titleCyc) -- DATA (full width) ----------------------------------------------- - local da = W.Card(c, "Your data", "chest", 0, y0 + Y(466), CW, 160) + local da = W.Card(c, Lang["Your data"], "chest", 0, y0 + Y(466), CW, 160) b = da.body local info = W.Text(b, 12, T.text); info:SetPoint("TOPLEFT", 6, -2) local note = W.Text(b, 10, T.dim); note:SetPoint("TOPLEFT", 6, -24); note:SetPoint("RIGHT", -6, 0); note:SetJustifyH("LEFT"); note:SetWordWrap(true) diff --git a/README.md b/README.md index e239825..65b33c5 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ In-game captures from version 1.12.1 show the previous Odometer layout (Mage, le ## Download -Get the 1.26.1 prerelease archive, `LifeTimeStats-1.26.1-forever.zip`, from the [Releases](../../releases) page and unzip it into `World of Warcraft\_forever_\Interface\AddOns\`. +Get the 1.27.0 prerelease archive, `LifeTimeStats-1.27.0-forever.zip`, from the [Releases](../../releases) page and unzip it into `World of Warcraft\_forever_\Interface\AddOns\`. ## The window @@ -218,7 +218,7 @@ Edit it if you like, pick Say / Party / Raid / Guild / Instance, press Send. Not ## Install -1. Download `LifeTimeStats-1.26.1-forever.zip`. +1. Download `LifeTimeStats-1.27.0-forever.zip`. 2. Unzip into `World of Warcraft\_forever_\Interface\AddOns\` so the folder is `AddOns\LifeTimeStats`. 3. Enable **LifeTimeStats** on the AddOns screen. @@ -233,7 +233,7 @@ Open **Backup** or run `/lts export` and copy the text for safekeeping. Large backup pastes show checksum and entry-reading progress; full character backups also report character-data validation. Cancel or change the paste to stop pending reads without changing your stats. The merge preview still requires confirmation, and the final merge is applied in memory before WoW writes SavedVariables. -Large backup exports show progress while encoding full-character data and computing checksums. Closing the dialog or switching formats cancels pending work. The export captures the character state when requested; later tracking changes do not alter that backup. +Large backup exports show progress while validating full-character data, encoding statistics or full-character data, and computing checksums. The initial copy of mutable values remains synchronous so the backup reflects one consistent point in time. Closing the dialog or switching formats cancels pending work. The export captures the character state when requested; later tracking changes do not alter that backup. Choose **Account preferences** in the backup window to copy a separate preferences backup. It includes an allowlist of appearance and tracking options, not character data, window positions, or screenshot settings. Paste it into Restore to review the settings that would change, then confirm to apply them account-wide. Use `/reload` to apply appearance changes. @@ -291,7 +291,7 @@ If the WoW UI canvas shrinks, the main window temporarily scales down to make ro - The **Journal** records new personal bests as local adventure moments by default; turn this off under Settings → Chat and display. No new record is sent to another player. - Unique lists stop growing at 20,000 entries each; tally buckets track up to 400 distinct labels in normal play (existing labels continue counting; new labels may be omitted at the limit; aggregate counters are separate); daily history keeps 40 days, and older days are kept as monthly totals. - Nothing is ever sent anywhere unless you press Send in the Share dialog or type `/lts share` with a channel. No chat spam unless you turn on milestones. -- Loot, duel, roll, reputation and skill messages are read with the client's own text, so other languages should work (only English has been tested for live tracking). Selected backup controls and progress messages have a German translation; untranslated text falls back to English. +- Loot, duel, roll, reputation and skill messages are read with the client's own text, so other languages should work (only English has been tested for live tracking). Selected backup controls, progress messages, Options labels, and main view selectors have a German translation; untranslated text falls back to English. ## Files diff --git a/Trackers.lua b/Trackers.lua index 87a38b1..0d94ea9 100644 --- a/Trackers.lua +++ b/Trackers.lua @@ -185,6 +185,7 @@ function ns.FinalizeRun(run) if run.bosses < best then return end ch.t.instbosses = ch.t.instbosses or {} ch.t.instbosses[run.name] = run.bosses + ns.MarkTallyChanged(ch.t.instbosses, true) local key = "run:" .. run.name if run.bosses > best then ch.f[key] = nil end ns.Min(key, run.lastBoss - run.start, run.bosses .. (run.bosses == 1 and " boss" or " bosses")) @@ -550,6 +551,7 @@ local function LevelUp(level) Max("level_slow", dur, label) ns.char.t.leveltime = ns.char.t.leveltime or {} ns.char.t.leveltime["Level " .. label] = dur + ns.MarkTallyChanged(ns.char.t.leveltime, true) end m.levelMark, m.levelMarkLevel, m.levelMarkPartial = online, level, nil if ns.LevelSnapshot then ns.LevelSnapshot(level) end diff --git a/UI.lua b/UI.lua index 928b892..d38008e 100644 --- a/UI.lua +++ b/UI.lua @@ -171,6 +171,12 @@ end -- Section tabs for a page whose table has heading rows: one tab per section, the active one -- being the section at the top of the visible rows. Clicking scrolls the table there. +local updatingPage = false +local function RefreshTabsAfterScroll() + -- The window updates tabs after the page has finished rebuilding its rows. + if not updatingPage and ns.UpdateSectionTabs then ns.UpdateSectionTabs() end +end + local function TableSectionTabs(tbl, sections) local out = {} local top = (tbl.offset or 0) + 1 @@ -735,7 +741,7 @@ local function CategoryPage(id, kpis, panels, cols) ns.RefreshWindow() FocusRow(self, self.table, label) end - p.table.onScroll = function() if ns.UpdateSectionTabs then ns.UpdateSectionTabs() end end + p.table.onScroll = RefreshTabsAfterScroll return p end @@ -1001,40 +1007,76 @@ local function BuildLists() ns.RefreshWindow() end) function p:SectionTabs() return TableSectionTabs(self.nameT, self.sections) end - p.nameT.onScroll = function() if ns.UpdateSectionTabs then ns.UpdateSectionTabs() end end + p.nameT.onScroll = RefreshTabsAfterScroll local rc = Panel(p, "Top 100", "star", lw + GAP, 0, CW - lw - GAP, CH) p.title = rc.title p.rankT = W.Table(rc.body, rc.bw, rc.bh, { { "#", 36, kind = "dim" }, { "NAME", 240, kind = "text" }, { "", 170, kind = "bar" }, { "TOTAL", 120, kind = "num" }, { "SESSION", 0, kind = "dim" }, }) - function p:Update(view, base, sess) - local names, sections = {}, {} - for _, group in ipairs(ns.SectionedLists()) do - names[#names + 1] = { group.name, "", header = true } - sections[#sections + 1] = { name = group.name, index = #names } - for _, l in ipairs(group.lists) do - local n = 0 - if l.count then n = l.count(base) else for _ in pairs(base.t[l.id] or {}) do n = n + 1 end end - names[#names + 1] = { l.name, n, id = l.id, color = (l.id == self.selected) and T.amber or nil } + local groups, definitions = ns.SectionedLists(), {} + for _, def in ipairs(ns.LISTS) do definitions[def.id] = def end + local bucketCounts = setmetatable({}, { __mode = "k" }) + local displayedCounts, shownSelection = {}, nil + local function CountList(def, base, liveTick) + if def.count then return def.count(base) end + local bucket = base.t[def.id] + if not bucket then return 0 end + local revision = ns.TallyMembershipVersion(bucket) + local cached = bucketCounts[bucket] + if liveTick and cached and cached.revision == revision then return cached.count end + local count = 0 + for _ in pairs(bucket) do count = count + 1 end + bucketCounts[bucket] = { revision = revision, count = count } + return count + end + function p:Update(view, base, sess, liveTick) + local dirty = not liveTick or shownSelection ~= self.selected + for _, group in ipairs(groups) do + for _, def in ipairs(group.lists) do + local count = CountList(def, base, liveTick) + if count ~= displayedCounts[def.id] then + displayedCounts[def.id], dirty = count, true + end end end - self.sections = sections - self.nameT:SetData(names, true) - if self.revealSelected then + if dirty then + local names, sections = {}, {} + for _, group in ipairs(groups) do + names[#names + 1] = { group.name, "", header = true } + sections[#sections + 1] = { name = group.name, index = #names } + for _, def in ipairs(group.lists) do + names[#names + 1] = { def.name, displayedCounts[def.id], id = def.id, + color = def.id == self.selected and T.amber or nil } + end + end + self.sections = sections + self.nameT:SetData(names, true) + end + if rawget(self, "revealSelected") then self.revealSelected = nil - for i, d in ipairs(names) do if d.id == self.selected then self.nameT:Reveal(i) end end + for i, row in ipairs(self.nameT.data) do if row.id == self.selected then self.nameT:Reveal(i); break end end + end + local def = definitions[self.selected] + if shownSelection ~= self.selected then + self.title:SetText(def.name:upper()) + shownSelection = self.selected end - local def - for _, l in ipairs(ns.LISTS) do if l.id == self.selected then def = l end end - self.title:SetText(def.name:upper()) if def.rows then self.rankT:SetData(def.rows(base, sess), self.lastSel == self.selected) self.lastSel = self.selected return end + local bucket, sessionBucket = base.t[def.id], sess.t[def.id] + local version, sessionVersion = ns.TallyVersion(bucket), ns.TallyVersion(sessionBucket) + local rank = rawget(self, "rankSource") + if liveTick and rank and self.lastSel == self.selected and rank.bucket == bucket + and rank.version == version and rank.sessionBucket == sessionBucket and rank.sessionVersion == sessionVersion then + return + end local top = ns.TopList(base, def.id, 100) + self.rankSource = { bucket = bucket, version = version, sessionBucket = sessionBucket, sessionVersion = sessionVersion } local maxv = top[1] and top[1][2] or 0 - local st = sess.t[def.id] or {} + local st = sessionBucket or {} local f = ns.FMT[def.fmt] or Int local rows = {} for i, e in ipairs(top) do @@ -1181,35 +1223,58 @@ local function BuildSearch() if pg and pg.FocusStat and d.stat then pg:FocusStat(d.stat) end end end) - function p:Update(view, base, sess) - local q = (win.search:GetText() or ""):lower() - local rows = {} - local catName = {} - for _, cdef in ipairs(ns.CATEGORIES) do catName[cdef.id] = cdef.name end + -- Definitions are fixed after load. Keep only the current query's + -- metadata; values still come from the current view and session. + local catName = {} + for _, def in ipairs(ns.CATEGORIES) do catName[def.id] = def.name end + local function Matches(q) + local matches = {} for cat, list in pairs(ns.STATS) do for _, st in ipairs(list) do if st.label:lower():find(q, 1, true) then - local v, what = ns.StatValue(st, view) - local sv = ns.StatValue(st, sess) - local where = catName[cat] or cat + local name = catName[cat] or cat local sec = ns.StatSection and ns.StatSection(cat, st) - if sec then where = where .. " › " .. sec end - rows[#rows + 1] = { st.label, where, ns.FormatStat(st, v), (sv and sv > 0) and ("+" .. ns.FormatStat(st, sv)) or "", - tip = (st.tip or "") .. "\nClick to open " .. (catName[cat] or cat) .. ".", what = what, cat = cat, stat = st.label } + matches[#matches + 1] = { stat = st, cat = cat, label = st.label, + where = sec and (name .. " › " .. sec) or name, + tip = (st.tip or "") .. "\nClick to open " .. name .. "." } end end end for _, u in ipairs(ns.UNIQUES) do if u.label:lower():find(q, 1, true) then - rows[#rows + 1] = { "Unique: " .. u.label, catName.fastest, Int((base.un or {})[u.set] or 0), "", cat = "fastest" } + matches[#matches + 1] = { label = "Unique: " .. u.label, unique = u.set, cat = "fastest", where = catName.fastest } end end for _, f in ipairs(ns.FASTEST) do if f.label:lower():find(q, 1, true) then - local fv = (base.f or {})[f.key] - rows[#rows + 1] = { "Fastest: " .. f.label, catName.fastest, fv and Time(fv) or "—", "", cat = "fastest" } + matches[#matches + 1] = { label = "Fastest: " .. f.label, fastest = f.key, cat = "fastest", where = catName.fastest } end end + return matches + end + local lastQuery, matches, tallyMatches = nil, nil, {} + function p:ClearTallySearch() tallyMatches = {} end + function p:Update(view, base, sess, liveTick) + local q = (win.search:GetText() or ""):lower() + if lastQuery ~= q then lastQuery, matches, tallyMatches = q, Matches(q), {} + elseif not liveTick then tallyMatches = {} end + local rows = {} + for _, match in ipairs(matches) do + local v, sv, what + if match.stat then + v, what = ns.StatValue(match.stat, view) + sv = ns.StatValue(match.stat, sess) + v = ns.FormatStat(match.stat, v) + sv = sv and sv > 0 and ("+" .. ns.FormatStat(match.stat, sv)) or "" + elseif match.unique then + v = Int((base.un or {})[match.unique] or 0) + else + local fv = (base.f or {})[match.fastest] + v = fv and Time(fv) or "—" + end + rows[#rows + 1] = { match.label, match.where, v, sv or "", tip = match.tip, what = what, + cat = match.cat, stat = match.stat and match.label } + end -- entries inside the top lists (spells, creatures, zones, people...) if #q >= 2 then local found = 0 @@ -1217,16 +1282,32 @@ local function BuildSearch() if found >= 80 then break end local t = base.t and base.t[l.id] if t then + local revision = ns.TallyMembershipVersion(t) + local cached = tallyMatches[l.id] + if not cached or cached.bucket ~= t or cached.revision ~= revision then + local names = {} + for name in pairs(t) do + if tostring(name):lower():find(q, 1, true) then + names[#names + 1] = name + if #names >= 80 then break end + end + end + cached = { bucket = t, revision = revision, names = names } + tallyMatches[l.id] = cached + end local f = ns.FMT[l.fmt] or Int - for name, v in pairs(t) do + for _, name in ipairs(cached.names) do if found >= 80 then break end - if tostring(name):lower():find(q, 1, true) then + local v = t[name] + if v ~= nil then found = found + 1 local sv = sess.t and sess.t[l.id] and sess.t[l.id][name] rows[#rows + 1] = { tostring(name) .. " " .. ns.GREY .. "(" .. l.name .. ")|r", catName.lists or "Top Lists", f(v), sv and ("+" .. f(sv)) or "", tip = l.name .. "\nClick to open Top Lists.", cat = "lists", list = l.id } end end + else + tallyMatches[l.id] = nil end end end @@ -2101,6 +2182,8 @@ end function ns.UpdateNavBadge() if not win then return end local n = ns.AchNewCount and ns.AchNewCount() or 0 + if rawget(win, "badgeCount") == n then return end + win.badgeCount = n for _, b in ipairs(win.navButtons) do if b.id == "achievements" then b.badge:SetText(n > 0 and (n > 99 and "99" or tostring(n)) or "") @@ -2121,15 +2204,22 @@ local function RefreshWindow(liveTick) local view, base, sess if rawget(current, "characterOnly") then view, base, sess = ns.char, ns.char, ns.session else view, base, sess = Views() end + updatingPage = true local ok, err = pcall(current.Update, current, view, base, sess, liveTick) + updatingPage = false if not ok then ns.LogError("ui:" .. tostring(current.id), err) end ns.UpdateSectionTabs() elseif not liveTick then ns.UpdateSectionTabs() end - local since = ns.char.meta.created and date("%b %d, %Y", ns.char.meta.created) or "?" - win.footer:SetText(string.format("Counting since %s · %d statistics tracked · %d character%s", - since, ns.CountStats(), ns.CharCount(), ns.CharCount() == 1 and "" or "s")) + if not liveTick or rawget(win, "footerCreated") ~= ns.char.meta.created then + local created = ns.char.meta.created + local since = not ns.BadNumber(created) and date("%b %d, %Y", created) or "?" + local characters = ns.CharCount() + win.footer:SetText(string.format("Counting since %s · %d statistics tracked · %d character%s", + since, ns.CountStats(), characters, characters == 1 and "" or "s")) + win.footerCreated = created + end ns.UpdateNavBadge() if win.nameText and ns.TitledName then win.nameText:SetText(ns.TitledName()) end if win.today then @@ -2242,30 +2332,35 @@ function ns.UpdateSectionTabs() if not defs or #defs < 2 then bar:Hide(); return end local book = bar.book local J = W.JOURNAL + local paper, framed = book or ns.Paper(), ns.Framed() for i, b in ipairs(bar.tabs) do local d = defs[i] - b.def = d + local previous = rawget(b, "def") + b.def = d -- Click always uses the latest callback and row position. if d then - local text = book and W.SmallCaps(d.name) or d.name - b.text:SetText(text) - local col = d.active and T.amber or ((book or ns.Paper()) and T.text or T.dim) - b.text:SetTextColor(col[1], col[2], col[3]) - if book then - if d.active then W.Bold(b.text, T.amber) elseif b.text.SetShadowOffset then b.text:SetShadowOffset(0, 0) end - local c = d.active and J.page or J.tab - b.bg:SetVertexColor(c[1], c[2], c[3], 1) - b:SetPoint("TOPLEFT", d.active and 6 or 0, -(i - 1) * (SECTION_TAB_H + SECTION_GAP)) - else - -- opaque, so the tabs read cleanly over the game world - W.Color(b.bg, d.active and T.tileHi or T.tile, ns.Framed() and 0.97 or nil) - b.edge:SetShown(d.active) + local active = d.active and true or false + if not previous or previous.name ~= d.name then + b.text:SetText(book and W.SmallCaps(d.name) or d.name) end - b:Show() - else + if not previous or (previous.active and true or false) ~= active then + local col = active and T.amber or (paper and T.text or T.dim) + b.text:SetTextColor(col[1], col[2], col[3]) + if book then + if active then W.Bold(b.text, T.amber) elseif b.text.SetShadowOffset then b.text:SetShadowOffset(0, 0) end + local c = active and J.page or J.tab + b.bg:SetVertexColor(c[1], c[2], c[3], 1) + b:SetPoint("TOPLEFT", active and 6 or 0, -(i - 1) * (SECTION_TAB_H + SECTION_GAP)) + else + W.Color(b.bg, active and T.tileHi or T.tile, framed and 0.97 or nil) + b.edge:SetShown(active) + end + end + if not previous then b:Show() end + elseif previous then b:Hide() end end - bar:Show() + if not bar:IsShown() then bar:Show() end end local function CreateWindow() @@ -2373,16 +2468,16 @@ local function CreateWindow() gear:SetScript("OnClick", function() ns.OpenOptions() end) win.rangeSeg = W.Segmented(head, { - { id = "lifetime", label = "Lifetime", tip = "Everything since LifeTimeStats was installed." }, - { id = "session", label = "Session", tip = "Since you logged in (or reset the session)." }, - { id = "today", label = "Today", tip = "Since midnight, local time." }, - { id = "week", label = "Week", tip = "The last 7 days, today included. Records and lists show lifetime values." }, - { id = "month", label = "Month", tip = "The last 30 days, today included. Records and lists show lifetime values." }, + { id = "lifetime", label = ns.L["Lifetime"], tip = "Everything since LifeTimeStats was installed." }, + { id = "session", label = ns.L["Session"], tip = "Since you logged in (or reset the session)." }, + { id = "today", label = ns.L["Today"], tip = "Since midnight, local time." }, + { id = "week", label = ns.L["Week"], tip = "The last 7 days, today included. Records and lists show lifetime values." }, + { id = "month", label = ns.L["Month"], tip = "The last 30 days, today included. Records and lists show lifetime values." }, }, ns.SelectViewRange) win.rangeSeg:SetPoint("RIGHT", gear, "LEFT", -10, 0) win.scopeSeg = W.Segmented(head, { - { id = "char", label = "Character", tip = "Only this character." }, - { id = "account", label = "Account", tip = "Every character on this account that has logged in with LifeTimeStats. Hover a value to see each character's part." }, + { id = "char", label = ns.L["Character"], tip = "Only this character." }, + { id = "account", label = ns.L["Account"], tip = "Every character on this account that has logged in with LifeTimeStats. Hover a value to see each character's part." }, }, ns.SelectViewScope) win.scopeSeg:SetPoint("RIGHT", win.rangeSeg, "LEFT", -8, 0) win.headParts = { logo = logo, t1 = t1, t2 = t2, rule = rule, sb = sb, close = close, portrait = portrait, ring = ring, gear = gear } @@ -2545,6 +2640,8 @@ local function CreateWindow() end) win:SetScript("OnHide", function() ns.InvalidateAccount() + if pages.lists then pages.lists.rankSource = nil end + if pages.search then pages.search:ClearTallySearch() end if pinLayer then pinLayer:Hide() end if noteLayer then noteLayer:Hide() end end) @@ -2866,18 +2963,10 @@ local function ShowFullBackupPreview(input, snapshot) dlg.hint:SetText("This will replace this character’s statistics and saved history.") dlg.eb:ClearFocus() dlg.box:Hide() - local journal, sessions = snapshot.record.journal or {}, snapshot.record.sessionlog or {} - local noteCount = snapshot.noteCount - if not noteCount then - noteCount = 0 - for _, entry in ipairs(journal) do - if ns.JournalNote(entry) then noteCount = noteCount + 1 end - end - end local validDate, saved = pcall(date, "%b %d, %Y at %H:%M", snapshot.savedAt) dlg.summary.source:SetText("Source: " .. snapshot.character:gsub("|", "||") .. " · This character") dlg.summary.saved:SetText(validDate and type(saved) == "string" and "Backed up " .. saved or "Backup date unavailable") - dlg.summary.counts:SetText(string.format("%d Journal entries · %d personal notes · %d saved sessions", #journal, noteCount, #sessions)) + dlg.summary.counts:SetText(string.format("%d Journal entries · %d personal notes · %d saved sessions", snapshot.journalCount, snapshot.noteCount or 0, snapshot.sessionCount)) dlg.summary:Show() dlg.editPaste:Show() dlg.action.text:SetText(L["Replace history"]) @@ -2960,7 +3049,7 @@ local function ApplyBackup(parsed, readError, readingFinished) ShowFullBackupPreview(text, snapshot) return end - local ok, reason = ns.RestoreFullBackup(snapshot) + local ok, reason = snapshot.apply() if not ok then SetRestoreInput("|cffd9604aCould not restore full backup:|r " .. tostring(reason)) return diff --git a/Upkeep.lua b/Upkeep.lua index 65a9c9d..6c3c410 100644 --- a/Upkeep.lua +++ b/Upkeep.lua @@ -11,6 +11,40 @@ local On = ns.On ns.L = setmetatable({}, { __index = function(_, key) return key end }) local LOCALES = { deDE = { + ["Appearance"] = "Aussehen", + ["Screenshots"] = "Screenshots", + ["Chat and display"] = "Chat und Anzeige", + ["Tracking and title"] = "Erfassung und Titel", + ["Your data"] = "Deine Daten", + ["Theme"] = "Design", + ["Applies after /reload"] = "Wird nach /reload angewendet", + ["Window size"] = "Fenstergröße", + ["Window scale"] = "Fensterskalierung", + ["Normal"] = "Normal", + ["Fill screen"] = "Bildschirm füllen", + ["Lock window"] = "Fenster sperren", + ["Minimap button"] = "Minikartenknopf", + ["Achievement alerts"] = "Erfolgsmeldungen", + ["Class colour accent"] = "Klassenfarbe", + ["Off"] = "Aus", + ["Chat"] = "Chat", + ["Toast"] = "Hinweis", + ["Both"] = "Beides", + ["Open window"] = "Fenster öffnen", + ["Reset window"] = "Fenster zurücksetzen", + ["Reload now"] = "Neu laden", + ["Backup"] = "Backup", + ["Restore"] = "Wiederherstellen", + ["Title"] = "Titel", + ["Encoding statistics"] = "Statistik wird kodiert", + ["Counting discoveries"] = "Entdeckungen werden gezählt", + ["Character"] = "Charakter", + ["Account"] = "Konto", + ["Lifetime"] = "Gesamt", + ["Session"] = "Sitzung", + ["Today"] = "Heute", + ["Week"] = "Woche", + ["Month"] = "Monat", ["Review backup"] = "Backup prüfen", ["Cancel"] = "Abbrechen", ["Close"] = "Schließen", diff --git a/Widgets.lua b/Widgets.lua index b6bc953..92a4a68 100644 --- a/Widgets.lua +++ b/Widgets.lua @@ -390,8 +390,16 @@ function W.Odometer(parent, x, y, w, h, label, icon, tip, allowFormatted) if configuredIcon ~= ic then self.icon:SetTexture(W.MEDIA .. "icons\\" .. ic); configuredIcon = ic end self.tipTitle, self.tipBody = lbl, tp end + local lastValue, lastSub function f:SetValue(v, sub, exact) v = math.max(0, math.floor((v or 0) + 0.5)) + sub = sub or "" + if not formattedMode and lastValue == v then + if lastSub ~= sub then self.sub:SetText(sub); lastSub = sub end + self.exact = exact + return + end + lastValue, lastSub = v, sub if number then if formattedMode then number:SetFont(W.NUM, 23, "") end number:SetText(ns.FormatInt(v)) @@ -427,7 +435,8 @@ function W.Odometer(parent, x, y, w, h, label, icon, tip, allowFormatted) formatted:Show() end formattedMode = true - self.sub:SetText(sub or "") + sub = sub or "" + if lastSub ~= sub then self.sub:SetText(sub); lastSub = sub end self.exact = text end end @@ -821,45 +830,74 @@ function W.Table(body, bw, bh, cols, onClick, emptyText) local empty = W.Text(f, 11, T.dim); empty:SetPoint("TOP", 0, -HH - 12); empty:SetText(emptyText or "Nothing recorded yet") f.offset = 0 f.data = {} + local function SetText(widget, text) + if rawget(widget, "ltsTableText") ~= text then + widget.ltsTableText = text + widget:SetText(text) + end + end + local function SetShown(widget, shown) + if rawget(widget, "ltsTableShown") ~= shown then + widget.ltsTableShown = shown + widget:SetShown(shown) + end + end + local scrollCount, scrollOffset function f:Render() local n = #self.data self.offset = math.max(0, math.min(self.offset, n - visible)) for r = 1, visible do local row = self.rows[r] local d = self.data[r + self.offset] - row.data = d - local head = d and d.header - row.zebra:SetShown(not head and ((r + self.offset) % 2) == 0) - row.rule:SetShown(head and true or false) - row.heading:SetShown(head and true or false) - if head then row.heading:SetText((W.SmallCaps or string.upper)(d[1])) end + row.data = d -- Tooltips and click callbacks always see the newest row. + local head = d and d.header and true or false + SetShown(row.zebra, not head and ((r + self.offset) % 2) == 0) + SetShown(row.rule, head) + SetShown(row.heading, head) + if head then SetText(row.heading, (W.SmallCaps or string.upper)(d[1])) end for i, c in ipairs(cols) do local cell = row.cells[i] - if head then - if c.kind == "bar" then cell.track:Hide(); cell.bar:Hide() else cell:SetText("") end - elseif c.kind == "bar" then - local v = d and d[i] or nil - cell.track:SetShown(v ~= nil); cell.bar:SetShown(v ~= nil) - if v then cell.bar:SetWidth(math.max(1, cell.w * math.max(0, math.min(1, v)))) end + if c.kind == "bar" then + local v = not head and d and d[i] or nil + SetShown(cell.track, v ~= nil); SetShown(cell.bar, v ~= nil) + if v then + local width = math.max(1, cell.w * math.max(0, math.min(1, v))) + if cell.lastWidth ~= width then + cell.bar:SetWidth(width) + cell.lastWidth = width + end + end else - cell:SetText(d and d[i] ~= nil and tostring(d[i]) or "") - if book and cell.SetShadowOffset then - if d and d.head and i == 2 then W.Bold(cell, T.amber) elseif c.kind ~= "num" then cell:SetShadowOffset(0, 0) end + SetText(cell, not head and d and d[i] ~= nil and tostring(d[i]) or "") + if not head then + if book and cell.SetShadowOffset then + local bold = d and d.head and i == 2 and true or false + if rawget(cell, "ltsTableBold") ~= bold then + if bold then W.Bold(cell, T.amber) elseif c.kind ~= "num" then cell:SetShadowOffset(0, 0) end + cell.ltsTableBold = bold + end + end + if i == 1 then + local color = d and d.color or (c.kind == "num" and T.amber or (c.kind == "dim" and T.dim or T.text)) + if rawget(cell, "ltsRed") ~= color[1] or rawget(cell, "ltsGreen") ~= color[2] or rawget(cell, "ltsBlue") ~= color[3] then + cell:SetTextColor(color[1], color[2], color[3]) + cell.ltsRed, cell.ltsGreen, cell.ltsBlue = color[1], color[2], color[3] + end + end end - if d and d.color and i == 1 then cell:SetTextColor(d.color[1], d.color[2], d.color[3]) - elseif i == 1 and c.kind == "text" then cell:SetTextColor(T.text[1], T.text[2], T.text[3]) end end end end - empty:SetShown(n == 0) - if n > visible then - sb:Show(); thumb:Show() - local th = math.max(16, visible * RH * visible / n) - thumb:SetHeight(th) - thumb:ClearAllPoints() - thumb:SetPoint("TOPRIGHT", sb, "TOPRIGHT", 0, -(visible * RH - th) * (self.offset / (n - visible))) - else - sb:Hide(); thumb:Hide() + SetShown(empty, n == 0) + if scrollCount ~= n or scrollOffset ~= self.offset then + scrollCount, scrollOffset = n, self.offset + SetShown(sb, n > visible); SetShown(thumb, n > visible) + if n > visible then + local th = math.max(16, visible * RH * visible / n) + thumb:SetHeight(th) + thumb:ClearAllPoints() + thumb:SetPoint("TOPRIGHT", sb, "TOPRIGHT", 0, -(visible * RH - th) * (self.offset / (n - visible))) + end end if self.onScroll then pcall(self.onScroll, self) end end diff --git a/tests/history.py b/tests/history.py index 0b65870..d38ff22 100644 --- a/tests/history.py +++ b/tests/history.py @@ -180,9 +180,12 @@ eq(phases["Reading character backup"], true, "full decode reports progress") eq(phases["Validating character data"], true, "full validation reports progress") eq(dialog.previewSnapshot.character, ns.charKey, "full preview uses decoded snapshot") +eq(dialog.previewSnapshot.record, nil, "preview does not expose validated record") +local applyPreview = dialog.previewSnapshot.apply ch.c.jumps = jumps + 150 button.scripts.OnClick(button) eq(ch.c.jumps, jumps + 100, "confirmed full restore replaces stats") +eq(applyPreview(), false, "full preview is single use") queued = {} ns.ShowImport(full) dialog:Hide() @@ -191,11 +194,13 @@ eq(dialog.previewSnapshot, false, "canceled full read cannot publish a preview") queued = {} ns.ShowExport() -eq(#queued, 1, "large stats export schedules checksum batches") +eq(#queued, 1, "large stats export schedules encoding batches") +eq(dialog.hint:GetText():find("Encoding statistics", 1, true) ~= nil, true, "stats format work runs in slices") local statsBatch = queued[1] local fullButton = dialog.exportModes.buttons[2] fullButton.scripts.OnClick(fullButton) eq(#queued, 2, "switching format starts a full export") +eq(dialog.hint:GetText():find("Validating character data", 1, true) ~= nil, true, "full export validation runs in slices") statsBatch() eq(dialog.eb:GetText(), "", "superseded export cannot publish text") local capturedJumps = ch.c.jumps diff --git a/tests/run.py b/tests/run.py index f0f3095..14cfca4 100644 --- a/tests/run.py +++ b/tests/run.py @@ -457,6 +457,114 @@ for i, row in ipairs(rows) do eq(row[1], expected[i][1], "top list matches full sort") end end eq(#ns.TopList(rankView, "examples", 0), 0, "zero limit selects nothing") +-- Ranking work follows its specific data rather than unrelated clock ticks. +do + local previousScope = ns.settings.scope + ns.settings.scope = "char" + ns.OpenPage("lists") + local page, selected = ns.Page("lists"), nil + for _, def in ipairs(ns.LISTS) do if not def.rows then selected = def.id; break end end + page.selected = selected + ns.RefreshWindow() + local originalRank, calls = ns.TopList, 0 + local originalCatalog, catalogUpdates = page.nameT.SetData, 0 + page.nameT.SetData = function(...) catalogUpdates = catalogUpdates + 1; return originalCatalog(...) end + ns.TopList = function(...) calls = calls + 1; return originalRank(...) end + local window = LifeTimeStatsWindow + local function tick() window:GetScript("OnUpdate")(window, 1) end + tick() + eq(calls, 0, "unchanged ranking skips work") + eq(catalogUpdates, 0, "unchanged catalog skips redraw") + ns.Tally("audit_other_rank", "unrelated", 1) + tick() + eq(calls, 0, "different tally bucket does not dirty ranking") + ns.Tally(selected, "Audit tracked rank", 1) + tick() + eq(calls, 1, "changed tally invalidates rank") + tick() + eq(calls, 1, "ranking settles after refresh") + eq(catalogUpdates, 1, "adding a label refreshes catalog count once") + ns.Tally(selected, "Audit tracked rank", 1) + tick() + eq(catalogUpdates, 1, "changing only a tally value does not redraw the catalog") + page.nameT.SetData = originalCatalog + ns.TopList, ns.settings.scope = originalRank, previousScope + ns.char.t[selected]["Audit tracked rank"] = nil + ns.session.t[selected]["Audit tracked rank"] = nil +end + +-- Search keeps metadata for one query but reads current counter values. +do + local previousScope, previousRange = ns.settings.scope, ns.settings.range + ns.settings.scope, ns.settings.range = "char", "lifetime" + local originalSection, calls = ns.StatSection, 0 + ns.StatSection = function(...) calls = calls + 1; return originalSection(...) end + local window = LifeTimeStatsWindow + window.search:SetText("items looted") + ns.OpenPage("search") + eq(calls > 0, true, "search resolves sections for a new query") + local page = ns.Page("search") + local before = page.table.data[1][3] + calls = 0 + ns.Add("items_looted", 3) + window:GetScript("OnUpdate")(window, 1) + eq(calls, 0, "steady query reuses section metadata") + eq(page.table.data[1][3] ~= before, true, "cached query still shows live values") + window.search:SetText("dodge") + ns.ShowPage("search") + eq(calls > 0, true, "changed query rebuilds metadata") + ns.StatSection, ns.settings.scope, ns.settings.range = originalSection, previousScope, previousRange +end + +do + local previousScope = ns.settings.scope + ns.settings.scope = "char" + local list = ns.LISTS[1].id + local window = LifeTimeStatsWindow + window.search:SetText("fixture tally needle") + ns.Tally(list, "Fixture tally needle alpha", 1) + ns.OpenPage("search") + local page, bucket = ns.Page("search"), ns.char.t[list] + local membership = ns.TallyMembershipVersion(bucket) + local before = page.table.data[1][3] + ns.Tally(list, "Fixture tally needle alpha", 2) + eq(ns.TallyMembershipVersion(bucket), membership, "value change preserves search membership revision") + window:GetScript("OnUpdate")(window, 1) + eq(page.table.data[1][3] ~= before, true, "cached tally search shows current total") + ns.Tally(list, "Fixture tally needle beta", 1) + window:GetScript("OnUpdate")(window, 1) + eq(#page.table.data, 2, "new tally key invalidates search matches") + ns.settings.scope = previousScope + for _, row in ipairs({ ns.char.t[list], ns.session.t[list] }) do + row["Fixture tally needle alpha"], row["Fixture tally needle beta"] = nil, nil + ns.MarkTallyChanged(row, true) + end +end + +-- Shared table renderer suppresses unchanged drawing calls, not new row data. +do + local list = ns.W.Table(UIParent, 280, 108, { { "Name", 120, kind = "text" }, { "Bar", 0, kind = "bar" } }) + local row = list.rows[1] + local text, width, shown = 0, 0, 0 + row.cells[1].SetText = function(_, value) text = text + 1; row.testText = value end + row.cells[2].bar.SetWidth = function() width = width + 1 end + row.cells[2].bar.SetShown = function() shown = shown + 1 end + list:SetData({ { "Alpha", 0.5, tip = "Old tooltip" } }) + local nextData = { "Alpha", 0.5, tip = "Updated tooltip" } + list:SetData({ nextData }, true) + eq(text, 1, "identical table text not repainted") + eq(width, 1, "unchanged bar width not repainted") + eq(shown, 1, "unchanged bar visibility not repainted") + eq(row.data, nextData, "pooled row references current tooltip data") + list:SetData({ { "Section", header = true } }) + eq(row.testText, "", "section row clears pooled data text") + eq(shown, 2, "section row hides pooled bar") + list:SetData({ { "Beta", 0.75 } }) + eq(row.testText, "Beta", "reused row restores data text") + eq(width, 2, "changed bar geometry applied") + eq(shown, 3, "reused row restores bar visibility") +end + -- stress: 20k combat events + 2k zone ticks, and saved data size with heavy synthetic data local t0c = os.clock() for i = 1, 20000 do diff --git a/tests/sections.py b/tests/sections.py index 98efa37..93c894e 100644 --- a/tests/sections.py +++ b/tests/sections.py @@ -171,5 +171,21 @@ ns.ShowPage("combat") eq(rawget(cp, "focus"), nil, "the highlight clears when the page is opened normally") +local bar = LifeTimeStatsWindow.sectionBar +local first = bar.tabs[1] +local originalText, writes = first.text.SetText, 0 +first.text.SetText = function(self, value) writes = writes + 1; originalText(self, value) end +local originalTabs, tabUpdates = ns.UpdateSectionTabs, 0 +ns.UpdateSectionTabs = function(...) tabUpdates = tabUpdates + 1; return originalTabs(...) end +ns.RefreshWindow() +eq(tabUpdates, 1, "page rebuild updates section tabs once") +eq(writes, 0, "unchanged section label is not redrawn") +cp.table:ScrollTo(cp.sections[#cp.sections].index) +eq(tabUpdates, 2, "direct scrolling still refreshes section tabs") +local active = 1 +for i, section in ipairs(cp.sections) do if section.index <= cp.table.offset + 2 then active = i end end +eq(bar.tabs[active].def.active, true, "scroll updates active section after clamping") +first.text.SetText, ns.UpdateSectionTabs = originalText, originalTabs + print("SECTIONS PASS: " .. checks .. " assertions") ''') From 83f82f9ca95cc9130eaf99293e2407c272fb806f Mon Sep 17 00:00:00 2001 From: SeanShaffer88 <252387677+SeanShaffer88@users.noreply.github.com> Date: Thu, 19 Nov 2026 05:56:09 +0000 Subject: [PATCH 2/2] Publish prereleases through the release workflow Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com> --- .github/workflows/release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6406c8..e2af805 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -88,6 +88,10 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | + release_kind=(--latest) + if grep -q "^Prerelease\b" "$RUNNER_TEMP/lifetimestats-release/release-notes.md"; then + release_kind=(--prerelease) + fi gh release create "$GITHUB_REF_NAME" \ "$RUNNER_TEMP/lifetimestats-release/LifeTimeStats-${GITHUB_REF_NAME#v}.zip" \ "$RUNNER_TEMP/lifetimestats-release/LifeTimeStats-${GITHUB_REF_NAME#v}.zip.sha256" \ @@ -95,4 +99,4 @@ jobs: --title "LifeTimeStats $GITHUB_REF_NAME" \ --notes-file "$RUNNER_TEMP/lifetimestats-release/release-notes.md" \ --verify-tag \ - --latest + "${release_kind[@]}"