a BUNCH of odyssey/investment translation
This commit is contained in:
parent
be09cbf7e5
commit
4f532e7b49
15 changed files with 647 additions and 333 deletions
|
|
@ -1,10 +1,14 @@
|
||||||
using Il2CppTMPro;
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using MelonLoader.Utils;
|
using MelonLoader.Utils;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using PvZ_Fusion_Translator.Patches.Managers;
|
using PvZ_Fusion_Translator.Patches.Managers;
|
||||||
|
using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Il2Cpp;
|
using static PvZ_Fusion_Translator.FileLoader;
|
||||||
|
|
||||||
[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun / cassidy / Teyliu", null)]
|
[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun / cassidy / Teyliu", null)]
|
||||||
[assembly: MelonGame("LanPiaoPiao", "PlantsVsZombiesRH")]
|
[assembly: MelonGame("LanPiaoPiao", "PlantsVsZombiesRH")]
|
||||||
|
|
@ -42,6 +46,7 @@ namespace PvZ_Fusion_Translator
|
||||||
{
|
{
|
||||||
dtStart = DateTime.Now;
|
dtStart = DateTime.Now;
|
||||||
replaceTextureRoutine = MelonCoroutines.Start(TextureStore.ReplaceTexturesCoroutine());
|
replaceTextureRoutine = MelonCoroutines.Start(TextureStore.ReplaceTexturesCoroutine());
|
||||||
|
TravelMgr_Patch.DumpTravelBuffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnDeinitializeMelon()
|
public override void OnDeinitializeMelon()
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects;
|
using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects;
|
||||||
|
using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
||||||
using PvZ_Fusion_Translator.Patches.OtherManagers;
|
using PvZ_Fusion_Translator.Patches.OtherManagers;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator
|
namespace PvZ_Fusion_Translator
|
||||||
{
|
{
|
||||||
|
|
@ -81,6 +81,10 @@ namespace PvZ_Fusion_Translator
|
||||||
}
|
}
|
||||||
Zombie_Patch.LoadHPStrings();
|
Zombie_Patch.LoadHPStrings();
|
||||||
}
|
}
|
||||||
|
else if(fileName.EndsWith("travel_buffs"))
|
||||||
|
{
|
||||||
|
TravelMgr_Patch.translatedTravelBuffs = JsonSerializer.Deserialize<Dictionary<string, SortedDictionary<int, string>>>(jsonString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SaveStrings();
|
SaveStrings();
|
||||||
DumpJson();
|
DumpJson();
|
||||||
|
|
@ -318,6 +322,68 @@ namespace PvZ_Fusion_Translator
|
||||||
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
|
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
|
||||||
File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData);
|
File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData);
|
||||||
|
|
||||||
|
// dump iz tips
|
||||||
|
var izLevelData = Resources.LoadAll<TextAsset>("izleveldata");
|
||||||
|
Dictionary<string, string> izLevelDataDump = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
string izTranslatedPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_iz.json");
|
||||||
|
if (!File.Exists(izTranslatedPath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(izTranslatedPath, JsonSerializer.Serialize(izLevelDataDump));
|
||||||
|
}
|
||||||
|
var izTranslatedTips = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(izTranslatedPath));
|
||||||
|
|
||||||
|
foreach (var level in izLevelData)
|
||||||
|
{
|
||||||
|
string data = level.text;
|
||||||
|
LevelData levelData = JsonUtility.FromJson<LevelData>(data);
|
||||||
|
if(levelData.tips != null)
|
||||||
|
{
|
||||||
|
izLevelDataDump.Add(level.name, levelData.tips);
|
||||||
|
if(izTranslatedTips.ContainsKey(level.name) && !StringStore.translationString.ContainsKey(levelData.tips))
|
||||||
|
{
|
||||||
|
StringStore.translationString.Add(levelData.tips, izTranslatedTips[level.name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(Path.Combine(dumpDir, "tips_iz.json"), JsonSerializer.Serialize(izLevelDataDump, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
|
||||||
|
// dump fusion showcase tips
|
||||||
|
var fusionShowcaseData = Resources.LoadAll<TextAsset>("leveldata/explore");
|
||||||
|
Dictionary<string, string> fusionShowcaseDataDump = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
string fsTranslatedPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_fs.json");
|
||||||
|
if(!File.Exists(fsTranslatedPath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(fsTranslatedPath, JsonSerializer.Serialize(fusionShowcaseDataDump));
|
||||||
|
}
|
||||||
|
var fsTranslatedTips = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(fsTranslatedPath));
|
||||||
|
|
||||||
|
foreach (var level in fusionShowcaseData)
|
||||||
|
{
|
||||||
|
string data = level.text;
|
||||||
|
LevelData levelData = JsonUtility.FromJson<LevelData>(data);
|
||||||
|
if (levelData.tips != null)
|
||||||
|
{
|
||||||
|
fusionShowcaseDataDump.Add(level.name, levelData.tips);
|
||||||
|
if (fsTranslatedTips.ContainsKey(level.name) && !StringStore.translationString.ContainsKey(levelData.tips))
|
||||||
|
{
|
||||||
|
StringStore.translationString.Add(levelData.tips, fsTranslatedTips[level.name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(Path.Combine(dumpDir, "tips_fs.json"), JsonSerializer.Serialize(fusionShowcaseDataDump, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
|
||||||
Dictionary<Achievement, AchievementObject> achievementsList = new Dictionary<Achievement, AchievementObject>();
|
Dictionary<Achievement, AchievementObject> achievementsList = new Dictionary<Achievement, AchievementObject>();
|
||||||
foreach (Il2CppSystem.Collections.Generic.KeyValuePair<Achievement, Il2CppSystem.Tuple<string, string>> entry in AchievementClip.achievementsText)
|
foreach (Il2CppSystem.Collections.Generic.KeyValuePair<Achievement, Il2CppSystem.Tuple<string, string>> entry in AchievementClip.achievementsText)
|
||||||
{
|
{
|
||||||
|
|
@ -362,6 +428,7 @@ namespace PvZ_Fusion_Translator
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
internal static void LoadLanguage()
|
internal static void LoadLanguage()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
||||||
|
|
||||||
//using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
//using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
|
|
@ -20,8 +22,8 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
string travelMatch = "";
|
|
||||||
string originalText = txt.text;
|
string originalText = txt.text;
|
||||||
|
string travelMatch = TravelMgr_Patch.MatchTravelBuff(originalText);
|
||||||
|
|
||||||
if (txt.gameObject.name.Contains("shadow"))
|
if (txt.gameObject.name.Contains("shadow"))
|
||||||
{
|
{
|
||||||
|
|
@ -41,7 +43,7 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Regex.Match(txt.text, @"(<color[^>]*>.*?</color>)", RegexOptions.Singleline).Success)
|
else if((Regex.Match(txt.text, @"(<color[^>]*>.*?</color>)", RegexOptions.Singleline).Success) && !StringStore.translationString.ContainsKey(txt.text))
|
||||||
{
|
{
|
||||||
txt.text = StringStore.TranslateColorText(txt.text, true);
|
txt.text = StringStore.TranslateColorText(txt.text, true);
|
||||||
if (txt.gameObject.name.Contains("main"))
|
if (txt.gameObject.name.Contains("main"))
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
[HarmonyPatch(typeof(DifficultyMgr))]
|
[HarmonyPatch(typeof(DifficultyMgr))]
|
||||||
public static class DifficultyMgr_Patch
|
public static class DifficultyMgr_Patch
|
||||||
{
|
{
|
||||||
//[HarmonyPatch(nameof(DifficultyMgr.Update))]
|
[HarmonyPatch(nameof(DifficultyMgr.Update))]
|
||||||
//[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
//private static void DifficultyMgr_Update(DifficultyMgr __instance)
|
private static void DifficultyMgr_Update(DifficultyMgr __instance)
|
||||||
//{
|
{
|
||||||
// __instance.t = StringStore.TranslateText(__instance.t);
|
__instance.t = StringStore.TranslateText(__instance.t);
|
||||||
// __instance.t.autoSizeTextContainer = false;
|
__instance.t.autoSizeTextContainer = false;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
using PvZ_Fusion_Translator.Patches.Modes.Odyssey;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -11,11 +11,11 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
[HarmonyPatch(typeof(OppositeBuffManager))]
|
[HarmonyPatch(typeof(OppositeBuffManager))]
|
||||||
public static class OppositeBuffManager_Patch
|
public static class OppositeBuffManager_Patch
|
||||||
{
|
{
|
||||||
//public static Dictionary<BuffType, string> buffLinks = TravelMgr_Patch.buffLinks;
|
public static Dictionary<BuffType, string> buffLinks = TravelMgr_Patch.buffLinks;
|
||||||
//public static Dictionary<string, List<string>> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs;
|
public static Dictionary<string, SortedDictionary<int, string>> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs;
|
||||||
//public static string badPattern = @"^但(.*)";
|
public static string badPattern = @"^但(.*)";
|
||||||
//public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}";
|
public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}";
|
||||||
//public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
[HarmonyPatch(nameof(OppositeBuffManager.Awake))]
|
[HarmonyPatch(nameof(OppositeBuffManager.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
|
@ -29,21 +29,21 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
|
|
||||||
public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List<TextMeshProUGUI> textList, BuffType buffType, int buffIndex, bool isBad = false)
|
public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List<TextMeshProUGUI> textList, BuffType buffType, int buffIndex, bool isBad = false)
|
||||||
{
|
{
|
||||||
//string buff = translatedTravelBuffs[buffLinks[buffType]][buffIndex];
|
string buff = translatedTravelBuffs[buffLinks[buffType]][buffIndex];
|
||||||
|
|
||||||
//foreach(var text in textList)
|
foreach (var text in textList)
|
||||||
//{
|
{
|
||||||
// if(isBad)
|
if (isBad)
|
||||||
// {
|
{
|
||||||
// text.text = string.Format(badFormat, buff);
|
text.text = string.Format(badFormat, buff);
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// {
|
{
|
||||||
// text.text = buff;
|
text.text = buff;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// text.font = fontAsset;
|
text.font = fontAsset;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,24 @@
|
||||||
//using HarmonyLib;
|
using HarmonyLib;
|
||||||
//using Il2Cpp;
|
using Il2Cpp;
|
||||||
//using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
//using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
//using UnityEngine;
|
using UnityEngine;
|
||||||
//using MelonLoader;
|
using MelonLoader;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelBuffMenu))]
|
[HarmonyPatch(typeof(TravelBuffMenu))]
|
||||||
// public static class TravelBuffMenu_Patch
|
public static class TravelBuffMenu_Patch
|
||||||
// {
|
{
|
||||||
// [HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))]
|
[HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void RefeshOptions(TravelBuffMenu __instance)
|
public static void RefeshOptions(TravelBuffMenu __instance)
|
||||||
// {
|
{
|
||||||
// foreach(TravelBuffOptionButton button in __instance.options)
|
foreach (TravelBuffOptionButton button in __instance.options)
|
||||||
// {
|
{
|
||||||
// TravelBuffOptionButton_Patch.TranslateOptionButton(button);
|
TravelBuffOptionButton_Patch.TranslateOptionButton(button);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
@ -1,41 +1,41 @@
|
||||||
//using HarmonyLib;
|
using HarmonyLib;
|
||||||
//using Il2Cpp;
|
using Il2Cpp;
|
||||||
//using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
//using MelonLoader;
|
using MelonLoader;
|
||||||
//using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using static MelonLoader.MelonLogger;
|
using static MelonLoader.MelonLogger;
|
||||||
//using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelBuffOptionButton))]
|
[HarmonyPatch(typeof(TravelBuffOptionButton))]
|
||||||
// public static class TravelBuffOptionButton_Patch
|
public static class TravelBuffOptionButton_Patch
|
||||||
// {
|
{
|
||||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void Awake(TravelBuffOptionButton __instance)
|
public static void Awake(TravelBuffOptionButton __instance)
|
||||||
// {
|
{
|
||||||
// TranslateOptionButton(__instance);
|
TranslateOptionButton(__instance);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void OnAnimOver(TravelBuffOptionButton __instance)
|
public static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||||
// {
|
{
|
||||||
// TranslateOptionButton(__instance);
|
TranslateOptionButton(__instance);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// public static void TranslateOptionButton(TravelBuffOptionButton button)
|
public static void TranslateOptionButton(TravelBuffOptionButton button)
|
||||||
// {
|
{
|
||||||
// List<string> buffSet = translatedTravelBuffs[buffLinks[button.buffType]];
|
SortedDictionary<int, string> buffSet = translatedTravelBuffs[buffLinks[button.buffType]];
|
||||||
|
|
||||||
// string buff = button.show != null && button.introduce.text != "词条已选完" ? buffSet[button.buffIndex] : StringStore.TranslateText("词条已选完");
|
string buff = button.show != null && button.introduce.text != "词条已选完" ? buffSet[button.buffIndex] : StringStore.TranslateText("词条已选完");
|
||||||
|
|
||||||
// button.introduce.text = buff;
|
button.introduce.text = buff;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
//List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||||
// //string buff = (__instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText("无");
|
//string buff = (__instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText("无");
|
||||||
// //__instance.introduce.text = buff;
|
//__instance.introduce.text = buff;
|
||||||
//}
|
}
|
||||||
|
|
|
||||||
25
MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs
Normal file
25
MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TravelInvestMenu))]
|
||||||
|
public static class TravelInvestMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TravelInvestMenu.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Start(TravelInvestMenu __instance)
|
||||||
|
{
|
||||||
|
Transform titleText = __instance.transform.Find("Title");
|
||||||
|
TextMeshProUGUI shadowText = titleText.GetComponent<TextMeshProUGUI>();
|
||||||
|
|
||||||
|
TextMeshProUGUI regularText = titleText.transform.Find("Title2").GetComponent<TextMeshProUGUI>();
|
||||||
|
regularText.text = StringStore.TranslateText(regularText.text);
|
||||||
|
|
||||||
|
shadowText.text = Utils.RemoveColorTags(regularText.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,51 +1,51 @@
|
||||||
//using HarmonyLib;
|
using HarmonyLib;
|
||||||
//using Il2Cpp;
|
using Il2Cpp;
|
||||||
//using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
//using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
//using UnityEngine;
|
using UnityEngine;
|
||||||
//using MelonLoader;
|
using MelonLoader;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelLookBuff))]
|
[HarmonyPatch(typeof(TravelLookBuff))]
|
||||||
// public static class TravelLookBuff_Patch
|
public static class TravelLookBuff_Patch
|
||||||
// {
|
{
|
||||||
// [HarmonyPatch(nameof(TravelLookBuff.Clear))]
|
[HarmonyPatch(nameof(TravelLookBuff.Clear))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void Post_Clear(TravelLookBuff __instance)
|
public static void Post_Clear(TravelLookBuff __instance)
|
||||||
// {
|
{
|
||||||
// __instance.introduce.text = StringStore.TranslateText("无");
|
__instance.introduce.text = StringStore.TranslateText("无");
|
||||||
// __instance.set = false;
|
__instance.set = false;
|
||||||
|
|
||||||
// foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// {
|
{
|
||||||
// text.text = StringStore.TranslateText(text.text);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
[HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void Post_OnMouseUpAsButton(TravelLookBuff __instance)
|
public static void Post_OnMouseUpAsButton(TravelLookBuff __instance)
|
||||||
// {
|
{
|
||||||
// foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// {
|
{
|
||||||
// text.text = StringStore.TranslateText(text.text);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
|
[HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// public static void Post_SetBuff(TravelLookBuff __instance)
|
public static void Post_SetBuff(TravelLookBuff __instance)
|
||||||
// {
|
{
|
||||||
// List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
SortedDictionary<int, string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||||
// string buffText = __instance.buffIndex < buffSet.Count ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
string buffText = buffSet.ContainsKey(__instance.buffIndex) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||||
// __instance.introduce.text = buffText;
|
__instance.introduce.text = buffText;
|
||||||
|
|
||||||
// foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// {
|
{
|
||||||
// text.text = StringStore.TranslateText(text.text);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
@ -1,46 +1,46 @@
|
||||||
//using HarmonyLib;
|
using HarmonyLib;
|
||||||
//using Il2Cpp;
|
using Il2Cpp;
|
||||||
//using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
//using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelLookMenu))]
|
[HarmonyPatch(typeof(TravelLookMenu))]
|
||||||
// public static class TravelLookMenu_Patch
|
public static class TravelLookMenu_Patch
|
||||||
// {
|
{
|
||||||
// public static string savedAssetString = "";
|
public static string savedAssetString = "";
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelLookMenu.Start))]
|
[HarmonyPatch(nameof(TravelLookMenu.Start))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// private static void Postfix_Start(TravelLookMenu __instance)
|
private static void Postfix_Start(TravelLookMenu __instance)
|
||||||
// {
|
{
|
||||||
// foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// {
|
{
|
||||||
// txt.text = StringStore.TranslateText(txt.text);
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
// txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Transform quitButtonTransform = __instance.transform.Find("Quit");
|
Transform quitButtonTransform = __instance.transform.Find("Quit");
|
||||||
// foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// {
|
{
|
||||||
// txt.text = StringStore.TranslateText("合上");
|
txt.text = StringStore.TranslateText("合上");
|
||||||
// txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
// }
|
}
|
||||||
|
|
||||||
// __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||||
// savedAssetString = __instance.treasureText.text;
|
savedAssetString = __instance.treasureText.text;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelLookMenu.Update))]
|
[HarmonyPatch(nameof(TravelLookMenu.Update))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// private static void Update(TravelLookMenu __instance)
|
private static void Update(TravelLookMenu __instance)
|
||||||
// {
|
{
|
||||||
// if (savedAssetString != __instance.treasureText.text)
|
if (savedAssetString != __instance.treasureText.text)
|
||||||
// {
|
{
|
||||||
// __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||||
// savedAssetString = __instance.treasureText.text;
|
savedAssetString = __instance.treasureText.text;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
@ -1,102 +1,114 @@
|
||||||
//using Il2Cpp;
|
using HarmonyLib;
|
||||||
//using System;
|
using Il2Cpp;
|
||||||
//using System.Collections.Generic;
|
using System;
|
||||||
//using System.Linq;
|
using System.Collections.Generic;
|
||||||
//using System.Text;
|
using System.Linq;
|
||||||
//using System.Text.Encodings.Web;
|
using System.Text;
|
||||||
//using System.Text.Json;
|
using System.Text.Encodings.Web;
|
||||||
//using System.Threading.Tasks;
|
using System.Text.Json;
|
||||||
//using HarmonyLib;
|
using System.Threading.Tasks;
|
||||||
|
using Unity.Collections;
|
||||||
|
using static PvZ_Fusion_Translator.FileLoader;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelMgr))]
|
[HarmonyPatch(typeof(TravelMgr))]
|
||||||
// public static class TravelMgr_Patch
|
public static class TravelMgr_Patch
|
||||||
// {
|
{
|
||||||
// public static Dictionary<BuffType, string> buffLinks = new Dictionary<BuffType, string>()
|
public static Dictionary<string, SortedDictionary<int, string>> dumpedTravelBuffs = new()
|
||||||
// {
|
{
|
||||||
// { BuffType.AdvancedBuff, "advancedUpgrades" },
|
{ "advancedBuffs", new SortedDictionary<int, string>() },
|
||||||
// { BuffType.UltimateBuff, "ultimateUpgrades" },
|
{ "ultimateBuffs", new SortedDictionary<int, string>() },
|
||||||
// { BuffType.UnlockPlant, "strongUltimates" },
|
{ "debuffs", new SortedDictionary<int, string>() },
|
||||||
// { BuffType.Debuff, "debuffs" },
|
{ "unlocks", new SortedDictionary<int, string>() },
|
||||||
// };
|
{ "investmentBuffs", new SortedDictionary<int, string>() }
|
||||||
|
};
|
||||||
|
|
||||||
// public static Dictionary<string, List<string>> dumpedTravelBuffs = new Dictionary<string, List<string>>()
|
public static Dictionary<string, SortedDictionary<int, string>> translatedTravelBuffs = new()
|
||||||
// {
|
{
|
||||||
// { "advancedUpgrades", [] },
|
{ "advancedBuffs", new SortedDictionary<int, string>() },
|
||||||
// { "ultimateUpgrades", [] },
|
{ "ultimateBuffs", new SortedDictionary<int, string>() },
|
||||||
// { "strongUltimates", [] },
|
{ "debuffs", new SortedDictionary<int, string>() },
|
||||||
// { "debuffs", [] }
|
{ "unlocks", new SortedDictionary<int, string>() },
|
||||||
// };
|
{ "investmentBuffs", new SortedDictionary<int, string>() }
|
||||||
|
};
|
||||||
|
|
||||||
// public static Dictionary<string, List<string>> translatedTravelBuffs = new Dictionary<string, List<string>>();
|
public static Dictionary<BuffType, string> buffLinks = new()
|
||||||
|
{
|
||||||
|
{ BuffType.AdvancedBuff, "advancedBuffs" },
|
||||||
|
{ BuffType.UltimateBuff, "ultimateBuffs" },
|
||||||
|
{ BuffType.Debuff, "debuffs" },
|
||||||
|
{ BuffType.UnlockPlant, "unlocks" },
|
||||||
|
{ BuffType.InvestmentBuff, "investmentBuffs" }
|
||||||
|
};
|
||||||
|
|
||||||
// public static void DumpTravelBuffs(Il2CppSystem.Collections.Generic.Dictionary<int, string> source, Dictionary<string, List<string>> dest, string index)
|
public static void DumpTravelBuffs()
|
||||||
// {
|
{
|
||||||
// foreach (var i in source)
|
TravelMgr.Instance.GetPlantBuffUnlockCount(PlantType.DoomGatling);
|
||||||
// {
|
|
||||||
// if (!Utils.CheckForUntranslatedText(i.Value))
|
|
||||||
// {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// dest[index].Add(i.Value);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public static string MatchTravelBuff(string originalText)
|
foreach (var pair in TravelDictionary.advancedBuffsText)
|
||||||
// {
|
{
|
||||||
// string res = "";
|
dumpedTravelBuffs["advancedBuffs"].Add((int)pair.Key, pair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
// foreach(var i in dumpedTravelBuffs)
|
foreach (var pair in TravelDictionary.ultimateBuffsText)
|
||||||
// {
|
{
|
||||||
// if(i.Value.Contains(originalText))
|
dumpedTravelBuffs["ultimateBuffs"].Add((int)pair.Key, pair.Value);
|
||||||
// {
|
}
|
||||||
// res = translatedTravelBuffs[i.Key][i.Value.IndexOf(originalText)];
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return res;
|
foreach (var pair in TravelDictionary.debuffData)
|
||||||
// }
|
{
|
||||||
|
dumpedTravelBuffs["debuffs"].Add((int)pair.Key, pair.Value.Item1);
|
||||||
|
}
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelMgr.Awake))]
|
foreach (var pair in TravelDictionary.unlocksText)
|
||||||
// [HarmonyPrefix]
|
{
|
||||||
// private static void Pre_Awake(TravelMgr __instance)
|
dumpedTravelBuffs["unlocks"].Add((int)pair.Key, pair.Value);
|
||||||
// {
|
}
|
||||||
// // Dump buffs
|
|
||||||
|
|
||||||
// dumpedTravelBuffs = new Dictionary<string, List<string>>() // reset dump
|
foreach (var pair in TravelMgr.InvestBuffsData)
|
||||||
// {
|
{
|
||||||
// { "advancedUpgrades", [] },
|
dumpedTravelBuffs["investmentBuffs"].Add((int)pair.Key, pair.Value.GetDescription());
|
||||||
// { "ultimateUpgrades", [] },
|
}
|
||||||
// { "strongUltimates", [] },
|
|
||||||
// { "debuffs", [] }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// DumpTravelBuffs(TravelMgr.advancedBuffs, dumpedTravelBuffs, "advancedUpgrades");
|
File.WriteAllText(Path.Combine(GetAssetDir(AssetType.Dumps), "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, new JsonSerializerOptions
|
||||||
// DumpTravelBuffs(TravelMgr.ultimateBuffs, dumpedTravelBuffs, "ultimateUpgrades");
|
{
|
||||||
// DumpTravelBuffs(TravelMgr.unlocks, dumpedTravelBuffs, "strongUltimates");
|
WriteIndented = true,
|
||||||
// DumpTravelBuffs(TravelMgr.debuffs, dumpedTravelBuffs, "debuffs");
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
|
||||||
// string dumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps);
|
string translatedTravelBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "travel_buffs.json");
|
||||||
// var options = new JsonSerializerOptions
|
|
||||||
// {
|
|
||||||
// Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
|
||||||
// WriteIndented = true
|
|
||||||
// };
|
|
||||||
// File.WriteAllText(Path.Combine(dumpDir, "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, options));
|
|
||||||
|
|
||||||
// string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
|
if (!File.Exists(translatedTravelBuffsPath))
|
||||||
// string travelBuffDir = Path.Combine(stringDir, "travel_buffs.json");
|
{
|
||||||
|
File.WriteAllText(translatedTravelBuffsPath, JsonSerializer.Serialize(dumpedTravelBuffs, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
translatedTravelBuffs = dumpedTravelBuffs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if(!File.Exists(travelBuffDir))
|
public static string MatchTravelBuff(string originalText)
|
||||||
// {
|
{
|
||||||
// File.WriteAllText(travelBuffDir, JsonSerializer.Serialize(dumpedTravelBuffs, options));
|
string res = "";
|
||||||
// }
|
|
||||||
|
|
||||||
// string travelBuffs = File.ReadAllText(Path.Combine(stringDir, "travel_buffs.json"));
|
foreach (var i in translatedTravelBuffs)
|
||||||
|
{
|
||||||
|
foreach (var j in translatedTravelBuffs[i.Key])
|
||||||
|
{
|
||||||
|
if (j.Value == originalText)
|
||||||
|
{
|
||||||
|
res = j.Value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// translatedTravelBuffs = JsonSerializer.Deserialize<Dictionary<string, List<string>>>(travelBuffs);
|
if (res != "") break;
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//}
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
97
MelonLoader/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs
Normal file
97
MelonLoader/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TravelStoreWindow))]
|
||||||
|
public static class TravelStoreWindow_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TravelStoreWindow.SetType))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetType(TravelStoreWindow __instance)
|
||||||
|
{
|
||||||
|
var buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||||
|
|
||||||
|
string buff = __instance.show != null && __instance.introduce.text != "词条已选完" ? buffSet[__instance.buffIndex] : StringStore.TranslateText("词条已选完");
|
||||||
|
string originalText = __instance.introduce.text;
|
||||||
|
|
||||||
|
string affinities = TranslateAffinities(originalText);
|
||||||
|
|
||||||
|
__instance.introduce.text = buff + affinities;
|
||||||
|
|
||||||
|
foreach (var text in __instance.buttonText)
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TravelStoreWindow.UpdateButtonText))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void UpdateButtonText(TravelStoreWindow __instance)
|
||||||
|
{
|
||||||
|
foreach (var text in __instance.buttonText)
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslateAffinities(string originalText)
|
||||||
|
{
|
||||||
|
string discolored = Utils.RemoveColorTags(originalText);
|
||||||
|
int firstNewlineIndex = discolored.IndexOf('\n');
|
||||||
|
|
||||||
|
string result = "";
|
||||||
|
List<string> translatedAffinities = [];
|
||||||
|
|
||||||
|
if(firstNewlineIndex >= 0)
|
||||||
|
{
|
||||||
|
string affinityString = discolored.Substring(firstNewlineIndex);
|
||||||
|
string[] affinities = affinityString.Split('\n');
|
||||||
|
|
||||||
|
string fStr = StringStore.translationStringRegex.ContainsKey("【([^\\s]+)】_IV") ? StringStore.translationStringRegex["【([^\\s]+)】_IV"] : "[{0}]";
|
||||||
|
string originalPattern = "【([^\\s]+)】";
|
||||||
|
|
||||||
|
foreach (string affinity in affinities)
|
||||||
|
{
|
||||||
|
if(affinity != "")
|
||||||
|
{
|
||||||
|
string translatedAffinity = affinity;
|
||||||
|
if (StringStore.TestRegex(affinity, originalPattern))
|
||||||
|
{
|
||||||
|
// Extract dynamic parts from the original text
|
||||||
|
var regex = new Regex(originalPattern);
|
||||||
|
var match = regex.Match(affinity);
|
||||||
|
int groupCount = match.Groups.Count;
|
||||||
|
|
||||||
|
// List to hold formatted dynamic parts
|
||||||
|
List<string> dynamicParts = [];
|
||||||
|
|
||||||
|
// Loop through each group and determine its translation
|
||||||
|
for (int i = 1; i < groupCount; i++)
|
||||||
|
{
|
||||||
|
string groupValue = match.Groups[i].Value;
|
||||||
|
string translatedValue = StringStore.translationString.ContainsKey(groupValue)
|
||||||
|
? StringStore.translationString[groupValue]
|
||||||
|
: groupValue;
|
||||||
|
dynamicParts.Add(translatedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the output string with dynamic parts
|
||||||
|
translatedAffinity = string.Format(fStr, [.. dynamicParts]);
|
||||||
|
}
|
||||||
|
|
||||||
|
translatedAffinities.Add(translatedAffinity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = "\n" + "<color=red>" + String.Join("\n", translatedAffinities) + "</color>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,70 +1,63 @@
|
||||||
//using HarmonyLib;
|
using HarmonyLib;
|
||||||
//using Il2Cpp;
|
using Il2Cpp;
|
||||||
//using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
//using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
//using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
//using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
//{
|
{
|
||||||
// [HarmonyPatch(typeof(TravelStore))]
|
[HarmonyPatch(typeof(TravelStore))]
|
||||||
// public static class TravelStore_Patch
|
public static class TravelStore_Patch
|
||||||
// {
|
{
|
||||||
// [HarmonyPatch(nameof(TravelStore.Update))]
|
[HarmonyPatch(nameof(TravelStore.Update))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// private static void Update(TravelStore __instance)
|
private static void Update(TravelStore __instance)
|
||||||
// {
|
{
|
||||||
// foreach(TextMeshProUGUI text in __instance.introduces)
|
TranslateStoreText(__instance);
|
||||||
// {
|
}
|
||||||
// if(__instance.currentSelect != null)
|
|
||||||
// {
|
|
||||||
// var buffList = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]];
|
|
||||||
// if(__instance.currentSelect.theBuffNumber < buffList.Count && __instance.currentSelect.theBuffNumber > -1)
|
|
||||||
// {
|
|
||||||
// text.text = buffList[__instance.currentSelect.theBuffNumber];
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// text.text = StringStore.TranslateText(text.text);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// foreach (var textMesh in __instance.points)
|
|
||||||
// {
|
|
||||||
// textMesh.text = StringStore.TranslateText(textMesh.text);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [HarmonyPatch(nameof(TravelStore.RefreshBuff))]
|
[HarmonyPatch(nameof(TravelStore.RefreshBuff))]
|
||||||
// [HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
// private static void RefreshBuff(TravelStore __instance)
|
private static void RefreshBuff(TravelStore __instance)
|
||||||
// {
|
{
|
||||||
// foreach (TravelBuff buff in __instance.travelBuffs)
|
TranslateStoreText(__instance);
|
||||||
// {
|
}
|
||||||
// TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
|
||||||
// cost.text = StringStore.TranslateText(cost.text);
|
|
||||||
// cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (TextMeshProUGUI text in __instance.introduces)
|
public static void TranslateStoreText(TravelStore __instance)
|
||||||
// {
|
{
|
||||||
// if (__instance.currentSelect != null)
|
__instance.investText.text = TranslateInvestText(__instance.investText.text);
|
||||||
// {
|
__instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text);
|
||||||
// var buffList = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]];
|
|
||||||
// if (__instance.currentSelect.theBuffNumber < buffList.Count && __instance.currentSelect.theBuffNumber > -1)
|
foreach (var text in __instance.pointText)
|
||||||
// {
|
{
|
||||||
// text.text = buffList[__instance.currentSelect.theBuffNumber];
|
text.text = StringStore.TranslateText(text.text);
|
||||||
// }
|
}
|
||||||
// else
|
foreach (var text in __instance.refreshText)
|
||||||
// {
|
{
|
||||||
// text.text = StringStore.TranslateText(text.text);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
// }
|
}
|
||||||
// }
|
foreach(var text in __instance.transform.Find("Quit").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
// }
|
{
|
||||||
// foreach (var textMesh in __instance.points)
|
text.text = StringStore.TranslateText("合上");
|
||||||
// {
|
}
|
||||||
// textMesh.text = StringStore.TranslateText(textMesh.text);
|
}
|
||||||
// }
|
|
||||||
// }
|
public static string TranslateInvestText(string investText)
|
||||||
// }
|
{
|
||||||
//}
|
string res = investText;
|
||||||
|
|
||||||
|
string[] investStats = investText.Split("\n\n");
|
||||||
|
List<string> translatedInvestStats = new List<string>();
|
||||||
|
foreach(string investStat in investStats)
|
||||||
|
{
|
||||||
|
string translatedInvestStat = StringStore.TranslateText(investStat);
|
||||||
|
translatedInvestStats.Add(translatedInvestStat);
|
||||||
|
}
|
||||||
|
|
||||||
|
res = String.Join("\n\n", translatedInvestStats);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
110
MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs
Normal file
110
MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TravelSynergyMenu))]
|
||||||
|
public static class TravelSynergyMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TravelSynergyMenu.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void Awake(TravelSynergyMenu __instance)
|
||||||
|
{
|
||||||
|
Transform background = __instance.transform.Find("Background");
|
||||||
|
Transform tip = __instance.transform.Find("Text (TMP)");
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI text in background.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI text in tip.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(SynergyNode))]
|
||||||
|
public static class SynergyNode_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(SynergyNode.InitNode))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void InitNode(SynergyNode __instance)
|
||||||
|
{
|
||||||
|
int firstNewlineIndex = __instance.synergyTitle.text.IndexOf("\n");
|
||||||
|
string title = __instance.synergyTitle.text.Substring(0, firstNewlineIndex);
|
||||||
|
string description = __instance.synergyTitle.text.Substring(firstNewlineIndex + 1);
|
||||||
|
description = (description.Substring(0, 8) == "</color>") ? description.Substring(8) : description;
|
||||||
|
|
||||||
|
string pattern = @"<color=[^>]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+";
|
||||||
|
string smallPattern = @"(<color=[^>]+>)(.*?)(</color>)";
|
||||||
|
MatchCollection matches = Regex.Matches(description, pattern);
|
||||||
|
string translatedDescription = "";
|
||||||
|
foreach(Match match in matches)
|
||||||
|
{
|
||||||
|
Match colorMatch = Regex.Match(match.Value, smallPattern, RegexOptions.Singleline);
|
||||||
|
if (colorMatch.Success)
|
||||||
|
{
|
||||||
|
translatedDescription += colorMatch.Groups[1].Value + TranslateSegment(colorMatch.Groups[2].Value) + colorMatch.Groups[3].Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FileLoader.DumpUntranslatedStrings(match.Value);
|
||||||
|
translatedDescription += TranslateSegment(match.Value) + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.synergyTitle.text = "<size=95%>" + StringStore.TranslateColorText(title) + "\n" + translatedDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslateSegment(string text)
|
||||||
|
{
|
||||||
|
string res = "";
|
||||||
|
|
||||||
|
List<string> parts = SplitSecondNewLines(text);
|
||||||
|
|
||||||
|
foreach(string part in parts)
|
||||||
|
{
|
||||||
|
string temp = "";
|
||||||
|
string[] lines = part.Split('\n');
|
||||||
|
if(lines.Length > 1)
|
||||||
|
{
|
||||||
|
FileLoader.DumpUntranslatedStrings(lines[0]);
|
||||||
|
FileLoader.DumpUntranslatedStrings(lines[1]);
|
||||||
|
temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]);
|
||||||
|
}
|
||||||
|
res += temp + "\n";
|
||||||
|
}
|
||||||
|
return res.Substring(0, res.Length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<string> SplitSecondNewLines(string originalText)
|
||||||
|
{
|
||||||
|
List<string> results = new List<string>();
|
||||||
|
|
||||||
|
string[] lines = originalText.Split('\n');
|
||||||
|
for (int i = 0; i < lines.Length; i += 2)
|
||||||
|
{
|
||||||
|
string res = "";
|
||||||
|
if(i + 1 < lines.Length)
|
||||||
|
{
|
||||||
|
res = lines[i] + "\n" + lines[i + 1];
|
||||||
|
results.Add(res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = lines[i];
|
||||||
|
results.Add(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -401,6 +401,9 @@
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
<Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" />
|
<Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Modes\Odyssey\TravelInvestMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Modes\Odyssey\TravelStoreWindow_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Modes\Odyssey\TravelSynergyMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Modes\Starbound\AdvantureEvolutionMenu_Patch.cs" />
|
<Compile Include="Patches\Modes\Starbound\AdvantureEvolutionMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Modes\Starbound\AdvantureStarMenu_Patch.cs" />
|
<Compile Include="Patches\Modes\Starbound\AdvantureStarMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Modes\Starbound\AdvantureMissionMenu_Patch.cs" />
|
<Compile Include="Patches\Modes\Starbound\AdvantureMissionMenu_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue