diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2afdad0..b6406c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -61,6 +61,8 @@ jobs: run: python tests/notebook.py - name: Verify the Lifetime Stats and Stats Explorer skins run: python tests/framed.py + - name: Verify the Stone & Gold and Adventure Journal skins + run: python tests/styled.py - name: Verify release packaging run: python tests/package_release.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d341fdd..d2015cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,23 @@ All notable changes to LifeTimeStats. Format: [Keep a Changelog](https://keepachangelog.com/), versions follow [SemVer](https://semver.org/). +## [Unreleased] + +### Added +- **Two more skins** (Settings > Appearance > Theme; a change applies after a reload). Both use LifeTimeStats' own artwork, drawn by `scripts/make_styled_textures.py`; neither is affiliated with the addon it is styled after. + - **Stone & Gold (in the style of Altoholic).** + - Dark stone inside steel rails with a gold bevel and gold corner plates. + - Your portrait in a gold ring on the top-left corner, and a gold title line with the version and author. + - A menu of the book's chapters with gold headers and their pages indented beneath; the open page gets a gold highlight bar. + - The chapters again as tabs along the bottom of the window. Each reopens the page you last read in it. + - **Adventure Journal (in the style of Dungeon Journal).** + - Dark brown leather in a darker frame with a thin gold line. + - "LifeTimeStats Journal" in gold in the middle of the top bar, with search on the left and the character and time-range dropdowns on the right. + - Gold-edged dark buttons for the pages, and journal-style cards with gold titles. + +### Changed +- "Falls & the elements" on the Deaths page is now "Falls & elements", so its tab is not cut off. + ## [1.25.2-forever] - 2026-11-17 Prerelease. Offline regression suites pass; not yet checked in the live client. Fixes come from in-game screenshots of 1.25.1. diff --git a/CREDITS.md b/CREDITS.md index 0a35951..e2815d5 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -10,5 +10,5 @@ - **Forever client API:** the captured API surface and live-client findings in Thunderz96/forever-addon-kit (MIT), used by `scripts/api_scan.py` during development; nothing from it is bundled. - **Forever addon restrictions:** findings shared by the authors of Field Guide (cjber/field-guide-forever issue #91) and the WoW Forever addon restriction notes on wowforevertierlist.com, which pointed to the combat log being secure-only. - **API references:** [warcraft.wiki.gg](https://warcraft.wiki.gg/), [Gethe/wow-ui-source](https://github.com/Gethe/wow-ui-source). -- **Artwork:** icon, logo, sidebar glyphs and dot texture drawn for this addon. The Lifetime Stats and Stats Explorer frame textures (parchment, wood, frame rails, gold corners, title plaque, compass emblem, crests, menu highlight, divider) are generated by `scripts/make_framed_textures.py`; their layout follows mock-ups supplied by the user, and no artwork from the mock-ups is used. The overview's milestone and highlight icons are the game's own icons. The Adventurer's Notebook textures (paper, wood, spiral ring, tab, tag, fold, seal) are generated by `scripts/make_notebook_textures.py` and its 19 ink sketches by `scripts/make_notebook_sketches.py`; the layout idea of a tabbed adventurer's notebook was suggested by the user from a printed D&D planner, but no artwork from it is used. Logo/icon text uses Inter (SIL Open Font License 1.1) and DejaVu Sans Mono (Bitstream Vera license). The in-game window uses the game's own fonts and the standard minimap border texture. +- **Artwork:** icon, logo, sidebar glyphs and dot texture drawn for this addon. The Lifetime Stats and Stats Explorer frame textures (parchment, wood, frame rails, gold corners, title plaque, compass emblem, crests, menu highlight, divider) are generated by `scripts/make_framed_textures.py`; their layout follows mock-ups supplied by the user, and no artwork from the mock-ups is used. The overview's milestone and highlight icons are the game's own icons. The Stone & Gold and Adventure Journal textures (stone, leather, rails, corner plates, portrait ring, highlight bar) are generated by `scripts/make_styled_textures.py`. Those skins are styled after the Altoholic and Dungeon Journal addons; no code or artwork from either is used. The Adventurer's Notebook textures (paper, wood, spiral ring, tab, tag, fold, seal) are generated by `scripts/make_notebook_textures.py` and its 19 ink sketches by `scripts/make_notebook_sketches.py`; the layout idea of a tabbed adventurer's notebook was suggested by the user from a printed D&D planner, but no artwork from it is used. Logo/icon text uses Inter (SIL Open Font License 1.1) and DejaVu Sans Mono (Bitstream Vera license). The in-game window uses the game's own fonts and the standard minimap border texture. - **License text:** GNU General Public License v3, Free Software Foundation. diff --git a/LifeTimeStats.toc b/LifeTimeStats.toc index d4e599d..eadd95d 100644 --- a/LifeTimeStats.toc +++ b/LifeTimeStats.toc @@ -39,6 +39,7 @@ Backup.lua Notebook.lua Framed.lua Overview.lua +Styled.lua UI.lua GuideUI.lua RosterUI.lua diff --git a/Media/styled/hbar.tga b/Media/styled/hbar.tga new file mode 100644 index 0000000..2e30577 Binary files /dev/null and b/Media/styled/hbar.tga differ diff --git a/Media/styled/jedge_h.tga b/Media/styled/jedge_h.tga new file mode 100644 index 0000000..ff007d0 Binary files /dev/null and b/Media/styled/jedge_h.tga differ diff --git a/Media/styled/jedge_v.tga b/Media/styled/jedge_v.tga new file mode 100644 index 0000000..5584c71 Binary files /dev/null and b/Media/styled/jedge_v.tga differ diff --git a/Media/styled/leather.tga b/Media/styled/leather.tga new file mode 100644 index 0000000..bf6514b Binary files /dev/null and b/Media/styled/leather.tga differ diff --git a/Media/styled/ring.tga b/Media/styled/ring.tga new file mode 100644 index 0000000..6755eb2 Binary files /dev/null and b/Media/styled/ring.tga differ diff --git a/Media/styled/rivet.tga b/Media/styled/rivet.tga new file mode 100644 index 0000000..d506c17 Binary files /dev/null and b/Media/styled/rivet.tga differ diff --git a/Media/styled/rock.tga b/Media/styled/rock.tga new file mode 100644 index 0000000..aab71c0 Binary files /dev/null and b/Media/styled/rock.tga differ diff --git a/Media/styled/sedge_h.tga b/Media/styled/sedge_h.tga new file mode 100644 index 0000000..81360f4 Binary files /dev/null and b/Media/styled/sedge_h.tga differ diff --git a/Media/styled/sedge_v.tga b/Media/styled/sedge_v.tga new file mode 100644 index 0000000..de0c9b7 Binary files /dev/null and b/Media/styled/sedge_v.tga differ diff --git a/README.md b/README.md index 887724d..8417d12 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,9 @@ Get the 1.25.2 prerelease archive, `LifeTimeStats-1.25.2-forever.zip`, from the - a card each for Combat, Exploration, Progression and Collections, which open their pages; - your pinned statistics along the bottom. -**Adventurer's Notebook** (the default from 1.21 to 1.24) turns the window into an adventurer's tome: a single hand-made sheet of aged parchment with torn edges and an inked frame. Six chapter tabs run down the side: **Hero** (Overview, Characters, Compare), **Deeds** (Travels, Battles, Deaths, Purse & Pack, Company), **Quests** (Adventures, Dungeon Tome, Life on the Road), **Legends** (Records, Feats & Firsts, Honours, Rolls of Note), **Chronicle** (Journal, Days) and **Lore** (How it works). The margin of each page lists that chapter's pages as tags, with Today below them. Each tab reopens the page you last read in it. Values are inked in your class colour. Every page has its own ink sketch in the margin (a compass on the Overview, a skull for Deaths, a backpack for Purse & Pack, crossed swords for Battles, and more). Earned achievements are stamped with a wax seal showing their tier, and a pinned Dashboard statistic is sealed once its goal is reached. The other skins (Stats Explorer, Adventurer's Notebook, Forever Journal, Odometer, Blizzard, ElvUI, Tukui, EllesmereUI) are in Settings; changing skin needs a /reload. +**Stone & Gold** is in the style of Altoholic: dark stone and steel with gold trim, a round portrait, chapters with gold headers in the menu and chapter tabs along the bottom. **Adventure Journal** is in the style of Dungeon Journal: dark brown leather in a darker frame with a thin gold line, a gold title and gold-edged buttons. Both are LifeTimeStats' own artwork and are not affiliated with those addons. + +**Adventurer's Notebook** (the default from 1.21 to 1.24) turns the window into an adventurer's tome: a single hand-made sheet of aged parchment with torn edges and an inked frame. Six chapter tabs run down the side: **Hero** (Overview, Characters, Compare), **Deeds** (Travels, Battles, Deaths, Purse & Pack, Company), **Quests** (Adventures, Dungeon Tome, Life on the Road), **Legends** (Records, Feats & Firsts, Honours, Rolls of Note), **Chronicle** (Journal, Days) and **Lore** (How it works). The margin of each page lists that chapter's pages as tags, with Today below them. Each tab reopens the page you last read in it. Values are inked in your class colour. Every page has its own ink sketch in the margin (a compass on the Overview, a skull for Deaths, a backpack for Purse & Pack, crossed swords for Battles, and more). Earned achievements are stamped with a wax seal showing their tier, and a pinned Dashboard statistic is sealed once its goal is reached. The other skins (Stats Explorer, Stone & Gold, Adventure Journal, Adventurer's Notebook, Forever Journal, Odometer, Blizzard, ElvUI, Tukui, EllesmereUI) are in Settings; changing skin needs a /reload. A Warcraft-style adventurer's journal (`/lts`) with gold trim, warm page panels, chapter accents and ledger counters. The accent colour can follow your **class colour**. diff --git a/Sections.lua b/Sections.lua index 51ddac2..67b6081 100644 --- a/Sections.lua +++ b/Sections.lua @@ -70,13 +70,13 @@ ns.STAT_SECTIONS = { }, }, deaths = { - order = { "Deaths", "Falls & the elements", "Recovering" }, + order = { "Deaths", "Falls & elements", "Recovering" }, default = "Deaths", rules = { { "Recovering", "key", "^ex_" }, { "Recovering", "key", "releases" }, { "Recovering", "key", "corpse" }, { "Recovering", "key", "^rez" }, { "Recovering", "key", "time_dead" }, { "Recovering", "label", "recover" }, { "Recovering", "label", "time alive" }, - { "Falls & the elements", "key", "^falls" }, { "Falls & the elements", "key", "^dmg_" }, + { "Falls & elements", "key", "^falls" }, { "Falls & elements", "key", "^dmg_" }, }, }, adventure = { diff --git a/Styled.lua b/Styled.lua new file mode 100644 index 0000000..daf648b --- /dev/null +++ b/Styled.lua @@ -0,0 +1,212 @@ +-- LifeTimeStats - two more skins with a frame of their own (LifeTimeStats' own artwork): +-- Stone & Gold (in the style of Altoholic): dark stone inside steel rails with a gold bevel, +-- a round portrait on the corner, a gold title line, a menu of chapters with gold headers +-- and the pages under them, and the chapters again as tabs along the bottom. +-- Adventure Journal (in the style of Dungeon Journal): dark brown leather in a darker frame +-- with a thin gold line, a gold title in the middle of the top bar and gold-edged buttons. +-- Pages are unchanged; the overview is the standard Dashboard. +-- Copyright (C) 2026 Malikor. Licensed under GPL-3.0-or-later (see LICENSE). +local _, ns = ... + +local HEAD_FILL = { 0.26, 0.20, 0.07, 0.95 } -- Stone & Gold chapter header +local BTN_FILL = { 0.16, 0.11, 0.07, 0.95 } -- Adventure Journal button +local BTN_ON = { 0.36, 0.25, 0.12, 1 } +local GOLD_EDGE = { 0.62, 0.48, 0.22, 1 } + +local function Tiled(f, path, size) + local t = f:CreateTexture(nil, "BACKGROUND", nil, -8) + t:SetAllPoints() + t:SetTexture(path, "REPEAT", "REPEAT") + if t.SetHorizTile then t:SetHorizTile(true); t:SetVertTile(true) end + return t +end + +-- ------------------------------------------------------------ the frame +function ns.BuildStyledSkin(win, side, head, dim) + local W, T = ns.W, ns.THEME + local M = W.MEDIA .. "styled\\" + local stone = ns.Stone() + local st = {} + win.styled = st + if win.SetBackdropColor then pcall(win.SetBackdropColor, win, 0, 0, 0, 0) end + if win.SetBackdropBorderColor then pcall(win.SetBackdropBorderColor, win, 0, 0, 0, 0) end + st.back = Tiled(win, M .. (stone and "rock" or "leather"), 256) + + -- rails and corners + local art = CreateFrame("Frame", nil, win) + art:SetAllPoints() + art:SetFrameLevel((win:GetFrameLevel() or 1) + 30) + st.art = art + local R = 20 + local h, v = stone and "sedge_h" or "jedge_h", stone and "sedge_v" or "jedge_v" + local function Rail(tex, coords) + local t = art:CreateTexture(nil, "BORDER") + t:SetTexture(M .. tex) + if coords then t:SetTexCoord(unpack(coords)) end + return t + end + st.top = Rail(h); st.top:SetPoint("BOTTOMLEFT", win, "TOPLEFT", 0, -3); st.top:SetPoint("BOTTOMRIGHT", win, "TOPRIGHT", 0, -3); st.top:SetHeight(R + 3) + st.bottom = Rail(h, { 0, 1, 1, 0 }); st.bottom:SetPoint("TOPLEFT", win, "BOTTOMLEFT", 0, 3); st.bottom:SetPoint("TOPRIGHT", win, "BOTTOMRIGHT", 0, 3); st.bottom:SetHeight(R + 3) + st.left = Rail(v); st.left:SetPoint("TOPRIGHT", win, "TOPLEFT", 3, 0); st.left:SetPoint("BOTTOMRIGHT", win, "BOTTOMLEFT", 3, 0); st.left:SetWidth(R + 3) + st.right = Rail(v, { 1, 0, 0, 1 }); st.right:SetPoint("TOPLEFT", win, "TOPRIGHT", -3, 0); st.right:SetPoint("BOTTOMLEFT", win, "BOTTOMRIGHT", -3, 0); st.right:SetWidth(R + 3) + st.corners = {} + for i, c in ipairs({ + { "TOPLEFT", -R + 2, R - 2, { 0, 1, 0, 1 } }, { "TOPRIGHT", R - 2, R - 2, { 1, 0, 0, 1 } }, + { "BOTTOMLEFT", -R + 2, -R + 2, { 0, 1, 1, 0 } }, { "BOTTOMRIGHT", R - 2, -R + 2, { 1, 0, 1, 0 } }, + }) do + local t = art:CreateTexture(nil, "ARTWORK") + t:SetTexture(M .. "rivet"); t:SetSize(40, 40); t:SetTexCoord(unpack(c[4])) + t:SetPoint(c[1], win, c[1], c[2], c[3]) + st.corners[i] = t + end + + -- header: a gold title line in the middle; the controls on either side + local hp = win.headParts or {} + for _, k in ipairs({ "logo", "t1", "t2", "rule", "portrait", "ring" }) do if hp[k] then hp[k]:Hide() end end + if win.nameText then win.nameText:Hide() end + if win.level then win.level:Hide() end + local bar = head:CreateTexture(nil, "BACKGROUND", nil, 1) + bar:SetPoint("TOPLEFT", 4, -4); bar:SetPoint("BOTTOMRIGHT", -4, 4) + bar:SetColorTexture(0, 0, 0, stone and 0.45 or 0.35) + st.title = W.Text(head, stone and 14 or 17, T.amber, W.FONT, "CENTER") + st.title:SetPoint("CENTER", 0, 0) + st.title:SetText(stone and ("LifeTimeStats |cffffffffv" .. tostring(ns.VERSION) .. "|r by |cff4fc4eeMalikor|r") or "LifeTimeStats Journal") + if st.title.SetShadowOffset then st.title:SetShadowOffset(1, -1); st.title:SetShadowColor(0, 0, 0, 1) end + + local S = ns.settings + win.scopeSeg:Hide(); win.rangeSeg:Hide() + local charDD = ns.FramedDropdown(head, 170, { + { id = "char", label = UnitName("player") or "This character", tip = "Only this character." }, + { id = "account", label = "All characters", tip = "Every character on this account that has logged in with LifeTimeStats." }, + }, function(id) S.scope = id; if ns.InvalidateAccount then ns.InvalidateAccount() end; ns.RefreshWindow() end, + { portrait = true, tip = { "Character", "Whose statistics to show." } }) + local rangeDD = ns.FramedDropdown(head, 136, { + { id = "lifetime", label = "All time" }, { id = "session", label = "This session" }, { id = "today", label = "Today" }, + { id = "week", label = "Last 7 days" }, { id = "month", label = "Last 30 days" }, + }, function(id) S.range = id; ns.RefreshWindow() end, { icon = "clock", tip = { "Time range", "Which stretch of time the pages show." } }) + rangeDD:SetPoint("RIGHT", hp.close, "LEFT", -10, 0) + charDD:SetPoint("RIGHT", rangeDD, "LEFT", -8, 0) + win.scopeSeg, win.rangeSeg = charDD, rangeDD + if hp.gear then hp.gear:ClearAllPoints(); hp.gear:SetPoint("RIGHT", charDD, "LEFT", -8, 0) end + local sb = hp.sb + if sb then + sb:ClearAllPoints() + sb:SetPoint("LEFT", head, "LEFT", stone and 64 or 12, 0) + sb:SetSize(200, 26) + end + + -- Stone & Gold: the portrait in a gold ring on the top-left corner + if stone then + local pf = CreateFrame("Frame", nil, art) + pf:SetSize(76, 76); pf:SetPoint("CENTER", win, "TOPLEFT", 14, -10) + pf:SetFrameLevel((art:GetFrameLevel() or 1) + 4) + st.portrait = pf:CreateTexture(nil, "ARTWORK") + st.portrait:SetSize(60, 60); st.portrait:SetPoint("CENTER") + if st.portrait.SetMask then pcall(st.portrait.SetMask, st.portrait, "Interface\\CharacterFrame\\TempPortraitAlphaMask") end + if SetPortraitTexture then pcall(SetPortraitTexture, st.portrait, "player") end + local ring = pf:CreateTexture(nil, "OVERLAY"); ring:SetAllPoints(); ring:SetTexture(M .. "ring") + st.ring = ring + end + + -- the menu + local navs = win.navButtons or {} + local byId = {} + for _, b in ipairs(navs) do + byId[b.id] = b + if b.kb then b.kb:Hide() end + b.bar:Hide() + b.bg:SetAlpha(0) + b.text:SetFont(W.FONT, 12, "") + end + if stone then + -- chapters with gold headers and their pages indented under them + local inset = side:CreateTexture(nil, "BACKGROUND", nil, -6) + inset:SetPoint("TOPLEFT", 6, -4); inset:SetPoint("BOTTOMRIGHT", -4, 4) + inset:SetColorTexture(0, 0, 0, 0.40) + st.headers = {} + local RH, y = 25, -8 + for _, tab in ipairs(ns.NOTEBOOK_TABS or {}) do + local hdr = CreateFrame("Button", nil, side) + hdr:SetSize(dim.SIDEBAR_W - 20, RH - 2); hdr:SetPoint("TOPLEFT", 10, y) + W.Box(hdr, HEAD_FILL, GOLD_EDGE) + hdr.text = W.Text(hdr, 12, T.amber); hdr.text:SetPoint("LEFT", 8, 0); hdr.text:SetText(tab.name) + hdr.tab = tab + hdr:SetScript("OnClick", function(self) ns.ShowPage(self.tab.pages[1]) end) + st.headers[#st.headers + 1] = hdr + y = y - RH + for _, pid in ipairs(tab.pages) do + local b = byId[pid] + if b then + b:ClearAllPoints() + b:SetPoint("TOPLEFT", 10, y); b:SetSize(dim.SIDEBAR_W - 20, RH - 2) + b.icon:Hide() + b.text:ClearAllPoints(); b.text:SetPoint("LEFT", 20, 0); b.text:SetWidth(dim.SIDEBAR_W - 48) + b.hbar = b:CreateTexture(nil, "BACKGROUND", nil, 2) + b.hbar:SetAllPoints(); b.hbar:SetTexture(M .. "hbar"); b.hbar:SetVertexColor(0.85, 0.65, 0.10, 0.85); b.hbar:Hide() + y = y - RH + end + end + end + if win.todayBox then win.todayBox:Hide() end -- the chapter list fills the column + else + for _, b in ipairs(navs) do + local fill = W.Box(b, BTN_FILL, GOLD_EDGE) + b.jfill = fill + b.text:SetTextColor(T.amber[1], T.amber[2], T.amber[3]) + end + end + + -- Stone & Gold: chapter tabs along the bottom + if stone then + st.tabs = {} + local x = 18 + for _, tab in ipairs(ns.NOTEBOOK_TABS or {}) do + local t = CreateFrame("Button", nil, art) + t:SetSize(108, 28) + t:SetPoint("TOPLEFT", win, "BOTTOMLEFT", x, -(R - 2)) + t.fill = W.Box(t, { 0.10, 0.09, 0.07, 0.96 }, GOLD_EDGE) + t.text = W.Text(t, 12, T.amber, nil, "CENTER"); t.text:SetPoint("CENTER", 0, 1); t.text:SetText(tab.name) + t.tab = tab + t:SetScript("OnClick", function(self) + local last = ns.settings and ns.settings.notebookPage and ns.settings.notebookPage[self.tab.id] + ns.ShowPage(last or self.tab.pages[1]) + end) + st.tabs[#st.tabs + 1] = t + x = x + 112 + end + if win.SetClampRectInsets then pcall(win.SetClampRectInsets, win, -40, -(24 + 118), 40, -50) end + end + return st +end + +-- Selected and unselected menu entries, and the chapter tabs (called from ShowPage). +function ns.StyleStyledNav(b, sel, pageId) + local T = ns.THEME + if ns.Stone() then + if b.hbar then b.hbar:SetShown(sel) end + local c = sel and { 1, 1, 1 } or { 0.86, 0.86, 0.86 } + b.text:SetTextColor(c[1], c[2], c[3]) + elseif b.jfill then + ns.W.Color(b.jfill, sel and BTN_ON or BTN_FILL) + local c = sel and { 1, 0.90, 0.55 } or T.amber + b.text:SetTextColor(c[1], c[2], c[3]) + b.icon:SetVertexColor(c[1], c[2], c[3]) + end +end + +function ns.UpdateStyledTabs(pageId) + local win = _G.LifeTimeStatsWindow + local st = win and rawget(win, "styled") + if not st or not st.tabs then return end + local tab = ns.NotebookTabFor and ns.NotebookTabFor(pageId) + for _, t in ipairs(st.tabs) do + local on = tab and t.tab.id == tab.id + ns.W.Color(t.fill, on and { 0.32, 0.25, 0.08, 1 } or { 0.10, 0.09, 0.07, 0.96 }) + local c = on and { 1, 1, 1 } or { 1, 0.82, 0 } + t.text:SetTextColor(c[1], c[2], c[3]) + end + if tab and ns.settings then + ns.settings.notebookPage = ns.settings.notebookPage or {} + ns.settings.notebookPage[tab.id] = pageId + end +end diff --git a/Themes.lua b/Themes.lua index 1da8d25..e955596 100644 --- a/Themes.lua +++ b/Themes.lua @@ -23,6 +23,14 @@ ns.THEMES = { text = hex("24190f"), dim = hex("4c3c29"), amber = hex("2c5a48"), cream2 = hex("7a6a4c"), rust = hex("9c3a24"), teal = hex("3d7563"), font = FRIZ, num = FRIZ, journal = { gold = hex("33281c"), trim = hex("6b5233"), top = hex("e8dab9"), base = hex("dccbaa"), tab = hex("cdb88f"), page = hex("e4d5b3") } }, + { id = "stone", name = "Stone & Gold (Altoholic style)", desc = "Dark stone and steel with gold trim, a round portrait, gold category headers in the menu and chapter tabs along the bottom, in the style of the Altoholic addon. LifeTimeStats' own artwork; not affiliated with Altoholic.", + bg = { 0.09, 0.09, 0.10, 0.97 }, tile = { 0.05, 0.05, 0.06, 0.72 }, tileHi = { 0.30, 0.24, 0.08, 1 }, edge = { 0.50, 0.42, 0.22, 0.9 }, + text = { 0.96, 0.96, 0.96, 1 }, dim = { 0.74, 0.74, 0.74, 1 }, amber = { 1, 0.82, 0, 1 }, + cream2 = { 0.82, 0.82, 0.82, 1 }, rust = { 0.85, 0.27, 0.20, 1 }, teal = { 0.30, 0.78, 0.92, 1 }, font = FRIZ, num = FRIZ }, + { id = "djournal", name = "Adventure Journal (Dungeon Journal style)", desc = "Dark brown leather in a darker frame with a thin gold line, gold titles and gold-edged buttons, in the style of the Dungeon Journal addon. LifeTimeStats' own artwork; not affiliated with Dungeon Journal.", + bg = hex("1a120c", 0.97), tile = hex("2a1d13", 0.92), tileHi = hex("4a3420"), edge = hex("8a6a36"), + text = hex("f2e6cc"), dim = hex("c4b08a"), amber = hex("f0c75e"), + cream2 = hex("d8c49a"), rust = hex("d9654c"), teal = hex("7fb8a4"), font = FRIZ, num = FRIZ }, { id = "notebook", name = "Adventurer's Notebook", desc = "An adventurer's notebook: parchment pages, ink, a spiral binding and tabs down the side. Made for roleplayers and RPG fans.", bg = hex("d6c095"), tile = hex("e2cfa3", 0.30), tileHi = hex("cdb487"), edge = hex("33281c", 0.85), text = hex("1f150c"), dim = hex("3e3020"), amber = hex("6e2610"), @@ -171,15 +179,18 @@ function ns.ThemeName(id) if id == "auto" then return "Auto (" .. (ns.THEME_BY_ID[ns.DetectUI()] or {}).name .. ")" end return (ns.THEME_BY_ID[id] or ns.THEME_BY_ID.notebook).name end -ns.THEME_ORDER = { "auto", "ledger", "explorer", "notebook", "forever", "odometer", "blizzard", "elvui", "tukui", "ellesmere" } +ns.THEME_ORDER = { "auto", "ledger", "explorer", "stone", "djournal", "notebook", "forever", "odometer", "blizzard", "elvui", "tukui", "ellesmere" } -- Skins drawn as a journal (mixed-case titles, inked numbers, banner shading): Forever Journal -- and the Adventurer's Notebook. ns.Notebook() is the notebook alone (its own window frame). -function ns.JournalSkin() return ns.themeId == "forever" or ns.Paper() end +function ns.JournalSkin() return ns.themeId == "forever" or ns.themeId == "djournal" or ns.Paper() end function ns.Notebook() return ns.themeId == "notebook" end -- The two framed tomes (Lifetime Stats and Stats Explorer) share a window frame. function ns.Framed() return ns.themeId == "ledger" or ns.themeId == "explorer" end function ns.Ledger() return ns.themeId == "ledger" end +-- The two styled skins (Stone & Gold, Adventure Journal) share a frame of their own (Styled.lua). +function ns.Styled() return ns.themeId == "stone" or ns.themeId == "djournal" end +function ns.Stone() return ns.themeId == "stone" end function ns.Explorer() return ns.themeId == "explorer" end -- Parchment skins: dark ink on paper, so text sizes, ink and tooltips follow the paper rules. function ns.Paper() return ns.themeId == "notebook" or ns.themeId == "ledger" or ns.themeId == "explorer" end diff --git a/UI.lua b/UI.lua index 71749b8..51b50bf 100644 --- a/UI.lua +++ b/UI.lua @@ -39,8 +39,8 @@ end local function ComputeLayout() local s = ns.settings and ns.settings.window or {} -- the framed skins put their title on a plaque over the top rail, so the header row sits lower - HEADER_H = (ns.Framed and ns.Framed()) and 62 or 44 - local book = (ns.Notebook and ns.Notebook()) or (ns.Framed and ns.Framed()) + HEADER_H = (ns.Framed and ns.Framed()) and 62 or ((ns.Styled and ns.Styled()) and 48 or 44) + local book = (ns.Notebook and ns.Notebook()) or (ns.Framed and ns.Framed()) or (ns.Styled and ns.Styled()) WIN_W, WIN_H = ns.WindowSizeFor(s.size, UIParent:GetWidth(), UIParent:GetHeight(), s.scale or 1, book) Derive() end @@ -2078,7 +2078,9 @@ function ns.ShowPage(id) b.text:SetTextColor(col[1], col[2], col[3]) b.icon:SetVertexColor(sel and T.amber[1] or T.dim[1], sel and T.amber[2] or T.dim[2], sel and T.amber[3] or T.dim[3]) if ns.Framed() and ns.StyleFramedNav then ns.StyleFramedNav(b, sel) end + if ns.Styled() and ns.StyleStyledNav then ns.StyleStyledNav(b, sel, id) end end + if ns.Styled() and ns.UpdateStyledTabs then ns.UpdateStyledTabs(id) end ns.RefreshWindow() end @@ -2131,7 +2133,7 @@ local function BuildSectionBar() local book = ns.Notebook() local bar = CreateFrame("Frame", nil, win) bar:SetSize(SECTION_TAB_W, SECTION_TABS * (SECTION_TAB_H + SECTION_GAP)) - local outside = book and 34 or (ns.Framed() and 30 or 2) -- past the parchment or the wooden frame + local outside = book and 34 or (ns.Framed() and 30 or (ns.Styled() and 24 or 2)) -- past the parchment or the frame bar:SetPoint("TOPLEFT", win, "TOPRIGHT", outside, -(HEADER_H + PAD)) bar:SetFrameLevel((win:GetFrameLevel() or 1) + 1) bar.tabs = {} @@ -2387,6 +2389,7 @@ local function CreateWindow() if ns.Notebook() and ns.BuildNotebookFrame then ns.BuildNotebookFrame(win, side, { HEADER_H = HEADER_H, FOOTER_H = FOOTER_H, SIDEBAR_W = SIDEBAR_W, PAD = PAD, CW = CW, CH = CH }) end if ns.Framed() and ns.BuildFramedSkin then ns.BuildFramedSkin(win, side, head, { HEADER_H = HEADER_H, FOOTER_H = FOOTER_H, SIDEBAR_W = SIDEBAR_W, PAD = PAD, CW = CW, CH = CH }) end + if ns.Styled() and ns.BuildStyledSkin then ns.BuildStyledSkin(win, side, head, { HEADER_H = HEADER_H, FOOTER_H = FOOTER_H, SIDEBAR_W = SIDEBAR_W, PAD = PAD, CW = CW, CH = CH }) end -- section tabs down the right side --------------------------------- BuildSectionBar() diff --git a/scripts/make_styled_textures.py b/scripts/make_styled_textures.py new file mode 100644 index 0000000..7dda4a8 --- /dev/null +++ b/scripts/make_styled_textures.py @@ -0,0 +1,117 @@ +"""Draw the textures of two more skins (original artwork, LifeTimeStats' own): + Stone & Gold - in the style of Altoholic: dark stone, steel rails with a gold bevel, a round + portrait ring, a gold highlight bar for the selected entry. + Adventure Journal - in the style of Dungeon Journal: dark brown leather inside a darker frame with + a thin gold line. + +Run: python scripts/make_styled_textures.py (needs Pillow) +Writes Media/styled/*.tga, all power-of-two 32-bit TGA: + rock 256x256 tileable dark stone + leather 256x256 tileable dark brown leather + sedge_h 512x32 steel rail with a gold inner bevel (top; flipped for the bottom) + sedge_v 32x512 the same, upright + jedge_h 512x32 dark brown rail with a thin gold line + jedge_v 32x512 the same, upright + rivet 64x64 gold corner plate with a rivet + ring 128x128 gold ring around the portrait + hbar 256x32 highlight bar fading to the right (white, tinted) +""" +import random +from pathlib import Path + +from PIL import Image, ImageDraw, ImageFilter + +OUT = Path(__file__).resolve().parent.parent / "Media" / "styled" +OUT.mkdir(parents=True, exist_ok=True) +random.seed(1616) +GOLD = (206, 166, 74, 255) +GOLD_D = (120, 90, 34, 255) +GOLD_L = (246, 220, 140, 255) + + +def save(img, name): + img.save(OUT / (name + ".tga")) + print("wrote", name, img.size) + + +def tile_noise(size, cells, blur): + small = Image.new("L", (cells, cells)) + small.putdata([random.randint(0, 255) for _ in range(cells * cells)]) + big = Image.new("L", (cells * 3, cells * 3)) + for x in range(3): + for y in range(3): + big.paste(small, (x * cells, y * cells)) + big = big.resize((size * 3, size * 3), Image.BICUBIC).filter(ImageFilter.GaussianBlur(blur)) + return big.crop((size, size, size * 2, size * 2)) + + +def tinted(noises, base, weights, spread=1.0): + out = Image.new("RGBA", noises[0].size) + o = out.load() + px = [n.load() for n in noises] + w, h = out.size + for y in range(h): + for x in range(w): + k = sum((p[x, y] - 128) * wt for p, wt in zip(px, weights)) + o[x, y] = tuple(max(0, min(255, int(c + k * spread))) for c in base) + (255,) + return out + + +# ---------------------------------------------------------------- stone and leather +save(tinted([tile_noise(256, 10, 6), tile_noise(256, 40, 1.5), tile_noise(256, 120, 0.6)], (40, 40, 42), (0.16, 0.10, 0.06)), "rock") +save(tinted([tile_noise(256, 8, 8), tile_noise(256, 60, 1.0), tile_noise(256, 160, 0.5)], (38, 26, 17), (0.10, 0.05, 0.05)), "leather") + + +def rail(w, h, horizontal, base, line, bevel): + n = tile_noise(max(w, h), 30, 1.2).resize((w, h)) + out = tinted([n], base, (0.12,)) + d = ImageDraw.Draw(out) + across = h if horizontal else w + for i in range(across): + t = i / (across - 1) + shade = int(-40 + 60 * (1 - abs(t - 0.45) * 1.6)) if bevel else int(-30 + 40 * t) + for j in range(w if horizontal else h): + xy = (j, i) if horizontal else (i, j) + r, g, b, a = out.getpixel(xy) + out.putpixel(xy, (max(0, min(255, r + shade)), max(0, min(255, g + shade)), max(0, min(255, b + shade)), a)) + if horizontal: + d.line([(0, h - 5), (w, h - 5)], fill=GOLD_D, width=3) + d.line([(0, h - 5), (w, h - 5)], fill=line, width=1) + d.line([(0, 1), (w, 1)], fill=(10, 10, 10, 255), width=2) + else: + d.line([(w - 5, 0), (w - 5, h)], fill=GOLD_D, width=3) + d.line([(w - 5, 0), (w - 5, h)], fill=line, width=1) + d.line([(1, 0), (1, h)], fill=(10, 10, 10, 255), width=2) + return out + + +save(rail(512, 32, True, (72, 74, 80), GOLD, True), "sedge_h") +save(rail(32, 512, False, (72, 74, 80), GOLD, True), "sedge_v") +save(rail(512, 32, True, (52, 34, 22), GOLD_L, False), "jedge_h") +save(rail(32, 512, False, (52, 34, 22), GOLD_L, False), "jedge_v") + +# ---------------------------------------------------------------- gold corner plate with a rivet +big = Image.new("RGBA", (256, 256), (0, 0, 0, 0)) +d = ImageDraw.Draw(big) +d.polygon([(0, 0), (190, 0), (190, 60), (60, 60), (60, 190), (0, 190)], fill=GOLD_D) +d.polygon([(10, 10), (176, 10), (176, 48), (48, 48), (48, 176), (10, 176)], fill=GOLD) +d.ellipse((14, 14, 46, 46), fill=GOLD_L, outline=GOLD_D, width=6) +save(big.resize((64, 64), Image.LANCZOS), "rivet") + +# ---------------------------------------------------------------- portrait ring +big = Image.new("RGBA", (512, 512), (0, 0, 0, 0)) +d = ImageDraw.Draw(big) +d.ellipse((12, 12, 500, 500), outline=GOLD_D, width=44) +d.ellipse((22, 22, 490, 490), outline=GOLD, width=24) +d.ellipse((40, 40, 472, 472), outline=GOLD_L, width=6) +save(big.resize((128, 128), Image.LANCZOS), "ring") + +# ---------------------------------------------------------------- highlight bar +img = Image.new("RGBA", (256, 32), (0, 0, 0, 0)) +p = img.load() +for x in range(256): + a = int(255 * (1 - x / 255) ** 0.8) + for y in range(32): + edge = min(y, 31 - y) + p[x, y] = (255, 255, 255, int(a * min(1, 0.35 + edge / 10))) +save(img, "hbar") diff --git a/tests/styled.py b/tests/styled.py new file mode 100644 index 0000000..bb36d96 --- /dev/null +++ b/tests/styled.py @@ -0,0 +1,89 @@ +"""Offline tests for the Stone & Gold (Altoholic style) and Adventure Journal (Dungeon Journal style) skins.""" + +from pathlib import Path + +from lupa import lua51 +from PIL import Image + +ROOT = Path(__file__).resolve().parent.parent + +for name in ("rock", "leather", "sedge_h", "sedge_v", "jedge_h", "jedge_v", "rivet", "ring", "hbar"): + path = ROOT / "Media" / "styled" / (name + ".tga") + assert path.exists(), path + im = Image.open(path) + w, h = im.size + assert w & (w - 1) == 0 and h & (h - 1) == 0, (name, im.size) + assert im.mode == "RGBA", (name, im.mode) +print("textures ok") + + +def run(theme, body): + lua = lua51.LuaRuntime(unpack_returned_tuples=True) + lua.execute((ROOT / "tests/harness.lua").read_text(encoding="utf-8")) + lua.execute("ns = {}") + for name in (ROOT / "LifeTimeStats.toc").read_text(encoding="utf-8").splitlines(): + name = name.strip() + if name.endswith(".lua"): + chunk = lua.eval("function(src, name) return assert(loadstring(src, name)) end")( + (ROOT / name).read_text(encoding="utf-8"), name + ) + chunk("LifeTimeStats", lua.globals().ns) + return lua.execute(r''' +local checks = 0 +local function eq(got, expected, msg) + checks = checks + 1 + if got ~= expected then error(msg .. ": got " .. tostring(got) .. ", expected " .. tostring(expected), 2) end +end +local function fire(event, ...) local f = ns.frame; f.scripts.OnEvent(f, event, ...) end +fire("ADDON_LOADED", "LifeTimeStats") +fire("PLAYER_LOGIN") +fire("PLAYER_ENTERING_WORLD", true, false) +ns.settings.theme = "''' + theme + r'''" +ns.ToggleWindow() +local win = LifeTimeStatsWindow +local st = rawget(win, "styled") +eq(ns.themeId, "''' + theme + r'''", "theme applied") +eq(ns.Styled(), true, "a styled skin") +eq(ns.Paper(), false, "dark, not paper") +eq(st ~= nil, true, "frame built") +eq(#st.corners, 4, "four corner plates") +eq(win.scopeSeg.text:GetText(), "Malikor", "character dropdown") +win.rangeSeg.rows[4].scripts.OnClick(win.rangeSeg.rows[4]) +eq(ns.settings.range, "week", "range dropdown picks") +win.rangeSeg.rows[1].scripts.OnClick(win.rangeSeg.rows[1]) +''' + body + r''' +for _, c in ipairs(ns.CATEGORIES) do ns.ShowPage(c.id) end +eq(#ns.errors, 0, "no handler errors: " .. table.concat(ns.errors, " | ")) +return checks +''') + + +print("stone:", run("stone", r''' +eq(st.title:GetText():find("LifeTimeStats", 1, true) ~= nil, true, "title line") +eq(st.portrait ~= nil and st.ring ~= nil, true, "portrait in a gold ring") +eq(#st.headers, #ns.NOTEBOOK_TABS, "a gold header per chapter") +eq(#st.tabs, #ns.NOTEBOOK_TABS, "chapter tabs along the bottom") +eq(win.todayBox:IsShown(), false, "the chapter list fills the column") +-- a chapter tab opens its chapter; the selected page gets the gold bar +st.tabs[2].scripts.OnClick(st.tabs[2]) +eq(ns.activePage, ns.NOTEBOOK_TABS[2].pages[1], "chapter tab opens its first page") +local b +for _, n in ipairs(win.navButtons) do if n.id == ns.activePage then b = n end end +eq(b.hbar:IsShown(), true, "selected page highlighted") +st.headers[4].scripts.OnClick(st.headers[4]) +eq(ns.activePage, ns.NOTEBOOK_TABS[4].pages[1], "chapter header opens its first page") +ns.ShowPage("combat") +st.tabs[1].scripts.OnClick(st.tabs[1]) +ns.ShowPage("deaths") +st.tabs[2].scripts.OnClick(st.tabs[2]) +eq(ns.activePage, "deaths", "a chapter tab reopens the page last read in it") +''')) + +print("djournal:", run("djournal", r''' +eq(st.title:GetText(), "LifeTimeStats Journal", "journal title") +eq(st.tabs, nil, "no bottom tabs") +eq(ns.JournalSkin(), true, "journal-style cards") +local b = win.navButtons[1] +eq(rawget(b, "jfill") ~= nil, true, "gold-edged buttons") +''')) +print("STYLED PASS")