forked from PathOfBuildingCommunity/PathOfBuilding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemsTab.lua
3265 lines (3132 loc) · 128 KB
/
ItemsTab.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
-- Path of Building
--
-- Module: Items Tab
-- Items tab for the current build.
--
local pairs = pairs
local ipairs = ipairs
local next = next
local t_insert = table.insert
local t_remove = table.remove
local s_format = string.format
local m_max = math.max
local m_min = math.min
local m_ceil = math.ceil
local m_floor = math.floor
local m_modf = math.modf
local rarityDropList = {
{ label = colorCodes.NORMAL.."Normal", rarity = "NORMAL" },
{ label = colorCodes.MAGIC.."Magic", rarity = "MAGIC" },
{ label = colorCodes.RARE.."Rare", rarity = "RARE" },
{ label = colorCodes.UNIQUE.."Unique", rarity = "UNIQUE" },
{ label = colorCodes.RELIC.."Relic", rarity = "RELIC" }
}
local socketDropList = {
{ label = colorCodes.STRENGTH.."R", color = "R" },
{ label = colorCodes.DEXTERITY.."G", color = "G" },
{ label = colorCodes.INTELLIGENCE.."B", color = "B" },
{ label = colorCodes.SCION.."W", color = "W" }
}
local baseSlots = { "Weapon 1", "Weapon 2", "Helmet", "Body Armour", "Gloves", "Boots", "Amulet", "Ring 1", "Ring 2", "Belt", "Flask 1", "Flask 2", "Flask 3", "Flask 4", "Flask 5" }
local influenceInfo = itemLib.influenceInfo
local catalystQualityFormat = {
"^x7F7F7FQuality (Attack Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Speed Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Life and Mana Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Caster Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Attribute Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Physical and Chaos Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Resistance Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Defense Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Elemental Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
"^x7F7F7FQuality (Critical Modifiers): "..colorCodes.MAGIC.."+%d%% (augmented)",
}
local ItemsTabClass = newClass("ItemsTab", "UndoHandler", "ControlHost", "Control", function(self, build)
self.UndoHandler()
self.ControlHost()
self.Control()
self.build = build
self.socketViewer = new("PassiveTreeView")
self.items = { }
self.itemOrderList = { }
-- PoB Trader class initialization
self.tradeQuery = new("TradeQuery", self)
-- Set selector
self.controls.setSelect = new("DropDownControl", {"TOPLEFT",self,"TOPLEFT"}, 96, 8, 216, 20, nil, function(index, value)
self:SetActiveItemSet(self.itemSetOrderList[index])
self:AddUndoState()
end)
self.controls.setSelect.enableDroppedWidth = true
self.controls.setSelect.enabled = function()
return #self.itemSetOrderList > 1
end
self.controls.setSelect.tooltipFunc = function(tooltip, mode, index, value)
tooltip:Clear()
if mode == "HOVER" then
self:AddItemSetTooltip(tooltip, self.itemSets[self.itemSetOrderList[index]])
end
end
self.controls.setLabel = new("LabelControl", {"RIGHT",self.controls.setSelect,"LEFT"}, -2, 0, 0, 16, "^7Item set:")
self.controls.setManage = new("ButtonControl", {"LEFT",self.controls.setSelect,"RIGHT"}, 4, 0, 90, 20, "Manage...", function()
self:OpenItemSetManagePopup()
end)
-- Price Items
self.controls.priceDisplayItem = new("ButtonControl", {"TOPLEFT",self,"TOPLEFT"}, 96, 32, 310, 20, "Trade for these items", function()
self.tradeQuery:PriceItem()
end)
self.controls.priceDisplayItem.tooltipFunc = function(tooltip)
tooltip:Clear()
tooltip:AddLine(16, "^7Contains searches from the official trading site to help find")
tooltip:AddLine(16, "^7similar or better items for this build")
end
-- Item slots
self.slots = { }
self.orderedSlots = { }
self.slotOrder = { }
self.slotAnchor = new("Control", {"TOPLEFT",self,"TOPLEFT"}, 96, 76, 310, 0)
local prevSlot = self.slotAnchor
local function addSlot(slot)
prevSlot = slot
self.slots[slot.slotName] = slot
t_insert(self.orderedSlots, slot)
self.slotOrder[slot.slotName] = #self.orderedSlots
t_insert(self.controls, slot)
end
for index, slotName in ipairs(baseSlots) do
local slot = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName)
addSlot(slot)
if slotName:match("Weapon") then
-- Add alternate weapon slot
slot.weaponSet = 1
slot.shown = function()
return not self.activeItemSet.useSecondWeaponSet
end
local swapSlot = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.." Swap", slotName)
addSlot(swapSlot)
swapSlot.weaponSet = 2
swapSlot.shown = function()
return self.activeItemSet.useSecondWeaponSet
end
for i = 1, 6 do
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.."Swap Abyssal Socket "..i, "Abyssal #"..i)
addSlot(abyssal)
abyssal.parentSlot = swapSlot
abyssal.weaponSet = 2
abyssal.shown = function()
return not abyssal.inactive and self.activeItemSet.useSecondWeaponSet
end
swapSlot.abyssalSocketList[i] = abyssal
end
end
if slotName == "Weapon 1" or slotName == "Weapon 2" or slotName == "Helmet" or slotName == "Gloves" or slotName == "Body Armour" or slotName == "Boots" or slotName == "Belt" then
-- Add Abyssal Socket slots
for i = 1, 6 do
local abyssal = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, slotName.." Abyssal Socket "..i, "Abyssal #"..i)
addSlot(abyssal)
abyssal.parentSlot = slot
if slotName:match("Weapon") then
abyssal.weaponSet = 1
abyssal.shown = function()
return not abyssal.inactive and not self.activeItemSet.useSecondWeaponSet
end
end
slot.abyssalSocketList[i] = abyssal
end
end
end
-- Passive tree dropdown controls
self.controls.specSelect = new("DropDownControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 8, 216, 20, nil, function(index, value)
if self.build.treeTab.specList[index] then
self.build.modFlag = true
self.build.treeTab:SetActiveSpec(index)
end
end)
self.controls.specSelect.enabled = function()
return #self.controls.specSelect.list > 1
end
prevSlot = self.controls.specSelect
self.controls.specButton = new("ButtonControl", {"LEFT",prevSlot,"RIGHT"}, 4, 0, 90, 20, "Manage...", function()
self.build.treeTab:OpenSpecManagePopup()
end)
self.controls.specLabel = new("LabelControl", {"RIGHT",prevSlot,"LEFT"}, -2, 0, 0, 16, "^7Passive tree:")
self.sockets = { }
local socketOrder = { }
for _, node in pairs(build.latestTree.nodes) do
if node.type == "Socket" then
t_insert(socketOrder, node)
end
end
table.sort(socketOrder, function(a, b)
return a.id < b.id
end)
for _, node in ipairs(socketOrder) do
local socketControl = new("ItemSlotControl", {"TOPLEFT",prevSlot,"BOTTOMLEFT"}, 0, 2, self, "Jewel "..node.id, "Socket", node.id)
self.sockets[node.id] = socketControl
addSlot(socketControl)
end
self.controls.slotHeader = new("LabelControl", {"BOTTOMLEFT",self.slotAnchor,"TOPLEFT"}, 0, -4, 0, 16, "^7Equipped items:")
self.controls.weaponSwap1 = new("ButtonControl", {"BOTTOMRIGHT",self.slotAnchor,"TOPRIGHT"}, -20, -2, 18, 18, "I", function()
if self.activeItemSet.useSecondWeaponSet then
self.activeItemSet.useSecondWeaponSet = false
self:AddUndoState()
self.build.buildFlag = true
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.build.mainSocketGroup]
if mainSocketGroup and mainSocketGroup.slot and self.slots[mainSocketGroup.slot].weaponSet == 2 then
for index, socketGroup in ipairs(self.build.skillsTab.socketGroupList) do
if socketGroup.slot and self.slots[socketGroup.slot].weaponSet == 1 then
self.build.mainSocketGroup = index
break
end
end
end
end
end)
self.controls.weaponSwap1.overSizeText = 3
self.controls.weaponSwap1.locked = function()
return not self.activeItemSet.useSecondWeaponSet
end
self.controls.weaponSwap2 = new("ButtonControl", {"BOTTOMRIGHT",self.slotAnchor,"TOPRIGHT"}, 0, -2, 18, 18, "II", function()
if not self.activeItemSet.useSecondWeaponSet then
self.activeItemSet.useSecondWeaponSet = true
self:AddUndoState()
self.build.buildFlag = true
local mainSocketGroup = self.build.skillsTab.socketGroupList[self.build.mainSocketGroup]
if mainSocketGroup and mainSocketGroup.slot and self.slots[mainSocketGroup.slot].weaponSet == 1 then
for index, socketGroup in ipairs(self.build.skillsTab.socketGroupList) do
if socketGroup.slot and self.slots[socketGroup.slot].weaponSet == 2 then
self.build.mainSocketGroup = index
break
end
end
end
end
end)
self.controls.weaponSwap2.overSizeText = 3
self.controls.weaponSwap2.locked = function()
return self.activeItemSet.useSecondWeaponSet
end
self.controls.weaponSwapLabel = new("LabelControl", {"RIGHT",self.controls.weaponSwap1,"LEFT"}, -4, 0, 0, 14, "^7Weapon Set:")
-- All items list
if main.portraitMode then
self.controls.itemList = new("ItemListControl", {"TOPRIGHT",self.controls.specButton,"BOTTOMRIGHT"}, 0, 20, 360, 308, self, true)
else
self.controls.itemList = new("ItemListControl", {"TOPLEFT",self.controls.setManage,"TOPRIGHT"}, 20, 20, 360, 308, self, true)
end
-- Database selector
self.controls.selectDBLabel = new("LabelControl", {"TOPLEFT",self.controls.itemList,"BOTTOMLEFT"}, 0, 14, 0, 16, "^7Import from:")
self.controls.selectDBLabel.shown = function()
return self.height < 980
end
self.controls.selectDB = new("DropDownControl", {"LEFT",self.controls.selectDBLabel,"RIGHT"}, 4, 0, 150, 18, { "Uniques", "Rare Templates" })
-- Unique database
self.controls.uniqueDB = new("ItemDBControl", {"TOPLEFT",self.controls.itemList,"BOTTOMLEFT"}, 0, 76, 360, function(c) return m_min(244, self.maxY - select(2, c:GetPos())) end, self, main.uniqueDB, "UNIQUE")
self.controls.uniqueDB.y = function()
return self.controls.selectDBLabel:IsShown() and 118 or 96
end
self.controls.uniqueDB.shown = function()
return not self.controls.selectDBLabel:IsShown() or self.controls.selectDB.selIndex == 1
end
-- Rare template database
self.controls.rareDB = new("ItemDBControl", {"TOPLEFT",self.controls.itemList,"BOTTOMLEFT"}, 0, 76, 360, function(c) return m_min(260, self.maxY - select(2, c:GetPos())) end, self, main.rareDB, "RARE")
self.controls.rareDB.y = function()
return self.controls.selectDBLabel:IsShown() and 78 or 396
end
self.controls.rareDB.shown = function()
return not self.controls.selectDBLabel:IsShown() or self.controls.selectDB.selIndex == 2
end
-- Create/import item
self.controls.craftDisplayItem = new("ButtonControl", {"TOPLEFT",main.portraitMode and self.controls.setManage or self.controls.itemList,"TOPRIGHT"}, 20, main.portraitMode and 0 or -20, 120, 20, "Craft item...", function()
self:CraftItem()
end)
self.controls.craftDisplayItem.shown = function()
return self.displayItem == nil
end
self.controls.newDisplayItem = new("ButtonControl", {"TOPLEFT",self.controls.craftDisplayItem,"TOPRIGHT"}, 8, 0, 120, 20, "Create custom...", function()
self:EditDisplayItemText()
end)
self.controls.displayItemTip = new("LabelControl", {"TOPLEFT",self.controls.craftDisplayItem,"BOTTOMLEFT"}, 0, 8, 100, 16,
[[^7Double-click an item from one of the lists,
or copy and paste an item from in game
(hover over the item and Ctrl+C) to view or edit
the item and add it to your build. You can
also clone an item within Path of Building by
copying and pasting it with Ctrl+C and Ctrl+V.
You can Control + Click an item to equip it, or
drag it onto the slot. This will also add it to
your build if it's from the unique/template list.
If there's 2 slots an item can go in,
holding Shift will put it in the second.]])
self.controls.sharedItemList = new("SharedItemListControl", {"TOPLEFT",self.controls.craftDisplayItem, "BOTTOMLEFT"}, 0, 232, 340, 308, self, true)
-- Display item
self.displayItemTooltip = new("Tooltip")
self.displayItemTooltip.maxWidth = 458
self.anchorDisplayItem = new("Control", {"TOPLEFT",main.portraitMode and self.controls.setManage or self.controls.itemList,"TOPRIGHT"}, 20, main.portraitMode and 0 or -20, 0, 0)
self.anchorDisplayItem.shown = function()
return self.displayItem ~= nil
end
self.controls.addDisplayItem = new("ButtonControl", {"TOPLEFT",self.anchorDisplayItem,"TOPLEFT"}, 0, 0, 100, 20, "", function()
self:AddDisplayItem()
end)
self.controls.addDisplayItem.label = function()
return self.items[self.displayItem.id] and "Save" or "Add to build"
end
self.controls.editDisplayItem = new("ButtonControl", {"LEFT",self.controls.addDisplayItem,"RIGHT"}, 8, 0, 60, 20, "Edit...", function()
self:EditDisplayItemText()
end)
self.controls.removeDisplayItem = new("ButtonControl", {"LEFT",self.controls.editDisplayItem,"RIGHT"}, 8, 0, 60, 20, "Cancel", function()
self:SetDisplayItem()
end)
-- Section: Variant(s)
self.controls.displayItemSectionVariant = new("Control", {"TOPLEFT",self.controls.addDisplayItem,"BOTTOMLEFT"}, 0, 8, 0, function()
if not self.controls.displayItemVariant:IsShown() then
return 0
end
return (28 +
(self.displayItem.hasAltVariant and 24 or 0) +
(self.displayItem.hasAltVariant2 and 24 or 0) +
(self.displayItem.hasAltVariant3 and 24 or 0) +
(self.displayItem.hasAltVariant4 and 24 or 0) +
(self.displayItem.hasAltVariant5 and 24 or 0))
end)
self.controls.displayItemVariant = new("DropDownControl", {"TOPLEFT", self.controls.displayItemSectionVariant,"TOPLEFT"}, 0, 0, 300, 20, nil, function(index, value)
self.displayItem.variant = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemVariant.maxDroppedWidth = 1000
self.controls.displayItemVariant.shown = function()
return self.displayItem.variantList and #self.displayItem.variantList > 1
end
self.controls.displayItemAltVariant = new("DropDownControl", {"TOPLEFT",self.controls.displayItemVariant,"BOTTOMLEFT"}, 0, 4, 300, 20, nil, function(index, value)
self.displayItem.variantAlt = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemAltVariant.maxDroppedWidth = 1000
self.controls.displayItemAltVariant.shown = function()
return self.displayItem.hasAltVariant
end
self.controls.displayItemAltVariant2 = new("DropDownControl", {"TOPLEFT",self.controls.displayItemAltVariant,"BOTTOMLEFT"}, 0, 4, 300, 20, nil, function(index, value)
self.displayItem.variantAlt2 = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemAltVariant2.maxDroppedWidth = 1000
self.controls.displayItemAltVariant2.shown = function()
return self.displayItem.hasAltVariant2
end
self.controls.displayItemAltVariant3 = new("DropDownControl", {"TOPLEFT",self.controls.displayItemAltVariant2,"BOTTOMLEFT"}, 0, 4, 300, 20, nil, function(index, value)
self.displayItem.variantAlt3 = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemAltVariant3.maxDroppedWidth = 1000
self.controls.displayItemAltVariant3.shown = function()
return self.displayItem.hasAltVariant3
end
self.controls.displayItemAltVariant4 = new("DropDownControl", {"TOPLEFT",self.controls.displayItemAltVariant3,"BOTTOMLEFT"}, 0, 4, 300, 20, nil, function(index, value)
self.displayItem.variantAlt4 = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemAltVariant4.maxDroppedWidth = 1000
self.controls.displayItemAltVariant4.shown = function()
return self.displayItem.hasAltVariant4
end
self.controls.displayItemAltVariant5 = new("DropDownControl", {"TOPLEFT",self.controls.displayItemAltVariant4,"BOTTOMLEFT"}, 0, 4, 300, 20, nil, function(index, value)
self.displayItem.variantAlt5 = index
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateDisplayItemRangeLines()
end)
self.controls.displayItemAltVariant5.maxDroppedWidth = 1000
self.controls.displayItemAltVariant5.shown = function()
return self.displayItem.hasAltVariant5
end
-- Section: Sockets and Links
self.controls.displayItemSectionSockets = new("Control", {"TOPLEFT",self.controls.displayItemSectionVariant,"BOTTOMLEFT"}, 0, 0, 0, function()
return self.displayItem and self.displayItem.selectableSocketCount > 0 and 28 or 0
end)
for i = 1, 6 do
local drop = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionSockets,"TOPLEFT"}, (i-1) * 64, 0, 36, 20, socketDropList, function(index, value)
self.displayItem.sockets[i].color = value.color
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
end)
drop.shown = function()
return self.displayItem.selectableSocketCount >= i and self.displayItem.sockets[i] and self.displayItem.sockets[i].color ~= "A"
end
self.controls["displayItemSocket"..i] = drop
if i < 6 then
local link = new("CheckBoxControl", {"LEFT",drop,"RIGHT"}, 4, 0, 20, nil, function(state)
if state and self.displayItem.sockets[i].group ~= self.displayItem.sockets[i+1].group then
for s = i + 1, #self.displayItem.sockets do
self.displayItem.sockets[s].group = self.displayItem.sockets[s].group - 1
end
elseif not state and self.displayItem.sockets[i].group == self.displayItem.sockets[i+1].group then
for s = i + 1, #self.displayItem.sockets do
self.displayItem.sockets[s].group = self.displayItem.sockets[s].group + 1
end
end
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
end)
link.shown = function()
return self.displayItem.selectableSocketCount > i and self.displayItem.sockets[i+1] and self.displayItem.sockets[i+1].color ~= "A"
end
self.controls["displayItemLink"..i] = link
end
end
self.controls.displayItemAddSocket = new("ButtonControl", {"TOPLEFT",self.controls.displayItemSectionSockets,"TOPLEFT"}, function() return (#self.displayItem.sockets - self.displayItem.abyssalSocketCount) * 64 - 12 end, 0, 20, 20, "+", function()
local insertIndex = #self.displayItem.sockets - self.displayItem.abyssalSocketCount + 1
t_insert(self.displayItem.sockets, insertIndex, {
color = self.displayItem.defaultSocketColor,
group = self.displayItem.sockets[insertIndex - 1].group + 1
})
for s = insertIndex + 1, #self.displayItem.sockets do
self.displayItem.sockets[s].group = self.displayItem.sockets[s].group + 1
end
self.displayItem:BuildAndParseRaw()
self:UpdateSocketControls()
self:UpdateDisplayItemTooltip()
end)
self.controls.displayItemAddSocket.shown = function()
return #self.displayItem.sockets < self.displayItem.selectableSocketCount + self.displayItem.abyssalSocketCount
end
-- Section: Enchant / Anoint / Corrupt
self.controls.displayItemSectionEnchant = new("Control", {"TOPLEFT",self.controls.displayItemSectionSockets,"BOTTOMLEFT"}, 0, 0, 0, function()
return (self.controls.displayItemEnchant:IsShown() or self.controls.displayItemEnchant2:IsShown() or self.controls.displayItemAnoint:IsShown() or self.controls.displayItemAnoint2:IsShown() or self.controls.displayItemCorrupt:IsShown() ) and 28 or 0
end)
self.controls.displayItemEnchant = new("ButtonControl", {"TOPLEFT",self.controls.displayItemSectionEnchant,"TOPLEFT"}, 0, 0, 160, 20, "Apply Enchantment...", function()
self:EnchantDisplayItem(1)
end)
self.controls.displayItemEnchant.shown = function()
return self.displayItem and self.displayItem.enchantments
end
self.controls.displayItemEnchant2 = new("ButtonControl", {"TOPLEFT",self.controls.displayItemEnchant,"TOPRIGHT",true}, 8, 0, 160, 20, "Apply Enchantment 2...", function()
self:EnchantDisplayItem(2)
end)
self.controls.displayItemEnchant2.shown = function()
return self.displayItem and self.displayItem.enchantments and self.displayItem.canHaveTwoEnchants and #self.displayItem.enchantModLines > 0
end
self.controls.displayItemAnoint = new("ButtonControl", {"TOPLEFT",self.controls.displayItemEnchant2,"TOPRIGHT",true}, 8, 0, 100, 20, "Anoint...", function()
self:AnointDisplayItem(1)
end)
self.controls.displayItemAnoint.shown = function()
return self.displayItem and (self.displayItem.base.type == "Amulet" or self.displayItem.canBeAnointed)
end
self.controls.displayItemAnoint2 = new("ButtonControl", {"TOPLEFT",self.controls.displayItemAnoint,"TOPRIGHT",true}, 8, 0, 100, 20, "Anoint 2...", function()
self:AnointDisplayItem(2)
end)
self.controls.displayItemAnoint2.shown = function()
return self.displayItem and
(self.displayItem.base.type == "Amulet" or self.displayItem.canBeAnointed) and
self.displayItem.canHaveTwoEnchants and
#self.displayItem.enchantModLines > 0
end
self.controls.displayItemAnoint3 = new("ButtonControl", {"TOPLEFT",self.controls.displayItemAnoint2,"TOPRIGHT",true}, 8, 0, 100, 20, "Anoint 3...", function()
self:AnointDisplayItem(3)
end)
self.controls.displayItemAnoint3.shown = function()
return self.displayItem and
(self.displayItem.base.type == "Amulet" or self.displayItem.canBeAnointed) and
self.displayItem.canHaveThreeEnchants and
#self.displayItem.enchantModLines > 1
end
self.controls.displayItemAnoint4 = new("ButtonControl", {"TOPLEFT",self.controls.displayItemAnoint3,"TOPRIGHT",true}, 8, 0, 100, 20, "Anoint 4...", function()
self:AnointDisplayItem(4)
end)
self.controls.displayItemAnoint4.shown = function()
return self.displayItem and
(self.displayItem.base.type == "Amulet" or self.displayItem.canBeAnointed) and
self.displayItem.canHaveFourEnchants and
#self.displayItem.enchantModLines > 2
end
self.controls.displayItemCorrupt = new("ButtonControl", {"TOPLEFT",self.controls.displayItemAnoint4,"TOPRIGHT",true}, 8, 10, 100, 20, "Corrupt...", function()
self:CorruptDisplayItem("Corrupted")
end)
self.controls.displayItemCorrupt.shown = function()
return self.displayItem and self.displayItem.corruptible
end
--[[
self.controls.displayItemScourge = new("ButtonControl", {"TOPLEFT",self.controls.displayItemCorrupt,"TOPRIGHT",true}, 8, 0, 100, 20, "Scourge...", function()
self:CorruptDisplayItem("Scourge")
end)
self.controls.displayItemScourge.shown = function()
return self.displayItem and self.displayItem.corruptible
end
--]]
self.controls.displayItemAddImplicit = new("ButtonControl", {"TOPLEFT",self.controls.displayItemCorrupt,"TOPRIGHT",true}, 8, 0, 120, 20, "Add Implicit...", function()
self:AddImplicitToDisplayItem()
end)
self.controls.displayItemAddImplicit.shown = function()
return self.displayItem and (self.displayItem.corruptible or ((self.displayItem.type ~= "Flask" or self.displayItem.type ~= "Jewel") and (self.displayItem.rarity == "NORMAL" or self.displayItem.rarity == "MAGIC" or self.displayItem.rarity == "RARE")))
end
-- Section: Influence dropdowns
local influenceDisplayList = { "Influence" }
for i, curInfluenceInfo in ipairs(influenceInfo) do
influenceDisplayList[i + 1] = curInfluenceInfo.display
end
local function setDisplayItemInfluence(influenceIndexList)
self.displayItem:ResetInfluence()
for _, index in ipairs(influenceIndexList) do
if index > 0 then
self.displayItem[influenceInfo[index].key] = true;
end
end
if self.displayItem.crafted then
for i = 1, self.displayItem.affixLimit do
-- Force affix selectors to update
local drop = self.controls["displayItemAffix"..i]
drop.selFunc(drop.selIndex, drop.list[drop.selIndex])
end
end
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
end
self.controls.displayItemSectionInfluence = new("Control", {"TOPLEFT",self.controls.displayItemSectionEnchant,"BOTTOMLEFT"}, 0, 0, 0, function()
return self.displayItem and self.displayItem.canBeInfluenced and 28 or 0
end)
self.controls.displayItemInfluence = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionInfluence,"TOPRIGHT"}, 0, 0, 100, 20, influenceDisplayList, function(index, value)
local otherIndex = self.controls.displayItemInfluence2.selIndex
setDisplayItemInfluence({ index - 1, otherIndex - 1 })
end)
self.controls.displayItemInfluence.shown = function()
return self.displayItem and self.displayItem.canBeInfluenced
end
self.controls.displayItemInfluence2 = new("DropDownControl", {"TOPLEFT",self.controls.displayItemInfluence,"TOPRIGHT",true}, 8, 0, 100, 20, influenceDisplayList, function(index, value)
local otherIndex = self.controls.displayItemInfluence.selIndex
setDisplayItemInfluence({ index - 1, otherIndex - 1 })
end)
self.controls.displayItemInfluence2.shown = function()
return self.displayItem and self.displayItem.canBeInfluenced
end
-- Section: Catalysts
self.controls.displayItemSectionCatalyst = new("Control", {"TOPLEFT",self.controls.displayItemSectionInfluence,"BOTTOMLEFT"}, 0, 0, 0, function()
return (self.controls.displayItemCatalyst:IsShown() or self.controls.displayItemCatalystQualitySlider:IsShown()) and 28 or 0
end)
self.controls.displayItemCatalyst = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionCatalyst,"TOPRIGHT"}, 0, 0, 180, 20,
{"Catalyst","Abrasive (Attack)","Accelerating (Speed)","Fertile (Life & Mana)","Imbued (Caster)","Intrinsic (Attribute)","Noxious (Physical & Chaos)",
"Prismatic (Resistance)","Tempering (Defense)","Turbulent (Elemental)","Unstable (Critical)"},
function(index, value)
self.displayItem.catalyst = index - 1
if not self.displayItem.catalystQuality then
self.displayItem.catalystQuality = 20
end
if self.displayItem.crafted then
for i = 1, self.displayItem.affixLimit do
-- Force affix selectors to update
local drop = self.controls["displayItemAffix"..i]
drop.selFunc(drop.selIndex, drop.list[drop.selIndex])
end
end
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
end)
self.controls.displayItemCatalyst.shown = function()
return self.displayItem and (self.displayItem.crafted or self.displayItem.hasModTags) and (self.displayItem.base.type == "Amulet" or self.displayItem.base.type == "Ring" or self.displayItem.base.type == "Belt")
end
self.controls.displayItemCatalystQualitySlider = new("SliderControl", {"LEFT",self.controls.displayItemCatalyst,"RIGHT",true}, 8, 0, 200, 20, function(val)
self.displayItem.catalystQuality = round(val * 20)
if self.displayItem.crafted then
for i = 1, self.displayItem.affixLimit do
-- Force affix selectors to update
local drop = self.controls["displayItemAffix"..i]
drop.selFunc(drop.selIndex, drop.list[drop.selIndex])
end
end
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
end)
self.controls.displayItemCatalystQualitySlider.shown = function()
return self.displayItem and (self.displayItem.crafted or self.displayItem.hasModTags) and self.displayItem.catalyst and self.displayItem.catalyst > 0
end
self.controls.displayItemCatalystQualitySlider.tooltipFunc = function(tooltip, val)
local quality = round(val * 20)
tooltip:Clear()
tooltip:AddLine(16, "^7Quality: "..quality.."%")
end
-- Section: Cluster Jewel
self.controls.displayItemSectionClusterJewel = new("Control", {"TOPLEFT",self.controls.displayItemSectionCatalyst,"BOTTOMLEFT"}, 0, 0, 0, function()
return self.controls.displayItemClusterJewelSkill:IsShown() and 52 or 0
end)
self.controls.displayItemClusterJewelSkill = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionClusterJewel,"TOPLEFT"}, 0, 0, 300, 20, { }, function(index, value)
self.displayItem.clusterJewelSkill = value.skillId
self:CraftClusterJewel()
end) {
shown = function()
return self.displayItem and self.displayItem.crafted and self.displayItem.clusterJewel
end
}
self.controls.displayItemClusterJewelNodeCountLabel = new("LabelControl", {"TOPLEFT",self.controls.displayItemClusterJewelSkill,"BOTTOMLEFT"}, 0, 7, 0, 14, "^7Added Passives:")
self.controls.displayItemClusterJewelNodeCount = new("SliderControl", {"LEFT",self.controls.displayItemClusterJewelNodeCountLabel,"RIGHT"}, 2, 0, 150, 20, function(val)
local divVal = self.controls.displayItemClusterJewelNodeCount:GetDivVal()
local clusterJewel = self.displayItem.clusterJewel
self.displayItem.clusterJewelNodeCount = round(val * (clusterJewel.maxNodes - clusterJewel.minNodes) + clusterJewel.minNodes)
self:CraftClusterJewel()
end)
-- Section: Affix Selection
self.controls.displayItemSectionAffix = new("Control", {"TOPLEFT",self.controls.displayItemSectionClusterJewel,"BOTTOMLEFT"}, 0, 0, 0, function()
if not self.displayItem or not self.displayItem.crafted then
return 0
end
local h = 6
for i = 1, 6 do
if self.controls["displayItemAffix"..i]:IsShown() then
h = h + 24
if self.controls["displayItemAffixRange"..i]:IsShown() then
h = h + 18
end
end
end
return h
end)
for i = 1, 6 do
local prev = self.controls["displayItemAffix"..(i-1)] or self.controls.displayItemSectionAffix
local drop, slider
drop = new("DropDownControl", {"TOPLEFT",prev,"TOPLEFT"}, i==1 and 40 or 0, 0, 418, 20, nil, function(index, value)
local affix = { modId = "None" }
if value.modId then
affix.modId = value.modId
affix.range = slider.val
elseif value.modList then
slider.divCount = #value.modList
local index, range = slider:GetDivVal()
affix.modId = value.modList[index]
affix.range = range
end
self.displayItem[drop.outputTable][drop.outputIndex] = affix
self.displayItem:Craft()
self:UpdateDisplayItemTooltip()
self:UpdateAffixControls()
end)
drop.y = function()
return i == 1 and 0 or 24 + (prev.slider:IsShown() and 18 or 0)
end
drop.tooltipFunc = function(tooltip, mode, index, value)
local modList = value.modList
if not modList or main.popups[1] or mode == "OUT" or (self.selControl and self.selControl ~= drop) then
tooltip:Clear()
elseif tooltip:CheckForUpdate(modList) then
if value.modId or #modList == 1 then
local mod = self.displayItem.affixes[value.modId or modList[1]]
tooltip:AddLine(16, "^7Affix: "..mod.affix)
for _, line in ipairs(mod) do
tooltip:AddLine(14, "^7"..line)
end
if mod.level > 1 then
tooltip:AddLine(16, "Level: "..mod.level)
end
if mod.modTags and #mod.modTags > 0 then
tooltip:AddLine(16, "Tags: "..table.concat(mod.modTags, ', '))
end
local notableName = mod[1] and mod[1]:match("1 Added Passive Skill is (.*)")
local node = notableName and self.build.spec.tree.clusterNodeMap[notableName]
if node then
tooltip:AddSeparator(14)
-- Node name
self.socketViewer:AddNodeName(tooltip, node, self.build)
-- Node description
if node.sd[1] then
tooltip:AddLine(16, "")
for i, line in ipairs(node.sd) do
tooltip:AddLine(16, ((node.mods[i].extra or not node.mods[i].list) and colorCodes.UNSUPPORTED or colorCodes.MAGIC)..line)
end
end
-- Reminder text
if node.reminderText then
tooltip:AddSeparator(14)
for _, line in ipairs(node.reminderText) do
tooltip:AddLine(14, "^xA0A080"..line)
end
end
-- Comparison
tooltip:AddSeparator(14)
self:AppendAnointTooltip(tooltip, node, "Allocating")
-- Information of for this notable appears
local clusterInfo = self.build.data.clusterJewelInfoForNotable[notableName]
if clusterInfo then
tooltip:AddSeparator(14)
tooltip:AddLine(20, "^7"..notableName.." can appear on:")
local isFirstSize = true
for size, v in pairs(clusterInfo.size) do
tooltip:AddLine(18, colorCodes.MAGIC..size..":")
local sizeSkills = self.build.data.clusterJewels.jewels[size].skills
for i, type in ipairs(clusterInfo.jewelTypes) do
if sizeSkills[type] then
tooltip:AddLine(14, "^7 "..sizeSkills[type].name)
end
end
if not isFirstSize then
tooltip:AddLine(10, "")
end
isFirstSize = false
end
end
end
else
tooltip:AddLine(16, "^7"..#modList.." Tiers")
local minMod = self.displayItem.affixes[modList[1]]
local maxMod = self.displayItem.affixes[modList[#modList]]
for l, line in ipairs(minMod) do
local minLine = line:gsub("%((%d[%d%.]*)%-(%d[%d%.]*)%)", "%1")
local maxLine = maxMod[l]:gsub("%((%d[%d%.]*)%-(%d[%d%.]*)%)", "%2")
if maxLine == maxMod[l] then
tooltip:AddLine(14, maxLine)
else
local start = 1
tooltip:AddLine(14, minLine:gsub("%d[%d%.]*", function(min)
local s, e, max = maxLine:find("(%d[%d%.]*)", start)
start = e + 1
if min == max then
return min
else
return "("..min.."-"..max..")"
end
end))
end
end
tooltip:AddLine(16, "Level: "..minMod.level.." to "..maxMod.level)
-- Assuming that all mods have the same tags
if maxMod.modTags and #maxMod.modTags > 0 then
tooltip:AddLine(16, "Tags: "..table.concat(maxMod.modTags, ', '))
end
end
end
end
drop.shown = function()
return self.displayItem and self.displayItem.crafted and i <= self.displayItem.affixLimit
end
slider = new("SliderControl", {"TOPLEFT",drop,"BOTTOMLEFT"}, 0, 2, 300, 16, function(val)
local affix = self.displayItem[drop.outputTable][drop.outputIndex]
local index, range = slider:GetDivVal()
affix.modId = drop.list[drop.selIndex].modList[index]
affix.range = range
self.displayItem:Craft()
self:UpdateDisplayItemTooltip()
end)
slider.width = function()
return slider.divCount and 300 or 100
end
slider.tooltipFunc = function(tooltip, val)
local modList = drop.list[drop.selIndex].modList
if not modList or main.popups[1] or (self.selControl and self.selControl ~= slider) then
tooltip:Clear()
elseif tooltip:CheckForUpdate(val, modList) then
local index, range = slider:GetDivVal(val)
local modId = modList[index]
local mod = self.displayItem.affixes[modId]
for _, line in ipairs(mod) do
tooltip:AddLine(16, itemLib.applyRange(line, range))
end
tooltip:AddSeparator(10)
if #modList > 1 then
tooltip:AddLine(16, "^7Affix: Tier "..(#modList - isValueInArray(modList, modId) + 1).." ("..mod.affix..")")
else
tooltip:AddLine(16, "^7Affix: "..mod.affix)
end
for _, line in ipairs(mod) do
tooltip:AddLine(14, line)
end
if mod.level > 1 then
tooltip:AddLine(16, "Level: "..mod.level)
end
end
end
drop.slider = slider
self.controls["displayItemAffix"..i] = drop
self.controls["displayItemAffixLabel"..i] = new("LabelControl", {"RIGHT",drop,"LEFT"}, -4, 0, 0, 14, function()
return drop.outputTable == "prefixes" and "^7Prefix:" or "^7Suffix:"
end)
self.controls["displayItemAffixRange"..i] = slider
self.controls["displayItemAffixRangeLabel"..i] = new("LabelControl", {"RIGHT",slider,"LEFT"}, -4, 0, 0, 14, function()
return drop.selIndex > 1 and "^7Roll:" or "^x7F7F7FRoll:"
end)
end
-- Section: Custom modifiers
self.controls.displayItemSectionCustom = new("Control", {"TOPLEFT",self.controls.displayItemSectionAffix,"BOTTOMLEFT"}, 0, 0, 0, function()
return self.controls.displayItemAddCustom:IsShown() and 28 + self.displayItem.customCount * 22 or 0
end)
self.controls.displayItemAddCustom = new("ButtonControl", {"TOPLEFT",self.controls.displayItemSectionCustom,"TOPLEFT"}, 0, 0, 120, 20, "Add modifier...", function()
self:AddCustomModifierToDisplayItem()
end)
self.controls.displayItemAddCustom.shown = function()
return self.displayItem and (self.displayItem.rarity == "MAGIC" or self.displayItem.rarity == "RARE")
end
-- Section: Modifier Range
self.controls.displayItemSectionRange = new("Control", {"TOPLEFT",self.controls.displayItemSectionCustom,"BOTTOMLEFT"}, 0, 0, 0, function()
return self.displayItem.rangeLineList[1] and 28 or 0
end)
self.controls.displayItemRangeLine = new("DropDownControl", {"TOPLEFT",self.controls.displayItemSectionRange,"TOPLEFT"}, 0, 0, 350, 18, nil, function(index, value)
self.controls.displayItemRangeSlider.val = self.displayItem.rangeLineList[index].range
end)
self.controls.displayItemRangeLine.shown = function()
return self.displayItem and self.displayItem.rangeLineList[1] ~= nil
end
self.controls.displayItemRangeSlider = new("SliderControl", {"LEFT",self.controls.displayItemRangeLine,"RIGHT"}, 8, 0, 100, 18, function(val)
self.displayItem.rangeLineList[self.controls.displayItemRangeLine.selIndex].range = val
self.displayItem:BuildAndParseRaw()
self:UpdateDisplayItemTooltip()
self:UpdateCustomControls()
end)
-- Tooltip anchor
self.controls.displayItemTooltipAnchor = new("Control", {"TOPLEFT",self.controls.displayItemSectionRange,"BOTTOMLEFT"})
-- Scroll bars
self.controls.scrollBarH = new("ScrollBarControl", nil, 0, 0, 0, 18, 100, "HORIZONTAL", true)
self.controls.scrollBarV = new("ScrollBarControl", nil, 0, 0, 18, 0, 100, "VERTICAL", true)
-- Initialise drag target lists
t_insert(self.controls.itemList.dragTargetList, self.controls.sharedItemList)
t_insert(self.controls.itemList.dragTargetList, build.controls.mainSkillMinion)
t_insert(self.controls.uniqueDB.dragTargetList, self.controls.itemList)
t_insert(self.controls.uniqueDB.dragTargetList, self.controls.sharedItemList)
t_insert(self.controls.uniqueDB.dragTargetList, build.controls.mainSkillMinion)
t_insert(self.controls.rareDB.dragTargetList, self.controls.itemList)
t_insert(self.controls.rareDB.dragTargetList, self.controls.sharedItemList)
t_insert(self.controls.rareDB.dragTargetList, build.controls.mainSkillMinion)
t_insert(self.controls.sharedItemList.dragTargetList, self.controls.itemList)
t_insert(self.controls.sharedItemList.dragTargetList, build.controls.mainSkillMinion)
for _, slot in pairs(self.slots) do
t_insert(self.controls.itemList.dragTargetList, slot)
t_insert(self.controls.uniqueDB.dragTargetList, slot)
t_insert(self.controls.rareDB.dragTargetList, slot)
t_insert(self.controls.sharedItemList.dragTargetList, slot)
end
-- Initialise item sets
self.itemSets = { }
self.itemSetOrderList = { 1 }
self:NewItemSet(1)
self:SetActiveItemSet(1)
self:PopulateSlots()
self.lastSlot = self.slots[baseSlots[#baseSlots]]
end)
function ItemsTabClass:Load(xml, dbFileName)
self.activeItemSetId = 0
self.itemSets = { }
self.itemSetOrderList = { }
for _, node in ipairs(xml) do
if node.elem == "Item" then
local item = new("Item", "")
item.id = tonumber(node.attrib.id)
item.variant = tonumber(node.attrib.variant)
if node.attrib.variantAlt then
item.hasAltVariant = true
item.variantAlt = tonumber(node.attrib.variantAlt)
end
if node.attrib.variantAlt2 then
item.hasAltVariant2 = true
item.variantAlt2 = tonumber(node.attrib.variantAlt2)
end
if node.attrib.variantAlt3 then
item.hasAltVariant3 = true
item.variantAlt3 = tonumber(node.attrib.variantAlt3)
end
if node.attrib.variantAlt4 then
item.hasAltVariant4 = true
item.variantAlt4 = tonumber(node.attrib.variantAlt4)
end
if node.attrib.variantAlt5 then
item.hasAltVariant5 = true
item.variantAlt5 = tonumber(node.attrib.variantAlt5)
end
for _, child in ipairs(node) do
if type(child) == "string" then
item:ParseRaw(child)
elseif child.elem == "ModRange" then
local id = tonumber(child.attrib.id) or 0
local range = tonumber(child.attrib.range) or 1
-- This is garbage, but needed due to change to separate mod line lists
-- 'ModRange' elements are legacy though, so is this actually needed? :<
-- Maybe it is? Maybe it isn't? Maybe up is down? Maybe good is bad? AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-- Sorry, cluster jewels are making me crazy(-ier)
for _, list in ipairs{item.buffModLines, item.enchantModLines, item.scourgeModLines, item.implicitModLines, item.explicitModLines} do
if id <= #list then
list[id].range = range
break
end
id = id - #list
end
end
end
if item.base then
item:BuildModList()
self.items[item.id] = item
t_insert(self.itemOrderList, item.id)
end
-- Below is OBE and left for legacy compatibility (all Slots are part of ItemSets now)
elseif node.elem == "Slot" then
local slot = self.slots[node.attrib.name or ""]
if slot then
slot.selItemId = tonumber(node.attrib.itemId)
if slot.controls.activate then
slot.active = node.attrib.active == "true"
slot.controls.activate.state = slot.active
end
end
elseif node.elem == "ItemSet" then
local itemSet = self:NewItemSet(tonumber(node.attrib.id))
itemSet.title = node.attrib.title
itemSet.useSecondWeaponSet = node.attrib.useSecondWeaponSet == "true"
for _, child in ipairs(node) do
if child.elem == "Slot" then
local slotName = child.attrib.name or ""
if itemSet[slotName] then
itemSet[slotName].selItemId = tonumber(child.attrib.itemId)
itemSet[slotName].active = child.attrib.active == "true"
itemSet[slotName].pbURL = child.attrib.itemPbURL or ""
end
elseif child.elem == "SocketIdURL" then
local id = tonumber(child.attrib.nodeId)
itemSet[id] = { pbURL = child.attrib.itemPbURL or "" }
end
end
t_insert(self.itemSetOrderList, itemSet.id)
end
end
if not self.itemSetOrderList[1] then
self.activeItemSet = self:NewItemSet(1)
self.activeItemSet.useSecondWeaponSet = xml.attrib.useSecondWeaponSet == "true"
self.itemSetOrderList[1] = 1
end
self:SetActiveItemSet(tonumber(xml.attrib.activeItemSet) or 1)
self:ResetUndo()
end
function ItemsTabClass:Save(xml)
xml.attrib = {
activeItemSet = tostring(self.activeItemSetId),
useSecondWeaponSet = tostring(self.activeItemSet.useSecondWeaponSet),
}
for _, id in ipairs(self.itemOrderList) do
local item = self.items[id]
local child = {
elem = "Item",
attrib = {
id = tostring(id),
variant = item.variant and tostring(item.variant),
variantAlt = item.variantAlt and tostring(item.variantAlt),
variantAlt2 = item.variantAlt2 and tostring(item.variantAlt2),
variantAlt3 = item.variantAlt3 and tostring(item.variantAlt3),
variantAlt4 = item.variantAlt4 and tostring(item.variantAlt4),
variantAlt5 = item.variantAlt5 and tostring(item.variantAlt5)
}
}
item:BuildAndParseRaw()
t_insert(child, item.raw)
local id = #item.buffModLines + 1
for _, modLine in ipairs(item.enchantModLines) do
if modLine.range then
t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } })
end
id = id + 1
end
for _, modLine in ipairs(item.scourgeModLines) do
if modLine.range then
t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } })
end
id = id + 1
end
for _, modLine in ipairs(item.implicitModLines) do
if modLine.range then
t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } })
end
id = id + 1
end
for _, modLine in ipairs(item.explicitModLines) do
if modLine.range then
t_insert(child, { elem = "ModRange", attrib = { id = tostring(id), range = tostring(modLine.range) } })
end
id = id + 1
end
t_insert(xml, child)
end
for _, itemSetId in ipairs(self.itemSetOrderList) do
local itemSet = self.itemSets[itemSetId]
local child = { elem = "ItemSet", attrib = { id = tostring(itemSetId), title = itemSet.title, useSecondWeaponSet = tostring(itemSet.useSecondWeaponSet) } }
for slotName, slot in pairs(self.slots) do
if not slot.nodeId then
t_insert(child, { elem = "Slot", attrib = { name = slotName, itemId = tostring(itemSet[slotName].selItemId), itemPbURL = itemSet[slotName].pbURL or "", active = itemSet[slotName].active and "true" }})
else
if self.build.spec.allocNodes[slot.nodeId] then
t_insert(child, { elem = "SocketIdURL", attrib = { name = slotName, nodeId = tostring(slot.nodeId), itemPbURL = itemSet[slot.nodeId] and itemSet[slot.nodeId].pbURL or ""}})
end