MESSY bepinex stuff + some melonloader
This commit is contained in:
parent
0df5c96f4c
commit
7216014ac2
33 changed files with 958 additions and 572 deletions
|
|
@ -147,6 +147,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
public class AudioSource_Patch
|
public class AudioSource_Patch
|
||||||
{
|
{
|
||||||
public static void Prefix(UnityEngine.AudioSource __instance)
|
public static void Prefix(UnityEngine.AudioSource __instance)
|
||||||
|
{
|
||||||
|
if(Utils.customAudio)
|
||||||
{
|
{
|
||||||
if (__instance.clip == null)
|
if (__instance.clip == null)
|
||||||
return;
|
return;
|
||||||
|
|
@ -161,4 +163,5 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,7 +17,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
RestoreTextures();
|
RestoreTextures();
|
||||||
#endif
|
#endif
|
||||||
FileLoader.LoadDefaultTextures();
|
|
||||||
FileLoader.LoadTextures();
|
FileLoader.LoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,6 @@ public class Core : BasePlugin
|
||||||
public void InitCoroutine()
|
public void InitCoroutine()
|
||||||
{
|
{
|
||||||
replaceTextureRoutine = MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine());
|
replaceTextureRoutine = MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine());
|
||||||
Log.LogDebug("Coroutine Started");
|
|
||||||
}
|
}
|
||||||
public static void ShowToast(string message)
|
public static void ShowToast(string message)
|
||||||
{
|
{
|
||||||
|
|
@ -111,9 +110,24 @@ public class Core : BasePlugin
|
||||||
private void LoadConfig()
|
private void LoadConfig()
|
||||||
{
|
{
|
||||||
string mainCategory = "PvZ_Fusion_Translator";
|
string mainCategory = "PvZ_Fusion_Translator";
|
||||||
|
|
||||||
|
if(Config.TryGetEntry<bool>(new ConfigDefinition(mainCategory, "DefaultTextures"), out configDefaultTextures) == false)
|
||||||
|
{
|
||||||
configDefaultTextures = Config.Bind(new ConfigDefinition(mainCategory, "DefaultTextures"), false, new ConfigDescription("Use Default Textures + Translation Textures", new AcceptableValueList<bool>(true, false)));
|
configDefaultTextures = Config.Bind(new ConfigDefinition(mainCategory, "DefaultTextures"), false, new ConfigDescription("Use Default Textures + Translation Textures", new AcceptableValueList<bool>(true, false)));
|
||||||
|
}
|
||||||
|
bool defaultTextures = Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out configDefaultTextures);
|
||||||
|
|
||||||
|
if (Config.TryGetEntry<bool>(new ConfigDefinition(mainCategory, "DefaultAudio"), out configDefaultAudio) == false)
|
||||||
|
{
|
||||||
configDefaultAudio = Config.Bind(new ConfigDefinition(mainCategory, "DefaultAudio"), false, new ConfigDescription("Use Default Audio", new AcceptableValueList<bool>(true, false)));
|
configDefaultAudio = Config.Bind(new ConfigDefinition(mainCategory, "DefaultAudio"), false, new ConfigDescription("Use Default Audio", new AcceptableValueList<bool>(true, false)));
|
||||||
|
}
|
||||||
|
bool defaultAudio = Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out configDefaultAudio);
|
||||||
|
|
||||||
|
if (Config.TryGetEntry<string>(new ConfigDefinition(mainCategory, "Language"), out configLanguage) == false)
|
||||||
|
{
|
||||||
configLanguage = Config.Bind(new ConfigDefinition(mainCategory, "Language"), "English", new ConfigDescription("Load the Game in this Language", new AcceptableValueList<string>("English", "French", "Italian", "German", "Spanish", "Portuguese", "Indonesian", "Vietnamese", "Javanese", "Russian", "Japanese", "Korean")));
|
configLanguage = Config.Bind(new ConfigDefinition(mainCategory, "Language"), "English", new ConfigDescription("Load the Game in this Language", new AcceptableValueList<string>("English", "French", "Italian", "German", "Spanish", "Portuguese", "Indonesian", "Vietnamese", "Javanese", "Russian", "Japanese", "Korean")));
|
||||||
|
}
|
||||||
|
bool language = Config.TryGetEntry<string>(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out configLanguage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using BepInEx.Configuration;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers;
|
using PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -24,11 +25,21 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
string languagePath = language.HasValue ? ("Localization" + Path.DirectorySeparatorChar + language.ToString()) : string.Empty;
|
string languagePath = language.HasValue ? ("Localization" + Path.DirectorySeparatorChar + language.ToString()) : string.Empty;
|
||||||
return Path.Combine(Core.Instance.modsDirectory, languagePath, assetType.ToString());
|
return Path.Combine(Core.Instance.modsDirectory, languagePath, assetType.ToString());
|
||||||
}
|
}
|
||||||
|
// private static string GetAssetDir(AssetType assetType) => Path.Combine(Core.Instance.modsDirectory, assetType.ToString());
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
internal static void LoadStrings() => LoadStrings(Utils.Language);
|
internal static void LoadStrings() => LoadStrings(Utils.Language);
|
||||||
|
|
||||||
internal static void LoadStrings(Utils.LanguageEnum language)
|
internal static void LoadStrings(Utils.LanguageEnum language)
|
||||||
|
#else
|
||||||
|
internal static void LoadStrings(bool isLog = false)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
string stringDir = GetAssetDir(AssetType.Strings, Utils.Language);
|
string stringDir = GetAssetDir(AssetType.Strings, Utils.Language);
|
||||||
|
#else
|
||||||
|
string stringDir = GetAssetDir(AssetType.Strings);
|
||||||
|
#endif
|
||||||
if (!Directory.Exists(stringDir))
|
if (!Directory.Exists(stringDir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(stringDir);
|
Directory.CreateDirectory(stringDir);
|
||||||
|
|
@ -38,23 +49,23 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
foreach (string filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories))
|
foreach (string filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
|
||||||
#if OBFUSCATE
|
#if OBFUSCATE
|
||||||
if (CheckSumStore.IsModified(filepath))
|
if (CheckSumStore.IsModified(filepath))
|
||||||
{
|
{
|
||||||
Log.LogError("File {0} was modified!" , filepath);
|
Log.LogError("File {0} was modified!" , filepath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
string fileName = Path.GetFileNameWithoutExtension(filepath);
|
string fileName = Path.GetFileNameWithoutExtension(filepath);
|
||||||
StringStore.stringsDict[fileName] = filepath;
|
StringStore.stringsDict[fileName] = filepath;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogInfo("Loading File : " + filepath);
|
Log.LogInfo("Loading File : " + filepath);
|
||||||
#endif
|
#endif
|
||||||
string jsonString = File.ReadAllText(filepath);
|
string jsonString = File.ReadAllText(filepath);
|
||||||
if (fileName.EndsWith("_strings"))
|
if (fileName.EndsWith("_strings"))
|
||||||
{
|
{
|
||||||
Dictionary<string, string> dictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonString);
|
Dictionary<string, string> dictionary = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, string>>(jsonString);
|
||||||
foreach (var (key, value) in dictionary)
|
foreach (var (key, value) in dictionary)
|
||||||
{
|
{
|
||||||
StringStore.translationString[key] = value;
|
StringStore.translationString[key] = value;
|
||||||
|
|
@ -62,7 +73,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
else if (fileName.EndsWith("_regexs"))
|
else if (fileName.EndsWith("_regexs"))
|
||||||
{
|
{
|
||||||
Dictionary<string, string> dictionary = JsonSerializer.Deserialize<Dictionary<string, string>>(jsonString);
|
Dictionary<string, string> dictionary = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, string>>(jsonString);
|
||||||
foreach (var (key, value) in dictionary)
|
foreach (var (key, value) in dictionary)
|
||||||
{
|
{
|
||||||
StringStore.translationStringRegex[key] = value;
|
StringStore.translationStringRegex[key] = value;
|
||||||
|
|
@ -70,9 +81,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveStrings();
|
SaveStrings();
|
||||||
#if DEBUG
|
|
||||||
DumpJson();
|
DumpJson();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
@ -82,17 +91,16 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
Log.LogInfo("Strings loaded successfully.");
|
Log.LogInfo("Strings loaded successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool loadDefaultTextures = Core.Instance.configDefaultTextures.Value;
|
|
||||||
internal static void LoadTextures()
|
internal static void LoadTextures()
|
||||||
{
|
{
|
||||||
|
ConfigEntry<bool> defaultTextureEntry;
|
||||||
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out defaultTextureEntry);
|
||||||
|
|
||||||
// Default or Custom Texturse -> English Textures -> Localized Textures
|
// Default or Custom Texturse -> English Textures -> Localized Textures
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (loadDefaultTextures == true)
|
if (!defaultTextureEntry.Value)
|
||||||
{
|
|
||||||
LoadDefaultTextures();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
LoadCustomTextures();
|
LoadCustomTextures();
|
||||||
}
|
}
|
||||||
|
|
@ -103,17 +111,24 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
Log.LogError($"{e.GetType()} {e.Message}");
|
Log.LogError($"{e.GetType()} {e.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
if (Utils.Language != Utils.LanguageEnum.English)
|
if (Utils.Language != Utils.LanguageEnum.English)
|
||||||
{
|
{
|
||||||
LoadLocalizedTextures(Utils.LanguageEnum.English);
|
LoadLocalizedTextures(Utils.LanguageEnum.English);
|
||||||
}
|
}
|
||||||
LoadLocalizedTextures(Utils.Language);
|
LoadLocalizedTextures(Utils.Language);
|
||||||
|
#else
|
||||||
|
LoadLocalizedTextures();
|
||||||
|
#endif
|
||||||
|
|
||||||
Log.LogInfo("Textures loaded successfully.");
|
Log.LogInfo("Textures loaded successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null)
|
internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null)
|
||||||
{
|
{
|
||||||
|
ConfigEntry<bool> defaultTextureEntry;
|
||||||
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out defaultTextureEntry);
|
||||||
|
|
||||||
string textureDir = GetAssetDir(AssetType.Textures, language);
|
string textureDir = GetAssetDir(AssetType.Textures, language);
|
||||||
|
|
||||||
if (!Directory.Exists(textureDir))
|
if (!Directory.Exists(textureDir))
|
||||||
|
|
@ -124,22 +139,22 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
foreach (string filepath in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories))
|
foreach (string filepath in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
if (filepath.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) && loadDefaultTextures)
|
if (filepath.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) && defaultTextureEntry.Value)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OBFUSCATE
|
#if OBFUSCATE
|
||||||
if (CheckSumStore.IsModified(filepath))
|
if (CheckSumStore.IsModified(filepath))
|
||||||
{
|
{
|
||||||
Log.LogError("File {0} was modified!" , filepath);
|
Log.LogError("File {0} was modified!" , filepath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogDebug("Loading File : " + filepath);
|
Log.LogDebug("Loading File : " + filepath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Texture2D texture2D = Utils.LoadImage(filepath);
|
Texture2D texture2D = Utils.LoadImage(filepath);
|
||||||
TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath;
|
TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath;
|
||||||
|
|
@ -154,6 +169,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void LoadDefaultTextures()
|
internal static void LoadDefaultTextures()
|
||||||
|
{
|
||||||
|
if (Core.Instance.configDefaultTextures.Value)
|
||||||
{
|
{
|
||||||
string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]");
|
string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]");
|
||||||
if (!Directory.Exists(textureDefaultDir))
|
if (!Directory.Exists(textureDefaultDir))
|
||||||
|
|
@ -164,6 +181,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
foreach (string filepath in Directory.EnumerateFiles(textureDefaultDir, "*.png", SearchOption.AllDirectories))
|
foreach (string filepath in Directory.EnumerateFiles(textureDefaultDir, "*.png", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
|
|
||||||
#if OBFUSCATE
|
#if OBFUSCATE
|
||||||
if (CheckSumStore.IsModified(filepath))
|
if (CheckSumStore.IsModified(filepath))
|
||||||
{
|
{
|
||||||
|
|
@ -183,6 +201,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
Log.LogError(e.GetType() + " " + e.Message);
|
Log.LogError(e.GetType() + " " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal static void LoadCustomTextures()
|
internal static void LoadCustomTextures()
|
||||||
{
|
{
|
||||||
|
|
@ -196,13 +215,13 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
foreach (string filepath in Directory.EnumerateFiles(texturePackDir, "*.png", SearchOption.AllDirectories))
|
foreach (string filepath in Directory.EnumerateFiles(texturePackDir, "*.png", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
#if OBFUSCATE
|
#if OBFUSCATE
|
||||||
if (CheckSumStore.IsModified(filepath))
|
if (CheckSumStore.IsModified(filepath))
|
||||||
{
|
{
|
||||||
Log.LogError("File {0} was modified!" , filepath);
|
Log.LogError("File {0} was modified!" , filepath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Texture2D texture2D = Utils.LoadImage(filepath);
|
Texture2D texture2D = Utils.LoadImage(filepath);
|
||||||
TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath;
|
TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath;
|
||||||
|
|
@ -218,13 +237,17 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
|
|
||||||
internal static void SaveStrings()
|
internal static void SaveStrings()
|
||||||
{
|
{
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
string stringDir = GetAssetDir(AssetType.Strings, Utils.Language);
|
string stringDir = GetAssetDir(AssetType.Strings, Utils.Language);
|
||||||
|
#else
|
||||||
|
string stringDir = GetAssetDir(AssetType.Strings);
|
||||||
|
#endif
|
||||||
if (!Directory.Exists(stringDir))
|
if (!Directory.Exists(stringDir))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(stringDir);
|
Directory.CreateDirectory(stringDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
string translationStringRegex = JsonSerializer.Serialize(StringStore.translationStringRegex, new JsonSerializerOptions
|
string translationStringRegex = System.Text.Json.JsonSerializer.Serialize(StringStore.translationStringRegex, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
|
@ -232,7 +255,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
|
|
||||||
File.WriteAllText(Path.Combine(stringDir, "translation_regexs.json"), translationStringRegex);
|
File.WriteAllText(Path.Combine(stringDir, "translation_regexs.json"), translationStringRegex);
|
||||||
|
|
||||||
string translationString = JsonSerializer.Serialize(StringStore.translationString, new JsonSerializerOptions
|
string translationString = System.Text.Json.JsonSerializer.Serialize(StringStore.translationString, new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
WriteIndented = true,
|
WriteIndented = true,
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
|
|
@ -241,7 +264,6 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
File.WriteAllText(Path.Combine(stringDir, "translation_strings.json"), translationString);
|
File.WriteAllText(Path.Combine(stringDir, "translation_strings.json"), translationString);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
public static void DumpJson()
|
public static void DumpJson()
|
||||||
{
|
{
|
||||||
string dumpDir = GetAssetDir(AssetType.Dumps);
|
string dumpDir = GetAssetDir(AssetType.Dumps);
|
||||||
|
|
@ -266,9 +288,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if DEBUG && MELON
|
#if DEBUG
|
||||||
public static void DumpUntranslatedStrings(string text)
|
public static void DumpUntranslatedStrings(string text)
|
||||||
{
|
{
|
||||||
string dumpDir = GetAssetDir(AssetType.Dumps);
|
string dumpDir = GetAssetDir(AssetType.Dumps);
|
||||||
|
|
@ -285,22 +306,30 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
|
|
||||||
string json = File.ReadAllText(jsonFile);
|
string json = File.ReadAllText(jsonFile);
|
||||||
JObject untranslatedStrings = JObject.Parse(json);
|
var untranslatedStrings = JsonSerializer.Deserialize<Dictionary<string, string>>(json);
|
||||||
|
|
||||||
if (!untranslatedStrings.ContainsKey(text))
|
if (!untranslatedStrings.ContainsKey(text))
|
||||||
{
|
{
|
||||||
untranslatedStrings[text] = text;
|
untranslatedStrings[text] = text;
|
||||||
File.WriteAllText(jsonFile, untranslatedStrings.ToString());
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||||
|
WriteIndented = true
|
||||||
|
};
|
||||||
|
File.WriteAllText(jsonFile, JsonSerializer.Serialize(untranslatedStrings, options));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
internal static void LoadLanguage()
|
internal static void LoadLanguage()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Load the language preference as a string and parse it into the enum
|
// Load the language preference as a string and parse it into the enum
|
||||||
string languageName = Core.Instance.configLanguage.Value;
|
ConfigEntry<string> languageEntry;
|
||||||
|
Core.Instance.Config.TryGetEntry<string>(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out languageEntry);
|
||||||
|
string languageName = languageEntry.Value;
|
||||||
if (Enum.TryParse(languageName, out Utils.LanguageEnum loadedLanguage))
|
if (Enum.TryParse(languageName, out Utils.LanguageEnum loadedLanguage))
|
||||||
{
|
{
|
||||||
Utils.Language = loadedLanguage;
|
Utils.Language = loadedLanguage;
|
||||||
|
|
@ -325,10 +354,10 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Save the current language as a string
|
// Save the current language as a string
|
||||||
if (Core.Instance.Config.TryGetEntry<string>("PvZ_Fusion_Translator", "Language", out var languageEntry))
|
ConfigEntry<string> languageEntry;
|
||||||
{
|
Core.Instance.Config.TryGetEntry<string>(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out languageEntry);
|
||||||
languageEntry.Value = Utils.Language.ToString();
|
languageEntry.Value = Utils.Language.ToString();
|
||||||
}
|
Core.Instance.Config.Save();
|
||||||
|
|
||||||
// Ensure changes are written to the config file
|
// Ensure changes are written to the config file
|
||||||
// MelonPreferences.Save();
|
// MelonPreferences.Save();
|
||||||
|
|
@ -340,5 +369,6 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
// Log.LogInfo($"Language has been saved: {Utils.Language}");
|
// Log.LogInfo($"Language has been saved: {Utils.Language}");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.TextCore.Text;
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.TextCore.Text;
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine.TextCore.Text;
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
@ -22,7 +21,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
|
TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
string regexStr = "【([^\\s]+)】\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
|
string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
|
||||||
|
|
||||||
Regex regex = new Regex(regexStr);
|
Regex regex = new Regex(regexStr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.TextCore.Text;
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(AbyssMenu))]
|
[HarmonyPatch(typeof(AbyssMenu))]
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using System.Collections.Generic;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
|
|
@ -19,15 +18,22 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
string regexStr1 = "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)\n";
|
string[] regexStrList = [
|
||||||
string regexStr2 = "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)";
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
|
||||||
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
|
||||||
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
|
||||||
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
|
||||||
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
|
||||||
|
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)"
|
||||||
|
];
|
||||||
|
|
||||||
Regex regex1 = new Regex(regexStr1);
|
foreach(string regexStr in regexStrList)
|
||||||
Regex regex2 = new Regex(regexStr2);
|
|
||||||
|
|
||||||
if (regex1.IsMatch(__instance.settleInfo.text))
|
|
||||||
{
|
{
|
||||||
Match match = regex1.Match(__instance.settleInfo.text);
|
Regex regex = new Regex(regexStr);
|
||||||
|
|
||||||
|
if (regex.IsMatch(__instance.settleInfo.text))
|
||||||
|
{
|
||||||
|
Match match = regex.Match(__instance.settleInfo.text);
|
||||||
int groupCount = match.Groups.Count;
|
int groupCount = match.Groups.Count;
|
||||||
|
|
||||||
List<string> dynamicParts = [];
|
List<string> dynamicParts = [];
|
||||||
|
|
@ -39,25 +45,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
dynamicParts.Add(translatedValue);
|
dynamicParts.Add(translatedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr1], [.. dynamicParts]);
|
__instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
||||||
__instance.settleInfo.font = fontAsset;
|
__instance.settleInfo.font = fontAsset;
|
||||||
}
|
}
|
||||||
else if (regex2.IsMatch(__instance.settleInfo.text))
|
|
||||||
{
|
|
||||||
Match match = regex2.Match(__instance.settleInfo.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
__instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr2], [.. dynamicParts]);
|
|
||||||
__instance.settleInfo.font = fontAsset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using HarmonyLib;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using MelonLoader;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
|
|
@ -30,6 +31,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI text in __instance.transform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,30 @@
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_;
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using BepInEx;
|
||||||
|
using UnityEngine.Experimental.Rendering.RenderGraphModule;
|
||||||
|
using BepInEx.Unity.IL2CPP.Utils;
|
||||||
|
using Unity.VisualScripting.FullSerializer;
|
||||||
|
|
||||||
public class OptionButtonData
|
public class OptionButtonData
|
||||||
{
|
{
|
||||||
public OptionBtn Button { get; set; }
|
public OptionBtn Button { get; set; }
|
||||||
public Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
public Utils.LanguageEnum? Language { get; set; } // Null if it's the "Next" button
|
public Utils.LanguageEnum? Language { get; set; } // Null if it's the "Next" button
|
||||||
|
public Utils.ToggleEnum? Toggle { get; set; } // Null if it's the "Next" button
|
||||||
public bool IsNextButton { get; set; }
|
public bool IsNextButton { get; set; }
|
||||||
|
public bool shifted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
|
|
@ -24,17 +32,25 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
internal class OptLanguageBtn_Patch
|
internal class OptLanguageBtn_Patch
|
||||||
{
|
{
|
||||||
public static Dictionary<int, OptionButtonData> LanguageBtnDict = new();
|
public static Dictionary<int, OptionButtonData> LanguageBtnDict = new();
|
||||||
|
public static Dictionary<int, OptionButtonData> ToggleBtnDict = new();
|
||||||
private static bool buttonsCreated = false;
|
private static bool buttonsCreated = false;
|
||||||
|
private static bool togglesCreated = false;
|
||||||
private static OptionBtn cachedTemplateButton;
|
private static OptionBtn cachedTemplateButton;
|
||||||
|
private static OptionBtn cachedTemplateToggleButton;
|
||||||
|
|
||||||
private const float startX = 4.3241f + 2.56f;
|
private const float startX = 4.3241f + 2.56f;
|
||||||
private const float startY = 2.7769f;
|
private const float startY = 2.7769f;
|
||||||
private const float ySpacing = 1.2505f;
|
private const float ySpacing = 1.2505f;
|
||||||
|
|
||||||
|
private const float toggleStartX = 4.3241f;
|
||||||
|
private const float toggleStartY = -2.2251f;
|
||||||
|
|
||||||
private static List<Utils.LanguageEnum> AvailableLanguages;
|
private static List<Utils.LanguageEnum> AvailableLanguages;
|
||||||
|
private static List<Utils.ToggleEnum> AvailableToggles;
|
||||||
private const int LanguagesPerPage = 5;
|
private const int LanguagesPerPage = 5;
|
||||||
private static int currentPage = 0;
|
private static int currentPage = 0;
|
||||||
private static OptionBtn[] buttonSlots = new OptionBtn[6]; // 5 language buttons + 1 next button
|
private static OptionBtn[] buttonSlots = new OptionBtn[6]; // 5 language buttons + 1 next button
|
||||||
|
private static OptionBtn[] toggleSlots = new OptionBtn[2];
|
||||||
|
|
||||||
public static void CreateLanguageButtons(OptionBtn templateButton)
|
public static void CreateLanguageButtons(OptionBtn templateButton)
|
||||||
{
|
{
|
||||||
|
|
@ -68,10 +84,43 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
UpdatePage();
|
UpdatePage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CreateToggleButtons(OptionBtn templateButton)
|
||||||
|
{
|
||||||
|
if (togglesCreated) return;
|
||||||
|
togglesCreated = true;
|
||||||
|
cachedTemplateToggleButton = templateButton;
|
||||||
|
|
||||||
|
AvailableToggles = Enum.GetValues(typeof(Utils.ToggleEnum))
|
||||||
|
.Cast<Utils.ToggleEnum>()
|
||||||
|
.Where(lang => lang != Utils.ToggleEnum.TOGGLE_END)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var newButton = Object.Instantiate(templateButton, templateButton.transform.parent);
|
||||||
|
newButton.optionType = 100 + i;
|
||||||
|
|
||||||
|
float yPos = toggleStartY - i * ySpacing;
|
||||||
|
Vector3 pos = new(toggleStartX, yPos);
|
||||||
|
newButton.transform.position = pos;
|
||||||
|
|
||||||
|
toggleSlots[i] = newButton;
|
||||||
|
|
||||||
|
ToggleBtnDict[newButton.GetInstanceID()] = new OptionButtonData
|
||||||
|
{
|
||||||
|
Button = newButton,
|
||||||
|
Position = pos
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdatePage();
|
||||||
|
}
|
||||||
|
|
||||||
private static void UpdatePage()
|
private static void UpdatePage()
|
||||||
{
|
{
|
||||||
int startIndex = currentPage * LanguagesPerPage;
|
int startIndex = currentPage * LanguagesPerPage;
|
||||||
int langCount = AvailableLanguages.Count;
|
int langCount = AvailableLanguages.Count;
|
||||||
|
int toggleCount = (togglesCreated) ? AvailableToggles.Count : 0;
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -94,6 +143,30 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (togglesCreated)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
var btn = toggleSlots[i];
|
||||||
|
var data = ToggleBtnDict[btn.GetInstanceID()];
|
||||||
|
|
||||||
|
if (i < toggleCount)
|
||||||
|
{
|
||||||
|
var toggle = AvailableToggles[i];
|
||||||
|
data.Toggle = toggle;
|
||||||
|
data.IsNextButton = false;
|
||||||
|
btn.gameObject.SetActive(true);
|
||||||
|
UpdateButtonText(btn, toggle.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Language = null;
|
||||||
|
data.IsNextButton = false;
|
||||||
|
btn.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// "Next" button always visible at index 5
|
// "Next" button always visible at index 5
|
||||||
var nextBtn = buttonSlots[5];
|
var nextBtn = buttonSlots[5];
|
||||||
var nextData = LanguageBtnDict[nextBtn.GetInstanceID()];
|
var nextData = LanguageBtnDict[nextBtn.GetInstanceID()];
|
||||||
|
|
@ -134,7 +207,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void FlashMessage(OptionBtn button, string message)
|
private static void FlashMessage(OptionBtn button, string message, float yShift = 0.0f)
|
||||||
{
|
{
|
||||||
var child = button.transform.GetChild(0);
|
var child = button.transform.GetChild(0);
|
||||||
if (child != null)
|
if (child != null)
|
||||||
|
|
@ -143,6 +216,19 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
if (text != null)
|
if (text != null)
|
||||||
{
|
{
|
||||||
text.text = message;
|
text.text = message;
|
||||||
|
OptionButtonData data;
|
||||||
|
bool isToggle = ToggleBtnDict.TryGetValue(button.GetInstanceID(), out data);
|
||||||
|
|
||||||
|
if(isToggle)
|
||||||
|
{
|
||||||
|
text.transform.position = new Vector3(text.transform.position.x, text.transform.position.y + (ToggleBtnDict[button.GetInstanceID()].shifted ? 0.0f : yShift), text.transform.position.z);
|
||||||
|
ToggleBtnDict[button.GetInstanceID()].shifted = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text.transform.position = new Vector3(text.transform.position.x, text.transform.position.y + (LanguageBtnDict[button.GetInstanceID()].shifted ? 0.0f : yShift), text.transform.position.z);
|
||||||
|
LanguageBtnDict[button.GetInstanceID()].shifted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
child.gameObject.SetActive(true);
|
child.gameObject.SetActive(true);
|
||||||
|
|
||||||
|
|
@ -156,6 +242,30 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ToggleCustomAssets(string type)
|
||||||
|
{
|
||||||
|
if (type != "Textures" && type != "Audio") return;
|
||||||
|
|
||||||
|
if(type == "Textures")
|
||||||
|
{
|
||||||
|
Utils.customTextures = !Utils.customTextures;
|
||||||
|
ConfigEntry<bool> customTexturesEntry;
|
||||||
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out customTexturesEntry);
|
||||||
|
customTexturesEntry.BoxedValue = !Utils.customTextures;
|
||||||
|
TextureStore.Reload();
|
||||||
|
Coroutine replaceTextureRoutine = Core.MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "Audio")
|
||||||
|
{
|
||||||
|
Utils.customAudio = !Utils.customAudio;
|
||||||
|
ConfigEntry<bool> customAudioEntry;
|
||||||
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out customAudioEntry);
|
||||||
|
customAudioEntry.BoxedValue = !Utils.customAudio;
|
||||||
|
}
|
||||||
|
Core.Instance.Config.Save();
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(OptionBtn))]
|
[HarmonyPatch(typeof(OptionBtn))]
|
||||||
public static class OptLangBtn_Patch
|
public static class OptLangBtn_Patch
|
||||||
{
|
{
|
||||||
|
|
@ -166,7 +276,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
if (!buttonsCreated || cachedTemplateButton == null)
|
if (!buttonsCreated || cachedTemplateButton == null)
|
||||||
{
|
{
|
||||||
buttonsCreated = false;
|
buttonsCreated = false;
|
||||||
|
togglesCreated = false;
|
||||||
CreateLanguageButtons(__instance);
|
CreateLanguageButtons(__instance);
|
||||||
|
CreateToggleButtons(__instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,6 +311,20 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData))
|
||||||
|
{
|
||||||
|
string toggleType = toggleData.Toggle.ToString();
|
||||||
|
ToggleCustomAssets(toggleType);
|
||||||
|
if (toggleType == "Textures")
|
||||||
|
{
|
||||||
|
FlashMessage(toggleData.Button, "<size=10>Toggled custom textures!", 0.1f);
|
||||||
|
}
|
||||||
|
else if (toggleType == "Audio")
|
||||||
|
{
|
||||||
|
FlashMessage(toggleData.Button, "<size=10>Toggled custom audio!", 0.1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(OptionBtn.Update))]
|
[HarmonyPatch(nameof(OptionBtn.Update))]
|
||||||
|
|
@ -209,6 +335,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
{
|
{
|
||||||
btnData.Button.transform.position = btnData.Position;
|
btnData.Button.transform.position = btnData.Position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData))
|
||||||
|
{
|
||||||
|
toggleData.Button.transform.position = toggleData.Position;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -9,12 +8,17 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(MainMenu))]
|
[HarmonyPatch(typeof(MainMenu))]
|
||||||
public class MainMenu_Patch
|
public class MainMenu_Patch
|
||||||
{
|
{
|
||||||
|
private static bool _warningShown = false;
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(MainMenu.FixedUpdate))]
|
[HarmonyPatch(nameof(MainMenu.FixedUpdate))]
|
||||||
private static void FixedUpdate(MainMenu __instance)
|
private static void FixedUpdate(MainMenu __instance)
|
||||||
{
|
{
|
||||||
NoticeMenu noticeMenu = NoticeMenu.Instance;
|
if (_warningShown || NoticeMenu.Instance == null)
|
||||||
WarningStore.WarningReload(Utils.Language, noticeMenu);
|
return;
|
||||||
|
|
||||||
|
WarningStore.WarningReload(Utils.Language, NoticeMenu.Instance);
|
||||||
|
_warningShown = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
|
|
|
||||||
20
BepInEx/Patches/GameObjects/OtherMenu_Patch.cs
Normal file
20
BepInEx/Patches/GameObjects/OtherMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(OtherMenu))]
|
||||||
|
public static class OtherMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(OtherMenu.UpdateText))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void UpdateText(OtherMenu __instance)
|
||||||
|
{
|
||||||
|
__instance.text1 = StringStore.TranslateText(__instance.text1);
|
||||||
|
__instance.text2 = StringStore.TranslateText(__instance.text2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,27 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(TravelBuffOptionButton __instance)
|
||||||
|
{
|
||||||
|
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||||
|
{
|
||||||
|
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TravelBuffOptionButton.SetBackground))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetBackground(TravelBuffOptionButton __instance)
|
||||||
|
{
|
||||||
|
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||||
|
}
|
||||||
//[HarmonyPatch(nameof(TravelMenuMgr.SetText))]
|
//[HarmonyPatch(nameof(TravelMenuMgr.SetText))]
|
||||||
//[HarmonyPostfix]
|
//[HarmonyPostfix]
|
||||||
//private static void SetText(TravelMenuMgr __instance)
|
//private static void SetText(TravelMenuMgr __instance)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
|
|
@ -24,6 +23,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
StringStore.TranslateTextTransform(moneyTransform);
|
StringStore.TranslateTextTransform(moneyTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI text in __instance.points)
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelStore.SetText), new Type[] { typeof(string)})]
|
[HarmonyPatch(nameof(TravelStore.SetText), new Type[] { typeof(string)})]
|
||||||
|
|
@ -34,6 +38,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
text.text = StringStore.TranslateText(text.text);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI text in __instance.points)
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
string difficultyText = StringStore.patchesStore["Difficulty"][Utils.Language.ToString()];
|
__instance.t.text = StringStore.TranslateText(__instance.t.text);
|
||||||
__instance.t.text = string.Format(difficultyText + " {0}", GameAPP.difficulty);
|
|
||||||
#else
|
#else
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
||||||
string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"];
|
string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"];
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
string zombieText = StringStore.patchesStore["Zombies"][Utils.Language.ToString()];
|
string zombieText = StringStore.TranslateText(__instance.t.text);
|
||||||
__instance.t.text = string.Format(zombieText + " {0}", Board.Instance.enermyCount);
|
__instance.t.text = zombieText;
|
||||||
#else
|
#else
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
||||||
string zombieText = StringStore.patchesStore["Zombies"]["Spanish"];
|
string zombieText = StringStore.patchesStore["Zombies"]["Spanish"];
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System.IO;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.IO;
|
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
{
|
{
|
||||||
|
|
@ -12,8 +11,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
public static partial class AlmanacMgrZombie_Patch
|
public static partial class AlmanacMgrZombie_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(AlmanacMgrZombie.InitNameAndInfoFromJson))]
|
[HarmonyPatch(nameof(AlmanacMgrZombie.InitNameAndInfoFromJson))]
|
||||||
[HarmonyPrefix]
|
[HarmonyPostfix]
|
||||||
private static bool InitNameAndInfoFromJson(AlmanacMgrZombie __instance)
|
private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance)
|
||||||
{
|
{
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
string currentLanguage = Utils.Language.ToString();
|
string currentLanguage = Utils.Language.ToString();
|
||||||
|
|
@ -23,18 +22,19 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
string currentLanguage = "English";
|
string currentLanguage = "English";
|
||||||
#endif
|
#endif
|
||||||
string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json");
|
string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json");
|
||||||
|
string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json");
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}");
|
Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}");
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OBFUSCATE
|
#if OBFUSCATE
|
||||||
if (CheckSumStore.IsModified(path))
|
if (CheckSumStore.IsModified(path))
|
||||||
{
|
{
|
||||||
Log.LogError("File {0} was modified!", path);
|
Log.LogError("File {0} was modified!", path);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -78,12 +78,38 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
component.font = fontAsset;
|
component.font = fontAsset;
|
||||||
component2.font = fontAsset;
|
component2.font = fontAsset;
|
||||||
component3.font = fontAsset;
|
component3.font = fontAsset;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
if (File.Exists(moddedPath))
|
||||||
|
{
|
||||||
|
string moddedJson;
|
||||||
|
moddedJson = File.ReadAllText(moddedPath);
|
||||||
|
|
||||||
|
AlmanacMgrZombie.ZombieAlmanacData moddedZombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(moddedJson);
|
||||||
|
|
||||||
|
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in moddedZombieData.zombies)
|
||||||
|
{
|
||||||
|
if (zombieInfo.theZombieType == __instance.theZombieType)
|
||||||
|
{
|
||||||
|
component.text = zombieInfo.info + "\n\n" + zombieInfo.introduce;
|
||||||
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
component2.text = zombieInfo.name;
|
||||||
|
component2.autoSizeTextContainer = true;
|
||||||
|
component3.text = Utils.RemoveColorTags(zombieInfo.name);
|
||||||
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
if (hasAlmanacFont)
|
||||||
|
component.font = almanacFontAsset;
|
||||||
|
else
|
||||||
|
component.font = fontAsset;
|
||||||
|
component2.font = fontAsset;
|
||||||
|
component3.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AlmanacMgrZombie.OnMouseDown))]
|
[HarmonyPatch(nameof(AlmanacMgrZombie.OnMouseDown))]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using TMPro;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||||
|
|
@ -23,6 +22,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
string currentLanguage = "English";
|
string currentLanguage = "English";
|
||||||
#endif
|
#endif
|
||||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||||
|
string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json");
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
|
|
@ -70,12 +70,13 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
||||||
component.overflowMode = TextOverflowModes.Page;
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
|
||||||
//fix dimensions for cost text
|
// fix dimensions for cost text
|
||||||
component.rectTransform.offsetMax = new Vector2(component.rectTransform.offsetMax.x, 27.3839f);
|
component.rectTransform.offsetMax = new Vector2(component.rectTransform.offsetMax.x, 27.3839f);
|
||||||
component.rectTransform.offsetMin = new Vector2(component.rectTransform.offsetMin.x, -29.3079f);
|
component.rectTransform.offsetMin = new Vector2(component.rectTransform.offsetMin.x, -29.3079f);
|
||||||
component.rectTransform.sizeDelta = new Vector2(component.rectTransform.sizeDelta.x, 50.917f);
|
component.rectTransform.sizeDelta = new Vector2(component.rectTransform.sizeDelta.x, 50.917f);
|
||||||
component.transform.localPosition = new Vector3(component.transform.localPosition.x, component.transform.localPosition.y + 0.15f, component.transform.localPosition.z);
|
component.transform.localPosition = new Vector3(component.transform.localPosition.x, component.transform.localPosition.y + 0.15f, component.transform.localPosition.z);
|
||||||
|
|
||||||
|
|
||||||
component2.text = plantInfo.name;
|
component2.text = plantInfo.name;
|
||||||
component2.autoSizeTextContainer = true;
|
component2.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
|
@ -99,6 +100,52 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (File.Exists(moddedPath))
|
||||||
|
{
|
||||||
|
string moddedJson;
|
||||||
|
moddedJson = File.ReadAllText(moddedPath);
|
||||||
|
|
||||||
|
AlmanacPlantBank.PlantData moddedPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(moddedJson);
|
||||||
|
|
||||||
|
foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants)
|
||||||
|
{
|
||||||
|
if (plantInfo.seedType == __instance.theSeedType)
|
||||||
|
{
|
||||||
|
component.autoSizeTextContainer = false;
|
||||||
|
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
||||||
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
|
||||||
|
// fix dimensions for cost text
|
||||||
|
component.rectTransform.offsetMax = new Vector2(component.rectTransform.offsetMax.x, 27.3839f);
|
||||||
|
component.rectTransform.offsetMin = new Vector2(component.rectTransform.offsetMin.x, -29.3079f);
|
||||||
|
component.rectTransform.sizeDelta = new Vector2(component.rectTransform.sizeDelta.x, 50.917f);
|
||||||
|
component.transform.localPosition = new Vector3(component.transform.localPosition.x, component.transform.localPosition.y + 0.15f, component.transform.localPosition.z);
|
||||||
|
|
||||||
|
|
||||||
|
component2.text = plantInfo.name;
|
||||||
|
component2.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
component3.text = Utils.RemoveColorTags(plantInfo.name);
|
||||||
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
component4.text = plantInfo.cost;
|
||||||
|
|
||||||
|
if (hasAlmanacFont)
|
||||||
|
{
|
||||||
|
component.font = almanacFontAsset;
|
||||||
|
component4.font = almanacFontAsset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
component.font = fontAsset;
|
||||||
|
component4.font = fontAsset;
|
||||||
|
}
|
||||||
|
component2.font = fontAsset;
|
||||||
|
component3.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using System.IO;
|
using HarmonyLib;
|
||||||
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@
|
||||||
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
|
<PackageReference Include="BepInEx.PluginInfoProps" Version="2.*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG</DefineConstants>
|
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -75,26 +81,14 @@
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMulti|AnyCPU'">
|
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMulti|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMulti|x64'">
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMulti|x64'">
|
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMulti|ARM64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseMulti|ARM64'">
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugMulti|ARM64'">
|
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE</DefineConstants>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseOther|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseOther|AnyCPU'">
|
||||||
<DefineConstants>$(DefineConstants);OTHER;OBFUSCATE</DefineConstants>
|
<DefineConstants>$(DefineConstants);OTHER;OBFUSCATE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -111,6 +105,83 @@
|
||||||
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE;RELEASE</DefineConstants>
|
<DefineConstants>$(DefineConstants);MULTI_LANGUAGE;OBFUSCATE;RELEASE</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AssetStore\CheckSumStore.cs" />
|
||||||
|
<Compile Include="AssetStore\FontStore.cs" />
|
||||||
|
<Compile Include="AssetStore\StringStore.cs" />
|
||||||
|
<Compile Include="AssetStore\TextureStore.cs" />
|
||||||
|
<Compile Include="AssetStore\WarningStore.cs" />
|
||||||
|
<Compile Include="Core.cs" />
|
||||||
|
<Compile Include="FileLoader.cs" />
|
||||||
|
<Compile Include="FontHandler.cs" />
|
||||||
|
<Compile Include="Log.cs" />
|
||||||
|
<Compile Include="ModFeatures.cs" />
|
||||||
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\BaseMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\CustomLevelEnter_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\SaveMenuBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MainMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\AbyssGoods_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\DY_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\LanternUmbrella_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\MagnetBox_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\MagnetInterface_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\Money_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
|
||||||
|
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\EveBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||||
|
<Compile Include="Patches\OtherManagers\GardenUI_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\NoticePauseMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\InGameUIMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\OptLanguageBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\PauseMenu_Btn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\PVPPotBtn_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\SelectYourPlants_Patch.cs" />
|
||||||
|
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||||
|
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||||
|
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TravelBuff_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TravelRefresh_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TravelStore_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\Plant_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\PlayerName_Patch.cs" />
|
||||||
|
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||||
|
<Compile Include="Utils.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>$(GamePath)\BepInEx\core\0Harmony.dll</HintPath>
|
<HintPath>$(GamePath)\BepInEx\core\0Harmony.dll</HintPath>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using BepInEx;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Unity.VisualScripting.FullSerializer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Experimental.Rendering;
|
using UnityEngine.Experimental.Rendering;
|
||||||
|
|
||||||
|
|
@ -20,7 +23,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
ImageConversion.LoadImage(ogTexture, File.ReadAllBytes(texturePath));
|
ImageConversion.LoadImage(ogTexture, File.ReadAllBytes(texturePath));
|
||||||
|
|
||||||
Log.LogDebug("OK! Replaced Texture " + ogTexture.name);
|
Core.Log.LogDebug("OK! Replaced Texture " + ogTexture.name);
|
||||||
|
|
||||||
ogTexture.name = "replaced_" + ogTexture.name;
|
ogTexture.name = "replaced_" + ogTexture.name;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -77,6 +80,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
return Regex.Replace(text, @"<color=[^>]+>", "");
|
return Regex.Replace(text, @"<color=[^>]+>", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
internal static void ChangeLanguage(string language)
|
internal static void ChangeLanguage(string language)
|
||||||
{
|
{
|
||||||
OldLanguage = Language;
|
OldLanguage = Language;
|
||||||
|
|
@ -97,9 +101,19 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
TextureStore.Reload();
|
TextureStore.Reload();
|
||||||
FileLoader.SaveLanguage();
|
FileLoader.SaveLanguage();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
public static Utils.LanguageEnum OldLanguage;
|
public static Utils.LanguageEnum OldLanguage;
|
||||||
|
#endif
|
||||||
|
|
||||||
public static Utils.LanguageEnum Language;
|
public static Utils.LanguageEnum Language;
|
||||||
|
|
||||||
|
public static string mainCategory = "PvZ_Fusion_Translator";
|
||||||
|
|
||||||
|
public static bool customTextures = !Core.Instance.configDefaultTextures.Value;
|
||||||
|
public static bool customAudio = !Core.Instance.configDefaultAudio.Value;
|
||||||
|
|
||||||
public enum LanguageEnum
|
public enum LanguageEnum
|
||||||
{
|
{
|
||||||
// first column
|
// first column
|
||||||
|
|
@ -121,8 +135,18 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
// third column
|
// third column
|
||||||
// Ukrainian,
|
// Ukrainian,
|
||||||
// Slovak,
|
// Slovak,
|
||||||
|
Polish,
|
||||||
|
Hungarian,
|
||||||
|
Arabic,
|
||||||
|
|
||||||
LANG_END
|
LANG_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ToggleEnum
|
||||||
|
{
|
||||||
|
Textures,
|
||||||
|
Audio,
|
||||||
|
TOGGLE_END
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -23,17 +23,9 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
|
||||||
bool loadCustomAudio = MelonPreferences.GetEntryValue<bool>("PvZ_Fusion_Translator", "DefaultAudio");
|
|
||||||
if (loadCustomAudio)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
LoadAudios();
|
LoadAudios();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
public static void LoadAudios()
|
public static void LoadAudios()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(customAudioPath))
|
if (!Directory.Exists(customAudioPath))
|
||||||
|
|
@ -157,6 +149,8 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
|
|
||||||
|
|
||||||
public static void AudioPlayPatch(AudioSource __instance)
|
public static void AudioPlayPatch(AudioSource __instance)
|
||||||
|
{
|
||||||
|
if(Utils.customAudio)
|
||||||
{
|
{
|
||||||
if (__instance.clip == null)
|
if (__instance.clip == null)
|
||||||
return;
|
return;
|
||||||
|
|
@ -178,4 +172,5 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
RestoreTextures();
|
RestoreTextures();
|
||||||
#endif
|
#endif
|
||||||
FileLoader.LoadDefaultTextures();
|
|
||||||
FileLoader.LoadTextures();
|
FileLoader.LoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,11 +96,7 @@ namespace PvZ_Fusion_Translator
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (loadDefaultTextures == true)
|
if (Utils.customTextures)
|
||||||
{
|
|
||||||
LoadDefaultTextures();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
LoadCustomTextures();
|
LoadCustomTextures();
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +163,7 @@ namespace PvZ_Fusion_Translator
|
||||||
|
|
||||||
internal static void LoadDefaultTextures()
|
internal static void LoadDefaultTextures()
|
||||||
{
|
{
|
||||||
if(Utils.customTextures)
|
if(Utils.customTextures == false)
|
||||||
{
|
{
|
||||||
string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]");
|
string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]");
|
||||||
if (!Directory.Exists(textureDefaultDir))
|
if (!Directory.Exists(textureDefaultDir))
|
||||||
|
|
|
||||||
|
|
@ -240,8 +240,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
|
|
||||||
if(type == "Textures")
|
if(type == "Textures")
|
||||||
{
|
{
|
||||||
Utils.customTextures = (Utils.customTextures) ? false : true;
|
Utils.customTextures = !Utils.customTextures;
|
||||||
MelonPreferences.SetEntryValue<bool>("PvZ_Fusion_Translator", "DefaultTextures", !Utils.customTextures);
|
MelonPreferences.SetEntryValue<bool>("PvZ_Fusion_Translator", "DefaultTextures", !Utils.customTextures);
|
||||||
|
TextureStore.Reload();
|
||||||
|
object replaceTextureRoutine = MelonCoroutines.Start(TextureStore.ReplaceTexturesCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "Audio")
|
if (type == "Audio")
|
||||||
|
|
@ -304,11 +306,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
ToggleCustomAssets(toggleType);
|
ToggleCustomAssets(toggleType);
|
||||||
if (toggleType == "Textures")
|
if (toggleType == "Textures")
|
||||||
{
|
{
|
||||||
FlashMessage(toggleData.Button, "<size=10>Toggled custom textures! (Restart game to apply changes.)", 0.1f);
|
FlashMessage(toggleData.Button, "<size=10>Toggled custom textures!", 0.1f);
|
||||||
}
|
}
|
||||||
else if (toggleType == "Audio")
|
else if (toggleType == "Audio")
|
||||||
{
|
{
|
||||||
FlashMessage(toggleData.Button, "<size=10>Toggled custom audio! (Restart game to apply changes.)", 0.1f);
|
FlashMessage(toggleData.Button, "<size=10>Toggled custom audio!", 0.1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue