3.6 code IDK something update
This commit is contained in:
parent
22e503bd32
commit
92f03fdcb7
16 changed files with 337 additions and 74 deletions
|
|
@ -83,7 +83,7 @@ namespace PvZ_Fusion_Translator
|
||||||
Utils.OpenSaveDirectory();
|
Utils.OpenSaveDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.Delete))
|
if (Input.GetKeyDown(KeyCode.PageUp))
|
||||||
{
|
{
|
||||||
Utils.OpenOnlineAlmanac();
|
Utils.OpenOnlineAlmanac();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ namespace PvZ_Fusion_Translator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string detailStringsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/3.6/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Almanac/DetailStrings.json").Result;
|
string detailStringsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Almanac/DetailStringsTranslate.json").Result;
|
||||||
if(detailStringsContent != null)
|
if(detailStringsContent != null)
|
||||||
{
|
{
|
||||||
LoadDetailStrings(detailStringsContent);
|
LoadDetailStrings(detailStringsContent);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
public static void TranslateInGameTextMesh(TextMeshProUGUI txt)
|
public static void TranslateInGameTextMesh(TextMeshProUGUI txt)
|
||||||
{
|
{
|
||||||
if (txt == null) return;
|
if (txt == null) return;
|
||||||
|
if (txt.text == currentText) return;
|
||||||
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
|
@ -145,6 +146,8 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
|
|
||||||
|
currentText = txt.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string namePlantedPattern = "种植了:([^\\s]+)";
|
public static string namePlantedPattern = "种植了:([^\\s]+)";
|
||||||
|
|
|
||||||
49
MelonLoader/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs
Normal file
49
MelonLoader/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.Patches.Managers;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TMP_Dropdown))]
|
||||||
|
public static class TMP_Dropdown_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TMP_Dropdown.Awake))]
|
||||||
|
[HarmonyPatch(nameof(TMP_Dropdown.Start))]
|
||||||
|
[HarmonyPatch(nameof(TMP_Dropdown.Show))]
|
||||||
|
[HarmonyPatch(nameof(TMP_Dropdown.SetValue))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void Awake(TMP_Dropdown __instance)
|
||||||
|
{
|
||||||
|
if(__instance.captionText)
|
||||||
|
{
|
||||||
|
TMP_Text txt = __instance.captionText;
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(__instance.itemText)
|
||||||
|
{
|
||||||
|
TMP_Text txt = __instance.itemText;
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(TMP_Dropdown.DropdownItem dropdownItem in __instance.m_Items)
|
||||||
|
{
|
||||||
|
TMP_Text txt = dropdownItem.text;
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TMP_Dropdown.CreateDropdownList))]
|
||||||
|
public static void CreateDropdownList(TMP_Dropdown __instance)
|
||||||
|
{
|
||||||
|
foreach(TMP_Text txt in __instance.GetComponentsInChildren<TMP_Text>(true))
|
||||||
|
{
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -10,7 +10,7 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(TMP_InputField.OnEnable))]
|
[HarmonyPatch(nameof(TMP_InputField.OnEnable))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void OnEnable(TMP_InputField __instance)
|
public static void OnEnable(TMP_InputField __instance)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(__instance.text))
|
if (!string.IsNullOrEmpty(__instance.text))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
if(__instance.transform.parent.name.Contains("DrawCardsText"))
|
if(__instance.transform.parent.name.Contains("DrawCardsText"))
|
||||||
{
|
{
|
||||||
Log.LogDebug("skipping drawcardstext");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
foreach(TextMeshProUGUI txt in window.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach(TextMeshProUGUI txt in window.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
txt.text = StringStore.TranslateText(txt.text);
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_MC") ? StringStore.TranslateText(txt.text + "_MC") : StringStore.TranslateText(txt.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,10 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
|
||||||
public static void TranslateOptionButton(TravelBuffOptionButton button)
|
public static void TranslateOptionButton(TravelBuffOptionButton button)
|
||||||
{
|
{
|
||||||
/*SortedDictionary<int, string> buffSet = translatedTravelBuffs[buffLinks[button.buffType]];
|
if(!TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text) && Utils.CheckForUntranslatedText(button.introduce.text))
|
||||||
|
{
|
||||||
string buff = button.show != null && button.introduce.text != "词条已选完" ? buffSet[button.buffIndex] : StringStore.TranslateText("词条已选完");
|
button.introduce.text = StringStore.TranslateText(button.introduce.text);
|
||||||
|
}
|
||||||
button.introduce.text = buff;*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,14 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
string buffText = buffSet.ContainsKey(__instance.buffIndex) ? 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("Introduce").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
if(!TravelMgr_Patch.travelBuffString.ContainsKey(text.text) && Utils.CheckForUntranslatedText(text.text))
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -169,10 +169,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.LogInfo("Couldnt find this buff");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*var translatedBuffSet = travelBuffs[i.Key];
|
/*var translatedBuffSet = travelBuffs[i.Key];
|
||||||
if(translatedBuffSet.ContainsKey(j.Key))
|
if(translatedBuffSet.ContainsKey(j.Key))
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
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 UnityEngine;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
using static Il2CppSystem.Globalization.TimeSpanFormat;
|
||||||
|
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
{
|
{
|
||||||
|
|
@ -19,10 +20,19 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
|
||||||
string buff = __instance.show != null && __instance.introduce.text != "词条已选完" ? buffSet[__instance.buffIndex] : StringStore.TranslateText("词条已选完");*/
|
string buff = __instance.show != null && __instance.introduce.text != "词条已选完" ? buffSet[__instance.buffIndex] : StringStore.TranslateText("词条已选完");*/
|
||||||
string originalText = __instance.introduce.text;
|
string originalText = __instance.introduce.text;
|
||||||
|
string affinityPattern = "([\\s\\S]+)(\\\n<color=red>)([\\s\\S]+)(<\\/color>)";
|
||||||
string affinities = TranslateAffinities(originalText);
|
if(Regex.IsMatch(__instance.introduce.text, affinityPattern, options: RegexOptions.Singleline))
|
||||||
|
{
|
||||||
__instance.introduce.text = originalText + affinities;
|
Match match = Regex.Match(__instance.introduce.text, affinityPattern, options: RegexOptions.Singleline);
|
||||||
|
string startText = match.Groups[1].Value;
|
||||||
|
string affinityText = match.Groups[3].Value;
|
||||||
|
string affinities = TranslateAffinities(affinityText);
|
||||||
|
__instance.introduce.text = startText + affinities;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__instance.introduce.text = originalText;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var text in __instance.buttonText)
|
foreach (var text in __instance.buttonText)
|
||||||
{
|
{
|
||||||
|
|
@ -42,55 +52,41 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
|
||||||
|
|
||||||
public static string TranslateAffinities(string originalText)
|
public static string TranslateAffinities(string originalText)
|
||||||
{
|
{
|
||||||
string discolored = Utils.RemoveColorTags(originalText);
|
|
||||||
int firstNewlineIndex = discolored.IndexOf('\n');
|
|
||||||
|
|
||||||
string result = "";
|
string result = "";
|
||||||
List<string> translatedAffinities = [];
|
List<string> translatedAffinities = [];
|
||||||
|
|
||||||
if(firstNewlineIndex >= 0)
|
string[] lines = originalText.Split('\n');
|
||||||
|
|
||||||
|
foreach(string line in lines)
|
||||||
{
|
{
|
||||||
string affinityString = discolored.Substring(firstNewlineIndex);
|
if (string.IsNullOrEmpty(line)) continue;
|
||||||
string[] affinities = affinityString.Split('\n');
|
|
||||||
|
|
||||||
string fStr = StringStore.translationStringRegex.ContainsKey("【([^\\s]+)】_IV") ? StringStore.translationStringRegex["【([^\\s]+)】_IV"] : "[{0}]";
|
string fStr = StringStore.translationStringRegex.ContainsKey("【([^\\s]+)】_IV") ? StringStore.translationStringRegex["【([^\\s]+)】_IV"] : "[{0}]";
|
||||||
string originalPattern = "【([^\\s]+)】";
|
|
||||||
|
|
||||||
foreach (string affinity in affinities)
|
// Extract dynamic parts from the original text
|
||||||
|
var regex = new Regex("【([^\\s]+)】");
|
||||||
|
var match = regex.Match(line);
|
||||||
|
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++)
|
||||||
{
|
{
|
||||||
if(affinity != "")
|
string groupValue = match.Groups[i].Value;
|
||||||
{
|
string translatedValue = StringStore.translationString.ContainsKey(groupValue)
|
||||||
string translatedAffinity = affinity;
|
? StringStore.translationString[groupValue]
|
||||||
if (StringStore.TestRegex(affinity, originalPattern))
|
: groupValue;
|
||||||
{
|
dynamicParts.Add(translatedValue);
|
||||||
// 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>";
|
|
||||||
|
// Format the output string with dynamic parts
|
||||||
|
string translatedAffinity = string.Format(fStr, [.. dynamicParts]);
|
||||||
|
translatedAffinities.Add(translatedAffinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = "\n" + "<color=red>" + String.Join("\n", translatedAffinities) + "</color>";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppGameLevel;
|
using Il2CppGameLevel;
|
||||||
|
using Il2CppGameLevel.EventNodes;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -9,7 +10,9 @@ using System.Text;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Unity.VisualScripting.FullSerializer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
||||||
{
|
{
|
||||||
|
|
@ -20,8 +23,34 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void LoadOnlineLevelAsync(CustomButton_enterGame __instance)
|
public static void LoadOnlineLevelAsync(CustomButton_enterGame __instance)
|
||||||
{
|
{
|
||||||
|
string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json");
|
||||||
Dictionary<string, TranslatedLevelData> dumpData = new Dictionary<string, TranslatedLevelData>();
|
Dictionary<string, TranslatedLevelData> dumpData = new Dictionary<string, TranslatedLevelData>();
|
||||||
|
|
||||||
|
if (!File.Exists(dumpPath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
dumpData = JsonSerializer.Deserialize<Dictionary<string, TranslatedLevelData>>(File.ReadAllText(dumpPath));
|
||||||
|
|
||||||
|
string dumpStringsPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_strings.json");
|
||||||
|
Dictionary<string, string> dumpStringsData = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
if (!File.Exists(dumpStringsPath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(dumpStringsPath, System.Text.Json.JsonSerializer.Serialize(dumpStringsData, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
dumpStringsData = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(dumpStringsPath));
|
||||||
|
|
||||||
var level = __instance;
|
var level = __instance;
|
||||||
|
|
||||||
if(level.onlineLevelInfo != null)
|
if(level.onlineLevelInfo != null)
|
||||||
|
|
@ -29,31 +58,158 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
||||||
string levelId = level.onlineLevelInfo.levelId;
|
string levelId = level.onlineLevelInfo.levelId;
|
||||||
if(levelId != null)
|
if(levelId != null)
|
||||||
{
|
{
|
||||||
|
SerializedLevelData serializedLevel = level.serializedLevel;
|
||||||
if(CustomLevelMenu_Patch.translatedLevelData.ContainsKey(levelId))
|
if(CustomLevelMenu_Patch.translatedLevelData.ContainsKey(levelId))
|
||||||
{
|
{
|
||||||
TranslatedLevelData levelData = CustomLevelMenu_Patch.translatedLevelData[levelId];
|
TranslatedLevelData levelData = CustomLevelMenu_Patch.translatedLevelData[levelId];
|
||||||
level.levelName.text = levelData.name;
|
level.levelName.text = levelData.name;
|
||||||
level.serializedLevel.name = levelData.name;
|
serializedLevel.name = levelData.name;
|
||||||
level.serializedLevel.boardConfig.startTip = levelData.startTip;
|
serializedLevel.boardConfig.startTip = levelData.startTip;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.levelData.Name, level.serializedLevel.boardConfig.startTip);
|
TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.onlineLevelInfo.levelName, serializedLevel.boardConfig.startTip);
|
||||||
dumpData.Add(levelId, dumpedLevelData);
|
dumpData.Add(levelId, dumpedLevelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*level.levelData.SerializedLevelData
|
||||||
|
foreach()*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
level.levelName.text = StringStore.TranslateText(level.levelData.Name);
|
level.levelName.text = StringStore.TranslateText(level.levelName.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json");
|
|
||||||
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
}));
|
}));
|
||||||
|
File.WriteAllText(dumpStringsPath, System.Text.Json.JsonSerializer.Serialize(dumpStringsData, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*[HarmonyPatch(typeof(LevelManager))]
|
||||||
|
public static class Test
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(LevelManager.SaveLevelData))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void SaveLevelData(LevelManager __instance, ref SerializedLevelData serializedLevelData)
|
||||||
|
{
|
||||||
|
Log.LogDebug("hi 2");
|
||||||
|
string json = JsonUtility.ToJson(serializedLevelData);
|
||||||
|
ReferenceLevelData references = Newtonsoft.Json.JsonConvert.DeserializeObject<ReferenceLevelData>(json);
|
||||||
|
foreach(var reference in references.references.RefIds)
|
||||||
|
{
|
||||||
|
ReferenceLevelData.Data nodeData = reference.data;
|
||||||
|
string nodeType = nodeData.nodeType;
|
||||||
|
|
||||||
|
if(nodeType == "StringConcatNode")
|
||||||
|
{
|
||||||
|
Log.LogDebug(nodeData.value.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nodeType == "StringValueNode")
|
||||||
|
{
|
||||||
|
Log.LogDebug(nodeData.value.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class ReferenceLevelData
|
||||||
|
{
|
||||||
|
public class Data
|
||||||
|
{
|
||||||
|
public string nodeId { get; set; }
|
||||||
|
public string nodeType { get; set; }
|
||||||
|
public Position position { get; set; }
|
||||||
|
public string nodeName { get; set; }
|
||||||
|
public string plant_PortName { get; set; }
|
||||||
|
public string column_PortName { get; set; }
|
||||||
|
public string row_PortName { get; set; }
|
||||||
|
public string plantType_PortName { get; set; }
|
||||||
|
public object value { get; set; }
|
||||||
|
public string value_PortName { get; set; }
|
||||||
|
public string plantTypeA_PortName { get; set; }
|
||||||
|
public string plantTypeB_PortName { get; set; }
|
||||||
|
public string equal_PortName { get; set; }
|
||||||
|
public string trigger_PortName { get; set; }
|
||||||
|
public string count_PortName { get; set; }
|
||||||
|
public string output_PortName { get; set; }
|
||||||
|
public string index_PortName { get; set; }
|
||||||
|
public string plants_PortName { get; set; }
|
||||||
|
public string plantList_PortName { get; set; }
|
||||||
|
public string loopBody_PortName { get; set; }
|
||||||
|
public string currentPlant_PortName { get; set; }
|
||||||
|
public string currentIndex_PortName { get; set; }
|
||||||
|
public string onCompleted_PortName { get; set; }
|
||||||
|
public string condition_PortName { get; set; }
|
||||||
|
public string then_PortName { get; set; }
|
||||||
|
public string else_PortName { get; set; }
|
||||||
|
public string a_PortName { get; set; }
|
||||||
|
public string b_PortName { get; set; }
|
||||||
|
public string result_PortName { get; set; }
|
||||||
|
public string shouldReset_PortName { get; set; }
|
||||||
|
public string onCount_PortName { get; set; }
|
||||||
|
public int? startValue { get; set; }
|
||||||
|
public string valueA_PortName { get; set; }
|
||||||
|
public string valueB_PortName { get; set; }
|
||||||
|
public string greater_PortName { get; set; }
|
||||||
|
public string less_PortName { get; set; }
|
||||||
|
public string displayText { get; set; }
|
||||||
|
public double? duration { get; set; }
|
||||||
|
public string text_PortName { get; set; }
|
||||||
|
public string duration_PortName { get; set; }
|
||||||
|
public string int_PortName { get; set; }
|
||||||
|
public string float_PortName { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GodShootingConfig
|
||||||
|
{
|
||||||
|
public List<object> plants { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Position
|
||||||
|
{
|
||||||
|
public double x { get; set; }
|
||||||
|
public double y { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class References
|
||||||
|
{
|
||||||
|
public int version { get; set; }
|
||||||
|
public List<RefId> RefIds { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RefId
|
||||||
|
{
|
||||||
|
public int rid { get; set; }
|
||||||
|
public Type type { get; set; }
|
||||||
|
public Data data { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Type
|
||||||
|
{
|
||||||
|
public string @class { get; set; }
|
||||||
|
public string ns { get; set; }
|
||||||
|
public string asm { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ZombiesWithRow
|
||||||
|
{
|
||||||
|
public int zombieType { get; set; }
|
||||||
|
public int row { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public EventNodeGraph eventNodeGraph { get; set; }
|
||||||
|
public References references { get; set; }
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
@ -59,8 +59,18 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
||||||
|
|
||||||
public static void TranslateLevelButtons(CustomLevelMenu __instance)
|
public static void TranslateLevelButtons(CustomLevelMenu __instance)
|
||||||
{
|
{
|
||||||
|
string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json");
|
||||||
Dictionary<string, TranslatedLevelData> dumpData = new Dictionary<string, TranslatedLevelData>();
|
Dictionary<string, TranslatedLevelData> dumpData = new Dictionary<string, TranslatedLevelData>();
|
||||||
|
|
||||||
|
if (!File.Exists(dumpPath))
|
||||||
|
{
|
||||||
|
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
foreach(CustomButton_enterGame level in __instance.levels)
|
foreach(CustomButton_enterGame level in __instance.levels)
|
||||||
{
|
{
|
||||||
if(level.onlineLevelInfo != null)
|
if(level.onlineLevelInfo != null)
|
||||||
|
|
@ -77,18 +87,17 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.levelData.Name, level.serializedLevel.boardConfig.startTip);
|
TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.onlineLevelInfo.levelName, level.serializedLevel.boardConfig.startTip);
|
||||||
dumpData.Add(levelId, dumpedLevelData);
|
dumpData.Add(levelId, dumpedLevelData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
level.levelName.text = StringStore.TranslateText(level.levelData.Name);
|
level.levelName.text = StringStore.TranslateText(level.levelName.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json");
|
|
||||||
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,20 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
||||||
txt.text = (zombieName != "") ? zombieName : StringStore.TranslateText(txt.text);
|
txt.text = (zombieName != "") ? zombieName : StringStore.TranslateText(txt.text);
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
|
else if(nodeUI.Node.nodeType == "PlantTypeListStorageNode")
|
||||||
|
{
|
||||||
|
Transform dropdownTransform = nodeUI.transform.Find("Header/ValueEditContainer/Dropdown(Clone)");
|
||||||
|
|
||||||
|
if (!dropdownTransform) continue;
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI txt in dropdownTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
if (!Utils.CheckForUntranslatedText(txt.text)) continue;
|
||||||
|
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
txt.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ using System.Threading.Tasks;
|
||||||
using Il2CppGameLevel.EventNodes;
|
using Il2CppGameLevel.EventNodes;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator.Patches.BaseTextObjects;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
||||||
{
|
{
|
||||||
|
|
@ -17,11 +18,33 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
||||||
public static class RuntimeNodeUI_Patch
|
public static class RuntimeNodeUI_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(RuntimeNodeUI.Awake))]
|
[HarmonyPatch(nameof(RuntimeNodeUI.Awake))]
|
||||||
|
[HarmonyPatch(nameof(RuntimeNodeUI.Initialize))]
|
||||||
|
[HarmonyPatch(nameof(RuntimeNodeUI.CreatePorts))]
|
||||||
|
[HarmonyPatch(nameof(RuntimeNodeUI.CreateTravelEntryEditUI), argumentTypes: [typeof(RectTransform), typeof(GetTravelEntryNode)])]
|
||||||
|
[HarmonyPatch(nameof(RuntimeNodeUI.CreateStringInputField))]
|
||||||
|
[HarmonyPatch(nameof(RuntimeNodeUI.CreatePorts))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void Awake(RuntimeNodeUI __instance)
|
public static void Awake(RuntimeNodeUI __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
if(__instance.dropdownPrefab)
|
||||||
|
{
|
||||||
|
if(__instance.dropdownPrefab.TryGetComponent<TMP_Dropdown>(out TMP_Dropdown dropdown))
|
||||||
|
{
|
||||||
|
TMP_Dropdown_Patch.CreateDropdownList(dropdown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(__instance.valueInputField)
|
||||||
|
{
|
||||||
|
TMP_InputField_Patch.OnEnable(__instance.valueInputField);
|
||||||
|
foreach(TextMeshProUGUI txt in __instance.valueInputField.GetComponentsInChildren<TextMeshProUGUI>(true))
|
||||||
|
{
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
|
@ -29,13 +52,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(RuntimeNodeUI.Initialize))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
public static void Initialize(RuntimeNodeUI __instance)
|
|
||||||
{
|
|
||||||
Awake(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(RuntimeNodeUI.UpdateDisplay))]
|
[HarmonyPatch(nameof(RuntimeNodeUI.UpdateDisplay))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void UpdateDisplay(RuntimeNodeUI __instance)
|
public static void UpdateDisplay(RuntimeNodeUI __instance)
|
||||||
|
|
@ -67,6 +83,23 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(__instance.dropdownPrefab)
|
||||||
|
{
|
||||||
|
if(__instance.dropdownPrefab.TryGetComponent<TMP_Dropdown>(out TMP_Dropdown dropdown))
|
||||||
|
{
|
||||||
|
TMP_Dropdown_Patch.CreateDropdownList(dropdown);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(__instance.valueInputField)
|
||||||
|
{
|
||||||
|
TMP_InputField_Patch.OnEnable(__instance.valueInputField);
|
||||||
|
foreach(TextMeshProUGUI txt in __instance.valueInputField.GetComponentsInChildren<TextMeshProUGUI>(true))
|
||||||
|
{
|
||||||
|
txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(RuntimeNodeUI.UpdateSelectionVisual))]
|
[HarmonyPatch(nameof(RuntimeNodeUI.UpdateSelectionVisual))]
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,7 @@
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
|
<Compile Include="Patches\BaseTextObjects\TMP_Dropdown_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AlmanacCardUI_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AlmanacCardUI_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AlmanacSelectMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AlmanacSelectMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ConfirmMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ConfirmMenu_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue