Update BIE branch
This commit is contained in:
parent
946cecbfdb
commit
8930591cc5
17 changed files with 455 additions and 113 deletions
|
|
@ -48,6 +48,9 @@ public class Core : BasePlugin
|
|||
TextureStore.Init();
|
||||
StringStore.Init();
|
||||
FontStore.Init();
|
||||
// Register plant indices for fast lookups and load HP regexes
|
||||
Utils.RegisterPlantIndices();
|
||||
PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings();
|
||||
|
||||
InitCoroutine();
|
||||
}
|
||||
|
|
@ -92,6 +95,10 @@ public class Core : BasePlugin
|
|||
Log.LogInfo("del del");
|
||||
Utils.OpenTrello();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
Time.timeScale = 0;
|
||||
}
|
||||
if (TowerManager.Instance != null)
|
||||
{
|
||||
TowerManager_Patch.UpdateText();
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
__instance.fontSize = 12;
|
||||
}
|
||||
|
||||
if (__instance.text == "Полный Хаосs" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present")
|
||||
if (__instance.text == "Полный Хаос" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present")
|
||||
{
|
||||
__instance.text += "\nБесконечно";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(MainMenu_Btn))]
|
||||
public static class MainMenu_Btn_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))]
|
||||
[HarmonyPostfix]
|
||||
private static void OnMouseEnter(MainMenu_Btn __instance)
|
||||
{
|
||||
string textToShow = null;
|
||||
|
||||
if (__instance.transform.parent.name == "recipe")
|
||||
{
|
||||
textToShow = "探索模式";
|
||||
}
|
||||
else if (__instance.name == "mysterious")
|
||||
{
|
||||
textToShow = "神秘模式";
|
||||
}
|
||||
|
||||
if (textToShow != null)
|
||||
{
|
||||
InGameText.Instance.ShowText(textToShow, 2.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -27,8 +27,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
|
||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
if(!text.name.Contains("_EVACUATE"))
|
||||
{
|
||||
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert and translate legacy Text components
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
{
|
||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
StringStore.TranslateText(txt);
|
||||
}
|
||||
|
||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
__instance.nameText.text = StringStore.TranslateText(__instance.nameText.text);
|
||||
}
|
||||
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))]
|
||||
|
|
@ -29,12 +29,38 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
{
|
||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
StringStore.TranslateText(txt);
|
||||
__instance.nameText.text = StringStore.TranslateText(__instance.nameText.text);
|
||||
}
|
||||
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreEnterWindow.SetIcon))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetIcon(ExploreEnterWindow __instance)
|
||||
{
|
||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||
|
||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
__instance.nameText.text = StringStore.TranslateText(__instance.nameText.text);
|
||||
}
|
||||
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreEnterWindow.SetDisable))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetDisable(ExploreEnterWindow __instance)
|
||||
{
|
||||
if (__instance.disabled)
|
||||
{
|
||||
__instance.nameText.text = StringStore.TranslateText("敬请期待");
|
||||
}
|
||||
|
||||
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
[HarmonyPostfix]
|
||||
public static void UpdateHealthText(TrainingDummy __instance)
|
||||
{
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthText);
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthTextShadow);
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthText, null);
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthTextShadow, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
{
|
||||
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
|
||||
{
|
||||
{ "最后一击:(\\d+)\nDPS:(.+)$", "Last damage: {0}\nDPS: {1}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||
{ "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
|
||||
};
|
||||
|
||||
|
|
@ -59,12 +59,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
}
|
||||
|
||||
public static void TranslateHpUI(TextMeshPro textTMP)
|
||||
public static void TranslateHpUI(TextMeshPro textTMP, Zombie __instance = null)
|
||||
{
|
||||
if (textTMP)
|
||||
{
|
||||
string origText = textTMP.text;
|
||||
string translatedText = TranslateHPText(origText);
|
||||
string translatedText = __instance == null ? TranslateHPText(origText) : TranslateHPText(origText, __instance);
|
||||
textTMP.text = translatedText == origText ? origText : translatedText;
|
||||
textTMP.autoSizeTextContainer = false;
|
||||
if (translatedText != origText)
|
||||
|
|
@ -97,5 +97,45 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
}
|
||||
return originalText;
|
||||
}
|
||||
|
||||
public static string TranslateHPText(string originalText, Zombie __instance)
|
||||
{
|
||||
string finalText = __instance.healthText.text;
|
||||
int fIndex = -1;
|
||||
bool found = false;
|
||||
|
||||
for (int i = 0; i < HPStrings.Count; i++)
|
||||
{
|
||||
var hp = HPStrings.ElementAt(i);
|
||||
Regex regex = new Regex(hp.Key);
|
||||
if (regex.IsMatch(originalText))
|
||||
{
|
||||
fIndex = i;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fIndex > -1 && found)
|
||||
{
|
||||
string fStr = HPStrings.ElementAt(fIndex).Value;
|
||||
|
||||
switch (fIndex)
|
||||
{
|
||||
case 1:
|
||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth);
|
||||
break;
|
||||
case 2:
|
||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth);
|
||||
break;
|
||||
case 3:
|
||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return finalText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,13 +23,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
{
|
||||
if(txt.name.Contains("Introduce"))
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
|
||||
string text = txt.text;
|
||||
string[] lines = text.Split("\n");
|
||||
|
||||
lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
string updatedText = String.Join("\n", lines);
|
||||
|
||||
txt.text = StringStore.TranslateText(updatedText);
|
||||
txt.text = updatedText;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
36
BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
36
BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(SeedLibrary))]
|
||||
public static class SeedLibrary_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode))]
|
||||
[HarmonyPostfix]
|
||||
private static void ChangeSafeMode(SeedLibrary __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
|
||||
Transform safetyBoxButtonTransform = __instance.transform.Find("SafeBox").Find("StartSafeMode");
|
||||
|
||||
if (__instance.safeMode == false && safetyBoxButtonTransform != null)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in safetyBoxButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -9,25 +9,37 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
[HarmonyPatch(typeof(TravelLookMenu))]
|
||||
public static class TravelLookMenu_Patch
|
||||
{
|
||||
public static string savedAssetString = "";
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookMenu.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Postfix_Start(TravelLookMenu __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
Transform quitButtonTransform = __instance.transform.Find("Quit");
|
||||
if (quitButtonTransform != null)
|
||||
foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
TextMeshProUGUI[] allTexts = quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>(true);
|
||||
|
||||
foreach (var textComp in allTexts)
|
||||
{
|
||||
if (textComp != null && textComp.text == StringStore.TranslateText("关闭"))
|
||||
{
|
||||
textComp.text = StringStore.TranslateText("关闭_close");
|
||||
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
textComp.font = fontAsset;
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||
savedAssetString = __instance.treasureText.text;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookMenu.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(TravelLookMenu __instance)
|
||||
{
|
||||
if (savedAssetString != __instance.treasureText.text)
|
||||
{
|
||||
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||
savedAssetString = __instance.treasureText.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs
Normal file
30
BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureEvacuateMenu))]
|
||||
public static class TreasureEvacuateMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureEvacuateMenu.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(TreasureEvacuateMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = fontAsset;
|
||||
if (txt.name.Contains("text (1)"))
|
||||
{
|
||||
txt.name = txt.name + "_EVACUATE";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -3,6 +3,7 @@ using TMPro;
|
|||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
|
|
@ -46,6 +47,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
|
||||
foreach (Text txt in __instance.GetComponentsInChildren<Text>())
|
||||
{
|
||||
GameObject newTxtObj = Utils.ConvertToTextMeshProUGUI(txt.gameObject, txt.transform.parent, "text");
|
||||
TextMeshProUGUI newTxt = newTxtObj.GetComponent<TextMeshProUGUI>();
|
||||
newTxt.text = StringStore.TranslateText("植物商店");
|
||||
newTxt.autoSizeTextContainer = true;
|
||||
newTxt.color = new Color(0, 0, 0.3922f, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
Log.LogWarning($"Introduce text: {component?.text}");
|
||||
Log.LogWarning($"Plant name: {component2?.text}");
|
||||
#endif
|
||||
component.text = component.text ?? string.Empty;
|
||||
//component.text = component.text ?? string.Empty;
|
||||
|
||||
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,27 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
__instance.transform.GetChild(6).GetChild(0).GetComponent<TextMeshProUGUI>()};
|
||||
TextMeshProUGUI[] array2 = array;
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||
|
||||
if (array2[i].text.Contains("配方:"))
|
||||
{
|
||||
string[] lines = array2[i].text.Split(":");
|
||||
lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]);
|
||||
if (lines[1] == "")
|
||||
{
|
||||
Log.LogInfo("Couldn't find plant! (Fusion Showcase)");
|
||||
lines[1] = StringStore.TranslateText(lines[1]);
|
||||
}
|
||||
array2[i].text = StringStore.TranslateText("配方:") + lines[1];
|
||||
array2[i].autoSizeTextContainer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
array2[i] = StringStore.TranslateText(array2[i]);
|
||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(InGameUI.Update))]
|
||||
|
|
|
|||
31
BepInEx/Patches/Managers/TreasureManager_Patch.cs
Normal file
31
BepInEx/Patches/Managers/TreasureManager_Patch.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureManager))]
|
||||
public static class TreasureManager_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureManager.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(TreasureManager __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.evaText)
|
||||
{
|
||||
txt.autoSizeTextContainer = false;
|
||||
|
||||
if (txt.text != "Evacuate")
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.name = txt.text + "_EVACUATE";
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,6 +107,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="AssetStore\AudioStore.cs" />
|
||||
<Compile Include="AssetStore\CheckSumStore.cs" />
|
||||
<Compile Include="AssetStore\FontStore.cs" />
|
||||
<Compile Include="AssetStore\StringStore.cs" />
|
||||
|
|
@ -117,105 +118,107 @@
|
|||
<Compile Include="FontHandler.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="ModFeatures.cs" />
|
||||
<Compile Include="AssetStore\AudioStore.cs" />
|
||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UIProgress2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CrisisZombieWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueStartMenu_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TrainingDummy_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UltimateChomper_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\BaseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\CustomLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptLanguageBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PauseMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PVPPotBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\SaveMenuBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CrisisZombieWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MainMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\AbyssGoods_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\DY_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\LanternUmbrella_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\MagnetBox_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\MagnetInterface_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Money_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Plant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\PlayerName_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\SelectYourPlants_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TrainingDummy_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UltimateChomper_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\NoticePauseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueStartMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\SeedLibrary_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TowerOption_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TowerUpgradeMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuffMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\GameAPP_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\GardenUI_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\NoticePauseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\InGameUI_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptLanguageBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PauseMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PVPPotBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\SelectYourPlants_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelRefresh_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelStore_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Plant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\PlayerName_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureConfirmMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureEquipmentMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureEvacuateMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureMainMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureUpgradeMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\GameAPP_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\InGameUI_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\GardenUI_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,57 @@ using UnityEngine;
|
|||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.UI;
|
||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_
|
||||
{
|
||||
public class Utils
|
||||
{
|
||||
public static Dictionary<int, KeyValuePair<int, string>> plantIndices = new Dictionary<int, KeyValuePair<int, string>>();
|
||||
|
||||
public static void RegisterPlantIndices()
|
||||
{
|
||||
plantIndices = new Dictionary<int, KeyValuePair<int, string>>();
|
||||
string originalJson;
|
||||
string translatedJson;
|
||||
|
||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||
string dumpDir = GetAssetDir(AssetType.Dumps);
|
||||
string originalPath = Path.Combine(dumpDir, "LawnStrings.json");
|
||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||
|
||||
if ((!File.Exists(path)) || (!File.Exists(originalPath)))
|
||||
{
|
||||
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||
}
|
||||
else
|
||||
{
|
||||
originalJson = File.ReadAllText(originalPath);
|
||||
translatedJson = File.ReadAllText(path);
|
||||
AlmanacPlantBank.PlantData originalPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(originalJson);
|
||||
AlmanacPlantBank.PlantData translatedPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(translatedJson);
|
||||
|
||||
for (int i = 0; i < originalPlantData.plants.Count; i++)
|
||||
{
|
||||
var originalPlantInfo = originalPlantData.plants[i];
|
||||
AlmanacPlantBank.PlantInfo translatedPlantInfo = null;
|
||||
|
||||
foreach (var info in translatedPlantData.plants)
|
||||
{
|
||||
if (info.seedType == originalPlantInfo.seedType)
|
||||
{
|
||||
translatedPlantInfo = info;
|
||||
}
|
||||
}
|
||||
|
||||
if (translatedPlantInfo != null)
|
||||
{
|
||||
var temp = new KeyValuePair<int, string>(translatedPlantInfo.seedType, translatedPlantInfo.name);
|
||||
plantIndices.Add(originalPlantInfo.seedType, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
internal static bool TryReplaceTexture2D(Texture2D ogTexture)
|
||||
{
|
||||
if (ogTexture != null)
|
||||
|
|
@ -198,6 +244,53 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
return thePlantName;
|
||||
}
|
||||
|
||||
public static string GetPlantNameFromAlmanac(string theOriginalPlantName)
|
||||
{
|
||||
string originalJson;
|
||||
string translatedJson;
|
||||
string thePlantName = "";
|
||||
|
||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||
string dumpDir = GetAssetDir(AssetType.Dumps);
|
||||
string originalPath = Path.Combine(dumpDir, "LawnStrings.json");
|
||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||
|
||||
if ((!File.Exists(path)) || (!File.Exists(originalPath)))
|
||||
{
|
||||
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||
thePlantName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
bool foundPlantName = false;
|
||||
|
||||
originalJson = File.ReadAllText(originalPath);
|
||||
translatedJson = File.ReadAllText(path);
|
||||
AlmanacPlantBank.PlantData originalPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(originalJson);
|
||||
AlmanacPlantBank.PlantData translatedPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(translatedJson);
|
||||
|
||||
for (int i = 0; i < originalPlantData.plants.Count; i++)
|
||||
{
|
||||
var originalPlantInfo = originalPlantData.plants[i];
|
||||
KeyValuePair<int, string> translatedPlantInfo = plantIndices[originalPlantInfo.seedType];
|
||||
|
||||
if (originalPlantInfo.name == theOriginalPlantName)
|
||||
{
|
||||
thePlantName = translatedPlantInfo.Value;
|
||||
foundPlantName = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundPlantName)
|
||||
{
|
||||
Log.LogInfo("Couldn't find plant name!");
|
||||
thePlantName = "";
|
||||
}
|
||||
}
|
||||
|
||||
return thePlantName;
|
||||
}
|
||||
|
||||
#if MULTI_LANGUAGE
|
||||
internal static void ChangeLanguage(string language)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue