-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathItemChecklistUI.cs
607 lines (522 loc) · 21.9 KB
/
ItemChecklistUI.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
using ItemChecklist.UIElements;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using ReLogic.Content;
using Terraria;
using Terraria.Audio;
using Terraria.GameContent;
using Terraria.GameContent.UI.Elements;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI;
using UIItemSlot = ItemChecklist.UIElements.UIItemSlot;
using Steamworks;
using System.Runtime.CompilerServices;
using System.ComponentModel;
using Terraria.Localization;
namespace ItemChecklist
{
class ItemChecklistUI : UIState
{
internal static ItemChecklistUI instance;
public UIHoverImageButton foundFilterButton;
public UIToggleHoverImageButton muteButton;
//public UIHoverImageButton sortButton;
public UIHoverImageButton modFilterButton;
public UIToggleHoverImageButton collectChestItemsButton;
public UIToggleHoverImageButton showBadgeButton;
private bool buttonsHaveDummyTextures;
public UIDragableElement mainPanel;
public UIPanel checklistPanel;
internal NewUITextBox itemNameFilter;
internal NewUITextBox itemDescriptionFilter;
internal SharedUI sharedUI;
public UIGrid checklistGrid;
public UICollectionBar collectionBar;
//public static SortModes sortMode = SortModes.TerrariaSort;
float spacing = 8f;
public static bool Visible
{
get { return ItemChecklist.ItemChecklistInterface.CurrentState == ItemChecklist.instance.ItemChecklistUI; }
set { ItemChecklist.ItemChecklistInterface.SetState(value ? ItemChecklist.instance.ItemChecklistUI : null); }
}
public static int showCompleted = 0; // 0: both, 1: unfound, 2: found
public static bool announce = true;
public static bool collectChestItems = true;
public static bool showBadge = true;
public static string hoverText = "";
UIItemSlot[] itemSlots;
internal static int[] vanillaIDsInSortOrder;
internal List<string> modnames;
internal int currentMod = 0;
public string[] foundFilterStrings;
const string LOCALIZATION_KEY = "Mods.ItemChecklist.Ui.";
public static LocalizedText ToggleCollectChestItemsText;
public static LocalizedText ToggleMessagesText;
public static LocalizedText ShowSortValueTextText;
public static LocalizedText FilterByNameText;
public static LocalizedText FilterByTooltipText;
public static LocalizedText CycleModFilterText;
public static LocalizedText CycleFoundFilterText;
public static LocalizedText ModnamesAllText;
public static LocalizedText FoundFilterAllText;
public static LocalizedText FoundFilterUnfoundText;
public static LocalizedText FoundFilterFoundText;
public static LocalizedText ModnamesVanillaText;
public ItemChecklistUI()
{
instance = this;
FilterByTooltipText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FilterByTooltipText) );
FilterByNameText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FilterByNameText) );
ToggleCollectChestItemsText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ToggleCollectChestItemsText) );
ToggleMessagesText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ToggleMessagesText) );
ShowSortValueTextText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ShowSortValueTextText) );
CycleModFilterText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(CycleModFilterText) );
CycleFoundFilterText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(CycleFoundFilterText) );
ModnamesAllText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ModnamesAllText) );
FoundFilterAllText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterAllText) );
FoundFilterUnfoundText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterUnfoundText) );
FoundFilterFoundText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(FoundFilterFoundText) );
ModnamesVanillaText = Language.GetOrRegister( LOCALIZATION_KEY + nameof(ModnamesVanillaText) );
foundFilterStrings = new [] { FoundFilterAllText.Value , FoundFilterUnfoundText.Value , FoundFilterFoundText.Value };
}
public override void OnInitialize()
{
// Is initialize called? (Yes it is called on reload) I want to reset nicely with new character or new loaded mods: visible = false;
announce = false; // overwritten by modplayer
collectChestItems = false;
showBadge = false;
mainPanel = new UIDragableElement();
//mainPanel.SetPadding(0);
//mainPanel.PaddingTop = 4;
mainPanel.Left.Set(400f, 0f);
mainPanel.Top.Set(400f, 0f);
mainPanel.Width.Set(475f, 0f); // + 30
mainPanel.MinWidth.Set(415f, 0f);
mainPanel.MaxWidth.Set(884f, 0f);
mainPanel.Height.Set(370, 0f);
mainPanel.MinHeight.Set(263, 0f);
mainPanel.MaxHeight.Set(1000, 0f);
//mainPanel.BackgroundColor = Color.LightBlue;
var config = ModContent.GetInstance<ItemChecklistClientConfig>();
mainPanel.Left.Set(config.ItemChecklistPosition.X, 0f);
mainPanel.Top.Set(config.ItemChecklistPosition.Y, 0f);
mainPanel.Width.Set(config.ItemChecklistSize.X, 0f);
mainPanel.Height.Set(config.ItemChecklistSize.Y, 0f);
int top = 0;
int left = 0;
checklistPanel = new UIPanel();
checklistPanel.SetPadding(10);
checklistPanel.BackgroundColor = new Color(73, 94, 171);;
checklistPanel.Top.Set(0, 0f);
checklistPanel.Height.Set(0, 1f);
checklistPanel.Width.Set(0, 1f);
mainPanel.Append(checklistPanel);
mainPanel.AddDragTarget(checklistPanel);
// Because OnInitialize Happens during load and because we need it to happen for OnEnterWorld, use dummy sprite.
buttonsHaveDummyTextures = true;
foundFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, CycleFoundFilterText.Format("??"));
foundFilterButton.OnLeftClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, true);
foundFilterButton.OnRightClick += (a, b) => ToggleFoundFilterButtonClicked(a, b, false);
foundFilterButton.Top.Pixels = top;
checklistPanel.Append(foundFilterButton);
left += (int)spacing * 2 + 28;
//sortButton = new UIHoverImageButton(sortButtonTexture, "Cycle Sort Method: ??");
//sortButton.OnClick += (a, b) => ToggleSortButtonClicked(a, b, true);
//sortButton.OnRightClick += (a, b) => ToggleSortButtonClicked(a, b, false);
//sortButton.Left.Pixels = spacing * 4 + 28 * 2;
//sortButton.Top.Pixels = top;
//checklistPanel.Append(sortButton);
modFilterButton = new UIHoverImageButton(TextureAssets.MagicPixel.Value, CycleModFilterText.Format( "??" ));
modFilterButton.OnLeftClick += (a, b) => ToggleModFilterButtonClicked(a, b, true);
modFilterButton.OnRightClick += (a, b) => ToggleModFilterButtonClicked(a, b, false);
modFilterButton.Left.Pixels = left;
modFilterButton.Top.Pixels = top;
checklistPanel.Append(modFilterButton);
left += (int)spacing * 2 + 28;
muteButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ToggleMessagesText.Value, announce);
muteButton.OnLeftClick += ToggleMuteButtonClicked;
muteButton.Left.Pixels = left;
muteButton.Top.Pixels = top;
checklistPanel.Append(muteButton);
left += (int)spacing * 2 + 28;
collectChestItemsButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ToggleCollectChestItemsText.Value, collectChestItems);
collectChestItemsButton.OnLeftClick += ToggleFindChestItemsButtonClicked;
collectChestItemsButton.Left.Pixels = left;
collectChestItemsButton.Top.Pixels = top;
checklistPanel.Append(collectChestItemsButton);
left += (int)spacing * 2 + 28;
showBadgeButton = new UIToggleHoverImageButton(TextureAssets.MagicPixel.Value, ItemChecklist.instance.Assets.Request<Texture2D>("UIElements/closeButton", AssetRequestMode.ImmediateLoad).Value, ShowSortValueTextText.Value, showBadge);
showBadgeButton.OnLeftClick += ToggleShowBadgeButtonClicked;
showBadgeButton.Left.Pixels = left;
showBadgeButton.Top.Pixels = top;
checklistPanel.Append(showBadgeButton);
left += (int)spacing * 2 + 28;
top += 34;
itemNameFilter = new NewUITextBox(FilterByNameText.Value);
itemNameFilter.OnTextChanged += () => { ValidateItemFilter(); updateNeeded = true; };
itemNameFilter.OnTabPressed += () => { itemDescriptionFilter.Focus(); };
itemNameFilter.Top.Pixels = top;
//itemNameFilter.Left.Set(-152, 1f);
itemNameFilter.Width.Set(0, 1f);
itemNameFilter.Height.Set(25, 0f);
checklistPanel.Append(itemNameFilter);
top += 30;
itemDescriptionFilter = new NewUITextBox(FilterByTooltipText.Value);
itemDescriptionFilter.OnTextChanged += () => { ValidateItemDescription(); updateNeeded = true; };
itemDescriptionFilter.OnTabPressed += () => { itemNameFilter.Focus(); };
itemDescriptionFilter.Top.Pixels = top;
//itemDescriptionFilter.Left.Set(-152, 1f);
itemDescriptionFilter.Width.Set(0, 1f);
itemDescriptionFilter.Height.Set(25, 0f);
checklistPanel.Append(itemDescriptionFilter);
top += 30;
sharedUI = new SharedUI();
sharedUI.Initialize();
sharedUI.sortsAndFiltersPanel.Top.Set(top, 0f);
sharedUI.sortsAndFiltersPanel.Width.Set(0f, 1);
sharedUI.sortsAndFiltersPanel.Height.Set(60, 0f);
checklistPanel.Append(sharedUI.sortsAndFiltersPanel);
top += 68;
checklistGrid = new UIGrid();
checklistGrid.alternateSort = ItemGridSort;
checklistGrid.Top.Pixels = top;
checklistGrid.Width.Set(-25f, 1f);
checklistGrid.Height.Set(-top - 24, 1f);
checklistGrid.ListPadding = 2f;
checklistPanel.Append(checklistGrid);
FixedUIScrollbar checklistListScrollbar = new FixedUIScrollbar();
checklistListScrollbar.SetView(100f, 1000f);
checklistListScrollbar.Top.Pixels = top;
checklistListScrollbar.Height.Set(-top - 24, 1f);
checklistListScrollbar.HAlign = 1f;
checklistPanel.Append(checklistListScrollbar);
checklistGrid.SetScrollbar(checklistListScrollbar);
// Checklistlist populated when the panel is shown: UpdateCheckboxes()
collectionBar = new UICollectionBar() {
Width = new StyleDimension(0f, 1f),
Height = new StyleDimension(15f, 0f),
VAlign = 1f,
};
checklistPanel.Append(collectionBar);
Append(mainPanel);
// load time impact, do this on first show?
itemSlots = new UIItemSlot[ItemLoader.ItemCount];
Item[] itemSlotItems = new Item[ItemLoader.ItemCount];
for (int i = 0; i < ItemLoader.ItemCount; i++)
{
Item item = ContentSamples.ItemsByType[i];
if (item.type == ItemID.None)
continue;
itemSlots[i] = new UIItemSlot(item, i);
itemSlotItems[i] = item;
}
FieldInfo inventoryGlowHue = typeof(Terraria.UI.ItemSlot).GetField("inventoryGlowHue", BindingFlags.Static | BindingFlags.NonPublic);
FieldInfo inventoryGlowTime = typeof(Terraria.UI.ItemSlot).GetField("inventoryGlowTime", BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo SortMethod = typeof(ItemSorting).GetMethod("Sort", BindingFlags.Static | BindingFlags.NonPublic);
object[] parametersArray = new object[] { itemSlotItems, new int[0] };
inventoryGlowHue.SetValue(null, new float[ItemLoader.ItemCount]);
inventoryGlowTime.SetValue(null, new int[ItemLoader.ItemCount]);
//SortMethod.Invoke(null, parametersArray);
inventoryGlowHue.SetValue(null, new float[58]);
inventoryGlowTime.SetValue(null, new int[58]);
int[] vanillaIDsInSortOrderTemp = itemSlotItems.Where(x => x != null).Select((x) => x.type).ToArray();
vanillaIDsInSortOrder = new int[ItemLoader.ItemCount];
for (int i = 0; i < ItemLoader.ItemCount; i++)
{
vanillaIDsInSortOrder[i] = Array.FindIndex(vanillaIDsInSortOrderTemp, x => x == i);
}
List<Item> list = ContentSamples.ItemsByType.Values.ToList();
IOrderedEnumerable<IGrouping<ContentSamples.CreativeHelper.ItemGroup, ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup>> orderedEnumerable = from x in list
select new ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup(x) into x
group x by x.Group into @group
orderby (int)@group.Key
select @group;
int order = 0;
foreach (IGrouping<ContentSamples.CreativeHelper.ItemGroup, ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup> item2 in orderedEnumerable) {
foreach (ContentSamples.CreativeHelper.ItemGroupAndOrderInGroup item3 in item2) {
//vanillaIDsInSortOrder[order] = item3.ItemType;
// TODO...rename?
vanillaIDsInSortOrder[item3.ItemType] = order;
order++;
}
}
modnames = new List<string>() { ModnamesAllText.Value, ModnamesVanillaText.Value };
modnames.AddRange(ModLoader.Mods.Where(mod => mod.GetContent<ModItem>().Any()).Select(x => x.Name)/*.Where(x => x != "ModLoader")*/);
updateNeeded = true;
}
private int ItemGridSort(UIElement x, UIElement y)
{
UIItemSlot a = x as UIItemSlot;
UIItemSlot b = y as UIItemSlot;
if (SharedUI.instance.SelectedSort != null)
return SharedUI.instance.SelectedSort.sort(a.item, b.item);
return a.item.type.CompareTo(b.item.type);
}
private void ToggleFoundFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
{
SoundEngine.PlaySound(SoundID.MenuTick);
showCompleted = (3 + showCompleted + (left ? 1 : -1)) % 3;
foundFilterButton.hoverText = CycleFoundFilterText.Format( foundFilterStrings[showCompleted]);
UpdateNeeded();
}
private void ToggleMuteButtonClicked(UIMouseEvent evt, UIElement listeningElement)
{
announce = !announce;
SoundEngine.PlaySound(announce ? SoundID.MenuOpen : SoundID.MenuClose);
muteButton.SetEnabled(announce);
}
//private void ToggleSortButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
//{
// Main.PlaySound(SoundID.MenuTick);
// sortMode = left ? sortMode.NextEnum() : sortMode.PreviousEnum();
// sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString();
// UpdateNeeded();
//}
private void ToggleModFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement, bool left)
{
SoundEngine.PlaySound(SoundID.MenuTick);
currentMod = (modnames.Count + currentMod + (left ? 1 : -1)) % modnames.Count;
modFilterButton.hoverText = CycleModFilterText.Format( modnames[currentMod]);
UpdateNeeded();
}
private void ToggleShowBadgeButtonClicked(UIMouseEvent evt, UIElement listeningElement)
{
showBadge = !showBadge;
SoundEngine.PlaySound(showBadge ? SoundID.MenuOpen : SoundID.MenuClose);
showBadgeButton.SetEnabled(showBadge);
}
private void ToggleFindChestItemsButtonClicked(UIMouseEvent evt, UIElement listeningElement)
{
collectChestItems = !collectChestItems;
SoundEngine.PlaySound(collectChestItems ? SoundID.MenuOpen : SoundID.MenuClose);
collectChestItemsButton.SetEnabled(collectChestItems);
}
internal void RefreshPreferences()
{
foundFilterButton.hoverText = CycleFoundFilterText.Format( foundFilterStrings[showCompleted]);
//sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString();
modFilterButton.hoverText = CycleModFilterText.Format( modnames[currentMod]);
muteButton.SetEnabled(announce);
collectChestItemsButton.SetEnabled(collectChestItems);
UpdateNeeded();
}
private bool updateNeeded;
private int lastfoundID = -1;
internal void UpdateNeeded(int lastfoundID = -1)
{
updateNeeded = true;
if (lastfoundID > 0)
{
this.lastfoundID = lastfoundID;
}
}
// todo, items on load.
internal void UpdateCheckboxes()
{
if (!updateNeeded) { return; }
updateNeeded = false;
checklistGrid.Clear();
collectionBar.RecalculateBars();
if (buttonsHaveDummyTextures)
{
Main.instance.LoadItem(ItemID.Megaphone);
Main.instance.LoadItem(ItemID.Book);
Texture2D foundFilterTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request<Texture2D>("Images/filterFound", AssetRequestMode.ImmediateLoad), 32, 32);
Texture2D muteButtonTexture = Utilities.ResizeImage(TextureAssets.Item[ItemID.Megaphone], 32, 32);
//Texture2D sortButtonTexture = Utilities.ResizeImage(Main.itemTexture[ItemID.ToxicFlask], 32, 32);
Texture2D modFilterButtonTexture = Utilities.ResizeImage(ItemChecklist.instance.Assets.Request<Texture2D>("Images/filterMod", AssetRequestMode.ImmediateLoad), 32, 32);
Texture2D collectChestItemsButtonTexture = Utilities.ResizeImage(TextureAssets.Cursors[8], 32, 32);
Texture2D showBadgeButtonTexture = Utilities.ResizeImage(TextureAssets.Item[ItemID.Book], 32, 32); // Main.extraTexture[58]
foundFilterButton.SetImage(foundFilterTexture);
muteButton.SetImage(muteButtonTexture);
modFilterButton.SetImage(modFilterButtonTexture);
collectChestItemsButton.SetImage(collectChestItemsButtonTexture);
showBadgeButton.SetImage(showBadgeButtonTexture);
buttonsHaveDummyTextures = false;
}
var itemChecklistPlayer = Main.LocalPlayer.GetModPlayer<ItemChecklistPlayer>();
var temp = new List<UIItemSlot>();
for (int i = 0; i < itemChecklistPlayer.findableItems.Length; i++)
{
if (itemChecklistPlayer.findableItems[i])
{
if (itemSlots[i] == null) continue;
// filters here
if ((showCompleted != 1 && itemChecklistPlayer.foundItem[i]) || (showCompleted != 2 && !itemChecklistPlayer.foundItem[i]))
{
if (!PassModFilter(itemSlots[i]))
continue;
if (SharedUI.instance.SelectedCategory != null)
{
if (!SharedUI.instance.SelectedCategory.belongs(itemSlots[i].item) && !SharedUI.instance.SelectedCategory.subCategories.Any(x => x.belongs(itemSlots[i].item)))
continue;
}
bool filtered = false;
foreach (var filter in SharedUI.instance.availableFilters)
{
if (filter.button.selected)
if (!filter.belongs(itemSlots[i].item))
filtered = true;
}
if (filtered)
continue;
if (itemSlots[i].item.Name.IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) == -1)
continue;
if (itemDescriptionFilter.currentString.Length > 0)
{
if ((itemSlots[i].item.ToolTip != null && GetTooltipsAsString(itemSlots[i].item.ToolTip).IndexOf(itemDescriptionFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1) /*|| (recipe.createItem.toolTip2 != null && recipe.createItem.toolTip2.ToLower().IndexOf(itemDescriptionFilter.Text, StringComparison.OrdinalIgnoreCase) != -1)*/)
{
}
else
{
continue;
}
}
UIItemSlot box = itemSlots[i];
box.badge = SharedUI.instance.SelectedSort?.badge(box.item) ?? "";
temp.Add(box);
}
}
}
checklistGrid.AddRange(temp);
if (lastfoundID > 0)
{
checklistGrid.Recalculate();
if (showCompleted != 1) // Don't Goto when unfound is the display mode.
{
checklistGrid.Goto(delegate (UIElement element)
{
UIItemSlot itemSlot = element as UIItemSlot;
return itemSlot != null && itemSlot.itemType == lastfoundID;
}, true);
}
lastfoundID = -1;
}
}
private bool PassModFilter(UIItemSlot itemSlot)
{
if (currentMod == 0)
{
return true;
}
else if (currentMod == 1 && itemSlot.item.ModItem == null)
{
return true;
}
else if (itemSlot.item.ModItem != null && itemSlot.item.ModItem.Mod.Name == modnames[currentMod])
{
return true;
}
return false;
}
private void ValidateItemFilter()
{
if (itemNameFilter.currentString.Length > 0)
{
bool found = false;
foreach (var itemSlot in itemSlots)
{
if (itemSlot == null) continue;
if (itemSlot.item.Name.IndexOf(itemNameFilter.currentString, StringComparison.OrdinalIgnoreCase) != -1)
{
found = true;
break;
}
}
if (!found)
{
itemNameFilter.SetText(itemNameFilter.currentString.Substring(0, itemNameFilter.currentString.Length - 1));
}
}
updateNeeded = true;
}
private void ValidateItemDescription()
{
updateNeeded = true;
}
public override void Draw(SpriteBatch spriteBatch) {
if (buttonsHaveDummyTextures)
return;
base.Draw(spriteBatch);
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
ItemChecklistUI.hoverText = "";
Vector2 MousePosition = new Vector2((float)Main.mouseX, (float)Main.mouseY);
if (mainPanel.ContainsPoint(MousePosition))
{
Main.player[Main.myPlayer].mouseInterface = true;
}
}
public override void Update(GameTime gameTime)
{
base.Update(gameTime);
sharedUI.Update();
UpdateCheckboxes();
}
private string GetTooltipsAsString(ItemTooltip toolTip)
{
StringBuilder sb = new StringBuilder();
for (int j = 0; j < toolTip.Lines; j++)
{
sb.Append(toolTip.GetLine(j) + "\n");
}
return sb.ToString().ToLower();
}
internal static void OnScrollWheel_FixHotbarScroll(UIScrollWheelEvent evt, UIElement listeningElement)
{
Main.LocalPlayer.ScrollHotbar(Terraria.GameInput.PlayerInput.ScrollWheelDelta / 120);
}
}
//public enum SortModes
//{
// ID,
// Value,
// AZ,
// Rare,
// TerrariaSort,
//}
public class FixedUIScrollbar : UIScrollbar
{
protected override void DrawSelf(SpriteBatch spriteBatch)
{
UserInterface temp = UserInterface.ActiveInstance;
UserInterface.ActiveInstance = ItemChecklist.ItemChecklistInterface;
base.DrawSelf(spriteBatch);
UserInterface.ActiveInstance = temp;
}
public override void LeftMouseDown(UIMouseEvent evt)
{
UserInterface temp = UserInterface.ActiveInstance;
UserInterface.ActiveInstance = ItemChecklist.ItemChecklistInterface;
base.LeftMouseDown(evt);
UserInterface.ActiveInstance = temp;
}
}
//public static class Extensions
//{
// public static string ToFriendlyString(this SortModes sortmode)
// {
// switch (sortmode)
// {
// case SortModes.AZ:
// return "Alphabetically";
// case SortModes.ID:
// return "ID";
// case SortModes.Value:
// return "Value";
// case SortModes.Rare:
// return "Rarity";
// case SortModes.TerrariaSort:
// return "Terraria Sort";
// }
// return "Unknown Sort";
// }
//}
}