From 17e5a5df397e72687428849f81c37c6d618c05a4 Mon Sep 17 00:00:00 2001 From: JavidPack Date: Thu, 1 Apr 2021 22:10:14 -0600 Subject: [PATCH] v0.6.6.3, fix some reload/cancel issues --- CheatSheet.cs | 19 +++++++++++++++++++ Menus/GenericItemSlot.cs | 2 +- Menus/ItemBrowser.cs | 1 + Menus/NPCSlot.cs | 4 ++-- Menus/RecipeQuerySlot.cs | 4 ++-- Menus/RecipeSlot.cs | 4 ++-- Menus/Slot.cs | 2 +- build.txt | 2 +- 8 files changed, 29 insertions(+), 9 deletions(-) diff --git a/CheatSheet.cs b/CheatSheet.cs index 6d82c6c..41b3b39 100644 --- a/CheatSheet.cs +++ b/CheatSheet.cs @@ -105,6 +105,15 @@ public override void Load() herosPermissions[NPCButcher_Permission] = true; herosPermissions[CheatSheetExtensions_Permission] = true; herosPermissions[QuickTeleport_Permission] = true; + + GenericItemSlot.backgroundTexture = Main.inventoryBack9Texture; + NPCSlot.backgroundTexture = Main.inventoryBack9Texture; + NPCSlot.filteredBackgroundTexture = Main.inventoryBack5Texture; + RecipeQuerySlot.backgroundTexture = Main.inventoryBack9Texture; + RecipeQuerySlot.backgroundTextureFake = Main.inventoryBack8Texture; + RecipeSlot.backgroundTexture = Main.inventoryBack9Texture; + RecipeSlot.selectedBackgroundTexture = Main.inventoryBack15Texture; + Slot.backgroundTexture = Main.inventoryBack9Texture; } public override void Unload() @@ -113,6 +122,14 @@ public override void Unload() ButtonTexture.Clear(); ButtonTooltip.Clear(); + GenericItemSlot.backgroundTexture = null; + NPCSlot.backgroundTexture = null; + NPCSlot.filteredBackgroundTexture = null; + RecipeQuerySlot.backgroundTexture = null; + RecipeQuerySlot.backgroundTextureFake = null; + RecipeSlot.backgroundTexture = null; + RecipeSlot.selectedBackgroundTexture = null; + Slot.backgroundTexture = null; PaintToolsSlot.CurrentSelect = null; AllItemsMenu.singleSlotArray = null; UI.UICheckbox.checkboxTexture = null; @@ -155,6 +172,8 @@ public override void Unload() internal static string CSText(string category, string key) { + if (translations == null) + return ""; return translations[$"Mods.CheatSheet.{category}.{key}"].GetTranslation(Language.ActiveCulture); // This isn't good until after load....can revert after fixing static initializers for string[] // return Language.GetTextValue($"Mods.CheatSheet.{category}.{key}"); diff --git a/Menus/GenericItemSlot.cs b/Menus/GenericItemSlot.cs index d79d807..ef89cc6 100644 --- a/Menus/GenericItemSlot.cs +++ b/Menus/GenericItemSlot.cs @@ -9,7 +9,7 @@ namespace CheatSheet.Menus { internal class GenericItemSlot : UIView { - public static Texture2D backgroundTexture = Main.inventoryBack9Texture; + public static Texture2D backgroundTexture; public Item item = null; diff --git a/Menus/ItemBrowser.cs b/Menus/ItemBrowser.cs index e88cd89..2861c44 100644 --- a/Menus/ItemBrowser.cs +++ b/Menus/ItemBrowser.cs @@ -33,6 +33,7 @@ internal enum ItemBrowserCategories internal class ItemBrowser : UISlideWindow { internal static string CSText(string key, string category = "ItemBrowser") => CheatSheet.CSText(category, key); + // TODO: static stuff like this is bad when unload/cancel happens before translations are ready. private static string[] categNames = new string[] { CSText("AllItems"), diff --git a/Menus/NPCSlot.cs b/Menus/NPCSlot.cs index bf206ca..55a4195 100644 --- a/Menus/NPCSlot.cs +++ b/Menus/NPCSlot.cs @@ -22,8 +22,8 @@ internal class NPCSlot : UIView public int index = 0; - public static Texture2D backgroundTexture = Main.inventoryBack9Texture; - public static Texture2D filteredBackgroundTexture = Main.inventoryBack5Texture; + public static Texture2D backgroundTexture; + public static Texture2D filteredBackgroundTexture; public bool functionalSlot; private bool rightClicking; diff --git a/Menus/RecipeQuerySlot.cs b/Menus/RecipeQuerySlot.cs index 318a985..94b9126 100644 --- a/Menus/RecipeQuerySlot.cs +++ b/Menus/RecipeQuerySlot.cs @@ -9,8 +9,8 @@ namespace CheatSheet.Menus { internal class RecipeQuerySlot : UIView { - public static Texture2D backgroundTexture = Main.inventoryBack9Texture; - public static Texture2D backgroundTextureFake = Main.inventoryBack8Texture; + public static Texture2D backgroundTexture; + public static Texture2D backgroundTextureFake; public Item item = new Item(); internal bool real = true; diff --git a/Menus/RecipeSlot.cs b/Menus/RecipeSlot.cs index 3b508ac..caad79a 100644 --- a/Menus/RecipeSlot.cs +++ b/Menus/RecipeSlot.cs @@ -9,8 +9,8 @@ namespace CheatSheet.Menus { internal class RecipeSlot : UIView { - public static Texture2D backgroundTexture = Main.inventoryBack9Texture; - public static Texture2D selectedBackgroundTexture = Main.inventoryBack15Texture; + public static Texture2D backgroundTexture; + public static Texture2D selectedBackgroundTexture; public int recipeIndex = -1; public Recipe recipe; diff --git a/Menus/Slot.cs b/Menus/Slot.cs index 5b713bd..2892d1f 100644 --- a/Menus/Slot.cs +++ b/Menus/Slot.cs @@ -14,7 +14,7 @@ internal class Slot : UIView public int index = -1; - public static Texture2D backgroundTexture = Main.inventoryBack9Texture; + public static Texture2D backgroundTexture; public bool functionalSlot; private bool rightClicking; diff --git a/build.txt b/build.txt index f8f6bbd..d7d96ba 100644 --- a/build.txt +++ b/build.txt @@ -1,5 +1,5 @@ author = jopojelly, jofairden, rrryutaro -version = 0.6.6.2 +version = 0.6.6.3 displayName = Cheat Sheet homepage = http://forums.terraria.org/index.php?threads/cheat-sheet.41407/ buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, .git\*