forked from LetsTimeIt/DungeonTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DungeonTools.lua
5290 lines (4858 loc) · 199 KB
/
DungeonTools.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
-- Made by Nnoggie, 2017-2020
local AddonName, MDT = ...
local L = MDT.L
local mainFrameStrata = "HIGH"
local canvasDrawLayer = "BORDER"
local twipe,tinsert,tremove,tgetn,CreateFrame,tonumber,pi,max,min,atan2,abs,pairs,ipairs,GetCursorPosition,GameTooltip = table.wipe,table.insert,table.remove,table.getn,CreateFrame,tonumber,math.pi,math.max,math.min,math.atan2,math.abs,pairs,ipairs,GetCursorPosition,GameTooltip
local SetPortraitTextureFromCreatureDisplayID,MouseIsOver = SetPortraitTextureFromCreatureDisplayID,MouseIsOver
local sizex = 840
local sizey = 555
local mythicColor = "|cFFFFFFFF"
MDT.BackdropColor = { 0.058823399245739, 0.058823399245739, 0.058823399245739, 0.9}
local AceGUI = LibStub("AceGUI-3.0")
local db
local icon = LibStub("LibDBIcon-1.0")
local LDB = LibStub("LibDataBroker-1.1"):NewDataObject("DungeonTools", {
type = "data source",
text = "Dungeon Tools",
icon = "Interface\\ICONS\\inv_relics_hourglass",
OnClick = function(button,buttonPressed)
if buttonPressed == "RightButton" then
if db.minimap.lock then
icon:Unlock("DungeonTools")
else
icon:Lock("DungeonTools")
end
else
MDT:ShowInterface()
end
end,
OnTooltipShow = function(tooltip)
if not tooltip or not tooltip.AddLine then return end
tooltip:AddLine(mythicColor .."Dungeon Tools|r")
tooltip:AddLine(L["Click to toggle AddOn Window"])
tooltip:AddLine(L["Right-click to lock Minimap Button"])
end,
})
SLASH_DUNGEONTOOLS1 = "/mplus"
SLASH_DUNGEONTOOLS2 = "/mdt"
SLASH_DUNGEONTOOLS3 = "/dungeontools"
BINDING_NAME_DungeonToolsToggle = L["Toggle Window"]
BINDING_NAME_DungeonToolsNPC = L["New NPC at Cursor Position"]
BINDING_NAME_DungeonToolsWaypoint = L["New Patrol Waypoint at Cursor Position"]
function SlashCmdList.DUNGEONTOOLS(cmd, editbox)
local rqst, arg = strsplit(' ', cmd)
if rqst == "devmode" then
MDT:ToggleDevMode()
elseif rqst == "reset" then
MDT:ResetMainFramePos()
elseif rqst == "dc" then
MDT:ToggleDataCollection()
elseif rqst == "hptrack" then
MDT:ToggleHealthTrack()
else
MDT:ShowInterface()
end
end
function MDT:GetLocaleIndex()
local localeToIndex = {
["enUS"] = 1,
["deDE"] = 2,
["esES"] = 3,
["esMX"] = 4,
["frFR"] = 5,
["itIT"] = 6,
["ptBR"] = 7,
["ruRU"] = 8,
["koKR"] = 9,
["zhCN"] = 10,
["zhTW"] = 11,
}
return localeToIndex[GetLocale()] or 1
end
local initFrames
-------------------------
--- Saved Variables ----
-------------------------
local defaultSavedVars = {
global = {
toolbarExpanded = true,
currentSeason = 5,
currentExpansion = 3,
scale = 1,
enemyForcesFormat = 2,
enemyStyle = 1,
currentDungeonIdx = 29,
currentDifficulty = 10,
xoffset = 0,
yoffset = -150,
defaultColor = "228b22",
anchorFrom = "TOP",
anchorTo = "TOP",
tooltipInCorner = false,
minimap = {
hide = false,
},
toolbar ={
color = {r=1,g=1,b=1,a=1},
brushSize = 3,
},
presets = {},
currentPreset = {},
dataCollectionActive = false,
colorPaletteInfo = {
autoColoring = true,
forceColorBlindMode = false,
colorPaletteIdx = 4,
customPaletteValues = {},
numberCustomColors = 12,
},
language = MDT:GetLocaleIndex(),
},
}
do
for i=1,37 do
defaultSavedVars.global.presets[i] = {
[1] = {text="Default",value={},colorPaletteInfo={autoColoring=true,colorPaletteIdx=4}},
[2] = {text="<New Preset>",value=0},
}
defaultSavedVars.global.currentPreset[i] = 1
end
end
-- Init db
do
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
--TODO Register Affix Changed event
frame:SetScript("OnEvent", function(self, event, ...)
return MDT[event](self,...)
end)
function MDT.ADDON_LOADED(self, addon)
if addon == "DungeonTools" then
db = LibStub("AceDB-3.0"):New("DungeonToolsDB", defaultSavedVars).global
icon:Register("DungeonTools", LDB, db.minimap)
if not db.minimap.hide then
icon:Show("DungeonTools")
end
--register AddOn Options
MDT:RegisterOptions()
self:UnregisterEvent("ADDON_LOADED")
end
end
local last = 0
function MDT.GROUP_ROSTER_UPDATE(self, addon)
--check not more than once per second (blizzard event spam)
local now = GetTime()
if last < now - 1 then
if not MDT.main_frame then return end
local inGroup = UnitInRaid("player") or IsInGroup()
MDT.main_frame.LinkToChatButton:SetDisabled(not inGroup)
MDT.main_frame.LiveSessionButton:SetDisabled(not inGroup)
if inGroup then
MDT.main_frame.LinkToChatButton.text:SetTextColor(1,0.8196,0)
if MDT.liveSessionActive then
MDT.main_frame.LiveSessionButton:SetText(L["*Live*"])
MDT.main_frame.LiveSessionButton.text:SetTextColor(0,1,0)
else
MDT.main_frame.LiveSessionButton:SetText(L["Live"])
MDT.main_frame.LiveSessionButton.text:SetTextColor(1,0.8196,0)
end
else
MDT.main_frame.LinkToChatButton.text:SetTextColor(0.5,0.5,0.5)
MDT.main_frame.LiveSessionButton.text:SetTextColor(0.5,0.5,0.5)
end
last = now
--MDT:RequestDataCollectionUpdate()
end
end
function MDT.PLAYER_ENTERING_WORLD(self, addon)
--initialize Blizzard_ChallengesUI
C_Timer.After(1,function()
LoadAddOn("Blizzard_ChallengesUI")
C_MythicPlus.RequestCurrentAffixes()
C_MythicPlus.RequestMapInfo()
C_MythicPlus.RequestRewards()
end)
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
end
MDT.mapInfo = {}
MDT.dungeonTotalCount = {}
MDT.scaleMultiplier = {}
--affixID as used in C_ChallengeMode.GetAffixInfo(affixID)
--https://www.wowhead.com/affixes
--lvl 4 affix, lvl 7 affix, tyrannical/fortified, seasonal affix
local affixWeeks = {
[1] = {[1]=11,[2]=3,[3]=10,[4]=121}, -->>Bursting, Volcanic, Fortified
[2] = {[1]=7,[2]=124,[3]=9,[4]=121}, -->>Bolstering, Storming, Tyrannical
[3] = {[1]=123,[2]=12,[3]=10,[4]=121}, -->>Spiteful, Grievous, Fortified
[4] = {[1]=122,[2]=4,[3]=9,[4]=121}, -->>Inspiring, Necrotic, Tyrannical
[5] = {[1]=8,[2]=14,[3]=10,[4]=121}, -->>Sanguine, Quaking, Fortified
[6] = {[1]=6,[2]=13,[3]=9,[4]=121}, -->>Raging, Explosive, Tyrannical
[7] = {[1]=123,[2]=3,[3]=10,[4]=121}, -->>Spiteful, Volcanic, Fortified
[8] = {[1]=7,[2]=4,[3]=9,[4]=121}, -->>Bolstering, Necrotic, Tyrannical
[9] = {[1]=122,[2]=124,[3]=10,[4]=121}, -->>Inspiring, Storming, Fortified
[10] = {[1]=11,[2]=13,[3]=9,[4]=121}, -->>Bursting, Explosive, Tyrannical
[11] = {[1]=8,[2]=12,[3]=10,[4]=121}, -->>Sanguine, Grievous, Fortified
[12] = {[1]=6,[2]=14,[3]=9,[4]=121}, -->>Raging, Quaking, Tyrannical
}
local dungeonList = {
[1] = L["Black Rook Hold"],
[2] = L["Cathedral of Eternal Night"],
[3] = L["Court of Stars"],
[4] = L["Darkheart Thicket"],
[5] = L["Eye of Azshara"],
[6] = L["Halls of Valor"],
[7] = L["Maw of Souls"],
[8] = L["Neltharion's Lair"],
[9] = L["Return to Karazhan Lower"],
[10] = L["Return to Karazhan Upper"],
[11] = L["Seat of the Triumvirate"],
[12] = L["The Arcway"],
[13] = L["Vault of the Wardens"],
[14] = " >"..L["Battle for Azeroth"],
[15] = L["Atal'Dazar"],
[16] = L["Freehold"],
[17] = L["Kings' Rest"],
[18] = L["Shrine of the Storm"],
[19] = L["Siege of Boralus"],
[20] = L["Temple of Sethraliss"],
[21] = L["The MOTHERLODE!!"],
[22] = L["The Underrot"],
[23] = L["Tol Dagor"],
[24] = L["Waycrest Manor"],
[25] = L["Mechagon - Junkyard"],
[26] = L["Mechagon - Workshop"],
[27] = " <"..L["Legion"],
[28] = " >"..L["Shadowlands"],
[29] = L["De Other Side"],
[30] = L["Halls of Atonement"],
[31] = L["Mists of Tirna Scithe"],
[32] = L["Plaguefall"],
[33] = L["Sanguine Depths"],
[34] = L["Spires of Ascension"],
[35] = L["The Necrotic Wake"],
[36] = L["Theater of Pain"],
[37] = " <"..L["Battle for Azeroth"],
}
function MDT:GetNumDungeons() return #dungeonList-1 end
function MDT:GetDungeonName(idx) return dungeonList[idx] end
local dungeonSubLevels = {
[1] = {
[1] = L["The Ravenscrypt"],
[2] = L["The Grand Hall"],
[3] = L["Ravenshold"],
[4] = L["The Rook's Host"],
[5] = L["Lord Ravencrest's Chamber"],
[6] = L["The Raven's Crown"],
},
[2] = {
[1] = L["Hall of the Moon"],
[2] = L["Twilight Grove"],
[3] = L["The Emerald Archives"],
[4] = L["Path of Illumination"],
[5] = L["Sacristy of Elune"],
},
[3] = {
[1] = L["Court of Stars Sublevel"],
[2] = L["The Jeweled Estate"],
[3] = L["The Balconies"],
},
[4] = {
[1] = L["Darkheart Thicket Sublevel"],
},
[5] = {
[1] = L["Eye of Azshara Sublevel"],
},
[6] = {
[1] = L["The High Gate"],
[2] = L["Field of the Eternal Hunt"],
[3] = L["Halls of Valor Sublevel"],
},
[7] = {
[1] = L["Helmouth Cliffs"],
[2] = L["The Hold"],
[3] = L["The Naglfar"],
},
[8] = {
[1] = L["Neltharion's Lair Sublevel"],
},
[9] = {
[1] = L["Master's Terrace"],
[2] = L["Opera Hall Balcony"],
[3] = L["The Guest Chambers"],
[4] = L["The Banquet Hall"],
[5] = L["Upper Livery Stables"],
[6] = L["The Servant's Quarters"],
},
[10] = {
[1] = L["Lower Broken Stair"],
[2] = L["Upper Broken Stair"],
[3] = L["The Menagerie"],
[4] = L["Guardian's Library"],
[5] = L["Library Floor"],
[6] = L["Upper Library"],
[7] = L["Gamesman's Hall"],
[8] = L["Netherspace"],
},
[11] = {
[1] = L["Seat of the Triumvirate Sublevel"],
},
[12] = {
[1] = L["The Arcway Sublevel"],
},
[13] = {
[1] = L["The Warden's Court"],
[2] = L["Vault of the Wardens Sublevel"],
[3] = L["Vault of the Betrayer"],
},
[15] = {
[1] = L["Atal'Dazar Sublevel"],
[2] = L["Sacrificial Pits"],
},
[16] = {
[1] = L["Freehold Sublevel"],
},
[17] = {
[1] = L["Kings' Rest Sublevel"],
},
[18] = {
[1] = L["Shrine of the Storm Sublevel"],
[2] = L["Storm's End"],
},
[19] = {
[1] = L["Siege of Boralus Sublevel"],
[2] = L["Siege of Boralus (Upstairs)"],
},
[20] = {
[1] = L["Temple of Sethraliss Sublevel"],
[2] = L["Atrium of Sethraliss"],
},
[21] = {
[1] = L["The MOTHERLODE!! Sublevel"],
},
[22] = {
[1] = L["The Underrot Sublevel"],
[2] = L["Ruin's Descent"],
},
[23] = {
[1] = L["Tol Dagor Sublevel1"],
[2] = L["The Drain"],
[3] = L["The Brig"],
[4] = L["Detention Block"],
[5] = L["Officer Quarters"],
[6] = L["Overseer's Redoubt"],
[7] = L["Overseer's Summit"],
},
[24] = {
[1] = L["The Grand Foyer"],
[2] = L["Upstairs"],
[3] = L["The Cellar"],
[4] = L["Catacombs"],
[5] = L["The Rupture"],
},
[25] = {
[1] = L["Mechagon Island"],
[2] = L["Mechagon Island (Tunnels)"],
},
[26] = {
[1] = L["The Robodrome"],
[2] = L["Waste Pipes"],
[3] = L["The Under Junk"],
[4] = L["Mechagon City"],
},
[29] = {
[1] = L["De Other Side"],
[2] = L["Mechagon"],
[3] = L["Zul'Gurub"],
[4] = L["Ardenweald"],
},
[30] = {
[1] = L["HallsOfAtonementFloor1"],
[2] = L["HallsOfAtonementFloor2"],
[3] = L["HallsOfAtonementFloor3"],
},
[31] = {
[1] = L["Mists of Tirna Scithe"],
},
[32] = {
[1] = L["Plaguefall"],
[2] = L["The Festering Sanctum"],
},
[33] = {
[1] = L["Sanguine DepthsFloor1"],
[2] = L["Sanguine DepthsFloor2"],
},
[34] = {
[1] = L["Honor's Ascent"],
[2] = L["Gardens of Repose"],
[3] = L["Font of Fealty"],
[4] = L["Seat of the Archon"],
},
[35] = {
[1] = L["TheNecroticWakeFloor1"],
[2] = L["TheNecroticWakeFloor2"],
[3] = L["TheNecroticWakeFloor3"],
},
[36] = {
[1] = L["TheaterOfPainFloor1"],
[2] = L["TheaterOfPainFloor2"],
[3] = L["TheaterOfPainFloor3"],
[4] = L["TheaterOfPainFloor4"],
[5] = L["TheaterOfPainFloor5"],
},
}
function MDT:GetDungeonSublevels()
return dungeonSubLevels
end
function MDT:GetSublevelName(dungeonIdx, sublevelIdx)
if not dungeonIdx then dungeonIdx = db.currentDungeonIdx end
return dungeonSubLevels[dungeonIdx][sublevelIdx]
end
MDT.dungeonMaps = {
[1] = {
[0]= "BlackRookHoldDungeon",
[1]= "BlackRookHoldDungeon1_",
[2]= "BlackRookHoldDungeon2_",
[3]= "BlackRookHoldDungeon3_",
[4]= "BlackRookHoldDungeon4_",
[5]= "BlackRookHoldDungeon5_",
[6]= "BlackRookHoldDungeon6_",
},
[2] = {
[0]= "TombofSargerasDungeon",
[1]= "TombofSargerasDungeon1_",
[2]= "TombofSargerasDungeon2_",
[3]= "TombofSargerasDungeon3_",
[4]= "TombofSargerasDungeon4_",
[5]= "TombofSargerasDungeon5_",
},
[3] = {
[0] = "SuramarNoblesDistrict",
[1] = "SuramarNoblesDistrict",
[2] = "SuramarNoblesDistrict1_",
[3] = "SuramarNoblesDistrict2_",
},
[4] = {
[0] = "DarkheartThicket",
[1] = "DarkheartThicket",
},
[5] = {
[0]= "AszunaDungeon",
[1]= "AszunaDungeon",
},
[6] = {
[0]= "Hallsofvalor",
[1]= "Hallsofvalor1_",
[2]= "Hallsofvalor",
[3]= "Hallsofvalor2_",
},
[7] = {
[0] = "HelheimDungeonDock",
[1] = "HelheimDungeonDock",
[2] = "HelheimDungeonDock1_",
[3] = "HelheimDungeonDock2_",
},
[8] = {
[0] = "NeltharionsLair",
[1] = "NeltharionsLair",
},
[9] = {
[0] = "LegionKarazhanDungeon",
[1] = "LegionKarazhanDungeon6_",
[2] = "LegionKarazhanDungeon5_",
[3] = "LegionKarazhanDungeon4_",
[4] = "LegionKarazhanDungeon3_",
[5] = "LegionKarazhanDungeon2_",
[6] = "LegionKarazhanDungeon1_",
},
[10] = {
[0] = "LegionKarazhanDungeon",
[1] = "LegionKarazhanDungeon7_",
[2] = "LegionKarazhanDungeon8_",
[3] = "LegionKarazhanDungeon9_",
[4] = "LegionKarazhanDungeon10_",
[5] = "LegionKarazhanDungeon11_",
[6] = "LegionKarazhanDungeon12_",
[7] = "LegionKarazhanDungeon13_",
[8] = "LegionKarazhanDungeon14_",
},
[11] = {
[0] = "ArgusDungeon",
[1] = "ArgusDungeon",
},
[12] = {
[0]= "SuamarCatacombsDungeon",
[1]= "SuamarCatacombsDungeon1_",
},
[13] = {
[0]= "VaultOfTheWardens",
[1]= "VaultOfTheWardens1_",
[2]= "VaultOfTheWardens2_",
[3]= "VaultOfTheWardens3_",
},
[15] = {
[0]= "CityOfGold",
[1]= "CityOfGold1_",
[2]= "CityOfGold2_",
},
[16] = {
[0]= "KulTirasPirateTownDungeon",
[1]= "KulTirasPirateTownDungeon",
},
[17] = {
[0] = "KingsRest",
[1] = "KingsRest1_"
},
[18] = {
[0] = "ShrineOfTheStorm",
[1] = "ShrineOfTheStorm",
[2] = "ShrineOfTheStorm1_",
},
[19] = {
[0] = "SiegeOfBoralus",
[1] = "SiegeOfBoralus",
[2] = "SiegeOfBoralus",
},
[20] = {
[0] = "TempleOfSethralissA",
[1] = "TempleOfSethralissA",
[2] = "TempleOfSethralissB",
},
[21] = {
[0] = "KezanDungeon",
[1] = "KezanDungeon",
},
[22] = {
[0] = "UnderrotExterior",
[1] = "UnderrotExterior",
[2] = "UnderrotInterior",
},
[23] = {
[0] = "PrisonDungeon",
[1] = "PrisonDungeon",
[2] = "PrisonDungeon1_",
[3] = "PrisonDungeon2_",
[4] = "PrisonDungeon3_",
[5] = "PrisonDungeon4_",
[6] = "PrisonDungeon5_",
[7] = "PrisonDungeon6_",
},
[24] = {
[0] = "Waycrest",
[1] = "Waycrest1_",
[2] = "Waycrest2_",
[3] = "Waycrest3_",
[4] = "Waycrest4_",
[5] = "Waycrest5_",
},
[25] = {
[0] = "MechagonDungeon",
[1] = "MechagonDungeonExterior",
[2] = "MechagonDungeonExterior",
},
[26] = {
[0] = "MechagonDungeon",
[1] = "MechagonDungeon1_",
[2] = "MechagonDungeon2_",
[3] = "MechagonDungeon3_",
[4] = "MechagonDungeon4_",
},
[29] = {
[0] = "DeOtherSide_Ardenweald",
[1] = "DeOtherSide_Main",
[2] = "DeOtherSide_Gnome",
[3] = "DeOtherSide_Hakkar",
[4] = "DeOtherSide_Ardenweald",
},
[30] = {
[0] = "HallsOfAtonement_A",
[1] = "HallsOfAttonementExterior",
[2] = "HallsOfAtonement_A",
[3] = "HallsOfAtonement_B",
},
[31] = {
[0] = "MistsOfTirneScithe",
[1] = "MistsOfTirneScithe",
},
[32] = {
[0] = "Plaguefall",
[1] = "Plaguefall",
[2] = "Plaguefall_B",
},
[33] = {
[0] = "SanguineDepths_A",
[1] = "SanguineDepths_A",
[2] = "SanguineDepths_B",
},
[34] = {
[0] = "SpiresOfAscension_A",
[1] = "SpiresOfAscension_A",
[2] = "SpiresOfAscension_B",
[3] = "SpiresOfAscension_C",
[4] = "SpiresOfAscension_D",
},
[35] = {
[0] = "NecroticWake_A",
[1] = "NecroticWake_Exterior",
[2] = "NecroticWake_A",
[3] = "NecroticWake_B",
},
[36] = {
[0] = "TheaterOfPain",
[1] = "TheaterOfPain",
[2] = "TheaterOfPain_Warlord",
[3] = "TheaterOfPain_Lich",
[4] = "TheaterOfPain_AbomTop",
[5] = "TheaterOfPain_AbomBot",
},
}
MDT.dungeonBosses = {}
MDT.dungeonEnemies = {}
MDT.mapPOIs = {}
function MDT:GetDB()
return db
end
local framesInitialized
function MDT:ImportFromLegacyMDT()
local mdtDb = LibStub("AceDB-3.0"):New("MythicDungeonToolsDB", defaultSavedVars).global
for dungeonIdx,presets in pairs(mdtDb.presets) do
if not db.presets[dungeonIdx] then
db.presets[dungeonIdx] = {}
end
local oldPresetLen = #db.presets[dungeonIdx]
local newPresetLen = #presets
-- Quick hack
db.presets[dungeonIdx][newPresetLen] = MDT:DeepCopy(db.presets[dungeonIdx][oldPresetLen])
local currentIdx = oldPresetLen
for _,preset in pairs(presets) do
if preset["text"] ~= "Default" and preset["text"] ~= "<New Preset>" then
db.presets[dungeonIdx][currentIdx] = MDT:DeepCopy(preset)
db.presets[dungeonIdx][currentIdx]["text"] = preset["text"].." (Imported)";
currentIdx = currentIdx + 1
end
end
end
db.Imported = true
end
function MDT:ShowInterface(force)
if not framesInitialized then initFrames() end
if not db.Imported then
MDT:ImportFromLegacyMDT()
end
MDT:SanitizePresets()
if self.main_frame:IsShown() and not force then
MDT:HideInterface()
else
self.main_frame:Show()
self.main_frame.HelpButton:Show()
self:CheckCurrentZone()
--edge case if user closed MDT window while in the process of dragging a corrupted blip
if self.draggedBlip then
if MDT.liveSessionActive then
MDT:LiveSession_SendCorruptedPositions(MDT:GetRiftOffsets())
end
self:UpdateMap()
self.draggedBlip = nil
end
MDT:UpdateBottomText()
end
end
function MDT:HideInterface()
self.main_frame:Hide()
self.main_frame.HelpButton:Hide()
end
function MDT:ToggleDevMode()
db.devMode = not db.devMode
ReloadUI()
end
function MDT:ToggleDataCollection()
db.dataCollectionActive = not db.dataCollectionActive
print(string.format("%sMDT|r: DataCollection %s. Reload Interface!", mythicColor,db.dataCollectionActive and "|cFF00FF00Enabled|r" or "|cFFFF0000Disabled|r"))
end
function MDT:ToggleHealthTrack()
MDT.DataCollection:InitHealthTrack()
print(string.format("%sMDT|r: HealthTrack %s.", mythicColor,"|cFF00FF00Enabled|r"))
end
function MDT:CreateMenu()
-- Close button
self.main_frame.closeButton = CreateFrame("Button", "MDTCloseButton", self.main_frame, "UIPanelCloseButton")
self.main_frame.closeButton:ClearAllPoints()
self.main_frame.closeButton:SetPoint("TOPRIGHT", self.main_frame.sidePanel, "TOPRIGHT", 0, 0)
self.main_frame.closeButton:SetScript("OnClick", function() self:HideInterface() end)
self.main_frame.closeButton:SetFrameLevel(4)
--Maximize Button
self.main_frame.maximizeButton = CreateFrame("Button", "MDTMaximizeButton", self.main_frame, "MaximizeMinimizeButtonFrameTemplate")
self.main_frame.maximizeButton:ClearAllPoints()
self.main_frame.maximizeButton:SetPoint("RIGHT", self.main_frame.closeButton, "LEFT", 0, 0)
self.main_frame.maximizeButton:SetFrameLevel(4)
db.maximized = db.maximized or false
if not db.maximized then self.main_frame.maximizeButton:Minimize() end
self.main_frame.maximizeButton:SetOnMaximizedCallback(self.Maximize)
self.main_frame.maximizeButton:SetOnMinimizedCallback(self.Minimize)
--return to live preset
self.main_frame.liveReturnButton = CreateFrame("Button", "MDTLiveReturnButton", self.main_frame, "UIPanelCloseButton")
local liveReturnButton = self.main_frame.liveReturnButton
liveReturnButton:ClearAllPoints()
liveReturnButton:SetPoint("RIGHT", self.main_frame.topPanel, "RIGHT", 0, 0)
liveReturnButton.Icon = liveReturnButton:CreateTexture(nil, "OVERLAY")
liveReturnButton.Icon:SetTexture("Interface\\Buttons\\UI-RefreshButton")
liveReturnButton.Icon:SetSize(16,16)
liveReturnButton.Icon:SetTexCoord(1, 0, 0, 1) --flipped image
liveReturnButton.Icon:SetPoint("CENTER",liveReturnButton,"CENTER")
liveReturnButton:SetScript("OnClick", function() self:ReturnToLivePreset() end)
liveReturnButton:SetFrameLevel(4)
liveReturnButton.tooltip = L["Return to the live preset"]
--set preset as new live preset
self.main_frame.setLivePresetButton = CreateFrame("Button", "MDTSetLivePresetButton", self.main_frame, "UIPanelCloseButton")
local setLivePresetButton = self.main_frame.setLivePresetButton
setLivePresetButton:ClearAllPoints()
setLivePresetButton:SetPoint("RIGHT", liveReturnButton, "LEFT", 0, 0)
setLivePresetButton.Icon = setLivePresetButton:CreateTexture(nil, "OVERLAY")
setLivePresetButton.Icon:SetTexture("Interface\\ChatFrame\\ChatFrameExpandArrow")
setLivePresetButton.Icon:SetSize(16,16)
setLivePresetButton.Icon:SetPoint("CENTER",setLivePresetButton,"CENTER")
setLivePresetButton:SetScript("OnClick", function() self:SetLivePreset() end)
setLivePresetButton:SetFrameLevel(4)
setLivePresetButton.tooltip = L["Make this preset the live preset"]
self:SkinMenuButtons()
--Resize Handle
self.main_frame.resizer = CreateFrame("BUTTON", nil, self.main_frame.sidePanel)
local resizer = self.main_frame.resizer
resizer:SetPoint("BOTTOMRIGHT", self.main_frame.sidePanel,"BOTTOMRIGHT",7,-7)
resizer:SetSize(25, 25)
resizer:EnableMouse()
resizer:SetScript("OnMouseDown", function()
self.main_frame:StartSizing("BOTTOMRIGHT")
self:StartScaling()
self:HideAllPresetObjects()
self:ReleaseHullTextures()
self.main_frame:SetScript("OnSizeChanged", function()
local height = self.main_frame:GetHeight()
self:SetScale(height/sizey)
end)
end)
resizer:SetScript("OnMouseUp", function()
self.main_frame:StopMovingOrSizing()
self:UpdateEnemyInfoFrame()
self:UpdateMap()
self:CreateTutorialButton(self.main_frame)
self.main_frame:SetScript("OnSizeChanged", function() end)
end)
local normal = resizer:CreateTexture(nil, "OVERLAY")
normal:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up")
normal:SetTexCoord(0, 1, 0, 1)
normal:SetPoint("BOTTOMLEFT", resizer, 0, 6)
normal:SetPoint("TOPRIGHT", resizer, -6, 0)
resizer:SetNormalTexture(normal)
local pushed = resizer:CreateTexture(nil, "OVERLAY")
pushed:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down")
pushed:SetTexCoord(0, 1, 0, 1)
pushed:SetPoint("BOTTOMLEFT", resizer, 0, 6)
pushed:SetPoint("TOPRIGHT", resizer, -6, 0)
resizer:SetPushedTexture(pushed)
local highlight = resizer:CreateTexture(nil, "OVERLAY")
highlight:SetTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight")
highlight:SetTexCoord(0, 1, 0, 1)
highlight:SetPoint("BOTTOMLEFT", resizer, 0, 6)
highlight:SetPoint("TOPRIGHT", resizer, -6, 0)
resizer:SetHighlightTexture(highlight)
end
function MDT:SkinMenuButtons()
--attempt to skin close button for ElvUI
if IsAddOnLoaded("ElvUI") then
local E, L, V, P, G = unpack(ElvUI)
local S
if E then S = E:GetModule("Skins") end
if S then
S:HandleCloseButton(self.main_frame.closeButton)
S:HandleMaxMinFrame(self.main_frame.maximizeButton)
S:HandleButton(self.main_frame.liveReturnButton)
self.main_frame.liveReturnButton:Size(26)
--self.main_frame.liveReturnButton.Icon:SetVertexColor(0,1,1,1)
S:HandleButton(self.main_frame.setLivePresetButton)
self.main_frame.setLivePresetButton:Size(26)
self.main_frame.setLivePresetButton.Icon:SetVertexColor(1, .82, 0, 0.8)
end
end
end
---GetDefaultMapPanelSize
function MDT:GetDefaultMapPanelSize()
return sizex,sizey
end
---GetScale
---Returns scale factor stored in db
function MDT:GetScale()
if not db.scale then db.scale = 1 end
return db.scale
end
local oldScrollValues = {}
---StartScaling
---Stores values when we start scaling the frame
function MDT:StartScaling()
local f = self.main_frame
oldScrollValues.oldScrollH = f.scrollFrame:GetHorizontalScroll()
oldScrollValues.oldScrollV = f.scrollFrame:GetVerticalScroll()
oldScrollValues.oldSizeX = f.scrollFrame:GetWidth()
oldScrollValues.oldSizeY = f.scrollFrame:GetHeight()
HelpPlate_Hide(true)
self:DungeonEnemies_HideAllBlips()
self:POI_HideAllPoints()
self:KillAllAnimatedLines()
end
---SetScale
---Scales the map frame and it's sub frames to a factor and stores the scale in db
function MDT:SetScale(scale)
local f = self.main_frame
local newSizex = sizex*scale
local newSizey = sizey*scale
f:SetSize(newSizex,newSizey)
f.scrollFrame:SetSize(newSizex, newSizey)
f.mapPanelFrame:SetSize(newSizex, newSizey)
for i=1,12 do
f["mapPanelTile"..i]:SetSize((newSizex/4+5*scale),(newSizex/4+5*scale))
end
for i=1,10 do
for j=1,15 do
f["largeMapPanelTile"..i..j]:SetSize(newSizex/15,newSizex/15)
end
end
f.scrollFrame:SetVerticalScroll(oldScrollValues.oldScrollV * (newSizey / oldScrollValues.oldSizeY))
f.scrollFrame:SetHorizontalScroll(oldScrollValues.oldScrollH * (newSizex / oldScrollValues.oldSizeX))
f.scrollFrame.cursorY = f.scrollFrame.cursorY * (newSizey / oldScrollValues.oldSizeY)
f.scrollFrame.cursorX = f.scrollFrame.cursorX * (newSizex / oldScrollValues.oldSizeX)
self:ZoomMap(0)
db.scale = scale
db.nonFullscreenScale = scale
end
function MDT:GetFullScreenSizes()
local newSizey = GetScreenHeight()-60 --top and bottom panel 30 each
local newSizex = newSizey*(sizex/sizey)
local isNarrow
if newSizex+251>GetScreenWidth() then --251 sidebar
newSizex = GetScreenWidth()-251
newSizey = newSizex*(sizey/sizex)
isNarrow = true
end
local scale = newSizey/sizey --use this for adjusting NPC / POI positions later
return newSizex, newSizey, scale, isNarrow
end
---Maximize
---FULLSCREEN the UI
function MDT:Maximize()
local f = MDT.main_frame
local oldScrollH = f.scrollFrame:GetHorizontalScroll()
local oldScrollV = f.scrollFrame:GetVerticalScroll()
local oldSizeX = f.scrollFrame:GetWidth()
local oldSizeY = f.scrollFrame:GetHeight()
if not f.blackoutFrame then
f.blackoutFrame = CreateFrame("Frame", "MDTBlackoutFrame", f)
f.blackoutFrame:EnableMouse(true)
f.blackoutFrameTex = f.blackoutFrame:CreateTexture(nil, "BACKGROUND")
f.blackoutFrameTex:SetAllPoints()
f.blackoutFrameTex:SetDrawLayer(canvasDrawLayer, -6)
f.blackoutFrameTex:SetColorTexture(0.058823399245739,0.058823399245739,0.058823399245739,1)
f.blackoutFrame:ClearAllPoints()
f.blackoutFrame:SetAllPoints(UIParent)
end
f.blackoutFrame:Show()
f.topPanel:RegisterForDrag(nil)
f.bottomPanel:RegisterForDrag(nil)
local newSizex, newSizey, scale, isNarrow = MDT:GetFullScreenSizes()
db.scale = scale
f:ClearAllPoints()
if not isNarrow then
f:SetPoint("TOP", UIParent,"TOP", -(f.sidePanel:GetWidth()/2), -30)
else
f:SetPoint("LEFT", UIParent,"LEFT")
end
f:SetSize(newSizex,newSizey)
f.scrollFrame:SetSize(newSizex, newSizey)
f.mapPanelFrame:SetSize(newSizex, newSizey)
for i=1,12 do
f["mapPanelTile"..i]:SetSize((newSizex/4+5*db.scale),(newSizex/4+5*db.scale))
end
for i=1,10 do
for j=1,15 do
f["largeMapPanelTile"..i..j]:SetSize(newSizex/15,newSizex/15)
end
end
f.scrollFrame:SetVerticalScroll(oldScrollV * (newSizey / oldSizeY))
f.scrollFrame:SetHorizontalScroll(oldScrollH * (newSizex / oldSizeX))
f.scrollFrame.cursorY = f.scrollFrame.cursorY * (newSizey / oldSizeY)
f.scrollFrame.cursorX = f.scrollFrame.cursorX * (newSizex / oldSizeX)
MDT:ZoomMap(0)
MDT:UpdateEnemyInfoFrame()
MDT:UpdateMap()
if db.devMode then
f.devPanel:ClearAllPoints()
f.devPanel:SetPoint("TOPLEFT",f,"TOPLEFT",0,-45)
end
f.resizer:Hide()
MDT:CreateTutorialButton(MDT.main_frame)
db.maximized = true
end
---Minimize
---Restore normal UI
function MDT:Minimize()
local f = MDT.main_frame
local oldScrollH = f.scrollFrame:GetHorizontalScroll()
local oldScrollV = f.scrollFrame:GetVerticalScroll()
local oldSizeX = f.scrollFrame:GetWidth()
local oldSizeY = f.scrollFrame:GetHeight()
if f.blackoutFrame then f.blackoutFrame:Hide() end
f.topPanel:RegisterForDrag("LeftButton")
f.bottomPanel:RegisterForDrag("LeftButton")
db.scale = db.nonFullscreenScale
local newSizex = sizex*db.scale
local newSizey = sizey*db.scale
f:ClearAllPoints()
f:SetPoint(db.anchorTo, UIParent,db.anchorFrom, db.xoffset, db.yoffset)
f:SetSize(newSizex,newSizey)
f.scrollFrame:SetSize(newSizex, newSizey)
f.mapPanelFrame:SetSize(newSizex, newSizey)
for i=1,12 do
f["mapPanelTile"..i]:SetSize(newSizex/4+(5*db.scale),newSizex/4+(5*db.scale))
end
for i=1,10 do
for j=1,15 do
f["largeMapPanelTile"..i..j]:SetSize(newSizex/15,newSizex/15)
end
end
f.scrollFrame:SetVerticalScroll(oldScrollV * (newSizey / oldSizeY))
f.scrollFrame:SetHorizontalScroll(oldScrollH * (newSizex / oldSizeX))
f.scrollFrame.cursorY = f.scrollFrame.cursorY * (newSizey / oldSizeY)
f.scrollFrame.cursorX = f.scrollFrame.cursorX * (newSizex / oldSizeX)
MDT:ZoomMap(0)
MDT:UpdateEnemyInfoFrame()
MDT:UpdateMap()
if db.devMode then
f.devPanel:ClearAllPoints()
f.devPanel:SetPoint("TOPRIGHT",f.topPanel,"TOPLEFT",0,0)
end
f.resizer:Show()
MDT:CreateTutorialButton(MDT.main_frame)
db.maximized = false
end
function MDT:SkinProgressBar(progressBar)
local bar = progressBar and progressBar.Bar
if not bar then return end
bar.Icon:Hide()
bar.IconBG:Hide()
if IsAddOnLoaded("ElvUI") then
local E, L, V, P, G = unpack(ElvUI)