-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsumablesTab.lua
More file actions
1104 lines (1028 loc) · 41.7 KB
/
ConsumablesTab.lua
File metadata and controls
1104 lines (1028 loc) · 41.7 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 ConsumablesTab = {}
_G["ConsumablesTab"] = ConsumablesTab
local AceGUI = LibStub("AceGUI-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("PowerRaid")
local bossKeys = {
"General", "PVP", "Azuregos", "Lord Kazzak", "Emeriss", "Lethon", "Taerar", "Ysondre", "Lucifron", "Magmadar",
"Gehennas", "Garr", "Shazzrah", "Baron Geddon", "Golemagg the Incinerator", "Sulfuron Harbinger",
"Majordomo Executus", "Ragnaros", "Razorgore the Untamed", "Vaelastrasz the Corrupt", "Broodlord Lashlayer",
"Firemaw", "Ebonroc", "Flamegor", "Chromaggus", "Nefarian"
}
local bosses = {}
for _, boss in pairs(bossKeys) do
bosses[boss] = L[boss]
end
local consumablesInfo = {
["16040"] = {}, -- Arcane Bomb
["13813"] = { -- Blessed Sunfruit Juice
["buffId"] = "18141",
},
["13810"] = { -- Blessed Sunfruit
["buffId"] = "18125",
},
["5206"] = { -- Bogling Root
["buffId"] = "5665",
},
["20748"] = { -- Brilliant Mana Oil
["buffId"] = "25123",
["lesserItemIds"] = {"20747"},
["lesserBuffIds"] = {"25120"}
},
["20749"] = { -- Brilliant Wizard Oil
["buffId"] = "25122",
["lesserItemIds"] = {"20750"},
["lesserBuffIds"] = {"25121"}
},
["8423"] = { -- Cerebral Cortex Compound
["buffId"] = "10692",
},
["11566"] = {}, -- Crystal Charge
["11567"] = { -- Crystal Spire
["buffId"] = "15279",
},
["11564"] = { -- Crystal Ward
["buffId"] = "15233",
},
["12662"] = { -- Demonic Rune/Dark Rune
["altItemIds"] = {"20520"}
},
["18641"] = {}, -- Dense Dynamite
["12404"] = { -- Dense Sharpening Stone
["buffId"] = "16138",
},
["21023"] = { -- Dirge's Kickin' Chimaerok Chops
["buffId"] = "25661",
},
["12654"] = {}, -- Doomshot
["18262"] = { -- Elemental Sharpening Stone
["buffId"] = "22756",
},
["13453"] = { -- Elixir of Brute Force
["buffId"] = "17537",
},
["3825"] = { -- Elixir of Fortitude
["buffId"] = "3593",
},
["17708"] = { -- Elixir of Frost Power
["buffId"] = "21920",
},
["9206"] = { -- Elixir of Giants
["buffId"] = "11405",
},
["9187"] = { -- Elixir of Greater Agility
["buffId"] = "11334",
},
["21546"] = { -- Elixir of Greater Firepower
["buffId"] = "26276",
},
["9179"] = { -- Elixir of Greater Intellect
["buffId"] = "11396",
},
["3386"] = {}, -- Elixir of Poison Resistance
["9264"] = { -- Elixir of Shadow Power
["buffId"] = "11474",
},
["13445"] = { -- Elixir of Superior Defense
["buffId"] = "11348",
},
["13452"] = { -- Elixir of the Mongoose
["buffId"] = "17538",
},
["13447"] = { -- Elixir of the Sages
["buffId"] = "17535",
},
["13513"] = { -- Flask of Chromatic Resistance
["buffId"] = "17629",
},
["13511"] = { -- Flask of Distilled Wisdom
["buffId"] = "17627",
},
["13506"] = {}, -- Flask of Petrification
["13512"] = { -- Flask of Supreme Power
["buffId"] = "17628",
},
["13510"] = { -- Flask of the Titans
["buffId"] = "17626",
},
["5634"] = {}, -- Free Action Potion
["9088"] = { -- Gift of Arthas
["buffId"] = "11371",
},
["8424"] = { -- Gizzard Gum
["buffId"] = "10693",
},
["10646"] = {}, -- Goblin Sapper Charge
["18269"] = { -- Gordok Green Grog
["buffId"] = "22789",
},
["13454"] = { -- Greater Arcane Elixir
["buffId"] = "17539",
["lesserItemIds"] = {"9155"},
["lesserBuffIds"] = {"11390"}
},
["13461"] = { -- Greater Arcane Protection Potion
["buffId"] = "17549",
},
["13457"] = { -- Greater Fire Protection Potion
["buffId"] = "17543",
["lesserItemIds"] = {"6049"},
["lesserBuffIds"] = {"7233"}
},
["13456"] = { -- Greater Frost Protection Potion
["buffId"] = "17544",
["lesserItemIds"] = {"6050"},
["lesserBuffIds"] = {"7239"}
},
["13460"] = { -- Greater Holy Protection Potion
["buffId"] = "17545",
["lesserItemIds"] = {"6051"},
["lesserBuffIds"] = {"7245"}
},
["13458"] = { -- Greater Nature Protection Potion
["buffId"] = "17546",
["lesserItemIds"] = {"6052"},
["lesserBuffIds"] = {"7254"}
},
["13459"] = { -- Greater Shadow Protection Potion
["buffId"] = "17548",
["lesserItemIds"] = {"6048"},
["lesserBuffIds"] = {"7242"}
},
["13455"] = { -- Greater Stoneshield Potion
["buffId"] = "17540",
},
["13928"] = { -- Grilled Squid
["buffId"] = "18192",
},
["8412"] = { -- Ground Scorpok Assay
["buffId"] = "10669",
},
["14530"] = {}, -- Heavy Runecloth Bandage
["8928"] = { -- Instant Poison VI
["buffId"] = "11340",
},
["12457"] = { -- Juju Chill
["buffId"] = "16325",
},
["12455"] = { -- Juju Ember
["buffId"] = "16326",
},
["12450"] = { -- Juju Flurry
["buffId"] = "16322",
},
["12460"] = { -- Juju Might
["buffId"] = "16329",
},
["12451"] = { -- Juju Power
["buffId"] = "16323",
},
["18284"] = { -- Kreeg's Stout Beatdown
["buffId"] = "22790",
},
["3387"] = {}, -- Limited Invulnerability Potion
["20008"] = {}, -- Living Action Potion
["8411"] = { -- Lung Juice Cocktail
["buffId"] = "10668",
},
["20007"] = { -- Mageblood Potion
["buffId"] = "24363",
},
["2091"] = {}, -- Magic Dust
["19013"] = { -- Major Healthstone
["altItemIds"] = {"19012", "9421"}
},
["13444"] = {}, -- Major Mana Potion
["20004"] = { -- Major Troll's Blood Potion
["buffId"] = "24361",
},
["9449"] = { -- Manual Crowd Pummeler
["buffId"] = "13494",
},
["13442"] = {}, -- Mighty Rage Potion
["11952"] = { -- Night Dragon's Breath
["altItemIds"] = {"14894"}
},
["13931"] = { -- Nightfin Soup
["buffId"] = "18194",
},
["8956"] = {}, -- Oil of Immolation
["19440"] = {}, -- Powerful Anti-Venom
["8410"] = { -- R.O.I.D.S.
["buffId"] = "10667",
},
["9030"] = {}, -- Restorative Potion
["21151"] = { -- Rumsey Rum Black Label
["buffId"] = "25804",
},
["18254"] = { -- Runn Tum Tuber Surprise
["buffId"] = "22730",
},
["21217"] = { -- Sagefish Delight
["buffId"] = "25941",
},
["20080"] = { -- Sheen of Zanza
["buffId"] = "24417",
},
["20452"] = { -- Smoked Desert Dumplings
["buffId"] = "24799",
},
["20079"] = { -- Spirit of Zanza
["buffId"] = "24382",
},
["13180"] = {}, -- Stratholme Holy Water
["20081"] = { -- Swiftness of Zanza
["buffId"] = "24383",
},
["18045"] = { -- Tender Wolf Steak
["buffId"] = "19710",
},
["7676"] = {}, -- Thistle Tea
["15993"] = { -- Thorium Grenade
["altItemIds"] = {"16005", "10830", "10586", "10562", "10514", "4394", "4390", "4380", "4374", "4370", "4360", "4403"}
},
["18042"] = {}, -- Thorium Headed Arrow
["15997"] = {}, -- Thorium Shells
["11951"] = {}, -- Whipper Root Tuber
["12820"] = { -- Winterfall Firewater
["buffId"] = "17038",
}
}
local numConsumablesFetching = 0
for itemId, itemData in pairs(consumablesInfo) do
itemData["itemId"] = itemId
itemData["toolTip"] = nil
itemData["name"] = GetItemName(tonumber(itemId))
itemData["icon"] = GetItemIcon(tonumber(itemId))
if itemData["name"] == nil then
numConsumablesFetching = numConsumablesFetching + 1
local item = Item:CreateFromItemID(tonumber(itemId))
item:ContinueOnItemLoad(function()
numConsumablesFetching = numConsumablesFetching - 1
itemData["name"] = item:GetItemName()
end)
end
end
local specs = {
["All Classes"] = {
["englishClass"] = "",
["currentBuffs"] = {},
["currentItems"] = {},
["currentSpecs"] = {},
},
["Shaman (Ele)"] = {
["englishClass"] = "SHAMAN",
["hidden"] = true,
["currentBuffs"] = {},
["currentItems"] = {},
},
["Shaman (Enh)"] = {
["englishClass"] = "SHAMAN",
["hidden"] = true,
["currentBuffs"] = {},
["currentItems"] = {},
},
["Druid (Feral DPS)"] = {
["englishClass"] = "DRUID",
["hidden"] = true,
["currentBuffs"] = {},
["currentItems"] = {},
},
["Druid (Moonkin)"] = {
["englishClass"] = "DRUID",
["hidden"] = true,
["currentBuffs"] = {},
["currentItems"] = {},
},
["Druid (Feral Tank)"] = {
["englishClass"] = "DRUID",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Priest (Healing)"] = {
["englishClass"] = "PRIEST",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Paladin (Holy)"] = {
["englishClass"] = "PALADIN",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Hunter"] = {
["englishClass"] = "HUNTER",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Mage"] = {
["englishClass"] = "MAGE",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Paladin (Prot)"] = {
["englishClass"] = "PALADIN",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Warrior (Prot)"] = {
["englishClass"] = "WARRIOR",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Druid (Resto)"] = {
["englishClass"] = "DRUID",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Shaman (Resto)"] = {
["englishClass"] = "SHAMAN",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Paladin (Ret)"] = {
["englishClass"] = "PALADIN",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Rogue"] = {
["englishClass"] = "ROGUE",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Priest (Shadow)"] = {
["englishClass"] = "PRIEST",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Warlock"] = {
["englishClass"] = "WARLOCK",
["currentBuffs"] = {},
["currentItems"] = {},
},
["Warrior (DPS)"] = {
["englishClass"] = "WARRIOR",
["currentBuffs"] = {},
["currentItems"] = {},
},
}
local tabId = PowerRaidGUI.ConsumablesTabId
local tabName = PowerRaidGUI.tabIdsToTabNames[tabId]
local function OnValueChanged(value, spec, spellName)
local currType = PowerRaid.db.char.currentConsumableType
local currBoss = PowerRaid.db.char.currentBoss
PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currType][spellName] = value
end
function ConsumablesTab:getConsumablesInfo()
return consumablesInfo
end
function ConsumablesTab:getSpecs()
return specs
end
function ConsumablesTab:getBosses()
return bosses
end
function ConsumablesTab:ShouldShowSpec(specData)
return not specData["hidden"] and ((PowerRaid.faction == "Horde" and specData["englishClass"] ~= "PALADIN") or (PowerRaid.faction == "Alliance" and specData["englishClass"] ~= "SHAMAN"))
end
function ConsumablesTab:GetLocalizedSpecNameWithColor(spec)
return format("|c%s%s|r",
GetClassColorFromEnglishClass(specs[spec]["englishClass"]),
GetLocalizedSpecName(spec))
end
function ConsumablesTab:SendConsumesOrBuffQuestion(type, spec, reportAfterScan)
local currBoss = PowerRaid.db.char.currentBoss
if spec == "All Classes" then
for aspec, _ in pairs(specs) do
specs[aspec][(type == "ITEM" and "currentItems" or "currentBuffs")] = {}
end
else
specs[spec][(type == "ITEM" and "currentItems" or "currentBuffs")] = {}
end
local consumeIds = {}
for _, consumeId in pairs(PowerRaid.db.char.consumesForSpecs[spec]) do
local count = tonumber(PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][type][consumeId])
if count ~= nil and count > 0 then
table.insert(consumeIds, consumeId)
end
end
if #consumeIds > 0 then
PowerRaid.tabsScanActive[tabId] = true
if reportAfterScan then
PowerRaid.tabsReportActive[tabId] = true
end
if type == "ITEM" then
PowerRaid:ConsumablesQuestion(spec, consumeIds, PowerRaid.db.char.consumablesLesserEnabled)
elseif type == "BUFF" then
PowerRaid:QuestionBuffs(spec, consumeIds, PowerRaid.db.char.consumablesLesserEnabled)
end
end
end
-- buff or item scan
function ConsumablesTab:ScanConsumables(type, spec, reportAfterScan)
if spec == "All Classes" then
for aspec, v in pairs(specs) do
self:SendConsumesOrBuffQuestion(type, aspec, reportAfterScan)
end
else
self:SendConsumesOrBuffQuestion(type, "All Classes", reportAfterScan)
self:SendConsumesOrBuffQuestion(type, spec, reportAfterScan)
end
end
local function CreateCurrentClassConsumeRowItem(consumableInfo, count, requiredCount)
local currConsume = AceGUI:Create("Icon")
if(consumableInfo["icon"]) then
currConsume:SetImage(consumableInfo["icon"])
else
currConsume:SetImage("Interface\\Icons\\inv_misc_questionmark")
end
currConsume:SetImageSize(16, 16)
currConsume.image:SetAllPoints()
currConsume:SetWidth(16)
currConsume:SetHeight(16)
--if consumableInfo["itemId"] then
-- currConsume.frame:SetScript("OnEnter", function()
-- if(consumableInfo["toolTip"] == nil) then
-- consumableInfo["toolTip"] = CreateFrame("GameTooltip", consumableInfo["itemId"] .. spec .. spec .. player, nil, "GameTooltipTemplate")
-- end
-- consumableInfo["toolTip"]:SetOwner(currConsume.frame, "ANCHOR_CURSOR")
-- consumableInfo["toolTip"]:SetItemByID(consumableInfo["itemId"])
-- consumableInfo["toolTip"]:Show()
-- end)
-- currConsume.frame:SetScript("OnLeave", function()
-- consumableInfo["toolTip"]:Hide()
-- end)
--end
if count < requiredCount then
currConsume.image:SetVertexColor(1, 1, 1, 0.2)
else
currConsume.image:SetVertexColor(1, 1, 1, 1)
end
return currConsume
end
local function DrawCurrentClassConsumeRow(player, spec, consumeIterator, consumeIteratorAll)
local currType = PowerRaid.db.char.currentConsumableType
local currBoss = PowerRaid.db.char.currentBoss
local playerContainer = AceGUI:Create("SimpleGroup")
playerContainer:SetLayout("Flow")
playerContainer:SetFullWidth(true)
local currName = AceGUI:Create("Label")
local _, englishClass, classIndex = UnitClass(player)
currName:SetText("|c" .. GetClassColorFromEnglishClass(englishClass) .. player .. "|r")
local childrenIcons = {}
if consumeIterator then
for consumeId, count in pairs(consumeIterator) do
local requiredCount = tonumber(PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currType][consumeId])
if requiredCount ~= nil and requiredCount > 0 then
table.insert(childrenIcons, CreateCurrentClassConsumeRowItem(consumablesInfo[consumeId], count, requiredCount))
end
end
end
if consumeIteratorAll then
for consumeId, count in pairs(consumeIteratorAll) do
local requiredCount = tonumber(PowerRaid.db.char.consumablesToCheckFor[currBoss]["All Classes"][currType][consumeId])
if requiredCount ~= nil and requiredCount > 0 then
table.insert(childrenIcons, CreateCurrentClassConsumeRowItem(consumablesInfo[consumeId], count, requiredCount))
end
end
end
local iconsContainer = AceGUI:Create("SimpleGroup")
iconsContainer:SetLayout("Flow")
iconsContainer:SetWidth(16 * #childrenIcons + 1)
iconsContainer:SetHeight(16)
currName:SetWidth(350 - 16 * #childrenIcons - 1)
currName:SetHeight(16)
playerContainer:AddChild(currName)
playerContainer:AddChild(iconsContainer)
iconsContainer:AddChildren(unpack(childrenIcons))
return playerContainer
end
local function DrawCurrentClassConsumables()
local currentSpec = PowerRaid.db.char.currentSpecTab
local raidContainer = AceGUI:Create("SimpleGroup")
raidContainer:SetFullWidth(true)
raidContainer:SetLayout("Flow")
local groupContainer = AceGUI:Create("SimpleGroup")
groupContainer:SetRelativeWidth(1)
groupContainer:SetLayout("List")
groupContainer:SetFullWidth(true)
local consumeType
if PowerRaid.db.char.currentConsumableType == "ITEM" then
consumeType = "currentItems"
elseif PowerRaid.db.char.currentConsumableType == "BUFF" then
consumeType = "currentBuffs"
end
local playerContainers = {}
if consumeType then
if currentSpec == "All Classes" then
for aspec, _ in pairs(specs) do
if aspec ~= "All Classes" then
local players = {}
for player, currentItems in pairs(specs[aspec][consumeType]) do
table.insert(playerContainers, DrawCurrentClassConsumeRow(player, aspec, currentItems, specs["All Classes"][consumeType][player]))
players[player] = true
end
for player, currentItemsAll in pairs(specs["All Classes"][consumeType]) do
if not players[player] and specs["All Classes"]["currentSpecs"][player] == aspec then
table.insert(playerContainers, DrawCurrentClassConsumeRow(player, aspec, specs[aspec][consumeType][player], currentItemsAll))
end
end
end
end
else
local players = {}
for player, currentItems in pairs(specs[currentSpec][consumeType]) do
table.insert(playerContainers, DrawCurrentClassConsumeRow(player, currentSpec, currentItems, specs["All Classes"][consumeType][player]))
players[player] = true
end
for player, currentItemsAll in pairs(specs["All Classes"][consumeType]) do
if not players[player] and specs["All Classes"]["currentSpecs"][player] == currentSpec then
table.insert(playerContainers, DrawCurrentClassConsumeRow(player, currentSpec, specs[currentSpec][consumeType][player], currentItemsAll))
end
end
end
end
raidContainer:AddChild(groupContainer)
groupContainer:AddChildren(unpack(playerContainers))
return raidContainer
end
function ConsumablesTab:findMissingItems(spec, type, playersMissingAll, playersMissingAny, itemOrBuffToPlayersMissingList, playersHaveAll, playersHaveAny, itemOrBuffToPlayersHaveList)
local boss = PowerRaid.db.char.currentBoss
for player, consumeIds in pairs(specs[spec][(type == "ITEM" and "currentItems" or "currentBuffs")]) do
for consumeId, count in pairs(consumeIds) do
local itemNum = tonumber(PowerRaid.db.char.consumablesToCheckFor[boss][spec][type][consumeId])
if itemNum ~= nil and itemNum > 0 then
local itemNameMaybeWithCount = consumablesInfo[consumeId]["name"]
if itemNum > 1 then
itemNameMaybeWithCount = itemNameMaybeWithCount .. " (" .. itemNum .. ")"
end
if count < itemNum then
playersMissingAny[player] = true
playersHaveAll[player] = false
if itemOrBuffToPlayersMissingList[itemNameMaybeWithCount] == nil then
itemOrBuffToPlayersMissingList[itemNameMaybeWithCount] = {}
end
table.insert(itemOrBuffToPlayersMissingList[itemNameMaybeWithCount], player)
elseif count >= itemNum then
playersHaveAny[player] = true
playersMissingAll[player] = false
if itemOrBuffToPlayersHaveList[itemNameMaybeWithCount] == nil then
itemOrBuffToPlayersHaveList[itemNameMaybeWithCount] = {}
end
table.insert(itemOrBuffToPlayersHaveList[itemNameMaybeWithCount], player)
end
end
end
end
end
function ConsumablesTab:outputReport()
local channel = PowerRaid.db.char.currentReportOutputChannels[tabId]
local reportType = PowerRaid.db.char.currentReportOutputTypes[tabId]
local type = PowerRaid.db.char.currentConsumableType
local spec = PowerRaid.db.char.currentSpecTab
local intro = format("[%s] %s: ", L["Power Raid"],
format(L["reportOutputting"], GetReportTypes(tabId, format("%s (%s)", tabName, type == "ITEM" and L["Items"] or L["Buffs"]))[reportType]))
local knownPlayers = {}
local playersMissingAll = {}
local playersMissingAny = {}
local itemOrBuffToPlayersMissingList = {}
local playersHaveAll = {}
local playersHaveAny = {}
local itemOrBuffToPlayersHaveList = {}
if spec == "All Classes" then
for aspec, _ in pairs(specs) do
for player, _ in pairs(specs[aspec][(type == "ITEM" and "currentItems" or "currentBuffs")]) do
knownPlayers[player] = true
playersMissingAll[player] = true
playersHaveAll[player] = true
end
end
else
for player, _ in pairs(specs["All Classes"][(type == "ITEM" and "currentItems" or "currentBuffs")]) do
knownPlayers[player] = true
playersMissingAll[player] = true
playersHaveAll[player] = true
end
for player, _ in pairs(specs[spec][(type == "ITEM" and "currentItems" or "currentBuffs")]) do
knownPlayers[player] = true
playersMissingAll[player] = true
playersHaveAll[player] = true
end
end
if spec == "All Classes" then
for aspec, _ in pairs(specs) do
ConsumablesTab:findMissingItems(aspec, type, playersMissingAll, playersMissingAny, itemOrBuffToPlayersMissingList, playersHaveAll, playersHaveAny, itemOrBuffToPlayersHaveList)
end
else
ConsumablesTab:findMissingItems("All Classes", type, playersMissingAll, playersMissingAny, itemOrBuffToPlayersMissingList, playersHaveAll, playersHaveAny, itemOrBuffToPlayersHaveList)
ConsumablesTab:findMissingItems(spec, type, playersMissingAll, playersMissingAny, itemOrBuffToPlayersMissingList, playersHaveAll, playersHaveAny, itemOrBuffToPlayersHaveList)
end
local playersMissingAllList = ConvertTruthyDictToList(playersMissingAll)
local playersMissingAnyList = ConvertTruthyDictToList(playersMissingAny)
local playersHaveAllList = ConvertTruthyDictToList(playersHaveAll)
local playersHaveAnyList = ConvertTruthyDictToList(playersHaveAny)
local showUnknown = PowerRaid.db.char.reportUnknownPlayers[tabId]
if reportType == "missing_all" then
OutputPlayersList(channel, intro, playersMissingAllList, knownPlayers, showUnknown)
elseif reportType == "missing_any" then
OutputPlayersList(channel, intro, playersMissingAnyList, knownPlayers, showUnknown)
elseif reportType == "missing_each" then
OutputItemToPlayers(channel, intro, itemOrBuffToPlayersMissingList, knownPlayers, showUnknown)
elseif reportType == "has_all" then
OutputPlayersList(channel, intro, playersHaveAllList, knownPlayers, showUnknown)
elseif reportType == "has_any" then
OutputPlayersList(channel, intro, playersHaveAnyList, knownPlayers, showUnknown)
elseif reportType == "has_each" then
OutputItemToPlayers(channel, intro, itemOrBuffToPlayersHaveList, knownPlayers, showUnknown)
end
end
local itemIncrementerMax = 10
local function GetConsumeItemNum(spec, consumeId)
local currBoss = PowerRaid.db.char.currentBoss
local currConsumableType = PowerRaid.db.char.currentConsumableType
local itemNum = tonumber(PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId])
if itemNum == nil or itemNum < 0 then
itemNum = 0
PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId] = itemNum
elseif itemNum > itemIncrementerMax then
itemNum = itemIncrementerMax
PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId] = itemNum
end
return itemNum
end
local function GetItemIncrementerLabelText(num)
local labelString = " "
if num < 10 then
labelString = labelString .. " "
end
if num == 0 then
return labelString .. "|cFFC1C4C6" .. tostring(num) .. "|r"
else
return labelString .. "|cFF00FF00" .. tostring(num) .. "|r"
end
end
local function UpdateItemIncrementerButton(num, button, buttonType)
local buttonText
local isDisabled
if buttonType == "LEFT" then
buttonText = "-"
isDisabled = (num <= 0)
else
buttonText = "+"
isDisabled = (num >= itemIncrementerMax)
end
button:SetDisabled(isDisabled)
if isDisabled then
button:SetText("|cFF999DA0" .. buttonText .. "|r")
else
button:SetText(buttonText)
end
end
local function CreateItemIncrementer(spec, consumeId, consumableInfo)
local currBoss = PowerRaid.db.char.currentBoss
local currConsumableType = PowerRaid.db.char.currentConsumableType
local itemSelector = AceGUI:Create("SimpleGroup")
itemSelector:SetWidth(64)
itemSelector:SetLayout("Flow")
local tempIcon = AceGUI:Create("InteractiveLabel")
tempIcon:SetWidth(64)
tempIcon:SetImage(consumableInfo["icon"])
tempIcon:SetImageSize(16, 16)
if consumableInfo["itemId"] then
tempIcon:SetCallback("OnEnter", function()
if(consumableInfo["toolTip"] == nil) then
consumableInfo["toolTip"] = CreateFrame( "GameTooltip", consumeId .. spec .. currConsumableType .. "checkbox" , nil, "GameTooltipTemplate" )
end
consumableInfo["toolTip"]:SetOwner(tempIcon.frame, "ANCHOR_CURSOR")
consumableInfo["toolTip"]:SetItemByID(consumableInfo["itemId"])
consumableInfo["toolTip"]:Show()
end)
tempIcon:SetCallback("OnLeave", function()
consumableInfo["toolTip"]:Hide()
end)
end
local itemNum = GetConsumeItemNum(spec, consumeId)
local tempLabel = AceGUI:Create("Label")
tempLabel:SetWidth(16)
tempLabel:SetHeight(12)
tempLabel:SetText(GetItemIncrementerLabelText(itemNum))
local tempLeftButton = AceGUI:Create("Button")
tempLeftButton:SetWidth(12)
tempLeftButton:SetHeight(12)
UpdateItemIncrementerButton(itemNum, tempLeftButton, "LEFT")
local tempRightButton = AceGUI:Create("Button")
tempRightButton:SetWidth(12)
tempRightButton:SetHeight(12)
UpdateItemIncrementerButton(itemNum, tempRightButton, "RIGHT")
local getIncrementDecrementCallback = (function(isIncrement)
return (function()
local num = GetConsumeItemNum(spec, consumeId)
if isIncrement and num < itemIncrementerMax then
num = num + 1
elseif not isIncrement and num > 0 then
num = num - 1
end
UpdateItemIncrementerButton(num, tempLeftButton, "LEFT")
UpdateItemIncrementerButton(num, tempRightButton, "RIGHT")
PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId] = num
tempLabel:SetText(GetItemIncrementerLabelText(num))
end)
end)
tempLeftButton:SetCallback("OnClick", getIncrementDecrementCallback(false))
local incrementCallback = getIncrementDecrementCallback(true)
tempRightButton:SetCallback("OnClick", incrementCallback)
tempIcon:SetCallback("OnClick", incrementCallback)
itemSelector:AddChild(tempIcon)
local spacer = AceGUI:Create("Label")
spacer:SetWidth(12)
spacer:SetText("")
itemSelector:AddChild(spacer)
itemSelector:AddChild(tempLeftButton)
itemSelector:AddChild(tempLabel)
itemSelector:AddChild(tempRightButton)
return itemSelector
end
local function DrawCurrentClassTab()
local spec = PowerRaid.db.char.currentSpecTab
local currBoss = PowerRaid.db.char.currentBoss
local currConsumableType = PowerRaid.db.char.currentConsumableType
local fullTab = AceGUI:Create("SimpleGroup")
fullTab:SetFullWidth(true)
fullTab:SetLayout("Flow")
local consumeIterator = { [1] = spec }
if spec == "All Classes" then
consumeIterator = {}
for spec, _ in pairs(specs) do
if ConsumablesTab:ShouldShowSpec(specs[spec]) then
table.insert(consumeIterator, spec)
end
end
table.sort(consumeIterator)
end
for i, spec in pairs(consumeIterator) do
local consumablesForSpec = AceGUI:Create("InlineGroup")
consumablesForSpec:SetTitle(format(L["specConsumables"], ConsumablesTab:GetLocalizedSpecNameWithColor(spec)))
consumablesForSpec:SetFullWidth(true)
consumablesForSpec:SetLayout("Flow")
for _, consumeId in pairs(PowerRaid.db.char.consumesForSpecs[spec]) do
if currConsumableType == "ITEM" and consumablesInfo[consumeId]["itemId"] ~= nil then
consumablesForSpec:AddChild(CreateItemIncrementer(spec, consumeId, consumablesInfo[consumeId]))
elseif PowerRaid.db.char.currentConsumableType == "BUFF" and consumablesInfo[consumeId]["buffId"] ~= nil then
local tempCheckBox = AceGUI:Create("CheckBox")
tempCheckBox:SetWidth(64)
tempCheckBox:SetLabel("")
if PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId] == 1 then
tempCheckBox:SetValue(true)
else
tempCheckBox:SetValue(false)
end
tempCheckBox:SetImage(consumablesInfo[consumeId]["icon"])
tempCheckBox:SetCallback("OnValueChanged", function()
if tempCheckBox:GetValue() then
OnValueChanged(1, spec, consumeId)
else
OnValueChanged(0, spec, consumeId)
end
end)
if consumablesInfo[consumeId]["itemId"] then
tempCheckBox:SetCallback("OnEnter", function()
if(consumablesInfo[consumeId]["toolTip"] == nil) then
consumablesInfo[consumeId]["toolTip"] = CreateFrame( "GameTooltip", consumeId .. spec .. currConsumableType .. "checkbox" , nil, "GameTooltipTemplate" )
end
consumablesInfo[consumeId]["toolTip"]:SetOwner(tempCheckBox.frame, "ANCHOR_CURSOR")
consumablesInfo[consumeId]["toolTip"]:SetItemByID(consumablesInfo[consumeId]["itemId"])
consumablesInfo[consumeId]["toolTip"]:Show()
end)
tempCheckBox:SetCallback("OnLeave", function()
consumablesInfo[consumeId]["toolTip"]:Hide()
end)
end
consumablesForSpec:AddChild(tempCheckBox)
else
PowerRaid.db.char.consumablesToCheckFor[currBoss][spec][currConsumableType][consumeId] = 0
end
end
fullTab:AddChild(consumablesForSpec)
end
return fullTab
end
function ConsumablesTab:getAddRemoveConsumesDropdownListAndOrder(spec)
local consumeDropdownListOrder = {}
local consumeDropdownList = {}
consumeDropdownList["removeConsumeTitleItem"] = format(L["removeFromSpec"], spec)
table.insert(consumeDropdownListOrder, "removeConsumeTitleItem")
for _, consumeId in pairs(PowerRaid.db.char.consumesForSpecs[spec]) do
consumeDropdownList[consumeId] = consumablesInfo[consumeId]["name"]
table.insert(consumeDropdownListOrder, consumeId)
end
consumeDropdownList["addConsumeTitleItem"] = format(L["addToSpec"], spec)
table.insert(consumeDropdownListOrder, "addConsumeTitleItem")
local addConsumeNameToId = {}
for consumeId, consumableInfo in pairs(consumablesInfo) do
local consumeExistsInCurrentSpec = false
for _, consumeIdInSpec in pairs(PowerRaid.db.char.consumesForSpecs[spec]) do
if consumeIdInSpec == consumeId then
consumeExistsInCurrentSpec = true
break
end
end
if not consumeExistsInCurrentSpec then
consumeDropdownList[consumeId] = consumableInfo["name"]
addConsumeNameToId[consumableInfo["name"]] = consumeId
end
end
for _, consumeId in orderedPairs(addConsumeNameToId) do
table.insert(consumeDropdownListOrder, consumeId)
end
return consumeDropdownList, consumeDropdownListOrder
end
function ConsumablesTab:RemoveConsumeIdFromSpec(spec, consumeId)
local removedFromSpec = false
for i, consumeIdForSpec in pairs(PowerRaid.db.char.consumesForSpecs[spec]) do
if consumeIdForSpec == consumeId then
table.remove(PowerRaid.db.char.consumesForSpecs[spec], i)
removedFromSpec = true
for boss, _ in pairs(bosses) do
for type, consumesToCheckForType in pairs(PowerRaid.db.char.consumablesToCheckFor[boss][spec]) do
local removedTable = {}
local foundConsume = false
for id, val in pairs(consumesToCheckForType) do
if id == consumeId then
foundConsume = true
else
removedTable[id] = val
end
end
if foundConsume then
PowerRaid.db.char.consumablesToCheckFor[boss][spec][type] = removedTable
end
end
end
break
end
end
return removedFromSpec
end
function ConsumablesTab:SortListOfConsumeIds(consumeIdsList)
local nameToIds = {}
for _, consumeId in pairs(consumeIdsList) do
nameToIds[consumablesInfo[consumeId]["name"]] = consumeId
end
local sorted = {}
for _, consumeId in orderedPairs(nameToIds) do
table.insert(sorted, consumeId)
end
return sorted
end
function ConsumablesTab:DrawConsumables(container)
local topTitleGroup = AceGUI:Create("SimpleGroup")
topTitleGroup:SetFullWidth(true)
topTitleGroup:SetLayout("Flow")
local specChoosingLabel = AceGUI:Create("Label")
specChoosingLabel:SetWidth(200)
specChoosingLabel:SetText(L["Choose Item or Buff and Class to Check for:"])
topTitleGroup:AddChild(specChoosingLabel)
local typeDropdown = AceGUI:Create("Dropdown")
typeDropdown:SetWidth(100)
typeDropdown:SetList({["ITEM"] = L["Item"], ["BUFF"] = L["Buff"]})
typeDropdown:SetValue(PowerRaid.db.char.currentConsumableType)
typeDropdown:SetCallback("OnValueChanged", function(widget, event, key)
PowerRaid.db.char.currentConsumableType = key
PowerRaidGUI:ReloadCurrentTab()
end)
topTitleGroup:AddChild(typeDropdown)
local specDropDown = AceGUI:Create("Dropdown")
specDropDown:SetWidth(120)
local dropdown = {}
for key, value in pairs(specs) do
if ConsumablesTab:ShouldShowSpec(value) then
dropdown[key] = ConsumablesTab:GetLocalizedSpecNameWithColor(key)
end
end
specDropDown:SetList(dropdown)
specDropDown:SetValue(PowerRaid.db.char.currentSpecTab)
specDropDown:SetCallback("OnValueChanged", function(widget, event, key)
PowerRaid.db.char.currentSpecTab = key
PowerRaidGUI:ReloadCurrentTab()
end)
topTitleGroup:AddChild(specDropDown)
local bossDropDown = AceGUI:Create("Dropdown")
bossDropDown:SetWidth(150)
bossDropDown:SetList(bosses, bossKeys)
bossDropDown:SetValue(PowerRaid.db.char.currentBoss)
bossDropDown:SetCallback("OnValueChanged", function(widget, event, key)
PowerRaid.db.char.currentBoss = key
PowerRaidGUI:ReloadCurrentTab()
end)
topTitleGroup:AddChild(bossDropDown)
local lesserCheckBox = AceGUI:Create("CheckBox")
lesserCheckBox:SetLabel(L["Lesser"])
lesserCheckBox:SetWidth(90)
lesserCheckBox:SetValue(PowerRaid.db.char.consumablesLesserEnabled)
lesserCheckBox:SetCallback("OnValueChanged", function()
PowerRaid.db.char.consumablesLesserEnabled = lesserCheckBox:GetValue()
end)
lesserCheckBox:SetCallback("OnEnter", function()
if(lesserCheckBoxTooltip == nil) then
lesserCheckBoxTooltip = CreateFrame("GameTooltip", "lessercheckbox" , nil, "GameTooltipTemplate")
end
lesserCheckBoxTooltip:SetOwner(lesserCheckBox.frame, "ANCHOR_CURSOR")
lesserCheckBoxTooltip:SetText(L["lesserDescription"])
lesserCheckBoxTooltip:Show()
end)
lesserCheckBox:SetCallback("OnLeave", function()
lesserCheckBoxTooltip:Hide()
end)
topTitleGroup:AddChild(lesserCheckBox)
local clearBtn = AceGUI:Create("Button")
clearBtn:SetText(format("|cFFF2003C%s|r", L["Clear Selected"]))
clearBtn:SetWidth(120)
clearBtn:SetCallback("OnClick", function()