From a33617f9f265b6233033ac61176fad49e0b3f201 Mon Sep 17 00:00:00 2001 From: JavidPack Date: Fri, 6 Jan 2017 17:37:14 -0700 Subject: [PATCH] 0.2.0.2 release, mod filter --- ItemChecklistUI.cs | 73 +++++++++++++++++++++++++++++++++++++-------- build.txt | 2 +- filterMod.png | Bin 0 -> 2912 bytes 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 filterMod.png diff --git a/ItemChecklistUI.cs b/ItemChecklistUI.cs index 502a04b..875b233 100644 --- a/ItemChecklistUI.cs +++ b/ItemChecklistUI.cs @@ -7,14 +7,17 @@ using Terraria.ID; using System; using System.Reflection; using System.Linq; +using Terraria.ModLoader; +using System.Collections.Generic; namespace ItemChecklist.UI { class ItemChecklistUI : UIState { - public UIHoverImageButton toggleButton; + public UIHoverImageButton foundFilterButton; public UIToggleHoverImageButton muteButton; public UIHoverImageButton sortButton; + public UIHoverImageButton modFilterButton; public UIPanel checklistPanel; public UIGrid checklistGrid; public static SortModes sortMode = SortModes.TerrariaSort; @@ -28,6 +31,11 @@ namespace ItemChecklist.UI ItemSlot[] itemSlots; internal static int[] vanillaIDsInSortOrder; + internal List modnames; + internal int currentMod = 0; + + public string[] foundFilterStrings = { "All", "Unfound", "Found" }; + 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; @@ -43,9 +51,9 @@ namespace ItemChecklist.UI checklistPanel.Height.Set(-100, 1f); checklistPanel.BackgroundColor = new Color(73, 94, 171); - toggleButton = new UIHoverImageButton(Main.itemTexture[ItemID.Book], "Cycle Found Filter"); - toggleButton.OnClick += ToggleButtonClicked; - checklistPanel.Append(toggleButton); + foundFilterButton = new UIHoverImageButton(Main.itemTexture[ItemID.Book], "Cycle Found Filter: ??"); + foundFilterButton.OnClick += ToggleFoundFilterButtonClicked; + checklistPanel.Append(foundFilterButton); muteButton = new UIToggleHoverImageButton(Main.itemTexture[ItemID.Megaphone], ItemChecklist.instance.GetTexture("closeButton"), "Toggle Messages", announce); muteButton.OnClick += ToggleMuteButtonClicked; @@ -53,12 +61,18 @@ namespace ItemChecklist.UI muteButton.Top.Pixels = 4; checklistPanel.Append(muteButton); - sortButton = new UIHoverImageButton(Main.itemTexture[ItemID.ToxicFlask], "Cycle Sort Method: ID"); + sortButton = new UIHoverImageButton(Main.itemTexture[ItemID.ToxicFlask], "Cycle Sort Method: ??"); sortButton.OnClick += ToggleSortButtonClicked; sortButton.Left.Pixels = spacing * 4 + 28 * 2; sortButton.Top.Pixels = 4; checklistPanel.Append(sortButton); + modFilterButton = new UIHoverImageButton(ItemChecklist.instance.GetTexture("filterMod"), "Cycle Mod Filter: ??"); + modFilterButton.OnClick += ToggleModFilterButtonClicked; + modFilterButton.Left.Pixels = spacing * 6 + 28 * 3; + modFilterButton.Top.Pixels = 4; + checklistPanel.Append(modFilterButton); + checklistGrid = new UIGrid(5); checklistGrid.Top.Pixels = 32f + spacing; checklistGrid.Width.Set(-25f, 1f); @@ -106,34 +120,48 @@ namespace ItemChecklist.UI vanillaIDsInSortOrder[i] = Array.FindIndex(vanillaIDsInSortOrderTemp, x => x == i); } + modnames = new List() { "All", "Vanilla"}; + modnames.AddRange(ModLoader.GetLoadedMods()/*.Where(x => x != "ModLoader")*/); + updateneeded = true; } - private void ToggleButtonClicked(UIMouseEvent evt, UIElement listeningElement) + private void ToggleFoundFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement) { - Main.PlaySound(10, -1, -1, 1); + Main.PlaySound(SoundID.MenuTick); showCompleted = ++showCompleted % 3; + foundFilterButton.hoverText = "Cycle Found Filter: " + foundFilterStrings[showCompleted]; UpdateNeeded(); } private void ToggleMuteButtonClicked(UIMouseEvent evt, UIElement listeningElement) { - Main.PlaySound(10, -1, -1, 1); announce = !announce; + Main.PlaySound(announce ? SoundID.MenuOpen : SoundID.MenuClose); muteButton.SetEnabled(announce); } private void ToggleSortButtonClicked(UIMouseEvent evt, UIElement listeningElement) { - Main.PlaySound(10, -1, -1, 1); + Main.PlaySound(SoundID.MenuTick); sortMode = sortMode.Next(); sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString(); UpdateNeeded(); } + private void ToggleModFilterButtonClicked(UIMouseEvent evt, UIElement listeningElement) + { + Main.PlaySound(SoundID.MenuTick); + currentMod = (currentMod + 1) % modnames.Count; + modFilterButton.hoverText = "Cycle Mod Filter: " + modnames[currentMod]; + UpdateNeeded(); + } + internal void RefreshPreferences() { + foundFilterButton.hoverText = "Cycle Found Filter: " + foundFilterStrings[showCompleted]; sortButton.hoverText = "Cycle Sort Method: " + sortMode.ToFriendlyString(); + modFilterButton.hoverText = "Cycle Mod Filter: " + modnames[currentMod]; muteButton.SetEnabled(announce); UpdateNeeded(); } @@ -165,11 +193,13 @@ namespace ItemChecklist.UI // filters here if ((showCompleted != 1 && itemChecklistPlayer.foundItem[i]) || (showCompleted != 2 && !itemChecklistPlayer.foundItem[i])) { + if (PassModFilter(itemSlots[i])) + { + ItemSlot box = itemSlots[i]; - ItemSlot box = itemSlots[i]; - - checklistGrid._items.Add(box); - checklistGrid._innerList.Append(box); + checklistGrid._items.Add(box); + checklistGrid._innerList.Append(box); + } } } } @@ -188,6 +218,23 @@ namespace ItemChecklist.UI } } + private bool PassModFilter(ItemSlot 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; + } + protected override void DrawSelf(SpriteBatch spriteBatch) { UpdateCheckboxes(); diff --git a/build.txt b/build.txt index 8838969..0b63f31 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly -version = 0.2.0.1 +version = 0.2.0.2 displayName = Item Checklist homepage = https://forums.terraria.org/index.php?threads/item-checklist-in-game-100-item-collection-checklist.52786/ hideCode = false diff --git a/filterMod.png b/filterMod.png new file mode 100644 index 0000000000000000000000000000000000000000..095de7a5468090fa8e13d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