-
Notifications
You must be signed in to change notification settings - Fork 23
/
BossLogUI.cs
1409 lines (1284 loc) · 48.4 KB
/
BossLogUI.cs
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
using BossChecklist.UIElements;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
using Terraria.GameContent.UI.Elements;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using Terraria.ModLoader.Config;
using Terraria.ModLoader.UI;
using Terraria.UI;
using Terraria.UI.Chat;
using static BossChecklist.UIElements.BossLogUIElements;
namespace BossChecklist
{
class BossLogUI : UIState
{
public BossAssistButton bosslogbutton;
public BossLogPanel BookArea;
public BossLogPanel PageOne;
public BossLogPanel PageTwo;
public SubpageButton recordButton;
public SubpageButton spawnButton;
public SubpageButton lootButton;
//public SubpageButton collectButton;
public SubpageButton toolTipButton;
public UIImageButton NextPage;
public UIImageButton PrevPage;
public UIHoverImageButton toggleHidden;
public BookUI filterPanel;
private List<BookUI> filterCheck;
private List<BookUI> filterCheckMark;
private List<UIText> filterTypes;
public BookUI ToCTab;
public BookUI CreditsTab;
public BookUI BossTab;
public BookUI MiniBossTab;
public BookUI EventTab;
public UIList prehardmodeList;
public UIList hardmodeList;
public BossLogUIElements.FixedUIScrollbar scrollOne;
public BossLogUIElements.FixedUIScrollbar scrollTwo;
public UIList pageTwoItemList; // Item slot lists that include: Loot tables, spawn item, and collectibles
// Cropped Textures
public static Texture2D bookTexture;
public static Texture2D borderTexture;
public static Texture2D fadedTexture;
public static Texture2D colorTexture;
public static Texture2D prevTexture;
public static Texture2D nextTexture;
public static Texture2D tocTexture;
public static Texture2D credTexture;
public static Texture2D bossNavTexture;
public static Texture2D minibossNavTexture;
public static Texture2D eventNavTexture;
public static Texture2D filterTexture;
public static Texture2D checkMarkTexture;
public static Texture2D xTexture;
public static Texture2D circleTexture;
public static Texture2D checkboxTexture;
//public static Texture2D silverStarTexture; // unused
public static Texture2D chestTexture;
public static Texture2D starTexture;
public static Texture2D goldChestTexture;
public static int PageNum = -3; // Selected Boss Page (starts out with an invalid number for the initial check)
public static int SubPageNum = 0; // Selected Topic Tab (Records, Spawn Info, Loot/Collection)
public static int RecipePageNum = 0;
public static int RecipeShown = 0;
public static bool showHidden = false;
public static bool[] AltPage; // AltPage for Records is "Player Best/World Best(Server)"
private bool bossLogVisible;
public bool BossLogVisible {
get { return bossLogVisible; }
set {
if (value) {
Append(ToCTab);
Append(CreditsTab);
Append(filterPanel);
Append(BossTab);
Append(MiniBossTab);
Append(EventTab);
Append(PageOne);
Append(PageTwo);
Append(BookArea);
}
else {
RemoveChild(ToCTab);
RemoveChild(CreditsTab);
RemoveChild(filterPanel);
RemoveChild(BossTab);
RemoveChild(MiniBossTab);
RemoveChild(EventTab);
RemoveChild(PageOne);
RemoveChild(PageTwo);
RemoveChild(BookArea);
}
bossLogVisible = value;
}
}
public void ToggleBossLog(bool show = true, bool resetPage = false) {
if (PageNum == -3) {
resetPage = true;
}
if (resetPage) {
PageNum = -1;
SubPageNum = 0;
ToCTab.Left.Set(-416, 0.5f);
filterPanel.Left.Set(-416 + ToCTab.Width.Pixels, 0.5f);
foreach (UIText uitext in filterTypes) {
filterPanel.RemoveChild(uitext);
}
UpdateTableofContents();
}
else {
UpdateSubPage(SubPageNum);
}
BossLogVisible = show;
if (show) {
// TODO: Small fix to update hidden list on open
Main.playerInventory = false;
Main.LocalPlayer.GetModPlayer<PlayerAssist>().hasOpenedTheBossLog = true; // Removes rainbow glow
}
}
public override void OnInitialize() {
// Book Button
bookTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Button"), new Rectangle(0, 0, 34, 38));
borderTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Button"), new Rectangle(36, 0, 34, 38));
fadedTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Button"), new Rectangle(72, 0, 34, 38));
colorTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Button"), new Rectangle(108, 0, 34, 38));
// Nav
prevTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(0, 0, 22, 22));
nextTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(24, 0, 22, 22));
tocTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(48, 0, 22, 22));
credTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(72, 0, 22, 22));
bossNavTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(0, 24, 22, 22));
minibossNavTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(24, 24, 22, 22));
eventNavTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(48, 24, 22, 22));
filterTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Nav"), new Rectangle(72, 24, 22, 22));
// Checks
checkMarkTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(0, 0, 22, 20));
xTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(24, 0, 22, 20));
circleTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(48, 0, 22, 20));
checkboxTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(72, 0, 22, 20));
chestTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(24, 22, 22, 20));
starTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(48, 22, 22, 20));
goldChestTexture = CropTexture(BossChecklist.instance.GetTexture("Resources/LogUI_Checks"), new Rectangle(72, 22, 22, 20));
bosslogbutton = new BossAssistButton(bookTexture, "Mods.BossChecklist.BossLog.Terms.BossLog");
bosslogbutton.Id = "OpenUI";
bosslogbutton.Width.Set(34, 0f);
bosslogbutton.Height.Set(38, 0f);
bosslogbutton.Left.Set(Main.screenWidth - bosslogbutton.Width.Pixels - 190, 0f);
bosslogbutton.Top.Pixels = Main.screenHeight - bosslogbutton.Height.Pixels - 8;
bosslogbutton.OnClick += (a, b) => ToggleBossLog(true);
AltPage = new bool[]
{
false, false, false, false
};
ToCTab = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Tab"));
ToCTab.Height.Pixels = 76;
ToCTab.Width.Pixels = 32;
ToCTab.Left.Set(-416, 0.5f);
ToCTab.Top.Set(-250 + 20, 0.5f);
ToCTab.Id = "ToCFilter_Tab";
ToCTab.OnClick += new MouseEvent(OpenViaTab);
BossTab = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Tab"));
BossTab.Height.Pixels = 76;
BossTab.Width.Pixels = 32;
BossTab.Left.Set(-416, 0.5f);
BossTab.Top.Set(-250 + 30 + 76, 0.5f);
BossTab.Id = "Boss_Tab";
BossTab.OnClick += new MouseEvent(OpenViaTab);
MiniBossTab = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Tab"));
MiniBossTab.Height.Pixels = 76;
MiniBossTab.Width.Pixels = 32;
MiniBossTab.Left.Set(-416, 0.5f);
MiniBossTab.Top.Set(-250 + 40 + (76 * 2), 0.5f);
MiniBossTab.Id = "Miniboss_Tab";
MiniBossTab.OnClick += new MouseEvent(OpenViaTab);
EventTab = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Tab"));
EventTab.Height.Pixels = 76;
EventTab.Width.Pixels = 32;
EventTab.Left.Set(-416, 0.5f);
EventTab.Top.Set(-250 + 50 + (76 * 3), 0.5f);
EventTab.Id = "Event_Tab";
EventTab.OnClick += new MouseEvent(OpenViaTab);
CreditsTab = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Tab"));
CreditsTab.Height.Pixels = 76;
CreditsTab.Width.Pixels = 32;
CreditsTab.Left.Set(-416, 0.5f);
CreditsTab.Top.Set(-250 + 60 + (76 * 4), 0.5f);
CreditsTab.Id = "Credits_Tab";
CreditsTab.OnClick += new MouseEvent(OpenViaTab);
BookArea = new BossLogPanel();
BookArea.Width.Pixels = 800;
BookArea.Height.Pixels = 478;
BookArea.Left.Pixels = (Main.screenWidth / 2) - 400;
BookArea.Top.Pixels = (Main.screenHeight / 2) - (478 / 2) - 6;
PageOne = new BossLogPanel { Id = "PageOne" };
PageOne.Width.Pixels = 375;
PageOne.Height.Pixels = 480;
PageOne.Left.Pixels = (Main.screenWidth / 2) - 400 + 20;
PageOne.Top.Pixels = (Main.screenHeight / 2) - 250 + 12;
PrevPage = new BossAssistButton(prevTexture, "") { Id = "Previous" };
PrevPage.Width.Pixels = 14;
PrevPage.Height.Pixels = 20;
PrevPage.Left.Pixels = 8;
PrevPage.Top.Pixels = 416;
PrevPage.OnClick += new MouseEvent(PageChangerClicked);
prehardmodeList = new UIList();
prehardmodeList.Left.Pixels = 4;
prehardmodeList.Top.Pixels = 44;
prehardmodeList.Width.Pixels = PageOne.Width.Pixels - 60;
prehardmodeList.Height.Pixels = PageOne.Height.Pixels - 136;
prehardmodeList.PaddingTop = 5;
scrollOne = new BossLogUIElements.FixedUIScrollbar();
scrollOne.SetView(100f, 1000f);
scrollOne.Top.Pixels = 50f;
scrollOne.Left.Pixels = -18;
scrollOne.Height.Set(-24f, 0.75f);
scrollOne.HAlign = 1f;
scrollTwo = new BossLogUIElements.FixedUIScrollbar();
scrollTwo.SetView(100f, 1000f);
scrollTwo.Top.Pixels = 50f;
scrollTwo.Left.Pixels = -28;
scrollTwo.Height.Set(-24f, 0.75f);
scrollTwo.HAlign = 1f;
PageTwo = new BossLogPanel { Id = "PageTwo" };
PageTwo.Width.Pixels = 375;
PageTwo.Height.Pixels = 480;
PageTwo.Left.Pixels = (Main.screenWidth / 2) - 400 + 800 - PageTwo.Width.Pixels;
PageTwo.Top.Pixels = (Main.screenHeight / 2) - 250 + 12;
pageTwoItemList = new UIList();
filterPanel = new BookUI(BossChecklist.instance.GetTexture("Resources/LogUI_Filter"));
filterPanel.Id = "filterPanel";
filterPanel.Height.Pixels = 76;
filterPanel.Width.Pixels = 152;
filterPanel.Left.Set(-416, 0.5f);
filterPanel.Top.Set(-250 + 20, 0.5f);
filterCheckMark = new List<BookUI>();
filterCheck = new List<BookUI>();
filterTypes = new List<UIText>();
for (int i = 0; i < 3; i++) {
BookUI newCheck = new BookUI(checkMarkTexture);
newCheck.Id = "C_" + i;
filterCheckMark.Add(newCheck);
BookUI newCheckBox = new BookUI(checkboxTexture);
newCheckBox.Id = "F_" + i;
newCheckBox.Top.Pixels = (20 * i) + 5;
newCheckBox.Left.Pixels = 5;
newCheckBox.OnClick += new MouseEvent(ChangeFilter);
newCheckBox.Append(filterCheckMark[i]);
filterCheck.Add(newCheckBox);
string type = "Bosses";
if (i == 1) {
type = "Mini bosses";
}
if (i == 2) {
type = "Events";
}
UIText bosses = new UIText(type, 0.85f);
bosses.Top.Pixels = 10 + (20 * i);
bosses.Left.Pixels = 25;
filterTypes.Add(bosses);
}
NextPage = new BossAssistButton(nextTexture, "") { Id = "Next" };
NextPage.Width.Pixels = 14;
NextPage.Height.Pixels = 20;
NextPage.Left.Pixels = PageTwo.Width.Pixels - (int)(NextPage.Width.Pixels * 3);
NextPage.Top.Pixels = 416;
NextPage.OnClick += new MouseEvent(PageChangerClicked);
PageTwo.Append(NextPage);
hardmodeList = new UIList();
hardmodeList.Left.Pixels = 4;
hardmodeList.Top.Pixels = 44;
hardmodeList.Width.Pixels = PageOne.Width.Pixels - 60;
hardmodeList.Height.Pixels = PageOne.Height.Pixels - 136;
hardmodeList.PaddingTop = 5;
recordButton = new SubpageButton("Mods.BossChecklist.BossLog.DrawnText.Records");
recordButton.Width.Pixels = PageTwo.Width.Pixels / 2 - 24;
recordButton.Height.Pixels = 25;
recordButton.Left.Pixels = 0;
recordButton.Top.Pixels = 15;
recordButton.OnClick += (a, b) => UpdateSubPage(0);
recordButton.OnRightDoubleClick += (a, b) => ResetStats();
spawnButton = new SubpageButton("Mods.BossChecklist.BossLog.DrawnText.SpawnInfo");
spawnButton.Width.Pixels = PageTwo.Width.Pixels / 2 - 24;
spawnButton.Height.Pixels = 25;
spawnButton.Left.Pixels = PageTwo.Width.Pixels / 2 - 8;
spawnButton.Top.Pixels = 15;
spawnButton.OnClick += (a, b) => UpdateSubPage(1);
lootButton = new SubpageButton("Mods.BossChecklist.BossLog.DrawnText.LootCollect");
lootButton.Width.Pixels = PageTwo.Width.Pixels / 2 - 24;
lootButton.Height.Pixels = 25;
lootButton.Left.Pixels = PageTwo.Width.Pixels / 2 - lootButton.Width.Pixels / 2 - 16;
lootButton.Top.Pixels = 50;
lootButton.OnClick += (a, b) => UpdateSubPage(2);
lootButton.OnRightDoubleClick += new MouseEvent(RemoveItem);
toolTipButton = new SubpageButton("Disclaimer");
toolTipButton.Width.Pixels = 32;
toolTipButton.Height.Pixels = 32;
toolTipButton.Left.Pixels = PageTwo.Width.Pixels - toolTipButton.Width.Pixels - 30;
toolTipButton.Top.Pixels = 100;
toolTipButton.OnClick += (a, b) => SwapRecordPage();
toggleHidden = new UIHoverImageButton(Main.inventoryTickOffTexture, "Toggle hidden visibility");
toggleHidden.Left.Pixels = 112 - Main.inventoryTickOffTexture.Width;
toggleHidden.Top.Pixels = Main.inventoryTickOffTexture.Height * 2 / 3;
toggleHidden.OnClick += (a, b) => ToggleHidden();
filterPanel.Append(toggleHidden);
}
public override void Update(GameTime gameTime) {
this.AddOrRemoveChild(bosslogbutton, Main.playerInventory);
// We reset the position of the button to make sure it updates with the screen res
BookArea.Left.Pixels = (Main.screenWidth / 2) - 400;
BookArea.Top.Pixels = (Main.screenHeight / 2) - (478 / 2) - 6;
PageOne.Left.Pixels = (Main.screenWidth / 2) - 400 + 20;
PageOne.Top.Pixels = (Main.screenHeight / 2) - 250 + 12;
PageTwo.Left.Pixels = (Main.screenWidth / 2) - 400 + 800 - PageTwo.Width.Pixels;
PageTwo.Top.Pixels = (Main.screenHeight / 2) - 250 + 12;
// Updating tabs to proper positions
CreditsTab.Left.Pixels = -416 + (PageNum == -2 ? 0 : 800);
BossTab.Left.Pixels = -416 + (PageNum >= FindNext(EntryType.Boss) || PageNum == -2 ? 0 : 800);
MiniBossTab.Left.Pixels = -416 + (PageNum >= FindNext(EntryType.MiniBoss) || PageNum == -2 ? 0 : 800);
EventTab.Left.Pixels = -416 + (PageNum >= FindNext(EntryType.Event) || PageNum == -2 ? 0 : 800);
if (PageNum != -1) {
ToCTab.Left.Set(-416, 0.5f);
filterPanel.Left.Set(-416 + ToCTab.Width.Pixels, 0.5f);
foreach (UIText uitext in filterTypes) {
filterPanel.RemoveChild(uitext);
}
filterPanel.Width.Pixels = 32;
filterPanel.Top.Precent = 5f; // Throw it off screen.
}
else {
filterPanel.Top.Precent = 0.5f;
}
if (filterPanel.HasChild(filterCheck[0])) {
filterCheckMark[0].SetImage(BossChecklist.BossLogConfig.FilterBosses == "Show" ? checkMarkTexture : circleTexture);
if (BossChecklist.BossLogConfig.FilterMiniBosses == "Show") {
filterCheckMark[1].SetImage(checkMarkTexture);
}
else if (BossChecklist.BossLogConfig.FilterMiniBosses == "Hide") {
filterCheckMark[1].SetImage(xTexture);
}
else {
filterCheckMark[1].SetImage(circleTexture);
}
if (BossChecklist.BossLogConfig.FilterEvents == "Show") {
filterCheckMark[2].SetImage(checkMarkTexture);
}
else if (BossChecklist.BossLogConfig.FilterEvents == "Hide") {
filterCheckMark[2].SetImage(xTexture);
}
else {
filterCheckMark[2].SetImage(circleTexture);
}
}
base.Update(gameTime);
}
public TextSnippet hoveredTextSnippet;
public override void Draw(SpriteBatch spriteBatch) {
base.Draw(spriteBatch);
if (hoveredTextSnippet != null) {
hoveredTextSnippet.OnHover();
if (Main.mouseLeft && Main.mouseLeftRelease) {
hoveredTextSnippet.OnClick();
}
hoveredTextSnippet = null;
}
}
public void ToggleFilterPanel(UIMouseEvent evt, UIElement listeningElement) {
if (filterPanel.Left.Pixels != -416 - 120 + ToCTab.Width.Pixels) {
ToCTab.Left.Set(-416 - 120, 0.5f);
filterPanel.Left.Set(-416 - 120 + ToCTab.Width.Pixels, 0.5f);
filterPanel.Width.Pixels = 152;
foreach (BookUI uiimage in filterCheck) {
filterPanel.Append(uiimage);
}
foreach (UIText uitext in filterTypes) {
filterPanel.Append(uitext);
}
}
else {
ToCTab.Left.Set(-416, 0.5f);
filterPanel.Left.Set(-416 + ToCTab.Width.Pixels, 0.5f);
foreach (BookUI uiimage in filterCheck) {
filterPanel.RemoveChild(uiimage);
}
foreach (UIText uitext in filterTypes) {
filterPanel.RemoveChild(uitext);
}
filterPanel.Width.Pixels = 32;
}
}
private void ChangeFilter(UIMouseEvent evt, UIElement listeningElement) {
string rowID = listeningElement.Id.Substring(2, 1);
if (rowID == "0") {
if (BossChecklist.BossLogConfig.FilterBosses == "Show") {
BossChecklist.BossLogConfig.FilterBosses = "Hide when completed";
}
else {
BossChecklist.BossLogConfig.FilterBosses = "Show";
}
}
if (rowID == "1") {
if (BossChecklist.BossLogConfig.FilterMiniBosses == "Show") {
BossChecklist.BossLogConfig.FilterMiniBosses = "Hide when completed";
}
else if (BossChecklist.BossLogConfig.FilterMiniBosses == "Hide when completed") {
BossChecklist.BossLogConfig.FilterMiniBosses = "Hide";
}
else {
BossChecklist.BossLogConfig.FilterMiniBosses = "Show";
}
}
if (rowID == "2") {
if (BossChecklist.BossLogConfig.FilterEvents == "Show") {
BossChecklist.BossLogConfig.FilterEvents = "Hide when completed";
}
else if (BossChecklist.BossLogConfig.FilterEvents == "Hide when completed") {
BossChecklist.BossLogConfig.FilterEvents = "Hide";
}
else {
BossChecklist.BossLogConfig.FilterEvents = "Show";
}
}
BossChecklist.SaveConfig(BossChecklist.BossLogConfig);
UpdateTableofContents();
}
private void OpenViaTab(UIMouseEvent evt, UIElement listeningElement) {
if (!BookUI.DrawTab(listeningElement.Id)) {
return;
}
// Reset new record
PlayerAssist modPlayer = Main.LocalPlayer.GetModPlayer<PlayerAssist>();
if (PageNum >= 0 && modPlayer.hasNewRecord[PageNum]) {
modPlayer.hasNewRecord[PageNum] = false;
}
if (listeningElement.Id == "ToCFilter_Tab" && PageNum == -1) {
ToggleFilterPanel(evt, listeningElement);
return;
}
if (listeningElement.Id == "Boss_Tab") {
PageNum = FindNext(EntryType.Boss);
}
else if (listeningElement.Id == "Miniboss_Tab") {
PageNum = FindNext(EntryType.MiniBoss);
}
else if (listeningElement.Id == "Event_Tab") {
PageNum = FindNext(EntryType.Event);
}
else if (listeningElement.Id == "Credits_Tab") {
UpdateCredits();
}
else {
UpdateTableofContents();
}
if (PageNum >= 0) {
ResetBothPages();
UpdateSubPage(SubPageNum);
}
}
// TODO: Test both ResetStats and RemoveItem() in multiplayer
private void ResetStats() {
if (BossChecklist.DebugConfig.ResetRecordsBool && SubPageNum == 0) {
BossStats stats = Main.LocalPlayer.GetModPlayer<PlayerAssist>().AllBossRecords[PageNum].stat;
stats.kills = 0;
stats.deaths = 0;
stats.durationBest = -1;
stats.durationPrev = -1;
stats.hitsTakenBest = -1;
stats.hitsTakenPrev = -1;
stats.dodgeTimeBest = -1;
stats.healthLossBest = -1;
stats.healthLossPrev = -1;
stats.healthAtStart = -1;
stats.healthAtStartPrev = -1;
OpenRecord();
if (Main.netMode == NetmodeID.MultiplayerClient) {
RecordID specificRecord = RecordID.ResetAll;
ModPacket packet = BossChecklist.instance.GetPacket();
packet.Write((byte)PacketMessageType.RecordUpdate);
packet.Write((int)PageNum);
stats.NetSend(packet, specificRecord);
packet.Send(toClient: Main.LocalPlayer.whoAmI);
}
}
}
private void RemoveItem(UIMouseEvent evt, UIElement listeningElement) {
// Double right-click an item slot to remove that item from the selected boss page's loot/collection list
// Double right-click the "Loot / Collection" button to entirely clear the selected boss page's loot/collection list
// If holding Alt while right-clicking will do the above for ALL boss lists
Player player = Main.LocalPlayer;
PlayerAssist modPlayer = player.GetModPlayer<PlayerAssist>();
if (BossChecklist.DebugConfig.ResetLootItems && SubPageNum == 2) {
string ID = listeningElement.Id;
if (ID == "") {
if (Main.keyState.IsKeyDown(Keys.LeftAlt) || Main.keyState.IsKeyDown(Keys.RightAlt)) {
for (int i = 0; i < modPlayer.BossTrophies.Count; i++) {
if (AltPage[2]) {
modPlayer.BossTrophies[i].collectibles.Clear();
}
else {
modPlayer.BossTrophies[i].loot.Clear();
}
}
}
else {
if (AltPage[2]) {
modPlayer.BossTrophies[PageNum].collectibles.Clear();
}
else {
modPlayer.BossTrophies[PageNum].loot.Clear();
}
}
}
else if (ID.StartsWith("collect_")) {
int itemType = Convert.ToInt32(ID.Substring(8));
if (Main.keyState.IsKeyDown(Keys.LeftAlt) || Main.keyState.IsKeyDown(Keys.RightAlt)) {
for (int i = 0; i < modPlayer.BossTrophies.Count; i++) {
modPlayer.BossTrophies[i].collectibles.RemoveAll(x => x.Type == itemType);
}
}
else {
List<ItemDefinition> collection = modPlayer.BossTrophies[PageNum].collectibles;
collection.RemoveAll(x => x.Type == itemType);
}
}
else if (ID.StartsWith("loot_")) {
int itemType = Convert.ToInt32(ID.Substring(5));
if (Main.keyState.IsKeyDown(Keys.LeftAlt) || Main.keyState.IsKeyDown(Keys.RightAlt)) {
for (int i = 0; i < modPlayer.BossTrophies.Count; i++) {
modPlayer.BossTrophies[i].loot.RemoveAll(x => x.Type == itemType);
}
}
else {
List<ItemDefinition> loot = modPlayer.BossTrophies[PageNum].loot;
loot.RemoveAll(x => x.Type == itemType);
}
}
OpenLoot();
}
}
private void ChangeSpawnItem(UIMouseEvent evt, UIElement listeningElement) {
if (listeningElement.Id == "NextItem") {
RecipePageNum++;
RecipeShown = 0;
}
else if (listeningElement.Id == "PrevItem") {
RecipePageNum--;
RecipeShown = 0;
}
else if (listeningElement.Id.Contains("CycleItem")) {
int index = listeningElement.Id.IndexOf('_');
if (RecipeShown == Convert.ToInt32(listeningElement.Id.Substring(index + 1)) - 1) {
RecipeShown = 0;
}
else {
RecipeShown++;
}
}
OpenSpawn();
}
private void PageChangerClicked(UIMouseEvent evt, UIElement listeningElement) {
// Reset new record
PlayerAssist modPlayer = Main.LocalPlayer.GetModPlayer<PlayerAssist>();
if (PageNum >= 0 && modPlayer.hasNewRecord[PageNum]) {
modPlayer.hasNewRecord[PageNum] = false;
}
pageTwoItemList.Clear();
prehardmodeList.Clear();
hardmodeList.Clear();
PageOne.RemoveChild(scrollOne);
PageTwo.RemoveChild(scrollTwo);
RecipeShown = 0;
RecipePageNum = 0;
// Move to next/prev
List<BossInfo> BossList = BossChecklist.bossTracker.SortedBosses;
if (listeningElement.Id == "Next") {
if (PageNum < BossList.Count - 1) {
PageNum++;
}
else {
PageNum = -2;
}
}
else { // button is previous
if (PageNum >= 0) {
PageNum--;
}
else {
PageNum = BossList.Count - 1;
}
}
// If the page is hidden or unavailable, keep moving till its not or until page is at either end
if (PageNum >= 0 && (BossList[PageNum].hidden || !BossList[PageNum].available())) {
while (PageNum >= 0) {
BossInfo currentBoss = BossList[PageNum];
if (!currentBoss.hidden && currentBoss.available()) {
break;
}
if (listeningElement.Id == "Next") {
if (PageNum < BossList.Count - 1) {
PageNum++;
}
else {
PageNum = -2;
}
}
else { // button is previous
if (PageNum >= 0) {
PageNum--;
}
else {
PageNum = BossList.Count - 1;
}
}
}
}
ResetBothPages();
UpdateSubPage(SubPageNum);
}
private void ToggleHidden() {
showHidden = !showHidden;
toggleHidden.SetImage(showHidden ? Main.inventoryTickOnTexture : Main.inventoryTickOffTexture);
UpdateTableofContents();
}
private void OpenRecord() {
ResetBothPages();
if (PageNum < 0) {
return;
}
// Incase we want to put any UI stuff on these pages
}
private void OpenSpawn() {
ResetBothPages();
int TotalRecipes = 0;
if (PageNum < 0) {
return;
}
pageTwoItemList.Clear();
BossInfo boss = BossChecklist.bossTracker.SortedBosses[PageNum];
if (boss.modSource == "Unknown") {
return;
}
var message = new UIMessageBox(Language.GetTextValue(boss.info));
message.Width.Set(-34f, 1f);
message.Height.Set(-370f, 1f);
message.Top.Set(85f, 0f);
message.Left.Set(-10f, 0f);
//message.PaddingRight = 30;
PageTwo.Append(message);
scrollTwo = new BossLogUIElements.FixedUIScrollbar();
scrollTwo.SetView(100f, 1000f);
scrollTwo.Top.Set(91f, 0f);
scrollTwo.Height.Set(-382f, 1f);
scrollTwo.Left.Set(-20, 0f);
scrollTwo.HAlign = 1f;
PageTwo.Append(scrollTwo);
message.SetScrollbar(scrollTwo);
if (boss.spawnItem.Count == 0 || boss.spawnItem.All(x => x <= 0)) {
string type = "Boss";
if (boss.type == EntryType.MiniBoss) {
type = "MiniBoss";
}
else if (boss.type == EntryType.Event) {
type = "Event";
}
UIText info = new UIText(Language.GetTextValue($"Mods.BossChecklist.BossLog.DrawnText.NoSpawn{type}"));
info.Left.Pixels = (PageTwo.Width.Pixels / 2) - (Main.fontMouseText.MeasureString(info.Text).X / 2) - 20;
info.Top.Pixels = 300;
PageTwo.Append(info);
return;
}
List<Item> ingredients = new List<Item>();
List<int> requiredTiles = new List<int>();
string recipeMod = "Terraria";
//List<Recipe> recipes = Main.recipe.ToList();
Item spawn = new Item();
if (BossChecklist.bossTracker.SortedBosses[PageNum].spawnItem[RecipePageNum] != 0) {
RecipeFinder finder = new RecipeFinder();
finder.SetResult(boss.spawnItem[RecipePageNum]);
foreach (Recipe recipe in finder.SearchRecipes()) {
if (TotalRecipes == RecipeShown) {
foreach (Item item in recipe.requiredItem) {
Item clone = item.Clone();
OverrideForGroups(recipe, clone);
ingredients.Add(clone);
}
foreach (int tile in recipe.requiredTile) {
if (tile != -1) {
requiredTiles.Add(tile);
}
}
if (recipe is ModRecipe modRecipe) {
recipeMod = modRecipe.mod.DisplayName;
}
}
TotalRecipes++;
}
spawn.SetDefaults(boss.spawnItem[RecipePageNum]);
LogItemSlot spawnItemSlot = new LogItemSlot(spawn, false, spawn.HoverName, ItemSlot.Context.EquipDye);
spawnItemSlot.Height.Pixels = 50;
spawnItemSlot.Width.Pixels = 50;
spawnItemSlot.Top.Pixels = 230;
spawnItemSlot.Left.Pixels = 33 + (56 * 2);
PageTwo.Append(spawnItemSlot);
int row = 0;
int col = 0;
for (int k = 0; k < ingredients.Count; k++) {
LogItemSlot ingList = new LogItemSlot(ingredients[k], false, ingredients[k].HoverName, ItemSlot.Context.GuideItem, 0.85f);
ingList.Id = "ingredient_" + k;
ingList.Height.Pixels = 50;
ingList.Width.Pixels = 50;
ingList.Top.Pixels = 240 + (48 * (row + 1));
ingList.Left.Pixels = 5 + (48 * col);
PageTwo.Append(ingList);
col++;
if (k == 6) {
// Fills in rows with empty slots. New rows start after 7 items
if (ingList.item.type == 0) {
break;
}
col = 0;
row++;
}
else if (k == 13) {
// Hopefully no mod uses more than 14 items to craft this spawn item
// If so, cut off the remaining row to prevent the itemslots from overflowing below the page. TODO? change this?
break;
}
}
Item craft = new Item();
if (ingredients.Count > 0 && requiredTiles.Count == 0) {
craft.SetDefaults(ItemID.PowerGlove);
LogItemSlot craftItem = new LogItemSlot(craft, false, Language.GetTextValue("Mods.BossChecklist.BossLog.Terms.ByHand"), ItemSlot.Context.EquipArmorVanity, 0.85f);
craftItem.Height.Pixels = 50;
craftItem.Width.Pixels = 50;
craftItem.Top.Pixels = 240 + (48 * (row + 2));
craftItem.Left.Pixels = 5;
PageTwo.Append(craftItem);
}
else if (requiredTiles.Count > 0) {
for (int l = 0; l < requiredTiles.Count; l++) {
if (requiredTiles[l] == -1) {
break; // Prevents extra empty slots from being created
}
LogItemSlot tileList;
if (requiredTiles[l] == 26) {
craft.SetDefaults(0);
string demonAltar = Language.GetTextValue("MapObject.DemonAltar");
string crimsonAltar = Language.GetTextValue("MapObject.CrimsonAltar");
string altarType = WorldGen.crimson ? crimsonAltar : demonAltar;
tileList = new LogItemSlot(craft, false, altarType, ItemSlot.Context.EquipArmorVanity, 0.85f);
}
else {
for (int m = 0; m < ItemLoader.ItemCount; m++) {
craft.SetDefaults(m);
if (craft.createTile == requiredTiles[l]) {
break;
}
}
tileList = new LogItemSlot(craft, false, craft.HoverName, ItemSlot.Context.EquipArmorVanity, 0.85f);
}
tileList.Height.Pixels = 50;
tileList.Width.Pixels = 50;
tileList.Top.Pixels = 240 + (48 * (row + 2));
tileList.Left.Pixels = 5 + (48 * l);
PageTwo.Append(tileList);
}
}
if (RecipePageNum > 0) {
BossAssistButton PrevItem = new BossAssistButton(prevTexture, "");
PrevItem.Id = "PrevItem";
PrevItem.Top.Pixels = 245;
PrevItem.Left.Pixels = 125;
PrevItem.Width.Pixels = 14;
PrevItem.Height.Pixels = 20;
PrevItem.OnClick += new MouseEvent(ChangeSpawnItem);
PageTwo.Append(PrevItem);
}
if (RecipePageNum < BossChecklist.bossTracker.SortedBosses[PageNum].spawnItem.Count - 1) {
BossAssistButton NextItem = new BossAssistButton(nextTexture, "");
NextItem.Id = "NextItem";
NextItem.Top.Pixels = 245;
NextItem.Left.Pixels = 203;
NextItem.Width.Pixels = 14;
NextItem.Height.Pixels = 20;
NextItem.OnClick += new MouseEvent(ChangeSpawnItem);
PageTwo.Append(NextItem);
}
if (TotalRecipes > 1) {
BossAssistButton CycleItem = new BossAssistButton(tocTexture, Language.GetTextValue("Mods.BossChecklist.BossLog.DrawnText.CycleRecipe"));
CycleItem.Id = "CycleItem_" + TotalRecipes;
CycleItem.Top.Pixels = 245;
CycleItem.Left.Pixels = 40;
CycleItem.Width.Pixels = 22;
CycleItem.Height.Pixels = 22;
CycleItem.OnClick += new MouseEvent(ChangeSpawnItem);
PageTwo.Append(CycleItem);
}
string recipeMessage = Language.GetTextValue("Mods.BossChecklist.BossLog.DrawnText.Noncraftable");
if (TotalRecipes > 0) {
recipeMessage = Language.GetTextValue("Mods.BossChecklist.BossLog.DrawnText.RecipeFrom", recipeMod);
}
UIText ModdedRecipe = new UIText(recipeMessage, 0.8f);
ModdedRecipe.Left.Pixels = -5;
ModdedRecipe.Top.Pixels = 205;
PageTwo.Append(ModdedRecipe);
}
}
private void OpenLoot() {
ResetBothPages();
BossLogPanel.shownAltPage = false;
if (AltPage[SubPageNum]) {
OpenCollect();
return;
}
if (PageNum < 0) {
return;
}
int row = 0;
int col = 0;
pageTwoItemList.Left.Pixels = 0;
pageTwoItemList.Top.Pixels = 125;
pageTwoItemList.Width.Pixels = PageTwo.Width.Pixels - 25;
pageTwoItemList.Height.Pixels = PageTwo.Height.Pixels - 125 - 80;
scrollTwo.SetView(10f, 1000f);
scrollTwo.Top.Pixels = 125;
scrollTwo.Left.Pixels = -18;
scrollTwo.Height.Set(-88f, 0.75f);
scrollTwo.HAlign = 1f;
pageTwoItemList.Clear();
BossInfo shortcut = BossChecklist.bossTracker.SortedBosses[PageNum];
LootRow newRow = new LootRow(0) { Id = "Loot0" };
for (int i = 0; i < shortcut.loot.Count; i++) {
if (BossChecklist.registeredBossBagTypes.Contains(shortcut.loot[i])) {
continue;
}
Item expertItem = new Item();
expertItem.SetDefaults(shortcut.loot[i]);
if (expertItem.expert) {
BossCollection Collection = Main.LocalPlayer.GetModPlayer<PlayerAssist>().BossTrophies[PageNum];
LogItemSlot lootTable = new LogItemSlot(expertItem, Collection.loot.Any(x => x.Type == expertItem.type), expertItem.Name, ItemSlot.Context.ShopItem);
lootTable.Height.Pixels = 50;
lootTable.Width.Pixels = 50;
lootTable.Id = "loot_" + expertItem.type;
lootTable.Left.Pixels = (col * 56);
lootTable.OnRightDoubleClick += new MouseEvent(RemoveItem);
newRow.Append(lootTable);
col++;
if (col == 6) {
col = 0;
row++;
pageTwoItemList.Add(newRow);
newRow = new LootRow(row) { Id = "Loot" + row };
}
}
}
for (int i = 0; i < shortcut.loot.Count; i++) {
if (BossChecklist.registeredBossBagTypes.Contains(shortcut.loot[i])) {
continue;
}
Item loot = new Item();
loot.SetDefaults(shortcut.loot[i]);
if (shortcut.npcIDs[0] < NPCID.Count) {
if (WorldGen.crimson) {
if (loot.type == ItemID.DemoniteOre || loot.type == ItemID.CorruptSeeds || loot.type == ItemID.UnholyArrow) {
continue;
}
}
else { // Corruption
if (loot.type == ItemID.CrimtaneOre || loot.type == ItemID.CrimsonSeeds) {
continue;
}
}
}
if (!loot.expert) {
BossCollection Collection = Main.LocalPlayer.GetModPlayer<PlayerAssist>().BossTrophies[PageNum];
LogItemSlot lootTable = new LogItemSlot(loot, Collection.loot.Any(x => x.Type == loot.type), loot.Name, ItemSlot.Context.TrashItem);
lootTable.Height.Pixels = 50;
lootTable.Width.Pixels = 50;
lootTable.Id = "loot_" + loot.type;
lootTable.Left.Pixels = (col * 56);
lootTable.OnRightDoubleClick += new MouseEvent(RemoveItem);
newRow.Append(lootTable);
col++;
if (col == 6) {
col = 0;
row++;
pageTwoItemList.Add(newRow);
newRow = new LootRow(row) { Id = "Loot" + row };
}
}
}
if (col != 0) {
col = 0;
row++;
pageTwoItemList.Add(newRow);
newRow = new LootRow(row) { Id = "Loot" + row };
}
if (row > 5) {
PageTwo.Append(scrollTwo);
}
PageTwo.Append(pageTwoItemList);
pageTwoItemList.SetScrollbar(scrollTwo);
}
private void OpenCollect() {
ResetBothPages();
if (PageNum < 0) {
return;