-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathThemes.lua
265 lines (224 loc) · 8.34 KB
/
Themes.lua
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
local addonName, addon = ...
local fmt = string.format
local themes = {}
addon.themes = themes
themes['RXP Blue'] = {
background = {12 / 255, 12 / 255, 27 / 255, 1},
bottomFrameBG = {18 / 255, 18 / 255, 40 / 255, 1},
bottomFrameHighlight = {54 / 255, 62 / 255, 109 / 255, 1},
mapPins = {206 / 210, 123 / 210, 1, 1},
tooltip = "|cFFCE7BFF", -- AARRGGBB
texturePath = "Interface/AddOns/" .. addonName .. "/Textures/",
font = _G.GameFontNormal:GetFont(),
textColor = {1, 1, 1},
applicable = function() return not RXPCData.GA end,
author = "RestedXP",
bgTextures = {
edge = "Interface/BUTTONS/WHITE8X8",
bottom = "Interface/BUTTONS/WHITE8X8",
},
edges = {
edge = "Interface/AddOns/" .. addonName .. "/Textures/rxp-borders",
guideName = "Interface/AddOns/" .. addonName .. "/Textures/rxp-borders",
},
}
themes['Default'] = themes['RXP Blue']
-- Built-in themes must provide all properties
themes['RXP Red'] = {
background = {19 / 255, 0 / 255, 0 / 255, 1},
bottomFrameBG = {31 / 255, 0 / 255, 0 / 255, 1},
bottomFrameHighlight = {81 / 255, 0 / 255, 0 / 255, 1},
mapPins = {0.9, 0.1, 0.1, 1},
tooltip = "|c0000C1FF", -- AARRGGBB
texturePath = "Interface/AddOns/" .. addonName .. "/Textures/Hardcore/",
font = _G.GameFontNormal:GetFont(),
textColor = {1, 1, 1},
--applicable = function() return addon.settings.profile.hardcore end,
--applicable = true,
applicable = function() return not RXPCData.GA end,
author = "RestedXP",
bgTextures = {
edge = "Interface/BUTTONS/WHITE8X8",
bottom = "Interface/BUTTONS/WHITE8X8",
},
edges = {
edge = "Interface/AddOns/" .. addonName .. "/Textures/Hardcore/rxp-borders",
guideName = "Interface/AddOns/" .. addonName .. "/Textures/Hardcore/rxp-borders",
},
}
themes['RXP Gold'] = {
background = {32 / 255, 18 / 255, 0 / 255, 1},
bottomFrameBG = {48 / 255, 27 / 255, 0 / 255, 1},
bottomFrameHighlight = {125 / 255, 71 / 255, 0 / 255, 1},
mapPins = {0.95, 0.15, 0.15, 1},
tooltip = "|c0000C1FF", -- AARRGGBB
texturePath = "Interface/AddOns/" .. addonName .. "/Textures/GoldAssistant/",
font = _G.GameFontNormal:GetFont(),
textColor = {1, 1, 1},
applicable = function() return RXPCData.GA == true end,
--applicable = true,
author = "RestedXP"
}
local classColor = _G.RAID_CLASS_COLORS[select(2, UnitClass("player"))]
themes['DarkMode'] = {
background = {14 / 255, 14 / 255, 14 / 255, 255 / 255},
bottomFrameBG = {19 / 255, 19 / 255, 19 / 255, 255 / 255},
bottomFrameHighlight = {classColor.r, classColor.g, classColor.b, 128 / 255},
mapPins = {classColor.r, classColor.g, classColor.b, 1},
tooltip = "|c" .. classColor.colorStr,
texturePath = "Interface/AddOns/" .. addonName .. "/Textures/DarkMode/",
font = _G.GameFontNormal:GetFont(),
textColor = {1, 1, 1},
applicable = function() return not RXPCData.GA end,
--applicable = true,
author = "Bypass"
}
themes['RXP Green'] = {
background = {6 / 255, 23 / 255, 12 / 255, 1},
bottomFrameBG = {9 / 255, 34 / 255, 17 / 255, 1},
bottomFrameHighlight = {4 / 255, 113 / 255, 65 / 255, 1},
mapPins = {0 / 255, 203 / 255, 66 / 255, 1},
tooltip = "|cFFCE7BFF", -- AARRGGBB
texturePath = "Interface/AddOns/" .. addonName .. "/Textures/Green/",
font = _G.GameFontNormal:GetFont(),
textColor = {1, 1, 1},
applicable = function() return not RXPCData.GA end,
author = "RestedXP",
bgTextures = {
edge = "Interface/BUTTONS/WHITE8X8",
bottom = "Interface/BUTTONS/WHITE8X8",
},
edges = {
edge = "Interface/AddOns/" .. addonName .. "/Textures/Green/rxp-borders",
guideName = "Interface/AddOns/" .. addonName .. "/Textures/Green/rxp-borders",
},
}
addon.customThemeBase = CopyTable(themes.Default)
addon.customThemeBase.name = "Custom"
addon.customThemeBase.applicable = true
addon.customThemeBase.author = _G.UnitName("player")
addon.customThemeBase.bgTextures.guideName = "Interface/BUTTONS/WHITE8X8"
addon.guideTextColors = {}
-- TODO move into themes
addon.guideTextColors.default = {
["RXP_FRIENDLY_"] = "FF00FF25",
["RXP_ENEMY_"] = "FFFF5722",
["RXP_LOOT_"] = "FF00BCD4",
["RXP_WARN_"] = "FFFCDC00",
["RXP_PICK_"] = "FFDB2EEF",
["RXP_BUY_"] = "FF0E8312"
}
local function themeApplies(applicable,isTable)
if applicable == nil then
return true
elseif type(applicable) == "boolean" then
return applicable
elseif type(applicable) == "function" then
return applicable()
elseif type(applicable) == "table" and not isTable then
return themeApplies(applicable.applicable,true)
end
end
local function GetDefaultTheme()
if addon.currentGuide and addon.currentGuide.theme and
themes[addon.currentGuide.theme] then
return themes[addon.currentGuide.theme]
elseif RXPCData.GA then
return themes["RXP Gold"]
elseif addon.settings.profile.hardcore then
return themes["RXP Red"]
else
return themes["Default"]
end
end
function addon:LoadActiveTheme()
local applicableTheme = addon.settings.profile.activeTheme
local newTheme
if applicableTheme == "Default" then
newTheme = GetDefaultTheme()
else
newTheme = themes[applicableTheme]
end
-- Reset theme to default if selected goes away
if not (newTheme and themeApplies(newTheme)) then
newTheme = GetDefaultTheme()
end
addon.activeTheme = newTheme
local RXPFrame = addon.RXPFrame
if newTheme.bgTextures then
for name,frame in pairs(RXPFrame.backdrop) do
local texture = newTheme.bgTextures[name] or RXPFrame.defaultBackground[name]
frame.bgFile = texture
end
end
RXPFrame.backdrop.edge.edgeFile = addon.GetTexture("rxp-borders") or RXPFrame.defaultEdges.edge
RXPFrame.backdrop.guideName.edgeFile = addon.GetTexture("rxp-borders") or RXPFrame.defaultEdges.guideName
RXPFrame.backdrop.bottom.edgeFile = nil
if newTheme.edges then
for name,texture in pairs(newTheme.edges) do
local frame = RXPFrame.backdrop[name]
frame.edgeFile = texture
end
end
-- TOOD fix legacy calls
addon.colors = addon.activeTheme
addon.font = addon.activeTheme.font
return addon.activeTheme
end
function addon:GetThemeOptions()
local themeOptions = {}
for k, t in pairs(themes) do
if themeApplies(t.applicable) then
if k == 'Custom' then
themeOptions[k] = 'Custom'
elseif k == "Default" then
themeOptions[""] = "Default"
else
themeOptions[k] = fmt("%s by %s", k, t.author)
end
end
end
return themeOptions
end
function addon:RegisterTheme(theme)
if not theme then return end
if not theme['name'] or not theme['author'] then
self.comms.PrettyPrint("Theme missing name or author")
return
end
for k, _ in pairs(themes.Default) do
if not theme[k] and k ~= 'name' and k ~= 'author' then
if self.settings.profile.debug then
self.comms.PrettyPrint("%s theme missing %s using default",
theme.name, k)
end
theme[k] = themes.Default[k]
end
end
if not themeApplies(theme.applicable) then
self.comms.PrettyPrint(
"%s does not apply to current mode, importing anyway", theme.name)
end
themes[theme.name] = theme
end
function addon.GetTexture(name)
-- Avoid nil concatenation
if not name or not (addon.activeTheme and addon.activeTheme.texturePath) then
return
end
-- Exclude banner from hiding custom theme colors
if addon.activeTheme.name == "Custom" and name == 'rxp-banner' then
return
end
-- Validate for non-built-in textures?
-- https://www.wowinterface.com/forums/showpost.php?p=337605&postcount=8
return fmt("%s%s", addon.activeTheme.texturePath, name)
end
function addon:ImportCustomThemes()
-- Register empty custom theme
self:RegisterTheme(addon.settings.profile.customTheme)
if not _G.RXPGuides_Themes then return end
-- TODO use loop to strip array?
for _, theme in pairs(_G.RXPGuides_Themes) do self:RegisterTheme(theme) end
wipe(_G.RXPGuides_Themes)
end