-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme.lua
More file actions
152 lines (136 loc) · 5.54 KB
/
Copy paththeme.lua
File metadata and controls
152 lines (136 loc) · 5.54 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
-- pfQuest Reforged -- shared visual system
-- One place for the flat dark look: panel chrome, fonts, accent colors and the
-- progress-bar factory used by the tracker. Pure presentation helpers -- no
-- game logic, no saved variables beyond reading pfQuest_config font size.
-- 3.3.5a-safe API surface only: SetBackdrop, CreateTexture, SetTexture(r,g,b,a).
pfQuestTheme = {
-- pfQuest's signature teal, used as the single accent
accent = { 0.2, 1.0, 0.8 },
-- panel body / border (flat dark, GW2-style)
bg = { 0.07, 0.07, 0.09 },
border = { 0, 0, 0 },
-- progress ramp (red -> yellow -> green handled by callers via GetColor)
dim = { 0.55, 0.55, 0.55 },
}
local T = pfQuestTheme
-- When GW2 UI (WotLK Reforged) is installed, adopt its look instead of the
-- standalone teal: GW2's warm parchment-gold accent and its darker, more
-- opaque panel body, so every pfQuest window (tracker, browser, journal,
-- config, welcome) reads as part of the GW2 UI rather than a foreign teal
-- box. Standalone (no GW2) keeps the teal identity. Detection is a plain
-- addon-loaded check -- no dependency, no coupling to GW2 internals.
if IsAddOnLoaded and (IsAddOnLoaded("GW2_UI") or IsAddOnLoaded("GW2-UI")) then
T.accent = { 1.0, 0.93, 0.73 } -- GW2 parchment gold
T.bg = { 0.04, 0.04, 0.045 }
T.gw2 = true
T.panelAlpha = 0.92 -- GW2 panels are near-opaque
end
T.panelAlpha = T.panelAlpha or 0.85
-- 1px flat border + dark body. `alpha` is the BODY alpha (border stays solid).
function T.SkinPanel(frame, alpha)
frame:SetBackdrop({
bgFile = "Interface\\BUTTONS\\WHITE8X8",
edgeFile = "Interface\\BUTTONS\\WHITE8X8",
edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 },
})
frame:SetBackdropColor(T.bg[1], T.bg[2], T.bg[3], alpha or T.panelAlpha)
frame:SetBackdropBorderColor(T.border[1], T.border[2], T.border[3], 0.9)
end
-- Accent-tinted header strip texture for a panel's top bar.
function T.HeaderStrip(frame, height)
local strip = frame:CreateTexture(nil, "BORDER")
strip:SetTexture(T.bg[1] * 1.6, T.bg[2] * 1.6, T.bg[3] * 1.6, 0.9)
strip:SetPoint("TOPLEFT", 1, -1)
strip:SetPoint("TOPRIGHT", -1, -1)
strip:SetHeight(height - 2)
local line = frame:CreateTexture(nil, "BORDER")
line:SetTexture(T.accent[1], T.accent[2], T.accent[3], 0.35)
line:SetPoint("TOPLEFT", 1, -(height - 1))
line:SetPoint("TOPRIGHT", -1, -(height - 1))
line:SetHeight(1)
return strip
end
-- Thin progress bar: dark track + colored fill. The caller drives it with
-- bar.SetProgress(pct01, r, g, b); width follows the parent automatically.
function T.CreateProgressBar(parent, height)
local bar = { height = height or 3, enabled = true }
bar.track = parent:CreateTexture(nil, "BORDER")
bar.track:SetTexture(1, 1, 1, 0.10)
bar.track:SetHeight(bar.height)
bar.fill = parent:CreateTexture(nil, "ARTWORK")
bar.fill:SetTexture(T.accent[1], T.accent[2], T.accent[3], 0.9)
bar.fill:SetHeight(bar.height)
bar.fill:SetPoint("LEFT", bar.track, "LEFT", 0, 0)
bar.fill:SetWidth(0.01)
function bar.SetPoint(_, a, b, c, d, e)
bar.track:SetPoint(a, b, c, d, e)
end
-- The fill is sized in absolute pixels from the track's width, but the track is
-- anchored LEFT+RIGHT to its parent -- so GetWidth() only reports a real number once
-- the layout has resolved. SetProgress runs during the tracker refresh, BEFORE the
-- tracker sets its own width, so the read came back unresolved and the old
-- "if width <= 0 then width = 1" fallback drew a 1px sliver: a quest at 100% showed a
-- stub of green (QA screenshot). Remember what was asked for and re-apply it from
-- bar:Refresh() once the width is known -- deterministic, no polling.
function bar.Apply(_)
local pct = bar.pct
if bar.enabled == false or pct == nil then
bar.track:Hide()
bar.fill:Hide()
return
end
bar.track:Show()
local width = bar.track:GetWidth()
if pct <= 0.001 or not width or width <= 0 then
bar.fill:Hide()
else
bar.fill:Show()
bar.fill:SetWidth(width * pct)
end
if bar.r then
bar.fill:SetTexture(bar.r, bar.g, bar.b, 0.9)
end
end
-- On/off for the whole bar (the "Quest Tracker Progress Bars" option). A flag rather
-- than a Show/Hide pair: this table is NOT a frame -- it owns two textures and exposes
-- only what is defined here -- and visibility is decided entirely inside Apply, so a
-- bare Show would be contradicted by the very next SetProgress anyway.
function bar.SetEnabled(_, on)
bar.enabled = on and true or false
bar:Apply()
end
-- Called by the tracker after it has sized itself, so the fill matches the final width.
function bar.Refresh(_)
bar:Apply()
end
function bar.SetProgress(_, pct, r, g, b)
if pct ~= nil then
pct = pct < 0 and 0 or pct > 1 and 1 or pct
end
bar.pct = pct
if r then bar.r, bar.g, bar.b = r, g, b end
bar:Apply()
end
function bar.Hide(_)
bar.track:Hide()
bar.fill:Hide()
end
return bar
end
-- Uniform hover behavior for icon buttons: dim by default, accent on hover.
function T.HoverIcon(button)
if not button.icon then return end
button.icon:SetVertexColor(0.75, 0.75, 0.75)
local enter, leave = button:GetScript("OnEnter"), button:GetScript("OnLeave")
button:SetScript("OnEnter", function()
this.icon:SetVertexColor(T.accent[1], T.accent[2], T.accent[3])
if enter then enter() end
end)
button:SetScript("OnLeave", function()
if not this.gwActive then
this.icon:SetVertexColor(0.75, 0.75, 0.75)
end
if leave then leave() end
end)
end