odyssey id system fixes + file protection added
This commit is contained in:
parent
14a1681ea9
commit
ba7c713a37
5 changed files with 75 additions and 80 deletions
|
|
@ -41,27 +41,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
|
||||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||||
{
|
||||
string regexStr = "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s:]+)\n减伤强度:(\\d+)";
|
||||
|
||||
Regex regex = new Regex(regexStr);
|
||||
|
||||
if(regex.IsMatch(txt.text))
|
||||
{
|
||||
Match match = regex.Match(txt.text);
|
||||
int groupCount = match.Groups.Count;
|
||||
|
||||
List<string> dynamicParts = [];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
txt.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,8 @@
|
|||
using Il2Cpp;
|
||||
using Il2CppTMPro;
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using System.Text.Json;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||
{
|
||||
|
|
@ -20,6 +18,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
|
||||
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||
File.WriteAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "changelog.txt"), contentText.text);
|
||||
|
||||
string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
|
||||
string changelogDir = Path.Combine(stringDir, "changelog.txt");
|
||||
|
||||
if (!File.Exists(changelogDir))
|
||||
{
|
||||
File.WriteAllText(changelogDir, contentText.text);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
|
|
@ -27,12 +33,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
private static void Post_Awake(NoticeMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
string changelogText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "changelog.txt"));
|
||||
string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
|
||||
string changelogDir = Path.Combine(stringDir, "changelog.txt");
|
||||
|
||||
string changelogText = File.ReadAllText(changelogDir);
|
||||
|
||||
GameObject contentObject = __instance.transform.FindChild("Scroll View").GetChild(0).GetChild(0).gameObject; //bc normal Find or FindChild didn't work
|
||||
|
||||
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||
contentText.text = changelogText;
|
||||
contentText.text = changelogText;
|
||||
|
||||
ContentSizeFitter sizeFitter = contentObject.AddComponent<ContentSizeFitter>();
|
||||
sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
|
|
|||
|
|
@ -6,35 +6,35 @@ 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)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
|
||||
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(TravelBuffOptionButton __instance)
|
||||
{
|
||||
__instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
}
|
||||
// [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.OnAnimOver))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
|
||||
[HarmonyPatch(nameof(TravelBuffOptionButton.SetBackground))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetBackground(TravelBuffOptionButton __instance)
|
||||
{
|
||||
__instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
}
|
||||
}
|
||||
// [HarmonyPatch(nameof(TravelBuffOptionButton.SetBackground))]
|
||||
// [HarmonyPostfix]
|
||||
// private static void SetBackground(TravelBuffOptionButton __instance)
|
||||
// {
|
||||
// __instance.introduce.text = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,44 +4,42 @@ using Il2CppTMPro;
|
|||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
|
||||
using UnityEngine;
|
||||
using MelonLoader;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TravelLookBuff))]
|
||||
public static class TravelLookBuff_Patch
|
||||
{
|
||||
private static void TranslateTexts(TravelLookBuff __instance)
|
||||
[HarmonyPatch(nameof(TravelLookBuff.Clear))]
|
||||
[HarmonyPostfix]
|
||||
public static void Post_Clear(TravelLookBuff __instance)
|
||||
{
|
||||
string buffText = translatedTravelBuffs[buffLinks[__instance.buffType]][__instance.buffIndex];
|
||||
__instance.introduce.text = StringStore.TranslateText("无");
|
||||
__instance.set = false;
|
||||
}
|
||||
|
||||
__instance.introduce.text = buffText;
|
||||
|
||||
Transform transform = __instance.rectTransform.transform;
|
||||
var component1 = transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||
var component2 = transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||
|
||||
if (component1 != null) component1.text = StringStore.TranslateText(component1.text);
|
||||
if (component2 != null) component2.text = StringStore.TranslateText(component2.text);
|
||||
[HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
||||
[HarmonyPostfix]
|
||||
public static void Post_OnMouseUpAsButton(TravelLookBuff __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetBuff(TravelLookBuff __instance) => TranslateTexts(__instance);
|
||||
public static void Post_SetBuff(TravelLookBuff __instance)
|
||||
{
|
||||
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
||||
[HarmonyPostfix]
|
||||
private static void OnMouseUpAsButton(TravelLookBuff __instance) => TranslateTexts(__instance);
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.Clear))]
|
||||
[HarmonyPostfix]
|
||||
private static void Clear(TravelLookBuff __instance) => TranslateTexts(__instance);
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.SetText), new Type[] { typeof(string) })]
|
||||
[HarmonyPostfix]
|
||||
private static void SetText_String(TravelLookBuff __instance) => TranslateTexts(__instance);
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookBuff.SetText), new Type[] { typeof(bool), typeof(int) })]
|
||||
[HarmonyPostfix]
|
||||
private static void SetText_Bool(TravelLookBuff __instance) => TranslateTexts(__instance);
|
||||
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -63,6 +63,13 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
File.WriteAllText(Path.Combine(dumpDir, "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, options));
|
||||
|
||||
string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
|
||||
string travelBuffDir = Path.Combine(stringDir, "travel_buffs.json");
|
||||
|
||||
if(!File.Exists(travelBuffDir))
|
||||
{
|
||||
File.WriteAllText(travelBuffDir, JsonSerializer.Serialize(dumpedTravelBuffs, options));
|
||||
}
|
||||
|
||||
string travelBuffs = File.ReadAllText(Path.Combine(stringDir, "travel_buffs.json"));
|
||||
|
||||
translatedTravelBuffs = JsonSerializer.Deserialize<Dictionary<string, List<string>>>(travelBuffs);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue