Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ItemFilters.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8using Terraria.UI;
9
11
12public static class ItemFilters
13{
15 {
16 private const int _tooltipMaxLines = 30;
17
18 private string[] _toolTipLines = new string[30];
19
20 private bool[] _unusedPrefixLine = new bool[30];
21
22 private bool[] _unusedBadPrefixLines = new bool[30];
23
24 private int _unusedYoyoLogo;
25
27
28 private string _search;
29
30 public bool FitsFilter(Item entry)
31 {
32 if (_search == null)
33 {
34 return true;
35 }
36 int numLines = 1;
37 float knockBack = entry.knockBack;
39 for (int i = 0; i < numLines; i++)
40 {
41 if (_toolTipLines[i].ToLower().IndexOf(_search, StringComparison.OrdinalIgnoreCase) != -1)
42 {
43 return true;
44 }
45 }
46 return false;
47 }
48
49 public string GetDisplayNameKey()
50 {
51 return "CreativePowers.TabSearch";
52 }
53
55 {
56 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Rank_Light", (AssetRequestMode)1);
57 return new UIImageFramed(obj, obj.Frame())
58 {
59 HAlign = 0.5f,
60 VAlign = 0.5f
61 };
62 }
63
64 public void SetSearch(string searchText)
65 {
67 }
68 }
69
71 {
72 public bool FitsFilter(Item entry)
73 {
74 if (entry.createWall != -1)
75 {
76 return true;
77 }
78 if (entry.tileWand != -1)
79 {
80 return true;
81 }
82 if (entry.createTile == -1)
83 {
84 return false;
85 }
86 return !Main.tileFrameImportant[entry.createTile];
87 }
88
89 public string GetDisplayNameKey()
90 {
91 return "CreativePowers.TabBlocks";
92 }
93
95 {
96 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
97 return new UIImageFramed(obj, obj.Frame(11, 1, 4).OffsetSize(-2, 0))
98 {
99 HAlign = 0.5f,
100 VAlign = 0.5f
101 };
102 }
103 }
104
106 {
107 public bool FitsFilter(Item entry)
108 {
109 int createTile = entry.createTile;
110 if (createTile == -1)
111 {
112 return false;
113 }
114 return Main.tileFrameImportant[createTile];
115 }
116
117 public string GetDisplayNameKey()
118 {
119 return "CreativePowers.TabFurniture";
120 }
121
123 {
124 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
125 return new UIImageFramed(obj, obj.Frame(11, 1, 7).OffsetSize(-2, 0))
126 {
127 HAlign = 0.5f,
128 VAlign = 0.5f
129 };
130 }
131 }
132
133 public class Tools : IItemEntryFilter, IEntryFilter<Item>
134 {
136 {
137 509, 850, 851, 3612, 3625, 3611, 510, 849, 3620, 1071,
138 1543, 1072, 1544, 1100, 1545, 50, 3199, 3124, 5358, 5359,
139 5360, 5361, 5437, 1326, 5335, 3384, 4263, 4819, 4262, 946,
140 4707, 205, 206, 207, 1128, 3031, 4820, 5302, 5364, 4460,
141 4608, 4872, 3032, 5303, 5304, 1991, 4821, 3183, 779, 5134,
142 1299, 4711, 4049, 114
143 };
144
145 public bool FitsFilter(Item entry)
146 {
147 if (entry.pick > 0)
148 {
149 return true;
150 }
151 if (entry.axe > 0)
152 {
153 return true;
154 }
155 if (entry.hammer > 0)
156 {
157 return true;
158 }
159 if (entry.fishingPole > 0)
160 {
161 return true;
162 }
163 if (entry.tileWand != -1)
164 {
165 return true;
166 }
168 {
169 return true;
170 }
171 return false;
172 }
173
174 public string GetDisplayNameKey()
175 {
176 return "CreativePowers.TabTools";
177 }
178
180 {
181 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
182 return new UIImageFramed(obj, obj.Frame(11, 1, 6).OffsetSize(-2, 0))
183 {
184 HAlign = 0.5f,
185 VAlign = 0.5f
186 };
187 }
188 }
189
191 {
192 public bool FitsFilter(Item entry)
193 {
194 return entry.damage > 0;
195 }
196
197 public string GetDisplayNameKey()
198 {
199 return "CreativePowers.TabWeapons";
200 }
201
203 {
204 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
205 return new UIImageFramed(obj, obj.Frame(11).OffsetSize(-2, 0))
206 {
207 HAlign = 0.5f,
208 VAlign = 0.5f
209 };
210 }
211 }
212
213 public abstract class AArmor
214 {
216 {
217 if (entry.bodySlot != -1 || entry.headSlot != -1 || entry.legSlot != -1)
218 {
219 return entry.vanity == shouldBeSocial;
220 }
221 return false;
222 }
223 }
224
226 {
227 public bool FitsFilter(Item entry)
228 {
230 }
231
232 public string GetDisplayNameKey()
233 {
234 return "CreativePowers.TabArmor";
235 }
236
238 {
239 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
240 return new UIImageFramed(obj, obj.Frame(11, 1, 2).OffsetSize(-2, 0))
241 {
242 HAlign = 0.5f,
243 VAlign = 0.5f
244 };
245 }
246 }
247
249 {
250 public bool FitsFilter(Item entry)
251 {
253 }
254
255 public string GetDisplayNameKey()
256 {
257 return "CreativePowers.TabVanity";
258 }
259
261 {
262 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
263 return new UIImageFramed(obj, obj.Frame(11, 1, 8).OffsetSize(-2, 0))
264 {
265 HAlign = 0.5f,
266 VAlign = 0.5f
267 };
268 }
269 }
270
271 public abstract class AAccessories
272 {
274 {
275 Misc,
276 NonMisc
277 }
278
280 {
281 bool flag = ItemSlot.IsMiscEquipment(entry);
282 if (flag && categoryType == AccessoriesCategory.Misc)
283 {
284 return true;
285 }
286 if (!flag && categoryType == AccessoriesCategory.NonMisc && entry.accessory)
287 {
288 return true;
289 }
290 return false;
291 }
292 }
293
295 {
296 public bool FitsFilter(Item entry)
297 {
299 }
300
301 public string GetDisplayNameKey()
302 {
303 return "CreativePowers.TabAccessories";
304 }
305
307 {
308 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
309 return new UIImageFramed(obj, obj.Frame(11, 1, 1).OffsetSize(-2, 0))
310 {
311 HAlign = 0.5f,
312 VAlign = 0.5f
313 };
314 }
315 }
316
318 {
319 public bool FitsFilter(Item entry)
320 {
322 }
323
324 public string GetDisplayNameKey()
325 {
326 return "CreativePowers.TabAccessoriesMisc";
327 }
328
330 {
331 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
332 return new UIImageFramed(obj, obj.Frame(11, 1, 9).OffsetSize(-2, 0))
333 {
334 HAlign = 0.5f,
335 VAlign = 0.5f
336 };
337 }
338 }
339
341 {
342 public bool FitsFilter(Item entry)
343 {
344 int type = entry.type;
345 if (type == 267 || type == 1307)
346 {
347 return true;
348 }
349 bool flag = entry.createTile != -1 || entry.createWall != -1 || entry.tileWand != -1;
350 if (entry.consumable)
351 {
352 return !flag;
353 }
354 return false;
355 }
356
357 public string GetDisplayNameKey()
358 {
359 return "CreativePowers.TabConsumables";
360 }
361
363 {
364 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
365 return new UIImageFramed(obj, obj.Frame(11, 1, 3).OffsetSize(-2, 0))
366 {
367 HAlign = 0.5f,
368 VAlign = 0.5f
369 };
370 }
371 }
372
374 {
375 public bool FitsFilter(Item entry)
376 {
377 return ItemID.Sets.SortingPriorityBossSpawns[entry.type] != -1;
378 }
379
380 public string GetDisplayNameKey()
381 {
382 return "CreativePowers.TabMisc";
383 }
384
386 {
387 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
388 return new UIImageFramed(obj, obj.Frame(11, 1, 5).OffsetSize(-2, 0))
389 {
390 HAlign = 0.5f,
391 VAlign = 0.5f
392 };
393 }
394 }
395
397 {
398 private bool[] _fitsFilterByItemType;
399
401 {
402 short count = ItemID.Count;
403 _fitsFilterByItemType = new bool[count];
404 for (int i = 1; i < count; i++)
405 {
406 _fitsFilterByItemType[i] = true;
408 if (!CreativeItemSacrificesCatalog.Instance.TryGetSacrificeCountCapToUnlockInfiniteItems(i, out var _))
409 {
410 _fitsFilterByItemType[i] = false;
411 continue;
412 }
413 for (int j = 0; j < otherFiltersToCheckAgainst.Count; j++)
414 {
416 {
417 _fitsFilterByItemType[i] = false;
418 break;
419 }
420 }
421 }
422 }
423
424 public bool FitsFilter(Item entry)
425 {
426 if (_fitsFilterByItemType.IndexInRange(entry.type))
427 {
428 return _fitsFilterByItemType[entry.type];
429 }
430 return false;
431 }
432
433 public string GetDisplayNameKey()
434 {
435 return "CreativePowers.TabMisc";
436 }
437
439 {
440 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
441 return new UIImageFramed(obj, obj.Frame(11, 1, 5).OffsetSize(-2, 0))
442 {
443 HAlign = 0.5f,
444 VAlign = 0.5f
445 };
446 }
447 }
448
450 {
451 public bool FitsFilter(Item entry)
452 {
453 return entry.material;
454 }
455
456 public string GetDisplayNameKey()
457 {
458 return "CreativePowers.TabMaterials";
459 }
460
462 {
463 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Creative/Infinite_Icons", (AssetRequestMode)1);
464 return new UIImageFramed(obj, obj.Frame(11, 1, 10).OffsetSize(-2, 0))
465 {
466 HAlign = 0.5f,
467 VAlign = 0.5f
468 };
469 }
470 }
471
472 private const int framesPerRow = 11;
473
474 private const int framesPerColumn = 1;
475
476 private const int frameSizeOffsetX = -2;
477
478 private const int frameSizeOffsetY = 0;
479}
bool IsAnAccessoryOfType(Item entry, AccessoriesCategory categoryType)
bool IsAnArmorThatMatchesSocialState(Item entry, bool shouldBeSocial)
MiscFallback(List< IItemEntryFilter > otherFiltersToCheckAgainst)
static Dictionary< int, Item > ItemsByType
static int[] SortingPriorityBossSpawns
Definition ItemID.cs:1064
static readonly short Count
Definition ItemID.cs:12138
static void MouseText_DrawItemTooltip_GetLinesInfo(Item item, ref int yoyoLogo, ref int researchLine, float oldKB, ref int numLines, string[] toolTipLine, bool[] preFixLine, bool[] badPreFixLine)
Definition Main.cs:19206
static bool[] tileFrameImportant
Definition Main.cs:1495
static IAssetRepository Assets
Definition Main.cs:209
static bool IsMiscEquipment(Item item)
Definition ItemSlot.cs:2645