diff --git a/BepInEx/Core.cs b/BepInEx/Core.cs index e69ff89..d674cf8 100644 --- a/BepInEx/Core.cs +++ b/BepInEx/Core.cs @@ -33,7 +33,12 @@ public class Core : BasePlugin public ConfigEntry configDefaultAudio; public ConfigEntry configLanguage; - public override void Load() + private static float lastCheck = 0f; + private static float checkTime = 0f; + private static float checkInterval = 2f; + private static bool stringreloaded = false; + + public override void Load() { Log = base.Log; Instance = this; @@ -98,6 +103,25 @@ public class Core : BasePlugin { TowerManager_Patch.UpdateText(); } + if (Input.GetKeyDown(KeyCode.RightShift)) + { + stringreloaded = !stringreloaded; + } + Core.DebugStringReload(); + } + + public static void DebugStringReload() + { + if (stringreloaded == true) + { + checkTime += Time.deltaTime; + if (checkTime >= checkInterval) + { + StringStore.Reload(); + ShowToast("Strings Reloaded!"); + checkTime = 0f; + } + } } public void OnGUI() diff --git a/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs b/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs index 13ceea3..c5aa552 100644 --- a/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs +++ b/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using TMPro; using PvZ_Fusion_Translator__BepInEx_.AssetStore; using UnityEngine; @@ -17,12 +17,13 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects { TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - PlantType thePlantType = __instance.plant.thePlantType; + BigGardenPlant thePlant = __instance.plant; foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) { - if(txt.name.Contains("Introduce")) + if(txt.name.Contains("Introduce") && thePlant != null) { + PlantType thePlantType = thePlant.thePlantType; txt.text = StringStore.TranslateText(txt.text); string text = txt.text; diff --git a/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs b/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs index 2148408..ddae2f7 100644 --- a/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs +++ b/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs @@ -14,7 +14,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers { [HarmonyPatch(nameof(AlmanacPlantBank.InitNameAndInfoFromJson))] [HarmonyPostfix] - private static void InitNameAndInfoFromJson(AlmanacPlantBank __instance) + public static void InitNameAndInfoFromJson(AlmanacPlantBank __instance) { #if MULTI_LANGUAGE string currentLanguage = Utils.Language.ToString(); diff --git a/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs b/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs index 7afa26c..421a626 100644 --- a/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs +++ b/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs @@ -28,7 +28,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent(); cost.text = StringStore.TranslateText(cost.text); cost.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - FileLoader.DumpUntranslatedStrings(cost.text); + //FileLoader.DumpUntranslatedStrings(cost.text); } foreach (TextMeshProUGUI intr in __instance.introduces) intr.text = StringStore.TranslateText(intr.text); diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs index 3647392..356c40b 100644 --- a/MelonLoader/Utils.cs +++ b/MelonLoader/Utils.cs @@ -235,39 +235,7 @@ namespace PvZ_Fusion_Translator return theZombieName; } - public static string GetZombieNameFromAlmanac(ZombieType theZombieType) - { - string json; - string theZombieName = ""; - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); - Log.LogError("Zombie name could not be found!"); - theZombieName = ""; - } - else - { - json = File.ReadAllText(path); - AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson(json); - - foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies) - { - if ((int)zombieInfo.theZombieType == (int)theZombieType) - { - theZombieName = zombieInfo.name; - } - } - } - - return theZombieName; - } - - public static Dictionary> plantIndices = new Dictionary>(); Dictionary>(); + public static Dictionary> plantIndices = new Dictionary>(); public static void RegisterPlantIndices() {