Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIBestiarySortingOptionsGrid.cs
Go to the documentation of this file.
1using System;
6using Terraria.ID;
8using Terraria.UI;
9
11
13{
15
17
18 private int _currentSelected = -1;
19
20 private int _defaultStepIndex;
21
22 public event Action OnClickingOption;
23
25 {
28 Width = new StyleDimension(0f, 1f);
29 Height = new StyleDimension(0f, 1f);
30 BackgroundColor = new Color(35, 40, 83) * 0.5f;
31 BorderColor = new Color(35, 40, 83) * 0.5f;
33 SetPadding(0f);
34 BuildGrid();
35 }
36
37 private void BuildGrid()
38 {
39 int num = 2;
40 int num2 = 26 + num;
41 int num3 = 0;
42 for (int i = 0; i < _sorter.Steps.Count; i++)
43 {
44 if (!_sorter.Steps[i].HiddenFromSortOptions)
45 {
46 num3++;
47 }
48 }
50 {
51 Width = new StyleDimension(126f, 0f),
52 Height = new StyleDimension(num3 * num2 + 5 + 3, 0f),
53 HAlign = 1f,
54 VAlign = 0f,
55 Left = new StyleDimension(-118f, 0f),
56 Top = new StyleDimension(0f, 0f)
57 };
58 uIPanel.BorderColor = new Color(89, 116, 213, 255) * 0.9f;
59 uIPanel.BackgroundColor = new Color(73, 94, 171) * 0.9f;
60 uIPanel.SetPadding(0f);
62 int num4 = 0;
63 for (int j = 0; j < _sorter.Steps.Count; j++)
64 {
66 if (!bestiarySortStep.HiddenFromSortOptions)
67 {
69 {
70 Width = new StyleDimension(114f, 0f),
71 Height = new StyleDimension(num2 - num, 0f),
72 HAlign = 0.5f,
73 Top = new StyleDimension(5 + num2 * num4, 0f)
74 };
75 groupOptionButton.ShowHighlightWhenSelected = false;
76 groupOptionButton.OnLeftClick += ClickOption;
77 groupOptionButton.SetSnapPoint("SortSteps", num4);
80 num4++;
81 }
82 }
84 {
85 item.SetCurrentOption(-1);
86 }
87 }
88
90 {
91 int num = ((GroupOptionButton<int>)listeningElement).OptionValue;
92 if (num == _currentSelected)
93 {
95 }
97 {
98 bool flag = num == item.OptionValue;
99 item.SetCurrentOption(flag ? num : (-1));
100 if (flag)
101 {
102 item.SetColor(new Color(152, 175, 235), 1f);
103 }
104 else
105 {
106 item.SetColor(Colors.InventoryDefaultColor, 0.7f);
107 }
108 }
109 _currentSelected = num;
111 if (this.OnClickingOption != null)
112 {
113 this.OnClickingOption();
114 }
115 }
116
123}
void Add(TKey key, TValue value)
void GetEntriesToShow(out int maxEntriesWidth, out int maxEntriesHeight, out int maxEntriesToHave)
UIBestiarySortingOptionsGrid(EntrySorter< BestiaryEntry, IBestiarySortStep > sorter)
void ClickOption(UIMouseEvent evt, UIElement listeningElement)
static readonly Color InventoryDefaultColor
Definition Colors.cs:93
static LocalizedText GetText(string key)
Definition Language.cs:10
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
StyleDimension Left
Definition UIElement.cs:25
StyleDimension Width
Definition UIElement.cs:27
void SetPadding(float pixels)
Definition UIElement.cs:361
StyleDimension Top
Definition UIElement.cs:23