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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755 | local AP_display_name, AP = ...
-- Config.lua
-- $Id: Config.lua 216 2010-09-03 03:27:56Z LaoTseu $
if not AllPlayed_revision then AllPlayed_revision = {} end
AllPlayed_revision.config = ("$Revision: 216 $"):match("(%d+)")
-- Backward compatibility stuff
local IS_40 = (select(4, GetBuildInfo()) >= 40000)
-- Localizations
local L = LibStub("AceLocale-3.0"):GetLocale("AllPlayed")
-- Local functions
local GetVersionString
local ReturnConfigMenu
local DisplayConfigMenu
local InitConfig
-- Version iditification management
do
local version_string = nil
function GetVersionString()
if not version_string then
-- Find the curent revision number from all the files revisions
local revision = 0
if AllPlayed_revision then
for _, rev in pairs(AllPlayed_revision) do
local rev = tonumber(rev)
if rev and rev > revision then revision = rev end
end
else
assert(false,"No AllPlayed_revision")
end
-- Find the curent version
local version = GetAddOnMetadata("AllPlayed", "Version"):match("([^ ]+)")
version_string = string.format(L["Version %s (r%s)"], version, revision)
end
return version_string
end
end -- do
-- Menu management
local function ReturnConfigMenu()
-- This funciton is called only once. Otherwise, I would recycle the table
local config_menu = {
[1] = {
text = L["AllPlayed Configuration"];
isTitle = true;
},
[2] = {
isTitle = true;
},
[3] = {
text = " ";
disabled = true;
},
[4] = {
text = L["Display"],
tooltipText = L["Set the display options"];
hasArrow = true;
menuList = {
[1] = {
text = L["All Factions"];
tooltipText = L["All factions will be displayed"];
checked = 'all_factions';
},
[2] = {
text = L["All Realms"];
tooltipText = L["All realms will de displayed"];
checked = 'all_realms';
},
[3] = {
text = L["Show Played Time"];
tooltipText = L["Display the played time and the total time played"];
checked = 'show_played_time';
},
[4] = {
text = L["Show Seconds"];
tooltipText = L["Display the seconds in the time strings"];
checked = 'show_seconds';
},
[5] = {
text = L["Show Gold"];
tooltipText = L["Display the gold each character pocess"];
checked = 'show_coins';
},
[6] = {
text = L["Show XP Progress"];
tooltipText = L["Display XP progress as a decimal value appended to the level"];
checked = 'show_progress';
},
[7] = {
text = L["Show XP total"];
tooltipText = L["Show the total XP for all characters"];
checked = 'show_xp_total';
},
[8] = {
text = L["Show Location"];
tooltipText = L["Show the character location"];
hasArrow = true;
menuList = {
[1] = {
text = L["Don't show location"];
list = 'show_location';
arg1 = "none";
},
[2] = {
text = L["Show zone"];
list = 'show_location';
arg1 = "loc";
},
[3] = {
text = L["Show subzone"];
list = 'show_location';
arg1 = "sub";
},
[4] = {
text = L["Show zone/subzone"];
list = 'show_location';
arg1 = "loc/sub";
},
},
},
[9] = {
text = L["Rested XP"];
tooltipText = L["Set the rested XP options"];
hasArrow = true;
menuList = {
[1] = {
text = L["Rested XP Total"];
tooltipText = L["Show the character rested XP"];
checked = 'show_rested_xp';
},
[2] = {
text = L["Percent Rest"];
tooltipText = L["Set the base for % display of rested XP"];
hasArrow = true;
menuList = {
[1] = {
text = L["None"];
list = 'percent_rest';
arg1 = "0";
},
[2] = {
text = L["100%"];
list = 'percent_rest';
arg1 = "100";
},
[3] = {
text = L["150%"];
list = 'percent_rest';
arg1 = "150";
},
},
},
[3] = {
text = L["Rested XP Countdown"];
tooltipText = L["Show the time remaining before the character is 100% rested"];
checked = 'show_rested_xp_countdown';
},
},
},
[10] = {
text = L["PVP"];
tooltipText = L["Set the PVP options"];
hasArrow = true;
menuList = {
[1] = {
text = L["Honor Kills"];
tooltipText = L["Show the character honor kills"];
checked = 'show_honor_kills';
},
[2] = {
text = L["Honor Points"];
tooltipText = L["Show the character honor points"];
checked = 'show_honor_points';
},
[3] = {
text = L["Arena Points"];
tooltipText = L["Show the character arena points"];
checked = 'show_arena_points';
},
[4] = {
text = L["Show PVP Totals"];
tooltipText = L["Show the honor related stats for all characters"];
checked = 'show_pvp_totals';
},
},
},
[11] = {
text = L["Show Class Name"];
tooltipText = L["Show the character class beside the level"];
checked = 'show_class_name';
},
[12] = {
text = L["Colorize Class"];
tooltipText = L["Colorize the character name based on class"];
checked = 'colorize_class';
},
[13] = {
text = L["Use Old Shaman Colour"];
tooltipText = L["Use the pre-210 patch colour for the Shaman class"];
checked = 'use_pre_210_shaman_colour';
},
[14] = {
text = L["Use Icons"];
tooltipText = L["Use graphics for coin and PvP currencies"];
checked = 'use_icons';
},
},
},
[5] = {
text = L["Sort"],
tooltipText = L["Set the sort options"];
hasArrow = true;
menuList = {
[1] = {
text = L["Sort Type"],
tooltipText = L["Select the sort type"];
hasArrow = true;
menuList = {
[1] = {
text = L["By name"];
list = 'sort_type';
arg1 = "alpha";
},
[2] = {
text = L["By level"];
list = 'sort_type';
arg1 = "level";
},
[3] = {
text = L["By experience"];
list = 'sort_type';
arg1 = "xp";
},
[4] = {
text = L["By rested XP"];
list = 'sort_type';
arg1 = "rested_xp";
},
[5] = {
text = L["By money"];
list = 'sort_type';
arg1 = "coin";
},
[6] = {
text = L["By time played"];
list = 'sort_type';
arg1 = "time_played";
},
},
},
[2] = {
text = L["Sort in reverse order"];
tooltipText = L["Use the curent sort type in reverse order"];
checked = 'reverse_sort';
},
},
},
[6] = {
text = L["Ignore Characters"],
tooltipText = L["Hide characters from display"];
hasArrow = true;
menuList = {
},
},
[7] = {
text = " ";
disabled = true;
},
[8] = {
text = L["Minimap Icon"];
tooltipText = L["Show Minimap Icon"];
checked = 'show_minimap_icon';
},
[9] = {
text = L["Configuration"];
tooltipText = L["Open configuration dialog"];
tooltipOnButton = 1;
func = function() InterfaceOptionsFrame_OpenToCategory(AP_display_name) end;
},
}
-- No area or honor points in Cataclysm
if IS_40 then
config_menu[4].menuList[10].menuList[2] = config_menu[4].menuList[10].menuList[4]
config_menu[4].menuList[10].menuList[3] = nil
config_menu[4].menuList[10].menuList[4] = nil
end
-- Set version for display
config_menu[2].text = GetVersionString()
-- All the checkbox options need to have their menu with the menu button
-- and a pair of function to get and set the options
local function AddCheckboxOption(menu)
local foundCheck = false
for i=1,#menu do
-- For Cataclysm only
if IS_40 then
menu[i].isNotRadial = true
end
if menu[i].checked then
menu[i].tooltipOnButton = 1
menu[i].keepShownOnClick = 1
menu[i].value = menu[i].checked
menu[i].checked = function() return AllPlayed:GetOption(menu[i].value) end
menu[i].func = function(dropdownmenu, arg1, arg2, checked)
AllPlayed:SetOption(dropdownmenu.value, not AllPlayed:GetOption(dropdownmenu.value))
end
foundCheck = true
end
-- For options where you choose one choice from a list of set arguments
-- arg1 contains the choice
if menu[i].list then
menu[i].tooltipOnButton = 1
menu[i].value = menu[i].list
menu[i].checked = function() return AllPlayed:GetOption(menu[i].value) == menu[i].arg1 end
menu[i].func = function(dropdownmenu, arg1, arg2, checked)
AllPlayed:SetOption(dropdownmenu.value, arg1)
end
menu[i].list = nil
foundCheck = true
end
-- Submenus
if menu[i].menuList then AddCheckboxOption(menu[i].menuList) end
-- Set notCheckable if no checkable items were found
end
if not foundCheck then
for i=1,#menu do
menu[i].notCheckable = 1
end
end
end
AddCheckboxOption(config_menu)
-- Build the ignored list
local i = 1
for faction, faction_table in pairs(AP.db.global.data) do
for realm, realm_table in pairs(faction_table) do
for pc, _ in pairs(realm_table) do
local pc_name = format(L["%s : %s"], realm, pc)
config_menu[6].menuList[i] = {
text = pc_name;
tooltipText = string.format(L["Hide %s of %s from display"], pc, realm);
tooltipOnButton = 1;
keepShownOnClick = 1;
checked = function() return AllPlayed:GetOption('is_ignored',realm, pc) end;
func = function(dropdownmenu, arg1, arg2, checked)
AllPlayed:SetOption(
'is_ignored',
not AllPlayed:GetOption('is_ignored',realm, pc),
realm,
pc
)
end;
}
-- Specify no radial button for Cataclysm
if IS_40 then config_menu[6].menuList[i].isNotRadial = true end
i = i + 1
end
end
end
return config_menu
end
do
local dropdownFrame = CreateFrame("Frame", "AllPlayedDropdownMenu", anchor, "UIDropDownMenuTemplate")
function DisplayConfigMenu(anchorFrame)
local anchor
if anchorFrame then
anchor = anchorFrame:GetName()
else
anchor = "cursor"
end
EasyMenu(AP.config_menu, dropdownFrame, anchor, nil, nil, "MENU")
end
end -- do
-- Option management
local function GetOptions()
local options = {
name = AP_display_name,
childGroups = "tab",
type = "group",
order = 1,
args = {
display = {
type = 'group', name = L["Display"], desc = L["Specify what to display"], args = {
main = {
type = 'header',
name = L["Main Settings"],
order = 1,
},
show_coins = {
name = L["Show Gold"],
desc = L["Display the gold each character pocess"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_coins') end,
set = function(info, v) AllPlayed:SetOption('show_coins',v) end,
order = 1.1,
},
use_icons = {
name = L["Use Icons"],
desc = L["Use graphics for coin and PvP currencies"],
type = 'toggle',
get = function() return AllPlayed:GetOption('use_icons') end,
set = function(info, v) AllPlayed:SetOption('use_icons',v) end,
order = 1.2,
},
show_class_name = {
name = L["Show Class Name"],
desc = L["Show the character class beside the level"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_class_name') end,
set = function(info, v) AllPlayed:SetOption('show_class_name',v) end,
order = 1.3,
},
colorize_class = {
name = L["Colorize Class"],
desc = L["Colorize the character name based on class"],
type = 'toggle',
get = function() return AllPlayed:GetOption('colorize_class') end,
set = function(info, v) AllPlayed:SetOption('colorize_class',v) end,
order = 1.4,
},
use_pre_210_shaman_colour = {
name = L["Use Old Shaman Colour"],
desc = L["Use the pre-210 patch colour for the Shaman class"],
type = 'toggle',
get = function() return AllPlayed:GetOption('use_pre_210_shaman_colour') end,
set = function(info, v) AllPlayed:SetOption('use_pre_210_shaman_colour',v) end,
order = 1.5,
},
show_location = {
name = L["Show Location"],
desc = L["Show the character location"],
width = "full",
type = 'select',
get = function() return AllPlayed:GetOption('show_location') end,
set = function(info, v) AllPlayed:SetOption('show_location',v) end,
values = { ["none"] = L["Don't show location"],
["loc"] = L["Show zone"],
["sub"] = L["Show subzone"],
["loc/sub"] = L["Show zone/subzone"]
},
order = 1.6,
},
faction_and_realms = {
type = 'header',
name = L["Factions and Realms"],
order = 2,
},
all_factions = {
name = L["All Factions"],
desc = L["All factions will be displayed"],
type = 'toggle',
get = function() return AllPlayed:GetOption('all_factions') end,
set = function(info, v) AllPlayed:SetOption('all_factions',v) end,
order = 2.1,
},
all_realms = {
name = L["All Realms"],
desc = L["All realms will de displayed"],
type = 'toggle',
get = function() return AllPlayed:GetOption('all_realms') end,
set = function(info, v) AllPlayed:SetOption('all_realms',v) end,
order = 2.2,
},
time = {
type = 'header',
name = L["Time Played"],
order = 3,
},
show_played_time = {
name = L["Show Played Time"],
desc = L["Display the played time and the total time played"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_played_time') end,
set = function(info, v) AllPlayed:SetOption('show_played_time',v) end,
order = 3.1,
},
show_seconds = {
name = L["Show Seconds"],
desc = L["Display the seconds in the time strings"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_seconds') end,
set = function(info, v) AllPlayed:SetOption('show_seconds',v) end,
order = 3.2,
},
xp = {
type = 'header',
name = L["Experience Points"],
order = 5,
},
show_progress = {
name = L["Show XP Progress"],
desc = L["Display XP progress as a decimal value appended to the level"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_progress') end,
set = function(info, v) AllPlayed:SetOption('show_progress',v) end,
order = 5.1,
},
show_xp_total = {
name = L["Show XP total"],
desc = L["Show the total XP for all characters"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_xp_total') end,
set = function(info, v) AllPlayed:SetOption('show_xp_total',v) end,
order = 5.2,
},
show_rested_xp = {
name = L["Rested XP Total"],
desc = L["Show the character rested XP"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_rested_xp') end,
set = function(info, v) AllPlayed:SetOption('show_rested_xp',v) end,
order = 5.3,
},
show_rested_xp_countdown = {
name = L["Rested XP Countdown"],
desc = L["Show the time remaining before the character is 100% rested"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_rested_xp_countdown') end,
set = function(info, v) AllPlayed:SetOption('show_rested_xp_countdown',v) end,
order = 5.4,
},
percent_rest = {
name = L["Percent Rest"],
desc = L["Set the base for % display of rested XP"],
type = 'select',
get = function() return AllPlayed:GetOption('percent_rest') end,
set = function(info, v) AllPlayed:SetOption('percent_rest',v) end,
values = { ["0"] = L["Do not show Percent Rest"], ["100"] = L["100%"], ["150"] = L["150%"] },
order = 5.5,
},
sort = {
type = 'header',
name = L["Sort Order"],
order = 9,
},
sort_type = {
name = L["Sort Type"],
desc = L["Select the sort type"],
type = 'select',
get = function() return AllPlayed:GetOption('sort_type') end,
set = function(info, v) AllPlayed:SetOption('sort_type',v) end,
values = {
["alpha"] = L["By name"],
["level"] = L["By level"],
["xp"] = L["By experience"],
["rested_xp"] = L["By rested XP"],
["percent_rest"] = L["By % rested"],
["coin"] = L["By money"],
["time_played"] = L["By time played"],
},
order = 9.1,
},
reverse_sort = {
name = L["Sort in reverse order"],
desc = L["Use the curent sort type in reverse order"],
type = 'toggle',
get = function() return AllPlayed:GetOption('reverse_sort') end,
set = function(info, v) AllPlayed:SetOption('reverse_sort',v) end,
order = 9.2,
},
pvp = {
type = 'header',
name = L["PVP"],
desc = L["Set the PVP options"],
order = 11,
},
show_honor_kills= {
name = L["Honor Kills"],
desc = L["Show the character honor kills"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_honor_kills') end,
set = function(info, v) AllPlayed:SetOption('show_honor_kills',v) end,
order = 11.1,
},
show_honor_points = {
name = L["Honor Points"],
desc = L["Show the character honor points"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_honor_points') end,
set = function(info, v) AllPlayed:SetOption('show_honor_points',v) end,
order = 11.2,
},
show_arena_points = {
name = L["Arena Points"],
desc = L["Show the character arena points"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_arena_points') end,
set = function(info, v) AllPlayed:SetOption('show_arena_points',v) end,
order = 11.3,
},
show_pvp_totals = {
name = L["Show PVP Totals"],
desc = L["Show the honor related stats for all characters"],
type = 'toggle',
get = function() return AllPlayed:GetOption('show_pvp_totals') end,
set = function(info, v) AllPlayed:SetOption('show_pvp_totals',v) end,
order = 11.4,
},
}, order = 10,
},
ignore = {
name = L["Ignore Characters"],
desc = L["Hide characters from display"],
type = 'group',
args = {
ignore_desc = {
name = L["Hide characters from display"],
type = 'description',
order = .5,
},
ignore_desc2 = {
name = " ",
type = 'description',
order = .7,
},
},
order = 20
},
ui = {
type = 'group', name = L["UI"], desc = L["Set UI options"], args = {
show_minimap_icon = {
name = L["Minimap Icon"],
desc = L["Show Minimap Icon"],
width = "full",
type = 'toggle',
get = function() return AllPlayed:GetOption('show_minimap_icon') end,
set = function(info, v) AllPlayed:SetOption('show_minimap_icon',v) end,
order = .5,
},
tooltip_scale = {
name = L["Scale"],
desc = L["Scale the tooltip (70% to 150%)"],
width = "full",
type = 'range',
min = .7,
max = 1.5,
step = .05,
isPercent = true,
get = function() return AllPlayed:GetOption('tooltip_scale') end,
set = function(info, v) AllPlayed:SetOption('tooltip_scale',v) end,
order = .6,
},
opacity = {
name = L["Opacity"],
desc = L["% opacity of the tooltip background"],
width = "full",
type = 'range',
min = 0,
max = 1,
step = .05,
isPercent = true,
get = function() return AllPlayed:GetOption('opacity') end,
set = function(info, v) AllPlayed:SetOption('opacity',v) end,
order = .7,
},
}, order = 30,
},
},
}
-- Arena and Honor points do not exists in Cataclysm
if IS_40 then
options.args.display.args.show_arena_points = nil
options.args.display.args.show_honor_points = nil
end
-- Ignore section
local faction_order = 1
for faction, faction_table in pairs(AP.db.global.data) do
local faction_id = "faction" .. faction_order
options.args.ignore.args[faction_id] = {
type = 'group',
name = faction,
args = {},
}
faction_order = faction_order + 1
local realm_order = 1
for realm, realm_table in pairs(faction_table) do
local realm_id = "realm" .. realm_order
options.args.ignore.args[faction_id].args[realm_id] = {
type = 'group',
name = realm,
args = {},
}
local pc_order = 1
for pc, _ in pairs(realm_table) do
pc_id = "pc" .. pc_order
options.args.ignore.args[faction_id].args[realm_id].args[pc_id] = {
name = pc,
desc = string.format(L["Hide %s of %s from display"], pc, realm),
type = 'toggle',
get = function() return AllPlayed:GetOption('is_ignored',realm, pc) end,
set = function(info, value) AllPlayed:SetOption('is_ignored', value, realm, pc) end
}
pc_order = pc_order + 1
end
realm_order = realm_order + 1
end
end
-- Profile section
options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(AP.db)
return options
end
-- Configuration initialization
local function InitConfig()
-- Initialize config menu
AP.config_menu = ReturnConfigMenu()
-- Initialized options panel
LibStub("AceConfig-3.0"):RegisterOptionsTable(AP_display_name, GetOptions())
AP.options_frame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(AP_display_name)
-- About section
if LibStub:GetLibrary("LibAboutPanel", true) then
LibStub:GetLibrary("LibAboutPanel").new(AP_display_name, AP_display_name)
end
end
-- Functions used outside of Config.lua
AP.DisplayConfigMenu = DisplayConfigMenu
AP.GetVersionString = GetVersionString
AP.InitConfig = InitConfig
|