abyss fixes + misc fixes before fusion showcase editor
This commit is contained in:
parent
ba7c713a37
commit
cf90e910db
14 changed files with 405 additions and 55 deletions
|
|
@ -122,7 +122,43 @@ namespace PvZ_Fusion_Translator.AssetStore
|
|||
checkText = text;
|
||||
|
||||
return checkText;
|
||||
}
|
||||
|
||||
public static string TranslateText(string originalText, string pattern, bool isLog = false)
|
||||
{
|
||||
if (TestRegex(originalText, pattern) && translationStringRegex.ContainsKey(pattern))
|
||||
{
|
||||
// Extract dynamic parts from the original text
|
||||
var regex = new Regex(pattern);
|
||||
var match = regex.Match(originalText);
|
||||
int groupCount = match.Groups.Count;
|
||||
|
||||
if (isLog)
|
||||
Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount);
|
||||
|
||||
// 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 = translationString.ContainsKey(groupValue)
|
||||
? translationString[groupValue]
|
||||
: groupValue;
|
||||
dynamicParts.Add(translatedValue);
|
||||
}
|
||||
|
||||
// Format the output string with dynamic parts
|
||||
return string.Format(translationStringRegex[pattern], [.. dynamicParts]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isLog)
|
||||
Log.LogDebug($"Text '{originalText}' not translated");
|
||||
FileLoader.DumpUntranslatedStrings(originalText);
|
||||
return originalText;
|
||||
}
|
||||
}
|
||||
|
||||
public static string DoTranslateText(string originalText, bool isLog = false)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
using Il2Cpp;
|
||||
using Il2CppTMPro;
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using PvZ_Fusion_Translator.Patches.Managers;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||
{
|
||||
|
|
@ -25,7 +26,16 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
|||
|
||||
foreach (TextMeshProUGUI txt in __instance.textMeshes)
|
||||
{
|
||||
string travelMatch = TravelMgr_Patch.MatchTravelBuff(txt.text);
|
||||
|
||||
if(travelMatch != "")
|
||||
{
|
||||
txt.text = travelMatch;
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text, true);
|
||||
}
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
104
MelonLoader/Patches/GameObjects/AbyssBuffMenu_Patch.cs
Normal file
104
MelonLoader/Patches/GameObjects/AbyssBuffMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
using HarmonyLib;
|
||||
using Il2Cpp;
|
||||
using Il2CppTMPro;
|
||||
using MelonLoader.TinyJSON;
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine.TextCore.Text;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(AbyssBuffMenu))]
|
||||
public static class AbyssBuffMenu_Patch
|
||||
{
|
||||
public static Dictionary<string, string> abyssBuffData = new Dictionary<string, string>();
|
||||
|
||||
[HarmonyPatch(nameof(AbyssBuffMenu.Awake))]
|
||||
[HarmonyPostfix]
|
||||
public static void Post_Awake(AbyssBuffMenu __instance)
|
||||
{
|
||||
LoadAbyssBuffData();
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
text.font = fontAsset;
|
||||
}
|
||||
|
||||
TranslateWindows(__instance, fontAsset);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssBuffMenu.SelectWindow))]
|
||||
[HarmonyPostfix]
|
||||
public static void Post_SelectWindow(AbyssBuffMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
TranslateWindows(__instance, fontAsset);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssBuffMenu.SetFavorite))]
|
||||
[HarmonyPostfix]
|
||||
public static void Post_SetFavorite(AbyssBuffMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
text.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset)
|
||||
{
|
||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if (abyssBuffData.ContainsKey(text.text))
|
||||
{
|
||||
text.text = abyssBuffData[text.text];
|
||||
text.font = fontAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var x in abyssBuffData)
|
||||
{
|
||||
if (x.Key.Contains("{value}"))
|
||||
{
|
||||
string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)");
|
||||
if (Regex.IsMatch(text.text, pattern))
|
||||
{
|
||||
var regex = new Regex(pattern);
|
||||
var match = regex.Match(text.text);
|
||||
|
||||
text.text = String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value);
|
||||
text.font = fontAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach(AbyssBuffWindow window in __instance.GetComponentsInChildren<AbyssBuffWindow>())
|
||||
{
|
||||
window.buffName.autoSizeTextContainer = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LoadAbyssBuffData()
|
||||
{
|
||||
abyssBuffData.Clear();
|
||||
|
||||
string abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"));
|
||||
abyssBuffData = JsonSerializer.Deserialize<Dictionary<string, string>>(abyssBuffText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
|
||||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text, false);
|
||||
txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
|
||||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,11 +27,6 @@ namespace PvZ_Fusion_Translator.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
|
||||
{
|
||||
|
|
@ -68,6 +63,24 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
try
|
||||
{
|
||||
if (__instance.transform.childCount >= 2)
|
||||
{
|
||||
if(__instance.name == "EditMode")
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
TextMeshProUGUI[] extraTexts = __instance.transform.GetChild(1).GetComponentsInChildren<TextMeshProUGUI>();
|
||||
|
||||
text.text = StringStore.TranslateText(text.text, false);
|
||||
text.font = fontAsset;
|
||||
|
||||
foreach(TextMeshProUGUI extraText in extraTexts)
|
||||
{
|
||||
extraText.text = StringStore.TranslateText(extraText.text, false);
|
||||
extraText.font = fontAsset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||
|
|
@ -77,7 +90,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
|
||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
|
|
|||
24
MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs
Normal file
24
MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using Il2Cpp;
|
||||
using Il2CppTMPro;
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(ExploreMakeMenu))]
|
||||
public static class ExploreMakeMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(ExploreMakeMenu.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(ExploreMakeMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,14 +21,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
}
|
||||
|
||||
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
|
||||
foreach(TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if (txt.name.Contains("(TMP)"))
|
||||
{
|
||||
Log.LogDebug(txt.transform.parent.name);
|
||||
txt.autoSizeTextContainer = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreMenu.UpdateWindows))]
|
||||
|
|
|
|||
|
|
@ -6,35 +6,34 @@ using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
|
|||
|
||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||
{
|
||||
//[HarmonyPatch(typeof(TravelBuffOptionButton))]
|
||||
//public static class TravelBuffOptionButton_Patch
|
||||
//{
|
||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void SetBuff(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
[HarmonyPatch(typeof(TravelBuffOptionButton))]
|
||||
public static class TravelBuffOptionButton_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetBuff(TravelBuffOptionButton __instance)
|
||||
{
|
||||
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||
|
||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void Awake(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
}
|
||||
|
||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(TravelBuffOptionButton __instance)
|
||||
{
|
||||
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||
|
||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.SetBackground))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void SetBackground(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
||||
[HarmonyPostfix]
|
||||
private static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||
{
|
||||
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
{
|
||||
__instance.introduce.text = StringStore.TranslateText("无");
|
||||
__instance.set = false;
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
||||
|
|
@ -35,6 +40,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
{
|
||||
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||
__instance.introduce.text = buffText;
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
|
|
|
|||
125
MelonLoader/Patches/Managers/AbyssBuffData_Patch.cs
Normal file
125
MelonLoader/Patches/Managers/AbyssBuffData_Patch.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
//using HarmonyLib;
|
||||
//using Il2Cpp;
|
||||
//using MelonLoader;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Text.Json;
|
||||
//using System.Threading.Tasks;
|
||||
//using Unity.VisualScripting;
|
||||
//using UnityEngine;
|
||||
|
||||
//namespace PvZ_Fusion_Translator.Patches.Managers
|
||||
//{
|
||||
// [HarmonyPatch(typeof(AbyssBuffData))]
|
||||
// public static class AbyssBuffData_Patch
|
||||
// {
|
||||
// [HarmonyPatch(nameof(AbyssBuffData.LoadData))]
|
||||
// [HarmonyPostfix]
|
||||
// public static void Pre_LoadData(AbyssBuffData __instance)
|
||||
// {
|
||||
// string originalAbyssBuffStr = Resources.Load<TextAsset>("AbyssBuffData").text;
|
||||
// Dictionary<string, List<AbyssBuffInfo>> originalAbyssBuffData = JsonSerializer.Deserialize<Dictionary<string, List<AbyssBuffInfo>>>(originalAbyssBuffStr);
|
||||
// List<AbyssBuffInfo> infos = originalAbyssBuffData["infos"];
|
||||
// Il2CppSystem.Collections.Generic.Dictionary<AbyssBuff, Il2CppSystem.ValueTuple<string, string, float>> result = new();
|
||||
|
||||
// string abyssBuffDataDir = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json");
|
||||
// if (!File.Exists(abyssBuffDataDir))
|
||||
// {
|
||||
// File.WriteAllText(abyssBuffDataDir, originalAbyssBuffStr);
|
||||
// }
|
||||
|
||||
// Dictionary<string, string> abyssBuffData = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(abyssBuffDataDir));
|
||||
|
||||
// for (int i = 0; i < infos.Count; i++)
|
||||
// {
|
||||
// AbyssBuffInfo originalTuple = infos[i];
|
||||
// Il2CppSystem.ValueTuple<string, string, float> translatedTuple = new();
|
||||
|
||||
// translatedTuple.Item1 = abyssBuffData.ContainsKey(originalTuple.name) ? abyssBuffData[originalTuple.name] : originalTuple.name;
|
||||
// translatedTuple.Item2 = abyssBuffData.ContainsKey(originalTuple.introduce) ? abyssBuffData[originalTuple.introduce] : originalTuple.introduce;
|
||||
// translatedTuple.Item3 = originalTuple.value;
|
||||
|
||||
// foreach (var x in AbyssBuffData.buffDatas)
|
||||
// {
|
||||
// if (x.Value.Item1 == originalTuple.name)
|
||||
// {
|
||||
// AbyssBuffData.buffDatas[x.Key] = translatedTuple;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// public enum AbyssBuffClone
|
||||
// {
|
||||
// 生存_聚塑,
|
||||
// 生存_启命,
|
||||
// 生存_坚定,
|
||||
// 生存_弥合,
|
||||
// 生存_警戒,
|
||||
// 生存_霸体,
|
||||
// 生存_共存,
|
||||
// 生存_护盾,
|
||||
// 生存_治疗,
|
||||
// 生存_主宰,
|
||||
// 寒冰_聚塑,
|
||||
// 寒冰_刺骨,
|
||||
// 寒冰_凛风,
|
||||
// 寒冰_冻结,
|
||||
// 寒冰_保护,
|
||||
// 寒冰_折磨,
|
||||
// 寒冰_扩散,
|
||||
// 寒冰_凝神,
|
||||
// 寒冰_破冰,
|
||||
// 寒冰_永冻,
|
||||
// 魅惑_聚塑,
|
||||
// 魅惑_感应,
|
||||
// 魅惑_催眠,
|
||||
// 魅惑_无畏,
|
||||
// 魅惑_脆弱,
|
||||
// 魅惑_黑曜,
|
||||
// 魅惑_转世,
|
||||
// 魅惑_支援,
|
||||
// 魅惑_沉重,
|
||||
// 魅惑_共鸣,
|
||||
// 烈焰_聚塑,
|
||||
// 烈焰_爆破,
|
||||
// 烈焰_怒火,
|
||||
// 烈焰_红唇,
|
||||
// 烈焰_融化,
|
||||
// 烈焰_燃烧,
|
||||
// 烈焰_浴火,
|
||||
// 烈焰_鬼火,
|
||||
// 烈焰_诅咒,
|
||||
// 烈焰_太阳,
|
||||
// 通用_断水,
|
||||
// 通用_千斤,
|
||||
// 通用_急迫,
|
||||
// 通用_折扣,
|
||||
// 通用_密植,
|
||||
// 通用_超级,
|
||||
// 通用_究极,
|
||||
// 通用_极速,
|
||||
// 通用_强力,
|
||||
// 通用_专注,
|
||||
// 通用_迸发,
|
||||
// 通用_投资,
|
||||
// 通用_机遇,
|
||||
// 通用_命运,
|
||||
// 通用_时停,
|
||||
// 通用_升级,
|
||||
// 蒜毒_聚塑,
|
||||
// 蒜毒_腐蚀,
|
||||
// 蒜毒_侵蚀,
|
||||
// 蒜毒_血清,
|
||||
// 蒜毒_混乱,
|
||||
// 蒜毒_虚弱,
|
||||
// 蒜毒_反胃,
|
||||
// 蒜毒_虫噬,
|
||||
// 蒜毒_百毒,
|
||||
// 蒜毒_爆裂
|
||||
// }
|
||||
//}
|
||||
12
MelonLoader/Patches/Managers/AbyssInfo_Patch.cs
Normal file
12
MelonLoader/Patches/Managers/AbyssInfo_Patch.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace PvZ_Fusion_Translator.Patches.Managers
|
||||
//{
|
||||
// public class AbyssInfo_Patch
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
|
@ -26,7 +26,8 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
|
||||
if(new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
|
||||
{
|
||||
array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
|
||||
string customName = (StringStore.translationString.ContainsKey(parts[0] + "_IZ")) ? parts[0] + "_IZ" : parts[0];
|
||||
array[i].text = string.Format(fStr, StringStore.TranslateText(customName), parts[1]);
|
||||
}
|
||||
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,14 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
{ BuffType.Debuff, "debuffs" },
|
||||
};
|
||||
|
||||
public static Dictionary<string, List<string>> dumpedTravelBuffs = new Dictionary<string, List<string>>()
|
||||
{
|
||||
{ "advancedUpgrades", [] },
|
||||
{ "ultimateUpgrades", [] },
|
||||
{ "strongUltimates", [] },
|
||||
{ "debuffs", [] }
|
||||
};
|
||||
|
||||
public static Dictionary<string, List<string>> translatedTravelBuffs = new Dictionary<string, List<string>>();
|
||||
|
||||
public static void DumpTravelBuffs(Il2CppSystem.Collections.Generic.Dictionary<int, string> source, Dictionary<string, List<string>> dest, string index)
|
||||
|
|
@ -35,13 +43,29 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
}
|
||||
}
|
||||
|
||||
public static string MatchTravelBuff(string originalText)
|
||||
{
|
||||
string res = "";
|
||||
|
||||
foreach(var i in dumpedTravelBuffs)
|
||||
{
|
||||
if(i.Value.Contains(originalText))
|
||||
{
|
||||
res = translatedTravelBuffs[i.Key][i.Value.IndexOf(originalText)];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelMgr.Awake))]
|
||||
[HarmonyPrefix]
|
||||
private static void Pre_Awake(TravelMgr __instance)
|
||||
{
|
||||
// Dump buffs
|
||||
|
||||
Dictionary<string, List<string>> dumpedTravelBuffs = new Dictionary<string, List<string>>()
|
||||
dumpedTravelBuffs = new Dictionary<string, List<string>>() // reset dump
|
||||
{
|
||||
{ "advancedUpgrades", [] },
|
||||
{ "ultimateUpgrades", [] },
|
||||
|
|
|
|||
|
|
@ -400,6 +400,8 @@
|
|||
<Compile Include="Log.cs" />
|
||||
<Compile Include="ModFeatures.cs" />
|
||||
<Compile Include="AssetStore\AudioStore.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||
|
|
@ -457,6 +459,8 @@
|
|||
<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\AbyssBuffData_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AbyssInfo_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue