-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoGoMount_Manager.lua
1308 lines (1097 loc) · 39.8 KB
/
GoGoMount_Manager.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
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
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ///////////////////////////////////////////////////////////////////////////////////////////
--
-- GoGoMount_Manager v3.1
-- Author: SLOKnightfall
-- GoGoMount_Manager: Integrates GoGoMounts Preferred and Excluded listing directly into the Mount List and adds profile support
-- ///////////////////////////////////////////////////////////////////////////////////////////
GoGoMount_Manager = LibStub("AceAddon-3.0"):NewAddon("GoGoMount_Manager","AceEvent-3.0", "AceHook-3.0")
GoGoMount_Manager.spell_to_id = {}
GoGoMount_Manager.JournalFilter = {}
local private = {}
local spell_to_id = GoGoMount_Manager.spell_to_id
local L = LibStub("AceLocale-3.0"):GetLocale("GoGoMount_Manager", silent)
--Mirror of the GoGoMount pref settings
local GlobalPrefs = {}
local GlobalExclude = {}
local ZoneMountList = {}
local recentMounts = {}
local specialForms = {}
local ExtraPassengerMounts = {}
--Zone Based Settings globals
local EnableZoneEdit = false
local EnablePassengerEdit = false
local selectedCont = nil
local selectedZone = nil
local selectedProfile = nil
local continentZoneList = {
[12] = C_Map.GetMapInfo(12).name, -- Kalimdor
[13] = C_Map.GetMapInfo(13).name, -- Azeroth
[101] = C_Map.GetMapInfo(101).name, -- Outlands
[113] = C_Map.GetMapInfo(113).name, -- Northrend
[424] = C_Map.GetMapInfo(424).name, -- Pandaria
[572] = C_Map.GetMapInfo(572).name, -- Draenor
[619] = C_Map.GetMapInfo(619).name, -- Broken Isles
[875] = C_Map.GetMapInfo(875).name, -- Zandalar
[876] = C_Map.GetMapInfo(876).name, -- Kul Tiras
}
local ZoneList = {}
--Mount Defaults
local MountDefaults = {
[230] = {["type"] = "Ground Mount", [38] = true, [330]=true, [400]=true, [402]=true, [405]=true, [701]=true, [10001]=67, [10002]=160, [10004]=67},
[231] = {["type"] = "Riding/sea turtle", [15] = true, [39] = true, [402]=true, [404]=true, [10001]=108, [10002]=100, [10004]=108},
[232] = {["type"] = "Vashj'ir Seahorse", [36] = true, [53] = true, [401] = true, [10001]=371, [10004]=371},
[241] = {["type"] = "AQ bugs", [38] = true, [201] = true, [330]=true, [402]=true, [10002]=160},
[247] = {["type"] = "Red Flying Cloud", [9] = true, [38] = true, [300]=true, [301]=true, [330]=true, [400]=true, [402]=true, [403]=true, [405]=true, [701]=true, [10001]=67, [10002]=160, [10003]=250, [10004]=67},
[248] = {["type"] = "Flying Mount", [9] = true, [38] = true, [300]=true, [301]=true, [330]=true, [400]=true, [402]=true, [403]=true, [405]=true, [701]=true, [10001]=67, [10002]=160, [10003]=250, [10004]=67},
[254] = {["type"] = "Swimming Mount", [36] = true, [53] = true, [404] = true, [10001]=108, [10004]=108},
[269] = {["type"] = "Striders", [38] = true, [330]=true, [400]=true, [402]=true, [405]=true, [701]=true, [10001]=67, [10002]=160, [10004]=200},
[284] = {["type"] = "Chauffer", [38] = true, [330]=true, [400]=true, [402]=true, [405]=true, [701]=true, [10001]=67, [10002]=160, [10004]=67},
}
--Default Settings
local defaults = {
profile = {
GlobalPrefs = {},
GlobalExclude = {},
ZoneMountList = {},
ExtraPassengerMounts = {},
init = true,
UseFix = true,
AddMissingMounts = true,
ForceRandom = true,
HistorySize = 5,
}
}
--Ace3 Menu Settings
local options = {
name = "GoGoMount_Manager",
handler = GoGoMount_Manager,
type = 'group',
args = {
settings = {
name = "Settings",
handler = GoGoMount_Manager,
type = 'group',
order = 0,
args = {
forceRandom = {
name = "Rechoose mount if previously selected",
desc = "Enables / disables bug fixes for GoGoMount",
type = "toggle",
set = function(info,val) GoGoMount_Manager.db.profile.ForceRandom = val end,
get = function(info) return GoGoMount_Manager.db.profile.ForceRandom end,
order = 1,
width = "full",
},
forceRandomHistory = {
name = "Number of mounts to keep history for",
--desc = "Enables / disables bug fixes for GoGoMount",
type = "range",
set = function(info,val) GoGoMount_Manager.db.profile.HistorySize = val end,
get = function(info) return GoGoMount_Manager.db.profile.HistorySize end,
order = 1,
width = "full",
min = 1,
max = 5,
step = 1,
},
fixToggle = {
name = "Enable GoGoMount Bug Fixes",
desc = "Enables / disables bug fixes for GoGoMount",
type = "toggle",
set = function(info,val) GoGoMount_Manager.db.profile.UseFix = val, GoGoMount_Manager:ToggleFixes(val) end,
get = function(info) return GoGoMount_Manager.db.profile.UseFix end,
order = 1,
width = "full",
},
missingMounts = {
name = "Add Missing Mounts",
desc = "Adds missing mounts to the GoGoMountDB with default values",
type = "toggle",
set = function(info,val) GoGoMount_Manager.db.profile.AddMissingMounts = val; if val then GoGoMount_Manager:AddMissingMounts() end; end,
get = function(info) return GoGoMount_Manager.db.profile.AddMissingMounts end,
order = 2,
width = "full",
},
},
},
},
}
--Builds out list of zones in a given continent
---------
local function fillContinentZoneList(continent)
---------
if not continent then return {} end
wipe(ZoneList)
local children = C_Map.GetMapChildrenInfo(continent)
if children then
for _, child in ipairs(children) do
if child.mapType == Enum.UIMapType.Zone then
ZoneList[child.mapID] = C_Map.GetMapInfo(child.mapID).name
end
end
end
end
--Copies the global mounts of a profile to a selected zone
---------
local function CopyProfileToZone(profileName)
---------
ZoneMountList[selectedZone] = {["Preferred"] = {}, ["Excluded"] = {},}
if GoGoMount_Manager.db.profiles[profileName]["GlobalPrefs"] then
for spellID, setting in pairs(GoGoMount_Manager.db.profiles[profileName]["GlobalPrefs"]) do
ZoneMountList[selectedZone]["Preferred"][spellID] = setting
end
end
if GoGoMount_Manager.db.profiles[profileName]["GlobalExclude"] then
for spellID, setting in pairs(GoGoMount_Manager.db.profiles[profileName]["GlobalExclude"]) do
ZoneMountList[selectedZone]["Excluded"][spellID] = setting
end
end
GoGoMount_Manager:UpdateCB()
GoGoMount_Manager:UpdateGoGoMountPrefs()
end
--Ace3 Menu Settings for the Zone Settings window
local zone_options = {
name = "GoGoMount_Manager_Zone",
handler = GoGoMount_Manager,
type = 'group',
args = {
zoneoptions={
name = "Options",
type = "group",
--hidden = true,
args={
Topheader = {
order = 0,
type = "header",
name = "GOGOMount_Manager",
},
filler1 = {
order = 0.1,
type = "description",
name = "\n",
},
globalheader = {
order = 0.5,
type = "header",
name = L.GLOBAL_HELPERS_HEADER,
},
clearglobalfav = {
order = 1,
type = "execute",
name = L.CLEAR_GLOBAL_FAVORITES,
func = function() GoGoMount_Manager:ClearGlobalFav() end,
width = 1.6,
},
clearglobalexclude = {
order = 2,
type = "execute",
name = L.CLEAR_GLOBAL_EXCLUDES,
func = function() GoGoMount_Manager:ClearGlobalExclude() end,
width = "full",
},
p_filler2 = {
order = 2.1,
type = "description",
name = "\n",
},
passengerheader = {
order = 2.2,
type = "header",
name = L.PASSENGER_HEADER,
width = "full",
},
passengerMounts = {
order = 2.3,
type = "toggle",
name = L.ENABLE_PASSENGER_SETTINGS,
get = function(info) return EnablePassengerEdit end,
set = function(info, value) private.TogglePassengerSelection(value) end,
width = "full",
},
filler2 = {
order = 2.4,
type = "description",
name = "\n",
},
zoneheader = {
order = 2.5,
type = "header",
name = L.ZONE_SETTINGS_HEADER,
width = "full",
},
item = {
order = 3,
type = "toggle",
name = L.ENABLE_ZONE_SETTINGS,
get = function(info) return EnableZoneEdit end,
set = function(info, value) EnableZoneEdit = value; GoGoMount_Manager:UpdateCB(); private.TogglePassengerSelection(false) end,
width = "full",
},
cont = {
order = 4,
type = "select",
name = "Continent",
get = function(info) return selectedCont end,
set = function(info, value) selectedCont = value; fillContinentZoneList(value); selectedZone=nil end,
values = continentZoneList,
disabled = function() return not EnableZoneEdit end,
},
zone = {
order = 5,
type = "select",
name = "Zone",
get = function(info) return selectedZone end,
set = function(info, value) selectedZone = value; ZoneMountList[value] = ZoneMountList[value] or{["Preferred"] = {},["Excluded"] = {},}; GoGoMount_Manager:UpdateCB() end,
values = function() return ZoneList end,
disabled = function() return not EnableZoneEdit end,
},
profile = {
order = 6,
type = "select",
name = L.COPY_PROFILE ,
get = function(info) return selectedProfile end,
set = function(info, value) selectedProfile = GoGoMount_Manager.db:GetProfiles()[value]; CopyProfileToZone(selectedProfile) end,
values = function() return GoGoMount_Manager.db:GetProfiles() end,
disabled = function() return not EnableZoneEdit and not selectedZone end,
width = "full",
},
filler3 = {
order = 6.4,
type = "description",
name = "\n",
},
zoneheader_2 = {
order = 6.5,
type = "header",
name = L.ZONE_HELPERS_HEADER,
width = "full",
},
clearselectedzone = {
order = 7,
type = "execute",
name = L.CLEAR_SELECTED_ZONE,
func = function() GoGoMount_Manager:ClearZoneFavorites() end,
width = "full",
},
clearallzone = {
order = 8,
type = "execute",
name = L.CLEAR_ALL_ZONES,
func = function() GoGoMount_Manager:ClearAllZoneFavorites() end,
width = "full",
},
},
},
},
}
function private.TogglePassengerSelection(value)
EnablePassengerEdit = value
if value then
GoGoMount_Manager.JournalFilter:SetAllSubFilters(GoGoMount_Manager.JournalFilter.settings.filter["mountType"], false)
GoGoMount_Manager.JournalFilter.settings.filter["mountType"]["passenger"] = true
EnableZoneEdit = false
else
GoGoMount_Manager.JournalFilter:SetAllSubFilters(GoGoMount_Manager.JournalFilter.settings.filter["mountType"], true)
end
GoGoMount_Manager.JournalFilter:UpdateIndexMap()
MountJournal_UpdateMountList()
GoGoMount_Manager:UpdateCB()
end
---Updates our GlobalPrefs if changes are made via the GoGoMounts options
--Pram: spellID - spellID to set the table value for
---------
local function GoGo_GlobalPrefMount_update(spellID)
---------
if GlobalPrefs[spellID] or GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
GlobalPrefs[spellID] = null
else
GlobalPrefs[spellID] = true
end
end
---Updates our GlobalExclude if changes are made via the GoGoMounts options
--Pram: spellID - spellID to set the table value for
---------
local function GoGo_GlobalExcludeMount_update(spellID)
---------
if GlobalExclude[spellID] or GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
GlobalExclude[spellID] = null
else
GlobalExclude[spellID] = true
end
end
---Updates our GlobalPrefs if changes are made via the GoGoMounts options
--Pram: spellID - spellID to set the table value for
---------
local function GoGo_PassengerMount_update(spellID)
---------
if ExtraPassengerMounts[spellID] or GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
ExtraPassengerMounts[spellID] = null
else
ExtraPassengerMounts[spellID] = true
end
end
---------
local function GoGo_ZoneExcludeMount_update(spellID,ZoneID)
---------
local zone = ZoneID or GoGo_Variables.Player.MapID
ZoneMountList[zone] = ZoneMountList[zone] or {["Preferred"] = {}, ["Excluded"] = {},}
if ZoneMountList[zone]["Excluded"][spellID] or GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
ZoneMountList[zone]["Excluded"][spellID] = null
else
ZoneMountList[zone]["Excluded"][spellID] = true
end
end
---------
local function GoGo_ZonePrefMount_update(spellID,ZoneID)
---------
local zone = ZoneID or GoGo_Variables.Player.MapID
ZoneMountList[zone] = ZoneMountList[zone] or {["Preferred"] = {}, ["Excluded"] = {},}
if ZoneMountList[zone]["Preferred"][spellID] or GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
ZoneMountList[zone]["Preferred"][spellID] = null
else
ZoneMountList[zone]["Preferred"][spellID] = true
end
end
---------
local function ZonePrefMount(spellID,ZoneID)
---------
if spellID == nil or ZoneID == nil then
return
else
spellID = tonumber(spellID)
end
if GoGo_Variables.Debug >= 10 then
GoGo_DebugAddLine("GoGo_ZonePrefMount: Preference ID " .. spellID)
end
GoGo_Prefs.MapIDs[ZoneID] = GoGo_Prefs.MapIDs[ZoneID] or {["Preferred"] = {},["Excluded"] = {}}
for GoGo_CounterA = 1, #GoGo_Prefs.MapIDs[ZoneID]["Preferred"] do
if GoGo_Prefs.MapIDs[ZoneID]["Preferred"][GoGo_CounterA] == spellID then
table.remove(GoGo_Prefs.MapIDs[ZoneID]["Preferred"], GoGo_CounterA)
GoGo_ZonePrefMount_update(spellID,ZoneID)
return -- mount found, removed and now returning
end
end
if not GoGo_SearchTable(GoGo_Prefs.UnknownMounts, spellID) then
table.insert(GoGo_Prefs.MapIDs[ZoneID]["Preferred"], spellID)
end
GoGo_ZonePrefMount_update(spellID,ZoneID)
end
---------
local function ZoneExcludeMount(spellID, ZoneID)
---------
if spellID == nil or ZoneID==nil then
return
else
spellID = tonumber(spellID)
end
if GoGo_Variables.Debug >= 10 then
GoGo_DebugAddLine("GoGo_ZoneExcludedMount: Excluded ID " .. spellID)
end
GoGo_Prefs.MapIDs[ZoneID] = GoGo_Prefs.MapIDs[ZoneID] or {["Preferred"] = {},["Excluded"] = {}}
for GoGo_CounterA = 1, #GoGo_Prefs.MapIDs[ZoneID]["Excluded"] do
if GoGo_Prefs.MapIDs[ZoneID]["Excluded"][GoGo_CounterA] == spellID then
table.remove(GoGo_Prefs.MapIDs[ZoneID]["Excluded"], GoGo_CounterA)
GoGo_ZoneExcludeMount_update(spellID)
return
end
end
table.insert(GoGo_Prefs.MapIDs[ZoneID]["Excluded"], spellID)
GoGo_ZoneExcludeMount_update(spellID,ZoneID)
end
---Initilizes the buttons and creates the appropriate on click behaviour
--Pram: frame - frame that the checkbox should be added to
--Pram: index - index used to refrence the checkbox that is created created
--Return: checkbox - the created checkbox frame
---------
local function init_button(frame, index)
---------
local checkbox = CreateFrame("CheckButton", "GGMM"..index, frame, "ChatConfigCheckButtonTemplate")
checkbox:SetPoint("BOTTOMRIGHT")
checkbox.spellID = 0
checkbox:RegisterForClicks("AnyUp")
checkbox:SetScript("OnClick",
function(self, button)
if (checkbox:GetChecked()) and button == "LeftButton" and EnableZoneEdit then
-- Sets as Perfered Mount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
ZonePrefMount(checkbox.spellID, selectedZone )
checkbox:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
checkbox.tooltip = L.ZONE_ENABLE
elseif (checkbox:GetChecked()) and button == "LeftButton" and not EnableZoneEdit and not EnablePassengerEdit then -- Sets as Perfered Mount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
GoGo_GlobalPrefMount(checkbox.spellID)
checkbox:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
checkbox.tooltip = L.GLOBAL_ENABLE
elseif (checkbox:GetChecked()) and button == "RightButton" and EnableZoneEdit then -- Sets as Excluded Mount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
ZoneExcludeMount(checkbox.spellID, selectedZone)
checkbox:SetCheckedTexture("Interface/Buttons/UI-GROUPLOOT-PASS-DOWN")
checkbox.tooltip = L.ZONE_EXCLUDE
elseif (checkbox:GetChecked()) and button == "RightButton" and not EnableZoneEdit and not EnablePassengerEdit then -- Sets as Excluded Mount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
GoGo_GlobalExcludeMount(checkbox.spellID)
checkbox:SetCheckedTexture("Interface/Buttons/UI-GROUPLOOT-PASS-DOWN")
checkbox.tooltip = L.GLOBAL_EXCLUDE
elseif not (checkbox:GetChecked()) and EnableZoneEdit then -- Removes Settings from GoGoMount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
if ZoneMountList[selectedZone]["Preferred"][checkbox.spellID] then
ZonePrefMount(checkbox.spellID, selectedZone )
end
if ZoneMountList[selectedZone]["Excluded"][checkbox.spellID] then
ZoneExcludeMount(checkbox.spellID, selectedZone)
end
checkbox.tooltip = L.GLOBAL_CLEAR
elseif (checkbox:GetChecked()) and button == "LeftButton" and EnablePassengerEdit then --passenger mount
-- Sets as Perfered Mount
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON)
GoGo_ExtraPassengerMounts(checkbox.spellID)
checkbox:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
checkbox.tooltip = "Pass"
elseif not (checkbox:GetChecked()) and EnablePassengerEdit then
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
GoGo_ExtraPassengerMounts(checkbox.spellID)
checkbox.tooltip = L.GLOBAL_CLEAR
elseif not (checkbox:GetChecked()) and not EnableZoneEdit then
PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_OFF)
if GlobalPrefs[checkbox.spellID] then
GoGo_GlobalPrefMount(checkbox.spellID)
end
if GlobalExclude[checkbox.spellID] then
GoGo_GlobalExcludeMount(checkbox.spellID)
end
checkbox.tooltip = L.GLOBAL_CLEAR
end
end
)
local text = checkbox:CreateFontString(checkbox:GetName() .. "_Text")
checkbox.text = text
checkbox.text:SetFont("Fonts\\FRIZQT__.TTF", 15)
--checkbox.text:SetTextColor(0.85, 0.85, 0.85, 1)
checkbox.text:ClearAllPoints()
checkbox.text:SetPoint("RIGHT", checkbox, "LEFT")
checkbox.text:SetText("Z:")
return checkbox
end
---Refreshes our global lists to get any changes made from the GoGoMount options
---------
local function RefreshFromGoGoPrefs()
---------
wipe(GlobalPrefs)
wipe(GlobalExclude)
wipe(ZoneMountList)
wipe(ExtraPassengerMounts)
if GoGo_Prefs.GlobalPrefMounts then
for counter = 1, #GoGo_Prefs.GlobalPrefMounts do
GlobalPrefs[GoGo_Prefs.GlobalPrefMounts[counter]] = true
end
end
if GoGo_Prefs.GlobalExclude then
for counter = 1, #GoGo_Prefs.GlobalExclude do
GlobalExclude[GoGo_Prefs.GlobalExclude[counter]] = true
end
end
if GoGo_Prefs.ExtraPassengerMounts then
for counter = 1, #GoGo_Prefs.ExtraPassengerMounts do
ExtraPassengerMounts[GoGo_Prefs.ExtraPassengerMounts[counter]] = true
end
end
if GoGo_Prefs.MapIDs then
for zone, data in pairs(GoGo_Prefs.MapIDs) do
ZoneMountList[zone] = {["Preferred"] = {}, ["Excluded"] = {},}
for counter = 1,#GoGo_Prefs.MapIDs[zone]["Preferred"] do
ZoneMountList[zone]["Preferred"][GoGo_Prefs.MapIDs[zone]["Preferred"][counter]] = true
end
for counter = 1,#GoGo_Prefs.MapIDs[zone]["Excluded"] do
ZoneMountList[zone]["Excluded"][GoGo_Prefs.MapIDs[zone]["Excluded"][counter]] = true
end
end
end
end
---Updates the checkboxes on Collection Mount List to match GoGoMount set mounts
---------
local function UpdateMountList_Checkboxes()
---------
local scrollFrame = MountJournal.ListScrollFrame
local offset = HybridScrollFrame_GetOffset(scrollFrame)
local buttons = scrollFrame.buttons
local numMounts = C_MountJournal.GetNumMounts()
local showMounts = true
if ( numMounts < 1 ) then return end --If there are no mounts then nothing needs to be done.
local numDisplayedMounts = C_MountJournal.GetNumDisplayedMounts()
for i=1, #buttons do
local button = buttons[i]
local displayIndex = i + offset
if ( displayIndex <= numDisplayedMounts and showMounts ) then
local index = displayIndex
local _, spellID, _, _, isUsable,_, _, _, _, _, isCollected = C_MountJournal.GetDisplayedMountInfo(index)
if button.GGMM then
else
button.GGMM = init_button(button, i)
end
--Dont let mounts that are not able to be used be selected.
if isCollected then
button.GGMM.spellID = spellID
button.GGMM:SetChecked(false)
button.GGMM.tooltip = L.GLOBAL_CLEAR
if EnableZoneEdit then
button.GGMM.tooltip = L.ZONE_CLEAR
button.GGMM.text:SetText("Z:")
button.GGMM.text:Show()
ZoneMountList[selectedZone] = ZoneMountList[selectedZone] or {["Preferred"]={},["Excluded"]={}}
if ZoneMountList[selectedZone]["Preferred"][spellID]then
button.GGMM:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
button.GGMM:SetChecked(true)
button.GGMM.tooltip = L.ZONE_ENABLE
end
if ZoneMountList[selectedZone]["Excluded"][spellID] then
button.GGMM:SetCheckedTexture("Interface/Buttons/UI-GROUPLOOT-PASS-DOWN")
button.GGMM:SetChecked(true)
button.GGMM.tooltip = L.ZONE_EXCLUDE
end
elseif EnablePassengerEdit then
button.GGMM.text:SetText("P:")
button.GGMM.text:Show()
if ExtraPassengerMounts[spellID] then
button.GGMM:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
button.GGMM:SetChecked(true)
button.GGMM.tooltip = "Passeng"
end
else
button.GGMM.text:Hide()
if GlobalPrefs[spellID] then
button.GGMM:SetCheckedTexture("Interface/Buttons/UI-CheckBox-Check")
button.GGMM:SetChecked(true)
button.GGMM.tooltip = L.GLOBAL_ENABLE
end
if GlobalExclude[spellID] then
button.GGMM:SetCheckedTexture("Interface/Buttons/UI-GROUPLOOT-PASS-DOWN")
button.GGMM:SetChecked(true)
button.GGMM.tooltip = L.GLOBAL_EXCLUDE
end
end
button.GGMM:Show()
else
button.GGMM:Hide()
end
else
if button.GGMM then
button.GGMM:Hide()
end
end
end
local currentMapID = C_Map.GetBestMapForUnit("player")
--Sets status message
if EnableZoneEdit then
GGMM_ZONE_ALERT:SetText("Zone Based Settings")
elseif GoGo_Prefs.MapIDs[currentMapID] and (#GoGo_Prefs.MapIDs[currentMapID]["Preferred"] > 0 or #GoGo_Prefs.MapIDs[currentMapID]["Excluded"] > 0) then
GGMM_ZONE_ALERT:SetText("Zone has Favorite Overides")
else
GGMM_ZONE_ALERT:SetText("")
end
end
---------
function GoGoMount_Manager:UpdateCB()
---------
UpdateMountList_Checkboxes()
end
---------
function GoGoMount_Manager:SelectedZone()
---------
return selectedZone
end
--- Gets current Manager profile data and updates the GoGoMount saved variables to match
---------
local function UpdateGoGoMountPrefs()
---------
GoGo_Prefs.GlobalPrefMounts = {}
for id in pairs(GlobalPrefs) do
tinsert(GoGo_Prefs.GlobalPrefMounts,id)
end
GoGo_Prefs.GlobalExclude = {}
for id in pairs(GlobalExclude) do
tinsert(GoGo_Prefs.GlobalExclude,id)
end
GoGo_Prefs.ExtraPassengerMounts = {}
for id in pairs(ExtraPassengerMounts) do
tinsert(GoGo_Prefs.ExtraPassengerMounts,id)
end
GoGo_Prefs.MapIDs = {}
for zone, data in pairs(ZoneMountList) do
GoGo_Prefs.MapIDs[zone] = {["Preferred"] = {}, ["Excluded"] = {},}
for id in pairs(data["Preferred"]) do
tinsert(GoGo_Prefs.MapIDs[zone]["Preferred"],id)
end
for id in pairs(data["Excluded"]) do
tinsert(GoGo_Prefs.MapIDs[zone]["Excluded"],id)
end
end
end
---------
function GoGoMount_Manager:UpdateGoGoMountPrefs()
---------
UpdateGoGoMountPrefs()
end
---Ace based addon initilization
---------
function GoGoMount_Manager:OnInitialize()
---------
self.db = LibStub("AceDB-3.0"):New("GoGoMount_ManagerDB", defaults)
options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
LibStub("AceConfig-3.0"):RegisterOptionsTable("GoGoMount_Manager", options)
LibStub("AceConfig-3.0"):RegisterOptionsTable("GoGoMount_Manager_Zone", zone_options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("GoGoMount_Manager", "GoGoMount_Manager")
self.db.RegisterCallback(self, "OnProfileChanged", "ChangeProfile")
self.db.RegisterCallback(self, "OnProfileCopied", "ChangeProfile")
self.db.RegisterCallback(self, "OnProfileReset", "ResetProfile")
self.db.RegisterCallback(self, "OnNewProfile", "ResetProfile")
local LibDualSpec = LibStub('LibDualSpec-1.0')
LibDualSpec:EnhanceDatabase(self.db, "GoGoMount_Manager")
LibDualSpec:EnhanceOptions(options.args.profiles, self.db)
--Hooking GoGoMount funtions
self:SecureHook("GoGo_GlobalExcludeMount", GoGo_GlobalExcludeMount_update)
self:SecureHook("GoGo_ExtraPassengerMounts", GoGo_PassengerMount_update)
self:SecureHook("GoGo_GlobalPrefMount", GoGo_GlobalPrefMount_update)
self:SecureHook("GoGo_ZoneExcludeMount", GoGo_ZoneExcludeMount_update)
self:SecureHook("GoGo_ZonePrefMount", GoGo_ZonePrefMount_update)
end
---------
function GoGoMount_Manager:OnEnable()
---------
--Link local lists to profile data
GlobalPrefs = self.db.profile.GlobalPrefs or {}
GlobalExclude = self.db.profile.GlobalExclude or {}
ZoneMountList = self.db.profile.ZoneMountList or {}
ExtraPassengerMounts = self.db.profile.ExtraPassengerMounts or {}
GoGoMount_Manager:ToggleFixes(self.db.profile.UseFix)
GoGoMount_Manager:ToggleRandomizer(self.db.profile.ForceRandom)
self:SecureHook("GoGo_GetMountDB", "AddMissingMounts")
GoGo_GetMountDB()
GoGoMount_Manager:SyncPrefs()
--Hooking MountJournal functions
LoadAddOn("Blizzard_Collections")
self:SecureHook("MountJournal_UpdateMountList", UpdateMountList_Checkboxes)
self:SecureHook(MountJournal.ListScrollFrame,"update", UpdateMountList_Checkboxes)
GoGoMount_Manager:Build()
GoGoMount_Manager.JournalFilter:OnLogin()
GoGoMount_Manager.JournalFilter:LoadUI()
GoGoMount_Manager.JournalFilter:InitDropdown()
end
---Resets current profile
---------
function GoGoMount_Manager:ResetProfile()
---------
wipe(GoGoMount_Manager.db.profile)
GlobalPrefs = {}
GlobalExclude = {}
ZoneMountList = {}
ExtraPassengerMounts = {}
GoGoMount_Manager:SyncPrefs()
GoGoMount_Manager:UpdateCB()
end
--Updates mount list to be selected profile
---------
function GoGoMount_Manager:ChangeProfile()
---------
GlobalPrefs = self.db.profile.GlobalPrefs or {}
GlobalExclude = self.db.profile.GlobalExclude or {}
ZoneMountList = self.db.profile.ZoneMountList or {}
ExtraPassengerMounts = self.db.profile.ExtraPassengerMounts or {}
GoGoMount_Manager:SyncPrefs()
GoGoMount_Manager:UpdateCB()
end
---Syncs mount prefrence lists between GoGoMount & GoGoMount_Manager
---------
function GoGoMount_Manager:SyncPrefs()
---------
--if initial run rebuilds tables based on current GoGoMount selections
if GoGoMount_Manager.db.profile.init then
RefreshFromGoGoPrefs()
GoGoMount_Manager.db.profile.init = false
--sets GoGoMount selections to be what is stored in the profile.
else
UpdateGoGoMountPrefs()
end
end
--clears all global favorites
---------
function GoGoMount_Manager:ClearGlobalFav()
---------
GoGo_Prefs.GlobalPrefMounts = {}
RefreshFromGoGoPrefs()
UpdateMountList_Checkboxes()
end
--clears global exclusions
---------
function GoGoMount_Manager:ClearGlobalExclude()
---------
GoGo_Prefs.GlobalExclude = {}
RefreshFromGoGoPrefs()
UpdateMountList_Checkboxes()
end
--clears current zone favorites
---------
function GoGoMount_Manager:ClearZoneFavorites()
---------
GoGo_Prefs.MapIDs[selectedZone] = {["Preferred"] = {},["Excluded"] = {},}
RefreshFromGoGoPrefs()
UpdateMountList_Checkboxes()
end
--clears all zone favorites
---------
function GoGoMount_Manager:ClearAllZoneFavorites()
---------
wipe(GoGo_Prefs.MapIDs)
RefreshFromGoGoPrefs()
UpdateMountList_Checkboxes()
end
--Builds the menu frame for the Mount Journal
---------
function GoGoMount_Manager:Build()
---------
local f = CreateFrame('Frame', "GoGoMountManager_ZoneMenu", MountJournal)
f:SetClampedToScreen(true)
f:SetSize(250, 160)
f:SetPoint("TOPLEFT",MountJournal,"TOPRIGHT")
f:SetPoint("BOTTOMLEFT",MountJournal,"BOTTOMRIGHT")
f:Hide()
f:EnableMouse(true)
f:SetFrameStrata('HIGH')
f:SetMovable(false)
f:SetToplevel(true)
f.border = f:CreateTexture()
f.border:SetAllPoints()
f.border:SetColorTexture(0,0,0,1)
f.border:SetTexture([[Interface\Tooltips\UI-Tooltip-Background]])
f.border:SetDrawLayer('BORDER')
f.background = f:CreateTexture()
f.background:SetPoint('TOPLEFT', f, 'TOPLEFT', 1, -1)
f.background:SetPoint('BOTTOMRIGHT', f, 'BOTTOMRIGHT', 65, 1)
--f.background:SetColorTexture(0.1,0.1,0.1,1)
f.background:SetTexture("Interface\\PetBattles\\MountJournal-BG")
f.background:SetDrawLayer('ARTWORK')
local close_ = CreateFrame("Button", nil, f)
close_:SetNormalTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Up")
close_:SetPushedTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Down")
close_:SetHighlightTexture("Interface\\Buttons\\UI-Panel-MinimizeButton-Highlight", "ADD")
close_:SetSize(32, 32)
close_:SetPoint("TOPRIGHT", f, "TOPRIGHT", 0, 0)
close_:SetScript("OnClick", function(self)
self:GetParent():Hide()
self:GetParent().free = true
end)
f.close = close_
local content = CreateFrame("Frame",nil, f)
content:SetPoint("TOPLEFT",15,-15)
content:SetPoint("BOTTOMRIGHT",-15,15)
--This creats a cusomt AceGUI container which lets us imbed a AceGUI menu into our frame.
local widget = {
frame = f,
content = content,
type = "GGMMContainer"
}
widget["OnRelease"] = function(self)
self.status = nil
wipe(self.localstatus)
end
f:SetScript("OnShow", function(self)
selectedZone = C_Map.GetBestMapForUnit("player")
ZoneList = {[C_Map.GetBestMapForUnit("player")]=C_Map.GetMapInfo(C_Map.GetBestMapForUnit("player")).name}
selectedCont = nil
EnableZoneEdit = false
LibStub("AceConfigDialog-3.0"):Open("GoGoMount_Manager_Zone", widget, "zoneoptions")
f:Show()
end)
f:SetScript("OnHide", function(self)
selectedZone =C_Map.GetBestMapForUnit("player")
ZoneList = {[C_Map.GetBestMapForUnit("player")]=C_Map.GetMapInfo(C_Map.GetBestMapForUnit("player")).name}
selectedCont = nil
EnableZoneEdit = false
GoGoMount_Manager:UpdateCB()
f:Hide()
end)
LibStub("AceGUI-3.0"):RegisterAsContainer(widget)
local mountButton = CreateFrame("Button", nil , MountJournal)
mountButton:SetNormalTexture("Interface\\Buttons\\UI-MicroButton-Mounts-Up")
mountButton:SetPushedTexture("Interface\\Buttons\\UI-MicroButton-Mounts-Down")
mountButton:SetPoint("BOTTOMRIGHT", MountJournal, "BOTTOMRIGHT", 0, 0)
mountButton:SetWidth(30)
mountButton:SetHeight(45)
mountButton:SetScript("OnClick", function(self, button, down)
local Shift = IsShiftKeyDown()
if Shift then
selectedZone = C_Map.GetBestMapForUnit("player")
EnableZoneEdit = not EnableZoneEdit
GoGoMount_Manager:UpdateCB()
else
if f:IsShown() then
f:Hide()
else
f:Show()
end
end
end)
mountButton:SetScript("OnEnter",
function(self)
GameTooltip:SetOwner (self, "ANCHOR_RIGHT")
GameTooltip:SetText(L.GOGOMOUNT_BUTTON_TOOLTIP, 1, 1, 1)
GameTooltip:Show()