- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodAltManager.lua
More file actions
Latest commit
1581 lines (1437 loc) · 49.9 KB
/
Copy pathMethodAltManager.lua
File metadata and controls
1581 lines (1437 loc) · 49.9 KB
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
local_, AltManager=...
_G["AltManager"] =AltManager
-- Made by: Qooning - Tarren Mill <Method>, 2017-2018
localsizey=220
localinstances_y_add=1
localitems_y_add=1
localcurrencies_y_add=1
localxoffset=0
localyoffset=150
localalpha=1
localaddon="MethodAltManager"
localnumel=table.getn
localAurora=_G.Aurora
localper_alt_x=120
localmin_x_size=300
localmin_level=50
localname_label="Name"
localmythic_done_label="Highest M+ done"
localmythic_keystone_label="Keystone"
localseals_owned_label="Seals owned"
localseals_bought_label="Seals obtained"
localazerite_label="Heart of Azeroth"
localdepleted_label="Depleted"
localVERSION="@project-version@"
localfavoriteTier=EJ_GetNumTiers()
localfunctionformat_table_impl (table, out, indent, visited)
indent=indentor2-- indentation level for current table
visited=visitedor {} -- visited tables, avoid infinite recursion
visited[table] =true-- mark current table as visited
out[#out+1] =format('%s {\n', tostring(table))
fork,vinpairs(table) do
out[#out+1] =format('%s%s = ', string.rep('',indent), tostring(k))
iftype(v) =='table' then
ifvisited[v] then
out[#out+1] =format('%s { already shown }\n', tostring(v))
else
format_table_impl (v, out, indent+2, visited)
end
else
out[#out+1] =format('%s\n', tostring(v))
end
end
out[#out+1] =format('%s},\n', string.rep('', indent-2))
end
functionformat_table(t)
localout= {}
format_table_impl(t, out)
returntable.concat(out)
end
functionprint_table(table)
DEFAULT_CHAT_FRAME:AddMessage(format_table(table))
end
functiontablelength(T)
localcount=0
for_inpairs(T) docount=count+1end
returncount
end
-- Mythic+ Dungeons
localdungeons= {}
localBfAWorldBosses= {
--[BossID] = QuestID
[2139] =52181, -- T'zane
[2141] =52169, -- Ji'arak
[2197] =52157, -- Hailstone Construct
[2212] =52848, -- The Lion's Roar (Horde)
[2199] =52163, -- Azurethos, The Winged Typhoon
[2198] =52166, -- Warbringer Yenajz
[2210] =52196, -- Dunegorger Kraulok
[2213] =52847, -- Doom's Howl (Alliance)
}
localraids= {}
SLASH_METHODALTMANAGER1="/mam"
SLASH_METHODALTMANAGER2="/alts"
localfunctionspairs(t, order)
localkeys= {}
forkinpairs(t) dokeys[#keys+1] =kend
iforderthen
table.sort(keys, function(a,b) returnorder(t, a, b) end)
else
table.sort(keys)
end
locali=0
returnfunction()
i=i+1
ifkeys[i] then
returnkeys[i], t[keys[i]]
end
end
end
functionSlashCmdList.METHODALTMANAGER(cmd, editbox)
localrqst, arg=strsplit('', cmd)
ifrqst=="help" then
print("Method Alt Manager help:")
print("\"/alts purge\" to remove all stored data.")
print("\"/alts remove name\" to remove characters by name.")
elseifrqst=="purge" then
AltManager:Purge()
elseifrqst=="remove" then
AltManager:RemoveCharactersByName(arg)
else
AltManager:ShowInterface()
end
end
do
localmain_frame=CreateFrame("frame", "AltManagerFrame", UIParent)
AltManager.main_frame=main_frame
main_frame:SetFrameStrata("MEDIUM")
main_frame.background=main_frame:CreateTexture(nil, "BACKGROUND")
main_frame.background:SetAllPoints()
main_frame.background:SetDrawLayer("ARTWORK", 1)
main_frame.background:SetColorTexture(0, 0, 0, 0.5)
main_frame.scan_tooltip=CreateFrame('GameTooltip', 'DepletedTooltipScan', UIParent, 'GameTooltipTemplate')
-- Set frame position
main_frame:ClearAllPoints()
main_frame:SetPoint("CENTER", UIParent, "CENTER", xoffset, yoffset)
main_frame:RegisterEvent("ADDON_LOADED")
main_frame:RegisterEvent("PLAYER_LOGIN")
main_frame:RegisterEvent("QUEST_TURNED_IN")
main_frame:RegisterEvent("BAG_UPDATE_DELAYED")
main_frame:RegisterEvent("AZERITE_ITEM_EXPERIENCE_CHANGED")
main_frame:RegisterEvent("CHAT_MSG_CURRENCY")
main_frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
main_frame:SetScript("OnEvent", function(self, ...)
localevent, loaded=...
ifevent=="ADDON_LOADED" then
ifaddon==loadedthen
AltManager:OnLoad()
end
end
ifevent=="PLAYER_LOGIN" then
AltManager:OnLogin()
AltManager:MainOptionsInit()
AltManager:MAMO_CURR_INIT()
AltManager:MAMO_ITEMS_INIT()
end
ifevent=="AZERITE_ITEM_EXPERIENCE_CHANGED" then
localdata=AltManager:CollectData()
AltManager:StoreData(data)
end
if (event=="BAG_UPDATE_DELAYED" orevent=="QUEST_TURNED_IN" orevent=="CHAT_MSG_CURRENCY" orevent=="CURRENCY_DISPLAY_UPDATE") and (AltManager.addon_loadedandAltManager.player_ready) then
localdata=AltManager:CollectData()
AltManager:StoreData(data)
end
end)
-- Show Frame
main_frame:Hide()
end
functionAltManager:InitDB()
localt= {}
t.alts=0
returnt
end
-- because of guid...
functionAltManager:OnLogin()
self:GenerateDungeonTable()
self.CurrencyTable=self:GenerateCurrencyTable()
self:ValidateSchema()
self:ValidateReset()
self:StoreData(self:CollectData())
localalts=MethodAltManagerDB.alts
AltManager:CreateMenu()
self.main_frame.background:SetAllPoints()
-- Create menus
AltManager:MakeTopBottomTextures(self.main_frame)
AltManager:MakeBorder(self.main_frame, 5)
self.player_ready=true
end
functionAltManager:OnLoad()
self.main_frame:UnregisterEvent("ADDON_LOADED")
tinsert(UISpecialFrames,"AltManagerFrame")
MethodAltManagerDB=MethodAltManagerDBorself:InitDB()
C_MythicPlus.RequestRewards()
C_MythicPlus.RequestCurrentAffixes()
C_MythicPlus.RequestMapInfo()
fork,vinpairs(dungeons) do
-- request info in advance
C_MythicPlus.RequestMapInfo(k)
end
self.addon_loaded=true
end
functionAltManager:CreateFontFrame(parent, x_size, height, relative_to, y_offset, label, justify, tooltip)
localf=CreateFrame("Button", nil, parent)
f:SetSize(x_size, height)
f:SetNormalFontObject(GameFontHighlightSmall)
f:SetText(label)
f:SetPoint("TOPLEFT", relative_to, "TOPLEFT", 0, y_offset)
f:GetFontString():SetJustifyH(justify)
f:GetFontString():SetJustifyV("CENTER")
f:SetPushedTextOffset(0, 0)
f:GetFontString():SetWidth(120)
f:GetFontString():SetHeight(20)
f:SetFrameLevel(parent:GetFrameLevel()+2)
iftooltipthen
f:SetScript('OnEnter', tooltip)
f:SetScript('OnLeave', function(self)
GameTooltip:Hide()
end)
end
returnf
end
functionAltManager:ShowTooltip()
ifMethodAltManagerDB.optionsandMethodAltManagerDB.options.tooltipsandMethodAltManagerDB.options.tooltips.valuethen
returntrue
else
returnfalse
end
end
functionAltManager:Keyset()
localkeyset= {}
ifMethodAltManagerDBandMethodAltManagerDB.datathen
forkinpairs(MethodAltManagerDB.data) do
table.insert(keyset, k)
end
end
returnkeyset
end
-- Use API to generate dungeons-table
functionAltManager:GenerateDungeonTable()
localtempMapTable= {}
localemptyTable=true
localAPITable=C_ChallengeMode.GetMapTable()
for_, kinpairs(APITable) do
localname=C_ChallengeMode.GetMapUIInfo(k)
localshortHand=name:gsub("(%a)([%w_']*)", "%1"):gsub("%s+", "")
table.insert(tempMapTable, k, shortHand)
emptyTable=false
end
ifnotemptyTablethen
dungeons=tempMapTable
end
end
-- Use API to generate currency-table
functionAltManager:GenerateCurrencyTable()
localtempCurrencyTable= {}
fori=1,10000do
localcurrency=C_CurrencyInfo.GetCurrencyInfo(i)
ifcurrencyandcurrency.discoveredthen
tempCurrencyTable[i] = {
["label"] =currency.name,
["count"] =currency.quantity,
["earned"] =currency.quantityEarnedThisWeek,
["weekly"] =currency.maxWeeklyQuantity,
["total"] =currency.maxQuantity
}
end
end
returntempCurrencyTable
end
functionfilterCurrencies(curr)
localFilteredList= {}
localcurrency_list=MethodAltManagerDB.options.currencies
if (currency_list) then
forcid, cobjinpairs(currency_list) do
if(curr[cid]) then
FilteredList[cid] = {
["label"] =curr[cid].label,
["order"] =currency_list[cid]["order"],
["count"] =curr[cid].count,
["earned"] =curr[cid].earned,
["weekly"] =curr[cid].weekly,
["total"] =curr[cid].total
}
else
localname, currentAmount, texture, earnedThisWeek, weeklyMax, totalMax, isDiscovered, rarity=C_CurrencyInfo.GetCurrencyInfo(cid)
FilteredList[cid] = {
["label"] =name,
["order"] =currency_list[cid]["order"],
["count"] =nil,
["earned"] =nil,
["weekly"] =weeklyMax,
["total"] =totalMax
}
end
end
end
returnFilteredList
end
functionfilterItems(items)
localFilteredList= {}
if (items) then
forcid, cobjinpairs(items) do
if(cobj.orderandnot (cobj.order==math.huge)) then
FilteredList[cid] =cobj
end
end
end
returnFilteredList
end
functionCopyItemTable(items)
localList= {}
if (items) then
forcid, cobjinpairs(items) do
List[cid] = {
["label"] =cobj.label
}
end
end
returnList
end
functionAltManager:GenerateRaidData()
-- Select the latest tier
EJ_SelectTier(favoriteTier)
localraidData= {}
ifEJ_GetCurrentTier() ==favoriteTierthen
localraid= {}
localinstanceIdx=1
localbossIdx=1
-- Get raid instance from latest tier
localinstanceID, instanceName=EJ_GetInstanceByIndex(instanceIdx, true)
whileinstanceIDdo
raid["id"] =instanceID
raid["label"] =instanceName
raid["order"] =instanceIdx
raid["killed"] =nil
local_, _, bossID=EJ_GetEncounterInfoByIndex(bossIdx, instanceID)
whilebossIDdo
bossIdx=bossIdx+1
_, _, bossID=EJ_GetEncounterInfoByIndex(bossIdx, instanceID)
end
raid["bosses"] =bossIdx-1
raid["data"] =function(alt_data, i) returnself:MakeRaidString(alt_data.savedins, i) end
raidData[instanceID] =raid
raid= {}
bossIdx=1
instanceIdx=instanceIdx+1
instanceID, instanceName=EJ_GetInstanceByIndex(instanceIdx, true)
end
end
raids[favoriteTier] =raidData
end
functionAltManager:ValidateSchema()
localdb=MethodAltManagerDB
ifnotdbthenreturnend
ifnotdb.datathenreturnend
localkeyset= {}
forkinpairs(db.data) do
table.insert(keyset, k)
end
foralt=1, db.altsdo
localschema_version=db.data[keyset[alt]].version
localchar_table=db.data[keyset[alt]]
ifnotschema_versionthen
print('MethodAltManager - Old Character Schema found for '..char_table.name..'. Updating')
char_table.mplus= {
key= {
["dungeon"] =char_table.dungeon,
["level"] =char_table.level
},
highest_mplus=char_table.highest_mplus
}
char_table.dungeon=nil
char_table.level=nil
char_table.highest_mplus=nil
char_table.version=VERSION
end
end
end
functionAltManager:ValidateReset()
localdb=MethodAltManagerDB
ifnotdbthenreturnend
ifnotdb.datathenreturnend
localkeyset= {}
forkinpairs(db.data) do
table.insert(keyset, k)
end
foralt=1, db.altsdo
localexpiry=db.data[keyset[alt]].expiresor0
localchar_table=db.data[keyset[alt]]
iftime() >expirythen
-- reset this alt
char_table.seals_bought=0
localreward=char_table.mplus.highest_mplus>0
char_table.mplus= {
key= {
["dungeon"] ="Unknown",
["level"] ="?"
},
highest_mplus=0,
reward=reward
}
char_table.expires=self:GetNextWeeklyResetTime()
char_table.savedins= {}
ifnotchar_table.heart_of_azeroththenelse
char_table.heart_of_azeroth.weekly=false
end
end
end
end
functionAltManager:Purge()
MethodAltManagerDB=self:InitDB()
end
functionAltManager:RemoveCharactersByName(name)
localdb=MethodAltManagerDB
localindices= {}
forguid, datainpairs(db.data) do
ifdb.data[guid].name==namethen
indices[#indices+1] =guid
end
end
db.alts=db.alts-#indices
fori=1,#indicesdo
db.data[indices[i]] =nil
end
print("MAM - Found " .. (#indices) .." characters by the name of " ..name)
self:DynamicUIReload()
end
functionAltManager:StoreData(data)
ifnotself.addon_loadedthen
return
end
-- This can happen shortly after logging in, the game doesn't know the characters guid yet
ifnotdataornotdata.guidthen
return
end
ifUnitLevel('player') <min_levelthenreturnend
localdb=MethodAltManagerDB
localguid=data.guid
db.data=db.dataor {}
db.options=db.optionsor {}
db.options.currencies=db.options.currenciesor {}
db.options.items=db.options.itemsor {}
localupdate=false
fork, vinpairs(db.data) do
ifk==guidthen
update=true
end
end
ifnotupdatethen
db.data[guid] =data
db.alts=db.alts+1
else
db.data[guid] =data
end
end
functionAltManager:StoreOptions(data)
ifnotAltManager.addon_loadedthen
return
end
-- This can happen shortly after logging in, the game doesn't know the characters guid yet
ifnotdatathen
return
end
localdb=MethodAltManagerDB
localcurr=data.currencies
db.data=db.dataor {}
db.options=db.optionsor {}
db.options.currencies=db.options.currenciesor {}
db.options.currencies=curr
self:DynamicUIReload()
end
functionAltManager:DynamicUIReload()
self.main_frame:Hide()
self:StoreData(self:CollectData())
self:CreateLabels()
self.main_frame:Show()
end
functionAltManager:CollectData()
ifUnitLevel('player') <min_levelthenreturnend
localname=UnitName('player')
local_, class=UnitClass('player')
localdungeon=nil
localexpire=nil
locallevel=nil
localseals=nil
localseals_bought=nil
localmplus= { key= { } }
localhighest_mplus=0
localdepleted=false
localitems=nil
localguid=UnitGUID('player')
localmine_old=nil
localoptions=nil
ifMethodAltManagerDBandMethodAltManagerDB.datathen
mine_old=MethodAltManagerDB.data[guid]
end
ifMethodAltManagerDBandMethodAltManagerDB.optionsthen
options=MethodAltManagerDB.options
ifoptions.itemsthen
items=CopyItemTable(options.items)
end
end
C_MythicPlus.RequestRewards()
locall, cR, nR=C_MythicPlus.GetWeeklyChestRewardLevel()
iflandl>highest_mplusthen
highest_mplus=l
end
localchallengeMapID=C_MythicPlus.GetOwnedKeystoneChallengeMapID()
localreward=C_MythicPlus.IsWeeklyRewardAvailable()
dungeon=challengeMapIDandC_ChallengeMode.GetMapUIInfo(challengeMapID) or"Unknown"
level=C_MythicPlus.GetOwnedKeystoneLevel() or'?'
-- find keystone
localkeystone_found=false
forcontainer=BACKPACK_CONTAINER, NUM_BAG_SLOTSdo
localslots=GetContainerNumSlots(container)
forslot=1, slotsdo
local_, itemCount, _, _, _, _, slotLink, _, _, slotItemID=GetContainerItemInfo(container, slot)
--[[ if slotItemID == 158923 then
local itemString = slotLink:match("|Hkeystone:([0-9:]+)|h(%b[])|h")
local info = { strsplit(":", itemString) }
-- scan tooltip for depleted
self.main_frame.scan_tooltip:SetOwner(UIParent, 'ANCHOR_NONE')
self.main_frame.scan_tooltip:SetBagItem(container, slot)
local regions = self.main_frame.scan_tooltip:GetRegions()
for i = 1, self.main_frame.scan_tooltip:NumLines() do
local left = _G["DepletedTooltipScanTextLeft"..i]:GetText()
if string.find(left, depleted_label) then
depleted = true
end
end
self.main_frame.scan_tooltip:Hide()
dungeon = tonumber(info[2])
if not dungeon then print("MethodAltManager - Parse Failure, please let Qoning know that this happened.") end
level = tonumber(info[3])
if not level then print("MethodAltManager - Parse Failure, please let Qoning know that this happened.") end
expire = tonumber(info[4])
keystone_found = true
else ]]
ifitemsanditems[slotItemID] then
items[slotItemID].count=items[slotItemID].countor0
items[slotItemID].count=items[slotItemID].count+itemCount
end
end
end
-- Heart of Azeroth Progress
localheart_of_azeroth=nil
localazeriteItemLocation=C_AzeriteItem.FindActiveAzeriteItem()
if (azeriteItemLocation) then
localxp, totalLevelXP=C_AzeriteItem.GetAzeriteItemXPInfo(azeriteItemLocation)
heart_of_azeroth= {
['lvl'] =C_AzeriteItem.GetPowerLevel(azeriteItemLocation),
['xp'] =xp,
['totalXP'] =totalLevelXP,
['weekly'] =C_QuestLog.IsQuestFlaggedCompleted(53435) orC_QuestLog.IsQuestFlaggedCompleted(53436),
}
end
-- Process currencies
self.CurrencyTable=self.CurrencyTableorself:GenerateCurrencyTable()
_, seals=C_CurrencyInfo.GetCurrencyInfo(1580)
seals_bought=0
-- Seals - BfA
localgold_1=C_QuestLog.IsQuestFlaggedCompleted(52834)
localgold_2=C_QuestLog.IsQuestFlaggedCompleted(52838)
localresources_1=C_QuestLog.IsQuestFlaggedCompleted(52837)
localresources_2=C_QuestLog.IsQuestFlaggedCompleted(52840)
localmarks_1=C_QuestLog.IsQuestFlaggedCompleted(52835)
localmarks_2=C_QuestLog.IsQuestFlaggedCompleted(52839)
ifgold_1thenseals_bought=seals_bought+1end
ifgold_2thenseals_bought=seals_bought+1end
ifresources_1thenseals_bought=seals_bought+1end
ifresources_2thenseals_bought=seals_bought+1end
ifmarks_1thenseals_bought=seals_bought+1end
ifmarks_2thenseals_bought=seals_bought+1end
localsaves=GetNumSavedInstances()
localchar_table= {}
char_table.savedins= {}
fori=1, savesdo
localinstance= {}
localname, iID, reset, difficultyID, _, _, instanceIDMostSig, isRaid, _, difficulty, bosses, killed_bosses=GetSavedInstanceInfo(i)
ifisRaidandreset>0then
char_table.savedins[name] =char_table.savedins[name] or {}
char_table.savedins[name][difficultyID] = {
difficultyID,
difficulty,
bosses,
killed_bosses
}
end
end
-- Check BfA World bosses
localbfaworldtotal=0
forcid, cobjinpairs(BfAWorldBosses) do
bfaworldtotal=C_QuestLog.IsQuestFlaggedCompleted(cobj) andbfaworldtotal+1orbfaworldtotal
end
if (bfaworldtotal>0) then
char_table.savedins["Azeroth"] =char_table.savedins[name] or {}
char_table.savedins["Azeroth"][4] = {
4,
"25 Player",
2,
bfaworldtotal,
}
end
local_, ilevel=GetAverageItemLevel()
-- store data into a table
char_table.guid=UnitGUID('player')
char_table.name=name
char_table.class=class
char_table.faction=UnitFactionGroup("player")
char_table.realm=GetRealmName()
char_table.ilevel=ilevel
char_table.seals=seals
char_table.seals_bought=seals_bought
char_table.mplus= {
key= {
dungeon=dungeon,
level=level
},
reward=reward,
highest_mplus=highest_mplus
}
char_table.heart_of_azeroth=heart_of_azeroth
char_table.items=items
char_table.currencies=self.CurrencyTable
char_table.expires=self:GetNextWeeklyResetTime()
char_table.version=VERSION
returnchar_table
end
functionAltManager:PopulateStrings()
localfont_height=20
localdb=MethodAltManagerDB
localkeyset= {}
forkinpairs(db.data) do
table.insert(keyset, k)
end
self.main_frame.alt_columns=self.main_frame.alt_columnsor {}
localalt=0
foralt_guid, alt_datainspairs(db.data, function(t, a, b) returnt[a].ilevel>t[b].ilevelend) do
alt=alt+1
-- create the frame to which all the fontstrings anchor
localanchor_frame=self.main_frame.alt_columns[alt] orCreateFrame("Button", nil, self.main_frame)
ifnotself.main_frame.alt_columns[alt] then
self.main_frame.alt_columns[alt] =anchor_frame
end
anchor_frame:SetPoint("TOPLEFT", self.main_frame.label_column, "TOPRIGHT", per_alt_x* (alt-1), 0)
-- init table for fontstring storage
self.main_frame.alt_columns[alt].label_columns=self.main_frame.alt_columns[alt].label_columnsor {}
locallabel_columns=self.main_frame.alt_columns[alt].label_columns
-- create / fill fontstrings
locali=1
forcolumn_iden, columninspairs(self.columns_table, function(t, a, b) returnt[a].order<t[b].orderend) do
-- only display data with values
iftype(column.data) =="function" then
localcurrent_row=label_columns[i] orself:CreateFontFrame(
self.main_frame,
per_alt_x,
column.font_heightorfont_height,
anchor_frame,
-(i-1) *font_height,
column.data(alt_data, i),
"CENTER",
column.tooltipandcolumn.tooltip(alt_data,i))
-- insert it into storage if just created
ifnotself.main_frame.alt_columns[alt].label_columns[i] then
self.main_frame.alt_columns[alt].label_columns[i] =current_row
end
ifcolumn.colorthen
localcolor=column.color(alt_data)
current_row:GetFontString():SetTextColor(color.r, color.g, color.b, 1)
end
current_row:SetText(column.data(alt_data, i))
ifcolumn.fontthen
current_row:GetFontString():SetFont(column.font, 8)
else
--current_row:GetFontString():SetFont("Fonts\\FRIZQT__.TTF", 14)
end
ifcolumn.justifythen
current_row:GetFontString():SetJustifyV(column.justify)
end
i=i+1
end
end
sizey=20* (i-1)
anchor_frame:SetSize(per_alt_x, sizey)
end
end
functionAltManager:CreateMenu()
-- Close button
self.main_frame.closeButton=CreateFrame("Button", "CloseButton", self.main_frame, "UIPanelCloseButton")
ifAurorathenAurora.Skin.UIPanelCloseButton(self.main_frame.closeButton) end
self.main_frame.closeButton:ClearAllPoints()
self.main_frame.closeButton:SetFrameLevel(self.main_frame:GetFrameLevel() +2)
self.main_frame.closeButton:SetPoint("BOTTOMRIGHT", self.main_frame, "TOPRIGHT",Auroraand-5or-10, Auroraand5or-2)
self.main_frame.closeButton:SetScript("OnClick", function() AltManager:HideInterface() end)
-- Options button
self.main_frame.settingsButton=CreateFrame("Button", "SettingsButton", self.main_frame, "UIPanelButtonTemplate")
ifAurorathenAurora.Skin.UIPanelButtonTemplate(self.main_frame.settingsButton) end
self.main_frame.settingsButton:SetText('Conf')
self.main_frame.settingsButton:ClearAllPoints()
self.main_frame.settingsButton:SetFrameLevel(self.main_frame:GetFrameLevel() +2)
self.main_frame.settingsButton:SetPoint("BOTTOMRIGHT", self.main_frame, "TOPRIGHT",Auroraand-50or-50, Auroraand5or-2)
self.main_frame.settingsButton:SetScript("OnClick", function() InterfaceOptionsFrame_OpenToCategory(AltManager.MAMO_CURR) end)
localcolumn_table= {
name= {
order=1,
label=name_label,
data=function(alt_data) returnalt_data.nameend,
color=function(alt_data) returnRAID_CLASS_COLORS[alt_data.class] end,
tooltip=function(alt_data)
returnfunction(self)
ifAltManager:ShowTooltip() then
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
ifalt_data.realmthenGameTooltip:AddLine("Realm: "..alt_data.realm, 0.2, 1, 0.6, 0.2, 1, 0.6) end
GameTooltip:Show()
end
end
end,
},
ilevel= {
order=2,
data=function(alt_data) returnstring.format("%.2f", alt_data.ilevelor0) end,
justify="TOP",
font="Fonts\\FRIZQT__.TTF",
},
hoalevel= {
order=3,
label=azerite_label,
color=function(alt_data)
ifnotalt_data.heart_of_azeroththenreturn {r=255, g=0, b=0}
else
returnalt_data.heart_of_azeroth.weeklyand {r=0, g=255, b=0} or {r=255, g=0, b=0}
end
end,
data=function(alt_data)
ifnotalt_data.heart_of_azeroththenreturn"-"
else
returntostring(alt_data.heart_of_azeroth.lvl) .." (" ..tostring(alt_data.heart_of_azeroth.xp/alt_data.heart_of_azeroth.totalXP*100):gsub('(%-?%d+)%.%d+','%1') .."%)"
end
end,
tooltip=function(alt_data)
returnfunction(self)
ifAltManager:ShowTooltip() then
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
ifalt_data.heart_of_azeroththen
GameTooltip:AddLine('Details:', nil, nil, nil, false)
GameTooltip:AddLine('XP: '..alt_data.heart_of_azeroth.xp..'/'..alt_data.heart_of_azeroth.totalXP, 0.2, 1, 0.6, 0.2, 1, 0.6)
GameTooltip:AddLine('Islands '.. (alt_data.heart_of_azeroth.weeklyand'' or'not')..' done', 0.2, 1, 0.6, 0.2, 1, 0.6)
else
GameTooltip:AddLine('No Heart Data Found', nil, nil, nil, false)
end
GameTooltip:Show()
end
end
end,
},
mplus= {
order=4,
label=mythic_done_label,
data=function(alt_data) returntostring(alt_data.mplus.highest_mplus) end,
color=function(alt_data) returnalt_data.mplus.rewardand {r=230, g=128, b=0} or {r=255, g=255, b=255} end,
tooltip=function(alt_data)
returnfunction(self)
ifAltManager:ShowTooltip() then
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
ifalt_data.mplus.rewardthenGameTooltip:AddLine('Weekly Chest available', 0.2, 1, 0.6, 0.2, 1, 0.6) end
GameTooltip:Show()
end
end
end,
},
keystone= {
order=5,
label=mythic_keystone_label,
data=function(alt_data) return (dungeons[alt_data.mplus.key.dungeon] oralt_data.mplus.key.dungeon) .." +" ..tostring(alt_data.mplus.key.level); end,
},
seals_owned= {
order=6,
label=seals_owned_label,
data=function(alt_data) returntostring(alt_data.seals) end,
},
seals_bought= {
order=7,
label=seals_bought_label,
data=function(alt_data) returntostring(alt_data.seals_bought) end,
},
items= {
order=9,
data="items",
items_function=function()
self.item_list=self.item_listor {}
self:CreateItemFrame()
end,
},
currencies= {
order=9,
data="currencies",
currency_function=function(currencies)
self.currency_list=self.currency_listor {}
self:CreateCurrencyFrame(currencies)
end,
tooltip=function(currency)
returnfunction(self)
ifAltManager:ShowTooltip() then
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
ifcurrency.earnedandcurrency.weeklythen
GameTooltip:AddLine('Details:', nil, nil, nil, false)
GameTooltip:AddLine('Weekly: '..currency.earned..'/'..currency.weekly, 0.2, 1, 0.6, 0.2, 1, 0.6)
ifcurrency.total>0thenGameTooltip:AddLine('Max: '..currency.total, 0.2, 1, 0.6, 0.2, 1, 0.6) end
else
GameTooltip:AddLine('No Extra information currently saved', nil, nil, nil, false)
end
GameTooltip:Show()
end
end
end,
},
raid_unroll= {
order=12,
data="unroll",
name="+ Instances",
unroll_function=function(button)
self.instances_unroll=self.instances_unrollor {}
self.instances_unroll.state=self.instances_unroll.stateor"closed"
ifself.instances_unroll.state=="closed" then
self:CreateUnrollFrame()
button:SetText("- Instances")
self.instances_unroll.state="open"
else
-- do rollup
self.main_frame:SetSize(max((MethodAltManagerDB.alts+1) *per_alt_x, min_x_size), self.main_frame.lowest_point+60)
self.main_frame.background:SetAllPoints()
self.instances_unroll.unroll_frame:Hide()
button:SetText("+ Instances")
self.instances_unroll.state="closed"
end
end
}
}
self.columns_table=column_table
self:CreateLabels(true)
end
functionAltManager:CreateLabels(first_render)
-- create labels and unrolls
localcurrencies= (MethodAltManagerDB.optionsandMethodAltManagerDB.options.currencies) ornil
localitems= (MethodAltManagerDB.optionsandMethodAltManagerDB.options.items) ornil
items=filterItems(items)
localfont_height=20
locallabel_column=self.main_frame.label_columnorCreateFrame("Button", nil, self.main_frame)
ifnotself.main_frame.label_columnthenself.main_frame.label_column=label_columnend
label_column:SetPoint("TOPLEFT", self.main_frame, "TOPLEFT", 4, -1)
locali=1
forrow_iden, rowinspairs(self.columns_table, function(t, a, b) returnt[a].order<t[b].orderend) do
ifrow.labelthen
iffirst_renderthen
locallabel_row=self:CreateFontFrame(self.main_frame, per_alt_x, font_height, label_column, -(i-1)*font_height, row.label..":", "RIGHT")
end
self.main_frame.lowest_point=-(i-1)*font_height
end
ifrow.data=="unroll" then
self.main_frame.unroll_start=self.main_frame.lowest_point
-- create a button that will unroll it
self.unroll_button=self.unroll_buttonorCreateFrame("Button", nil, self.main_frame, "UIPanelButtonTemplate")
localunroll_button=self.unroll_button
unroll_button:SetText(row.name)
unroll_button:SetFrameLevel(self.main_frame:GetFrameLevel() +2)
unroll_button:SetSize(unroll_button:GetTextWidth() +20, 25)
unroll_button:SetPoint("TOPLEFT", self.currency_list.label_column, "BOTTOMLEFT", 10,-10)
ifAurorathenAurora.Skin.UIPanelButtonTemplate(unroll_button) end
unroll_button:SetScript("OnClick", function() row.unroll_function(unroll_button) end)
self.tierDropDown=self.tierDropDownorCreateFrame("Frame", nil, self.currency_list.label_column, "UIDropDownMenuTemplate")
localtierDropDown=self.tierDropDown
ifAurorathenAurora.Skin.UIDropDownMenuTemplate(tierDropDown) end
tierDropDown:SetPoint("LEFT", unroll_button, "RIGHT")
UIDropDownMenu_SetWidth(tierDropDown, 130) -- Use in place of dropDown:SetWidth
UIDropDownMenu_SetText(tierDropDown, EJ_GetTierInfo(favoriteTier))
UIDropDownMenu_Initialize(tierDropDown, AltManagerDropDown_Menu)
functiontierDropDown:SetTier(newValue)
-- Change Encounter Journal to correct expansion
favoriteTier=newValue
EJ_SelectTier(newValue)
-- Set correct value to dropdown menu
UIDropDownMenu_SetText(tierDropDown, EJ_GetTierInfo(favoriteTier))
-- Close the entire menu
CloseDropDownMenus()
-- Update unroll
AltManager.instances_unroll=AltManager.instances_unrollor {}
AltManager.instances_unroll.state="closed"
row.unroll_function(unroll_button)
end
i=i-1
end
ifrow.data=="items" then
ifitemsthen
self.main_frame.items_start=self.main_frame.lowest_point
row.items_function()
end
i=i-1
end
ifrow.data=="currencies" then
ifcurrenciesthen
self.main_frame.currency_start=self.main_frame.lowest_point
row.currency_function(currencies)
end
i=i-1
end
i=i+1
end