-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.lua
351 lines (316 loc) · 8.74 KB
/
config.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
local Nameplates = select(2, ...)
local Config = Nameplates:NewModule("Config")
local L = Nameplates.L
local SML, registered, options, config, dialog
function Config:OnInitialize()
config = LibStub("AceConfig-3.0")
dialog = LibStub("AceConfigDialog-3.0")
SML = LibStub:GetLibrary("LibSharedMedia-3.0")
SML:Register(SML.MediaType.STATUSBAR, "BantoBar", "Interface\\Addons\\Nameplates\\images\\banto")
SML:Register(SML.MediaType.STATUSBAR, "Smooth", "Interface\\Addons\\Nameplates\\images\\smooth")
SML:Register(SML.MediaType.STATUSBAR, "Perl", "Interface\\Addons\\Nameplates\\images\\perl")
SML:Register(SML.MediaType.STATUSBAR, "Glaze", "Interface\\Addons\\Nameplates\\images\\glaze")
SML:Register(SML.MediaType.STATUSBAR, "Charcoal", "Interface\\Addons\\Nameplates\\images\\Charcoal")
SML:Register(SML.MediaType.STATUSBAR, "Otravi", "Interface\\Addons\\Nameplates\\images\\otravi")
SML:Register(SML.MediaType.STATUSBAR, "Striped", "Interface\\Addons\\Nameplates\\images\\striped")
SML:Register(SML.MediaType.STATUSBAR, "LiteStep", "Interface\\Addons\\Nameplates\\images\\LiteStep")
SML:Register(SML.MediaType.STATUSBAR, "Nameplates Default", "Interface\\TargetingFrame\\UI-TargetingFrame-BarFill")
end
-- GUI
local function set(info, value)
local cat = info[1]
if( cat == "general" or cat == "nameplates" ) then
Nameplates.db.profile[info[#(info)]] = value
Nameplates:Reload()
else
Nameplates.db.profile[info.arg][info[#(info)]] = value
Nameplates:Reload()
end
end
local function get(info)
local cat = info[1]
if( cat == "general" or cat == "nameplates" ) then
return Nameplates.db.profile[info[#(info)]]
end
return Nameplates.db.profile[info.arg][info[#(info)]]
end
-- Yes this is a quick hack
local function setColor(info, r, g, b, a)
local cat = info.arg
local key = info[#(info)]
Nameplates.db.profile[cat][key].r = r
Nameplates.db.profile[cat][key].g = g
Nameplates.db.profile[cat][key].b = b
Nameplates.db.profile[cat][key].a = a
Nameplates:Reload()
end
local function getColor(info)
local value = get(info)
return value.r, value.g, value.b, value.a
end
-- Return all registered SML textures
local textures = {}
function Config:GetTextures()
for k in pairs(textures) do textures[k] = nil end
for _, name in pairs(SML:List(SML.MediaType.STATUSBAR)) do
textures[name] = name
end
return textures
end
-- Return all registered SML fonts
local fonts = {}
function Config:GetFonts()
for k in pairs(fonts) do fonts[k] = nil end
for _, name in pairs(SML:List(SML.MediaType.FONT)) do
fonts[name] = name
end
return fonts
end
local fontBorders = {[""] = L["None"], ["OUTLINE"] = L["Outline"], ["THICKOUTLINE"] = L["Thick outline"], ["MONOCHROME"] = L["Monochrome"]}
local function loadTextSettings(config, key)
config.args.font = {
order = 1,
type = "group",
inline = true,
name = L["Font"],
args = {
name = {
order = 1,
type = "select",
name = L["Font name"],
values = "GetFonts",
dialogControl = "LSM30_Font",
arg = key,
},
border = {
order = 2,
type = "select",
name = L["Font border"],
values = fontBorders,
arg = key,
},
size = {
order = 3,
type = "range",
name = L["Font size"],
min = 1, max = 20, step = 1,
arg = key,
},
},
}
config.args.shadow = {
order = 4,
type = "group",
inline = true,
name = L["Shadow"],
arg = key,
args = {
shadowEnabled = {
order = 0,
type = "toggle",
name = L["Enable shadow"],
arg = key,
},
shadowColor = {
order = 1,
type = "color",
name = L["Shadow color"],
hasAlpha = true,
set = setColor,
get = getColor,
arg = key,
},
x = {
order = 2,
type = "range",
name = L["Shadow offset X"],
min = -2, max = 2, step = 1,
set = setNumber,
arg = key,
},
y = {
order = 3,
type = "range",
name = L["Shadow offset Y"],
min = -2, max = 2, step = 1,
set = setNumber,
arg = key,
},
},
}
end
local function loadOptions()
options = {}
options.type = "group"
options.name = "Nameplates"
options.args = {}
options.args.general = {
type = "group",
order = 1,
name = L["General"],
get = get,
set = set,
handler = Config,
args = {
general = {
order = 1,
type = "group",
inline = true,
name = L["General"],
args = {
bindings = {
order = 1,
type = "toggle",
name = L["Show nameplate visibility status"],
width = "full",
},
},
},
nameplates = {
order = 2,
type = "group",
inline = true,
name = L["Nameplates"],
args = {
textureName = {
order = 1,
type = "select",
name = L["Bar texture"],
dialogControl = "LSM30_Statusbar",
values = "GetTextures",
},
hideHealth = {
order = 2,
type = "toggle",
name = L["Hide health bar border"],
desc = L["A UI reload is required to make the border show again."],
width = "full",
},
hideCast = {
order = 3,
type = "toggle",
name = L["Hide cast bar border"],
desc = L["A UI reload is required to make the border show again."],
width = "full",
},
hideElite = {
order = 4,
type = "toggle",
name = L["Hide elite indicator"],
desc = L["A UI reload is required to make the elite indicator show again."],
width = "full",
},
hideUninterruptible = {
order = 5,
type = "toggle",
name = L["Hide cast uninterruptible shield"],
desc = L["A UI reload is required to make the cast shield indicator show again."],
width = "full",
},
},
},
},
}
options.args.text = {
order = 2,
type = "group",
name = L["Cast/Health text"],
get = get,
set = set,
handler = Config,
args = {
text = {
order = 0,
type = "group",
inline = true,
name = L["Text"],
args = {
healthType = {
order = 1,
type = "select",
name = L["Health text display"],
desc = L["Style of display for health bar text."],
values = {["none"] = L["None"], ["minmax"] = L["Min / Max"], ["deff"] = L["Deficit"], ["percent"] = L["Percent"]},
arg = "text",
},
castType = {
order = 2,
type = "select",
name = L["Cast text display"],
desc = L["Style of display for cast bar text."],
values = {["crtmax"] = L["Current / Max"], ["none"] = L["None"], ["crt"] = L["Current"], ["percent"] = L["Percent"], ["timeleft"] = L["Time left"]},
arg = "text",
},
},
},
},
}
options.args.name = {
order = 4,
type = "group",
name = L["Name text"],
get = get,
set = set,
handler = Config,
args = {},
}
options.args.level = {
order = 5,
type = "group",
name = L["Level text"],
get = get,
set = set,
handler = Config,
args = {},
}
-- Load all of the text options in
loadTextSettings(options.args.text, "text")
loadTextSettings(options.args.name, "name")
loadTextSettings(options.args.level, "level")
-- DB Profiles
options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(Nameplates.db)
options.args.profile.order = 6
end
-- Slash commands
SLASH_NAMEPLATES1 = "/nameplates"
SLASH_NAMEPLATES2 = "/np"
SLASH_NAMEPLATES3 = "/nameplate"
SlashCmdList["NAMEPLATES"] = function(msg)
if( not registered ) then
if( not options ) then
loadOptions()
end
config:RegisterOptionsTable("Nameplates", options)
dialog:SetDefaultSize("Nameplates", 625, 500)
registered = true
end
dialog:Open("Nameplates")
end
-- Add the options to the default Blizzard UI
local register = CreateFrame("Frame", nil, InterfaceOptionsFrame)
register:SetScript("OnShow", function(self)
self:SetScript("OnShow", nil)
loadOptions()
config:RegisterOptionsTable("Nameplates-Bliz", {
name = "Nameplates",
type = "group",
args = {
help = {
type = "description",
name = string.format("Nameplates r%d is a basic nameplate modifier.", Nameplates.revision or 0),
},
},
})
dialog:SetDefaultSize("Nameplates-Bliz", 600, 400)
dialog:AddToBlizOptions("Nameplates-Bliz", "Nameplates")
config:RegisterOptionsTable("Nameplates-Profile", options.args.profile)
dialog:AddToBlizOptions("Nameplates-Profile", options.args.profile.name, "Nameplates")
config:RegisterOptionsTable("Nameplates-Text", options.args.text)
dialog:AddToBlizOptions("Nameplates-Text", options.args.text.name, "Nameplates")
config:RegisterOptionsTable("Nameplates-Level", options.args.level)
dialog:AddToBlizOptions("Nameplates-Level", options.args.level.name, "Nameplates")
config:RegisterOptionsTable("Nameplates-Name", options.args.name)
dialog:AddToBlizOptions("Nameplates-Name", options.args.name.name, "Nameplates")
config:RegisterOptionsTable("Nameplates-General", options.args.general)
dialog:AddToBlizOptions("Nameplates-General", options.args.general.name, "Nameplates")
end)