Repository navigation
Expand file tree
/
Copy pathThemes.lua
More file actions
201 lines (190 loc) · 13.9 KB
/
Copy pathThemes.lua
File metadata and controls
201 lines (190 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
-- LifeTimeStats - window themes. Match the look of popular UI replacements.
-- "Auto" follows supported UI replacements or uses Forever Journal. Themes are
-- applied when the window is first built (/reload to switch).
-- Copyright (C) 2026 Malikor. Licensed under GPL-3.0-or-later (see LICENSE).
local _, ns = ...
local function hex(h, a)
return { tonumber(h:sub(1, 2), 16) / 255, tonumber(h:sub(3, 4), 16) / 255, tonumber(h:sub(5, 6), 16) / 255, a or 1 }
end
local function Mix(c, d) return { math.min(1, c[1] + d), math.min(1, c[2] + d), math.min(1, c[3] + d), 1 } end
local ARIALN, FRIZ = "Fonts\\ARIALN.TTF", "Fonts\\FRIZQT__.TTF"
-- Each theme: palette, fonts and a short description for the settings button.
ns.THEMES = {
{ id = "ledger", name = "Lifetime Stats", desc = "A framed tome: dark wood and gold around clean parchment, a menu of pages down the left, highlights and recent activity on the overview.",
bg = hex("dccbaa"), tile = hex("eadcbd", 0.55), tileHi = hex("d2bf98"), edge = hex("6b5233", 0.75),
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 = "explorer", name = "Stats Explorer", desc = "The framed tome with a dark wooden menu, a lifetime score with its motto, a card for each part of your adventure and your pinned statistics along the bottom.",
bg = hex("dccbaa"), tile = hex("eadcbd", 0.55), tileHi = hex("d2bf98"), edge = hex("6b5233", 0.75),
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"),
cream2 = hex("7a6a4c"), rust = hex("a8432a"), teal = hex("4f7a5a"), font = FRIZ, num = FRIZ,
journal = { gold = hex("33281c"), trim = hex("33281c"), top = hex("dcc697"), base = hex("c9b083"), tab = hex("b99d6c"), page = hex("d6c095") } },
{ id = "forever", name = "Forever Journal", desc = "A bound adventurer's journal with gold trim, warm paper panels and WoW's own fonts.",
bg = hex("19130f", 0.98), tile = hex("251d16"), tileHi = hex("463324"), edge = hex("795b36"),
text = hex("f5e9d2"), dim = hex("c3ae89"), amber = hex("eac773"),
cream2 = hex("ddc49a"), rust = hex("e17a65"), teal = hex("88bca7"), font = STANDARD_TEXT_FONT or FRIZ, num = FRIZ },
{ id = "odometer", name = "Odometer", desc = "LifeTimeStats' own look: charcoal, cream text, amber digits.",
bg = hex("17191c", 0.97), tile = hex("24272b"), tileHi = hex("2e3237"), edge = hex("33363b"),
text = hex("efe6d2"), dim = hex("9b9486"), amber = hex("ffb238"),
cream2 = hex("c9bfa8"), rust = hex("d9604a"), teal = hex("6fb7a8") },
{ id = "blizzard", name = "Blizzard", desc = "Default game look: near-black panels, gold borders and headings, Friz Quadrata.",
bg = { 0.03, 0.03, 0.04, 0.95 }, tile = { 0.07, 0.07, 0.08, 0.95 }, tileHi = { 0.13, 0.12, 0.10, 1 }, edge = hex("6b5a32"),
text = { 1, 1, 1, 1 }, dim = { 0.70, 0.70, 0.70, 1 }, amber = hex("ffd100"),
cream2 = { 0.85, 0.85, 0.85, 1 }, rust = hex("e0402a"), teal = hex("40c0f0"), font = FRIZ, num = FRIZ },
{ id = "elvui", name = "ElvUI", desc = "Flat dark panels with black 1-pixel borders and the blue value colour. Uses ElvUI's own colours and font when ElvUI is loaded.",
bg = { 0.06, 0.06, 0.06, 0.92 }, tile = { 0.10, 0.10, 0.10, 1 }, tileHi = { 0.16, 0.16, 0.16, 1 }, edge = { 0, 0, 0, 1 },
text = { 1, 1, 1, 1 }, dim = { 0.62, 0.62, 0.62, 1 }, amber = { 0.09, 0.52, 0.82, 1 },
cream2 = { 0.80, 0.80, 0.80, 1 }, rust = { 0.78, 0.25, 0.25, 1 }, teal = { 0.25, 0.75, 0.45, 1 }, font = ARIALN, num = ARIALN, live = "ElvUI" },
{ id = "tukui", name = "Tukui", desc = "Tukui's classic look: dark grey panels, grey borders, white text. Uses Tukui's colours when it is loaded.",
bg = { 0.08, 0.08, 0.08, 0.92 }, tile = { 0.11, 0.11, 0.11, 1 }, tileHi = { 0.18, 0.18, 0.18, 1 }, edge = { 0.30, 0.30, 0.30, 1 },
text = { 1, 1, 1, 1 }, dim = { 0.60, 0.60, 0.60, 1 }, amber = { 0.85, 0.85, 0.85, 1 },
cream2 = { 0.70, 0.70, 0.70, 1 }, rust = { 0.75, 0.30, 0.30, 1 }, teal = { 0.30, 0.70, 0.50, 1 }, font = ARIALN, num = ARIALN, live = "Tukui" },
{ id = "ellesmere", name = "EllesmereUI", desc = "Warm near-black panels, faint white borders, soft-white text and EllesmereUI's accent (teal, bronze on Forever). Uses its live accent and font when loaded.",
bg = { 0.069, 0.058, 0.047, 0.96 }, tile = { 0.095, 0.082, 0.068, 1 }, tileHi = { 0.13, 0.115, 0.098, 1 }, edge = { 0.12, 0.108, 0.097, 1 },
text = { 1, 1, 1, 0.92 }, dim = { 0.53, 0.51, 0.49, 1 }, amber = { 220 / 255, 167 / 255, 127 / 255, 1 },
cream2 = { 0.78, 0.76, 0.73, 1 }, rust = { 0.86, 0.36, 0.31, 1 }, teal = { 12 / 255, 210 / 255, 157 / 255, 1 }, font = ARIALN, num = ARIALN, live = "EllesmereUI" },
}
ns.THEME_BY_ID = {}
for _, t in ipairs(ns.THEMES) do ns.THEME_BY_ID[t.id] = t end
local function Loaded(name)
local f = (C_AddOns and C_AddOns.IsAddOnLoaded) or IsAddOnLoaded
if not f then return false end
local ok, r = pcall(f, name)
return ok and r and true or false
end
local function Col(t) if type(t) == "table" then local r, g, b = t.r or t[1], t.g or t[2], t.b or t[3] if type(r) == "number" and type(g) == "number" and type(b) == "number" then return { r, g, b, 1 } end end end
-- Which UI addon is running (for "Auto").
function ns.DetectUI()
if Loaded("EllesmereUI") or type(_G.EllesmereUI) == "table" and _G.EllesmereUI.ELLESMERE_GREEN then return "ellesmere" end
if Loaded("ElvUI") then return "elvui" end
if Loaded("Tukui") then return "tukui" end
return "ledger"
end
-- Live colours / font from the UI addon itself, if loaded. Every read is guarded.
local LIVE = {
ElvUI = function(p)
local E = type(_G.ElvUI) == "table" and _G.ElvUI[1]
local m = type(E) == "table" and E.media
if type(m) ~= "table" then return end
local bd, bo, val = Col(m.backdropcolor), Col(m.bordercolor), Col(m.rgbvaluecolor)
if bd then p.tile = bd; p.tileHi = Mix(bd, 0.06); p.bg = { bd[1] * 0.6, bd[2] * 0.6, bd[3] * 0.6, 0.92 } end
if bo then p.edge = bo end
if val then p.amber = val end
if type(m.normFont) == "string" then p.font = m.normFont; p.num = m.normFont end
return true
end,
Tukui = function(p)
local T = type(_G.Tukui) == "table" and _G.Tukui[1]
local c = type(T) == "table" and T.Colors
if type(c) ~= "table" then return end
local bd, bo = Col(c.backdrop), Col(c.border)
if bd then p.tile = bd; p.tileHi = Mix(bd, 0.06); p.bg = { bd[1] * 0.75, bd[2] * 0.75, bd[3] * 0.75, 0.92 } end
if bo then p.edge = bo end
return true
end,
EllesmereUI = function(p)
local E = _G.EllesmereUI
if type(E) ~= "table" then return end
-- Official skinning API first (EllesmereUI.RegisterSkin hands us its getters).
local Sk = ns.euiSkin
if Sk and (not Sk.IsEnabled or Sk.IsEnabled()) then
local ok, r, g, b = pcall(Sk.GetAccentColor)
if ok and type(r) == "number" then p.amber = { r, g, b, 1 } end
local ok2, pr, pg, pb, pa = pcall(Sk.GetPanelColor)
if ok2 and type(pr) == "number" then
p.tile = { pr, pg, pb, 1 }; p.tileHi = Mix(p.tile, 0.04)
p.bg = { pr * 0.85, pg * 0.85, pb * 0.85, math.max(pa or 0.95, 0.92) }
end
local ok3, font = pcall(Sk.GetFont)
if ok3 and type(font) == "string" and font ~= "" then p.font = font; p.num = font end
if ok and type(r) == "number" then return true end
end
local r, g, b
if type(E.ResolveActiveAccent) == "function" then
local ok, a, bb, c = pcall(E.ResolveActiveAccent)
if ok and type(a) == "number" then r, g, b = a, bb, c end
end
if not r then local c = Col(E.ELLESMERE_GREEN) if c then r, g, b = c[1], c[2], c[3] end end
if r then p.amber = { r, g, b, 1 } end
if type(E.GetFontPath) == "function" then
local ok, f = pcall(E.GetFontPath)
if ok and type(f) == "string" and f ~= "" then p.font = f; p.num = f end
elseif type(E.EXPRESSWAY) == "string" then p.font = E.EXPRESSWAY; p.num = E.EXPRESSWAY end
return true
end,
}
local function Copy(dst, src) if src then dst[1], dst[2], dst[3], dst[4] = src[1], src[2], src[3], src[4] or 1 end end
-- Resolve the chosen theme into ns.THEME (in place, so every holder of these tables sees it).
function ns.ApplyTheme()
local want = (ns.settings and ns.settings.theme) or "auto"
local id = want == "auto" and ns.DetectUI() or want
local base = ns.THEME_BY_ID[id] or ns.THEME_BY_ID.notebook
id = base.id
local p = {}
for k, v in pairs(base) do p[k] = type(v) == "table" and { v[1], v[2], v[3], v[4] } or v end
p.liveUsed = base.live and LIVE[base.live] and (function() local ok, r = pcall(LIVE[base.live], p) return ok and r end)() or false
local T = ns.THEME
for _, k in ipairs({ "bg", "tile", "tileHi", "edge", "text", "dim", "amber" }) do Copy(T[k], p[k]) end
ns.themeId, ns.themeLive = id, p.liveUsed and true or false
local W = ns.W
if W and W.JOURNAL then
-- The journal-style skins share W.JOURNAL; the notebook swaps in its paper and ink.
W.JOURNAL_FOREVER = W.JOURNAL_FOREVER or (function()
local c = {}
for k, v in pairs(W.JOURNAL) do c[k] = { v[1], v[2], v[3] } end
return c
end)()
local src = base.journal or W.JOURNAL_FOREVER
for k, v in pairs(src) do
local dst = W.JOURNAL[k]
if dst then dst[1], dst[2], dst[3] = v[1], v[2], v[3] else W.JOURNAL[k] = { v[1], v[2], v[3] } end
end
end
if W then
W.FONT = p.font or STANDARD_TEXT_FONT or FRIZ
W.NUM = p.num or ARIALN
if W.C then Copy(W.C.cream2, p.cream2); Copy(W.C.rust, p.rust); Copy(W.C.teal, p.teal) end
end
local a = T.amber
ns.accent2 = { a[1] * 0.78, a[2] * 0.78, a[3] * 0.78, 1 }
ns.GOLD = string.format("|cff%02x%02x%02x", math.floor(a[1] * 255), math.floor(a[2] * 255), math.floor(a[3] * 255))
ns.GREEN = string.format("|cff%02x%02x%02x", math.floor(T.text[1] * 255), math.floor(T.text[2] * 255), math.floor(T.text[3] * 255))
ns.GREY = string.format("|cff%02x%02x%02x", math.floor(T.dim[1] * 255), math.floor(T.dim[2] * 255), math.floor(T.dim[3] * 255))
if ns.ApplyAccent then ns.ApplyAccent() end
end
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", "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.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
-- EllesmereUI skinning API: register once; the getters feed the EllesmereUI theme.
if type(_G.EllesmereUI) == "table" and type(_G.EllesmereUI.RegisterSkin) == "function" then
pcall(_G.EllesmereUI.RegisterSkin, "LifeTimeStats", function(Sk) ns.euiSkin = Sk end)
end