Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIBestiaryFilteringOptionsGrid.cs
Go to the documentation of this file.
1using System;
8using Terraria.ID;
10using Terraria.UI;
11
13
15{
17
19
21
23
25
26 public event Action OnClickingOption;
27
42
43 private void BuildContainer()
44 {
47 {
50 HAlign = 1f,
51 VAlign = 0f,
52 Left = new StyleDimension(0f, 0f),
53 Top = new StyleDimension(0f, 0f)
54 };
55 uIPanel.BorderColor = new Color(89, 116, 213, 255) * 0.9f;
56 uIPanel.BackgroundColor = new Color(73, 94, 171) * 0.9f;
57 uIPanel.SetPadding(0f);
60 }
61
79
80 public void UpdateAvailability()
81 {
86 int num = -1;
87 int num2 = -1;
88 for (int i = 0; i < _filterer.AvailableFilters.Count; i++)
89 {
90 int num3 = i / perRow;
91 int num4 = i % perRow;
95 {
97 {
100 HAlign = 0f,
101 VAlign = 0f,
102 Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0f),
103 Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0f)
104 };
105 groupOptionButton.OnLeftClick += ClickOption;
106 groupOptionButton.SetSnapPoint("Filters", i);
107 groupOptionButton.ShowHighlightWhenSelected = false;
111 if (image != null)
112 {
113 image.Left = new StyleDimension(num, 0f);
114 image.Top = new StyleDimension(num2, 0f);
115 groupOptionButton.Append(image);
116 }
118 }
119 else
120 {
123 {
126 HAlign = 0f,
127 VAlign = 0f,
128 Top = new StyleDimension(offsetTop + (float)(num3 * heightWithSpacing), 0f),
129 Left = new StyleDimension(offsetLeft + (float)(num4 * widthWithSpacing), 0f),
130 FadeFromBlack = 0.5f
131 };
132 groupOptionButton2.ShowHighlightWhenSelected = false;
133 groupOptionButton2.SetPadding(0f);
134 groupOptionButton2.SetSnapPoint("Filters", i);
135 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode)1);
136 UIImageFramed uIImageFramed = new UIImageFramed(obj, obj.Frame(16, 5, 0, 4))
137 {
138 HAlign = 0.5f,
139 VAlign = 0.5f,
140 Color = Color.White * 0.2f
141 };
142 uIImageFramed.Left = new StyleDimension(num, 0f);
143 uIImageFramed.Top = new StyleDimension(num2, 0f);
147 }
148 }
150 }
151
159
161 {
162 widthPerButton = 32;
163 heightPerButton = 32;
164 int num = 2;
168 perRow = 12;
169 howManyRows = (int)Math.Ceiling((float)_filterer.AvailableFilters.Count / (float)perRow);
170 offsetLeft = (float)(perRow * widthWithSpacing - num) * 0.5f;
171 offsetTop = (float)(howManyRows * heightWithSpacing - num) * 0.5f;
172 offsetLeft = 6f;
173 offsetTop = 6f;
174 }
175
177 {
179 {
180 bool flag = _filterer.IsFilterActive(filterButton.OptionValue);
181 filterButton.SetCurrentOption(flag ? filterButton.OptionValue : (-1));
182 if (flag)
183 {
184 filterButton.SetColor(new Color(152, 175, 235), 1f);
185 }
186 else
187 {
189 }
190 }
191 }
192
194 {
195 bool? forcedDisplay = filter.ForcedDisplay;
196 if (forcedDisplay.HasValue)
197 {
198 return forcedDisplay.Value;
199 }
200 for (int i = 0; i < entries.Count; i++)
201 {
202 if (filter.FitsFilter(entries[i]) && entries[i].UIInfoProvider.GetEntryUICollectionInfo().UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0)
203 {
204 return true;
205 }
206 }
207 return false;
208 }
209
211 {
212 button.OnUpdate += delegate(UIElement element)
213 {
214 ShowButtonName(element, filter);
215 };
216 }
217
219 {
220 if (element.IsMouseHovering)
221 {
222 string textValue = Language.GetTextValue(number.GetDisplayNameKey());
223 Main.instance.MouseText(textValue, 0, 0);
224 }
225 }
226
228 {
232 if (this.OnClickingOption != null)
233 {
234 this.OnClickingOption();
235 }
236 }
237}
void Add(TKey key, TValue value)
static double Sqrt(double d)
static double Ceiling(double a)
void ShowButtonName(UIElement element, IBestiaryEntryFilter number)
bool GetIsFilterAvailableForEntries(IBestiaryEntryFilter filter, List< BestiaryEntry > entries)
void GetEntriesToShow(out int maxEntriesWidth, out int maxEntriesHeight, out int maxEntriesToHave)
UIBestiaryFilteringOptionsGrid(EntryFilterer< BestiaryEntry, IBestiaryEntryFilter > filterer)
EntryFilterer< BestiaryEntry, IBestiaryEntryFilter > _filterer
void GetDisplaySettings(out int widthPerButton, out int heightPerButton, out int widthWithSpacing, out int heightWithSpacing, out int perRow, out float offsetLeft, out float offsetTop, out int howManyRows)
static readonly Color InventoryDefaultColor
Definition Colors.cs:93
static string GetTextValue(string key)
Definition Language.cs:15
static Main instance
Definition Main.cs:283
static IAssetRepository Assets
Definition Main.cs:209
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