forked from Sidoine/Ovale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Options.lua
513 lines (490 loc) · 13.5 KB
/
Options.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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
--[[--------------------------------------------------------------------
Copyright (C) 2012, 2013 Sidoine De Wispelaere.
Copyright (C) 2012, 2013, 2014 Johnny C. Lam.
See the file LICENSE.txt for copying permission.
--]]--------------------------------------------------------------------
-- Ovale options and UI
local OVALE, Ovale = ...
local OvaleOptions = Ovale:NewModule("OvaleOptions", "AceConsole-3.0", "AceEvent-3.0")
Ovale.OvaleOptions = OvaleOptions
--<private-static-properties>
local AceConfig = LibStub("AceConfig-3.0")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local L = Ovale.L
local ipairs = ipairs
local pairs = pairs
local tinsert = table.insert
local type = type
local API_InterfaceOptionsFrame_OpenToCategory = InterfaceOptionsFrame_OpenToCategory
-- GLOBALS: LibStub
-- List of registered modules providing options.
local self_register = {}
--</private-static-properties>
--<public-static-properties>
-- AceDB default database.
OvaleOptions.defaultDB = {
profile = {
check = {},
list = {},
standaloneOptions = false,
apparence = {
-- Icon group
avecCible = false,
clickThru = false,
enCombat = false,
enableIcons = true,
hideEmpty = false,
hideVehicule = false,
margin = 4,
offsetX = 0,
offsetY = 0,
targetHostileOnly = false,
verrouille = false,
vertical = false,
-- Icon
alpha = 1,
flashIcon = true,
fontScale = 1,
highlightIcon = true,
iconScale = 1,
numeric = false,
raccourcis = true,
smallIconScale = 0.8,
targetText = "●",
-- Options
iconShiftX = 0,
iconShiftY = 0,
optionsAlpha = 1,
-- Two abilities
predictif = false,
secondIconScale = 1,
-- Advanced
taggedEnemies = false,
auraLag = 400,
},
},
}
-- AceDB options table.
OvaleOptions.options = {
type = "group",
args =
{
apparence =
{
name = OVALE,
type = "group",
-- Generic getter/setter for options.
get = function(info)
return Ovale.db.profile.apparence[info[#info]]
end,
set = function(info, value)
Ovale.db.profile.apparence[info[#info]] = value
-- Pass the name of the parent group as the event parameter.
OvaleOptions:SendMessage("Ovale_OptionChanged", info[#info - 1])
end,
args =
{
standaloneOptions = {
order = 30,
name = L["Standalone options"],
desc = L["Open configuration panel in a separate, movable window."],
type = "toggle",
get = function(info)
return Ovale.db.profile.standaloneOptions
end,
set = function(info, value)
Ovale.db.profile.standaloneOptions = value
end,
},
iconGroupAppearance =
{
order = 40,
type = "group",
name = L["Groupe d'icônes"],
args =
{
enableIcons = {
order = 10,
type = "toggle",
name = L["Enabled"],
width = "full",
set = function(info, value)
Ovale.db.profile.apparence.enableIcons = value
OvaleOptions:SendMessage("Ovale_OptionChanged", "visibility")
end,
},
verrouille =
{
order = 10,
type = "toggle",
name = L["Verrouiller position"],
disabled = function()
return not Ovale.db.profile.apparence.enableIcons
end,
},
clickThru =
{
order = 20,
type = "toggle",
name = L["Ignorer les clics souris"],
disabled = function()
return not Ovale.db.profile.apparence.enableIcons
end,
},
visibility = {
order = 20,
type = "group",
name = L["Visibilité"],
inline = true,
disabled = function()
return not Ovale.db.profile.apparence.enableIcons
end,
args = {
enCombat = {
order = 10,
type = "toggle",
name = L["En combat uniquement"],
},
avecCible = {
order = 20,
type = "toggle",
name = L["Si cible uniquement"],
},
targetHostileOnly = {
order = 30,
type = "toggle",
name = L["Cacher si cible amicale ou morte"],
},
hideVehicule = {
order = 40,
type = "toggle",
name = L["Cacher dans les véhicules"],
},
hideEmpty = {
order = 50,
type = "toggle",
name = L["Cacher bouton vide"],
},
},
},
layout = {
order = 30,
type = "group",
name = L["Layout"],
inline = true,
disabled = function()
return not Ovale.db.profile.apparence.enableIcons
end,
args = {
moving = {
order = 10,
type = "toggle",
name = L["Défilement"],
desc = L["Les icônes se déplacent"],
},
vertical = {
order = 20,
type = "toggle",
name = L["Vertical"],
},
offsetX = {
order = 30,
type = "range",
name = L["Horizontal offset"],
desc = L["Horizontal offset from the center of the screen."],
min = -1000, max = 1000,
softMin = -500, softMax = 500, bigStep = 1,
},
offsetY = {
order = 40,
type = "range",
name = L["Vertical offset"],
desc = L["Vertical offset from the center of the screen."],
min = -1000, max = 1000,
softMin = -500, softMax = 500, bigStep = 1,
},
margin = {
order = 50,
type = "range",
name = L["Marge entre deux icônes"],
min = -16, max = 64, step = 1,
},
}
}
},
},
iconAppearance =
{
order = 50,
type = "group",
name = L["Icône"],
args =
{
iconScale =
{
order = 10,
type = "range",
name = L["Taille des icônes"],
desc = L["La taille des icônes"],
min = 0.5, max = 3, bigStep = 0.01,
isPercent = true,
},
smallIconScale =
{
order = 20,
type = "range",
name = L["Taille des petites icônes"],
desc = L["La taille des petites icônes"],
min = 0.5, max = 3, bigStep = 0.01,
isPercent = true,
},
fontScale =
{
order = 30,
type = "range",
name = L["Taille des polices"],
desc = L["La taille des polices"],
min = 0.2, max = 2, bigStep = 0.01,
isPercent = true,
},
alpha =
{
order = 40,
type = "range",
name = L["Opacité des icônes"],
min = 0, max = 1, bigStep = 0.01,
isPercent = true,
},
raccourcis =
{
order = 50,
type = "toggle",
name = L["Raccourcis clavier"],
desc = L["Afficher les raccourcis clavier dans le coin inférieur gauche des icônes"],
},
numeric =
{
order = 60,
type = "toggle",
name = L["Affichage numérique"],
desc = L["Affiche le temps de recharge sous forme numérique"],
},
highlightIcon =
{
order = 70,
type = "toggle",
name = L["Illuminer l'icône"],
desc = L["Illuminer l'icône quand la technique doit être spammée"],
},
flashIcon =
{
order = 80,
type = "toggle",
name = L["Illuminer l'icône quand le temps de recharge est écoulé"],
},
targetText =
{
order = 90,
type = "input",
name = L["Caractère de portée"],
desc = L["Ce caractère est affiché dans un coin de l'icône pour indiquer si la cible est à portée"],
},
},
},
optionsAppearance =
{
order = 60,
type = "group",
name = L["Options"],
args =
{
iconShiftX =
{
order = 10,
type = "range",
name = L["Décalage horizontal des options"],
min = -256, max = 256, step = 1,
},
iconShiftY =
{
order = 20,
type = "range",
name = L["Décalage vertical des options"],
min = -256, max = 256, step = 1,
},
optionsAlpha =
{
order = 30,
type = "range",
name = L["Opacité des options"],
min = 0, max = 1, bigStep = 0.01,
isPercent = true,
},
},
},
predictiveIcon =
{
order = 70,
type = "group",
name = L["Prédictif"],
args =
{
predictif =
{
order = 10,
type = "toggle",
name = L["Prédictif"],
desc = L["Affiche les deux prochains sorts et pas uniquement le suivant"],
},
secondIconScale =
{
order = 20,
type = "range",
name = L["Taille du second icône"],
min = 0.2, max = 1, bigStep = 0.01,
isPercent = true,
},
},
},
advanced = {
order = 80,
type = "group",
name = "Advanced",
args =
{
taggedEnemies = {
order = 10,
type = "toggle",
name = L["Only count tagged enemies"],
desc = L["Only count a mob as an enemy if it is directly affected by a player's spells."],
},
auraLag =
{
order = 20,
type = "range",
name = L["Aura lag"],
desc = L["Lag (in milliseconds) between when an spell is cast and when the affected aura is applied or removed"],
min = 100, max = 700, step = 10,
},
},
},
},
},
actions =
{
name = "Actions",
type = "group",
args =
{
show =
{
type = "execute",
name = L["Afficher la fenêtre"],
guiHidden = true,
func = function()
Ovale.db.profile.apparence.enableIcons = true
OvaleOptions:SendMessage("Ovale_OptionChanged", "visibility")
end
},
hide =
{
type = "execute",
name = L["Cacher la fenêtre"],
guiHidden = true,
func = function()
Ovale.db.profile.apparence.enableIcons = false
OvaleOptions:SendMessage("Ovale_OptionChanged", "visibility")
end
},
config =
{
name = "Configuration",
type = "execute",
func = function() OvaleOptions:ToggleConfig() end,
},
refresh = {
name = L["Display refresh statistics"],
type = "execute",
func = function()
local avgRefresh, minRefresh, maxRefresh, count = Ovale:GetRefreshIntervalStatistics()
Ovale:Print("Refresh intervals: count = %d, avg = %d, min = %d, max = %d (ms)", count, avgRefresh, minRefresh, maxRefresh)
end,
},
},
},
},
}
--</public-static-properties>
--<public-static-methods>
function OvaleOptions:OnInitialize()
local db = LibStub("AceDB-3.0"):New("OvaleDB", self.defaultDB)
self.options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(db)
-- Add dual-spec support
local LibDualSpec = LibStub("LibDualSpec-1.0",true)
if LibDualSpec then
LibDualSpec:EnhanceDatabase(db, "Ovale")
LibDualSpec:EnhanceOptions(self.options.args.profile, db)
end
db.RegisterCallback( self, "OnNewProfile", "HandleProfileChanges" )
db.RegisterCallback( self, "OnProfileReset", "HandleProfileChanges" )
db.RegisterCallback( self, "OnProfileChanged", "HandleProfileChanges" )
db.RegisterCallback( self, "OnProfileCopied", "HandleProfileChanges" )
Ovale.db = db
-- Upgrade saved variables to current format.
self:UpgradeSavedVariables()
AceConfig:RegisterOptionsTable(OVALE, self.options.args.apparence)
AceConfig:RegisterOptionsTable(OVALE .. " Profiles", self.options.args.profile)
-- Slash commands.
AceConfig:RegisterOptionsTable(OVALE .. " Actions", self.options.args.actions, "Ovale")
AceConfigDialog:AddToBlizOptions(OVALE)
AceConfigDialog:AddToBlizOptions(OVALE .. " Profiles", "Profiles", OVALE)
end
function OvaleOptions:OnEnable()
self:HandleProfileChanges()
end
function OvaleOptions:RegisterOptions(addon)
tinsert(self_register, addon)
end
function OvaleOptions:UpgradeSavedVariables()
local profile = Ovale.db.profile
-- Merge two options that had the same meaning.
if profile.display ~= nil and type(profile.display) == "boolean" then
profile.apparence.enableIcons = profile.display
profile.display = nil
end
-- The frame position settings changed from left/top to offsetX/offsetY.
if profile.left or profile.top then
profile.left = nil
profile.top = nil
Ovale:OneTimeMessage("The Ovale icon frames position has been reset.")
end
-- Invoke module-specific upgrade for Saved Variables.
for _, addon in ipairs(self_register) do
if addon.UpgradeSavedVariables then
addon:UpgradeSavedVariables()
end
end
-- Re-register defaults so that any tables created during the upgrade are "populated"
-- by the default database automatically.
Ovale.db:RegisterDefaults(self.defaultDB)
end
function OvaleOptions:HandleProfileChanges()
self:SendMessage("Ovale_ProfileChanged")
self:SendMessage("Ovale_ScriptChanged")
end
function OvaleOptions:ToggleConfig()
if Ovale.db.profile.standaloneOptions then
local appName = OVALE
if AceConfigDialog.OpenFrames[appName] then
AceConfigDialog:Close(appName)
else
AceConfigDialog:Open(appName)
end
else
API_InterfaceOptionsFrame_OpenToCategory(OVALE)
-- Invoke the same call twice in a row to workaround a bug with Interface panel
-- opening without selecting the right category.
API_InterfaceOptionsFrame_OpenToCategory(OVALE)
end
end
--</public-static-methods>