forked from PathOfBuildingCommunity/PathOfBuilding
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild.lua
1361 lines (1292 loc) · 56.8 KB
/
Build.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: Build
-- Loads and manages the current build.
--
local pairs = pairs
local ipairs = ipairs
local t_insert = table.insert
local m_min = math.min
local m_max = math.max
local m_floor = math.floor
local m_abs = math.abs
local s_format = string.format
local normalBanditDropList = {
{ label = "Passive point", banditId = "None" },
{ label = "Oak (Life)", banditId = "Oak" },
{ label = "Kraityn (Resists)", banditId = "Kraityn" },
{ label = "Alira (Mana)", banditId = "Alira" },
}
local cruelBanditDropList = {
{ label = "Passive point", banditId = "None" },
{ label = "Oak (Endurance)", banditId = "Oak" },
{ label = "Kraityn (Frenzy)", banditId = "Kraityn" },
{ label = "Alira (Power)", banditId = "Alira" },
}
local mercilessBanditDropList = {
{ label = "Passive point", banditId = "None" },
{ label = "Oak (Phys Dmg)", banditId = "Oak" },
{ label = "Kraityn (Att. Speed)", banditId = "Kraityn" },
{ label = "Alira (Cast Speed)", banditId = "Alira" },
}
local fooBanditDropList = {
{ label = "2 Passive Points", banditId = "None" },
{ label = "Oak (Life Regen, Phys.Dmg. Reduction, Phys.Dmg)", banditId = "Oak" },
{ label = "Kraityn (Attack/Cast Speed, Attack Dodge, Move Speed)", banditId = "Kraityn" },
{ label = "Alira (Mana Regen, Crit Multiplier, Resists)", banditId = "Alira" },
}
local PantheonMajorGodDropList = {
{ label = "Nothing", id = "None" },
{ label = "Soul of the Brine King", id = "TheBrineKing" },
{ label = "Soul of Lunaris", id = "Lunaris" },
{ label = "Soul of Solaris", id = "Solaris" },
{ label = "Soul of Arakaali", id = "Arakaali" },
}
local PantheonMinorGodDropList = {
{ label = "Nothing", id = "None" },
{ label = "Soul of Gruthkul", id = "Gruthkul" },
{ label = "Soul of Yugul", id = "Yugul" },
{ label = "Soul of Abberath", id = "Abberath" },
{ label = "Soul of Tukohama", id = "Tukohama" },
{ label = "Soul of Garukhan", id = "Garukhan" },
{ label = "Soul of Ralakesh", id = "Ralakesh" },
{ label = "Soul of Ryslatha", id = "Ryslatha" },
{ label = "Soul of Shakari", id = "Shakari" },
}
local buildMode = new("ControlHost")
function buildMode:Init(dbFileName, buildName, buildXML, targetVersion)
self.dbFileName = dbFileName
self.buildName = buildName
if dbFileName then
self.dbFileSubPath = self.dbFileName:sub(#main.buildPath + 1, -#self.buildName - 5)
else
self.dbFileSubPath = main.modes.LIST.subPath or ""
end
if not buildName then
main:SetMode("LIST")
end
if not dbFileName and not targetVersion and not buildXML then
targetVersion = liveTargetVersion
--self.targetVersion = nil
--self:OpenTargetVersionPopup(true)
--return
end
self.abortSave = true
wipeTable(self.controls)
local miscTooltip = new("Tooltip")
-- Controls: top bar, left side
self.anchorTopBarLeft = new("Control", nil, 4, 4, 0, 20)
self.controls.back = new("ButtonControl", {"LEFT",self.anchorTopBarLeft,"RIGHT"}, 0, 0, 60, 20, "<< Back", function()
if self.unsaved then
self:OpenSavePopup("LIST")
else
self:CloseBuild()
end
end)
self.controls.buildName = new("Control", {"LEFT",self.controls.back,"RIGHT"}, 8, 0, 0, 20)
self.controls.buildName.width = function(control)
local limit = self.anchorTopBarRight:GetPos() - 98 - 40 - self.controls.back:GetSize() - self.controls.save:GetSize() - self.controls.saveAs:GetSize()
local bnw = DrawStringWidth(16, "VAR", self.buildName)
self.strWidth = m_min(bnw, limit)
self.strLimited = bnw > limit
return self.strWidth + 98
end
self.controls.buildName.Draw = function(control)
local x, y = control:GetPos()
local width, height = control:GetSize()
SetDrawColor(0.5, 0.5, 0.5)
DrawImage(nil, x + 91, y, self.strWidth + 6, 20)
SetDrawColor(0, 0, 0)
DrawImage(nil, x + 92, y + 1, self.strWidth + 4, 18)
SetDrawColor(1, 1, 1)
SetViewport(x, y + 2, self.strWidth + 94, 16)
DrawString(0, 0, "LEFT", 16, "VAR", "Current build: "..self.buildName)
SetViewport()
if control:IsMouseInBounds() then
SetDrawLayer(nil, 10)
miscTooltip:Clear()
if self.dbFileSubPath and self.dbFileSubPath ~= "" then
miscTooltip:AddLine(16, self.dbFileSubPath..self.buildName)
elseif self.strLimited then
miscTooltip:AddLine(16, self.buildName)
end
miscTooltip:Draw(x, y, width, height, main.viewPort)
SetDrawLayer(nil, 0)
end
end
self.controls.save = new("ButtonControl", {"LEFT",self.controls.buildName,"RIGHT"}, 8, 0, 50, 20, "Save", function()
self:SaveDBFile()
end)
self.controls.save.enabled = function()
return not self.dbFileName or self.unsaved
end
self.controls.saveAs = new("ButtonControl", {"LEFT",self.controls.save,"RIGHT"}, 8, 0, 70, 20, "Save As", function()
self:OpenSaveAsPopup()
end)
self.controls.saveAs.enabled = function()
return self.dbFileName
end
-- Controls: top bar, right side
self.anchorTopBarRight = new("Control", nil, function() return main.screenW / 2 + 6 end, 4, 0, 20)
self.controls.pointDisplay = new("Control", {"LEFT",self.anchorTopBarRight,"RIGHT"}, -12, 0, 0, 20)
self.controls.pointDisplay.x = function(control)
local width, height = control:GetSize()
if self.controls.saveAs:GetPos() + self.controls.saveAs:GetSize() < self.anchorTopBarRight:GetPos() - width - 16 then
return -12 - width
else
return 0
end
end
self.controls.pointDisplay.width = function(control)
local used, ascUsed = self.spec:CountAllocNodes()
local usedMax = 99 + (self.targetVersion == "2_6" and 21 or 22) + (self.calcsTab.mainOutput.ExtraPoints or 0)
local ascMax = 8
control.str = string.format("%s%3d / %3d %s%d / %d", used > usedMax and "^1" or "^7", used, usedMax, ascUsed > ascMax and "^1" or "^7", ascUsed, ascMax)
control.req = "Required level: "..m_max(1, (100 + used - usedMax))
return DrawStringWidth(16, "FIXED", control.str) + 8
end
self.controls.pointDisplay.Draw = function(control)
local x, y = control:GetPos()
local width, height = control:GetSize()
SetDrawColor(1, 1, 1)
DrawImage(nil, x, y, width, height)
SetDrawColor(0, 0, 0)
DrawImage(nil, x + 1, y + 1, width - 2, height - 2)
SetDrawColor(1, 1, 1)
DrawString(x + 4, y + 2, "LEFT", 16, "FIXED", control.str)
if control:IsMouseInBounds() then
SetDrawLayer(nil, 10)
miscTooltip:Clear()
miscTooltip:AddLine(16, control.req)
miscTooltip:Draw(x, y, width, height, main.viewPort)
SetDrawLayer(nil, 0)
end
end
self.controls.characterLevel = new("EditControl", {"LEFT",self.controls.pointDisplay,"RIGHT"}, 12, 0, 106, 20, "", "Level", "%D", 3, function(buf)
self.characterLevel = m_min(tonumber(buf) or 1, 100)
self.modFlag = true
self.buildFlag = true
end)
self.controls.characterLevel.tooltipFunc = function(tooltip)
if tooltip:CheckForUpdate(self.characterLevel) then
tooltip:AddLine(16, "Experience multiplier:")
local playerLevel = self.characterLevel
local safeZone = 3 + m_floor(playerLevel / 16)
for level, expLevel in ipairs(self.data.monsterExperienceLevelMap) do
local diff = m_abs(playerLevel - expLevel) - safeZone
local mult
if diff <= 0 then
mult = 1
else
mult = ((playerLevel + 5) / (playerLevel + 5 + diff ^ 2.5)) ^ 1.5
end
if playerLevel >= 95 then
mult = mult * (1 / (1 + 0.1 * (playerLevel - 94)))
end
if mult > 0.01 then
local line = level
if level >= 68 then
line = line .. string.format(" (Tier %d)", level - 67)
end
line = line .. string.format(": %.1f%%", mult * 100)
tooltip:AddLine(14, line)
end
end
end
end
self.controls.classDrop = new("DropDownControl", {"LEFT",self.controls.characterLevel,"RIGHT"}, 8, 0, 100, 20, nil, function(index, value)
if value.classId ~= self.spec.curClassId then
if self.spec:CountAllocNodes() == 0 or self.spec:IsClassConnected(value.classId) then
self.spec:SelectClass(value.classId)
self.spec:AddUndoState()
self.spec:SetWindowTitleWithBuildClass()
self.buildFlag = true
else
main:OpenConfirmPopup("Class Change", "Changing class to "..value.label.." will reset your passive tree.\nThis can be avoided by connecting one of the "..value.label.." starting nodes to your tree.", "Continue", function()
self.spec:SelectClass(value.classId)
self.spec:AddUndoState()
self.spec:SetWindowTitleWithBuildClass()
self.buildFlag = true
end)
end
end
end)
self.controls.ascendDrop = new("DropDownControl", {"LEFT",self.controls.classDrop,"RIGHT"}, 8, 0, 120, 20, nil, function(index, value)
self.spec:SelectAscendClass(value.ascendClassId)
self.spec:AddUndoState()
self.spec:SetWindowTitleWithBuildClass()
self.buildFlag = true
end)
-- List of display stats
-- This defines the stats in the side bar, and also which stats show in node/item comparisons
-- This may be user-customisable in the future
self.displayStats = {
{ stat = "ActiveMinionLimit", label = "Active Minion Limit", fmt = "d" },
{ stat = "AverageHit", label = "Average Hit", fmt = ".1f", compPercent = true },
{ stat = "AverageDamage", label = "Average Damage", fmt = ".1f", compPercent = true, flag = "attack" },
{ stat = "Speed", label = "Attack Rate", fmt = ".2f", compPercent = true, flag = "attack" },
{ stat = "Speed", label = "Cast Rate", fmt = ".2f", compPercent = true, flag = "spell" },
{ stat = "HitSpeed", label = "Hit Rate", fmt = ".2f", compPercent = true },
{ stat = "TrapThrowingTime", label = "Trap Throwing Time", fmt = ".2fs", compPercent = true, lowerIsBetter = true, },
{ stat = "TrapCooldown", label = "Trap Cooldown", fmt = ".2fs", lowerIsBetter = true },
{ stat = "MineLayingTime", label = targetVersion == "2_6" and "Mine Laying Time" or "Mine Throwing Time", fmt = ".2fs", compPercent = true, lowerIsBetter = true, },
{ stat = "TotemPlacementTime", label = "Totem Placement Time", fmt = ".2fs", compPercent = true, lowerIsBetter = true, },
{ stat = "PreEffectiveCritChance", label = "Crit Chance", fmt = ".2f%%" },
{ stat = "CritChance", label = "Effective Crit Chance", fmt = ".2f%%", condFunc = function(v,o) return v ~= o.PreEffectiveCritChance end },
{ stat = "CritMultiplier", label = "Crit Multiplier", fmt = "d%%", pc = true, condFunc = function(v,o) return (o.CritChance or 0) > 0 end },
{ stat = "HitChance", label = "Hit Chance", fmt = ".0f%%", flag = "attack" },
{ stat = "TotalDPS", label = "Total DPS", fmt = ".1f", compPercent = true, flag = "notAverage" },
{ stat = "TotalDot", label = "DoT DPS", fmt = ".1f", compPercent = true },
{ stat = "BleedDPS", label = "Bleed DPS", fmt = ".1f", compPercent = true },
{ stat = "BleedDamage", label = "Total Damage per Bleed", fmt = ".1f", compPercent = true, flag = "showAverage" },
{ stat = "WithBleedDPS", label = "Total DPS inc. Bleed", fmt = ".1f", compPercent = true, flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and (o.TotalDot or 0) == 0 and (o.PoisonDPS or 0) == 0 and (o.ImpaleDPS or 0) == 0 and (o.IgniteDPS or 0) == 0 end },
{ stat = "IgniteDPS", label = "Ignite DPS", fmt = ".1f", compPercent = true },
{ stat = "IgniteDamage", label = "Total Damage per Ignite", fmt = ".1f", compPercent = true, flag = "showAverage" },
{ stat = "WithIgniteDPS", label = "Total DPS inc. Ignite", fmt = ".1f", compPercent = true, flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and (o.TotalDot or 0) == 0 and (o.PoisonDPS or 0) == 0 and (o.ImpaleDPS or 0) == 0 and (o.BleedDPS or 0) == 0 end },
{ stat = "WithIgniteAverageDamage", label = "Average Dmg. inc. Ignite", fmt = ".1f", compPercent = true },
{ stat = "PoisonDPS", label = "Poison DPS", fmt = ".1f", compPercent = true },
{ stat = "PoisonDamage", label = "Total Damage per Poison", fmt = ".1f", compPercent = true },
{ stat = "WithPoisonDPS", label = "Total DPS inc. Poison", fmt = ".1f", compPercent = true, flag = "poison", flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and (o.TotalDot or 0) == 0 and (o.IgniteDPS or 0) == 0 and (o.ImpaleDPS or 0) == 0 and (o.BleedDPS or 0) == 0 end },
{ stat = "DecayDPS", label = "Decay DPS", fmt = ".1f", compPercent = true },
{ stat = "ImpaleDPS", label = "Impale Damage", fmt = ".1f", compPercent = true, flag = "impale", flag = "showAverage" },
{ stat = "WithImpaleDPS", label = "Damage inc. Impale", fmt = ".1f", compPercent = true, flag = "impale", flag = "showAverage", condFunc = function(v,o) return v ~= o.TotalDPS and (o.TotalDot or 0) == 0 and (o.IgniteDPS or 0) == 0 and (o.PoisonDPS or 0) == 0 and (o.BleedDPS or 0) == 0 end },
{ stat = "ImpaleDPS", label = "Impale DPS", fmt = ".1f", compPercent = true, flag = "impale", flag = "notAverage" },
{ stat = "WithImpaleDPS", label = "Total DPS inc. Impale", fmt = ".1f", compPercent = true, flag = "impale", flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and (o.TotalDot or 0) == 0 and (o.IgniteDPS or 0) == 0 and (o.PoisonDPS or 0) == 0 and (o.BleedDPS or 0) == 0 end },
{ stat = "CombinedDPS", label = "Combined DPS", fmt = ".1f", compPercent = true, flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and v ~= o.WithImpaleDPS and v ~= o.WithPoisonDPS and v ~= o.WithIgniteDPS and v ~= o.WithBleedDPS end },
{ stat = "CombinedAvg", label = "Combined Total Damage", fmt = ".1f", compPercent = true, flag = "showAverage", condFunc = function(v,o) return (v ~= o.AverageDamage and (o.TotalDot or 0) == 0) and (v ~= o.WithImpaleDPS or v ~= o.WithPoisonDPS or v ~= o.WithIgniteDPS or v ~= o.WithBleedDPS) end },
{ stat = "Cooldown", label = "Skill Cooldown", fmt = ".2fs", lowerIsBetter = true },
{ stat = "AreaOfEffectRadius", label = "AoE Radius", fmt = "d" },
{ stat = "ManaCost", label = "Mana Cost", fmt = "d", compPercent = true, lowerIsBetter = true, condFunc = function() return true end },
{ },
{ stat = "Str", label = "Strength", color = colorCodes.STRENGTH, fmt = "d" },
{ stat = "ReqStr", label = "Strength Required", color = colorCodes.STRENGTH, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Str end },
{ stat = "Dex", label = "Dexterity", color = colorCodes.DEXTERITY, fmt = "d" },
{ stat = "ReqDex", label = "Dexterity Required", color = colorCodes.DEXTERITY, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Dex end },
{ stat = "Int", label = "Intelligence", color = colorCodes.INTELLIGENCE, fmt = "d" },
{ stat = "ReqInt", label = "Intelligence Required", color = colorCodes.INTELLIGENCE, fmt = "d", lowerIsBetter = true, condFunc = function(v,o) return v > o.Int end },
{ },
{ stat = "Life", label = "Total Life", fmt = "d", compPercent = true },
{ stat = "Spec:LifeInc", label = "%Inc Life from Tree", fmt = "d%%", condFunc = function(v,o) return v > 0 and o.Life > 1 end },
{ stat = "LifeUnreserved", label = "Unreserved Life", fmt = "d", condFunc = function(v,o) return v < o.Life end, compPercent = true },
{ stat = "LifeUnreservedPercent", label = "Unreserved Life", fmt = "d%%", condFunc = function(v,o) return v < 100 end },
{ stat = "LifeRegen", label = "Life Regen", fmt = ".1f" },
{ stat = "LifeLeechGainRate", label = "Life Leech/On Hit Rate", fmt = ".1f", compPercent = true },
{ stat = "LifeLeechGainPerHit", label = "Life Leech/Gain per Hit", fmt = ".1f", compPercent = true },
{ },
{ stat = "Mana", label = "Total Mana", fmt = "d", compPercent = true },
{ stat = "Spec:ManaInc", label = "%Inc Mana from Tree", fmt = "d%%" },
{ stat = "ManaUnreserved", label = "Unreserved Mana", fmt = "d", condFunc = function(v,o) return v < o.Mana end, compPercent = true },
{ stat = "ManaUnreservedPercent", label = "Unreserved Mana", fmt = "d%%", condFunc = function(v,o) return v < 100 end },
{ stat = "ManaRegen", label = "Mana Regen", fmt = ".1f" },
{ stat = "ManaLeechGainRate", label = "Mana Leech/On Hit Rate", fmt = ".1f", compPercent = true },
{ stat = "ManaLeechGainPerHit", label = "Mana Leech/Gain per Hit", fmt = ".1f", compPercent = true },
{ },
{ stat = "TotalDegen", label = "Total Degen", fmt = ".1f", lowerIsBetter = true },
{ stat = "NetRegen", label = "Net Regen", fmt = "+.1f" },
{ stat = "NetLifeRegen", label = "Net Life Regen", fmt = "+.1f" },
{ stat = "NetManaRegen", label = "Net Mana Regen", fmt = "+.1f" },
{ },
{ stat = "EnergyShield", label = "Energy Shield", fmt = "d", compPercent = true },
{ stat = "Spec:EnergyShieldInc", label = "%Inc ES from Tree", fmt = "d%%" },
{ stat = "EnergyShieldRegen", label = "Energy Shield Regen", fmt = ".1f" },
{ stat = "EnergyShieldLeechGainRate", label = "ES Leech/On Hit Rate", fmt = ".1f", compPercent = true },
{ stat = "EnergyShieldLeechGainPerHit", label = "ES Leech/Gain per Hit", fmt = ".1f", compPercent = true },
{ stat = "Evasion", label = "Evasion rating", fmt = "d", compPercent = true },
{ stat = "Spec:EvasionInc", label = "%Inc Evasion from Tree", fmt = "d%%" },
{ stat = "MeleeEvadeChance", label = "Evade Chance", fmt = "d%%", condFunc = function(v,o) return v > 0 and o.MeleeEvadeChance == o.ProjectileEvadeChance end },
{ stat = "MeleeEvadeChance", label = "Melee Evade Chance", fmt = "d%%", condFunc = function(v,o) return v > 0 and o.MeleeEvadeChance ~= o.ProjectileEvadeChance end },
{ stat = "ProjectileEvadeChance", label = "Projectile Evade Chance", fmt = "d%%", condFunc = function(v,o) return v > 0 and o.MeleeEvadeChance ~= o.ProjectileEvadeChance end },
{ stat = "Armour", label = "Armour", fmt = "d", compPercent = true },
{ stat = "Spec:ArmourInc", label = "%Inc Armour from Tree", fmt = "d%%" },
{ stat = "PhysicalDamageReduction", label = "Phys. Damage Reduction", fmt = "d%%" },
{ stat = "EffectiveMovementSpeedMod", label = "Movement Speed Modifier", fmt = "+d%%", mod = true, condFunc = function() return true end },
{ stat = "BlockChance", label = "Block Chance", fmt = "d%%" },
{ stat = "SpellBlockChance", label = "Spell Block Chance", fmt = "d%%" },
{ stat = "AttackDodgeChance", label = "Attack Dodge Chance", fmt = "d%%" },
{ stat = "SpellDodgeChance", label = "Spell Dodge Chance", fmt = "d%%" },
{ },
{ stat = "FireResist", label = "Fire Resistance", fmt = "d%%", color = colorCodes.FIRE, condFunc = function() return true end, resistOverCapStat = "FireResistOverCap"},
{ stat = "ColdResist", label = "Cold Resistance", fmt = "d%%", color = colorCodes.COLD, condFunc = function() return true end, resistOverCapStat = "ColdResistOverCap" },
{ stat = "LightningResist", label = "Lightning Resistance", fmt = "d%%", color = colorCodes.LIGHTNING, condFunc = function() return true end, resistOverCapStat = "LightningResistOverCap" },
{ stat = "ChaosResist", label = "Chaos Resistance", fmt = "d%%", color = colorCodes.CHAOS, condFunc = function() return true end, resistOverCapStat = "ChaosResistOverCap" },
}
self.minionDisplayStats = {
{ stat = "AverageDamage", label = "Average Damage", fmt = ".1f", compPercent = true },
{ stat = "Speed", label = "Attack/Cast Rate", fmt = ".2f", compPercent = true },
{ stat = "HitSpeed", label = "Hit Rate", fmt = ".2f" },
{ stat = "TotalDPS", label = "Total DPS", fmt = ".1f", compPercent = true, flag = "notAverage" },
{ stat = "TotalDot", label = "DoT DPS", fmt = ".1f", compPercent = true },
{ stat = "BleedDPS", label = "Bleed DPS", fmt = ".1f", compPercent = true },
{ stat = "IgniteDPS", label = "Ignite DPS", fmt = ".1f", compPercent = true },
{ stat = "WithPoisonDPS", label = "DPS inc. Poison", fmt = ".1f", compPercent = true },
{ stat = "DecayDPS", label = "Decay DPS", fmt = ".1f", compPercent = true },
{ stat = "ImpaleDPS", label = "Impale DPS", fmt = ".1f", compPercent = true, flag = "impale" },
{ stat = "WithImpaleDPS", label = "Total DPS inc. Impale", fmt = ".1f", compPercent = true, flag = "impale" },
{ stat = "CombinedDPS", label = "Combined DPS", fmt = ".1f", compPercent = true, flag = "notAverage", condFunc = function(v,o) return v ~= o.TotalDPS and v ~= o.WithImpaleDPS and v ~= o.WithPoisonDPS and v ~= o.WithIgniteDPS end},
{ stat = "Cooldown", label = "Skill Cooldown", fmt = ".2fs", lowerIsBetter = true },
{ stat = "Life", label = "Total Life", fmt = ".1f", compPercent = true },
{ stat = "LifeRegen", label = "Life Regen", fmt = ".1f" },
{ stat = "LifeLeechGainRate", label = "Life Leech/On Hit Rate", fmt = ".1f", compPercent = true },
{ stat = "EnergyShield", label = "Energy Shield", fmt = "d", compPercent = true },
{ stat = "EnergyShieldRegen", label = "Energy Shield Regen", fmt = ".1f" },
{ stat = "EnergyShieldLeechGainRate", label = "ES Leech/On Hit Rate", fmt = ".1f", compPercent = true },
}
self.extraSaveStats = {
"PowerCharges",
"PowerChargesMax",
"FrenzyCharges",
"FrenzyChargesMax",
"EnduranceCharges",
"EnduranceChargesMax",
"ActiveTotemLimit",
"ActiveMinionLimit",
}
self.viewMode = "TREE"
self.targetVersion = defaultTargetVersion
self.characterLevel = 1
self.controls.characterLevel:SetText(tostring(self.characterLevel))
self.banditNormal = "None"
self.banditCruel = "None"
self.banditMerciless = "None"
self.pantheonMajorGod = "None"
self.pantheonMinorGod = "None"
self.spectreList = { }
-- Load build file
self.xmlSectionList = { }
if buildXML then
if self:LoadDB(buildXML, "Unnamed build") then
self:CloseBuild()
return
end
self.modFlag = true
else
if self:LoadDBFile() then
self:CloseBuild()
return
end
self.modFlag = false
end
if targetVersion then
self.targetVersion = targetVersion
end
self.targetVersionData = targetVersions[self.targetVersion]
if buildName == "~~temp~~" then
-- Remove temporary build file
os.remove(self.dbFileName)
self.buildName = "Unnamed build"
self.dbFileName = false
self.dbFileSubPath = nil
self.modFlag = true
end
-- Controls: Side bar
self.anchorSideBar = new("Control", nil, 4, 36, 0, 0)
self.controls.modeImport = new("ButtonControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 0, 134, 20, "Import/Export Build", function()
self.viewMode = "IMPORT"
end)
self.controls.modeImport.locked = function() return self.viewMode == "IMPORT" end
self.controls.modeNotes = new("ButtonControl", {"LEFT",self.controls.modeImport,"RIGHT"}, 4, 0, 58, 20, "Notes", function()
self.viewMode = "NOTES"
end)
self.controls.modeNotes.locked = function() return self.viewMode == "NOTES" end
self.controls.modeConfig = new("ButtonControl", {"TOPRIGHT",self.anchorSideBar,"TOPLEFT"}, 300, 0, 100, 20, "Configuration", function()
self.viewMode = "CONFIG"
end)
self.controls.modeConfig.locked = function() return self.viewMode == "CONFIG" end
self.controls.modeTree = new("ButtonControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 26, 72, 20, "Tree", function()
self.viewMode = "TREE"
end)
self.controls.modeTree.locked = function() return self.viewMode == "TREE" end
self.controls.modeSkills = new("ButtonControl", {"LEFT",self.controls.modeTree,"RIGHT"}, 4, 0, 72, 20, "Skills", function()
self.viewMode = "SKILLS"
end)
self.controls.modeSkills.locked = function() return self.viewMode == "SKILLS" end
self.controls.modeItems = new("ButtonControl", {"LEFT",self.controls.modeSkills,"RIGHT"}, 4, 0, 72, 20, "Items", function()
self.viewMode = "ITEMS"
end)
self.controls.modeItems.locked = function() return self.viewMode == "ITEMS" end
self.controls.modeCalcs = new("ButtonControl", {"LEFT",self.controls.modeItems,"RIGHT"}, 4, 0, 72, 20, "Calcs", function()
self.viewMode = "CALCS"
end)
self.controls.modeCalcs.locked = function() return self.viewMode == "CALCS" end
if self.targetVersion == "2_6" then
self.controls.banditNormal = new("DropDownControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 70, 100, 16, normalBanditDropList, function(index, value)
self.banditNormal = value.banditId
self.modFlag = true
self.buildFlag = true
end)
self.controls.banditNormalLabel = new("LabelControl", {"BOTTOMLEFT",self.controls.banditNormal,"TOPLEFT"}, 0, 0, 0, 14, "^7Normal Bandit:")
self.controls.banditCruel = new("DropDownControl", {"LEFT",self.controls.banditNormal,"RIGHT"}, 0, 0, 100, 16, mercilessBanditDropList, function(index, value)
self.banditCruel = value.banditId
self.modFlag = true
self.buildFlag = true
end)
self.controls.banditCruelLabel = new("LabelControl", {"BOTTOMLEFT",self.controls.banditCruel,"TOPLEFT"}, 0, 0, 0, 14, "^7Cruel Bandit:")
self.controls.banditMerciless = new("DropDownControl", {"LEFT",self.controls.banditCruel,"RIGHT"}, 0, 0, 100, 16, cruelBanditDropList, function(index, value)
self.banditMerciless = value.banditId
self.modFlag = true
self.buildFlag = true
end)
self.controls.banditMercilessLabel = new("LabelControl", {"BOTTOMLEFT",self.controls.banditMerciless,"TOPLEFT"}, 0, 0, 0, 14, "^7Merciless Bandit:")
else
self.controls.bandit = new("DropDownControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 70, 300, 16, fooBanditDropList, function(index, value)
self.bandit = value.banditId
self.modFlag = true
self.buildFlag = true
end)
self.controls.banditLabel = new("LabelControl", {"BOTTOMLEFT",self.controls.bandit,"TOPLEFT"}, 0, 0, 0, 14, "^7Bandit:")
-- The Pantheon
local function applyPantheonDescription(tooltip, mode, index, value)
tooltip:Clear()
if value.id == "None" then
return
end
local applyModes = { BODY = true, HOVER = true }
if applyModes[mode] then
local god = self.data.pantheons[value.id]
for _, soul in ipairs(god.souls) do
local name = soul.name
local lines = { }
for _, mod in ipairs(soul.mods) do
t_insert(lines, mod.line)
end
tooltip:AddLine(20, '^8'..name)
tooltip:AddLine(14, '^6'..table.concat(lines, '\n'))
tooltip:AddSeparator(10)
end
end
end
self.controls.pantheonMajorGod = new("DropDownControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 110, 300, 16, PantheonMajorGodDropList, function(index, value)
self.pantheonMajorGod = value.id
self.modFlag = true
self.buildFlag = true
end)
self.controls.pantheonMajorGod.tooltipFunc = applyPantheonDescription
self.controls.pantheonMinorGod = new("DropDownControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, 130, 300, 16, PantheonMinorGodDropList, function(index, value)
self.pantheonMinorGod = value.id
self.modFlag = true
self.buildFlag = true
end)
self.controls.pantheonMinorGod.tooltipFunc = applyPantheonDescription
self.controls.pantheonLabel = new("LabelControl", {"BOTTOMLEFT",self.controls.pantheonMajorGod,"TOPLEFT"}, 0, 0, 0, 14, "^7The Pantheon:")
end
local mainSkillPosY = (self.targetVersion == "2_6") and 95 or 155 -- The Pantheon's DropDown space
self.controls.mainSkillLabel = new("LabelControl", {"TOPLEFT",self.anchorSideBar,"TOPLEFT"}, 0, mainSkillPosY, 300, 16, "^7Main Skill:")
self.controls.mainSocketGroup = new("DropDownControl", {"TOPLEFT",self.controls.mainSkillLabel,"BOTTOMLEFT"}, 0, 2, 300, 16, nil, function(index, value)
self.mainSocketGroup = index
self.modFlag = true
self.buildFlag = true
end)
self.controls.mainSocketGroup.tooltipFunc = function(tooltip, mode, index, value)
local socketGroup = self.skillsTab.socketGroupList[index]
if socketGroup and tooltip:CheckForUpdate(socketGroup, self.outputRevision) then
self.skillsTab:AddSocketGroupTooltip(tooltip, socketGroup)
end
end
self.controls.mainSkill = new("DropDownControl", {"TOPLEFT",self.controls.mainSocketGroup,"BOTTOMLEFT"}, 0, 2, 300, 16, nil, function(index, value)
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
mainSocketGroup.mainActiveSkill = index
self.modFlag = true
self.buildFlag = true
end)
self.controls.mainSkillPart = new("DropDownControl", {"TOPLEFT",self.controls.mainSkill,"BOTTOMLEFT",true}, 0, 2, 200, 18, nil, function(index, value)
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
local srcInstance = mainSocketGroup.displaySkillList[mainSocketGroup.mainActiveSkill].activeEffect.srcInstance
srcInstance.skillPart = index
self.modFlag = true
self.buildFlag = true
end)
self.controls.mainSkillMineCountLabel = new("LabelControl", {"TOPLEFT",self.controls.mainSkillPart,"BOTTOMLEFT",true}, 0, 3, 0, 16, "^7Active Mines:") {
shown = function()
return self.controls.mainSkillMineCount:IsShown()
end,
}
self.controls.mainSkillMineCount = new("EditControl", {"LEFT",self.controls.mainSkillMineCountLabel,"RIGHT",true}, 2, 0, 60, 18, nil, nil, "%D", nil, function(buf)
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
local srcInstance = mainSocketGroup.displaySkillList[mainSocketGroup.mainActiveSkill].activeEffect.srcInstance
srcInstance.skillMineCount = tonumber(buf)
self.modFlag = true
self.buildFlag = true
end)
self.controls.mainSkillMinion = new("DropDownControl", {"TOPLEFT",self.controls.mainSkillMineCountLabel,"BOTTOMLEFT",true}, 0, 3, 178, 18, nil, function(index, value)
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
local srcInstance = mainSocketGroup.displaySkillList[mainSocketGroup.mainActiveSkill].activeEffect.srcInstance
if value.itemSetId then
srcInstance.skillMinionItemSet = value.itemSetId
else
srcInstance.skillMinion = value.minionId
end
self.modFlag = true
self.buildFlag = true
end)
function self.controls.mainSkillMinion.CanReceiveDrag(control, type, value)
if type == "Item" and control.list[control.selIndex] and control.list[control.selIndex].itemSetId then
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
local minionUses = mainSocketGroup.displaySkillList[mainSocketGroup.mainActiveSkill].activeEffect.grantedEffect.minionUses
return minionUses and minionUses[value:GetPrimarySlot()] -- O_O
end
end
function self.controls.mainSkillMinion.ReceiveDrag(control, type, value, source)
self.itemsTab:EquipItemInSet(value, control.list[control.selIndex].itemSetId)
end
function self.controls.mainSkillMinion.tooltipFunc(tooltip, mode, index, value)
tooltip:Clear()
if value.itemSetId then
self.itemsTab:AddItemSetTooltip(tooltip, self.itemsTab.itemSets[value.itemSetId])
tooltip:AddSeparator(14)
tooltip:AddLine(14, colorCodes.TIP.."Tip: You can drag items from the Items tab onto this dropdown to equip them onto the minion.")
end
end
self.controls.mainSkillMinionLibrary = new("ButtonControl", {"LEFT",self.controls.mainSkillMinion,"RIGHT"}, 2, 0, 120, 18, "Manage Spectres...", function()
self:OpenSpectreLibrary()
end)
self.controls.mainSkillMinionSkill = new("DropDownControl", {"TOPLEFT",self.controls.mainSkillMinion,"BOTTOMLEFT",true}, 0, 2, 200, 16, nil, function(index, value)
local mainSocketGroup = self.skillsTab.socketGroupList[self.mainSocketGroup]
local srcInstance = mainSocketGroup.displaySkillList[mainSocketGroup.mainActiveSkill].activeEffect.srcInstance
srcInstance.skillMinionSkill = index
self.modFlag = true
self.buildFlag = true
end)
self.controls.statBoxAnchor = new("Control", {"TOPLEFT",self.controls.mainSkillMinionSkill,"BOTTOMLEFT",true}, 0, 2, 0, 0)
self.controls.statBox = new("TextListControl", {"TOPLEFT",self.controls.statBoxAnchor,"BOTTOMLEFT"}, 0, 2, 300, 0, {{x=170,align="RIGHT_X"},{x=174,align="LEFT"}})
self.controls.statBox.height = function(control)
local x, y = control:GetPos()
return main.screenH - main.mainBarHeight - 4 - y
end
-- Initialise build components
self.data = data[self.targetVersion]
self.latestTree = main.tree[self.targetVersionData.latestTreeVersion]
self.importTab = new("ImportTab", self)
self.notesTab = new("NotesTab", self)
self.configTab = new("ConfigTab", self)
self.itemsTab = new("ItemsTab", self)
self.treeTab = new("TreeTab", self)
self.skillsTab = new("SkillsTab", self)
self.calcsTab = new("CalcsTab", self)
-- Load sections from the build file
self.savers = {
["Config"] = self.configTab,
["Notes"] = self.notesTab,
["Tree"] = self.treeTab,
["TreeView"] = self.treeTab.viewer,
["Items"] = self.itemsTab,
["Skills"] = self.skillsTab,
["Calcs"] = self.calcsTab,
["Import"] = self.importTab,
}
self.legacyLoaders = { -- Special loaders for legacy sections
["Spec"] = self.treeTab,
}
for _, node in ipairs(self.xmlSectionList) do
-- Check if there is a saver that can load this section
local saver = self.savers[node.elem] or self.legacyLoaders[node.elem]
if saver then
if saver:Load(node, self.dbFileName) then
self:CloseBuild()
return
end
end
end
for _, saver in pairs(self.savers) do
if saver.PostLoad then
saver:PostLoad()
end
end
if next(self.configTab.input) == nil then
-- Check for old calcs tab settings
self.configTab:ImportCalcSettings()
end
-- Initialise class dropdown
for classId, class in pairs(self.latestTree.classes) do
t_insert(self.controls.classDrop.list, {
label = class.name,
classId = classId,
})
end
table.sort(self.controls.classDrop.list, function(a, b) return a.label < b.label end)
-- Build calculation output tables
self.outputRevision = 1
self.calcsTab:BuildOutput()
self:RefreshStatList()
self.buildFlag = false
self.spec:SetWindowTitleWithBuildClass()
--[[
local testTooltip = new("Tooltip")
for _, item in pairs(main.uniqueDB.list) do
ConPrintf("%s", item.name)
self.itemsTab:AddItemTooltip(testTooltip, item)
testTooltip:Clear()
end
for _, item in pairs(main.rareDB.list) do
ConPrintf("%s", item.name)
self.itemsTab:AddItemTooltip(testTooltip, item)
testTooltip:Clear()
end
--]]
--[[
local start = GetTime()
SetProfiling(true)
for i = 1, 10 do
self.calcsTab:PowerBuilder()
end
SetProfiling(false)
ConPrintf("Power build time: %d ms", GetTime() - start)
--]]
self.abortSave = false
end
function buildMode:CanExit(mode)
if not self.targetVersion or not self.unsaved then
return true
end
self:OpenSavePopup(mode)
return false
end
function buildMode:Shutdown()
if launch.devMode and self.targetVersion and not self.abortSave then
if self.dbFileName then
self:SaveDBFile()
elseif self.unsaved then
self.dbFileName = main.buildPath.."~~temp~~.xml"
self.buildName = "~~temp~~"
self.dbFileSubPath = ""
self:SaveDBFile()
end
end
self.abortSave = nil
self.savers = nil
end
function buildMode:GetArgs()
return self.dbFileName, self.buildName
end
function buildMode:CloseBuild()
main:SetWindowTitleSubtext()
main:SetMode("LIST", self.dbFileName and self.buildName, self.dbFileSubPath)
end
function buildMode:Load(xml, fileName)
self.targetVersion = data[xml.attrib.targetVersion] and xml.attrib.targetVersion or defaultTargetVersion
if xml.attrib.viewMode then
self.viewMode = xml.attrib.viewMode
end
self.characterLevel = tonumber(xml.attrib.level) or 1
self.controls.characterLevel:SetText(tostring(self.characterLevel))
for _, diff in pairs({"bandit","banditNormal","banditCruel","banditMerciless","pantheonMajorGod","pantheonMinorGod"}) do
self[diff] = xml.attrib[diff] or "None"
end
self.mainSocketGroup = tonumber(xml.attrib.mainSkillIndex) or tonumber(xml.attrib.mainSocketGroup) or 1
wipeTable(self.spectreList)
for _, child in ipairs(xml) do
if child.elem == "Spectre" then
if child.attrib.id and data[self.targetVersion].minions[child.attrib.id] then
t_insert(self.spectreList, child.attrib.id)
end
end
end
end
function buildMode:Save(xml)
xml.attrib = {
targetVersion = self.targetVersion,
viewMode = self.viewMode,
level = tostring(self.characterLevel),
className = self.spec.curClassName,
ascendClassName = self.spec.curAscendClassName,
bandit = self.bandit,
banditNormal = self.banditNormal,
banditCruel = self.banditCruel,
banditMerciless = self.banditMerciless,
pantheonMajorGod = self.pantheonMajorGod,
pantheonMinorGod = self.pantheonMinorGod,
mainSocketGroup = tostring(self.mainSocketGroup),
}
for _, id in ipairs(self.spectreList) do
t_insert(xml, { elem = "Spectre", attrib = { id = id } })
end
for index, statData in ipairs(self.displayStats) do
if statData.stat then
local statVal = self.calcsTab.mainOutput[statData.stat]
if statVal then
t_insert(xml, { elem = "PlayerStat", attrib = { stat = statData.stat, value = tostring(statVal) } })
end
end
end
for index, stat in ipairs(self.extraSaveStats) do
local statVal = self.calcsTab.mainOutput[stat]
if statVal then
t_insert(xml, { elem = "PlayerStat", attrib = { stat = stat, value = tostring(statVal) } })
end
end
if self.calcsTab.mainEnv.minion then
for index, statData in ipairs(self.minionDisplayStats) do
if statData.stat then
local statVal = self.calcsTab.mainOutput.Minion[statData.stat]
if statVal then
t_insert(xml, { elem = "MinionStat", attrib = { stat = statData.stat, value = tostring(statVal) } })
end
end
end
end
self.modFlag = false
end
function buildMode:OnFrame(inputEvents)
if not self.targetVersion then
main:DrawBackground(main.viewPort)
return
end
if self.abortSave and not launch.devMode then
self:CloseBuild()
end
for id, event in ipairs(inputEvents) do
if event.type == "KeyDown" then
if event.key == "MOUSE4" then
if self.unsaved then
self:OpenSavePopup("LIST")
else
self:CloseBuild()
end
elseif IsKeyDown("CTRL") then
if event.key == "s" then
self:SaveDBFile()
inputEvents[id] = nil
elseif event.key == "w" then
if self.unsaved then
self:OpenSavePopup("LIST")
else
self:CloseBuild()
end
elseif event.key == "1" then
self.viewMode = "TREE"
elseif event.key == "2" then
self.viewMode = "SKILLS"
elseif event.key == "3" then
self.viewMode = "ITEMS"
elseif event.key == "4" then
self.viewMode = "CALCS"
elseif event.key == "5" then
self.viewMode = "CONFIG"
end
end
end
end
self:ProcessControlsInput(inputEvents, main.viewPort)
-- Update contents of ascendancy class dropdown
wipeTable(self.controls.ascendDrop.list)
for i = 0, #self.spec.curClass.classes do
local ascendClass = self.spec.curClass.classes[i]
t_insert(self.controls.ascendDrop.list, {
label = ascendClass.name,
ascendClassId = i,
})
end
self.controls.classDrop:SelByValue(self.spec.curClassId, "classId")
self.controls.ascendDrop:SelByValue(self.spec.curAscendClassId, "ascendClassId")
for _, diff in pairs({"bandit","banditNormal","banditCruel","banditMerciless"}) do
if self.controls[diff] then
self.controls[diff]:SelByValue(self[diff], "banditId")
end
end
for _, diff in pairs({"pantheonMajorGod","pantheonMinorGod"}) do
if self.controls[diff] then
self.controls[diff]:SelByValue(self[diff], "id")
end
end
if self.buildFlag then
-- Rebuild calculation output tables
self.outputRevision = self.outputRevision + 1
self.buildFlag = false
self.calcsTab:BuildOutput()
self:RefreshStatList()
end
if main.showThousandsSidebar ~= self.lastShowThousandsSidebar then
self:RefreshStatList()
end
if main.showTitlebarName ~= self.lastShowTitlebarName then
self.spec:SetWindowTitleWithBuildClass()
end
-- Update contents of main skill dropdowns
self:RefreshSkillSelectControls(self.controls, self.mainSocketGroup, "")
-- Draw contents of current tab
local sideBarWidth = 312
local tabViewPort = {
x = sideBarWidth,
y = 32,
width = main.screenW - sideBarWidth,
height = main.screenH - 32
}
if self.viewMode == "IMPORT" then
self.importTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "NOTES" then
self.notesTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "CONFIG" then
self.configTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "TREE" then
self.treeTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "SKILLS" then
self.skillsTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "ITEMS" then
self.itemsTab:Draw(tabViewPort, inputEvents)
elseif self.viewMode == "CALCS" then
self.calcsTab:Draw(tabViewPort, inputEvents)
end
self.unsaved = self.modFlag or self.notesTab.modFlag or self.configTab.modFlag or self.treeTab.modFlag or self.spec.modFlag or self.skillsTab.modFlag or self.itemsTab.modFlag or self.calcsTab.modFlag
SetDrawLayer(5)
-- Draw top bar background
SetDrawColor(0.2, 0.2, 0.2)
DrawImage(nil, 0, 0, main.screenW, 28)
SetDrawColor(0.85, 0.85, 0.85)
DrawImage(nil, 0, 28, main.screenW, 4)
DrawImage(nil, main.screenW/2 - 2, 0, 4, 28)
-- Draw side bar background
SetDrawColor(0.1, 0.1, 0.1)
DrawImage(nil, 0, 32, sideBarWidth - 4, main.screenH - 32)
SetDrawColor(0.85, 0.85, 0.85)
DrawImage(nil, sideBarWidth - 4, 32, 4, main.screenH - 32)
self:DrawControls(main.viewPort)
end
-- Opens the game version selection popup
function buildMode:OpenTargetVersionPopup(initial)
local controls = { }
local function setVersion(version)
if version == self.targetVersion then
main:ClosePopup()
return
end
if initial then
main:ClosePopup()
self:Shutdown()
self:Init(false, self.buildName, nil, version)
end
end
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Which game version will this build use?")
controls.version2_6 = new("ButtonControl", nil, -90, 50, 170, 20, "2.6 (Atlas of Worlds)", function()
setVersion("2_6")
end)
controls.version3_0 = new("ButtonControl", nil, 90, 50, 170, 20, "3.0 (Fall of Oriath)", function()
setVersion("3_0")
end)
controls.note = new("LabelControl", nil, 0, 80, 0, 14, "^7Tip: Existing builds can be converted between versions\nusing the 'Game Version' option in the Configuration tab.")
controls.cancel = new("ButtonControl", nil, 0, 120, 80, 20, "Cancel", function()
main:ClosePopup()
if initial then
self:CloseBuild()
end
end)
main:OpenPopup(370, 150, "Game Version", controls, nil, nil, "cancel")
end
function buildMode:OpenSavePopup(mode, newVersion)
local modeDesc = {
["LIST"] = "now?",
["EXIT"] = "before exiting?",
["UPDATE"] = "before updating?",
["VERSION"] = "before converting?",
}
local controls = { }
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7This build has unsaved changes.\nDo you want to save them "..modeDesc[mode])
controls.save = new("ButtonControl", nil, -90, 70, 80, 20, "Save", function()
main:ClosePopup()
self.actionOnSave = mode
self.versionOnSave = newVersion
self:SaveDBFile()
end)
controls.noSave = new("ButtonControl", nil, 0, 70, 80, 20, "Don't Save", function()
main:ClosePopup()
if mode == "LIST" then
self:CloseBuild()
elseif mode == "EXIT" then
Exit()
elseif mode == "UPDATE" then
launch:ApplyUpdate(launch.updateAvailable)
elseif mode == "VERSION" then
self:Shutdown()
self:Init(self.dbFileName, self.buildName, nil, newVersion)
end
end)
controls.close = new("ButtonControl", nil, 90, 70, 80, 20, "Cancel", function()
main:ClosePopup()
end)
main:OpenPopup(300, 100, "Save Changes", controls)
end
function buildMode:OpenSaveAsPopup()
local newFileName, newBuildName
local controls = { }
local function updateBuildName()
local buf = controls.edit.buf
newFileName = main.buildPath..controls.folder.subPath..buf..".xml"
newBuildName = buf
controls.save.enabled = false
if buf:match("%S") then
local out = io.open(newFileName, "r")
if out then
out:close()
else
controls.save.enabled = true
end
end
end
controls.label = new("LabelControl", nil, 0, 20, 0, 16, "^7Enter new build name:")
controls.edit = new("EditControl", nil, 0, 40, 450, 20, self.dbFileName and self.buildName, nil, "\\/:%*%?\"<>|%c", 100, function(buf)
updateBuildName()
end)
controls.folderLabel = new("LabelControl", {"TOPLEFT",nil,"TOPLEFT"}, 10, 70, 0, 16, "^7Folder:")
controls.newFolder = new("ButtonControl", {"TOPLEFT",nil,"TOPLEFT"}, 100, 67, 94, 20, "New Folder...", function()
main:OpenNewFolderPopup(main.buildPath..controls.folder.subPath, function(newFolderName)
if newFolderName then
controls.folder:OpenFolder(newFolderName)
end
end)
end)
controls.folder = new("FolderListControl", nil, 0, 115, 450, 100, self.dbFileSubPath, function(subPath)
updateBuildName()
end)
controls.save = new("ButtonControl", nil, -45, 225, 80, 20, "Save", function()
main:ClosePopup()
self.dbFileName = newFileName
self.buildName = newBuildName
self.dbFileSubPath = controls.folder.subPath
self:SaveDBFile()
end)
controls.save.enabled = false
controls.close = new("ButtonControl", nil, 45, 225, 80, 20, "Cancel", function()
main:ClosePopup()
self.actionOnSave = nil
self.versionOnSave = nil