diff --git a/.gitignore b/.gitignore index 5966056..25ee30e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,137 +1,406 @@ -################################################################################ -# This .gitignore file was automatically created by Microsoft(R) Visual Studio. -################################################################################ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore -/.vs/BepInEx/copilot-chat/bff105b7/sessions -/.vs -/bin -/obj -/MelonLoader/obj -/BepInEx/obj/Debug/net6.0 -/BepInEx/obj -/BepInEx/bin/ReleaseMulti/net6.0 -/AlmanacPlantBank_Patch.cs -/MelonLoader/bin/x64/Debug -/BepInEx/bin/Debug/net6.0 -.HOWTO-sync-MelonLoader-from-origin-main.txt -/MelonLoader/bin/ReleaseMulti/net6.0 -MelonLoader/bin/Debug/net6.0/WebSocketDotNet.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.XRModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.WindModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.VRModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.VideoModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.VFXModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.VehiclesModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityWebRequestWWWModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityWebRequestTextureModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityWebRequestModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityWebRequestAudioModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityWebRequestAssetBundleModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityTestProtocolModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityCurlModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityConnectModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityAnalyticsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UnityAnalyticsCommonModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UmbraModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UIModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UIElementsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.UI.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TLSModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TilemapModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TextRenderingModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TextCoreTextEngineModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TextCoreFontEngineModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TerrainPhysicsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.TerrainModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.SubsystemsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.SubstanceModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.StreamingModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.SpriteShapeModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.SpriteMaskModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.SharedInternalsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ScreenCaptureModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.PropertiesModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ProfilerModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.PhysicsModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.Physics2DModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.PerformanceReportingModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ParticleSystemModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.LocalizationModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.JSONSerializeModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.InputModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.InputLegacyModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.IMGUIModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ImageConversionModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.HotReloadModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.GridModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.GIModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.GameCenterModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.DSPGraphModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.DirectorModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.CrashReportingModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.CoreModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ContentLoadModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ClothModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AudioModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AssetBundleModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.ARModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AnimationModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AndroidJNIModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AIModule.dll -MelonLoader/bin/Debug/net6.0/UnityEngine.AccessibilityModule.dll -MelonLoader/bin/Debug/net6.0/Unity.VisualScripting.Core.dll -MelonLoader/bin/Debug/net6.0/Unity.TextMeshPro.dll -MelonLoader/bin/Debug/net6.0/Unity.RenderPipelines.Universal.Runtime.dll -MelonLoader/bin/Debug/net6.0/Unity.RenderPipelines.Core.Runtime.dll -MelonLoader/bin/Debug/net6.0/Unity.RenderPipeline.Universal.ShaderLibrary.dll -MelonLoader/bin/Debug/net6.0/Unity.Mathematics.dll -MelonLoader/bin/Debug/net6.0/Unity.InternalAPIEngineBridge.001.dll -MelonLoader/bin/Debug/net6.0/Unity.Collections.LowLevel.ILSupport.dll -MelonLoader/bin/Debug/net6.0/Unity.Collections.dll -MelonLoader/bin/Debug/net6.0/Unity.Burst.Unsafe.dll -MelonLoader/bin/Debug/net6.0/Unity.Burst.dll -MelonLoader/bin/Debug/net6.0/Unity.2D.SpriteShape.Runtime.dll -MelonLoader/bin/Debug/net6.0/Unity.2D.Common.Runtime.dll -MelonLoader/bin/Debug/net6.0/Unity.2D.Animation.Runtime.dll -MelonLoader/bin/Debug/net6.0/Tomlet.dll -MelonLoader/bin/Debug/net6.0/PvZ_Fusion_Translator.pdb -MelonLoader/bin/Debug/net6.0/PvZ_Fusion_Translator.dll -MelonLoader/bin/Debug/net6.0/PvZ_Fusion_Translator.deps.json -MelonLoader/bin/Debug/net6.0/MonoMod.Utils.dll -MelonLoader/bin/Debug/net6.0/MonoMod.RuntimeDetour.dll -MelonLoader/bin/Debug/net6.0/MonoMod.ILHelpers.dll -MelonLoader/bin/Debug/net6.0/MonoMod.Backports.dll -MelonLoader/bin/Debug/net6.0/Mono.Cecil.Rocks.dll -MelonLoader/bin/Debug/net6.0/Mono.Cecil.Pdb.dll -MelonLoader/bin/Debug/net6.0/Mono.Cecil.Mdb.dll -MelonLoader/bin/Debug/net6.0/Mono.Cecil.dll -MelonLoader/bin/Debug/net6.0/Microsoft.Extensions.Logging.Abstractions.dll -MelonLoader/bin/Debug/net6.0/Microsoft.Diagnostics.Runtime.dll -MelonLoader/bin/Debug/net6.0/Microsoft.Diagnostics.NETCore.Client.dll -MelonLoader/bin/Debug/net6.0/MelonLoader.xml -MelonLoader/bin/Debug/net6.0/MelonLoader.pdb -MelonLoader/bin/Debug/net6.0/MelonLoader.dll -MelonLoader/bin/Debug/net6.0/Il2CppSystem.Xml.dll -MelonLoader/bin/Debug/net6.0/Il2CppSystem.dll -MelonLoader/bin/Debug/net6.0/Il2CppSystem.Core.dll -MelonLoader/bin/Debug/net6.0/Il2CppSystem.Configuration.dll -MelonLoader/bin/Debug/net6.0/Il2Cppmscorlib.dll -MelonLoader/bin/Debug/net6.0/Il2CppMono.Security.dll -MelonLoader/bin/Debug/net6.0/Il2CppInterop.Runtime.dll -MelonLoader/bin/Debug/net6.0/Il2CppInterop.HarmonySupport.dll -MelonLoader/bin/Debug/net6.0/Il2CppInterop.Generator.dll -MelonLoader/bin/Debug/net6.0/Il2CppInterop.Common.dll -MelonLoader/bin/Debug/net6.0/Il2Cpp__Generated.dll -MelonLoader/bin/Debug/net6.0/bHapticsLib.dll -MelonLoader/bin/Debug/net6.0/AudioImportLib.dll -MelonLoader/bin/Debug/net6.0/AssetsTools.NET.dll -MelonLoader/bin/Debug/net6.0/AssetRipper.Primitives.dll -MelonLoader/bin/Debug/net6.0/Assembly-CSharp.dll -MelonLoader/bin/Debug/net6.0/AsmResolver.PE.File.dll -MelonLoader/bin/Debug/net6.0/AsmResolver.PE.dll -MelonLoader/bin/Debug/net6.0/AsmResolver.DotNet.dll -MelonLoader/bin/Debug/net6.0/AsmResolver.dll -MelonLoader/bin/Debug/net6.0/0Harmony.dll -/MelonLoader/bin +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +# Emik.Morsels symlinks +/Directory.Build.local.props +/Directory.Build.props +/Directory.Build.targets +/global.json +/stylecop.json diff --git a/.idea/.idea.PvZ Fusion Translator/.idea/material_theme_project_new.xml b/.idea/.idea.PvZ Fusion Translator/.idea/material_theme_project_new.xml new file mode 100644 index 0000000..301d842 --- /dev/null +++ b/.idea/.idea.PvZ Fusion Translator/.idea/material_theme_project_new.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/BepInEx/AssetStore/AudioStore.cs b/BepInEx/AssetStore/AudioStore.cs deleted file mode 100644 index 6bc8c04..0000000 --- a/BepInEx/AssetStore/AudioStore.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using UnityEngine; -using AudioImportLib.BepInEx; -using BepInEx.Logging; -using System.Runtime; -using System.Runtime.InteropServices; -using System.Reflection; -using System.IO; -using BepInEx; -using BepInEx.Configuration; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - internal class AudioStore - { - public static Dictionary AudioClips = []; - public static Dictionary AudioClipNames = []; - public static ManualLogSource Log = Core.Log; - - public static ConfigEntry LogSounds; - public static ConfigEntry category; - - private static bool overrideEnabled; - public static string customAudioPath = Path.Combine(Paths.PluginPath, "PvZ_Fusion_Translator", "[Custom Audios]"); - private static readonly string[] allowedExts = [".wav", ".mp3", ".ogg"]; - -#if AUDIO_TESTING - public Canvas Canvas { get; set; } - public RectTransform songRectTransform { get; private set; } -#endif - - public static void Init() - { - LoadAudios(); - } - public static void LoadAudios() - { - try - { - // Clear existing dictionaries to prevent duplicate key errors - AudioClips.Clear(); - AudioClipNames.Clear(); - - if (!Directory.Exists(customAudioPath)) - Directory.CreateDirectory(customAudioPath); - - string[] audioFiles = Directory.GetFiles(customAudioPath, "*", SearchOption.AllDirectories); - var ovrClip = audioFiles.SingleOrDefault(f => Path.GetFileNameWithoutExtension(f) == "REPLACE_ALL"); - if (ovrClip == null) - { - foreach (string file in audioFiles) - { - if (!allowedExts.Contains(Path.GetExtension(file))) - continue; - - AudioClip clip = AudioImportLib.BepInEx.API.LoadAudioClip(file); - AudioClips.Add(clip.name, clip); - Log.LogInfo("Added Override: " + clip.name); - } - } - else - { - AudioClip clip = AudioImportLib.BepInEx.API.LoadAudioClip(ovrClip); - AudioClips.Add(clip.name, clip); - overrideEnabled = true; - Log.LogInfo("Added Override: " + clip.name); - } - } - catch (Exception ex) - { - Log.LogError($"Error loading audio clips: {ex.Message}"); - } - } - -#if AUDIO_TESTING - public static void InitializeCanvas() - { - - Transform canvasTransform; - - if (canvas != null) return; // Prevent duplicate canvas creation - - canvas = new GameObject("AudioSourceCanvas").AddComponent(); - canvas.renderMode = RenderMode.ScreenSpaceOverlay; - - CanvasScaler scaler = canvas.gameObject.AddComponent(); - scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; - scaler.referenceResolution = new Vector2(1920, 1080); - - canvas.gameObject.AddComponent(); - - // Add a RectTransform for positioning text - GameObject songTextObject = new GameObject("SongText"); - songTextObject.transform.SetParent(canvas.transform); - - songRectTransform = songTextObject.AddComponent(); - songRectTransform.anchorMin = new Vector2(1, 1); // Top-right corner - songRectTransform.anchorMax = new Vector2(1, 1); - songRectTransform.pivot = new Vector2(1, 1); - songRectTransform.anchoredPosition = new Vector2(-20, -20); // Adjust margin - - // Add a TextMeshPro component for the text - var textComponent = songTextObject.AddComponent(); - textComponent.alignment = TextAlignmentOptions.Right; - textComponent.fontSize = 24; - textComponent.color = Color.white; - textComponent.text = "Current Song: None"; // Placeholder - } - - - public static void AudioSources() - { - if (!Directory.Exists(customAudioPath)) - Directory.CreateDirectory(customAudioPath); - string path = Path.Combine(customAudioPath, "audio_source.json"); - if (!File.Exists(path)) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - return; - } - string json; - json = File.ReadAllText(path); - - AudioClipNames = JsonSerializer.Deserialize>(json); - } - - public static (string, string) GetAudioSource(string clipName) - { - if (AudioClipNames.TryGetValue(clipName, out var audioSource)) - { - return audioSource; - } - else - { - return ("Music", "Source Unknown"); - } - } - - - public static void UpdateAudioSourceText(string clipName, string sourceName) - { - if (songRectTransform == null) InitializeCanvas(); - - var textComponent = songRectTransform.GetComponent(); - if (textComponent != null) - { - textComponent.text = $"Current Song: {clipName}\nSource: {sourceName}"; - } - } -#endif - - [HarmonyPatch(typeof(AudioSource), "Play", [])] - public class AudioSource_Patch - { - public static void Prefix(AudioSource __instance) - { - if (Utils.customAudio) - { - if (__instance.clip == null) - return; - - string audioClipName = overrideEnabled ? "REPLACE_ALL" : __instance.clip.name; - - if (AudioClips.TryGetValue(audioClipName, out AudioClip replaceClip)) - { - __instance.pitch = 1; - - __instance.clip = replaceClip; - } - } - } - } - } -} \ No newline at end of file diff --git a/BepInEx/AssetStore/CheckSumStore.cs b/BepInEx/AssetStore/CheckSumStore.cs deleted file mode 100644 index 7ff0704..0000000 --- a/BepInEx/AssetStore/CheckSumStore.cs +++ /dev/null @@ -1,862 +0,0 @@ -#if OBFUSCATE -using System.Security.Cryptography; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.IO; -using static Newtonsoft.Json.JsonConvert; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using System.Collections.Generic; -using System; - -namespace PvZ_Fusion_Translator__BepInEx_.AssetStore -{ - internal class CheckSumStore - { - private static Dictionary modifiedCheckSums = new Dictionary(); - - private static Dictionary checkSums = new Dictionary() - { - #if !RELEASE || RELEASE - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_CloseButton" , "G/++rbb7GMZv51CxHKdVINtAji/x9zyyhlcbCCWyP2s=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_CloseButtonHighlight" , "nNygYVELdiLcY0xbk0I1uX92NRazxns+I1u7p0M/e4w=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundDay" , "pExENxFbAGfBzLByFps1SX9AN1H6cL0QQK0jOFn3qu8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundNight" , "n3LXi5yONzLVTc0eNStQtLdlcEsihCi5iImxbB7rMdY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundNightPool" , "fe6efxJzsAn3i75Wg7WrCyAFVQhMKXnzh+uThkCJXV4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundPool" , "yKlIHtnBPI8tiUnlRCHYcCnqwarpiuzfOj4H3yGn40o=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundRoof" , "cYTj11LkhWuJxO8j4h+s6+AG4JtgfZ2jfL4P/rWzGfc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_Imitater" , "9BD3A5dWXxgklYK4TTQ/G7d8A8OtZHgZrnq3hIrSlDY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexBack" , "KqSOHoWk3g/Vd1vtwL1X5X33ft8TkxHnupydPB/f8lI=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexButton" , "GWE8iGEa9rVJW3TGG0j2la9VwlxrJ/LfnLu0OMKxMZg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexButtonHighlight" , "kbz2ezXWjIGUC7Q0k3cagXMuRLpnU7l4xGiX7WdSMJE=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_PlantCard" , "lLnAYniK6sDgRW62t1Q/GGh9zIWkBOia+oFzntBBjx8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieBack" , "r3fcC00ZRR8vQUTsPRj339mQZi4/pFcL4rewSbRtM7E=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieCard" , "Fp2qKy2IpiEkA1hZrgXgrxyOA6hteIEQ8sqPrOkaaI4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieWindow" , "mRlpQuXwIiUhKwkZXcK8sDZ6aQKnl43Y5Pbw5NMsKmk=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieWindow2" , "GPvh5nRvUqJMjRHwhqC4SUUB3BUKfCgTk6AWO8eGq/M=" }, - { "Dumps\\Default Textures [Do Not Remove]\\CursorClick" , "r7q8kCmXo9FHCC00VPswxjsGba2OMpE4UzBByode7KI=" }, - { "Dumps\\Default Textures [Do Not Remove]\\CursorDefault" , "xUv6VFWl/tzVsUa5heAlzlOyFjdzXsX9kT7EobZTIFQ=" }, - { "Dumps\\Default Textures [Do Not Remove]\\garden_new" , "jkDprxF6ApST91S4TzAGyzj2MC9umC8XCaasbstkBt8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\MainMenu" , "e2lbkFcEN6hqwDk3A0SHZJu7PwEcol1u/QZtvpq71gc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\MainMenutravel" , "fvORSzOzZ6sNDHL3qC/eA7tExSe/TsLIBswcuuFgFZ4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\plant" , "ophzSlF5tmOXKn/2lHZUYiE4pMibPTqBvfQMnuBSzb8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Present" , "YHoZLVSxMkA8c2u2RCP1tJbFFZZxeulpuGTGp7AtpWA=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentOpen" , "TL+KhicnGWIIOcEyMdTErS1SyBO5citeF37g3CxRiuo=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentOpenZ" , "Ij60phw5j3rhjwMyGiVUOuvp0lelEJqtYQHEECc6l14=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentZ" , "fZF3EH0YB37P7j1LBJN9jIwniyCy1Oe2Tw2BsSGc4iA=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedBank" , "BjG7XCi4XIPZO+NHAgksjgSUoO3JPJrL7BGFEWNaQ0A=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Background" , "RB2fot78wqAGxeIIBuG8ZEnytADs/yxhdh3Jre74nMo=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button" , "/KtMBXY5AmPsmt98HVMAuoDrocKr7s/+g7/6wfMJIxY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button2" , "JYwHTIvcmX8NS1wxlb7u1nMPG4BRA2mgm6R2IM/9NXk=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button2_Glow" , "NRov8DgO5+9rqTXQASV8izLAp302/o5ufZgVrvb7aig=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button_Disabled" , "nvfQ1CN+p9h1rUqVhOOLAlCmsdehs2qgVz6kmWERGkU=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button_Glow" , "Wg8LhHovWpNtScBLZbhcjgqQcr4C2pehb3QS2bpmO1Y=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedfog" , "SN9MPqY76N6ucf+vzs22J+2Bs23+1Tl56f7GrT3Z9Yc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedlinkage" , "kqQiioaMU/fAv9+eTzdzV7KizreB80Qio2e9cyWtaOY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedp" , "i7wDlTSmSBueQ2sCWU7usRbfGoncupi6+plQrjv9A8w=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacketSilhouette" , "AVSM7MUReK4oLDUajmkWjQqT577of/ZhaAepDOQk54o=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Larger" , "C7ZuQNW+xi8YNyYtz09aAXOYP/t56u01WwgYo7FT0Tc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Night" , "YVCLQ3WeIUjevo0Wtf2xAOnDGAAzjl44bRHS1T5ProE=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Other" , "kiidD0VdJ/U0xYxtM7f9uvUYsK2VHFIZU3750doVtHc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Pool" , "8MQOevWJrWgIsnWhYi2xt61yxoJARcINzSYzRG7yrnM=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedroof" , "zluDS1sgaJ4iHXt4PfJ3tqi+LVduGKB9+WLdWZZH0ik=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seeds" , "JNHpZfk3qR+yWd4fhWsdNF+JxtfTOjTAKxLs61X0+co=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_almanac_shadow" , "SdZZ5VOq567+489ffjHcTbgWj3KjI01YKZgdUGj9yis=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Flower3" , "kIzmQGfYT3nCObTtM+C6F7WgE8oCj4M+Qq2II0n2IXw=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf1" , "OwGYCIlBbK5j1dZxBjHlPkvswRy+QHgYVXvmOYoMt6E=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf2" , "0ea/nJV5ziIA2Aher2Exfgz6lDuGDjqHf6Ra/bsmMrg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf3" , "nzELmsj1XUXJmOhMLixHLBzW5TGhZCkwoAOaRpRJlYw=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf4" , "pXEZUhFqr2KC1pCQLB6MwwJhBM5ZI2teGOvYPgr011U=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf5" , "SeX0iGZoN8ZbhKZSkonw9I7MS3lBVHVqzko1hX80LUg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaves" , "Fny+WEQ2N1yzFhdAPhR/zoK0P2HY4GDckluVL6u6Kz0=" }, - { "Dumps\\Default Textures [Do Not Remove]\\ShovelBank" , "Pas2yhjcl+HVwsIm68o9PRjAR72y5lTQm85e2vuYgBE=" }, - - // English - { "Localization\\English\\Textures\\Game\\FinalWave" , "0O9Esd6GUDRmYE9NtcuIvmRzZU6RKUeR4U6Xiy5qi6o=" }, - { "Localization\\English\\Textures\\Game\\FlagMeterLevelProgress" , "CzuBH4sm7Nid4zloZF3i0bpNcA9ILPhrmOxVYI4IggA=" }, - { "Localization\\English\\Textures\\Game\\HugeWave" , "n9O7b5CuD9Yu+ccecqsmm4ofp10MAw6eoZmIxnX8WwM=" }, - { "Localization\\English\\Textures\\Game\\StartPlant" , "IIz47Bh/4MjFKaZaHx5PAxz97YukBkSqHv8nnN7tMLM=" }, - { "Localization\\English\\Textures\\Game\\StartReady" , "lhaXbwp0oHTrX1JFyJE8hnabkzj4bgNyWdFDMn32cbo=" }, - { "Localization\\English\\Textures\\Game\\StartSet" , "WPtmG9W8kFZQthgaycm6P17wmnqWW55CnU2JjsOGJkU=" }, - { "Localization\\English\\Textures\\Logo\\标题合集" , "IfcPnZSGmfNl1jdd4RiGaD2o3XHs/K0R7HKKLzcFftE=" }, - { "Localization\\English\\Textures\\Menu\\NewAdv" , "6UYMHlQ5SdT+gX7cJLy0iwyCXdxblrjdNe2l/OCeDcc=" }, - { "Localization\\English\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Adventure_button" , "7PPDxa4AOg4Q/ioviwKYKx2ftu82+zlvJdbeqWlGaBQ=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "+Drt7kOZRfinB9t8BsklSl8Np6NxDPJ21XvYuVoiwbY=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Almanac" , "Th6/Pun/NEn6797dnzdq8XnCqY9/oIORszG6K3xSFbo=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "hp6y9BUvolJ0bQdU1FY1Oyt57fizZFx8Q3zXYR4t/BI=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenges_button" , "LDMp8hCkHDSIrN9F92K93txxjFZ69qKyfG429oRyGfc=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "rSB360yGYMYQyNUJYb2xMCgGmSFAl7plLTr1BDMA8W8=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenge_button" , "0DWLUXJ5RYKci+loCThNfHEpk7tKV08vifffcK8owNg=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "AXW4pkVR9twu7/SJYvqScPeNswIoefGCBJXDf7SsXFA=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Help1" , "bwLeNCc4/VtLyocaVQhB++/7t2l4ngYQg+3r95RSMDs=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Help2" , "B7p5vi9AyiidPL4nvBTVdL+WhUbsKzHEIHyWWAut1KU=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Options1" , "TJEiHNySrGFxBP85FeP3hl4TcLCVjX1VXYt0navnK04=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Options2" , "SehcWmqt2cxQhPlcJqUKGeRyl0VgxGymyrVKLyGH9LA=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Quit1" , "zbJL06XIJDi1PjiR52BZCmNSYaRCWLb13owTgv9hVw0=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Quit2" , "diLLwcdEED5M+H4Y35Rnyu+W+R6FU7qVDs7DteLWFtw=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "9JoXGZoVFEVUJR+s/mEye3rkTIYwGLZCiajp12bAP/g=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "b2xzl7F7FEkFZpxGKwEwasmF5BkxaZJArAhcnPQ+Ng4=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign1" , "RhYg1ymYR4mEqL0do6dIqRxts+BG9GlB4d5dc+gMjsU=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign2" , "aV7MGtWrsnh5O2ikBof66Y4n+w9xhbQbkOObNP2GysY=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "bov/KzSszIVUaDK3x1AFJZU5kbiBArl+tBybTxi7cS4=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_ZenGarden" , "8x4Y+E/DvSPrr1sY1k3trPVtqLrRuUUVWktfLIx5qTI=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "ldiEJGQVyYvquwZuPy/aYNf+Am24dG6iILuw/1k3dNQ=" }, - { "Localization\\English\\Textures\\Menu\\SZW" , "2FoSx111GS6QF3dQoUlqhsbVbDSB0MrnUFKilgsIyzo=" }, - { "Localization\\English\\Textures\\Menu\\thanks" , "bffGVtPUS70M8mNXyKDE9aU+XqGMLITegGGOaPMVL84=" }, - { "Localization\\English\\Textures\\Menu\\travel" , "vy+5i0dx1+DIECxAsVv/co8gIwM9zk8djIKCHbG9ykI=" }, - { "Localization\\English\\Textures\\Menu\\钥匙经典" , "PAPsrNZRY9UetFgFnEwZKdN1TgNbCrU7ZtaPZVzBxvg=" }, - { "Localization\\English\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\English\\Textures\\Particles\\ExplosionPowie" , "cuikfX+3LOtSw3EPB6DnjANO5bKkoYCMdWSm+StmW70=" }, - { "Localization\\English\\Textures\\Particles\\ExplosionSpudow" , "4pJ/gZsuKRsAbUL1YWsaaJC9NxrzhqUiQe6glK07ydU=" }, - { "Localization\\English\\Textures\\Particles\\guang" , "kh0dcDxOXgh8+Eq1TmKdJug5PdR+nzZrK5iS5Nkw7Gw=" }, - { "Localization\\English\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\English\\Textures\\Particles\\SunExplosionPowie" , "3bSjOYpanuLnsl58oYUzOAXt94nony6Drq8qdpfRSGQ=" }, - - { "Localization\\English\\Strings\\translation_regexs" , "rjxlsJwClOAJERCe9XmYJB1q+TX6h0p5zDHqCyu/9wE=" }, - { "Localization\\English\\Strings\\translation_strings" , "zsQF+z4URSZY7yuqTfuOIdc/sfcq6g1Hi6ZeedfBFS4=" }, - - { "Localization\\English\\Almanac\\LawnStringsTranslate" , "7BFCUmTVKh5MdefAGxiqgbVtWHcyq9Jg/e8jCWcGI2A=" }, - { "Localization\\English\\Almanac\\ZombieStringsTranslate" , "4KU0HKBDqw5VPbvDqzByDS4nGSG0UAHZ6ek7iv0FOUA=" }, - { "Localization\\English\\Almanac\\AchievementsTextTranslate" , "Y0rNgt02JEkiv/jacilOR0NgACVjqyWpQNQrF9t9PIs=" }, - - // French - { "Localization\\French\\Strings\\translation_regexs" , "Pv4R3N7SkRz8Ksp9DkHR+xMn3Tv7+t57FAwEYDveH4U=" }, - { "Localization\\French\\Strings\\translation_strings" , "atzVMZyXEHG93wcM7Uqz0tTHsWK+dxc1csQxLhHF5wA=" }, - - { "Localization\\French\\Textures\\Game\\FinalWave" , "VTTPmIlVoXW7tU/sQyTlZZq2dy3qOlVs7cmPQYd2PMU=" }, - { "Localization\\French\\Textures\\Game\\FlagMeterLevelProgress" , "DVG5/OyuPfwy7dNOE8NCKmqZK0tKpwsr7As0df3c+0Y=" }, - { "Localization\\French\\Textures\\Game\\StartPlant" , "RkTaTLEoVW4TnXBg+UL3YlG+sdqg+WhP934sTpLlzzk=" }, - { "Localization\\French\\Textures\\Game\\StartReady" , "8/MDcBU6dbIHN1vESmyp27QWxIbifrZZn4IDxKldW3c=" }, - { "Localization\\French\\Textures\\Game\\StartSet" , "8+doc0lYZ2a3W3qpbMSeRturIOWpmyhHw9COvM4Ctkk=" }, - { "Localization\\French\\Textures\\Menu\\NewAdv" , "4noYYWThghcWgV9BCO4WJjEGqHg+SblIoCoCKgTXdAo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Adventure_button" , "ZRxJ77hv8I2NmSiK6LTDgnOG9obBh+ueMa3R/NDCd5I=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "MoCVUnQ+U8HdUtA4haA7Cx3CmlC/hvVuvYc9bakMtW0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Almanac" , "8txwE7D0UbRCH0hzukyZBACcCn1f9yiXLvhzBIkfKCg=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "WoiG0xkTP5oLEYBWOwnf+kkvbY3jD/xTVYgjBQ6/RLQ=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenges_button" , "3NEwHpNoT1jEl+4gDpOYQ/9osW9rvdfdmiJ0ALIV8Uw=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "RD2hIoFhO7AU6nmtrp5iJwjptYy6ociYKGUJxNsYHd0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenge_button" , "eQO5Wj2FOU2kLRMmI6Hhp3lir/hmYhOGrct5dL6utI0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "3cetfrmDbZHx1uumNbBApG5p8I2T8spnrqVhPqSxkI8=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Help1" , "2yINgPeQqUy6b/mzw/2mFfTxWUlzQrJoYC4Yz/VoGy0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Help2" , "aaUDGQU1+0ltVD4OF2Luc/6pXK7LZ4B5jL9BtSNRnjo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Options1" , "Lpt1mXltCSkn+9BeMOT+CzTxcQ7cwUtFem+I1tWHdqE=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Options2" , "MNNGXO8AboJJf9tMKXLpIB6j1foAj6bcHopNhHcpRVo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Quit1" , "6NILc8MqiGcQ3ttSKGfDOEOgvUnIUNO/DWBIeNi4/pM=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Quit2" , "rwTFCgy3kNLCcBM5J6EjguUP4NuvfkDNJjks94eaP/g=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "UYwa4CPhRF8CiWro6Y22GfFQOlk8xCQ6Mldkgk4Jn0c=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "MzBfCyymyT0E4mGUdhps7O6IHJdHtwNtGoi3kRAS8Ok=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign1" , "T2Ci2ItAeYw0hMbOP87XJefKbaye8Fhv5tN4H3V7TFg=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign2" , "KnPecN+vhvShgMagZGtPKPzMLcc+N3Kqsrlt51YiKRU=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "v2L4jFj8hcIeJzle9LA0OLcCKwXXYdPVBucdslPTlF8=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_ZenGarden" , "ngbC53eTpHs9VaU1qViFJeJVCNhoZcvojiFpeqrXjMc=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "F/nkF7zPU6FyWpOaxMim7/NbS6mH23er3ihfF2tVUSk=" }, - { "Localization\\French\\Textures\\Menu\\SZW" , "Z0uAEbNYk36lyCsPXGXnmjO0L3C1E68aA54stVpbYYs=" }, - { "Localization\\French\\Textures\\Menu\\thanks" , "bzYfnWlAyBzLCflijFAld5m0LBmzDS5vyCbUJs+cn0U=" }, - { "Localization\\French\\Textures\\Menu\\travel" , "Ca4e7HNOAXOUzKQAw+1+H1JRI14D1yLEn5cdXHmFcMo=" }, - { "Localization\\French\\Textures\\Menu\\钥匙经典" , "E+VDMHWhhtf9MwVo8SB9b2eDTE1v3u5Wd5DxoM935fo=" }, - { "Localization\\French\\Textures\\Particles\\Doom" , "q/QV2mCopjFnbwQUUTvoPtcyGV/UAwuxjB9v+GDm3OE=" }, - { "Localization\\French\\Textures\\Particles\\ExplosionPowie" , "mqTy7LXjfh1v7kEtwHzIckWjm/4P97dCs4CbyvzOESU=" }, - { "Localization\\French\\Textures\\Particles\\ExplosionSpudow" , "zFpkHlUNR9jWL/H8FQWy8habmtvu2wtMi/PpClRax2c=" }, - { "Localization\\French\\Textures\\Particles\\Sproing" , "FSStD7Lw1uNrSHqZkZCKrY+hcA6O1DOMKe/6R+jqNdk=" }, - - { "Localization\\French\\Almanac\\LawnStringsTranslate" , "sjZ1qRYGKM3sKMimzIlfmd3e2T5gIV38wy3bU75pLjU=" }, - { "Localization\\French\\Almanac\\ZombieStringsTranslate" , "k6XiNRnACedQuAMhh2CHx9jwMfPEJTbG/UZpubs7EM8=" }, - { "Localization\\French\\Almanac\\AchievementsTextTranslate" , "cFzYB+rYT5//+JpvEHa8Or97RYJZdAI0zK3Pr0Fw9hU=" }, - - // Italian - { "Localization\\Italian\\Strings\\translation_regexs" , "Fr7kZcK4cwoN6WsCARX06Od+PkzCv/FTetj7ME0cIok=" }, - { "Localization\\Italian\\Strings\\translation_strings" , "gXM9MZ66TBCflwXl3hMvH46U70kU2w3i4o0EQAd6Xp8=" }, - - { "Localization\\Italian\\Textures\\Game\\FinalWave" , "J7mSpIXvwo0JbrS8RLLWr8jS5KwRcMoDT6aSIVykhiU=" }, - { "Localization\\Italian\\Textures\\Game\\FlagMeterLevelProgress" , "pwnHiUlgXSYUhEXhBWe1XUeeWfYTb0oTY9/UlerGPuU=" }, - { "Localization\\Italian\\Textures\\Game\\StartPlant" , "6OqWQtc8U0Qm8qyhkdhgOmLhR3yGVnLOFhZ6ZrDIjy4=" }, - { "Localization\\Italian\\Textures\\Game\\StartReady" , "3QPcKBCGX8TLM8xCqCDJqY0uCsRg0vUxGzmTkvfXujM=" }, - { "Localization\\Italian\\Textures\\Game\\StartSet" , "VS5T89S8Do4xqRwxSBt9kjV9o/minfu3M//piKAJVkQ=" }, - { "Localization\\Italian\\Textures\\Menu\\NewAdv" , "UEsXovFnKuglsJ9S59cnJjDnhfDyTAXtLtVEnw9oOD8=" }, - { "Localization\\Italian\\Textures\\Menu\\options_menuback" , "WjWI+u05cf2sNThCp2EaWE58r2HwXRIP1gfwvwNo84k=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "s4XJiAhMaWGMpyzt/fGQG/dESF2XeQQ9x+1FQWyLkiU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "NrVoP4kXJ8zaw9/cdm2oRPo08C3oCa24xCO23d11UBo=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Almanac" , "cOdUtbMj5hqPyHoYfORNboSUikAGyoNtKO7DicYANRI=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "ComYfg7rKwHPcmZENPfQP5T9TFQ0ARRmVye2nGAc+3A=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "DMY8d7mlP2ZmBHZz6BjYM1SEFlkFWp9VuIbB7+bMVwk=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "/OvCfFYFwlvf+DefR1/XYIAQ7djymbF4EK1kiLJzXHU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "0XDQd6EaJkRSnYezFxhMFFAse/i2ZlRVmW+Fn9kSWnY=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "UfKNb+QqlwzBdu1eORqEeDB9lVVKmGMpqRSExUAUAak=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Help1" , "RoyqJT79KbODd3PfK28pDvvnhcps9XVDxNNT1GjXu38=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Help2" , "UQdoBeSlI04NXh+VYjUyN9l3gT5p/CDRAU1jUsFqerU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Options1" , "3ebMHMsiekRjU3Rnc5t+yIkeHNpyZi8/Oulst4WWacg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Options2" , "PFlm0Sdy/1Kajr32uINpR6i7YXQ54a8dq0+OI0R8zec=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Quit1" , "bPWwEE74Tdb583NcXB8e5W/meXVvmwuWkuajv+/R5Ro=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Quit2" , "vBdX54EEKdZkJgiFcCQPtzRPoj0NSKTq7UA7rWDSTBg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "ZPkJ309XC1P5w3x4IPhItEeLd5WVlU0mIaBoHX3b5Bg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "8VuUajuH7+8MJqROk/3XFQOEx541qi89ykuQCNaJ+L0=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "1tP+grtgWPu5HtvUa2ox+9assN+Wgj63wBkJoskr6K8=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "sZuiY1fbj5mg0TXaMok/qJFwoYf3+OxkN+Bk3pbTjs8=" }, - { "Localization\\Italian\\Textures\\Menu\\SZW" , "6cXREWl13sjqgdz3Zf5kT1N7bCoIc7LyrHg3WNMVTyE=" }, - { "Localization\\Italian\\Textures\\Menu\\thanks" , "I2nKJztoIdeVy/CyGYN/r/DB+Gvv3geaFxOdtMdf3ao=" }, - { "Localization\\Italian\\Textures\\Particles\\Doom" , "8E+/HlnnJa52eoBgLYjMyjBCsb5bhc/rTnsJKs2hucA=" }, - { "Localization\\Italian\\Textures\\Particles\\ExplosionPowie" , "u2bgHV+XPb4gSz8CagwJdbKWszej9uoIcbM1Z5GRto8=" }, - { "Localization\\Italian\\Textures\\Particles\\ExplosionSpudow" , "CciMCMupOdEov98dK59e2wF2izCwW8jpBkwQE/EV/JY=" }, - { "Localization\\Italian\\Textures\\Particles\\Sproing" , "nYlKAmcK0rADsk4KS7FaQ3FZBfl+IGQuXb7O1GCML6Y=" }, - - { "Localization\\Italian\\Almanac\\LawnStringsTranslate" , "npd2sE+VJ46XdwqP4cx+Jg7/mgxFiUUgpxEKxDrBUKk=" }, - { "Localization\\Italian\\Almanac\\ZombieStringsTranslate" , "GEhXXOMNHS12b+dR5Q6cxYrORjjyywpkPEKB3QzCn+I=" }, - { "Localization\\Italian\\Almanac\\AchievementsTextTranslate" , "Z4YUscuIUlrlLiaYWHTEvNjztVt291fLjJjkfc/lYBE=" }, - - // German - { "Localization\\German\\Strings\\translation_regexs" , "v3wwSqcUG/g71BrZXhYkpxDYebHeO52n1I8QjjlOuUw=" }, - { "Localization\\German\\Strings\\translation_strings" , "LGDwWtGeEnEvv31TnvXdkVUEs5od34WPNQ0od7WKy60=" }, - - { "Localization\\German\\Textures\\Game\\FinalWave" , "+MHS0Xz4nzGw+0knMtj5vJYSxaaT0KH/g8DWXUOv788=" }, - { "Localization\\German\\Textures\\Game\\FlagMeterLevelProgress" , "M0XScRnevh24JLXF48cG2GecSHlbP4vGUerW0xk63OA=" }, - { "Localization\\German\\Textures\\Game\\StartPlant" , "ab42rVDpP/bDtBjg9LvrfVmEf3E2Bry1pwOnMo8vF+A=" }, - { "Localization\\German\\Textures\\Game\\StartReady" , "7vV3VLAlAKbjXTBzaxlN+ulcOimET/gMvohDzyjFXoI=" }, - { "Localization\\German\\Textures\\Game\\StartSet" , "nNyPtyTiTsCPalXr/MgQob6EEb8kgyPZjMWmbXu3YFw=" }, - { "Localization\\German\\Textures\\Menu\\NewAdv" , "Lx7kxZzwBLios8g7raYwDDPcz2X48SshJaWuklBYUDc=" }, - { "Localization\\German\\Textures\\Menu\\options_menuback" , "WjWI+u05cf2sNThCp2EaWE58r2HwXRIP1gfwvwNo84k=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Adventure_button" , "8NsCGe3aSbZ00AJFlELTtD1hOJlu+RojAAvvD77ICpw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "LcyIKu9BsVtJapQUrpkdefPiA+JTYkak3fg87Tx45JU=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Almanac" , "JrkVQQByD5XSa77HI5+MVGkrc+3nTDyKEP+Kuij6gPo=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "zUlJJqGxLiwafOpBogGO+zX621Q3EnetL+u5vROt6JQ=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenges_button" , "SWZKSjn8ytu5outezry04hHXcTmQD+f6KlWn4nlIZCA=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "9S0JmpQLSGprElTl2MzQoSuT+Eemhj7vaQ20lwi8Ynw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenge_button" , "VRVyZIq8PBKunX8767vh70F/SA85Cifao+kvi7HMIHE=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "WIH6pTlcbWqOMk+H2OYsBft0jVBwYT7hhWiiWaZzT8s=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Help1" , "t9KLP/pCP5dWxWp7nAPjon/4224sE+yY2sX+MhqRJ1Q=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Help2" , "KZ7sZ8Q9Jus9Su3Tu3FLWmWJssq/RPnuOO/eQ7HgaXI=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Options1" , "nqTlln74GhHYs6GKAqcsoS7AzDnOD1jOjvfBBzMOEyo=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Options2" , "xtg2c+bnhPszl8u8BTma6O/xMxiZ/asBAA5jRCbWtek=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Quit1" , "xyxc8phjdNVui7E7RHFSSlu8OGIXw8HW2QpBCrKokmQ=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Quit2" , "PBuRnBbzOk257Jm2i3ISLoz3oeDzy6LNurXaf9LKV2E=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "92BwDgaXMJZXqrcCxdIm8XcZai1NuGH0amcno5E2uU0=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "YzxTyUcR2OvQ1ctFTKq3kd47A0tgiXp/kPQC/hgdom4=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign1" , "T0wrDENK1CD3OgeosDNa4ab28lsSi9JmM7v8wbxB4bs=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign2" , "9SZQ6SvrqFn5kPXbF1JD7F5uMfvGyV0xkar2qCvb2UM=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "jJD+LiAoEzsnPJeUFt2Gpf+e2P8JjKpnfLDDPh6Zcho=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_ZenGarden" , "5Z6wqSVe04hmNHCPdPrDlJrXqgblhY6OG843O19GVmw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "z6YuoHbmClwoKeBjsLa0wypSdcB3QrEh2wzzYnDk6Ek=" }, - { "Localization\\German\\Textures\\Menu\\SZW" , "op9D5nHLxn/WZ/TVVaeji8hj9qRQl1DeuHZF/rj/ZMA=" }, - { "Localization\\German\\Textures\\Menu\\thanks" , "myLBgPcIux3cNkPd833r01ZqJsCqBTty31xJE68ZD28=" }, - { "Localization\\German\\Textures\\Menu\\travel" , "ASg2t1qO64hqGJMqDTQ8da8KotTKpkGtzKIaKuO1MqU=" }, - { "Localization\\German\\Textures\\Menu\\钥匙经典" , "KuqwMj6aedb2J7e8rVQpMa5Ie97lAFbGuwGFZq3POJo=" }, - { "Localization\\German\\Textures\\Particles\\Doom" , "rY5dss0ZrDcUHYVTddyesRpU+r0HoF5eiBM4iDMhHhY=" }, - { "Localization\\German\\Textures\\Particles\\ExplosionPowie" , "Gu4iuRPXhL3KAlUjBjbBOpjPthKXlViQ+8lw2sreTNY=" }, - { "Localization\\German\\Textures\\Particles\\ExplosionSpudow" , "z0h6r4O2FdV1r4CbGVd4nmEpGHZeo8dM2wV9suiZq8o=" }, - { "Localization\\German\\Almanac\\AchievementsTextTranslate" , "12tsG4qJrdtX0dxUOa532CyrC+cF403BfFg3fsjRO+I=" }, - { "Localization\\German\\Almanac\\LawnStringsTranslate" , "Vqqn/gcnY7SIPEVbIxSBi6DXSVBwMyVCQvhOs4KCoJQ=" }, - { "Localization\\German\\Almanac\\ZombieStringsTranslate" , "RlBdepGFFohgICk5idOkRFo9t8FxUuiMw4hoo6eYs0Y=" }, - - // Spanish - { "Localization\\Spanish\\Strings\\translation_regexs" , "4QFp251QrntXDcXjGrGYje8gvuKNHAxVp4FfLm0uHI4=" }, - { "Localization\\Spanish\\Strings\\translation_strings" , "BT+eTs1l2eWCDb+5CGgJJmjyAGqTulKOh2VuDIkwxTE=" }, - - { "Localization\\Spanish\\Textures\\Game\\FinalWave" , "fcYpg8VM7fWplgQdj87NOj5jtGgCPzvW4c2fJOUiJIs=" }, - { "Localization\\Spanish\\Textures\\Game\\FlagMeterLevelProgress" , "4MdtfTqEleDpziEenobp9O5cP3L/nZk18gdT9xW2O9c=" }, - { "Localization\\Spanish\\Textures\\Game\\HugeWave" , "n9O7b5CuD9Yu+ccecqsmm4ofp10MAw6eoZmIxnX8WwM=" }, - { "Localization\\Spanish\\Textures\\Game\\StartPlant" , "s7phwlweOMyWGCtCtFoLSMSC/VQSxFPVoB9T+RZQyhk=" }, - { "Localization\\Spanish\\Textures\\Game\\StartReady" , "DRI5gg//9pDb5dOaR0PhlBzuhP2lryhT6aeklSCUTxY=" }, - { "Localization\\Spanish\\Textures\\Game\\StartSet" , "eiX7QvBlF+EcJrXsOxqOkzu0VF/6hb04uNRRHRA/RMA=" }, - { "Localization\\Spanish\\Textures\\Logo\\标题合集" , "zt6CxJgEU+kegWGRKzQKwJynE91Nbpk9hgSby2zHW/o=" }, - { "Localization\\Spanish\\Textures\\Menu\\MainMenu" , "ZTaVNrPrxtSad5bo89RQVNXxaprYLZuGsl6dvuAoJR4=" }, - { "Localization\\Spanish\\Textures\\Menu\\MainMenutravel" , "w7iF3kfdiOg8EdbPKZlfxfObZXSAdqAMzfDMtM+4Dd8=" }, - { "Localization\\Spanish\\Textures\\Menu\\NewAdv" , "itgAdOEzcDj7sUA11u4xX3BwY7vssEdui606FpUUrEk=" }, - { "Localization\\Spanish\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Adventure_button" , "yE5gPHXKy3xnVBFtSTC0zjhfl0tCrc6sHPK8AiiO/s0=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "gwHOCHLV9NAvvChiQt5X95UOLaStVZogt4DWAokvACg=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Almanac" , "xfqV6GfWdsrPhlVIduoQ6x5QWnci7DRO0E8qC6lItDA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "a7NCRdhsKTG4/8CLniWG2j/3MbUh68YmT1QJWAVNCDI=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenges_button" , "LDMp8hCkHDSIrN9F92K93txxjFZ69qKyfG429oRyGfc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "rSB360yGYMYQyNUJYb2xMCgGmSFAl7plLTr1BDMA8W8=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenge_button" , "OT8c2V3GBYxsCMO2nHs7+DbKkdHupmjujVexo/jm1us=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "utQuQr3NQGeGxfmtc3CC7s86/jTGH3SipAkDrAXVbxY=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Help1" , "+W/tytQsNLMSqPE3QnC43MgqBsU0H9XNrjk4RHundLA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Help2" , "WNPFp01iipCzzArymTAcu4VLz5E+Hcm/bnjMZZ0eQ60=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_LevelNumbers" , "ES369OPOoW1RsrCvYQbKaUt0GF3zXXgUd3ZPnjDWXhc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Options1" , "zOkXmvvFsyjLO/nq0Dgl88rTSrJWwBPMp6QiAobyqMw=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Options2" , "MycGypHA2qhq7cgAk97vlPX1gfxmeXoMxQ0FaKwQpkA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Quit1" , "jtBCpgu/bShFN1ykigQtCjLb+U9aABHugP/8ezHmYxU=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Quit2" , "bbTsQCx08UTWFdM/0csjqYB8rSvCJJm3hZMWSDFmeI4=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Store" , "6gVEuBsk1/udDoEATm2tgmWMCkdme0+oxngcJAKrmP4=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "grdusCpWrRqZfBuNB1Dj7bKFzyQk3xFReAqoAEKYFhY=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "s6uGdZuYk0R0xmSa8KsCsZAziQC3F6AWyZaL+vqPi2Y=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "5iaDwlH8qBI3YyWWjyJ/azvzoOMuThRgYykZeAu55/I=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign1" , "EzxodXEKdnZDB+CRtpfAMzlGaoqBoXhO79UprQAErmw=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign2" , "vibMNgMtv+f43drQs5FWDYv/WaUn6VC3RVZv0qioywc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "esQplw+1F5GBRJA2KPKbZWTQvPEpQp+d2oyym7Bz2OQ=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_ZenGarden" , "6TrN8Qb2J40RES+YBsBdk9b9A1yy81/+0ZCGSfOqmQM=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "zr7f1egwQiGj+qJiAM11sWpvRVgGkj1E3q2Tpa6t82Y=" }, - { "Localization\\Spanish\\Textures\\Menu\\SZW" , "zXZkY8n4Xa4BRXd2P7CrPeV/oyoImKa3aHZN0AQxrDA=" }, - { "Localization\\Spanish\\Textures\\Menu\\thanks" , "a38UKni0HkBOxxZOz8YLEuRomcdqRxH+cUxIiZv+57s=" }, - { "Localization\\Spanish\\Textures\\Menu\\travel" , "gyGKFv33M2THt9HsNOGXrzayuTk2O6eW7SpR+gq+6Ac=" }, - { "Localization\\Spanish\\Textures\\Menu\\钥匙经典" , "2x/0/QLjwKGhOFxClKDi+wmB+d0n3/B9Y48pW8Kr/uc=" }, - { "Localization\\Spanish\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - - { "Localization\\Spanish\\Almanac\\LawnStringsTranslate" , "EyMLq+zINvouAEcKNy8fPEu0YIJ98NSLqpMs1NX/U1Y=" }, - { "Localization\\Spanish\\Almanac\\ZombieStringsTranslate" , "tVcpi3GfFH/0aqsaeCuzszFYi6s1IxzO6Zw7wnB0flU=" }, - { "Localization\\Spanish\\Almanac\\AchievementsTextTranslate" , "9PRacAZIbZjZZfc6/qoAggpiW2yZfKjWY7C4im+a2xg=" }, - - // Portuguese - { "Localization\\Portuguese\\Strings\\translation_regexs" , "rzeZrvBSmqIGxLs/jHRAJycnkaoKthMidVOItF2PrbY=" }, - { "Localization\\Portuguese\\Strings\\translation_strings" , "j+vbHq7c9x5Rarc0yFX5eSQmHHtdXsgRqpCxJ9SGKi4=" }, - - { "Localization\\Portuguese\\Textures\\Game\\FinalWave" , "MK0QFrw4Fco5s9xq+8quKs1Li+SinkQuh2OxfZA4gqo=" }, - { "Localization\\Portuguese\\Textures\\Game\\FlagMeterLevelProgress" , "YnkJry/FceiULgkq9RJleesNqgLp/SeKiE5MJA7Kplk=" }, - { "Localization\\Portuguese\\Textures\\Game\\HugeWave" , "jRqYPyzJm7kTbLeaSosHlGLWoUjF1mWqtVNdwtAcvuY=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartPlant" , "7IkydSAOydpjYX1+LSb+Fpt0M0KRmVcwdvjGgXJYMKg=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartReady" , "xoyag2YhVyujDnM/xAq9Xtym8HGKl/h1GCda1mfM3PM=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartSet" , "92OXIRhqJJhmdtb0W/WMNVi1t5hdEzpiwzfX/7p4vRI=" }, - { "Localization\\Portuguese\\Textures\\Logo\\标题合集" , "Ac0MlmlulBOa2w5peHxP7KhJFPAGObirxua3kWLlstY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\MainMenu" , "LNnYLNOJryrvG5XIO+ObgE3Nohxjo9n07UjaGjfVHSQ=" }, - { "Localization\\Portuguese\\Textures\\Menu\\MainMenutravel" , "ZwjI2ybianrOFPEfrLP/38t6y4QB7D6B8hAfr7fvSQ8=" }, - { "Localization\\Portuguese\\Textures\\Menu\\NewAdv" , "gxMOlYYsojAuEQkjdLIM46dkx4ssCH+ncPdK3QBlAFk=" }, - { "Localization\\Portuguese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "6yGbPdJMpbrmHUm9VSCVKHQxJ1sy0YgM42EhxRr1FLQ=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "rdyOJvSoNOHM6uNuL6ehbayGUaOUE/CWs8ZzbzOCafs=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Almanac" , "+5i+4oc5FJDlzzC86ewxR6aaGt2pB6snfvsCpJGL3gw=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "NBmzBkLDe+lMK/wxbV3p2L2hhByBUBP8onsYXO8Pxnk=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "mAy8FXDBpR1tsmwAkNvYB+kg8KKZLxmOtVP3d3DWiJ0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "jbM14CqEIK+GnRKoKUna7P78p4c74g8NNPEbp01f0VY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "TXWmZyG1TjBnem8kcFVv93RfUnYHf8CqV1n5BQyTGLo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "qUrCJfUYlEO32SCoPx89AzteV5hba2xzEjqCcNI2cJo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Flower3" , "KQThbd2XxKVgA/b9DE8RKwYoNRGTCvOOlGfIlmdnNFI=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Help1" , "gJxez2SDkvOvUtS7q3E6xlnQWWWeG28KaXJSG5pqqeg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Help2" , "FHAsPhSc3efXrwoZuiN3APOgXJQNf45znFcaoyZ7ZBE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_LevelNumbers" , "ES369OPOoW1RsrCvYQbKaUt0GF3zXXgUd3ZPnjDWXhc=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Options1" , "FQKd+uBul2bwIcr6nmNq1N3X25C8MRgjyGBy26OuR3g=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Options2" , "xZN/+5sa+0b2eDmS7WV2rw/IV6zglPmF9qan62eJHAg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Quit1" , "dLesJNU0+2/ep6cJnQBA2iUEgIOtve2ozeK9lBher/8=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Quit2" , "hvq+IpGRu+1Kvjz7g8797qjUIkMx8q3qcMyvJDnhMP4=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Store" , "WuaJyUo+GX7vDJ+R+MA6XRKF39j7lNZYOMCy+8wNzYE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "bDeLuhI74R/OTEAAqiIkJJfVyywn4s80lTrgGFNTzLA=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Survival_button" , "mAy8FXDBpR1tsmwAkNvYB+kg8KKZLxmOtVP3d3DWiJ0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "jbM14CqEIK+GnRKoKUna7P78p4c74g8NNPEbp01f0VY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "1mherm3clK7CvLh9GpVqMII32w+w54mKZE7Z9fkkZZo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "3PVn0DR/33yNI2bjQnDDSSiFRUI+q+1j5lfk/R6JgxI=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "EqYk1lM+BEqgaAqOJXF2HRPkYTgc9j2iMyjcd7/w/Vg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "0iGZDDOUZGqqbMV0CNnjMPVNbNXmvyrJlDIkJ0SV2jE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "r2YuP2O+mEVhGmapNpFRX8NTx1uY43oaU7kgZyzUhok=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "Ga88gKhsCeLtSoTYheuB6aPx5s34u9SqicGbLI/G6Ng=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "0xCUMxGOkVjkgU+fzmlzzSzC+acBGxKhmMjXT+idOk0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SZW" , "UVGfrlWecM6jEtNJPqjZ+zI66w3euAdOMNl1EPfKpxo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\thanks" , "eHFnd+JUF/r6YRbpTtjmbs6Pywp92asO6TD/rLmO6Eg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\travel" , "qmw+h5LBEWpIGaSe3HZF0XYUScF2VnGQxKWoD4cR2Pw=" }, - { "Localization\\Portuguese\\Textures\\Menu\\钥匙经典" , "g1DKaF3XxYSuiROmemzDz5C2cUcAQ7jPzuoV+nbC/Tw=" }, - { "Localization\\Portuguese\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\Portuguese\\Textures\\Particles\\ExplosionPowie" , "PHe2TsElYp9UvabT8sxF38JZc+4Hiz78HJyqH/Tzt3M=" }, - { "Localization\\Portuguese\\Textures\\Particles\\ExplosionSpudow" , "Hc/nhkiBIHrZzgdX8+zPYBVoGgNj8177Eqn/S/CvhUs=" }, - { "Localization\\Portuguese\\Textures\\Particles\\guang" , "zpzEG5fPPVYI3tf4DXE0hu3j5BlwIPSAKgcbpr/0wlw=" }, - { "Localization\\Portuguese\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\Portuguese\\Textures\\Particles\\SunExplosionPowie" , "Cx5JShdk8H2FKNujBTOylSR0708YuufHqWUZiV+sG6c=" }, - - { "Localization\\Portuguese\\Almanac\\LawnStringsTranslate" , "WilEedYB6brtG2gExyru8VCIPjYiH8KOvCZ3dXkSaUc=" }, - { "Localization\\Portuguese\\Almanac\\ZombieStringsTranslate" , "ihC0adgxNlZjMrbLFMrYbprM2fY5Po4GfxaGvLJiDaU=" }, - { "Localization\\Portuguese\\Almanac\\AchievementsTextTranslate" , "2gd4zJcz6giTsKjIyjIca3DkWOipeedtbQpX26AJnkE=" }, - - // Javanese - { "Localization\\Javanese\\Strings\\translation_regexs" , "ci3jGT0t5FHqstahiDanSlnoXjHtfNLKD1JV2ZmbARQ=" }, - { "Localization\\Javanese\\Strings\\translation_strings" , "r84OFD0SmodV4abyygiyDmwPcfDZTPPvZ5XA+sYHAIA=" }, - { "Localization\\Javanese\\Textures\\Game\\FinalWave" , "ZuqUOUgNV8tNZ0vzyn0ME2VOYbD1TuksAP900r94QP8=" }, - { "Localization\\Javanese\\Textures\\Game\\FlagMeterLevelProgress" , "bZUyDcbcLtz+uG7pnXncJEgBQn6dkE0HUuO0py5Qqtg=" }, - { "Localization\\Javanese\\Textures\\Game\\HugeWave" , "yNfz9nK3LRYy307H6xe9fbIkBM1WryMNkpUpX/AjaY8=" }, - { "Localization\\Javanese\\Textures\\Game\\StartPlant" , "vx2ZKMq6MPzgi/wQkTCHS3q2MKGfDSV/nR0Y6wcV1RM=" }, - { "Localization\\Javanese\\Textures\\Game\\StartReady" , "U/G1MHSRD5N3XYuLz4aj5DAnj2OSIL7lTLSakoTd8o8=" }, - { "Localization\\Javanese\\Textures\\Game\\StartSet" , "uX5YiWkb7Fh5TmEJAyj5llaUEPIv8HoIgtLhQ4cenMo=" }, - { "Localization\\Javanese\\Textures\\Logo\\标题合集" , "uAh1wGHTmqL+eelty5vhYB6aeXxyt0j4PMXgyDsWg6c=" }, - { "Localization\\Javanese\\Textures\\Menu\\MainMenu" , "OZ1gfSCjvhys6N8eeM0OZKX/z/FDLtX6HW3MA/UqgLs=" }, - { "Localization\\Javanese\\Textures\\Menu\\MainMenutravel" , "V7dmKMS/Ta7LUobEgFudX3hVXCs8GBulEYJUIkvn+do=" }, - { "Localization\\Javanese\\Textures\\Menu\\NewAdv" , "y9AUQwwNxsOnkPM5LY5DT80cQ/X6WmNsGmzzo1VZdyY=" }, - { "Localization\\Javanese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "5nPBRgfdFD0RWQ8j26FXzQBN630hSr+VRyKXr/9ALAM=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "39n+opclWXQEDzKDrsg2r0B5ZtCx7eMcryp13eJvZ1A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Almanac" , "MAucz/pmIdNnun4hLfp0PDrjESlsAZ/iL49NCYl6feQ=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Fea3OWEPntAYCFCP1DK0lrqQByQTQJ7TNWhS1wRfk3I=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "xdoeNs/98lT4BKon8Bcwk7m1S+fGbLeHgZISD9qVt1A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "91z8WbCI7XptpUtaN7mJ1BWz+0JNRMYNbDcoxzb7YhA=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "6W1spOrj4FB/SgOb8851XRMAnXoudOjNyl6z4Egw/rs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "2MhlockgUB7+YVxv096GrbPItf5IVWtuAiv/o65Dx3E=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Help1" , "TrxevH4mjIf4iCFdUXk/Skwq7Asg1dxteTGzqOjQk6o=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Help2" , "s8i2Ca+iB8CGihGdlzqFxZ8PYO7tdm4ODH3GiSqIyMA=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Options1" , "JmwncgGiBynAVjnGkPd0EKXh+MYkUhbpy7H90MYnfTE=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Options2" , "FBzi7WpQje1t1uadDIjcDCwVe994I+ICfmdx96NqrM4=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Quit1" , "N4yS6t5+p52vU93MbHeLgFik9uureOGgJFL8G4FwKho=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Quit2" , "NPtds1JqdvoLtHiAYxzyeM4RyvcrcYLu1HMSnO3252g=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StartAdventure_Button1" , "fIaIRMLy8g56ifWSPZmKH6CCQLia550aovyHGJIRUBQ=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StartAdventure_Highlight" , "n0+5ijqYlRWC/3l2JSqtZPnMDbFp7TLSeZefohaEqg8=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Store" , "6JxQIrwb++ekCR47/hQKyahxmMt0ntFDa8A6qETcs3M=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "8SnyShbhGdphCX4dqfWjuoQIZvlnpDsT7a9mrS6RLEs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Survival_button" , "/mMMNvV2V0X7oSVyKWhLryEO7Bo+eCgDiHozjd4I3/I=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "pNX/YY+qV9RmVt2dcXLTZ+magOEhQNxtxYCUQ4a+S4A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "IlFeFIlDFW5QAMWwRrgwt9kvStq7pJXNYnWfa3o3zmo=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "aHyZVtF7SxvC8i5Cvj6eARj4+YrB64TZ5njk9whfdgk=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "aJ7MmKsDxiIuExTTP+b26x548jJC9PR2l5An3/Xdlv4=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "5G3x/AWLBZY10RKKdlll4yD9YFzTNqke1GJuTQk0nCo=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "S6vvweA+KTaP0m90S3lu8oitt0/kfc/XasW740bkeGs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "kgnex+VH/1wjfCM0gLUPRQ16Nb/jeBOBwz7Uz+tBrKU=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "cHufQXgZze8hFwdw5M1gzd/kgtMrFQGIaforUAQeVUk=" }, - { "Localization\\Javanese\\Textures\\Menu\\SZW" , "kJM+ICVWg9rIbVDkhX63KdViIjnVYH4IGC8rqvmnAQI=" }, - { "Localization\\Javanese\\Textures\\Menu\\thanks" , "UPSssI3shIEOMFKQKhRALT2SHpmBTMgHmxpBbRJmPIM=" }, - { "Localization\\Javanese\\Textures\\Menu\\travel" , "s0AOJiMph12ZnPEYyXZ66EbfBHl8xlwhHh70nlW3kkU=" }, - { "Localization\\Javanese\\Textures\\Menu\\钥匙经典" , "5VCHANL1SD1xv+QsPdIDIGeq1Ksw2Q0O9Z5fH1ilCBE=" }, - { "Localization\\Javanese\\Textures\\Particles\\Doom" , "OE2mWsoMv7SEqRWQJWzJ+A/5gQXeRtogIph28cHJyLI=" }, - { "Localization\\Javanese\\Textures\\Particles\\ExplosionPowie" , "P2jrh7tf2d/9EWHoMScwpkpm9ZSvd+ZACEJqSzen7lw=" }, - { "Localization\\Javanese\\Textures\\Particles\\ExplosionSpudow" , "PXVMwcdcn2pL3mN7O3JEMFvI78XGb/POvZ3Sh26bbOw=" }, - { "Localization\\Javanese\\Textures\\Particles\\guang" , "fWG+wb2CZqaSsaLhiscKXHpqWiyG7Z2qXtHhBzumlSU=" }, - { "Localization\\Javanese\\Textures\\Particles\\Sproing" , "+CRy8k+5wzAdG5wVPM3sTYny3hCmPURD42qnTOIv898=" }, - { "Localization\\Javanese\\Textures\\Particles\\SunExplosionPowie" , "ifNQQNn0abUE11stJvwS5wZQm2Y9kPhQx7bXtF0EnCs=" }, - - { "Localization\\Javanese\\Almanac\\LawnStringsTranslate" , "5JgLhxOJA5v4dmZIlUuj5IhDJAijMQov7xNm4mhcKTw=" }, - { "Localization\\Javanese\\Almanac\\ZombieStringsTranslate" , "XpsMKQ0tZON0zeC0NAjZZqC/4SgSBFieYpDBMit2WFo=" }, - { "Localization\\Javanese\\Almanac\\AchievementsTextTranslate" , "g+5/ND/fdGs4fX7mX88GFp1vdI5lAicu4UcOhjLWoO8=" }, - - // Vietnamese - { "Localization\\Vietnamese\\Strings\\translation_regexs" , "jkmDo2/shz/L1entNc/VMTHSwITTe1lDSWkXwu21HY0=" }, - { "Localization\\Vietnamese\\Strings\\translation_strings" , "DEcePF0ruVJLmtTWVL6cgpg6R14ha8loB7E1sEf6r1M=" }, - - { "Localization\\Vietnamese\\Textures\\Game\\FinalWave" , "Ut9Z9amTQgL3Pdcza22zTjKANBKZ9iGQGwuiV9yia90=" }, - { "Localization\\Vietnamese\\Textures\\Game\\FlagMeterLevelProgress" , "4pMjKlDTK/eLQtYWZy1yjgAsDizgOQLZZcA6lYdDbqA=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartPlant" , "Vu7L6nDEl62NmhpQF+79hPc/Os3iJogr1N3DGUPv/Nw=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartReady" , "z3YlFfGkneA4LSSqqtlpnwNLJq3h7gwtl1ZvcxdgUxE=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartSet" , "snzA81WMzGmssVb862bG95eMRmDGn8t3tBEtj0M/OL4=" }, - { "Localization\\Vietnamese\\Textures\\Logo\\标题合集" , "xqL8p6JTWYSMJmWxxOsA6ToA9bdeA1PrFSWsfarm2uw=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\NewAdv" , "HgyAiO6/YX6jfqzcfW08m/EeXqFRsaGQlIv09U3kHyM=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "vkeO+XAUZURjHfog5dqM2EWmx4Q/Hkgm2lxKWWuEn84=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "bmw+kDo75C0h/xHg7U01xvGQqzjHBjgOvYjuZDLdOU8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Almanac" , "1gsF1/5A/Wwg7X7NmYVvJi3vaavEqbAMDy96vLCElf0=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Euqlx4l5PGWP/VDni40lyo6XONI7UH+jjT9NGbIdaSI=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "anKXed+ijHNf2PnlyRHOdnPNHujFsjwehPuS096dDS8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "Fva/m+l9o97nj/niIO3eXfVP+I9hCK+Mhm0nrB/ZgBw=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "wSZkmGAeFCCEj0US6ZJaJACCwRuj6Tj5JNirlbkmCcc=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "NFH6cDojgh8QeUFF9EMBi+yBVCj2Pi20Up1qQH3EycU=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Help1" , "Y3CrU9B+tdD80MgmCUoWmpvmByahXIvI5tzUjPZZlQ4=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Help2" , "lYbzNUtHudgFvpoEaIQZ420RBmFJmxjrwNmVrq1V1KA=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Options1" , "PmdPi4VkTI/Dlal5s82jQ3xay2F9xA5n5pfcz0ad4bk=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Options2" , "31itkFsIYHeaNMjwiHXiOkeC4pA4onVejVbvMR9dhS4=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Quit1" , "AuhF4Z+C9UE6huKECVBDMRSs1sUEOCsX2yJRPFJ19do=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Quit2" , "JsbRYVZk+KV1870Nt8rlWb6Le2YLKXU8Gc8NXMCfg3o=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "GXlUgJI9mP+YYqwBU/e+0LeFh9VsCgRLepK3yYLd5JA=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "U5t2Fhn17ahAzH7h+nkgpEpEVf7qBBoGfHd3d9tYnVY=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "2xGQ6lS/KxIwjmv3iu5cWBPGucSLBqcT7bdp8KCDC80=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "nMB8AT0nDCBG0aHPxmTKIvVNMvhVm8wli2zU22edZR8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "QhWvlqpFpjF0GYW3LTRaF7hjogvFH0CjtIGZNS1Q0rc=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "2PjsUHvJWhcAdG/Wq6xydshRL0ufXkj61IQ1QBnAcjo=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "xQ3G4RgOY+/pR4ZjmPkY92Ei/qURxbSmXF3dEGpkuYU=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SZW" , "0Rfvp6ZzoeqC0CN53g7VD1VjqTNY6pRbZyfJhPk16s8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\thanks" , "9+56vhTLNddtzyzVQfaKvf7pUwBwQQYYleVVh8j2P2Q=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\travel" , "Vz1TbErS6YBlJK3xGVltUi+M2wLINDwv675IfMYK774=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\钥匙经典" , "3vVVP4TSpnN+GhcKIorkVC6NiSXU90gQUhUFkp5JV9k=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\Doom" , "wGdj1YC7DgQ9gO+0qOUM3GvWkZvmSmFcdZPRuC0xWg4=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\ExplosionPowie" , "NLVTBUV+qnJSN8iDyN0/X5mCLuMf/gNf0eqQSNgyR/4=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\ExplosionSpudow" , "87XKk/0oU6tGGyCe1/2KzBHucjYc6fpEl6C5MQGz1bI=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\guang" , "4hMjrrMrOOkLgHlLzuIieJGzwy/SzmY/JI6KDKxA9EU=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\Sproing" , "Kt9TlS9eDVObwbNh9iy00bB5WjXufKPZv7i+mxUG9mw=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\SunExplosionPowie" , "DGdHTnCA+6ovq0sE5TwBEayKAuF5cb+MEOv8xX5hmFU=" }, - - { "Localization\\Vietnamese\\Almanac\\LawnStringsTranslate" , "CM3FWxA/MKhudP9bRjsTNY0ozLJ1K0nOVs/awEvOrnA=" }, - { "Localization\\Vietnamese\\Almanac\\ZombieStringsTranslate" , "yFHjQbsTxaw621AXaHzJLDulElVB1YlKI+nUxvjJuus=" }, - { "Localization\\Vietnamese\\Almanac\\AchievementsTextTranslate" , "Pyeukawk/N5uiUBKDs/erVzIzA+uqZZhtP2amyCKKdY=" }, - - // Indonesian - { "Localization\\Indonesian\\Strings\\translation_regexs" , "4hmtjqn06LLDtClO8mlg13blxXj1hPwWdaSjygj7/2I=" }, - { "Localization\\Indonesian\\Strings\\translation_strings" , "qc4bxqtaJeZBI6nxL4jnf+VpQu/xpJKs/89IYfDcNC8=" }, - { "Localization\\Indonesian\\Textures\\Game\\FinalWave" , "EKjMvK+krWb8AEnvhL02z4ETUR4GEbtEspU8xTL0XJY=" }, - { "Localization\\Indonesian\\Textures\\Game\\FlagMeterLevelProgress" , "bZUyDcbcLtz+uG7pnXncJEgBQn6dkE0HUuO0py5Qqtg=" }, - { "Localization\\Indonesian\\Textures\\Game\\HugeWave" , "kHSyCA4DjKiacui1Z2Vij0VSKr3UqI7FeiZp6MiYeRI=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartPlant" , "lraovY3Nx09xinbn9lF3g5OQPBmBzwkCS9EX3PeKrKA=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartReady" , "WwJG+GIHjqZ/3PWlt7MmATmn8gegir5JdWLHSDOyONk=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartSet" , "wnAy+G4MWwVp11UL9OovumPhS+bFoIw188yt7djqd5o=" }, - { "Localization\\Indonesian\\Textures\\Logo\\标题合集" , "i+dOUq/gv+NF4PbSsElYnsoi8WnrHFgTMCA+lEXwH9E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\FlagMeterLevelProgress" , "CzuBH4sm7Nid4zloZF3i0bpNcA9ILPhrmOxVYI4IggA=" }, - { "Localization\\Indonesian\\Textures\\Menu\\MainMenu" , "OZ1gfSCjvhys6N8eeM0OZKX/z/FDLtX6HW3MA/UqgLs=" }, - { "Localization\\Indonesian\\Textures\\Menu\\MainMenutravel" , "V7dmKMS/Ta7LUobEgFudX3hVXCs8GBulEYJUIkvn+do=" }, - { "Localization\\Indonesian\\Textures\\Menu\\NewAdv" , "y9AUQwwNxsOnkPM5LY5DT80cQ/X6WmNsGmzzo1VZdyY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "IZnCr7uu/muNeugOXMVymHMd5wJ+nfANiohpPnXKleo=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "qiAu0iMOKYUs9XDLgZ7LgVd+KiR0Xn0t0jtVNmjl2Yw=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Almanac" , "MAucz/pmIdNnun4hLfp0PDrjESlsAZ/iL49NCYl6feQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Fea3OWEPntAYCFCP1DK0lrqQByQTQJ7TNWhS1wRfk3I=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "BTltkx67dDWnRIL/TaXUKcUYiQFT01zF0IicWldAV+E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "GCd2qh/rfLbLserDnSzPekRvxIS6W9q+FeNWfkEqTcg=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "6W1spOrj4FB/SgOb8851XRMAnXoudOjNyl6z4Egw/rs=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "2MhlockgUB7+YVxv096GrbPItf5IVWtuAiv/o65Dx3E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Help1" , "F3na7RpFGvO8bF5lvQbvJanJQmUqPEO5+vkKo4Cx220=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Help2" , "imagpCvSovqC6SkeR3BAJqH1u9ssin0C6jwIhx0wGpc=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Options1" , "DMwpZW09/p4CFkgsAqMPExEXzQYOb1TAWKURN4LOYc4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Options2" , "s6wcmSMPErvL/4QuRE7ZYWtCg6Nl6A3FeVL1pK8cOrQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Quit1" , "fNNNbsaNEYP3bl3KwlypWIDZNCpm4wVDYUDsjzBw1zU=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Quit2" , "Qm2506IHHfwXKMkqS3gS39hjjZnV3AP2IHJlOrhYpCI=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Store" , "6gVEuBsk1/udDoEATm2tgmWMCkdme0+oxngcJAKrmP4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "grdusCpWrRqZfBuNB1Dj7bKFzyQk3xFReAqoAEKYFhY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Survival_button" , "0DWLUXJ5RYKci+loCThNfHEpk7tKV08vifffcK8owNg=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "AXW4pkVR9twu7/SJYvqScPeNswIoefGCBJXDf7SsXFA=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "Q24q+w0RftOK+HcQTDvjG5xDpIEYMdecJyGTNGoh9+U=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "S2IYcVmWghuxAVeaV67EnZ1ZjxyLuEmqLRhknUAQ9dQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign1" , "aJ7MmKsDxiIuExTTP+b26x548jJC9PR2l5An3/Xdlv4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign2" , "h5NWhUBnM+ro6J6xs7UDPEmT6055qZP49ppF4wIxePw=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "tu3PiZyJK6CcwaV78aQpqXcE5aLaHA9rPpgzMAbcEAk=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "MAMBtit0msOsty3zZ1yczih8NsF+4nA7fw7BkYMjCk0=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "B17BIhLDvt00Opiag4nqg9a6SvClVr3LlCjzMLI00iY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SZW" , "OWT6LXWuE7Tr3nH6wYMuUfh1+K9y4TRqtb570pm7veU=" }, - { "Localization\\Indonesian\\Textures\\Menu\\thanks" , "APJpvesl3m2b09ru53RG0MJWcbpia+teT/SnPrnO55E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\travel" , "YP1AGn+G7iYrZ5NQy08TbVxMjFfH7HzdyAMJtwEQ5L4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\钥匙经典" , "5VCHANL1SD1xv+QsPdIDIGeq1Ksw2Q0O9Z5fH1ilCBE=" }, - { "Localization\\Indonesian\\Textures\\Particles\\Doom" , "8vtJfi6ngoltUJQbyCLvp0RnoRZbbVN+piV6lwR8KgU=" }, - { "Localization\\Indonesian\\Textures\\Particles\\ExplosionPowie" , "mmL5xtnIBT3ffswqXHMiz0rXmbj85rCmiWGNnzQq1oM=" }, - { "Localization\\Indonesian\\Textures\\Particles\\ExplosionSpudow" , "PXVMwcdcn2pL3mN7O3JEMFvI78XGb/POvZ3Sh26bbOw=" }, - { "Localization\\Indonesian\\Textures\\Particles\\guang" , "fWG+wb2CZqaSsaLhiscKXHpqWiyG7Z2qXtHhBzumlSU=" }, - { "Localization\\Indonesian\\Textures\\Particles\\Sproing" , "+CRy8k+5wzAdG5wVPM3sTYny3hCmPURD42qnTOIv898=" }, - { "Localization\\Indonesian\\Textures\\Particles\\SunExplosionPowie" , "ifNQQNn0abUE11stJvwS5wZQm2Y9kPhQx7bXtF0EnCs=" }, - - { "Localization\\Indonesian\\Almanac\\LawnStringsTranslate" , "E/P7S2V3xWCnG/DZfW8shpV1ieJUvPf07U/TyJ9LPok=" }, - { "Localization\\Indonesian\\Almanac\\ZombieStringsTranslate" , "twHrylFgPp+RBQ6l10+QHIxgs/mI7p8lRC9etNsAKSU=" }, - { "Localization\\Indonesian\\Almanac\\AchievementsTextTranslate" , "eRZlZgKN2EtZV9BWYOPHPZHBuhLiHzYC3f/wDcwFnR4=" }, - - // Russian - { "Localization\\Russian\\Strings\\translation_regexs" , "6ASIdaFZLLTSdckI4evzynZY3CtCfTuG/BS0ENft/9I=" }, - { "Localization\\Russian\\Strings\\translation_strings" , "mRs9Kx+QyCO5PUScMWyr1P1f3cIMscK0pWjVP4iinL8=" }, - - { "Localization\\Russian\\Textures\\Game\\FinalWave" , "IOhfHr8EBtJYfpWWtELBUtmJNoxv1TdBFrhEfFPshVc=" }, - { "Localization\\Russian\\Textures\\Game\\FlagMeterLevelProgress" , "bGKyk8MpfsaYt95/NQ8kboA0Uxt6ay5PoL0l0RHZ/+M=" }, - { "Localization\\Russian\\Textures\\Game\\HugeWave" , "w1dq1brhzL0eGwj9GJS0vQZDgYVbWjDxRBx60xToKBc=" }, - { "Localization\\Russian\\Textures\\Game\\StartPlant" , "PIOtRaWW0ZdFMNBgyA3Ca4H4rMSLMvfXFvaY/ZZ/oEo=" }, - { "Localization\\Russian\\Textures\\Game\\StartReady" , "zUT1GiCxMDAPlxCyuYPmmztGxDCVdtjiB7C2+Qffpkg=" }, - { "Localization\\Russian\\Textures\\Game\\StartSet" , "ut3aHNTGhzVBNlvHTFIuyj+6SED8Pu9rOpIWKI0V8MQ=" }, - { "Localization\\Russian\\Textures\\Logo\\标题合集" , "qocM9muRdJBmjrs9yTHTknMLWX27aPY7AdMMdLIzd7c=" }, - { "Localization\\Russian\\Textures\\Menu\\NewAdv" , "PIDRlOMsgrLxpp51rWt//B2cBdmNKKEYTvuMUN0wFvI=" }, - { "Localization\\Russian\\Textures\\Menu\\options_menuback" , "HZfWszRsYXntilq2RRoQg6cYPNF7Api0ppAHYJ46wy4=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "UGbQ44kL1zXnsJcAr4vrZZu0hDSTEbtdKM2shtebg4w=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "drv1AX+e4D/mA+1IqymPQ5RllTfRatuI+a2/2YJD+GE=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Almanac" , "BdotPdigckPxfrORVW5EJucskfLdK06icpH+Q8mS9fs=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "XoTbNX+410xOdf6MX3BZiVlzD3MsWaqpF8KXZyxduXo=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "pcno2qw/DBMHX3VzGUHErYSAiQyGWseDJGjwHWZI//w=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "Bi5w/0q4C9CpWCjZGLLTHQek530srsp0/Kom4W29IG8=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "kfAEG09yl5h6dV0vHmPl6o72+Wu3kzvBXtyw62E1puk=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "VvP4urY9+U0EPEa19fByOzOX4yKuNzD7eLTuxlEBW2M=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Help1" , "jFKhKseKeZ+y1b1lLYBqfsM5GRGv6JVUa+Jo8sb9p0I=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Help2" , "c1xqKGKKyJhznB5vZpT8FkiSD/luKAEOVH7ZSr/rpp8=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Options1" , "BirUdLzY2B3sedbxZ1eqTwSo/l2UW+obPk+oZhhiSUw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Options2" , "SLSw+97otiN10CyE6nX6QqHmiOjQR8aYuBUveZ8Lx9c=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Quit1" , "B5L16JYjqNJSD5pA9vhEq/C4gzFkz7VYnzcORjOytxA=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Quit2" , "+7s74lMPYaJu+U+572MRvmOolp33Q5xmu/TMOmRvlZc=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StartAdventure_Button1" , "f+NFEqcMvJj20nysVA7mlGmFkJZAmmef+Gi8yUvwses=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StartAdventure_Highlight" , "f+NFEqcMvJj20nysVA7mlGmFkJZAmmef+Gi8yUvwses=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Store" , "N+M6I8pUzeEaetRaE1Wjh2j4g7a1uwrBnqR+7zbsxxQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "QiFOWjJqdoRZMbXfTuKJwTdm5a3E6vm0rGkXwMaMCYs=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "ta02SAcbm7ErKiwz4vpZzrtuptJComb4X2DAwx8GiJw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "28+kPzJUSqm5KKrUlA5GOAy5+q//1bknEniSze/Bb6M=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign1" , "8CV21tQ/HxANofuuTatQO1Ul8zXQYwo1rfzU6iozCiU=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign2" , "bG6o/CpJPm9XBfWq/m3f1cquTAOr5fbwRNtx7XEPcqg=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "v7BbNSzfQIVYLVrYSOIO2i1NbplOiQjYyQcR4rR8OJw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "WsYKxhTcuqTFT9jbeOne+W3/opToTbzZFnq7uGulJfQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "aGRi1WWchHxPisQdbkX9xmsALia6I1jo8JpysSHb4BQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SZW" , "eaqxoi1/FlIyUCfEpJnFgl1xoSwqP1XRHFIaobQzD1A=" }, - { "Localization\\Russian\\Textures\\Menu\\thanks" , "Juq3A9M9V/jScckNECv+JB2U7W+y6YivxELZV/nN3JE=" }, - { "Localization\\Russian\\Textures\\Menu\\travel" , "8lXVCidvQOeh8y9kG7xN51Ch9VyL8ThZah/OI1RxN6c=" }, - { "Localization\\Russian\\Textures\\Menu\\钥匙经典" , "wwcruWy65C8iXjA+SY1dvx/hrSQ/KvVkX4OOOZ6lS/s=" }, - { "Localization\\Russian\\Textures\\Particles\\Doom" , "OWddkj4pnY9xmSIuQIL0vb6F091j8UY2PEC4tZ6P3p8=" }, - { "Localization\\Russian\\Textures\\Particles\\ExplosionPowie" , "KbPmKOHVvOH9njUEBWb6SJPEdGOLbpAG0CpliNyUefA=" }, - { "Localization\\Russian\\Textures\\Particles\\ExplosionSpudow" , "k1C6TaoPE0ZRw79UAjDwlRaLjf4Q/b2N6JM9SN1I5fc=" }, - { "Localization\\Russian\\Textures\\Particles\\guang" , "+Xd4hpZk2VEhgHr9HATWRhjEbg4WlmXkh5DA+gXevIs=" }, - { "Localization\\Russian\\Textures\\Particles\\Sproing" , "i33iY8w5LR7Kdqf2vVQ7UmE9SrWZ+5AGepTy5QINyHE=" }, - { "Localization\\Russian\\Textures\\Particles\\SunExplosionPowie" , "BCXJtvwnDvIzc7cFnxN3wxR7t2o1rqa6hulW54PJLrc=" }, - - { "Localization\\Russian\\Almanac\\LawnStringsTranslate" , "NwYjBl+2v0brh38S4AJpHHWDK/1hCJ5VVqY+Cf5jYkU=" }, - { "Localization\\Russian\\Almanac\\ZombieStringsTranslate" , "ejVysCnTehbMFkjAXN7n7NqWespRHmv5cXYM0hMlK0U=" }, - { "Localization\\Russian\\Almanac\\AchievementsTextTranslate" , "ST45TjReYXrBOfT3r2YeDakJm1SN/jtH/5z0Qp6Ms4c=" }, - - // Japanese - { "Localization\\Japanese\\Strings\\translation_regexs" , "YXerYuvclj9na6pQOefuVfJVER28OAb2EkG/kMLqrGQ=" }, - { "Localization\\Japanese\\Strings\\translation_strings" , "hXi0RiHTbzptiAHqko0CRwDDWW9zoRSdQpOXpd4U3BI=" }, - - { "Localization\\Japanese\\Textures\\Game\\FinalWave" , "tyOrI4m+7b595JZufjhesTYXqiSWuNg4Dlm0fN/ZzVg=" }, - { "Localization\\Japanese\\Textures\\Game\\FlagMeterLevelProgress" , "J8Gnugo3MCdQCFNaw91nOWKiYEJltD7EpScPvgJjVdQ=" }, - { "Localization\\Japanese\\Textures\\Game\\StartPlant" , "8+rIjUEkUtyYRsu9ZHsM6B26fT87U6BYHtjhef+sZSc=" }, - { "Localization\\Japanese\\Textures\\Game\\StartReady" , "G0wx/YkdgSZju5xUluqrq554u7ywOGxRPjQwfEEHwSo=" }, - { "Localization\\Japanese\\Textures\\Game\\StartSet" , "4jSRsYZN+mA3pMZQtjtxxo7z8PYpjyM4Ja1coeOERmQ=" }, - { "Localization\\Japanese\\Textures\\Menu\\NewAdv" , "9CgysaFPLkL+h3CB5zLiUxj7Z7xSZCTQKFr/pAvjW4I=" }, - { "Localization\\Japanese\\Textures\\Menu\\options_menuback" , "KcUX62UuqoR0UKas1yijEQP56fWbagBIpSwFIr4df+k=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "nqJjYCKTGCWuIHwSSRDpsJkPK7quA/4UgfX+EZsadsI=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "/oarc88nswGdHzRI7+ol5XUH8pqEudTJ/l4mtWr6ugw=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Almanac" , "GsHU22IdE1GMx+6eDcJoQ/+LJDJwLG3sovrPion7/68=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "7aHSIocT5JbGVTh7addi0+WrON9G6LPv2xmuDy/tPRg=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "ljfdR00zwozWSwI85JwzGAGQgjXL1sCNpr/+juvcx0M=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "hkii/10+OmfcVLNOB3ATpI5iHpPhw7mgiVRAs+kDsHc=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "tf/14faCSFk7b9vFFn64FAAUpLGZVmfInI4K0Qmx9aM=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "1ZC0zr0P3WkXzKvZ17YwkLID/6YYdTx9PZQimMSos6o=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Help1" , "8OR4iqxkdQ3PsxbobY+JaN/w0lXNc2A+Kbec/VJ/QVY=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Help2" , "i60mg9eK5WzjUA0iZfQtvDWq7HImRV14xNqfLzFmELo=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Options1" , "YJZBgCXj/ZH4F8zPo+t4dAGmGMSiDAcybs2xuu1LTiw=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Options2" , "yIbcIgBPjVP3JKNiF6dBPdJ90Yd+fKC+99KUjTfHOqQ=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Quit1" , "hkDaVb8qUDLKPp1MIyGY6x4teZAVev56kjJ7KihPMss=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Quit2" , "Tx8u8J/YpKF0lEd436EJfOMzXVzSWlsWDHBh5s73MU0=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "hn9D4J0aBhdrM23YNrZJXd2qbQrePLru5gCYBR34xgo=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "+RQ4US+xJ23ieUzvO3sBzHJBEmCz5wZz7Gv6UmFjtdk=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "78kL8cLZGoQdNcZjPbXFAkhN9A0zyCun8ieAOUvva3k=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "Fkn7CvIOoeB8QrUUtj2HySgUg5ZR+zvry6jythPN2BY=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "S2xZmAOn82/7uJ0q5Ej4tc59cheMme02Eb/CBjQjULI=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "AE/8V2mkM15VErDDjg0g497fF4S3GYdSDRi9pDq0S+Q=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "KiN9KORVPhugq/laYeo+78CNeNW3CEVpVmi2J2WTNT8=" }, - { "Localization\\Japanese\\Textures\\Menu\\SZW" , "4jkQn+T+/oceMqVHefAyo7G/8LQ/3jZuF41rnEaFVy8=" }, - { "Localization\\Japanese\\Textures\\Menu\\thanks" , "aoTr0qV9HPJLz4WImY9FpU6mbB6Jy2WfOeXULgDWdlc=" }, - { "Localization\\Japanese\\Textures\\Menu\\travel" , "MwowpcnQ4BXqoE6I8n2iP6ZzmVSMNaUpyBkPIkaI2hE=" }, - { "Localization\\Japanese\\Textures\\Menu\\钥匙经典" , "FeQQRbKmP9uOZ37BtcHNjWH46zSe1tCrexTrnWcKX50=" }, - { "Localization\\Japanese\\Textures\\Particles\\Doom" , "x/jlt63Ryze1+Dhjm9A1M65LkwrpuN0tTwn6wq7OtPg=" }, - { "Localization\\Japanese\\Textures\\Particles\\ExplosionPowie" , "uEPr3YXyamejZGcJ9QYxkQ6GOnqK3Ddv5HsgBJCIyl0=" }, - { "Localization\\Japanese\\Textures\\Particles\\ExplosionSpudow" , "4wZzRVJGrKmZDuJXuA8O/0mvLJS08DrhfWiRk6Arb/M=" }, - { "Localization\\Japanese\\Textures\\Particles\\Sproing" , "pKet1LadsHBdq8mOR3IOtOngBHyfxdFLp2hipu8I4ZU=" }, - - { "Localization\\Japanese\\Almanac\\LawnStringsTranslate" , "D4riwyc3qc5fWLhnspeXCgCip2cb5k1/t0PlEPJ7wdY=" }, - { "Localization\\Japanese\\Almanac\\ZombieStringsTranslate" , "AzhgHGtIesVnO8aGJnpnY/C8+5eua2Z3wN887spfz7U=" }, - { "Localization\\Japanese\\Almanac\\AchievementsTextTranslate" , "PAk0G69Abd/8mqXxsrg1dChYjb3/Hmgp2UD9fqVnqXw=" }, - - // Korean - { "Localization\\Korean\\Strings\\translation_regexs" , "zWV/cHF92F+GrFwlSkGXyep2jqBDG5LAiGwyDtcG2rU=" }, - { "Localization\\Korean\\Strings\\translation_strings" , "qXdtfjxdZcK4Oe6ptsZd3Vg4rIavfM06ZkmMfmR8G1M=" }, - - { "Localization\\Korean\\Textures\\Game\\FinalWave" , "7I9i/6CVcPOhoL2n3/NUNOedbaIyQqlsj5U+jVQauu4=" }, - { "Localization\\Korean\\Textures\\Game\\FlagMeterLevelProgress" , "yMpBQDYecmFimlzSnsO8vdyEPp0Q6O5lAg0DWFS1m6M=" }, - { "Localization\\Korean\\Textures\\Game\\StartPlant" , "yGZNl/ELOvk/XqMp5pIhwrSLkAa/T+2pWcYb/tVC8CY=" }, - { "Localization\\Korean\\Textures\\Game\\StartReady" , "aNTSN8/FwAmu63eHs7wzdoDCnw3h3KWQ4SCiPtBoTdQ=" }, - { "Localization\\Korean\\Textures\\Game\\StartSet" , "PcrGZLSUL2xrPGTMzZJBc/xC05UdlWoCeHP8vNm8BjQ=" }, - { "Localization\\Korean\\Textures\\Menu\\NewAdv" , "LidoBW/vXZhokFRjg8MRy7daY4wehQ9vd3dBLwTsFLU=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Adventure_button" , "XvILct+pOLn9Ke3VvtlZPo4Zpob6wgAaNwb5w1+i3z0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "WTyEd+cIWl3fBF1guKAQuMvDdMDwFnsgyZXoklVRTdg=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Almanac" , "7DLBjkU41YWjh6up42n+2DU+UU4jzBcuCyIjoIQhK1E=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "1oUnvwRL6Jr+AwwXJKAB/jcmpWl+0UP69js6vIKZ9uY=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenges_button" , "qoPxgGKWuHKCg3pEmvkauWfmXFZWR0spWcoK6AvLysc=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "840p+IAAw8KPwkoNmvcWcOWwhpTzTtcLixzWr+MunS0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenge_button" , "FwlC3AOwWWeiqereusDpkRatqnKKN3c/xq5iPAhVo5Q=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "RZPSyMMXOr7W5aOWcr5xSR9XiANkWWVk6/OUnxxpUpI=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Help1" , "Akybqv0glw81aMYpGoosQ3PR7Ukhq+cD+ZlEUkLC5Yw=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Help2" , "6RZFnrYjpZM932niXc1qmRtAJm97GlDHzh3Q9c1u5b0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Options1" , "D7hYM4ZPRbA395EUkLhG4jf7lfJqSUalp7oZJQ9/BEs=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Options2" , "1Z3SHvyiFsK7Wy9I2tFONcVYjF50Ho4L2+CbePFqng8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Quit1" , "eD9BNRKQU7qei+eAsCSIidMwvwEhuBLPcpZkb/Q/Ag8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Quit2" , "scNdtWjkMrgtwBdXiS809HfOY+2+ycPqUAgH6RcFOfk=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "QPWZp3PBXeJK8y9Pu7euFoRNVsywdr5tCC6gOsKmlL8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "VGJtLoUZ4+EYlQUMHSOAUFYPwFr30w5/NLyl0G4Ba2Q=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign1" , "CPf6iaNv3ftvdOMQwm/gJ8hXE/13KeS+GHzEBl6DrpM=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign2" , "8Lr0ONZOInR+ZHz9ZQHHdr6e4jkARbxkDIm181Q/yWM=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "8JALSm+TKjNzIAtOd6DXJjkjc0bqEBXhPqlTO6sKZ0c=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_ZenGarden" , "b8bJJeKpQJhesrxy3c3JconWq1RJkMwkOBOi1JcKkUA=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "CwZAzOBJFFY9AG2tvPN58JggPNNEws9zEbcgMlsWEpc=" }, - { "Localization\\Korean\\Textures\\Menu\\SZW" , "ONrElpWA/7WkJq833t+slKToiieJtZhbz2dv2QSuQB0=" }, - { "Localization\\Korean\\Textures\\Menu\\thanks" , "HYnZf9x5uNG5tu5jga94X9+rILjt40bnKSR1qjkXF8M=" }, - { "Localization\\Korean\\Textures\\Menu\\travel" , "T/ngmCI6ilQ6k/pV2XZloY5OICc0bbKz0iwg/mcXpPw=" }, - { "Localization\\Korean\\Textures\\Menu\\钥匙经典" , "iO5Z+/6R8Pz1GoIh+TX5KWkCFJsOxfYYrMSV//9UJ34=" }, - { "Localization\\Korean\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\Korean\\Textures\\Particles\\ExplosionPowie" , "cuikfX+3LOtSw3EPB6DnjANO5bKkoYCMdWSm+StmW70=" }, - { "Localization\\Korean\\Textures\\Particles\\ExplosionSpudow" , "4pJ/gZsuKRsAbUL1YWsaaJC9NxrzhqUiQe6glK07ydU=" }, - { "Localization\\Korean\\Textures\\Particles\\guang" , "kh0dcDxOXgh8+Eq1TmKdJug5PdR+nzZrK5iS5Nkw7Gw=" }, - { "Localization\\Korean\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\Korean\\Textures\\Particles\\SunExplosionPowie" , "3bSjOYpanuLnsl58oYUzOAXt94nony6Drq8qdpfRSGQ=" }, - - { "Localization\\Korean\\Almanac\\LawnStringsTranslate" , "KRMiSTM91FoCR9sTGJU6hvsh0+sBMyHfqXwTSSea27M=" }, - { "Localization\\Korean\\Almanac\\ZombieStringsTranslate" , "xHI2LAW0JSEZN010GZPhPB60N0Csfbev2Mk5RwWFYyQ=" }, - { "Localization\\Korean\\Almanac\\AchievementsTextTranslate" , "J4/ZjY7vFNvwsMBx5eIwP7syuLD/+D7OaTY+YbUnq6s=" }, - - // Custom Textures - { "[Custom Textures]\\Almanac_GroundDay" , "ruvrVDVaICj+5PzN5FIcLTma+GtTb2AuKkHA42jTVBw=" }, - { "[Custom Textures]\\Almanac_GroundNight" , "uwrsmHM/IFY1n+AkYYmgEhoWRoaefOjP6sQMCWLtJ2s=" }, - { "[Custom Textures]\\Almanac_GroundNightPool" , "MQrZAvJDWs7k0c8cQjeNp5WNfB1Yns54Wqib63Glhsg=" }, - { "[Custom Textures]\\Almanac_GroundPool" , "fgHaxsX/KUXzAuRTLE7itRtmjPJ8YPo01Sy6Y2O5XWU=" }, - { "[Custom Textures]\\Almanac_PlantCard" , "1Spu2IG3EoCLn0MhAwMxydN2E8xcffFVfnKGk0KowLY=" }, - { "[Custom Textures]\\Almanac_ZombieBack" , "PUxcz+EA7ehsPkyA3gsicvaANh+7vX56yKbrCNFd8cI=" }, - { "[Custom Textures]\\Almanac_ZombieCard" , "S3QeUIrxZ3BJiovEyHBz0AYIoVzT2mQ1JA5hN3Ke8B0=" }, - { "[Custom Textures]\\Almanac_ZombieWindow" , "0JHTUpc1HdZ8/s/4NVKnchFmyrUaXgTgv3kUwS18zKo=" }, - { "[Custom Textures]\\Almanac_ZombieWindow2" , "NA9+T0M/4BihrNsGQVQCyxX2IO8xuyIKCm1PT6aB/vc=" }, - { "[Custom Textures]\\CursorClick" , "cELLXJkEQM+ULhcuL3GXdJ6Lw9iJF0grx3NuSfI3iGE=" }, - { "[Custom Textures]\\CursorDefault" , "AfBSPF65+ZXswrGKH5NRB/b5oa4WR5vuIet3xQ9/hqc=" }, - { "[Custom Textures]\\plant" , "JqOyre0JXBHjvWqUafUaBEfym62ZVhte6sP68TDn4xQ=" }, - { "[Custom Textures]\\SeedChooser_Background" , "RBVMr9F/IJiTVV9G9iZyUQguN6c+fQGb1BUoyuAKbyY=" }, - { "[Custom Textures]\\seedfog" , "l4gO/839bvGY3zk1/JPHPrZiD5sqVq0dCnCflUr/ilQ=" }, - { "[Custom Textures]\\seedp" , "amr82tmtplngahLPlu4wdPlq5adTKqUMXZoZ9qJ6u1U=" }, - { "[Custom Textures]\\SeedPacketSilhouette" , "W6vow+euXzdwjAufkJuRtdaIEiEPmbeeOkOHiQBNmHA=" }, - { "[Custom Textures]\\SeedPacket_Larger" , "+TZxcpkpyz49vmlkTAYyohpQuneLwrw1eJdYpbN6wAs=" }, - { "[Custom Textures]\\SeedPacket_Night" , "0pv9hCIOuoj9wfH2FP18kNwLkYUz0wuxVs3zl3OiHC0=" }, - { "[Custom Textures]\\SeedPacket_Other" , "Y/xlegVxGFn6Dt1nsDAEFSnslM3lyQ6WyCSl7RfwA5k=" }, - { "[Custom Textures]\\SeedPacket_Pool" , "4m5EDn8xfUtrZ/qENCISIRbZVQEjgk9UN1//AelB1Tw=" }, - { "[Custom Textures]\\seedroof" , "z9o/8qUJkgtys4WmPRvCt/wJz056+0Fjvfvk6pHwbLo=" }, - - { "Localization\\Spanish\\Textures\\[Custom Textures]\\CursorClick" , "4sKy7/xqFJqS/HVR1jUgMNvcPQdv6argIePfdcRhoIk=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\CursorDefault" , "zuNjht1GXgF/fOKCnW7KnOOaccjHRDB9m6giJvkKz1Q=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\garden_new" , "siziOyP+M2D5mI5ugtsjNI1O+zKcRqlHBDGrnSU1EV4=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\Present" , "glh2PeOuG8W1jQBiX8Xh0/4owPMGxFFXdOIc2siZ8Uo=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentOpen" , "9DQZ4GIEeqoATt6MA55HEvQrBueZ3FN9raMdqOIhOUI=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentOpenZ" , "BORx+RuCJUu8FLzDqdZcBFKFzMDbKB0KDZIkk4SnEmM=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentZ" , "3VQDMgCU5gz1uGzQzRSatXOHd50q9nHozgkicb9wEQU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SeedBank" , "ffJswlQikAaPhUily+jKz59tjUUsysRTyPetub7pVw4=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SeedChooser_Background" , "Z3jzRdTSxhpLU9HqeYhcDz+CfP1SerwzYteBh2gEX8M=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\seeds" , "Yaqa1lY4mMxmksslr1WjcV3vYAwrcLT6AVVHEvHS6Mw=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf1" , "wAoIJKiNxAuEkhFW9QjUAXCbdQmq0Q5DtztG+1VWjig=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf2" , "hRe+ceHzLid2ltXXaJsfLg3YHkb0xSwvgFh62XqUnpg=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf3" , "sU5tHuXpjZGsDd0I5BMPmsHj0W4flayrCEhr36iudp8=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf4" , "UnezQl5tm4gUZ3DwYCzRM85siS2dZWuo0HHx09fc/LU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf5" , "a73hDOb3r3gZAgpklCB2EkFjUaUbKJBXKhGT3tYosP0=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaves" , "ll3lRI+y441evcV9CJoFufhI5VQeC2eIew9AFSW8xEU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\ShovelBank" , "DUCNzvvDjIp8Kr8Clyx4eWwApiHiD8RmP+W05Mre+fI=" }, - - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundDay" , "HqSlvHQOonZvcid0jFZAj7az/P8uwKXZMT4Ukwyc8j0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundNight" , "qt947+pENaA91x4lYAYsNLcR6Xd6I1vNh/USyk45arw=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundNightPool" , "A92M4I2N2OfpN/y4R40ATVBrI2U+StgZQjIr0iVCEeU=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundPool" , "AmrvO/C5ggUeHr5+WOh16GWJ0jM1nXR+Vj/A87CRZ3U=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundRoof" , "ftdvDcMiDrdIBIoOTcxU6b9qT+GmPEkH2+tG2HA8blk=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "1Spu2IG3EoCLn0MhAwMxydN2E8xcffFVfnKGk0KowLY=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "PUxcz+EA7ehsPkyA3gsicvaANh+7vX56yKbrCNFd8cI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "S3QeUIrxZ3BJiovEyHBz0AYIoVzT2mQ1JA5hN3Ke8B0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "0JHTUpc1HdZ8/s/4NVKnchFmyrUaXgTgv3kUwS18zKo=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "NA9+T0M/4BihrNsGQVQCyxX2IO8xuyIKCm1PT6aB/vc=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\plant" , "Q5VaxJhSrv/z55FH7YmLBovhYV3zLux887J0IdOpwnc=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedChooser_Background" , "jnVWbr791bRlpO5CYQ5ZC2WPH4d7j8O4ODW41hA88nk=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedfog" , "fyjLtioDqCumbQuOl+4jgUYFqK+cATeOzoNl1qgRttI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedp" , "8qE/ZB7wdjFq6bNr6jWeCsVhhUD+JWORmpXryejDmjI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacketSilhouette" , "W6vow+euXzdwjAufkJuRtdaIEiEPmbeeOkOHiQBNmHA=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "TtCGi5F02Qx/ix9OXY86bMNjHCdch1E7De9wMTp3JIs=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Night" , "3QSOoNwMue9tK30JgCea/K2pGDlDv+Ibhp0NKRoZHN0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Other" , "7tjrV9SIzPaSEpMspdF7tKANXMu6ggeuj4XSy/UVACM=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "U4zfEwx/0mUqIgUYvuQ10T+tWTqJ54V3RUJiA1+FJts=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedroof" , "1W6A3m32iSQZ5WhJHK11tys1OQOvYLgdNGlUOe7wgnY=" }, - - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_IndexBack" , "S8wmWen4Za178Mkwwu8DJkKvvB2c2CRJbaRjIW/zvhw=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "O2UWyplpXK69pTFXYDSA5KiRyKAZ22LCDN71GIb5ZDg=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "L91uR40W1iPLqBd+ouENStDe9RN+xUOZtbF048MiD1U=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "3QvRtOtCpI6sqh26+Zbr9vTR9RB8oSXy4m7iS2snZUI=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "+LHsQLlwsYWEVS11F+SustquGoxjbGiyrs58XwyeYMw=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "e51IJA1bz9dDEvmXtO6CeL6/M6KMXDvojCbTz2MtnLk=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\garden_new" , "WxH9rTrIHkmQeu0ALKfFuI6JvXo1uKQlwvgIc72+lhI=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\plant" , "ZkLNZASMXf7P0621AH2sFm3rbulCrs7otMLrrxiaqsA=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedBank" , "+5f20e56ArqQ3Mt2BXtpSM2vO7SV+mWOzIBalIEh4Ew=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Background" , "kjv++O/zFxvPVoObxFTLXsH2MIp3zae4UJ8zu8kVOhY=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button" , "9d5FghH0XRShLwjivvcKtVqmlOQLZC/RqfT+Urv8PJo=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button_Disabled" , "iTsQO62+/80kG4jELlTnB/AXA8wvQKnqCgvQS4pDVlY=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button_Glow" , "cFJCF740SGrFKt7c5OOAcRSVdW5ZZ6sBuE+T3JSwgOU=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedfog" , "JFjRJErflXFgxgxXXGHr6fjLaVIpoYSS0hlWa5Fi09c=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedlinkage" , "3IAYdQXkrWvDMBpg5Zw4ZRU39zuY9OAd3lVhwp07aMk=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedp" , "oaPa7rvvRy+pP3yUvA82hSNJ9/LQIZ+RVGPfCYvaLUg=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacketSilhouette" , "ca+mkPyRnAjVIZZRieUCHFV2t3qiJnX2YQnd/z3iTvs=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "mFoaC4FBXiufdw/aG0SCLlxzpE1umDx3robELsUPhi8=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Night" , "KZEvxdx4nQnrYVPv8FY4DbVDAQBCjlllMnxXQHJ1gkE=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Other" , "EP7WPPrYdZvxAhRig/FBJWHEw67amJuOO9JO0Kqzh14=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "8eLUx9OWZORq3ItJcbQltcsyc6oPAW9PThEHoul/LY0=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedroof" , "HhNxpjbMgvt2FZdZZ7kfl546x6+5B4B97DgSH80wkMg=" }, - - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_IndexBack" , "DagukR2bViPz88Iu2B5w4QDMs4ykui/BYdk+lyaTK2o=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "O2UWyplpXK69pTFXYDSA5KiRyKAZ22LCDN71GIb5ZDg=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "L91uR40W1iPLqBd+ouENStDe9RN+xUOZtbF048MiD1U=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "3QvRtOtCpI6sqh26+Zbr9vTR9RB8oSXy4m7iS2snZUI=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "+LHsQLlwsYWEVS11F+SustquGoxjbGiyrs58XwyeYMw=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "e51IJA1bz9dDEvmXtO6CeL6/M6KMXDvojCbTz2MtnLk=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\garden_new" , "WxH9rTrIHkmQeu0ALKfFuI6JvXo1uKQlwvgIc72+lhI=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\plant" , "ZkLNZASMXf7P0621AH2sFm3rbulCrs7otMLrrxiaqsA=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedBank" , "+5f20e56ArqQ3Mt2BXtpSM2vO7SV+mWOzIBalIEh4Ew=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Background" , "kjv++O/zFxvPVoObxFTLXsH2MIp3zae4UJ8zu8kVOhY=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button" , "9d5FghH0XRShLwjivvcKtVqmlOQLZC/RqfT+Urv8PJo=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button_Disabled" , "iTsQO62+/80kG4jELlTnB/AXA8wvQKnqCgvQS4pDVlY=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button_Glow" , "cFJCF740SGrFKt7c5OOAcRSVdW5ZZ6sBuE+T3JSwgOU=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedfog" , "JFjRJErflXFgxgxXXGHr6fjLaVIpoYSS0hlWa5Fi09c=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedlinkage" , "3IAYdQXkrWvDMBpg5Zw4ZRU39zuY9OAd3lVhwp07aMk=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedp" , "oaPa7rvvRy+pP3yUvA82hSNJ9/LQIZ+RVGPfCYvaLUg=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "mFoaC4FBXiufdw/aG0SCLlxzpE1umDx3robELsUPhi8=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Night" , "KZEvxdx4nQnrYVPv8FY4DbVDAQBCjlllMnxXQHJ1gkE=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Other" , "EP7WPPrYdZvxAhRig/FBJWHEw67amJuOO9JO0Kqzh14=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "8eLUx9OWZORq3ItJcbQltcsyc6oPAW9PThEHoul/LY0=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedroof" , "HhNxpjbMgvt2FZdZZ7kfl546x6+5B4B97DgSH80wkMg=" }, - #endif - }; - - static string GetCheckSum(string filename) - { - using (var md5 = SHA256.Create()) - { - byte[] bytes = md5.ComputeHash(File.ReadAllBytes(filename)); - return Convert.ToBase64String(bytes); - } - } - - public static void SaveCheckSum() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string checkSumString = JsonSerializer.Serialize(checkSums, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - File.WriteAllText(Path.Combine(stringDir, "MD5.json"), checkSumString); - } - - public static void SaveModifiedChecksum() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string modifiedCheckSumString = JsonSerializer.Serialize(modifiedCheckSums, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - File.WriteAllText(Path.Combine(stringDir, "Modified_MD5.json"), modifiedCheckSumString); - } - - public static bool IsModified(string filepath) - { - string fileName = Path.GetFileNameWithoutExtension(filepath); - string directory = Path.GetDirectoryName(filepath); - string slicedFilePath = directory.Substring(directory.IndexOf("PvZ_Fusion_Translator\\") + "PvZ_Fusion_Translator\\".Length); - string slicedKey = Path.Combine(slicedFilePath, fileName); - - #if DEBUG - if (!checkSums.ContainsKey(slicedKey)) - { - checkSums.Add(slicedKey, GetCheckSum(filepath)); - SaveCheckSum(); - modifiedCheckSums.Add(slicedKey, GetCheckSum(filepath)); - SaveModifiedChecksum(); - } - else - { - if ((checkSums[slicedKey] != GetCheckSum(filepath))) - { - checkSums[slicedKey] = GetCheckSum(filepath); - modifiedCheckSums.Add(slicedKey, GetCheckSum(filepath)); - SaveModifiedChecksum(); - } - } - #elif RELEASE - if (!checkSums.ContainsKey(slicedKey) | (checkSums[slicedKey] != GetCheckSum(filepath))) - { - return true; - } - #endif - return false; - } - - public static void ConvertMD5Json() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string checksumDumpPath = Path.Combine(stringDir, "MD5.json"); - string checksumConvertPath = Path.Combine(stringDir, "MD5Convert.txt"); - string json = File.ReadAllText(checksumDumpPath); - Dictionary dictionary = DeserializeObject>(json); - - using StreamWriter writer = new StreamWriter(checksumConvertPath); - foreach (var kvp in dictionary) - { - string checksumKey = kvp.Key.Replace("\\", "\\\\"); - writer.WriteLine($"{{ \"{kvp.Key}\" , \"{kvp.Value}\" }},"); - } - - Log.LogDebug($"MD5.json converted to MD5Convert.json at {checksumConvertPath}"); - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/AssetStore/FontStore.cs b/BepInEx/AssetStore/FontStore.cs deleted file mode 100644 index 5be4dd3..0000000 --- a/BepInEx/AssetStore/FontStore.cs +++ /dev/null @@ -1,193 +0,0 @@ -using TMPro; -using System.Collections.Generic; -using System.IO; - -namespace PvZ_Fusion_Translator__BepInEx_.AssetStore -{ - public static class FontStore - { - internal static Dictionary fontAssetDict = []; - internal static Dictionary fontAssetDictSecondary = []; - - internal static void Init() - { - // Clear existing dictionaries to prevent duplicate key errors - fontAssetDict.Clear(); - fontAssetDictSecondary.Clear(); - - string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]"); - -#if MULTI_LANGUAGE - foreach (string file in Directory.GetFiles(fontsDir)) - { - string fileName = Path.GetFileNameWithoutExtension(file); - string fileExtension = Path.GetExtension(file); - - if (fileExtension == ".ttf" || fileExtension == ".otf") - { - if (!fileName.EndsWith("_Almanac") && !fileName.EndsWith("_Fallback")) - { - string fontPath = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", fileName + fileExtension); - - TMP_FontAsset fontAsset = FontHandler.LoadTMPFont(fontPath, true); - fontAsset.name = fileName; - if (!fontAssetDict.ContainsKey(fileName)) - { - fontAssetDict.Add(fileName, fontAsset); - } - - Log.LogInfo($"Font for language '{fileName}' loaded"); - } - } - } - - InitFallback(); -#else - string defaultFontDir = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", "English.ttf"); - - TMP_FontAsset defaultFont = FontHandler.LoadTMPFont(defaultFontDir, true); - fontAssetDict.Add("English", defaultFont); -#endif - } - - internal static void InitFallback() - { - string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]"); - foreach (string file in Directory.GetFiles(fontsDir)) - { - string fileName = Path.GetFileNameWithoutExtension(file); - string fileExtension = Path.GetExtension(file); - - if (fileExtension == ".ttf" || fileExtension == ".otf") - { - if (fileName.EndsWith("_Almanac") || fileName.EndsWith("_Fallback")) - { - string fallbackPath = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", fileName + fileExtension); - TMP_FontAsset fallbackFont = FontHandler.LoadTMPFont(fallbackPath, true); - fallbackFont.name = fileName; - - string fileNameLanguage = fileName.Replace("_Fallback", "").Replace("_Almanac", ""); - - if (fontAssetDictSecondary.ContainsKey(fileNameLanguage)) - { - if (fileName.EndsWith("_Fallback")) - { - if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Almanac")) - { - fontAssetDictSecondary.Add(fileNameLanguage + "_Almanac", fontAssetDictSecondary[fileNameLanguage]); - } - fontAssetDictSecondary.Remove(fileNameLanguage); - } - else - { - if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Fallback")) - { - fontAssetDictSecondary.Add(fileNameLanguage + "_Fallback", fontAssetDictSecondary[fileNameLanguage]); - } - fontAssetDictSecondary.Remove(fileNameLanguage); - } - if (!fontAssetDictSecondary.ContainsKey(fileName)) - { - fontAssetDictSecondary.Add(fileName, fallbackFont); - } - } - else - { - if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage)) - { - fontAssetDictSecondary.Add(fileNameLanguage, fallbackFont); - } - } - - // Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded"); - } - } - } - AddFallback(); - } - - public static void AddFallback() - { - foreach (var lang in fontAssetDict.Keys) - { - if (fontAssetDict[lang].fallbackFontAssetTable == null) - { - fontAssetDict[lang].fallbackFontAssetTable = new Il2CppSystem.Collections.Generic.List(); - } - - if (fontAssetDictSecondary.ContainsKey(lang)) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - if (fontAssetDictSecondary.ContainsKey(lang + "_Almanac")) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang + "_Almanac"]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - if (fontAssetDictSecondary.ContainsKey(lang + "_Fallback")) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang + "_Fallback"]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - } - } - -#if MULTI_LANGUAGE - public static TMP_FontAsset LoadTMPFont(string language) - { - if (fontAssetDict.TryGetValue(language, out TMP_FontAsset font)) - { - TMP_FontAsset fontAsset = font; - if (fontAsset.fallbackFontAssetTable != null) - { - // Log.LogInfo("Fallback font for language '" + language + "' loaded. The name of the FB Font is" + fontAsset.fallbackFontAssetTable[0].name); - } - return fontAsset; - } - return fontAssetDict.GetValueOrDefault("English"); - } -#else - public static TMP_FontAsset LoadTMPFont() - { - TMP_FontAsset defaultFont = fontAssetDict["English"]; - return defaultFont; - } -#endif - - public static TMP_FontAsset LoadTMPFontAlmanac(string language) - { - if (fontAssetDictSecondary.ContainsKey(language)) - { - if (fontAssetDictSecondary.TryGetValue(language, out TMP_FontAsset almanacAsset)) - { - return almanacAsset; - } - } - if (fontAssetDictSecondary.ContainsKey(language + "_Almanac")) - { - if (fontAssetDictSecondary.TryGetValue(language + "_Almanac", out TMP_FontAsset almanacAsset)) - { - return almanacAsset; - } - } - - return fontAssetDict.GetValueOrDefault("English"); - } - -#if MULTI_LANGUAGE - public static void Reload() - { - // Get the current language - string currentLanguage = Utils.Language.ToString(); - - // Load the font for the current language - _ = LoadTMPFont(currentLanguage); - } -#endif - - } -} \ No newline at end of file diff --git a/BepInEx/AssetStore/StringStore.cs b/BepInEx/AssetStore/StringStore.cs deleted file mode 100644 index 0fc5372..0000000 --- a/BepInEx/AssetStore/StringStore.cs +++ /dev/null @@ -1,411 +0,0 @@ -using TMPro; -using System.Text.RegularExpressions; -using UnityEngine; -using System.Collections.Generic; -using System.IO; - -namespace PvZ_Fusion_Translator__BepInEx_.AssetStore -{ - public static class StringStore - { - internal static Dictionary stringsDict = []; - - public static Dictionary translationStringRegex = new(); - - public static Dictionary translationString = new(); - - public static Dictionary> patchesStore = new() - { - { "Difficulty", new Dictionary - { - { "English" , "Difficulty:" }, - { "French" , "Difficulté:" }, - { "Italian" , "Difficoltà:" }, - { "German" , "Schwierigkeit:" }, - { "Spanish" , "Dificultad:" }, - { "Portuguese" , "Dificuldade:" }, - { "Filipino" , "Ang Hirap:" }, - { "Vietnamese" , "Độ Khó:" }, - { "Indonesian" , "Kesulitan:" }, - { "Russian" , "Сложность:" }, - { "Japanese" , "困難:" }, - { "Korean", "난이도:" }, - { "Javanese" , "Kesulitan:" }, - { "Polish", "Trudność:"}, - { "Hungarian", "Nehézség:"}, - { "Arabic", "صعوبة:"}, - // { "Ukrainian" , "Складність:" }, - // { "Slovak" , "Náročnosť:" }, - } - }, - { "Zombies", new Dictionary - { - { "English" , "Zombies:" }, - { "French" , "Les Zombies:" }, - { "Italian" , "Zombi:" }, - { "German" , "Zombies:" }, - { "Spanish" , "Zombis:" }, - { "Portuguese" , "Zumbis:" }, - { "Filipino" , "Mga Zombie:" }, - { "Vietnamese" , "Thây Ma:" }, - { "Indonesian" , "Zombi:" }, - { "Russian" , "Зомби:" }, - { "Japanese" , "ゾンビ:" }, - { "Korean", "좀비:" }, - { "Javanese" , "Mayit:" }, - { "Polish" , "Zombi:" }, - { "Hungarian" , "Zombik:" }, - { "Arabic" , "الزومبي:" }, - // { "Ukrainian" , "Зомбі:" }, - // { "Slovak" , "Zombíci:"} - } - } - - }; - - internal static void Init() - { - FileLoader.LoadStrings(); - } - - internal static void Reload() - { - translationString.Clear(); - translationStringRegex.Clear(); - FileLoader.LoadStrings(); - } - - public static TextMeshPro TranslateText(TextMeshPro originalTMP, bool isLog = false) - { - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - string translatedText = TranslateText(originalTMP.text); - originalTMP.font = fontAsset; - originalTMP.text = translatedText; - - return originalTMP; - } - - public static TextMeshProUGUI TranslateText(TextMeshProUGUI originalTMP, bool isLog = false) - { - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - string translatedText = TranslateText(originalTMP.text); - originalTMP.font = fontAsset; - originalTMP.text = translatedText; - - return originalTMP; - } - - public static string TranslateText(string originalText, bool isLog = false) - { - string text = DoTranslateText(originalText, false); - string checkText; - #if DEBUG - Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); - Match match = regex.Match(text); - - if(match.Success) - { - // Log.LogDebug("Untranslated String: " + match.Value); - FileLoader.DumpUntranslatedStrings(text); - } - #endif - checkText = text; - - return checkText; - - } - - public static string TranslateText(string originalText, string pattern, bool isLog = false) - { - if (TestRegex(originalText, pattern) && translationStringRegex.ContainsKey(pattern)) - { - // Extract dynamic parts from the original text - var regex = new Regex(pattern); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = translationString.ContainsKey(groupValue) - ? translationString[groupValue] - : groupValue; - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(translationStringRegex[pattern], [.. dynamicParts]); - } - else - { - if (isLog) - Log.LogDebug($"Text '{originalText}' not translated"); -#if DEBUG - FileLoader.DumpUntranslatedStrings(originalText); -#endif - return originalText; - } - } - - public static string TranslateColorText(string originalText, bool isLog = false) - { - string pattern = @"(]*>.*?)"; - if (TestRegex(originalText, pattern)) - { - return DoTranslateText(originalText, isLog); - } - return originalText; - } - - public static string DoTranslateText(string originalText, bool isLog = false) - { - if (string.IsNullOrEmpty(originalText)) - { - if (isLog) - Log.LogError("Text Null or Empty"); - - return string.Empty; - } - - if (translationString.ContainsKey(originalText)) - { - if (isLog) - Log.LogDebug($"Text '{originalText} found in translationString"); - return translationString[originalText]; - } - - // Regex-based dynamic translation - foreach (var entry in translationStringRegex) - { - if (TestRegex(originalText, entry.Key)) - { - // Extract dynamic parts from the original text - var regex = new Regex(entry.Key); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = translationString.ContainsKey(groupValue) - ? translationString[groupValue] - : groupValue; - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(entry.Value, [.. dynamicParts]); - } - } - - if (isLog) - Log.LogDebug($"Text '{originalText}' not translated"); - return originalText; - } - - public static bool TestRegex(string originalText, string pattern) - { - return Regex.IsMatch(originalText, pattern); - } - - private static TextAlignmentOptions TextAnchorToTMPAlignment(TextAnchor anchor) - { - return anchor switch - { - TextAnchor.UpperLeft => TextAlignmentOptions.TopLeft, - TextAnchor.UpperCenter => TextAlignmentOptions.Top, - TextAnchor.UpperRight => TextAlignmentOptions.TopRight, - TextAnchor.MiddleLeft => TextAlignmentOptions.MidlineLeft, - TextAnchor.MiddleCenter => TextAlignmentOptions.Center, - TextAnchor.MiddleRight => TextAlignmentOptions.MidlineRight, - TextAnchor.LowerLeft => TextAlignmentOptions.BottomLeft, - TextAnchor.LowerCenter => TextAlignmentOptions.Bottom, - TextAnchor.LowerRight => TextAlignmentOptions.BottomRight, - _ => TextAlignmentOptions.Center - }; - } - - public static TextMeshProUGUI ConvertToTextMeshPro(UnityEngine.UI.Text oldText, TMP_FontAsset fontAsset, bool isLog = false) - { - if (oldText == null) - { - Log.LogError("UnityEngine.UI.Text component is null."); - return null; - } - - if (fontAsset == null) - { - Log.LogError("TMP_FontAsset is null. Conversion cannot proceed."); - return null; - } - - // Log.LogInfo($"Converting UnityEngine.UI.Text: {oldText.name}"); - - GameObject textObject = oldText.gameObject; - - // Preserve text content and settings - string originalText = oldText.text; - originalText = TranslateText(originalText, isLog); - TextAnchor alignment = oldText.alignment; - Color color = oldText.color; - - // Remove old Text component - UnityEngine.Object.DestroyImmediate(oldText); - - // Add TextMeshProUGUI component - TextMeshProUGUI newTMP = textObject.AddComponent(); - if (newTMP == null) - { - Log.LogError($"Failed to add TextMeshProUGUI to object: {textObject.name}"); - return null; - } - - // Configure TextMeshProUGUI - newTMP.text = originalText; - newTMP.color = color; - newTMP.alignment = TextAnchorToTMPAlignment(alignment); - newTMP.font = fontAsset; - - // Log.LogInfo($"Successfully converted {textObject.name} to TextMeshProUGUI."); - - return newTMP; - } - - public static void TranslateTextTransform(Transform baseTransform, bool isAutoTextContainer = false, bool isLog = false) - { - if (!baseTransform) return; - -#if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); -#else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); -#endif - - if (fontAsset == null) - { -#if MULTI_LANGUAGE - Log.LogError($"Font for language '{currentLanguage}' not found. Translation aborted."); -#else - Log.LogError("Font not found. Translation aborted."); -#endif - return; - } - - // Local function for processing transforms - void ProcessTextTransform(Transform textTransform) - { - if (!textTransform) return; - - // Handle TextMeshPro components - TextMeshPro textTMP = textTransform.GetComponent(); - if (textTMP) - { - textTMP.text = TranslateText(textTMP.text, isLog); - textTMP.autoSizeTextContainer = isAutoTextContainer; - textTMP.font = fontAsset; - } - - TextMeshProUGUI textTMPUGUI = textTransform.GetComponent(); - if (textTMPUGUI) - { - textTMPUGUI.text = TranslateText(textTMPUGUI.text, isLog); - textTMPUGUI.enableAutoSizing = isAutoTextContainer; - textTMPUGUI.font = fontAsset; - } - - // Handle UnityEngine.UI.Text components - UnityEngine.UI.Text textUI = textTransform.GetComponent(); - if (textUI) - { - ConvertToTextMeshPro(textUI, fontAsset, isLog); - } - } - - // Process specific text paths - ProcessTextTransform(baseTransform.Find("text")); - ProcessTextTransform(baseTransform.Find("text1")); - // ProcessTextTransform(baseTransform.Find("text2")); - - Transform shadowTransform = baseTransform.Find("text/shadow"); - if (shadowTransform) ProcessTextTransform(shadowTransform); - - shadowTransform = baseTransform.Find("text1/shadow"); - if (shadowTransform) ProcessTextTransform(shadowTransform); - -#if TESTING - Transform childTransform = baseTransform.GetChild(0); - if (childTransform) ProcessTextTransform(childTransform); -#endif - } - - public static void TranslateTextUI(TextMeshPro textTMP, bool? isAutoTextContainer = null, bool isLog = false) - { - string currentLanguage = Utils.Language.ToString(); - if (textTMP) - { - textTMP.text = TranslateText(textTMP.text, isLog); - if (isAutoTextContainer!=null) textTMP.autoSizeTextContainer = isAutoTextContainer.Value; - textTMP.font = FontStore.LoadTMPFont(currentLanguage); - } - } - public static void TranslateTextUI(TextMeshProUGUI textTMP, bool? isAutoTextContainer = null, bool isLog = false) - { - string currentLanguage = Utils.Language.ToString(); - if (textTMP) - { - string origText = textTMP.text; - - textTMP.text = TranslateText(origText, isLog) == "" ? origText : TranslateText(origText, isLog); - if (isAutoTextContainer != null) textTMP.autoSizeTextContainer = isAutoTextContainer.Value; - if (origText != textTMP.text) - textTMP.font = FontStore.LoadTMPFont(currentLanguage); - } - } - - public static void TranslateTextUI(TMP_InputField TextInput) - { - string currentLanguage = Utils.Language.ToString(); - if (TextInput) - { - string oriText = TextInput.m_Text; - TextInput.m_Text = TranslateText(oriText); - TextInput.m_OriginalText = TranslateText(oriText); - TextInput.fontAsset = FontStore.LoadTMPFont(currentLanguage); - } - } - - public static void LogAll() - { - Log.LogInfo("Logging all StringStore entries."); - Log.LogInfo("Regex Entries: {0}", translationStringRegex.Count); - Log.LogInfo("String Entries: {0}", translationString.Count); - } - } -} \ No newline at end of file diff --git a/BepInEx/AssetStore/TextureStore.cs b/BepInEx/AssetStore/TextureStore.cs deleted file mode 100644 index 1be856c..0000000 --- a/BepInEx/AssetStore/TextureStore.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.Collections.Generic; -using System.Collections; -using UnityEngine; -using System.IO; - -namespace PvZ_Fusion_Translator__BepInEx_.AssetStore -{ - public static class TextureStore - { - internal static Dictionary textureDict = []; - - internal static Dictionary spriteDict = []; - - internal static void Init() => FileLoader.LoadTextures(); - - internal static void Reload() - { - textureDict.Clear(); - #if MULTI_LANGUAGE - RestoreTextures(); - #endif - if(!Utils.customTextures) - { - FileLoader.LoadDefaultTextures(); - } - FileLoader.LoadTextures(); - } - - public static IEnumerator ReplaceTexturesCoroutine() - { - if (!Utils.customTextures) - { - FileLoader.LoadDefaultTextures(); - } - while (true) - { - ReplaceTextures(); - yield return new WaitForSeconds(0.5f); // Adjust this interval as needed - } - } - - public static void ReplaceTextures() - { - Texture2D[] textures = Resources.FindObjectsOfTypeAll(); - foreach (Texture2D texture in textures) - { - if (texture.name.StartsWith("replaced_")) - continue; - - Utils.TryReplaceTexture2D(texture); - } - } - - #if MULTI_LANGUAGE - public static void RestoreTextures() - { - Texture2D[] textures = Resources.FindObjectsOfTypeAll(); - foreach (Texture2D texture in textures) - { - if (texture != null) - { - texture.name = texture.name.Replace("replaced_", ""); - } - } - } - #endif - - public static void LogAll() - { - Log.LogInfo("Logging all TextureStore entries."); - foreach (KeyValuePair entry in textureDict) - { - Log.LogInfo("TextureDict Entry: " + entry.Key + " | " + entry.Value); - } - } - } -} diff --git a/BepInEx/AssetStore/WarningStore.cs b/BepInEx/AssetStore/WarningStore.cs deleted file mode 100644 index 16e7a4b..0000000 --- a/BepInEx/AssetStore/WarningStore.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System.Runtime.CompilerServices; - -using TMPro; -using UnityEngine; -using UnityEngine.TextCore.Text; -using System.IO; -using System.Collections.Generic; - -namespace PvZ_Fusion_Translator__BepInEx_.AssetStore -{ - public static class WarningStore - { - #if MULTI_LANGUAGE - private static Dictionary warningMessages = new() - { - { "English", ("The only valid source of this translation is from this community:\n" + - "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + - "Plants Hybrid and superhybrid.online, they stole it.\n" + - "Stray away from other sources as they may contain viruses.\n" + - "Please visit our community for future updates.", - "Okay! Got it.") }, - { "French", ("La seule source valide pour cette traduction provient de cette\n" + - "communauté :discord.gg/DPAC5ZVJ8T. Si vous l'avez obtenue \n" + - "ailleurs, comme Plants Hybrid ou superhybrid.online, ils l'ont volée.\n" + - "Évitez les autres sources, car elles peuvent contenir des virus.\n" + - "Veuillez visiter notre communauté pour les mises à jour futures.", - "D'accord !") }, - { "Italian", ("L'unica fonte valida di questa traduzione è questa community:\n" + - "discord.gg/DPAC5ZVJ8T. Se l'hai ottenuta altrove, come \n" + - "Plants Hybrid e superhybrid.online, l'hanno rubata.\n" + - "Evita altre fonti, potrebbero contenere virus.\n" + - "Visita la nostra community per aggiornamenti futuri.", - "Va bene! Ho capito.") }, - { "German", ("Die einzige gültige Quelle für diese Übersetzung stammt aus\n" + - "dieser Community: discord.gg/DPAC5ZVJ8T. Wenn Sie diese \n" + - "irgendwo anders gefunden haben, z. B. bei Plants Hybrid oder \n" + - "superhybrid.online, dann haben sie sie gestohlen.\n" + - "Meiden Sie andere Quellen, da diese Viren enthalten könnten.\n" + - "Bitte besuchen Sie unsere Community für zukünftige Updates.", - "Okay, verstanden!") }, - { "Spanish", ("La única fuente válida de esta traducción proviene de esta\n" + - "comunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\n" + - "otro lugar como Plants Hybrid o superhybrid.online, la robaron.\n" + - "Manténgase alejado de otras fuentes, ya que podrían contener virus.\n" + - "Por favor, visite nuestra comunidad para futuras actualizaciones.", - "¡Entendido!") }, - { "Portuguese", ("O lugar original e seguro dessa tradução vem daqui:\n" + - "discord.gg/DPAC5ZVJ8T. Se você baixou ela de qualquer \n" + - "lugar como Plants Hybrid ou superhybrid.online, eles\n" + - "roubaram. Evite baixar deles, pode conter vírus.\n" + - "Por favor, visite nossa comunidade para atualizações futuras.", - "Okay, entendido.") }, - { "Filipino", ("Ang tanging opisyal na source ng pagsasaling ito ay mula\n" + - "lamang dito: discord.gg/DPAC5ZVJ8T. Kung nakuha nmo ito kahit \n" + - "saan pa tulad ng Plants Hybrid at superhybrid.online, ito ay ninakaw. \n" + - "Lumayo sa ibang source dahil posibleng may kasamang virus.\n" + - "Paki-bisita ang aming komunidad para sa mga darating na update." , - "Naiintindihan!") }, - { "Vietnamese", ("Nguồn duy nhất hợp lệ của bản dịch này là từ cộng\n" + - "đồng này: discord.gg/DPAC5ZVJ8T. Nếu bạn nhận \n" + - "được nó ở bất cứ nơi nào khác như Plants Hybrid \n" + - "hoặc superhybrid.online, họ đã ăn cắp nó.\n" + - "Tránh xa các nguồn khác vì chúng có thể chứa \n" + - "virus. Hãy ghé thăm cộng đồng của chúng tôi để \n" + - "cập nhật trong tương lai.", - "Đồng ý!") }, - { "Indonesian", ("Satu-satunya sumber resmi dari terjemahan ini adalah \n" + - "komunitas kami: discord.gg/DPAC5ZVJ8T. Jika Anda \n" + - "mendapatkannya dari sumber lain seperti Plants Hybrid \n" + - "dan superhybrid.online, mereka mencurinya. \n" + - "Jauhi sumber lain karena mungkin ada virus.\n" + - "Silakan kunjungi komunitas kami untuk pembaruan berikutnya.", - "Oke! Mengerti.") }, - { "Russian", ("Единственный проверенный источник этого перевода —\n" + - "сообщество discord.gg/DPAC5ZVJ8T.\n" + - "Или же его замена https://t.me/nekoshkindom\n" + - "Если вы скачали этот мод где-либо ещё, возможно он содержит вирусы.\n" + - "Программист перевода: LancerX0.\n" + - "Переводчик: Nekosha.", "Хорошо!") }, - { "Japanese", ("この翻訳の唯一の有効なソースは、このコミュニティからです:\n" + - "discord.gg/DPAC5ZVJ8T.Plants Hybridやsuperhybrid.online、\n" + - "YoutubeのBlue Flyが作っているもの、他のどこかでこれを入手した場合、\n" + - "彼らはそれを盗んだことになります。ウイルスが含まれている可能性があるので、\n" + - "他のソースからは離れてください。今後のアップデートについては、\n私たちのコミュニティをご覧ください。", - "了解しました!") }, - { "Korean", ("이 번역은 Bloom(discord.gg/DPAC5ZVJ8T)에서만\n" + - "제공됩니다. Bloom 디스코드 이외의 다른서드 파티 사이트, \n" + - "예를 들어 Plants Hybrid 및 superhybrid.online, 또는\n" + - "유튜브 Blue Fly등에서 제공하는 파일은 무단으로 재배포된 것이며,\n" + - "이런 사이트들에는 바이러스가 포함되어 있을 가능성이 높습니다. \n향후 업데이트를 위해 저희 디스코드를 방문해 주세요.", - "확인") }, - { "Javanese" , ("Sumber mung sing sah kanggo terjemahan iki saka komunitas iki:\n" + - "discord.gg/DPAC5ZVJ8T. Yen sampeyan nemokake iki ing papan\n" + - "liya kaya Plants Hybrid lan superhybrid.online, iku dicolong.\n" + - "Aja nyedhaki sumber liya amarga bisa ngandhut virus. Mangga\n" + - "ngunjungi komunitas kita kanggo nganyari ing mangsa ngarep.", - "Oke! Ngertos.") }, - { "Polish" , ("Jedynym wiarygodnym źródłem tego tłumaczenia jest ta społeczność:\n" + - "discord.gg/DPAC5ZVJ8T. Jeśli znalazłeś to gdziekolwiek indziej, np. \n" + - "Plants Hybrid i superhybrid.online, ukradli to.\n" + - "Omijaj inne źródła, ponieważ mogą zawierać wirusy.\n" + - "Odwiedź naszą społeczność, aby uzyskać przyszłe aktualizacje.", - "Okay! Rozumiem.") }, - { "Hungarian" , ("Ennek a fordításnak az egyetlen érvényes forrása ebből a közösségből származik:\n" + - "discord.gg/DPAC5ZVJ8T. Ha ezt valahol máshol szerezted, például \n" + - "Plants Hybrid és superhybrid.online oldalakon, akkor ők lopták.\n" + - "Kerüld a többi forrást, mert vírusokat tartalmazhatnak.\n" + - "Kérjük, látogass el közösségünkbe a jövőbeli frissítésekért.", - "Oké! Értem.") }, - { "Arabic" , ("The only valid source of this translation is from this community:\n" + - "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + - "Plants Hybrid and superhybrid.online, they stole it.\n" + - "Stray away from other sources as they may contain viruses.\n" + - "Please visit our community for future updates.", - "Okay! Got it.") }, - // { "OTHER" , ("A única fonte válida dessa tradução é desta\ncomunidade: discord.gg/DPAC5ZVJ8T. Se você obteve \nisso em qualquer lugar como Plants Hybrid\ne superhybrid.online,ou Blue Fly do Youtube,\nelses roubaram. Fique longe de sites falsos. Por favor,\nvisite nossa comunidade para futuras atualizações.", "¡Okei! Entendido.") } - // { "OTHER" , ("Ang translation na ito ay galing dito lamang:\ndiscord.gg/DPAC5ZVJ8T. Pag nakuha niyo ito sa iba pa\nkagaya ng Plants Hybrid o superhybrid.online, anumang\nginawagawa ng Blue Fly mula sa Youtube, o anumang\nSub2Unlock links, scam sila. MAG INGAT dahil\nkasi baka may virus 'jan. Join kayo sa discord namin!\nFilipino Translation by ColinPogi" , "Tayo magsi-laro!") } - }; - #else - public static string warningMessage = "La única fuente válida de esta traducción proviene de esta\ncomunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\notro lugar como Plants Hybrid o superhybrid.online, la robaron.\nManténgase alejado de otras fuentes, ya que podrían contener virus.\nPor favor, visite nuestra comunidad para futuras actualizaciones."; - public static string okayButton = "¡Entendido!"; - #endif - - #if MULTI_LANGUAGE - public static (string, string) GetWarningMessage(Utils.LanguageEnum language) - { - if (warningMessages.TryGetValue(language.ToString(), out var message)) - { - - return message; - } - else - { - return warningMessages["English"]; // Default to English if language code is not found - } - } - #endif - - public static void WarningLoad(NoticeMenu noticeMenu) - { - //GameAPP.theGameStatus = GameStatus.OpenOptions; - //GameObject gameObject = UnityEngine.Object.Instantiate(Resources.Load("UI/Prefabs/NoticePauseMenu"), GameAPP.canvas.transform); - //gameObject.name = "WarningMessage"; - //TextMeshProUGUI warning = gameObject.transform.GetChild(0).GetChild(0).GetComponent(); - //TextMeshProUGUI warningShadow = gameObject.transform.GetChild(0).GetChild(1).GetComponent(); - //Transform button = gameObject.transform.GetChild(1); - //warning.transform.position = new Vector3(0.7f, 0.4f, 0f); - //warningShadow.transform.position = new Vector3(0.7f, 0.4f, 0f); - - #if MULTI_LANGUAGE - var (warningMessage, okayButton) = WarningStore.GetWarningMessage(Utils.Language); - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - Transform warningTransform = noticeMenu.transform.FindChild("窗口"); - Transform warningTextTransform = warningTransform.FindChild("文字"); - Transform warningTextShadowTransform = warningTransform.FindChild("文字2"); - - Transform[] array = [warningTextTransform, warningTextShadowTransform]; - - for (int i = 0; i < array.Length; i++) - { - if (array[i] != null) - { - array[i].GetComponent().text = warningMessage; - array[i].GetComponent().font = fontAsset; - } - } - #endif - - //warning.text = warningMessage; - //warningShadow.text = warningMessage; - //warning.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - //warningShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - - //button.GetComponent().buttonNumber = 10; - //button.GetChild(0).GetComponent().text = okayButton; - //button.GetChild(0).GetComponent().font = FontStore.LoadTMPFont(Utils.Language.ToString()); - //button.GetChild(1).GetComponent().text = okayButton; - //gameObject.SetActive(false); - //gameObject.SetActive(true); - } - - #if MULTI_LANGUAGE - - public static bool isWarningMessageLoaded = false; - - public static void WarningReload(Utils.LanguageEnum language, NoticeMenu noticeMenu) - { - // Log.LogInfo("Current Language is " + Utils.OldLanguage); - // Log.LogInfo("Changed Language to " + language); - - if (Utils.OldLanguage.ToString() == language.ToString() && Utils.OldLanguage.ToString() != "English") - { - return; - } - if (!isWarningMessageLoaded) - { - WarningLoad(noticeMenu); - isWarningMessageLoaded = true; - } - - return; - } - #else - - public static bool isWarningMessageLoaded = false; - - public static void WarningReload() - { - if (!WarningStore.isWarningMessageLoaded) - { - WarningStore.WarningLoad(); - WarningStore.isWarningMessageLoaded = true; - } - } - #endif - } -} \ No newline at end of file diff --git a/BepInEx/Core.cs b/BepInEx/Core.cs deleted file mode 100644 index 6d58a9d..0000000 --- a/BepInEx/Core.cs +++ /dev/null @@ -1,185 +0,0 @@ -using BepInEx; -using BepInEx.Configuration; -using BepInEx.Logging; -using BepInEx.Unity.IL2CPP; -using BepInEx.Unity.IL2CPP.Utils; -using TMPro; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_.Patches.Managers; -using System; -using System.IO; -using System.Reflection; -using UnityEngine; - -[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "3.1.1")] -[BepInProcess("PlantsVsZombiesRH.exe")] -public class Core : BasePlugin -{ - public string modsDirectory => Path.Combine(Paths.PluginPath, "PvZ_Fusion_Translator"); - - private static DateTime dtStart; - private static DateTime? dtStartToast; - private static string toast_txt; - - public new static ManualLogSource Log; - public static Core Instance { get; private set; } - public static MonoBehaviour MonoInstance { get; private set; } - - private Coroutine replaceTextureRoutine = null; - - public ConfigEntry configDefaultTextures; - public ConfigEntry configDefaultAudio; - public ConfigEntry configLanguage; - - private static float lastCheck = 0f; - private static float checkTime = 0f; - private static float checkInterval = 2f; - private static bool stringreloaded = false; - - public override void Load() - { - Log = base.Log; - Instance = this; - LoadConfig(); - MonoInstance = AddComponent(); - Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly()); - dtStart = DateTime.Now; - - FileLoader.LoadLanguage(); - - AudioStore.Init(); - TextureStore.Init(); - StringStore.Init(); - FontStore.Init(); - Utils.RegisterPlantIndices(); - - //Utils.RegisterRecipeLinks(); - //PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings(); - - InitCoroutine(); - } - - public override bool Unload() - { - if (replaceTextureRoutine != null) - { - MonoInstance.StopCoroutine(replaceTextureRoutine); - Log.LogDebug("Coroutine Stopped"); - } - FileLoader.SaveLanguage(); - - #if OBFUSCATE && !RELEASE - CheckSumStore.ConvertMD5Json(); - #endif - - return true; - } - public void InitCoroutine() - { - replaceTextureRoutine = MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine()); - } - public static void ShowToast(string message) - { - toast_txt = message; - dtStartToast = DateTime.Now; - } - - public void OnUpdate() - { - ModFeatures.OnLateUpdate(); - - if (Input.GetKeyDown(KeyCode.Insert)) - { - Log.LogInfo("Insert press"); - Utils.OpenSaveDirectory(); - } - - if (Input.GetKeyDown(KeyCode.Delete)) - { - Log.LogInfo("del del"); - Utils.OpenTrello(); - } - if (TowerManager.Instance != null) - { - TowerManager_Patch.UpdateText(); - } - if (Input.GetKeyDown(KeyCode.RightShift)) - { - stringreloaded = !stringreloaded; - } - Core.DebugStringReload(); - } - - public static void DebugStringReload() - { - if (stringreloaded == true) - { - checkTime += Time.deltaTime; - if (checkTime >= checkInterval) - { - StringStore.Reload(); - ShowToast("Strings Reloaded!"); - checkTime = 0f; - } - } - } - - public void OnGUI() - { - #if DEBUG - if (dtStartToast != null) - { - try - { - GUI.Button(new Rect(10f, 10f, 200f, 20f), "\n" + toast_txt + "\n"); - } - catch(Exception e) - { - Log.LogError(e); - } - - TimeSpan? timeSpan = DateTime.Now - dtStartToast; - TimeSpan t = new TimeSpan(0, 0, 2); - if (timeSpan > t) - { - dtStartToast = null; - } - } - #endif - } - - private void LoadConfig() - { - string mainCategory = "PvZ_Fusion_Translator"; - - if(Config.TryGetEntry(new ConfigDefinition(mainCategory, "DefaultTextures"), out configDefaultTextures) == false) - { - configDefaultTextures = Config.Bind(new ConfigDefinition(mainCategory, "DefaultTextures"), false, new ConfigDescription("Use Default Textures + Translation Textures", new AcceptableValueList(true, false))); - } - bool defaultTextures = Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out configDefaultTextures); - - if (Config.TryGetEntry(new ConfigDefinition(mainCategory, "DefaultAudio"), out configDefaultAudio) == false) - { - configDefaultAudio = Config.Bind(new ConfigDefinition(mainCategory, "DefaultAudio"), false, new ConfigDescription("Use Default Audio", new AcceptableValueList(true, false))); - } - bool defaultAudio = Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out configDefaultAudio); - - if (Config.TryGetEntry(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("English", "French", "Italian", "German", "Spanish", "Portuguese", "Indonesian", "Vietnamese", "Javanese", "Russian", "Japanese", "Korean"))); - } - bool language = Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out configLanguage); - } -} - -public class UnityCoroutineHelper : MonoBehaviour -{ - public static UnityCoroutineHelper Instance { get; private set; } - - public void Awake() - { - Instance = this; - } -} \ No newline at end of file diff --git a/BepInEx/Dependencies/AudioImportLib.BepInEx.dll b/BepInEx/Dependencies/AudioImportLib.BepInEx.dll deleted file mode 100644 index 2e87423..0000000 Binary files a/BepInEx/Dependencies/AudioImportLib.BepInEx.dll and /dev/null differ diff --git a/BepInEx/FileLoader.cs b/BepInEx/FileLoader.cs deleted file mode 100644 index b410aee..0000000 --- a/BepInEx/FileLoader.cs +++ /dev/null @@ -1,382 +0,0 @@ -using BepInEx.Configuration; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text.Encodings.Web; -using System.Text.Json; -using UnityEngine; -using UnityEngine.Rendering; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - internal static class FileLoader - { - internal enum AssetType - { - Textures, - Strings, - Dumps, - Almanac, - Sprites - } - - public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null) - { - string languagePath = language.HasValue ? ("Localization" + Path.DirectorySeparatorChar + language.ToString()) : string.Empty; - 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(Utils.LanguageEnum language) -#else - internal static void LoadStrings(bool isLog = false) -#endif - { -#if MULTI_LANGUAGE - string stringDir = GetAssetDir(AssetType.Strings, Utils.Language); -#else - string stringDir = GetAssetDir(AssetType.Strings); -#endif - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - try - { - foreach (string filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories)) - { - -#if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } -#endif - - string fileName = Path.GetFileNameWithoutExtension(filepath); - StringStore.stringsDict[fileName] = filepath; -#if DEBUG - Log.LogInfo("Loading File : " + filepath); -#endif - string jsonString = File.ReadAllText(filepath); - if (fileName.EndsWith("_strings")) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(jsonString); - foreach (var (key, value) in dictionary) - { - StringStore.translationString[key] = value; - } - } - else if (fileName.EndsWith("_regexs")) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(jsonString); - foreach (var (key, value) in dictionary) - { - StringStore.translationStringRegex[key] = value; - } - } - } - SaveStrings(); - DumpJson(); - } - catch (Exception e) - { - Log.LogError("Error loading string."); - Log.LogError(e.GetType() + " " + e.Message); - } - Log.LogInfo("Strings loaded successfully."); - } - - - internal static void LoadTextures() - { - - // Default or Custom Texturse -> English Textures -> Localized Textures - try - { - if (Utils.customTextures) - { - LoadCustomTextures(); - } - else - { - LoadDefaultTextures(); - } - } - catch (Exception e) - { - Log.LogError("Error loading texture setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - -#if MULTI_LANGUAGE - if (Utils.Language != Utils.LanguageEnum.English) - { - LoadLocalizedTextures(Utils.LanguageEnum.English); - } - LoadLocalizedTextures(Utils.Language); -#else - LoadLocalizedTextures(); -#endif - - Log.LogInfo("Textures loaded successfully."); - } - - internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null) - { - ConfigEntry defaultTextureEntry; - Core.Instance.Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out defaultTextureEntry); - - string textureDir = GetAssetDir(AssetType.Textures, language); - - if (!Directory.Exists(textureDir)) - { - Directory.CreateDirectory(textureDir); - } - try - { - foreach (string filepath in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories)) - { - if (filepath.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) && defaultTextureEntry.Value) - { - continue; - } - -#if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } -#endif - -#if DEBUG - Log.LogDebug("Loading File : " + filepath); -#endif - - Texture2D texture2D = Utils.LoadImage(filepath); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - internal static void LoadDefaultTextures() - { - if (Core.Instance.configDefaultTextures.Value) - { - string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]"); - if (!Directory.Exists(textureDefaultDir)) - { - Directory.CreateDirectory(textureDefaultDir); - } - try - { - foreach (string filepath in Directory.EnumerateFiles(textureDefaultDir, "*.png", SearchOption.AllDirectories)) - { - -#if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } -#endif - - Texture2D texture2D = Utils.LoadImage(filepath); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - } - - internal static void LoadCustomTextures() - { - string texturePackDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Textures]"); - - if (!Directory.Exists(texturePackDir)) - { - Directory.CreateDirectory(texturePackDir); - } - try - { - foreach (string filepath in Directory.EnumerateFiles(texturePackDir, "*.png", SearchOption.AllDirectories)) - { -#if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } -#endif - - Texture2D texture2D = Utils.LoadImage(filepath); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = filepath; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - internal static void SaveStrings() - { -#if MULTI_LANGUAGE - string stringDir = GetAssetDir(AssetType.Strings, Utils.Language); -#else - string stringDir = GetAssetDir(AssetType.Strings); -#endif - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - - string translationStringRegex = System.Text.Json.JsonSerializer.Serialize(StringStore.translationStringRegex, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - - File.WriteAllText(Path.Combine(stringDir, "translation_regexs.json"), translationStringRegex); - - string translationString = System.Text.Json.JsonSerializer.Serialize(StringStore.translationString, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - - File.WriteAllText(Path.Combine(stringDir, "translation_strings.json"), translationString); - } - - public static void DumpJson() - { - string dumpDir = GetAssetDir(AssetType.Dumps); - - if (!Directory.Exists(dumpDir)) - { - Directory.CreateDirectory(dumpDir); - } - string LawnStrings = Resources.Load("LawnStrings").text; - string ZombieStrings = Resources.Load("ZombieStrings").text; - string AbyssBuffData = Resources.Load("AbyssBuffData").text; - File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings); - File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings); - File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData); - - Dictionary achievementsList = new Dictionary(); - foreach (var entry in AchievementClip.achievementsText) - { - var key = entry.Key; - var value = entry.Value; - achievementsList.Add(key, new AchievementObject(key, value.Item1, value.Item2)); - } - File.WriteAllText(Path.Combine(dumpDir, "AchievementsText.json"), JsonSerializer.Serialize(achievementsList, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - -//#if DEBUG - public static void DumpUntranslatedStrings(string text) - { - string dumpDir = GetAssetDir(AssetType.Dumps); - string jsonFile = Path.Combine(dumpDir, "UntranslatedStrings.json"); - - if (!Directory.Exists(dumpDir)) - { - Directory.CreateDirectory(dumpDir); - } - - if (!File.Exists(jsonFile)) - { - File.WriteAllText(jsonFile, "{}"); // Initialize empty JSON object - } - - string json = File.ReadAllText(jsonFile); - var untranslatedStrings = JsonSerializer.Deserialize>(json); - - if (!untranslatedStrings.ContainsKey(text)) - { - untranslatedStrings[text] = text; - var options = new JsonSerializerOptions - { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - WriteIndented = true - }; - File.WriteAllText(jsonFile, JsonSerializer.Serialize(untranslatedStrings, options)); - } - } -//#endif - -#if MULTI_LANGUAGE - internal static void LoadLanguage() - { - try - { - // Load the language preference as a string and parse it into the enum - ConfigEntry languageEntry; - Core.Instance.Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out languageEntry); - string languageName = languageEntry.Value; - if (Enum.TryParse(languageName, out Utils.LanguageEnum loadedLanguage)) - { - Utils.Language = loadedLanguage; - } - else - { - Log.LogWarning($"Invalid language '{languageName}' found in preferences. Falling back to English."); - Utils.Language = Utils.LanguageEnum.English; // Default fallback - } - Log.LogWarning($"Loaded language {languageName}"); - } - catch (Exception e) - { - Log.LogError("Error loading language setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - Log.LogInfo($"Language has been loaded: {Utils.Language}"); - } - - internal static void SaveLanguage() - { - try - { - // Save the current language as a string - ConfigEntry languageEntry; - Core.Instance.Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "Language"), out languageEntry); - languageEntry.Value = Utils.Language.ToString(); - Core.Instance.Config.Save(); - - // Ensure changes are written to the config file - // MelonPreferences.Save(); - } - catch (Exception e) - { - Log.LogError("Error saving language setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - // Log.LogInfo($"Language has been saved: {Utils.Language}"); - } -#endif - } -} diff --git a/BepInEx/FontHandler.cs b/BepInEx/FontHandler.cs deleted file mode 100644 index 44869f9..0000000 --- a/BepInEx/FontHandler.cs +++ /dev/null @@ -1,45 +0,0 @@ -using BepInEx; -using PvZ_Fusion_Translator__BepInEx_; -using System.IO; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - public static class FontHandler - { - public static Font LoadFont(this string pathFromModsFolder, bool throwException) - { - string fontFilePath = Path.Combine(Paths.PluginPath, pathFromModsFolder); - if (!File.Exists(fontFilePath)) - { - if (throwException) - Log.LogWarning($"Font not found at path: '{fontFilePath}'."); - return null; - } - - Font font = new Font(); - Font.Internal_CreateFontFromPath(font, fontFilePath); // Default size, adjust as needed - return font; - } - - public static TMP_FontAsset ConvertToTMP(this Font font) - { - TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(font); - if (fontAsset == null) - { - Log.LogWarning($"Failed to create TMP_FontAsset from font '{font.name}'."); - return null; - } - return fontAsset; - } - - public static TMP_FontAsset LoadTMPFont(this string pathFromModsFolder, bool throwException) - { - Font font = pathFromModsFolder.LoadFont(throwException); - if (font == null) - return null; - return font.ConvertToTMP(); - } - } -} \ No newline at end of file diff --git a/BepInEx/Log.cs b/BepInEx/Log.cs deleted file mode 100644 index b9407bf..0000000 --- a/BepInEx/Log.cs +++ /dev/null @@ -1,25 +0,0 @@ -using BepInEx.Logging; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - internal static class Log - { - private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("PvZ_Fusion_Translator"); - - public static void LogDebug(object txt) => Logger.LogDebug(txt); - public static void LogDebug(string txt) => Logger.LogDebug(txt); - public static void LogDebug(string txt, params object[] args) => Logger.LogDebug(string.Format(txt, args)); - - public static void LogInfo(object txt) => Logger.LogInfo(txt); - public static void LogInfo(string txt) => Logger.LogInfo(txt); - public static void LogInfo(string txt, params object[] args) => Logger.LogInfo(string.Format(txt, args)); - - public static void LogWarning(object txt) => Logger.LogWarning(txt); - public static void LogWarning(string txt) => Logger.LogWarning(txt); - public static void LogWarning(string txt, params object[] args) => Logger.LogWarning(string.Format(txt, args)); - - public static void LogError(object txt) => Logger.LogError(txt); - public static void LogError(string txt) => Logger.LogError(txt); - public static void LogError(string txt, params object[] args) => Logger.LogError(string.Format(txt, args)); - } -} \ No newline at end of file diff --git a/BepInEx/ModFeatures.cs b/BepInEx/ModFeatures.cs deleted file mode 100644 index b63a432..0000000 --- a/BepInEx/ModFeatures.cs +++ /dev/null @@ -1,80 +0,0 @@ -//#if DEBUG -using System; -using System.Collections.Generic; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - public static class ModFeatures - { - public enum ModType - { - ReloadStrings, - ReloadTextures, - } - - private class ModFeature - { - public string Name { get; private set; } - public ModType ModType { get; private set; } - public KeyCode KeyCode { get; private set; } - public bool IsActive { get; set; } - - public ModFeature(string name, ModType modType, KeyCode keyCode, bool defaultValue = false) - { - Name = name; - ModType = modType; - KeyCode = keyCode; - IsActive = defaultValue; - } - - public void ToggleFeature() - { - if (ModType == ModType.ReloadStrings) - { - StringStore.Reload(); - Core.ShowToast("Strings Reloaded!"); - return; - } - - if (ModType == ModType.ReloadTextures) - { - TextureStore.Reload(); - Core.ShowToast("Textures Reloaded!"); - return; - } - } - } - - private static readonly Dictionary featureLists = new() - { - { ModType.ReloadStrings, new ModFeature("Reload Strings", ModType.ReloadStrings, KeyCode.Home, true) }, - { ModType.ReloadTextures, new ModFeature("Reload Textures", ModType.ReloadTextures, KeyCode.End, true) }, - }; - - public static void ToggleFeature(ModType modType) - { - if (!featureLists.ContainsKey(modType)) - return; - - featureLists[modType].ToggleFeature(); - } - - public static void OnLateUpdate() - { - foreach (var feature in featureLists.Values) - { - if (feature.KeyCode != KeyCode.None && Enum.IsDefined(typeof(KeyCode), feature.KeyCode)) - { - if (Input.GetKeyDown(feature.KeyCode)) - { - Log.LogDebug(feature.KeyCode); - feature.ToggleFeature(); - } - } - } - } - } -} -//#endif \ No newline at end of file diff --git a/BepInEx/Patches/BaseTextObjects/InGameText_Patch.cs b/BepInEx/Patches/BaseTextObjects/InGameText_Patch.cs deleted file mode 100644 index 2687306..0000000 --- a/BepInEx/Patches/BaseTextObjects/InGameText_Patch.cs +++ /dev/null @@ -1,62 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_.Patches.Managers; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(InGameText))] - public static class InGameText_Patch - { - [HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool), typeof(bool) })] - [HarmonyPrefix] - private static void ShowText_Pre(InGameText __instance, ref string text) => text = StringStore.TranslateText(text, true); - - [HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool), typeof(bool) })] - [HarmonyPostfix] - private static void ShowText_Post(InGameText __instance) - { - #if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - foreach (TextMeshProUGUI txt in __instance.textMeshes) - { - string travelMatch = TravelMgr_Patch.MatchTravelBuff(txt.text); - string originalText = txt.text; - - if (txt.gameObject.name.Contains("shadow")) - { - continue; - } - - if (travelMatch != "") - { - txt.text = travelMatch; - if (txt.gameObject.name.Contains("main")) - { - originalText = txt.text; - Transform shadowText = txt.transform.parent.Find("Text_shadow"); - if (shadowText != null) - { - shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); - } - } - } - else if(System.Text.RegularExpressions.Regex.Match(txt.text, @"(]*>.*?)", System.Text.RegularExpressions.RegexOptions.Singleline).Success) - { - txt.text = StringStore.TranslateColorText(txt.text); - } - else - { - txt.text = StringStore.TranslateText(txt.text, true); - } - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/BaseTextObjects/TMP_InputField_Patch.cs b/BepInEx/Patches/BaseTextObjects/TMP_InputField_Patch.cs deleted file mode 100644 index c8046b6..0000000 --- a/BepInEx/Patches/BaseTextObjects/TMP_InputField_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(TMP_InputField))] - public static class TMP_InputField_Patch - { - [HarmonyPatch(nameof(TMP_InputField.OnEnable))] - [HarmonyPostfix] - private static void OnEnable(TMP_InputField __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - string text = StringStore.TranslateText(__instance.text); - __instance.m_Text = StringStore.TranslateText(text); - __instance.m_OriginalText = StringStore.TranslateText(text); - __instance.m_TextComponent.text = StringStore.TranslateText(text); - } - } - } -} diff --git a/BepInEx/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs b/BepInEx/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs deleted file mode 100644 index bf02d9a..0000000 --- a/BepInEx/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs +++ /dev/null @@ -1,97 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_.Patches.Managers; -using UnityEngine.UI; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(TextMeshProUGUI))] - public static class TextMeshProUGUI_Patch - { - [HarmonyPatch(nameof(TextMeshProUGUI.OnEnable))] - [HarmonyPostfix] - private static void OnEnable(TextMeshProUGUI __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - if(__instance.transform.parent.parent != null) - { - if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) - { - return; - } - } - - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - - if (__instance.name.StartsWith("LevelName")) - { - __instance.text = __instance.text.Replace("\n", " "); - - if (__instance.name == "LevelName2" || __instance.name == "LevelName3") - { - TowerManager_Patch.updatedText.Add(__instance.transform); - } - } - if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) - { - __instance.fontSizeMin = 10; - __instance.fontSize = 12; - } - - // __instance.ForceMeshUpdate(); - } - } - - [HarmonyPatch(nameof(TextMeshProUGUI.Awake))] - [HarmonyPostfix] - private static void Awake(TextMeshProUGUI __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - if (__instance.transform.parent.parent != null) - { - if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) - { - return; - } - } - - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - - if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) - { - __instance.fontSizeMin = 10; - __instance.fontSize = 12; - } - - if (__instance.text == "Полный Хаос" && __instance.transform.parent.parent.Find("Image").GetComponent().activeSprite.name == "Present") - { - __instance.text += "\nБесконечно"; - } - - // __instance.ForceMeshUpdate(); - } - } - } - [HarmonyPatch(typeof(TMP_SubMeshUI))] - public static class TMP_SubMeshUI_Patch - { - [HarmonyPatch(nameof(TMP_SubMeshUI.OnEnable))] - [HarmonyPostfix] - public static void OnEnable(TMP_SubMeshUI __instance) - { - if (!string.IsNullOrEmpty(__instance.textComponent.text)) - { - string text = StringStore.TranslateText(__instance.textComponent.text); - __instance.m_TextComponent.text = StringStore.TranslateText(text); - __instance.textComponent.text = StringStore.TranslateText(text); - } - } - } -} diff --git a/BepInEx/Patches/BaseTextObjects/TextMeshPro_Patch.cs b/BepInEx/Patches/BaseTextObjects/TextMeshPro_Patch.cs deleted file mode 100644 index 0497378..0000000 --- a/BepInEx/Patches/BaseTextObjects/TextMeshPro_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(TextMeshPro))] - public static class TextMeshPro_Patch - { - [HarmonyPatch(nameof(TextMeshPro.OnEnable))] - [HarmonyPostfix] - private static void OnEnable(TextMeshPro __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - if (__instance.transform.parent.name.StartsWith("AlmanacHelp") || __instance.transform.parent.name.StartsWith("CardBank")) - { - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - return; - } else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant") || __instance.transform.name.Contains("Name") || __instance.transform.name.Contains("Tips") || __instance.transform.parent.name.Contains("Signboard") || __instance.transform.parent.name.Contains("text"))) - { - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = true; - } - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/AbyssBuffMenu_Patch.cs b/BepInEx/Patches/GameObjects/AbyssBuffMenu_Patch.cs deleted file mode 100644 index 7e29e91..0000000 --- a/BepInEx/Patches/GameObjects/AbyssBuffMenu_Patch.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.IO; -using System.Text.Json; -using System.Text.RegularExpressions; -using HarmonyLib; -//using MelonLoader.TinyJSON; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using TMPro; -using UnityEngine.TextCore.Text; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AbyssBuffMenu))] - public static class AbyssBuffMenu_Patch - { - public static Dictionary abyssBuffData = new Dictionary(); - - [HarmonyPatch(nameof(AbyssBuffMenu.Awake))] - [HarmonyPostfix] - public static void Post_Awake(AbyssBuffMenu __instance) - { - LoadAbyssBuffData(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - - TranslateWindows(__instance, fontAsset); - } - - [HarmonyPatch(nameof(AbyssBuffMenu.SelectWindow))] - [HarmonyPostfix] - public static void Post_SelectWindow(AbyssBuffMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - TranslateWindows(__instance, fontAsset); - } - - [HarmonyPatch(nameof(AbyssBuffMenu.SetFavorite))] - [HarmonyPostfix] - public static void Post_SetFavorite(AbyssBuffMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - if (abyssBuffData.ContainsKey(text.text)) - { - text.text = abyssBuffData[text.text]; - } - else - { - string translatedRegex = TranslateAbyssBuffRegex(text.text); - if (translatedRegex != null) - { - text.text = translatedRegex; - } - } - - text.font = fontAsset; - } - } - - public static void LoadAbyssBuffData() - { - abyssBuffData.Clear(); - - string abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json")); - abyssBuffData = JsonSerializer.Deserialize>(abyssBuffText); - } - - public static string TranslateAbyssBuffRegex(string originalText) - { - foreach (var x in abyssBuffData) - { - if (x.Key.Contains("{value}")) - { - string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)"); - if (Regex.IsMatch(originalText, pattern)) - { - var regex = new Regex(pattern); - var match = regex.Match(originalText); - - return String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value); - } - } - } - - return null; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/AbyssCheckInBag_Patch.cs b/BepInEx/Patches/GameObjects/AbyssCheckInBag_Patch.cs deleted file mode 100644 index 28e7733..0000000 --- a/BepInEx/Patches/GameObjects/AbyssCheckInBag_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -//using HarmonyLib; -//using System; -//using PvZ_Fusion_Translator__BepInEx_.AssetStore; -//using UnityEngine; -//using UnityEngine.TextCore.Text; -//using UnityEngine.UI; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -//{ - -// [HarmonyPatch(typeof(AbyssCheckInBag))] -// public static class AbyssCheckInBag_Patch -// { -// [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))] -// [HarmonyPostfix] -// private static void MoveFromBag(AbyssCheckInBag __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } - -// [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))] -// [HarmonyPostfix] -// private static void SellIcon(AbyssCheckInBag __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } -// } -//} diff --git a/BepInEx/Patches/GameObjects/AbyssDevelopMenu_Patch.cs b/BepInEx/Patches/GameObjects/AbyssDevelopMenu_Patch.cs deleted file mode 100644 index 411a415..0000000 --- a/BepInEx/Patches/GameObjects/AbyssDevelopMenu_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -//using System.Text.RegularExpressions; -//using HarmonyLib; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using TMPro; -//using PvZ_Fusion_Translator__BepInEx_.AssetStore; -//using UnityEngine.TextCore.Text; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(AbyssDevelopMenu))] -// public static class AbyssDevelopMenu_Patch -// { - -// [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))] -// [HarmonyPostfix] -// private static void UpdateInfo(AbyssDevelopMenu __instance) -// { -// __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); -// __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); - -// TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent(); -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)"; - -// Regex regex = new Regex(regexStr); - -// if (regex.IsMatch(upgradeCostText.text)) -// { -// Match match = regex.Match(upgradeCostText.text); -// int groupCount = match.Groups.Count; - -// List 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); -// } - -// upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]); -// upgradeCostText.font = fontAsset; -// } -// } -// } -//} diff --git a/BepInEx/Patches/GameObjects/AbyssMenu_Patch.cs b/BepInEx/Patches/GameObjects/AbyssMenu_Patch.cs deleted file mode 100644 index 55bfcb7..0000000 --- a/BepInEx/Patches/GameObjects/AbyssMenu_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using Unity.VisualScripting; -using UnityEngine; -using System.Text.RegularExpressions; -using UnityEngine.UI; -using PvZ_Fusion_Translator__BepInEx_; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AbyssMenu))] - public static class AbyssMenu_Patch - { - [HarmonyPatch(nameof(AbyssMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, false); - txt.font = fontAsset; - } - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - [HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))] - [HarmonyPostfix] - private static void UpdateLevelInfo(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)"); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/AbyssSelectBuffWindow_Patch.cs b/BepInEx/Patches/GameObjects/AbyssSelectBuffWindow_Patch.cs deleted file mode 100644 index 7beb3ea..0000000 --- a/BepInEx/Patches/GameObjects/AbyssSelectBuffWindow_Patch.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Text.RegularExpressions; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AbyssSelectBuffWindow))] - public static class AbyssSelectBuffWindow_Patch - { - [HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(AbyssSelectBuffWindow __instance) - { - TranslateBuffWindow(__instance); - } - - [HarmonyPatch(nameof(AbyssSelectBuffWindow.SetBuff))] - [HarmonyPostfix] - private static void SetBuff(AbyssSelectBuffWindow __instance) - { - TranslateBuffWindow(__instance); - } - - public static void TranslateBuffWindow(AbyssSelectBuffWindow __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - AbyssBuffMenu_Patch.LoadAbyssBuffData(); - - foreach (TextMeshProUGUI titleText in __instance.titleText) - { - if (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(titleText.text)) - { - if (titleText.name.Contains("shadow")) - { - titleText.text = Utils.RemoveColorTags(AbyssBuffMenu_Patch.abyssBuffData[titleText.text]); - } - else - { - titleText.text = AbyssBuffMenu_Patch.abyssBuffData[titleText.text]; - } - } - titleText.font = fontAsset; - } - - string translatedIntroduceText = (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(__instance.introduce.text)) ? AbyssBuffMenu_Patch.abyssBuffData[__instance.introduce.text] : AbyssBuffMenu_Patch.TranslateAbyssBuffRegex(__instance.introduce.text); - - if (translatedIntroduceText != null) - { - __instance.introduce.text = translatedIntroduceText; - __instance.introduce.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/AbyssSettlementMenu_Patch.cs b/BepInEx/Patches/GameObjects/AbyssSettlementMenu_Patch.cs deleted file mode 100644 index d8731ce..0000000 --- a/BepInEx/Patches/GameObjects/AbyssSettlementMenu_Patch.cs +++ /dev/null @@ -1,55 +0,0 @@ -//using HarmonyLib; -//using System; -//using System.Collections.Generic; -//using TMPro; -//using PvZ_Fusion_Translator__BepInEx_.AssetStore; -//using Unity.VisualScripting; -//using UnityEngine; -//using System.Text.RegularExpressions; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(AbyssSettlementMenu))] -// public static class AbyssSettlementMenu_Patch -// { - -// [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))] -// [HarmonyPostfix] -// private static void InitSettle(AbyssSettlementMenu __instance) -// { -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// string[] regexStrList = [ -// "第(\\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+)" -// ]; - -// foreach(string regexStr in regexStrList) -// { -// Regex regex = new Regex(regexStr); - -// if (regex.IsMatch(__instance.settleInfo.text)) -// { -// Match match = regex.Match(__instance.settleInfo.text); -// int groupCount = match.Groups.Count; - -// List 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[regexStr], [.. dynamicParts]); -// __instance.settleInfo.font = fontAsset; -// } -// } -// } -// } -//} diff --git a/BepInEx/Patches/GameObjects/AbyssStoreMenu_Patch.cs b/BepInEx/Patches/GameObjects/AbyssStoreMenu_Patch.cs deleted file mode 100644 index a1c5f65..0000000 --- a/BepInEx/Patches/GameObjects/AbyssStoreMenu_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AbyssStoreMenu))] - public static class AbyssStoreMenu_Patch - { - [HarmonyPatch(nameof(AbyssStoreMenu.Update))] - [HarmonyPostfix] - private static void UpdateInfo(AbyssStoreMenu __instance) - { - __instance.yourMoney.text = StringStore.TranslateText(__instance.yourMoney.text); - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureEvolutionMenu_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureEvolutionMenu_Patch.cs deleted file mode 100644 index 23fe212..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureEvolutionMenu_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureEvolutionMenu))] - public static class AdvantureEvolutionMenu_Patch - { - [HarmonyPatch(nameof(AdvantureEvolutionMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureEvolutionMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureHelpMenu_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureHelpMenu_Patch.cs deleted file mode 100644 index 7ba5af7..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureHelpMenu_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureHelpMenu))] - public static class AdvantureHelpMenu_Patch - { - [HarmonyPatch(nameof(AdvantureHelpMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureHelpMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureMenu2_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureMenu2_Patch.cs deleted file mode 100644 index f0926c1..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureMenu2_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureMenu2))] - public static class AdvantureMenu2_Patch - { - [HarmonyPatch(nameof(AdvantureMenu2.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureMenu2 __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureMenu2.AdjustDifficulty))] - [HarmonyPostfix] - private static void AdjustDifficulty(AdvantureMenu2 __instance) - { - __instance.difficulty.text = StringStore.TranslateText(__instance.difficulty.text); - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureMenu_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureMenu_Patch.cs deleted file mode 100644 index 7360d02..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureMenu_Patch.cs +++ /dev/null @@ -1,63 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureMenu))] - public static class AdvantureMenu_Patch - { - [HarmonyPatch(nameof(AdvantureMenu.Start))] - [HarmonyPostfix] - private static void Start(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.ChangeDifficulty))] - [HarmonyPostfix] - private static void ChangeDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.GetChapterDifficulty))] - [HarmonyPostfix] - private static void GetChapterDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.UpdateChapterDifficulty))] - [HarmonyPostfix] - private static void UpdateChapterDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.UpdateStarCount))] - [HarmonyPostfix] - private static void UpdateStarCount(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - public static void TranslateAdvantureMenu(AdvantureMenu __instance) - { - bool hasSBString = StringStore.translationString.ContainsKey(__instance.difficulty.text + "_SB"); - __instance.difficulty.text = Utils.RemoveSizeTags(hasSBString ? StringStore.TranslateText(__instance.difficulty.text + "_SB") : StringStore.TranslateText(__instance.difficulty.text)); - __instance.chapterDifficulty.text = StringStore.TranslateText(__instance.chapterDifficulty.text); - __instance.starCount.text = StringStore.TranslateText(__instance.starCount.text); - - foreach (TextMeshProUGUI text in __instance.title) - { - text.text = StringStore.TranslateText(text.text); - } - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureMissionMenu_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureMissionMenu_Patch.cs deleted file mode 100644 index a26a9e3..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureMissionMenu_Patch.cs +++ /dev/null @@ -1,55 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureMissionMenu))] - public static class AdvantureMissionMenu_Patch - { - [HarmonyPatch(nameof(AdvantureMissionMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureMissionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - - [HarmonyPatch(nameof(AdvantureMissionMenu.InitText))] - [HarmonyPostfix] - private static void InitText(AdvantureMissionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - - [HarmonyPatch(nameof(AdvantureMissionMenu.SwitchAward))] - [HarmonyPostfix] - private static void SwitchAward(AdvantureMissionMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - } -} diff --git a/BepInEx/Patches/GameObjects/AdvantureStarMenu_Patch.cs b/BepInEx/Patches/GameObjects/AdvantureStarMenu_Patch.cs deleted file mode 100644 index 1d9541a..0000000 --- a/BepInEx/Patches/GameObjects/AdvantureStarMenu_Patch.cs +++ /dev/null @@ -1,60 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AdvantureStarMenu))] - public static class AdvantureStarMenu_Patch - { - [HarmonyPatch(nameof(AdvantureStarMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureStarMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.GetNodes))] - [HarmonyPostfix] - private static void GetNodes(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.UpdateStarText))] - [HarmonyPostfix] - private static void UpdateStarText(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.InitTalents))] - [HarmonyPostfix] - private static void InitTalents(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.ResetAward))] - [HarmonyPostfix] - private static void ResetAward(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/AlmanacPlantMenu_Patch.cs b/BepInEx/Patches/GameObjects/AlmanacPlantMenu_Patch.cs deleted file mode 100644 index 3dbb2e6..0000000 --- a/BepInEx/Patches/GameObjects/AlmanacPlantMenu_Patch.cs +++ /dev/null @@ -1,88 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.UI; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using static PvZ_Fusion_Translator__BepInEx_.Utils; -using static PvZ_Fusion_Translator__BepInEx_.Log; -using static AlmanacPlantBank; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacPlantMenu))] - public static class AlmanacPlantMenu_Patch - { - [HarmonyPatch(nameof(AlmanacPlantMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AlmanacPlantMenu __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren(true)) - { - bool isPlantName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background"; - if (text.gameObject.name != "Description" && !isPlantName) - { - text.text = StringStore.TranslateText(text.text); - text.font = font; - text.autoSizeTextContainer = true; - } - } - - // skin button resize - - AlmanacPlantWindow window = __instance.window; - GameObject skinButton = window.skinButton; - GameObject skinTextObj = skinButton.transform.GetChild(0).gameObject; - GameObject skinShadowTextObj = skinTextObj.transform.GetChild(0).gameObject; - TextMeshProUGUI skinShadowText = skinShadowTextObj.GetComponent(); - skinShadowText.text = StringStore.TranslateText("换肤_S"); - skinButton.transform.localScale /= 1.75f; - skinButton.transform.localPosition = new Vector3(0.0f, 111.345f, 0.0f); - skinButton.transform.GetChild(1).Translate(new Vector3(-0.35f, 0)); - skinButton.transform.GetChild(2).Translate(new Vector3(0.35f, 0)); - } - - [HarmonyPatch(nameof(AlmanacPlantMenu.SearchChanged))] - [HarmonyPrefix] - public static bool SearchChanged(AlmanacPlantMenu __instance, ref TMP_InputField inputField) - { - string search = inputField.text; - if (search != StringStore.TranslateText("搜索") && search != "") - { - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); - - string json; - json = File.ReadAllText(path); - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - - PlantData plantData = JsonUtility.FromJson(json); - - Il2CppSystem.Collections.Generic.List searchedPlants = new(); - - foreach (PlantInfo plantInfo in plantData.plants) - { - if (plantInfo.name.ToLower().Contains(search.ToLower())) - { - searchedPlants.Add((PlantType)plantInfo.seedType); - } - } - - __instance.ShowPlants(searchedPlants); - - return false; - } - - return true; - } - } -} - diff --git a/BepInEx/Patches/GameObjects/AlmanacPlantWindow_Patch.cs b/BepInEx/Patches/GameObjects/AlmanacPlantWindow_Patch.cs deleted file mode 100644 index 5dc2db1..0000000 --- a/BepInEx/Patches/GameObjects/AlmanacPlantWindow_Patch.cs +++ /dev/null @@ -1,189 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System; -using UnityEngine; -using UnityEngine.UI; -using System.IO; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using static PvZ_Fusion_Translator__BepInEx_.Log; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacPlantWindow))] - public static class AlmanacPlantWindow_Patch - { - [HarmonyPatch(nameof(AlmanacPlantWindow.UpdateText))] - [HarmonyPostfix] - private static void UpdateText(AlmanacPlantWindow __instance) - { - try - { - if (__instance == null) - { - Log.LogWarning("[AlmanacPlantWindow_Patch] __instance is null"); - return; - } - - if (__instance.showedPlantName == null || __instance.showedPlantIntroduce == null || __instance.plantTextContent == null) - { - Log.LogWarning("[AlmanacPlantWindow_Patch] Required UI components are null"); - return; - } - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogWarning($"[AlmanacPlantWindow_Patch] LawnStringsTranslate.json not found at: {path}"); - return; - } - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary != null && - (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || - FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage))) - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = almanacFontAsset != null; - - TMP_FontAsset fontAsset = null; - fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString()); - - AlmanacPlantBank.PlantData plantData = null; - - plantData = JsonUtility.FromJson(json); - - - bool foundMatch = false; - foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants) - { - if (plantInfo == null) continue; - if (plantInfo.seedType == (int)__instance.currentPlantType) - { - foundMatch = true; - try - { - if (__instance.showedPlantName != null) - { - foreach (TextMeshProUGUI text in __instance.showedPlantName) - { - if (text == null) continue; - text.autoSizeTextContainer = false; - string plantName = plantInfo.name ?? ""; - text.text = $"{Utils.RemoveSizeTags(plantName)} ({plantInfo.seedType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - } - - if (__instance.showedPlantIntroduce != null) - { - string info = plantInfo.info ?? ""; - string introduce = plantInfo.introduce ?? ""; - char[] toTrim = Environment.NewLine.ToCharArray(); - __instance.showedPlantIntroduce.text = Utils.RemoveSizeTags(plantInfo.info) + "\n\n" + Utils.RemoveSizeTags(plantInfo.introduce) + "\n\n" + Utils.RemoveSizeTags(plantInfo.cost).TrimStart(toTrim) + "\n\n"; - __instance.showedPlantIntroduce.font = fontAsset; - __instance.showedPlantIntroduce.margin = new Vector4(6, 2, 12, 0); - __instance.showedPlantIntroduce.enableWordWrapping = true; - __instance.showedPlantIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedPlantIntroduce.ForceMeshUpdate(); - - if (__instance.plantTextContent != null) - { - float textHeight = __instance.showedPlantIntroduce.preferredHeight; - __instance.plantTextContent.sizeDelta = new Vector2(__instance.plantTextContent.sizeDelta.x, textHeight); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacPlantWindow_Patch] Error updating plant info: {ex.Message}"); - } - break; - } - } - - if (!foundMatch && File.Exists(moddedPath)) - { - try - { - string moddedJson = File.ReadAllText(moddedPath); - if (!string.IsNullOrEmpty(moddedJson)) - { - AlmanacPlantBank.PlantData moddedPlantData = JsonUtility.FromJson(moddedJson); - if (moddedPlantData != null && moddedPlantData.plants != null) - { - foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants) - { - if (plantInfo == null) continue; - if (plantInfo.seedType == (int)__instance.currentPlantType) - { - try - { - if (__instance.showedPlantName != null) - { - foreach (TextMeshProUGUI text in __instance.showedPlantName) - { - if (text == null) continue; - text.autoSizeTextContainer = false; - string plantName = plantInfo.name ?? ""; - text.text = $"{Utils.RemoveSizeTags(plantName)} ({plantInfo.seedType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - } - - if (__instance.showedPlantIntroduce != null) - { - string info = plantInfo.info ?? ""; - string introduce = plantInfo.introduce ?? ""; - char[] toTrim = Environment.NewLine.ToCharArray(); - __instance.showedPlantIntroduce.text = Utils.RemoveSizeTags(plantInfo.info) + "\n\n" + Utils.RemoveSizeTags(plantInfo.introduce) + "\n\n" + Utils.RemoveSizeTags(plantInfo.cost).TrimStart(toTrim) + "\n\n"; - __instance.showedPlantIntroduce.font = fontAsset; - __instance.showedPlantIntroduce.margin = new Vector4(6, 2, 12, 0); - __instance.showedPlantIntroduce.enableWordWrapping = true; - __instance.showedPlantIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedPlantIntroduce.ForceMeshUpdate(); - - if (__instance.plantTextContent != null) - { - float textHeight = __instance.showedPlantIntroduce.preferredHeight; - __instance.plantTextContent.sizeDelta = new Vector2(__instance.plantTextContent.sizeDelta.x, textHeight); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacPlantWindow_Patch] Error updating modded plant info: {ex.Message}"); - } - break; - } - } - } - } - } - catch (Exception ex) - { - Log.LogWarning($"[AlmanacPlantWindow_Patch] Error reading ModdedPlantsTranslate.json: {ex.Message}"); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacPlantWindow_Patch] Unexpected error in UpdateText: {ex.Message}\n{ex.StackTrace}"); - } - } - } -} - diff --git a/BepInEx/Patches/GameObjects/AlmanacZombieMenu_Patch.cs b/BepInEx/Patches/GameObjects/AlmanacZombieMenu_Patch.cs deleted file mode 100644 index e85aef2..0000000 --- a/BepInEx/Patches/GameObjects/AlmanacZombieMenu_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using static PvZ_Fusion_Translator__BepInEx_.Log; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacZombieMenu))] - public static class AlmanacZombieMenu_Patch - { - [HarmonyPatch(nameof(AlmanacZombieMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AlmanacZombieMenu __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren(true)) - { - bool isZombieName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background"; - if (text.gameObject.name != "Description" && !isZombieName) - { - text.text = StringStore.TranslateText(text.text); - text.font = font; - text.autoSizeTextContainer = true; - } - } - } - } -} - diff --git a/BepInEx/Patches/GameObjects/AlmanacZombieWindow_Patch.cs b/BepInEx/Patches/GameObjects/AlmanacZombieWindow_Patch.cs deleted file mode 100644 index f20926a..0000000 --- a/BepInEx/Patches/GameObjects/AlmanacZombieWindow_Patch.cs +++ /dev/null @@ -1,187 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System; -using UnityEngine; -using UnityEngine.UI; -using System.IO; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using static PvZ_Fusion_Translator__BepInEx_.Log; -using PvZ_Fusion_Translator__BepInEx_.Patches.Managers; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacZombieWindow))] - public static class AlmanacZombieWindow_Patch - { - [HarmonyPatch(nameof(AlmanacZombieWindow.UpdateText))] - [HarmonyPostfix] - private static void UpdateText(AlmanacZombieWindow __instance) - { - try - { - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogWarning($"[AlmanacZombieWindow_Patch] ZombieStringsTranslate.json not found at: {path}"); - return; - } - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary != null && - (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || - FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage))) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = almanacFontAsset != null; - } - - TMP_FontAsset fontAsset = null; - fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString()); - - ZombieAlmanacData zombieAlmanacData = null; - zombieAlmanacData = JsonUtility.FromJson(json); - var zombieDataDic = ZombieDataManager.zombieDataDic; - - bool foundMatch = false; - foreach (ZombieInfo zombieInfo in zombieAlmanacData.zombies) - { - if (zombieInfo == null) continue; - if (zombieInfo.theZombieType == __instance.currentZombieType) - { - foundMatch = true; - try - { - if (__instance.showedZombieName != null) - { - foreach (TextMeshProUGUI text in __instance.showedZombieName) - { - if (text == null) continue; - text.autoSizeTextContainer = false; - string zombieName = zombieInfo.name ?? ""; - text.text = $"{Utils.RemoveSizeTags(zombieName)} ({(int)zombieInfo.theZombieType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - } - - if (__instance.showedZombieIntroduce != null) - { - string info = zombieInfo.info ?? ""; - string introduce = zombieInfo.introduce ?? ""; - - ZombieDataManager.ZombieData zombieData = zombieDataDic[__instance.currentZombieType]; - - string spawnInfo = ""; - string spawnInfoFormat = StringStore.translationStringRegex["出怪等级: (\\d+)\\n出怪权重: (\\d+)"]; - if(spawnInfoFormat != null) - { - spawnInfo = string.Format(spawnInfoFormat, new object[] { zombieData.summonLevel, zombieData.summonWeight }) + "\n\n"; - } - - __instance.showedZombieIntroduce.text = Utils.RemoveSizeTags(info) + "\n\n" + spawnInfo + Utils.RemoveSizeTags(introduce) + "\n\n"; - __instance.showedZombieIntroduce.font = fontAsset; - __instance.showedZombieIntroduce.margin = new Vector4(3, 2, 12, 0); - __instance.showedZombieIntroduce.enableWordWrapping = true; - __instance.showedZombieIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedZombieIntroduce.ForceMeshUpdate(); - - if (__instance.zombieTextContent != null) - { - float textHeight = __instance.showedZombieIntroduce.preferredHeight; - __instance.zombieTextContent.sizeDelta = new Vector2(__instance.zombieTextContent.sizeDelta.x, textHeight); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacZombieWindow_Patch] Error updating zombie info: {ex.Message}"); - } - break; - } - } - - if (!foundMatch && File.Exists(moddedPath)) - { - try - { - string moddedJson = File.ReadAllText(moddedPath); - if (!string.IsNullOrEmpty(moddedJson)) - { - ZombieAlmanacData moddedZombieData = JsonUtility.FromJson(moddedJson); - if (moddedZombieData != null && moddedZombieData.zombies != null) - { - foreach (ZombieInfo zombieInfo in moddedZombieData.zombies) - { - if (zombieInfo == null) continue; - if (zombieInfo.theZombieType == __instance.currentZombieType) - { - try - { - if (__instance.showedZombieName != null) - { - foreach (TextMeshProUGUI text in __instance.showedZombieName) - { - if (text == null) continue; - text.autoSizeTextContainer = false; - string zombieName = zombieInfo.name ?? ""; - text.text = $"{Utils.RemoveSizeTags(zombieName)} ({(int)zombieInfo.theZombieType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - } - - if (__instance.showedZombieIntroduce != null) - { - string info = zombieInfo.info ?? ""; - string introduce = zombieInfo.introduce ?? ""; - __instance.showedZombieIntroduce.text = Utils.RemoveSizeTags(info) + "\n\n" + Utils.RemoveSizeTags(introduce) + "\n\n"; - __instance.showedZombieIntroduce.font = fontAsset; - __instance.showedZombieIntroduce.margin = new Vector4(3, 2, 12, 0); - __instance.showedZombieIntroduce.enableWordWrapping = true; - __instance.showedZombieIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedZombieIntroduce.ForceMeshUpdate(); - - if (__instance.zombieTextContent != null) - { - float textHeight = __instance.showedZombieIntroduce.preferredHeight; - __instance.zombieTextContent.sizeDelta = new Vector2(__instance.zombieTextContent.sizeDelta.x, textHeight); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacZombieWindow_Patch] Error updating modded zombie info: {ex.Message}"); - } - break; - } - } - } - } - } - catch (Exception ex) - { - Log.LogWarning($"[AlmanacZombieWindow_Patch] Error reading ModdedZombiesTranslate.json: {ex.Message}"); - } - } - } - catch (Exception ex) - { - Log.LogError($"[AlmanacZombieWindow_Patch] Unexpected error in UpdateText: {ex.Message}\n{ex.StackTrace}"); - } - } - } -} - diff --git a/BepInEx/Patches/GameObjects/Almanac_Patch.cs b/BepInEx/Patches/GameObjects/Almanac_Patch.cs deleted file mode 100644 index 5ae5678..0000000 --- a/BepInEx/Patches/GameObjects/Almanac_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(Almanac))] - public static class Almanac_Patch - { - [HarmonyPatch(nameof(Almanac.Awake))] - [HarmonyPostfix] - private static void Awake(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - } - - [HarmonyPatch(nameof(Almanac.OldAlmanac))] - [HarmonyPostfix] - private static void OldAlmanac(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - } - - [HarmonyPatch(nameof(Almanac.AnimSwitch))] - [HarmonyPostfix] - private static void AnimSwitch(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - } - - public static void TranslateAlmanacMenu(Almanac __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - if (text.text == "关闭") - { - text.text = StringStore.TranslateText("合上"); - } - else - { - text.text = StringStore.TranslateText(text.text); - } - text.font = font; - } - } - } -} - diff --git a/BepInEx/Patches/GameObjects/BaseMenu_Patch.cs b/BepInEx/Patches/GameObjects/BaseMenu_Patch.cs deleted file mode 100644 index 7d7bd47..0000000 --- a/BepInEx/Patches/GameObjects/BaseMenu_Patch.cs +++ /dev/null @@ -1,41 +0,0 @@ -using HarmonyLib; -using System.Collections.Generic; -using System.Linq; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(BaseMenu))] - public static class BaseMenu_Patch - { - [HarmonyPatch(nameof(BaseMenu.Awake))] - [HarmonyPostfix] - private static void Awake(BaseMenu __instance) - { - TranslateBaseMenu(__instance, "Level"); - TranslateBaseMenu(__instance, "Levels"); - TranslateBaseMenu(__instance, "CustomLevel"); - } - - public static void TranslateBaseMenu(BaseMenu __instance, string levelsName) - { - Transform levels = __instance.transform.Find(levelsName); - if (levels != null) - { - List children = levels.GetComponentsInChildren(true).ToList(); - foreach (Transform child in children) - { - if (child.name == "Nextpage" || child.name == "LastPage" || child.name == "BackToIndex") - { - StringStore.TranslateTextTransform(child); - } - } - - StringStore.TranslateTextTransform(__instance.transform.Find("Goback")); - StringStore.TranslateTextTransform(__instance.transform.Find("Switich")); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/Board_Patch.cs b/BepInEx/Patches/GameObjects/Board_Patch.cs deleted file mode 100644 index 149d36c..0000000 --- a/BepInEx/Patches/GameObjects/Board_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(Board))] - public static class Board_Patch - { - [HarmonyPatch(nameof(Board.Update))] - [HarmonyPostfix] - private static void Update(Board __instance) - { - foreach (SpriteRenderer spriteRenderer in __instance.GetComponentsInChildren()) - { - if (spriteRenderer.sprite != null) - { - if (TextureStore.spriteDict.ContainsKey(spriteRenderer.sprite.name) && spriteRenderer.drawMode != SpriteDrawMode.Sliced) - { - spriteRenderer.drawMode = SpriteDrawMode.Sliced; - } - } - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssBuffButton_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/AbyssBuffButton_Patch.cs deleted file mode 100644 index 83a2ad1..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssBuffButton_Patch.cs +++ /dev/null @@ -1,53 +0,0 @@ -#if FIX -using System.Text.RegularExpressions; -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(AbyssBuffButton))] - public static class AbyssBuffButton_Patch - { - [HarmonyPatch(nameof(AbyssBuffButton.SetType))] - [HarmonyPostfix] - private static void SetType(AbyssBuffButton __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Regex regex = new Regex("([^\\s]+)\n价格:(\\d+)"); - - if (regex.IsMatch(__instance.description.text)) - { - Match match = regex.Match(__instance.description.text); - int groupCount = match.Groups.Count; - - List 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); - MelonLogger.Msg(translatedValue); - } - - __instance.description.text = string.Format(StringStore.translationStringRegex["([^\\s]+)\n价格:(\\d+)"], [.. dynamicParts]); - __instance.description.font = fontAsset; - } - } - - [HarmonyPatch(nameof(AbyssBuffButton.SetSold))] - [HarmonyPostfix] - private static void SetSold(AbyssBuffButton __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.description.text = StringStore.TranslateText(__instance.description.text); - __instance.description.font = fontAsset; - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs deleted file mode 100644 index 264f419..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -//using HarmonyLib; -//using System; -//using PvZ_Fusion_Translator__BepInEx_.AssetStore; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -//{ -// [HarmonyPatch(typeof(AbyssCheckSellMenu))] -// public static class AbyssCheckSellMenu_Patch -// { -// [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))] -// [HarmonyPostfix] -// private static void SellIcon(AbyssCheckSellMenu __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } - -// [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))] -// [HarmonyPostfix] -// private static void MoveInBag(AbyssCheckSellMenu __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } -// } -//} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssLevelEnter_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/AbyssLevelEnter_Patch.cs deleted file mode 100644 index 5e85488..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/AbyssLevelEnter_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(AbyssLevelEnter))] - public static class AbyssLevelEnter_Patch - { - [HarmonyPatch(nameof(AbyssLevelEnter.SetLevel))] - [HarmonyPostfix] - private static void SetLevel(AbyssLevelEnter __instance) - { - __instance.levelName = StringStore.TranslateText(__instance.levelName); - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs deleted file mode 100644 index b469518..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Linq; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(Advanture_Btn))] - public static class Advanture_Btn_Patch - { - [HarmonyPatch(nameof(Advanture_Btn.Start))] - [HarmonyPostfix] - private static void Start(Advanture_Btn __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs deleted file mode 100644 index 1342f06..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Linq; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(CustomLevelEnter))] - public static class CustomLevelEnter_Patch - { - [HarmonyPatch(nameof(CustomLevelEnter.Start))] - [HarmonyPostfix] - private static void Start(CustomLevelEnter __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = (StringStore.translationString.ContainsKey(originalKey + "_IZ")) ? StringStore.TranslateText(originalKey + "_IZ") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs deleted file mode 100644 index 7b813d0..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(ExploreMakeSceneButton))] - public class ExploreMakeSceneButton_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ExploreMakeSceneButton.Start))] - public static void Start(ExploreMakeSceneButton __instance) - { - __instance.sceneText.text = (StringStore.translationString.ContainsKey(__instance.sceneText.text + "_FS")) ? StringStore.TranslateText(__instance.sceneText.text + "_FS") : StringStore.TranslateText(__instance.sceneText.text); - __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs deleted file mode 100644 index 1429902..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(ExploreMakeZombieButton))] - public class ExploreMakeZombieButton_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ExploreMakeZombieButton.Start))] - public static void Start(ExploreMakeZombieButton __instance) - { - __instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType); - __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs deleted file mode 100644 index 52a196a..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs +++ /dev/null @@ -1,41 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(InGameBtn))] - public static class InGameBtn_Patch - { - [HarmonyPatch(nameof(InGameBtn.Update))] - [HarmonyPostfix] - private static void Update(InGameBtn __instance) - { - Transform sceneText = __instance.transform.FindChild("SceneText"); - if(sceneText != null) - { - TextMeshProUGUI sceneTextTMP = sceneText.transform.GetComponent(); - if(sceneTextTMP != null) - { - sceneTextTMP = AssetStore.StringStore.TranslateText(sceneTextTMP); - } - Transform sceneTextShadow = sceneText.transform.FindChild("SceneText"); - if(sceneTextShadow != null) - { - TextMeshProUGUI sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); - if (sceneTextShadowTMP != null) - { - sceneTextShadowTMP = AssetStore.StringStore.TranslateText(sceneTextShadowTMP); - } - } - } - - foreach(TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs deleted file mode 100644 index 15b67f5..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(MainMenu_Btn))] - public static class MainMenu_Btn_Patch - { - //[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))] - //[HarmonyPostfix] - //private static void OnMouseEnter(MainMenu_Btn __instance) - //{ - // string textToShow = null; - - // if (__instance.transform.parent.name == "recipe") - // { - // textToShow = "探索模式"; - // } - // else if (__instance.name == "mysterious") - // { - // textToShow = "神秘模式"; - // } - - // if (textToShow != null) - // { - // InGameText.Instance.ShowText(textToShow, 2.0f); - // } - //} - } -} - - diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs deleted file mode 100644 index 79ad47d..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(NormalBtn))] - public class NormalBtn_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))] - public static void OnMouseUpAsButton(NormalBtn __instance) - { - if (__instance.transform.childCount > 0) - { - Transform banTransform = __instance.transform.GetChild(0); - if (banTransform != null) - { - banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); - } - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs deleted file mode 100644 index 6c79998..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs +++ /dev/null @@ -1,345 +0,0 @@ -#if MULTI_LANGUAGE -using HarmonyLib; -using System.Collections.Generic; -using System; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.UIElements; -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 OptionBtn Button { get; set; } - public Vector3 Position { get; set; } - 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 shifted = false; -} - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - internal class OptLanguageBtn_Patch - { - public static Dictionary LanguageBtnDict = new(); - public static Dictionary ToggleBtnDict = new(); - private static bool buttonsCreated = false; - private static bool togglesCreated = false; - private static OptionBtn cachedTemplateButton; - private static OptionBtn cachedTemplateToggleButton; - - private const float startX = 4.3241f + 2.56f; - private const float startY = 2.7769f; - private const float ySpacing = 1.2505f; - - private const float toggleStartX = 4.3241f; - private const float toggleStartY = -2.2251f; - - private static List AvailableLanguages; - private static List AvailableToggles; - private const int LanguagesPerPage = 5; - private static int currentPage = 0; - 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) - { - if (buttonsCreated) return; - buttonsCreated = true; - cachedTemplateButton = templateButton; - - AvailableLanguages = Enum.GetValues(typeof(Utils.LanguageEnum)) - .Cast() - .Where(lang => lang != Utils.LanguageEnum.LANG_END) - .ToList(); - - for (int i = 0; i < 6; i++) - { - var newButton = Object.Instantiate(templateButton, templateButton.transform.parent); - newButton.optionType = 80 + i; - - float yPos = startY - i * ySpacing; - Vector3 pos = new(startX, yPos); - newButton.transform.position = pos; - - buttonSlots[i] = newButton; - - LanguageBtnDict[newButton.GetInstanceID()] = new OptionButtonData - { - Button = newButton, - Position = pos - }; - } - - UpdatePage(); - } - - public static void CreateToggleButtons(OptionBtn templateButton) - { - if (togglesCreated) return; - togglesCreated = true; - cachedTemplateToggleButton = templateButton; - - AvailableToggles = Enum.GetValues(typeof(Utils.ToggleEnum)) - .Cast() - .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() - { - int startIndex = currentPage * LanguagesPerPage; - int langCount = AvailableLanguages.Count; - int toggleCount = (togglesCreated) ? AvailableToggles.Count : 0; - - for (int i = 0; i < 5; i++) - { - var btn = buttonSlots[i]; - var data = LanguageBtnDict[btn.GetInstanceID()]; - - if (startIndex + i < langCount) - { - var lang = AvailableLanguages[startIndex + i]; - data.Language = lang; - data.IsNextButton = false; - btn.gameObject.SetActive(true); - UpdateButtonText(btn, lang.ToString()); - } - else - { - data.Language = null; - data.IsNextButton = false; - btn.gameObject.SetActive(false); - } - } - - 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 - var nextBtn = buttonSlots[5]; - var nextData = LanguageBtnDict[nextBtn.GetInstanceID()]; - nextData.Language = null; - nextData.IsNextButton = true; - nextBtn.gameObject.SetActive(true); - UpdateButtonText(nextBtn, "Next"); - } - - public static void UpdateButtonText(OptionBtn button, string languageName) - { - TMP_FontAsset defaultAsset = FontStore.LoadTMPFont("English"); - - for (int i = 0; i < 3; i++) - { - Transform textTransform = button.transform.GetChild(i); - if (textTransform != null) - { - if (i == 0) textTransform.gameObject.SetActive(false); - - TextMeshProUGUI text = textTransform.GetComponent(); - if (text != null) - { - if (i == 0) - { - text.text = ""; - text.color = Color.red; - } - else - { - text.text = languageName; - } - text.fontSize = 16; - text.font = defaultAsset; - text.autoSizeTextContainer = false; - } - } - } - } - - private static void FlashMessage(OptionBtn button, string message, float yShift = 0.0f) - { - var child = button.transform.GetChild(0); - if (child != null) - { - var text = child.GetComponent(); - if (text != null) - { - 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); - - System.Threading.Tasks.Task.Delay(1000).ContinueWith(_ => - { - if (button != null && child != null && child.gameObject.activeSelf) - { - child.gameObject.SetActive(false); - } - }); - } - } - - private static void ToggleCustomAssets(string type) - { - if (type != "Textures" && type != "Audio") return; - - if (type == "Textures") - { - ConfigEntry customTexturesEntry; - Core.Instance.Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out customTexturesEntry); - customTexturesEntry.BoxedValue = !customTexturesEntry.Value; // Toggle the config value - TextureStore.Reload(); - Coroutine replaceTextureRoutine = Core.MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine()); - } - - if (type == "Audio") - { - ConfigEntry customAudioEntry; - Core.Instance.Config.TryGetEntry(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out customAudioEntry); - customAudioEntry.BoxedValue = !customAudioEntry.Value; // Toggle the config value - } - Core.Instance.Config.Save(); - } - - [HarmonyPatch(typeof(OptionBtn))] - public static class OptLangBtn_Patch - { - [HarmonyPatch(nameof(OptionBtn.Awake))] - [HarmonyPostfix] - private static void Awake(OptionBtn __instance) - { - if (!buttonsCreated || cachedTemplateButton == null) - { - buttonsCreated = false; - togglesCreated = false; - CreateLanguageButtons(__instance); - CreateToggleButtons(__instance); - } - } - - [HarmonyPatch("OnMouseUpAsButton")] - [HarmonyPrefix] - private static void OnMouseUpAsButton(OptionBtn __instance) - { - if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) - { - if (btnData.IsNextButton) - { - currentPage = (currentPage + 1) % (int)Math.Ceiling((float)AvailableLanguages.Count / LanguagesPerPage); - UpdatePage(); - return; - } - - if (btnData.Language is Utils.LanguageEnum selectedLang) - { - string currentLang = Utils.Language.ToString(); - - if (currentLang == selectedLang.ToString()) - { - FlashMessage(btnData.Button, "Already Selected!"); - } - else - { - Utils.ChangeLanguage(selectedLang.ToString()); - Debug.Log($"Language changed to: {selectedLang}"); - FlashMessage(btnData.Button, "Language Changed!"); - } - } - } - - if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) - { - string toggleType = toggleData.Toggle.ToString(); - ToggleCustomAssets(toggleType); - if (toggleType == "Textures") - { - FlashMessage(toggleData.Button, "Toggled custom textures!", 0.1f); - } - else if (toggleType == "Audio") - { - FlashMessage(toggleData.Button, "Toggled custom audio!", 0.1f); - } - } - } - - [HarmonyPatch(nameof(OptionBtn.Update))] - [HarmonyPostfix] - private static void Update(OptionBtn __instance) - { - if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) - { - btnData.Button.transform.position = btnData.Position; - } - - if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) - { - toggleData.Button.transform.position = toggleData.Position; - } - } - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs deleted file mode 100644 index 87f3e66..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs +++ /dev/null @@ -1,69 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(OptionBtn))] - public static class OptionBtn_Patch - { - [HarmonyPatch(nameof(OptionBtn.Awake))] - [HarmonyPostfix] - private static void Awake(OptionBtn __instance) - { - Transform text_1Transform = __instance.transform.GetChild(0)?.transform; - if (text_1Transform != null) - { - TextMeshProUGUI text_1 = text_1Transform.GetComponent(); - text_1 = StringStore.TranslateText(text_1); - text_1.autoSizeTextContainer = false; - } - - Transform textTransform = __instance.transform.GetChild(1)?.transform; - if (textTransform != null) - { - TextMeshProUGUI text = textTransform.GetComponent(); - text = StringStore.TranslateText(text); - text.autoSizeTextContainer = false; - } - - Transform text2Transform = __instance.transform.GetChild(2)?.transform; - if (text2Transform != null) - { - TextMeshProUGUI text2 = text2Transform.GetComponent(); - text2 = StringStore.TranslateText(text2); - text2.autoSizeTextContainer = false; - } - } - - [HarmonyPatch("OnMouseUpAsButton")] - [HarmonyPostfix] - private static void OnMouseUpAsButtonPostfix(OptionBtn __instance) - { - Transform text_1Transform = __instance.transform.GetChild(0)?.transform; - if (text_1Transform != null) - { - TextMeshProUGUI text_1 = text_1Transform.GetComponent(); - text_1 = StringStore.TranslateText(text_1); - text_1.autoSizeTextContainer = false; - } - - Transform textTransform = __instance.transform.GetChild(1)?.transform; - if (textTransform != null) - { - TextMeshProUGUI text = textTransform.GetComponent(); - text = StringStore.TranslateText(text); - text.autoSizeTextContainer = false; - } - - Transform text2Transform = __instance.transform.GetChild(2)?.transform; - if (text2Transform != null) - { - TextMeshProUGUI text2 = text2Transform.GetComponent(); - text2 = StringStore.TranslateText(text2); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs deleted file mode 100644 index bb07b21..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs +++ /dev/null @@ -1,42 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(PVPPotBtn))] - public class PVPPotBtn_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(PVPPotBtn.OnMouseUpAsButton))] - public static void OnMouseUpAsButton(PVPPotBtn __instance) - { - Transform sceneText = __instance.transform.FindChild("text"); - if(sceneText != null) - { - TextMeshProUGUI sceneTextTMP = sceneText.transform.GetComponent(); - if(sceneTextTMP != null) - { - sceneTextTMP.text = StringStore.TranslateText(sceneTextTMP.text); - } - } - Transform sceneTextShadow = sceneText.transform.FindChild("text_1"); - if(sceneTextShadow != null) - { - TextMeshProUGUI sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); - if (sceneTextShadowTMP != null) - { - sceneTextShadowTMP.text = StringStore.TranslateText(sceneTextShadowTMP.text); - } - } - - if (__instance.name.Equals("ChangeBg_3") || __instance.name.Equals("ChangeBg_4")) - { - __instance.gameObject.SetActive(false); - __instance.gameObject.SetActive(true); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs deleted file mode 100644 index e110b2f..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs +++ /dev/null @@ -1,15 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(PauseMenu_Btn))] - public static class PauseMenu_Btn_Patch - { - [HarmonyPatch(nameof(PauseMenu_Btn.Start))] - [HarmonyPostfix] - private static void Start(PauseMenu_Btn __instance) => StringStore.TranslateTextTransform(__instance.transform); - } - -} diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs deleted file mode 100644 index b6b8df4..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -#if FIX -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(SaveMenuBtn))] - public static class SaveMenuBtn_Patch - { - [HarmonyPatch(nameof(SaveMenuBtn.OnMouseUpAsButton))] - [HarmonyPostfix] - private static void OnMouseUpAsButton(SaveMenuBtn __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.theName.text = StringStore.TranslateText(__instance.theName.text); - __instance.theName.font = fontAsset; - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs b/BepInEx/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs deleted file mode 100644 index 0de74e2..0000000 --- a/BepInEx/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs +++ /dev/null @@ -1,85 +0,0 @@ -using HarmonyLib; -using TMPro; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.UIElements; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIButton))] - public static class UIButton_Patch - { - [HarmonyPatch(typeof(UIButton), nameof(UIButton.Start))] - [HarmonyPostfix] - public static void Start(UIButton __instance) - { - if (__instance.transform.childCount >= 2) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - if (__instance.transform.name == "Goback") - { - text.text = "合上"; - } - text.text = StringStore.TranslateText(text.text); - text.font = font; - } - } - else - { - StringStore.TranslateTextTransform(__instance.transform); - if (__instance.transform.name == "Goback") - { - foreach (TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - } - } - - [HarmonyPatch(nameof(UIButton.OnMouseUpAsButton))] - [HarmonyPostfix] - public static void Postfix_OnMouseUpAsButton(UIButton __instance) - { - try - { - if (__instance.transform.childCount >= 2) - { - if (__instance.name == "EditMode") - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent(); - TextMeshProUGUI[] extraTexts = __instance.transform.GetChild(1).GetComponentsInChildren(); - - text.text = StringStore.TranslateText(text.text, false); - text.font = fontAsset; - - foreach (TextMeshProUGUI extraText in extraTexts) - { - extraText.text = StringStore.TranslateText(extraText.text, false); - extraText.font = fontAsset; - } - } - else - { - TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent(); - TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent(); - - text.text = StringStore.TranslateText(text.text, false); - textShadow.text = StringStore.TranslateText(textShadow.text, false); - - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } - catch (Exception) { } - } - } -} diff --git a/BepInEx/Patches/GameObjects/Close_Patch.cs b/BepInEx/Patches/GameObjects/Close_Patch.cs deleted file mode 100644 index 2df6f37..0000000 --- a/BepInEx/Patches/GameObjects/Close_Patch.cs +++ /dev/null @@ -1,52 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(Close))] - public static class Close_Patch - { - [HarmonyPatch(nameof(Close.Start))] - [HarmonyPostfix] - private static void Close_Start(Close __instance) - { - - TextMeshPro closeText = __instance.transform.GetChild(0).GetComponent(); - closeText.text = "合上"; - closeText = StringStore.TranslateText(closeText); - closeText.autoSizeTextContainer = true; - - Transform AlmanacTransform = __instance.transform.parent.transform; - - Transform nameTransform = AlmanacTransform.Find("Name"); - if (nameTransform != null) - { - TextMeshPro nameTMP = nameTransform.transform.GetComponent(); - if (nameTMP) - { - nameTMP = StringStore.TranslateText(nameTMP); - nameTMP.autoSizeTextContainer = true; - } - - Transform nameShadowTransform = nameTransform.Find("NameShadow"); - if (nameShadowTransform) - { - TextMeshPro nameShadowTMP = nameShadowTransform.transform.GetComponent(); - if (nameShadowTMP) - { - nameShadowTMP = StringStore.TranslateText(nameShadowTMP); - nameShadowTMP.autoSizeTextContainer = true; - } - } - } - - StringStore.TranslateTextTransform(AlmanacTransform.Find("Back"), true); - StringStore.TranslateTextTransform(AlmanacTransform.Find("NextPage")); - StringStore.TranslateTextTransform(AlmanacTransform.Find("LastPage")); - - } - } -} diff --git a/BepInEx/Patches/GameObjects/CrisisZombieWindow_Patch.cs b/BepInEx/Patches/GameObjects/CrisisZombieWindow_Patch.cs deleted file mode 100644 index 88b3411..0000000 --- a/BepInEx/Patches/GameObjects/CrisisZombieWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(CrisisZombieWindow))] - public static class CrisisZombieWindow_Patch - { - [HarmonyPatch(nameof(CrisisZombieWindow.Start))] - [HarmonyPostfix] - private static void Start(CrisisZombieWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(CrisisZombieWindow.SetZombieType))] - [HarmonyPostfix] - private static void SetZombieType(CrisisZombieWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/GameObjects/CustomSettings_Patch.cs b/BepInEx/Patches/GameObjects/CustomSettings_Patch.cs deleted file mode 100644 index a89481b..0000000 --- a/BepInEx/Patches/GameObjects/CustomSettings_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(CustomSettings))] - public static class CustomSettings_Patch - { - [HarmonyPatch(nameof(CustomSettings.Awake))] - [HarmonyPostfix] - private static void Awake(CustomSettings __instance) - { - __instance.textMesh = StringStore.TranslateText(__instance.textMesh); - } - - [HarmonyPatch(nameof(CustomSettings.ChangeText))] - [HarmonyPostfix] - private static void ChangeText(CustomSettings __instance) - { - __instance.textMesh = StringStore.TranslateText(__instance.textMesh); - } - } -} diff --git a/BepInEx/Patches/GameObjects/CustomSun_Patch.cs b/BepInEx/Patches/GameObjects/CustomSun_Patch.cs deleted file mode 100644 index 757ba73..0000000 --- a/BepInEx/Patches/GameObjects/CustomSun_Patch.cs +++ /dev/null @@ -1,45 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(CustomSun))] - public static class CustomSun_Patch - { - [HarmonyPatch(nameof(CustomSun.Awake))] - [HarmonyPostfix] - private static void Awake(CustomSun __instance) - { - if (__instance.inputField.gameObject.activeSelf) - { - string oriTextSun = __instance.inputField.m_Text; - __instance.inputField.gameObject.SetActive(false); - __instance.inputField.m_Text = StringStore.TranslateText(oriTextSun); - __instance.inputField.m_OriginalText = StringStore.TranslateText(oriTextSun); - __instance.inputField.gameObject.SetActive(true); - } - - if (__instance.setFlags.gameObject.activeSelf) - { - string oriTextFlags = __instance.setFlags.m_Text; - __instance.setFlags.gameObject.SetActive(false); - __instance.setFlags.m_Text = StringStore.TranslateText(oriTextFlags); - __instance.setFlags.m_OriginalText = StringStore.TranslateText(oriTextFlags); - __instance.setFlags.gameObject.SetActive(true); - } - - Transform lookZombieTransform = __instance.lookZombie.transform.GetChild(0).transform; - if (lookZombieTransform != null) - { - TextMeshProUGUI lookZombieTMP = lookZombieTransform.GetComponent(); - if (lookZombieTMP != null) - { - lookZombieTMP = StringStore.TranslateText(lookZombieTMP); - } - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/EveBuffMenu_Patch.cs b/BepInEx/Patches/GameObjects/EveBuffMenu_Patch.cs deleted file mode 100644 index 68beceb..0000000 --- a/BepInEx/Patches/GameObjects/EveBuffMenu_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Text.RegularExpressions; -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(EveBuffMenu))] - public static class EveBuffMenu_Patch - { - [HarmonyPatch(nameof(EveBuffMenu.Start))] - [HarmonyPostfix] - private static void Start(EveBuffMenu __instance) - { - foreach (EveOptionWindow window in __instance.windows) - { - EveOptionWindow_Patch.TranslateEveOptionWindow(window); - } - - foreach (TextMeshProUGUI text in __instance.quitButton.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - - [HarmonyPatch(nameof(EveBuffMenu.InitWindows))] - [HarmonyPostfix] - private static void InitWindows(EveBuffMenu __instance) - { - foreach (EveOptionWindow window in __instance.windows) - { - EveOptionWindow_Patch.TranslateEveOptionWindow(window); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/EveOptionWindow_Patch.cs b/BepInEx/Patches/GameObjects/EveOptionWindow_Patch.cs deleted file mode 100644 index f751dcd..0000000 --- a/BepInEx/Patches/GameObjects/EveOptionWindow_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Text.RegularExpressions; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(EveOptionWindow))] - public static class EveOptionWindow_Patch - { - [HarmonyPatch(nameof(EveOptionWindow.SetType))] - [HarmonyPostfix] - private static void SetType(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - [HarmonyPatch(nameof(EveOptionWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - [HarmonyPatch(nameof(EveOptionWindow.SelectedByRow))] - [HarmonyPostfix] - private static void SelectedByRow(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - public static void TranslateEveOptionWindow(EveOptionWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - - foreach (TextMeshProUGUI text in __instance.buttonText) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs b/BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs deleted file mode 100644 index f0d6b94..0000000 --- a/BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs +++ /dev/null @@ -1,66 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreEnterWindow))] - public static class ExploreEnterWindow_Patch - { - [HarmonyPatch(nameof(ExploreEnterWindow.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - if (__instance.nameText.text == "") - { - __instance.nameText.text = StringStore.TranslateText(__instance.nameText.text); - } - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))] - [HarmonyPostfix] - private static void SetInfo(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - if (__instance.nameText.text == "") - { - __instance.nameText.text = StringStore.TranslateText(__instance.nameText.text); - } - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetIcon))] - [HarmonyPostfix] - private static void SetIcon(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - if (__instance.nameText.text == "") - { - __instance.nameText.text = StringStore.TranslateText(__instance.nameText.text); - } - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetDisable))] - [HarmonyPostfix] - private static void SetDisable(ExploreEnterWindow __instance) - { - if (__instance.disabled) - { - __instance.nameText.text = StringStore.TranslateText("敬请期待"); - } - - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} diff --git a/BepInEx/Patches/GameObjects/ExploreMakeMenu_Patch.cs b/BepInEx/Patches/GameObjects/ExploreMakeMenu_Patch.cs deleted file mode 100644 index b2d941e..0000000 --- a/BepInEx/Patches/GameObjects/ExploreMakeMenu_Patch.cs +++ /dev/null @@ -1,79 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using System.Text.RegularExpressions; -using UnityEngine; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.IO; -using System.Text.Json; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreMakeMenu))] - public static class ExploreMakeMenu_Patch - { - [HarmonyPatch(nameof(ExploreMakeMenu.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.InitMenu))] - [HarmonyPostfix] - private static void InitMenu(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if(txt.text.Contains("关卡制作中:")) - { - string plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]); - txt.text = String.Format(StringStore.translationStringRegex["关卡制作中:([^\\s]+)"], plantName); - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.ViewScene))] - [HarmonyPostfix] - private static void ViewScene(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons))] - [HarmonyPostfix] - private static void InitZombieButtons(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ExploreMenu_Patch.cs b/BepInEx/Patches/GameObjects/ExploreMenu_Patch.cs deleted file mode 100644 index 795137f..0000000 --- a/BepInEx/Patches/GameObjects/ExploreMenu_Patch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreMenu))] - public static class ExploreMenu_Patch - { - [HarmonyPatch(nameof(ExploreMenu.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - } - - Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel"); - //foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren()) - //{ - // if (txt.name.Contains("Text (TMP)")) - // { - // txt.autoSizeTextContainer = true; - // if (txt.name == "Text (TMP)") - // { - // txt.transform.localPosition = new Vector3(94.4225f, -45.1565f, 0f); - // } - // } - //} - } - - [HarmonyPatch(nameof(ExploreMenu.UpdateWindows))] - [HarmonyPostfix] - private static void UpdateWindows(ExploreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs b/BepInEx/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs deleted file mode 100644 index 6f36532..0000000 --- a/BepInEx/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(FruitNinjaSelectWindow))] - public static class FruitNinjaSelectWindow_Patch - { - [HarmonyPatch(nameof(FruitNinjaSelectWindow.SetType))] - [HarmonyPostfix] - private static void SetType(FruitNinjaSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(FruitNinjaSelectWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(FruitNinjaSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/GameObjects/GardenBagMenu_Patch.cs b/BepInEx/Patches/GameObjects/GardenBagMenu_Patch.cs deleted file mode 100644 index 5c555a1..0000000 --- a/BepInEx/Patches/GameObjects/GardenBagMenu_Patch.cs +++ /dev/null @@ -1,51 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(GardenBagMenu))] - public static class GardenBagMenu_Patch - { - [HarmonyPatch(nameof(GardenBagMenu.SetTreasureCards))] - [HarmonyPostfix] - private static void SetTreasureCards(GardenBagMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if(txt.transform.parent.name.Contains("Close")) - { - txt.text = StringStore.TranslateText("合上"); - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(GardenBagMenu.SetTreasureCard))] - [HarmonyPostfix] - private static void SetTreasureCard(GardenBagMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if (txt.transform.parent.name.Contains("Close")) - { - txt.text = StringStore.TranslateText("合上"); - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/GardenCard_Patch.cs b/BepInEx/Patches/GameObjects/GardenCard_Patch.cs deleted file mode 100644 index ed7de7d..0000000 --- a/BepInEx/Patches/GameObjects/GardenCard_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(GardenCard))] - public static class GardenCard_Patch - { - [HarmonyPatch(nameof(GardenCard.Start))] - [HarmonyPostfix] - private static void Start(GardenCard __instance) - { - __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); - } - - [HarmonyPatch(nameof(GardenCard.ChangeCardSprite))] - [HarmonyPostfix] - private static void ChangeCardSprite(GardenCard __instance) - { - __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); - } - } -} diff --git a/BepInEx/Patches/GameObjects/GardenPlant_Patch.cs b/BepInEx/Patches/GameObjects/GardenPlant_Patch.cs deleted file mode 100644 index 5d8ea61..0000000 --- a/BepInEx/Patches/GameObjects/GardenPlant_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using System; -using System.Text.RegularExpressions; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(GardenPlant))] - public static class GardenPlant_Patch - { - [HarmonyPatch(nameof(GardenPlant.Start))] - [HarmonyPostfix] - private static void Start(GardenPlant __instance) - { - __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); - } - - [HarmonyPatch(nameof(GardenPlant.UpdateInfo))] - [HarmonyPostfix] - private static void UpdateInfo(GardenPlant __instance) - { - - __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MainMenu_Patch.cs b/BepInEx/Patches/GameObjects/MainMenu_Patch.cs deleted file mode 100644 index 8d00da2..0000000 --- a/BepInEx/Patches/GameObjects/MainMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(MainMenu))] - public class MainMenu_Patch - { - private static bool _warningShown = false; - - [HarmonyPostfix] - [HarmonyPatch(nameof(MainMenu.AnimOver))] - private static void AnimOver(MainMenu __instance) - { - if (_warningShown || NoticeMenu.Instance == null) - return; - - WarningStore.WarningReload(Utils.Language, NoticeMenu.Instance); - _warningShown = true; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/AbyssGoods_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/AbyssGoods_Patch.cs deleted file mode 100644 index 0c0e3b6..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/AbyssGoods_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(AbyssGoods))] - public static class AbyssGoods_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(AbyssGoods.Start))] - private static void Start(AbyssGoods __instance) - { - __instance.costText.text = StringStore.TranslateText(__instance.costText.text, false); - __instance.costText_shadow.text = StringStore.TranslateText(__instance.costText_shadow.text, false); - __instance.hasText.text = StringStore.TranslateText(__instance.hasText.text, false); - __instance.hasText_shadow.text = StringStore.TranslateText(__instance.hasText_shadow.text, false); - } - } -} diff --git a/BepInEx/Patches/GameObjects/MinorObjects/Brain_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/Brain_Patch.cs deleted file mode 100644 index ed896cf..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/Brain_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Text.RegularExpressions; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Brain))] - public static class Brain_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.Awake))] - private static void Awake(Brain __instance) - { - // reposition original points - Transform pointsTransform = __instance.points.transform; - GameObject pointsObject = __instance.points.gameObject; - pointsTransform.position = new Vector3(-6.5f, pointsTransform.position.y, pointsTransform.position.z); - - // instantiate and move new shadow - GameObject pointsShadowObject = UnityEngine.Object.Instantiate(pointsObject, parent: pointsTransform); - pointsShadowObject.SetActive(true); - Transform pointsShadowTransform = pointsShadowObject.transform; - pointsShadowTransform.position = new Vector3(-6.485f, pointsTransform.position.y - 0.015f, pointsTransform.position.z); - - // set points text - TextMeshPro pointsShadowText = pointsShadowObject.GetComponent(); - pointsShadowText.text = __instance.points.text; - pointsShadowText.sortingOrder -= 2; - pointsShadowText.color = Color.black; - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.Update))] - private static void Update(Brain __instance) - { - if (__instance.transform.Find("Points").GetChild(0) != null) - { - TextMeshPro shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); - shadowText.text = __instance.points.text; - } - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.WinAction))] - private static void WinAction(Brain __instance) - { - if (__instance.transform.Find("Points").GetChild(0) != null) - { - TextMeshPro shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); - shadowText.text = __instance.points.text; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/DY_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/DY_Patch.cs deleted file mode 100644 index 6659ddd..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/DY_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(DY))] - public static class DY_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(DY.Update))] - private static void Update(DY __instance) - { - __instance.TextMeshPro.text = StringStore.TranslateText(__instance.TextMeshPro.text); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs deleted file mode 100644 index acc26c1..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(JigsawClip))] - public static class JigsawClip_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(JigsawClip.Awake))] - private static void Postfix_Awake(JigsawClip __instance) - { - if (!__instance || !__instance.description) return; - - StringStore.TranslateTextUI(__instance.description); - } - [HarmonyPostfix] - [HarmonyPatch(nameof(JigsawClip.Update))] - private static void Postfix_Update(JigsawClip __instance) - { - if (!__instance || !__instance.description) return; - - if (__instance.description.text != StringStore.TranslateText(__instance.description.text)) - { - StringStore.TranslateTextUI(__instance.description); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs deleted file mode 100644 index e4c913c..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ -[HarmonyPatch(typeof(LanternUmbrella))] - public class LanternUmbrella_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(LanternUmbrella.Update))] - private static void Update(LanternUmbrella __instance) - { - __instance.energyText = StringStore.TranslateText(__instance.energyText); - __instance.energyTextShadow = StringStore.TranslateText(__instance.energyTextShadow); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs deleted file mode 100644 index 3ff15e8..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(MagnetBox))] - public class MagnetBox_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(MagnetBox.Update))] - private static void Update(MagnetBox __instance) - { - StringStore.TranslateTextTransform(__instance.transform); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs deleted file mode 100644 index 4263677..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(MagnetInterface))] - public class MagnetInterface_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(MagnetInterface.Update))] - private static void Update(MagnetInterface __instance) - { - StringStore.TranslateTextTransform(__instance.transform); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/Money_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/Money_Patch.cs deleted file mode 100644 index 312d327..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/Money_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Money))] - public static class Money_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Money.Update))] - private static void Update(Money __instance) - { - __instance.beanCount.text = StringStore.TranslateText(__instance.beanCount.text); - __instance.beanCount2.text = StringStore.TranslateText(__instance.beanCount2.text); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/Plant_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/Plant_Patch.cs deleted file mode 100644 index cd60f9f..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/Plant_Patch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Plant))] - public static class Plant_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Plant.Awake))] - private static void Awake(Plant __instance) - { - if (!(__instance.thePlantType == PlantType.SuperMachineNut || __instance.thePlantType == PlantType.MachineNut)) - return; - __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = ChangeHPText(__instance.healthSlider.healthTextShadow.text); - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Plant.UpdateText))] - private static void Update(Plant __instance) - { - if (!(__instance.thePlantType == PlantType.SuperMachineNut || __instance.thePlantType == PlantType.MachineNut)) - return; - if (__instance.thePlantHealth < __instance.thePlantMaxHealth) - return; - __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = ChangeHPText(__instance.healthSlider.healthTextShadow.text); - } - - static string ChangeHPText(string originalText) - { - var regex = new Regex(@"(\d+)\d\d\d/(\d)000"); - if (regex.IsMatch(originalText)) - { - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - List dynamicParts = new List(); - - for (int i = 1; i < groupCount; i++) - dynamicParts.Add(match.Groups[i].Value); - return originalText = string.Format("{0}k/{1}k", [.. dynamicParts]); - } - return originalText; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs deleted file mode 100644 index 90b423f..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(PlayerName))] - public static class PlayerName_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(PlayerName.Update))] - private static void Update(PlayerName __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs deleted file mode 100644 index c9ce753..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(SelectYourPlants))] - public static class SelectYourPlants_Patch - { - [HarmonyPatch(nameof(SelectYourPlants.Awake))] - [HarmonyPostfix] - private static void Awake(SelectYourPlants __instance) - { - __instance.TextMeshProUGUI = StringStore.TranslateText(__instance.TextMeshProUGUI); - __instance.TextMeshProUGUI.autoSizeTextContainer = true; - - __instance.TextMeshProUGUI2 = StringStore.TranslateText(__instance.TextMeshProUGUI2); - __instance.TextMeshProUGUI2.autoSizeTextContainer = true; - } - } -} diff --git a/BepInEx/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs deleted file mode 100644 index 3b34a5a..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs +++ /dev/null @@ -1,16 +0,0 @@ -using HarmonyLib; -using System; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(TrainingDummy), nameof(TrainingDummy.UpdateHealthText))] - public static class TrainingDummy_Patch - { - [HarmonyPostfix] - public static void UpdateHealthText(TrainingDummy __instance) - { - Zombie_Patch.TranslateHpUI_T(__instance.healthText, __instance); - Zombie_Patch.TranslateHpUI_T(__instance.healthTextShadow, __instance); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs deleted file mode 100644 index 3c4543d..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs +++ /dev/null @@ -1,16 +0,0 @@ -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(TreasureMoney))] - public static class TreasureMoney_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(TreasureMoney.Update))] - private static void Update(TreasureMoney __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - } - } -} diff --git a/BepInEx/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs deleted file mode 100644 index 8c8ccf0..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIProgress2))] - public static class UIProgress2_Patch - { - [HarmonyPatch(nameof(UIProgress2.Update))] - [HarmonyPostfix] - private static void Update(UIProgress2 __instance) - { - __instance.t.text = StringStore.TranslateText(__instance.t.text); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs deleted file mode 100644 index 5e8aac3..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(UltimateChomper), nameof(UltimateChomper.UpdateText))] - public static class UltimateChomper_Patch - { - [HarmonyPostfix] - public static void UpdateText(UltimateChomper __instance) - { - StringStore.TranslateText(__instance.killingText); - StringStore.TranslateText(__instance.killingTextShadow); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/MinorObjects/Zombie_Patch.cs b/BepInEx/Patches/GameObjects/MinorObjects/Zombie_Patch.cs deleted file mode 100644 index ff271df..0000000 --- a/BepInEx/Patches/GameObjects/MinorObjects/Zombie_Patch.cs +++ /dev/null @@ -1,176 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Zombie))] - public static class Zombie_Patch - { - private static Dictionary HPStrings = new Dictionary() - { - { "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" }, - { "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" }, - { "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" }, - { "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" }, - { "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" } - }; - - public static void LoadHPStrings() - { - foreach (var hp in HPStrings) - if (StringStore.translationStringRegex.ContainsKey(hp.Key)) - HPStrings[hp.Key] = StringStore.translationStringRegex[hp.Key]; - } - - [HarmonyPatch(nameof(Zombie.Start))] - [HarmonyPostfix] - public static void Start(Zombie __instance) - { - TranslateHpUI(__instance.healthText, __instance); - TranslateHpUI(__instance.healthTextShadow, __instance); - - if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0)) - __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); - } - - [HarmonyPatch(nameof(Zombie.Update))] - [HarmonyPrefix] - public static void Update(Zombie __instance) - { - if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth) - return; - TranslateHpUI(__instance.healthText, __instance); - TranslateHpUI(__instance.healthTextShadow, __instance); - - if (__instance.healthText.transform.rotation != Quaternion.Euler(0f, 0f, 0f)) - __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); - } - - public static void TranslateHpUI(TextMeshPro textTMP, Zombie __instance) - { - if (textTMP) - { - string origText = textTMP.text; - string translatedText = origText; - string pattern = "(\\d+)阶\\n([\\s\\S]+)"; - if (StringStore.TestRegex(translatedText, pattern)) - { - var match = Regex.Match(translatedText, pattern, RegexOptions.Singleline); - string tier = match.Groups[1].Value; - string healthText = TranslateHPText(match.Groups[2].Value, __instance); - string fStr = StringStore.translationStringRegex[pattern]; - translatedText = string.Format(fStr, new object[] { tier, healthText }); - } - else - { - translatedText = TranslateHPText(origText, __instance); - } - textTMP.text = translatedText == origText ? origText : translatedText; - textTMP.autoSizeTextContainer = false; - if (translatedText != origText) - textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - public static void TranslateHpUI_T(TextMeshPro textTMP, TrainingDummy __instance) - { - if (textTMP) - { - string origText = textTMP.text; - string translatedText = TranslateHPText_T(origText, __instance); - textTMP.text = translatedText == origText ? origText : translatedText; - textTMP.autoSizeTextContainer = false; - if (translatedText != origText) - textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - public static string TranslateHPText(string originalText, Zombie __instance) - { - if(originalText == null) - { - return originalText; - } - string finalText = __instance.healthText.text; - int fIndex = -1; - bool found = false; - - for (int i = 0; i < HPStrings.Count; i++) - { - var hp = HPStrings.ElementAt(i); - if(Regex.Match(originalText, hp.Key, RegexOptions.Singleline).Success) - { - fIndex = i; - found = true; - } - } - - if (fIndex > -1 && found) - { - string fStr = HPStrings.ElementAt(fIndex).Value; - - switch (fIndex) - { - case 1: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth); - break; - case 2: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth); - break; - case 3: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth); - break; - case 4: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth); - break; - default: - break; - } - } - - return finalText; - } - - public static string TranslateHPText_T(string originalText, TrainingDummy __instance) - { - string finalText = __instance.healthText.text; - int fIndex = -1; - bool found = false; - - for (int i = 0; i < HPStrings.Count; i++) - { - var hp = HPStrings.ElementAt(i); - Regex regex = new Regex(hp.Key); - if (regex.IsMatch(originalText)) - { - fIndex = i; - found = true; - } - } - - if (fIndex > -1 && found) - { - string fStr = HPStrings.ElementAt(fIndex).Value; - string DPS = originalText.Split("\n")[1].Replace("DPS:", ""); - DPS = StringStore.TranslateText(DPS); - - switch (fIndex) - { - case 0: - finalText = string.Format(fStr, __instance.lastDamage, DPS, __instance.totalDamage); - break; - default: - break; - } - } - - return finalText; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/NoticePauseMenu_Patch.cs b/BepInEx/Patches/GameObjects/NoticePauseMenu_Patch.cs deleted file mode 100644 index 0579148..0000000 --- a/BepInEx/Patches/GameObjects/NoticePauseMenu_Patch.cs +++ /dev/null @@ -1,62 +0,0 @@ -using HarmonyLib; -using UnityEngine.UI; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.IO; -using System; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(NoticeMenu))] - public class NoticePauseMenu_Patch - { - [HarmonyPrefix] - [HarmonyPatch(nameof(NoticeMenu.Awake))] - private static void Pre_Awake(NoticeMenu __instance) - { - GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; - - TextMeshProUGUI contentText = contentObject.GetComponent(); - File.WriteAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "changelog.txt"), contentText.text); - - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - string changelogDir = Path.Combine(stringDir, "changelog.txt"); - - if (!File.Exists(changelogDir)) - { - File.WriteAllText(changelogDir, contentText.text); - } - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(NoticeMenu.Awake))] - private static void Post_Awake(NoticeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - string changelogDir = Path.Combine(stringDir, "changelog.txt"); - - string changelogText = File.ReadAllText(changelogDir); - - GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; - - TextMeshProUGUI contentText = contentObject.GetComponent(); - contentText.text = changelogText; - contentText.margin = new Vector4(6, 2, 12, 0); - - contentText.enableWordWrapping = true; - contentText.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - contentText.ForceMeshUpdate(); - - //float textHeight = contentText.preferredHeight; - //RectTransform contentRect = contentObject.GetComponent(); - //contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, textHeight); - - ContentSizeFitter sizeFitter = contentObject.AddComponent(); - sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/OtherMenu_Patch.cs b/BepInEx/Patches/GameObjects/OtherMenu_Patch.cs deleted file mode 100644 index 4ffed8c..0000000 --- a/BepInEx/Patches/GameObjects/OtherMenu_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using System; -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); - } - } -} diff --git a/BepInEx/Patches/GameObjects/PlantDamageMenu_Patch.cs b/BepInEx/Patches/GameObjects/PlantDamageMenu_Patch.cs deleted file mode 100644 index d30635a..0000000 --- a/BepInEx/Patches/GameObjects/PlantDamageMenu_Patch.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Text.RegularExpressions; -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantDamageMenu))] - public static class PlantDamageMenu_Patch - { - [HarmonyPatch(nameof(PlantDamageMenu.Awake))] - [HarmonyPostfix] - private static void Awake(PlantDamageMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - [HarmonyPatch(nameof(PlantDamageMenu.InitCards))] - [HarmonyPostfix] - private static void InitCards(PlantDamageMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs b/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs deleted file mode 100644 index ed6e8dc..0000000 --- a/BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs +++ /dev/null @@ -1,54 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.UIElements; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using System; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantInfoWindow))] - public static class PlantInfoWindow_Patch - { - [HarmonyPatch(nameof(PlantInfoWindow.InitText))] - [HarmonyPostfix] - private static void InitText(PlantInfoWindow __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - BigGardenPlant thePlant = __instance.plant; - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if (txt.name.Contains("Introduce") && thePlant != null) - { - PlantType thePlantType = thePlant.thePlantType; - txt.text = StringStore.TranslateText(txt.text); - - string text = txt.text; - string[] lines = text.Split("\n"); - - lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType); - string updatedText = String.Join("\n", lines); - - txt.text = updatedText; - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - - txt.font = fontAsset; - } - - Transform parentWindowTransform = __instance.transform.parent; - Transform returnPlantTransform = parentWindowTransform.FindChild("Close"); - - foreach(TextMeshProUGUI txt in returnPlantTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/PlayerShootingMenu_Patch.cs b/BepInEx/Patches/GameObjects/PlayerShootingMenu_Patch.cs deleted file mode 100644 index b893898..0000000 --- a/BepInEx/Patches/GameObjects/PlayerShootingMenu_Patch.cs +++ /dev/null @@ -1,40 +0,0 @@ -using HarmonyLib; -using TMPro; -using BepInEx.Unity.IL2CPP; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlayerShootingMenu))] - public static class PlayerShootingMenu_Patch - { - [HarmonyPatch(nameof(PlayerShootingMenu.Update))] - [HarmonyPostfix] - private static void Update(PlayerShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(PlayerShootingMenu.Refresh))] - [HarmonyPostfix] - private static void Refresh(PlayerShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Transform refreshTransform = __instance.transform.FindChild("Button"); - foreach (TextMeshProUGUI text in refreshTransform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - text.autoSizeTextContainer = false; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/PlayerShootingWindow_Patch.cs b/BepInEx/Patches/GameObjects/PlayerShootingWindow_Patch.cs deleted file mode 100644 index 2c228af..0000000 --- a/BepInEx/Patches/GameObjects/PlayerShootingWindow_Patch.cs +++ /dev/null @@ -1,36 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlayerShootingWindow))] - public static class PlayerShootingWindow_Patch - { - [HarmonyPatch(nameof(PlayerShootingWindow.SetType))] - [HarmonyPostfix] - private static void SetType(PlayerShootingWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(PlayerShootingWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(PlayerShootingWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/GameObjects/RogueCardWindow_Patch.cs b/BepInEx/Patches/GameObjects/RogueCardWindow_Patch.cs deleted file mode 100644 index 47797d5..0000000 --- a/BepInEx/Patches/GameObjects/RogueCardWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(RogueCardWindow))] - public static class RogueCardWindow_Patch - { - [HarmonyPatch(nameof(RogueCardWindow.InitCard))] - [HarmonyPostfix] - private static void InitCard(RogueCardWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(RogueCardWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(RogueCardWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/GameObjects/RogueStartMenu_Patch.cs b/BepInEx/Patches/GameObjects/RogueStartMenu_Patch.cs deleted file mode 100644 index ce379ad..0000000 --- a/BepInEx/Patches/GameObjects/RogueStartMenu_Patch.cs +++ /dev/null @@ -1,42 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.TextCore.Text; -using UnityEngine.UI; -using static System.Net.Mime.MediaTypeNames; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - - [HarmonyPatch(typeof(RogueStartMenu))] - public static class RogueStartMenu_Patch - { - [HarmonyPatch(nameof(RogueStartMenu.SetLeader))] - [HarmonyPostfix] - private static void SetLeader(RogueStartMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(RogueStartMenu.EnterGame))] - [HarmonyPostfix] - private static void EnterGame(RogueStartMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs b/BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs deleted file mode 100644 index f2ba774..0000000 --- a/BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs +++ /dev/null @@ -1,36 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(SeedLibrary))] - public static class SeedLibrary_Patch - { - [HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode))] - [HarmonyPostfix] - private static void ChangeSafeMode(SeedLibrary __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - - Transform safetyBoxButtonTransform = __instance.transform.Find("SafeBox").Find("StartSafeMode"); - - if (__instance.safeMode == false && safetyBoxButtonTransform != null) - { - foreach (TextMeshProUGUI txt in safetyBoxButtonTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - } - } - } - } -} - - diff --git a/BepInEx/Patches/GameObjects/ShootingMenu_Patch.cs b/BepInEx/Patches/GameObjects/ShootingMenu_Patch.cs deleted file mode 100644 index 4169bda..0000000 --- a/BepInEx/Patches/GameObjects/ShootingMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ShootingMenu))] - public static class ShootingMenu_Patch - { - [HarmonyPatch(nameof(ShootingMenu.Update))] - [HarmonyPostfix] - private static void Update(ShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/ShootingSelectWindow_Patch.cs b/BepInEx/Patches/GameObjects/ShootingSelectWindow_Patch.cs deleted file mode 100644 index f42f5a5..0000000 --- a/BepInEx/Patches/GameObjects/ShootingSelectWindow_Patch.cs +++ /dev/null @@ -1,73 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ShootingSelectWindow))] - public static class ShootingSelectWindow_Patch - { - [HarmonyPatch(nameof(ShootingSelectWindow.InitPlantType))] - [HarmonyPostfix] - private static void InitCard(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.SetUpgradePlantTypes))] - [HarmonyPostfix] - private static void SetUpgradePlantTypes(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.GetMaxIndexInRoutes))] - [HarmonyPostfix] - private static void GetMaxIndexInRoutes(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.Start))] - [HarmonyPostfix] - private static void Start(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs b/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs deleted file mode 100644 index 07279bd..0000000 --- a/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using TMPro; -using BepInEx.Unity.IL2CPP; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(SpriteRenderer))] - public static class SpriteRenderer_Patch - { - [HarmonyPatch(nameof(SpriteRenderer.InvokeSpriteChanged))] - [HarmonyPostfix] - private static void InvokeSpriteChanged(SpriteRenderer __instance) - { - if (__instance.sprite != null) - { - if (TextureStore.spriteDict.ContainsKey(__instance.sprite.name) && __instance.drawMode != SpriteDrawMode.Sliced) - { - __instance.drawMode = SpriteDrawMode.Sliced; - } - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TowerOption_Patch.cs b/BepInEx/Patches/GameObjects/TowerOption_Patch.cs deleted file mode 100644 index a8784d1..0000000 --- a/BepInEx/Patches/GameObjects/TowerOption_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -//using HarmonyLib; -//using System; -//using TMPro; -//using PvZ_Fusion_Translator__BepInEx_.AssetStore; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(TowerOption))] -// public static class TowerOption_Patch -// { -// [HarmonyPatch(nameof(TowerOption.Start))] -// [HarmonyPostfix] -// private static void Postfix_Start(TowerOption __instance) -// { -// //TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren(true); -// __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); -// __instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString()); -// } -// } -//} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TowerUpgradeMenu_Patch.cs b/BepInEx/Patches/GameObjects/TowerUpgradeMenu_Patch.cs deleted file mode 100644 index fee9af4..0000000 --- a/BepInEx/Patches/GameObjects/TowerUpgradeMenu_Patch.cs +++ /dev/null @@ -1,39 +0,0 @@ -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TowerUpgradeMenu))] - public static class TowerUpgradeMenu_Patch - { - [HarmonyPatch(nameof(TowerUpgradeMenu.Awake))] - [HarmonyPostfix] - private static void Awake(TowerUpgradeMenu __instance) - { - __instance.des.text = StringStore.TranslateText(__instance.des.text); - __instance.des2.text = StringStore.TranslateText(__instance.des2.text); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - [HarmonyPatch(nameof(TowerUpgradeMenu.SetText))] - [HarmonyPostfix] - private static void SetText(TowerUpgradeMenu __instance) - { - __instance.des.text = StringStore.TranslateText(__instance.des.text); - __instance.des2.text = StringStore.TranslateText(__instance.des2.text); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TravelBuffMenu_Patch.cs b/BepInEx/Patches/GameObjects/TravelBuffMenu_Patch.cs deleted file mode 100644 index 2532e0c..0000000 --- a/BepInEx/Patches/GameObjects/TravelBuffMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch; -using UnityEngine; -using System.Collections.Generic; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelBuffMenu))] - public static class TravelBuffMenu_Patch - { - [HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))] - [HarmonyPostfix] - private static void RefeshOptions(TravelBuffMenu __instance) - { - foreach (TravelBuffOptionButton button in __instance.options) - { - button.introduce.text = translatedTravelBuffs[buffLinks[button.buffType]][button.buffIndex]; - List buffSet = translatedTravelBuffs[buffLinks[button.buffType]]; - string buffText = (button.buffIndex < buffSet.Count && button.show != null) ? buffSet[button.buffIndex] : StringStore.TranslateText(button.introduce.text); - button.introduce.text = buffText; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TravelBuffOptionButton_Patch.cs b/BepInEx/Patches/GameObjects/TravelBuffOptionButton_Patch.cs deleted file mode 100644 index 9c67c46..0000000 --- a/BepInEx/Patches/GameObjects/TravelBuffOptionButton_Patch.cs +++ /dev/null @@ -1,41 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch; -using UnityEngine; -using System.Collections.Generic; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelBuffOptionButton))] - public static class TravelBuffOptionButton_Patch - { - [HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))] - [HarmonyPostfix] - private static void SetBuff(TravelBuffOptionButton __instance) - { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; - } - - [HarmonyPatch(nameof(TravelBuffOptionButton.Awake))] - [HarmonyPostfix] - private static void Awake(TravelBuffOptionButton __instance) - { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; - } - - [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(TravelBuffOptionButton __instance) - { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; - } - } -} diff --git a/BepInEx/Patches/GameObjects/TravelBuff_Patch.cs b/BepInEx/Patches/GameObjects/TravelBuff_Patch.cs deleted file mode 100644 index 29ed00b..0000000 --- a/BepInEx/Patches/GameObjects/TravelBuff_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelBuff))] - public static class TravelBuff_Patch - { - [HarmonyPatch(nameof(TravelBuff.OnMouseUpAsButton))] - [HarmonyPostfix] - private static void OnMouseUpAsButton() - { - if (TravelBuffMgr.Instance == null) return; - TravelBuffMgr.Instance.text = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text); - TravelBuffMgr.Instance.text2 = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text2); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TravelLookBuff_Patch.cs b/BepInEx/Patches/GameObjects/TravelLookBuff_Patch.cs deleted file mode 100644 index d5e9697..0000000 --- a/BepInEx/Patches/GameObjects/TravelLookBuff_Patch.cs +++ /dev/null @@ -1,63 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelLookBuff))] - public static class TravelLookBuff_Patch - { - [HarmonyPatch(nameof(TravelLookBuff.Clear))] - [HarmonyPostfix] - public static void Post_Clear(TravelLookBuff __instance) - { - __instance.introduce.text = StringStore.TranslateText("无"); - __instance.set = false; - - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))] - [HarmonyPostfix] - public static void Post_OnMouseUpAsButton(TravelLookBuff __instance) - { - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(TravelLookBuff.SetBuff))] - [HarmonyPostfix] - public static void Post_SetBuff(TravelLookBuff __instance) - { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; -#if DEBUG - if (__instance.introduce.text != null) - { - Log.LogInfo($"BuffType: {__instance.buffType}, BuffIndex: {__instance.buffIndex}, BuffIntroduce: {__instance.introduce.text}"); - if (__instance.introduce.text != buffText) - { - FileLoader.DumpUntranslatedStrings(__instance.introduce.text); - //Log.LogInfo($"Mapped BuffIntroduce: {buffText}"); - } - } - -#endif - - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TravelLookMenu_Patch.cs b/BepInEx/Patches/GameObjects/TravelLookMenu_Patch.cs deleted file mode 100644 index 6eeb4a2..0000000 --- a/BepInEx/Patches/GameObjects/TravelLookMenu_Patch.cs +++ /dev/null @@ -1,46 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelLookMenu))] - public static class TravelLookMenu_Patch - { - public static string savedAssetString = ""; - - [HarmonyPatch(nameof(TravelLookMenu.Start))] - [HarmonyPostfix] - private static void Postfix_Start(TravelLookMenu __instance) - { - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - Transform quitButtonTransform = __instance.transform.Find("Quit"); - foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); - savedAssetString = __instance.treasureText.text; - } - - [HarmonyPatch(nameof(TravelLookMenu.Update))] - [HarmonyPostfix] - private static void Update(TravelLookMenu __instance) - { - if (savedAssetString != __instance.treasureText.text) - { - __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); - savedAssetString = __instance.treasureText.text; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TravelRefresh_Patch.cs b/BepInEx/Patches/GameObjects/TravelRefresh_Patch.cs deleted file mode 100644 index 5b0ee24..0000000 --- a/BepInEx/Patches/GameObjects/TravelRefresh_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TravelRefresh))] - public static class TravelRefresh_Patch - { - [HarmonyPatch(nameof(TravelRefresh.Start))] - [HarmonyPostfix] - private static void Start(TravelRefresh __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); - } - - [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))] - [HarmonyPostfix] - private static void OnMouseUpAsButton(TravelRefresh __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); - } - } -} diff --git a/BepInEx/Patches/GameObjects/TravelStore_Patch.cs b/BepInEx/Patches/GameObjects/TravelStore_Patch.cs deleted file mode 100644 index 5635ef8..0000000 --- a/BepInEx/Patches/GameObjects/TravelStore_Patch.cs +++ /dev/null @@ -1,70 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch; -using UnityEngine; -using System.Linq; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - public static class TravelStore_Patch - { - [HarmonyPatch(nameof(TravelStore.Update))] - [HarmonyPostfix] - private static void Update(TravelStore __instance) - { - foreach (TextMeshProUGUI text in __instance.introduces) - { - if (__instance.currentSelect != null) - { - var buffList = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]]; - if (__instance.currentSelect.theBuffNumber < buffList.Count && __instance.currentSelect.theBuffNumber > -1) - { - text.text = buffList[__instance.currentSelect.theBuffNumber]; - } - else - { - text.text = StringStore.TranslateText(text.text); - } - } - } - foreach (var textMesh in __instance.points) - { - textMesh.text = StringStore.TranslateText(textMesh.text); - } - } - - [HarmonyPatch(nameof(TravelStore.RefreshBuff))] - [HarmonyPostfix] - private static void RefreshBuff(TravelStore __instance) - { - foreach (TravelBuff buff in __instance.travelBuffs) - { - TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent(); - cost.text = StringStore.TranslateText(cost.text); - cost.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - foreach (TextMeshProUGUI text in __instance.introduces) - { - if (__instance.currentSelect != null) - { - var buffList = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]]; - if (__instance.currentSelect.theBuffNumber < buffList.Count && __instance.currentSelect.theBuffNumber > -1) - { - text.text = buffList[__instance.currentSelect.theBuffNumber]; - } - else - { - text.text = StringStore.TranslateText(text.text); - } - } - } - foreach (var textMesh in __instance.points) - { - textMesh.text = StringStore.TranslateText(textMesh.text); - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/TreasureConfirmMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureConfirmMenu_Patch.cs deleted file mode 100644 index 5c7df14..0000000 --- a/BepInEx/Patches/GameObjects/TreasureConfirmMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureConfirmMenu))] - public static class TreasureConfirmMenu_Patch - { - [HarmonyPatch(nameof(TreasureConfirmMenu.SetText))] - [HarmonyPostfix] - private static void SetText(TreasureConfirmMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/TreasureEquipmentMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureEquipmentMenu_Patch.cs deleted file mode 100644 index 729ab03..0000000 --- a/BepInEx/Patches/GameObjects/TreasureEquipmentMenu_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureEquipmentMenu))] - public static class TreasureEquipmentMenu_Patch - { - [HarmonyPatch(nameof(TreasureEquipmentMenu.Awake))] - [HarmonyPostfix] - private static void Awake(TreasureEquipmentMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureEquipmentMenu.UpdateCards))] - [HarmonyPostfix] - private static void UpdateCards(TreasureEquipmentMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs deleted file mode 100644 index a399829..0000000 --- a/BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureEvacuateMenu))] - public static class TreasureEvacuateMenu_Patch - { - [HarmonyPatch(nameof(TreasureEvacuateMenu.Start))] - [HarmonyPostfix] - private static void Start(TreasureEvacuateMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - if (txt.name.Contains("text (1)")) - { - txt.name = txt.name + "_EVACUATE"; - } - } - } - } -} - - diff --git a/BepInEx/Patches/GameObjects/TreasureMainMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureMainMenu_Patch.cs deleted file mode 100644 index 649af54..0000000 --- a/BepInEx/Patches/GameObjects/TreasureMainMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureMainMenu))] - public static class TreasureMainMenu_Patch - { - [HarmonyPatch(nameof(TreasureMainMenu.Update))] - [HarmonyPostfix] - private static void Update(TreasureMainMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/TreasureStoreMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureStoreMenu_Patch.cs deleted file mode 100644 index 7d11fe7..0000000 --- a/BepInEx/Patches/GameObjects/TreasureStoreMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureStoreMenu))] - public static class TreasureStoreMenu_Patch - { - [HarmonyPatch(nameof(TreasureStoreMenu.InitCards))] - [HarmonyPostfix] - private static void InitCards(TreasureStoreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs deleted file mode 100644 index b3990ab..0000000 --- a/BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs +++ /dev/null @@ -1,61 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureUpgradeMenu))] - public static class TreasureUpgradeMenu_Patch - { - [HarmonyPatch(nameof(TreasureUpgradeMenu.Start))] - [HarmonyPostfix] - private static void Start(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureUpgradeMenu.UpgradeWareHouse))] - [HarmonyPostfix] - private static void UpgradeWareHouse(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureUpgradeMenu.InitWareHouseUpgrade))] - [HarmonyPostfix] - private static void InitWareHouseUpgrade(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - - foreach (Text txt in __instance.GetComponentsInChildren()) - { - GameObject newTxtObj = Utils.ConvertToTextMeshProUGUI(txt.gameObject, txt.transform.parent, "text"); - TextMeshProUGUI newTxt = newTxtObj.GetComponent(); - newTxt.text = StringStore.TranslateText("植物商店"); - newTxt.autoSizeTextContainer = true; - newTxt.color = new Color(0, 0, 0.3922f, 1); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/TreasureWarehouseMenu_Patch.cs b/BepInEx/Patches/GameObjects/TreasureWarehouseMenu_Patch.cs deleted file mode 100644 index 235daba..0000000 --- a/BepInEx/Patches/GameObjects/TreasureWarehouseMenu_Patch.cs +++ /dev/null @@ -1,63 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(TreasureWarehouseMenu))] - public static class TreasureWarehouseMenu_Patch - { - [HarmonyPatch(nameof(TreasureWarehouseMenu.InitCards))] - [HarmonyPostfix] - private static void InitCards(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.QuickSell))] - [HarmonyPostfix] - private static void QuickSell(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.FastSell))] - [HarmonyPostfix] - private static void FastSell(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.EnterStore))] - [HarmonyPostfix] - private static void EnterStore(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/GameObjects/UIDifficulty_Patch.cs b/BepInEx/Patches/GameObjects/UIDifficulty_Patch.cs deleted file mode 100644 index 49159a5..0000000 --- a/BepInEx/Patches/GameObjects/UIDifficulty_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIDifficulty))] - public static class UIDifficulty_Patch - { - [HarmonyPatch(nameof(UIDifficulty.Update))] - [HarmonyPostfix] - private static void Update(UIDifficulty __instance) - { - __instance.t.text = StringStore.TranslateText(__instance.t.text); - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/GameObjects/UIZombieNum_Patch.cs b/BepInEx/Patches/GameObjects/UIZombieNum_Patch.cs deleted file mode 100644 index d547f91..0000000 --- a/BepInEx/Patches/GameObjects/UIZombieNum_Patch.cs +++ /dev/null @@ -1,29 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIZombieNum))] - public static class UIZombieNum_Patch - { - [HarmonyPatch(nameof(UIZombieNum.Update))] - [HarmonyPostfix] - private static void Update(UIZombieNum __instance) - { - - #if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - string zombieText = StringStore.TranslateText(__instance.t.text); - __instance.t.text = zombieText; - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - string zombieText = StringStore.patchesStore["Zombies"]["Spanish"]; - __instance.t.text = string.Format(zombieText + " {0}", Board.Instance.enermyCount); - #endif - - __instance.t.font = fontAsset; - } - } -} diff --git a/BepInEx/Patches/Managers/AbyssBuffData_Patch.cs b/BepInEx/Patches/Managers/AbyssBuffData_Patch.cs deleted file mode 100644 index e839ade..0000000 --- a/BepInEx/Patches/Managers/AbyssBuffData_Patch.cs +++ /dev/null @@ -1,125 +0,0 @@ -//using HarmonyLib; -//using BepInEx; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.IO; -//using System.Text; -//using System.Text.Json; -//using System.Threading.Tasks; -//using Unity.VisualScripting; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -//{ -// [HarmonyPatch(typeof(AbyssBuffData))] -// public static class AbyssBuffData_Patch -// { -// [HarmonyPatch(nameof(AbyssBuffData.LoadData))] -// [HarmonyPostfix] -// public static void Pre_LoadData(AbyssBuffData __instance) -// { -// string originalAbyssBuffStr = Resources.Load("AbyssBuffData").text; -// Dictionary> originalAbyssBuffData = JsonSerializer.Deserialize>>(originalAbyssBuffStr); -// List infos = originalAbyssBuffData["infos"]; -// Il2CppSystem.Collections.Generic.Dictionary> result = new(); - -// string abyssBuffDataDir = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"); -// if (!File.Exists(abyssBuffDataDir)) -// { -// File.WriteAllText(abyssBuffDataDir, originalAbyssBuffStr); -// } - -// Dictionary abyssBuffData = JsonSerializer.Deserialize>(File.ReadAllText(abyssBuffDataDir)); - -// for (int i = 0; i < infos.Count; i++) -// { -// AbyssBuffInfo originalTuple = infos[i]; -// Il2CppSystem.ValueTuple translatedTuple = new(); - -// translatedTuple.Item1 = abyssBuffData.ContainsKey(originalTuple.name) ? abyssBuffData[originalTuple.name] : originalTuple.name; -// translatedTuple.Item2 = abyssBuffData.ContainsKey(originalTuple.introduce) ? abyssBuffData[originalTuple.introduce] : originalTuple.introduce; -// translatedTuple.Item3 = originalTuple.value; - -// foreach (var x in AbyssBuffData.buffDatas) -// { -// if (x.Value.Item1 == originalTuple.name) -// { -// AbyssBuffData.buffDatas[x.Key] = translatedTuple; -// break; -// } -// } -// } -// } -// } - -// public enum AbyssBuffClone -// { -// 生存_聚塑, -// 生存_启命, -// 生存_坚定, -// 生存_弥合, -// 生存_警戒, -// 生存_霸体, -// 生存_共存, -// 生存_护盾, -// 生存_治疗, -// 生存_主宰, -// 寒冰_聚塑, -// 寒冰_刺骨, -// 寒冰_凛风, -// 寒冰_冻结, -// 寒冰_保护, -// 寒冰_折磨, -// 寒冰_扩散, -// 寒冰_凝神, -// 寒冰_破冰, -// 寒冰_永冻, -// 魅惑_聚塑, -// 魅惑_感应, -// 魅惑_催眠, -// 魅惑_无畏, -// 魅惑_脆弱, -// 魅惑_黑曜, -// 魅惑_转世, -// 魅惑_支援, -// 魅惑_沉重, -// 魅惑_共鸣, -// 烈焰_聚塑, -// 烈焰_爆破, -// 烈焰_怒火, -// 烈焰_红唇, -// 烈焰_融化, -// 烈焰_燃烧, -// 烈焰_浴火, -// 烈焰_鬼火, -// 烈焰_诅咒, -// 烈焰_太阳, -// 通用_断水, -// 通用_千斤, -// 通用_急迫, -// 通用_折扣, -// 通用_密植, -// 通用_超级, -// 通用_究极, -// 通用_极速, -// 通用_强力, -// 通用_专注, -// 通用_迸发, -// 通用_投资, -// 通用_机遇, -// 通用_命运, -// 通用_时停, -// 通用_升级, -// 蒜毒_聚塑, -// 蒜毒_腐蚀, -// 蒜毒_侵蚀, -// 蒜毒_血清, -// 蒜毒_混乱, -// 蒜毒_虚弱, -// 蒜毒_反胃, -// 蒜毒_虫噬, -// 蒜毒_百毒, -// 蒜毒_爆裂 -// } -//} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/AbyssDevelopMenu_Patch.cs b/BepInEx/Patches/Managers/AbyssDevelopMenu_Patch.cs deleted file mode 100644 index 3459635..0000000 --- a/BepInEx/Patches/Managers/AbyssDevelopMenu_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssDevelopMenu))] - public static class AbyssDevelopMenu_Patch - { - [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))] - [HarmonyPostfix] - private static void UpdateInfo(AbyssDevelopMenu __instance) - { - __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); - __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); - } - } -} diff --git a/BepInEx/Patches/Managers/AbyssInfo_Patch.cs b/BepInEx/Patches/Managers/AbyssInfo_Patch.cs deleted file mode 100644 index ce2e837..0000000 --- a/BepInEx/Patches/Managers/AbyssInfo_Patch.cs +++ /dev/null @@ -1,12 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; - -//namespace PvZ_Fusion_Translator.Patches.Managers -//{ -// public class AbyssInfo_Patch -// { -// } -//} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/AbyssMenu2_Patch.cs b/BepInEx/Patches/Managers/AbyssMenu2_Patch.cs deleted file mode 100644 index 6d02d4b..0000000 --- a/BepInEx/Patches/Managers/AbyssMenu2_Patch.cs +++ /dev/null @@ -1,101 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssMenu2))] - public static class AbyssMenu2_Patch - { - private static void UpdateAbyss2Text(AbyssMenu2 __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); - __instance.buffCountText.font = fontAsset; - - __instance.money.text = StringStore.TranslateText(__instance.money.text); - __instance.money.font = fontAsset; - - __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); - __instance.refreshText.font = fontAsset; - - __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); - __instance.statistics.font = fontAsset; - - Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; - if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform); - - Transform moneyTransform = __instance.transform.FindChild("Money").transform; - if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform); - - Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; - if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform); - - Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; - if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform); - - // Translate option buttons - Transform optionsTransform = __instance.transform.FindChild("Options").transform; - foreach (TextMeshProUGUI textMesh in optionsTransform.GetComponentsInChildren()) - { - textMesh.text = StringStore.TranslateText(textMesh.text); - } - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - [HarmonyPatch(nameof(AbyssMenu2.Start))] - [HarmonyPostfix] - private static void Start(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - Utils.ConvertButtonText(__instance.transform, "Help"); - - // custom bag text - __instance.transform.FindChild("Bag").FindChild("text").GetComponent().text += "_深渊"; - Utils.ConvertButtonText(__instance.transform, "Bag"); - } - - [HarmonyPatch(nameof(AbyssMenu2.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - } - - [HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))] - [HarmonyPostfix] - private static void UpdateIcons(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - } - - [HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))] - [HarmonyPostfix] - private static void UpdateBuff(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - } - - [HarmonyPatch(nameof(AbyssMenu2.BuyBuff))] - [HarmonyPostfix] - private static void BuyBuff(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - } - - [HarmonyPatch(nameof(AbyssMenu2.ShowBag))] - [HarmonyPostfix] - private static void ShowBag(AbyssMenu2 __instance) - { - UpdateAbyss2Text(__instance); - } - } -} diff --git a/BepInEx/Patches/Managers/AbyssMenu_Patch.cs b/BepInEx/Patches/Managers/AbyssMenu_Patch.cs deleted file mode 100644 index 0c60bcb..0000000 --- a/BepInEx/Patches/Managers/AbyssMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssMenu))] - public static class AbyssMenu_Patch - { - [HarmonyPatch(nameof(AbyssMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, false); - txt.font = fontAsset; - } - - - } - } -} diff --git a/BepInEx/Patches/Managers/AlmanacMgrZombie_Patch.cs b/BepInEx/Patches/Managers/AlmanacMgrZombie_Patch.cs deleted file mode 100644 index 002d522..0000000 --- a/BepInEx/Patches/Managers/AlmanacMgrZombie_Patch.cs +++ /dev/null @@ -1,145 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.IO; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(AlmanacMgrZombie))] - public static partial class AlmanacMgrZombie_Patch - { - [HarmonyPatch(nameof(AlmanacMgrZombie.InitNameAndInfoFromJson))] - [HarmonyPostfix] - private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance) - { -#if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); -#else - string almanacDir = almanacDir = GetAssetDir(AssetType.Almanac); - string currentLanguage = "English"; -#endif - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); - return; - } - -#if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } -#endif - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - -#if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); -#else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); -#endif - - TextMeshPro component = __instance.info.GetComponent(); - TextMeshPro component2 = __instance.zombieName.GetComponent(); - TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent(); - - ZombieAlmanacData zombieData = JsonUtility.FromJson(json); - - foreach (ZombieInfo zombieInfo in zombieData.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; - } - } - - if (File.Exists(moddedPath)) - { - string moddedJson; - moddedJson = File.ReadAllText(moddedPath); - - ZombieAlmanacData moddedZombieData = JsonUtility.FromJson(moddedJson); - - foreach (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))] - [HarmonyPrefix] - private static bool OnMouseDown(AlmanacMgrZombie __instance) - { - TextMeshPro component = __instance.info.GetComponent(); - if (component != null) - { - component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; - return false; - } - return true; - } - } - - [Serializable] - public class ZombieAlmanacData - { - public List zombies; - } - - [Serializable] - public class ZombieInfo - { - public string name; - public string info; - public string introduce; - public ZombieType theZombieType; - } -} diff --git a/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs b/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs deleted file mode 100644 index 9e23635..0000000 --- a/BepInEx/Patches/Managers/AlmanacPlantBank_Patch.cs +++ /dev/null @@ -1,200 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.IO; -using UnityEngine; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(AlmanacPlantBank))] - public static partial class AlmanacPlantBank_Patch - { - [HarmonyPatch(nameof(AlmanacPlantBank.InitNameAndInfoFromJson))] - [HarmonyPostfix] - private static void InitNameAndInfoFromJson(AlmanacPlantBank __instance) - { -#if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); -#else - string almanacDir = GetAssetDir(AssetType.Almanac); - string currentLanguage = "English"; -#endif - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - return; - } - -#if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } -#endif - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - -#if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); -#else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); -#endif - - TextMeshPro component = __instance.introduce.GetComponent(); - TextMeshPro component2 = __instance.plantName.GetComponent(); - TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent(); - TextMeshPro component4 = __instance.cost.GetComponent(); - - AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson(json); - - foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants) - { - if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name)) - { - 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 ?? string.Empty); - 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; - } - } - - if (File.Exists(moddedPath)) - { - string moddedJson; - moddedJson = File.ReadAllText(moddedPath); - - AlmanacPlantBank.PlantData moddedPlantData = JsonUtility.FromJson(moddedJson); - - foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants) - { - if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name)) - { - 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 ?? string.Empty); - 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; - } - - [HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))] - [HarmonyPrefix] - private static bool OnMouseDown(AlmanacPlantBank __instance) - { - TextMeshPro component = __instance.introduce.GetComponent(); - if (component != null) - { - component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; - return false; - } - return true; - } - - [HarmonyPatch(nameof(AlmanacPlantBank.PVPInit))] - [HarmonyPostfix] - private static void PVPInit(AlmanacPlantBank __instance) - { - TextMeshPro component = __instance.introduce.GetComponent(); - if (component != null) - { - component.autoSizeTextContainer = false; - } - - Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0); - if (banTransform != null) - { - banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); - } - } - - [HarmonyPatch(nameof(AlmanacPlantBank.Start))] - [HarmonyPostfix] - public static void Post_Start(AlmanacPlantBank __instance) - { - GameObject skinTextObj = __instance.skinButton.transform.GetChild(0).gameObject; - GameObject skinShadowTextObj = UnityEngine.Object.Instantiate(skinTextObj, parent: __instance.skinButton.transform); - TextMeshPro skinShadowText = skinShadowTextObj.GetComponent(); - skinShadowText.text = StringStore.TranslateText("换肤_S"); - skinShadowText.sortingOrder -= 2; - skinShadowTextObj.transform.Translate(new Vector3(0.015f, -0.015f, 0)); - skinTextObj.transform.Translate(new Vector3(-0.022f, 0)); - skinShadowTextObj.transform.Translate(new Vector3(-0.022f, 0)); - __instance.skinButton.transform.localScale /= 1.75f; - __instance.skinButton.transform.Translate(new Vector3(-0.075f, -0.15f, 0)); - __instance.skinButton.transform.GetChild(1).Translate(new Vector3(0.35f, 0)); - __instance.skinButton.transform.GetChild(2).Translate(new Vector3(-0.35f, 0)); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/CanvasUpUI_Patch.cs b/BepInEx/Patches/Managers/CanvasUpUI_Patch.cs deleted file mode 100644 index c73b142..0000000 --- a/BepInEx/Patches/Managers/CanvasUpUI_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_; -using System; -using System.Linq; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(CanvasUpUI))] - public static class CanvasUpUI_Patch - { - [HarmonyPatch(nameof(CanvasUpUI.Start))] - [HarmonyPostfix] - public static void Start(CanvasUpUI __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => (x.Value == text.text || x.Value.Replace("\n", "") == text.text)).Key; - text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text); - if(text.gameObject.name.Contains("LevelName")) - { - text.text = text.text.Replace("\n", " "); - } - text.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/ChessManager_Patch.cs b/BepInEx/Patches/Managers/ChessManager_Patch.cs deleted file mode 100644 index 1c2f52f..0000000 --- a/BepInEx/Patches/Managers/ChessManager_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.TextCore.Text; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(ChessManager))] - public static class ChessManager_Patch - { - [HarmonyPatch(nameof(ChessManager.Start))] - [HarmonyPostfix] - private static void Postfix_Start(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ChessManager.Update))] - [HarmonyPostfix] - private static void Postfix_Update(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ChessManager.UpdateText))] - [HarmonyPostfix] - private static void Postfix_UpdateText(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} diff --git a/BepInEx/Patches/Managers/CustomLevelShower_Patch.cs b/BepInEx/Patches/Managers/CustomLevelShower_Patch.cs deleted file mode 100644 index 81f4a72..0000000 --- a/BepInEx/Patches/Managers/CustomLevelShower_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if FIX -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(CustomLevelShower))] - public static class CustomLevelShower_Patch - { - [HarmonyPatch(nameof(CustomLevelShower.Show))] - [HarmonyPostfix] - private static void Show(CustomLevelShower __instance) - { - foreach (Transform transform in __instance.pages) - { - StringStore.TranslateTextTransform(transform); - } - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/Patches/Managers/DifficultyMgr_Patch.cs b/BepInEx/Patches/Managers/DifficultyMgr_Patch.cs deleted file mode 100644 index 84585b5..0000000 --- a/BepInEx/Patches/Managers/DifficultyMgr_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(DifficultyMgr))] - public static class DifficultyMgr_Patch - { - [HarmonyPatch(nameof(DifficultyMgr.Update))] - [HarmonyPostfix] - private static void DifficultyMgr_Update(DifficultyMgr __instance) - { - __instance.t = StringStore.TranslateText(__instance.t); - __instance.t.autoSizeTextContainer = false; - } - } -} diff --git a/BepInEx/Patches/Managers/DrawCardManager_Patch.cs b/BepInEx/Patches/Managers/DrawCardManager_Patch.cs deleted file mode 100644 index c85ca88..0000000 --- a/BepInEx/Patches/Managers/DrawCardManager_Patch.cs +++ /dev/null @@ -1,61 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using Il2CppSystem.Collections.Generic; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; -using UnityEngine.TextCore.Text; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects -{ - [HarmonyPatch(typeof(DrawCardManager))] - public static class DrawCardManager_Patch - { - [HarmonyPatch(nameof(DrawCardManager.UpdateText))] - [HarmonyPostfix] - private static void Postfix_UpdateText(DrawCardManager __instance) - { - Il2CppSystem.Collections.Generic.List texts = __instance.texts; - __instance.upName = StringStore.TranslateText(__instance.upName); - if (texts != null && texts.Count > 0) - { - foreach (TextMeshProUGUI textComponent in texts) - { - if (textComponent != null) - { - string translatedText = StringStore.TranslateText(textComponent.text); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - textComponent.text = translatedText; - textComponent.font = fontAsset; - } - } - } - } - - - - [HarmonyPatch(nameof(DrawCardManager.Update))] - [HarmonyPostfix] - private static void Postfix_Update(DrawCardManager __instance) - { - Il2CppSystem.Collections.Generic.List texts = __instance.texts; - __instance.upName = StringStore.TranslateText(__instance.upName); - - if (texts != null && texts.Count > 0) - { - foreach (TextMeshProUGUI textComponent in texts) - { - if (textComponent != null) - { - string translatedText = StringStore.TranslateText(textComponent.text); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - textComponent.text = translatedText; - textComponent.font = fontAsset; - } - } - } - - } - } -} - diff --git a/BepInEx/Patches/Managers/EndlessMgr_Patch.cs b/BepInEx/Patches/Managers/EndlessMgr_Patch.cs deleted file mode 100644 index b137eff..0000000 --- a/BepInEx/Patches/Managers/EndlessMgr_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(EndlessMgr))] - public static class EndlessMgr_Patch - { - [HarmonyPatch(nameof(EndlessMgr.Awake))] - [HarmonyPostfix] - private static void Awake(EndlessMgr __instance) - { - Transform textTransform = __instance.transform.GetChild(2); - if (textTransform != null && textTransform.gameObject.activeSelf) - { - TextMeshProUGUI textTMP = textTransform.GetComponent(); - if (textTMP != null) - { - textTMP = StringStore.TranslateText(textTMP); - } - } - } - } -} diff --git a/BepInEx/Patches/Managers/GameAPP_Patch.cs b/BepInEx/Patches/Managers/GameAPP_Patch.cs deleted file mode 100644 index 3fdccef..0000000 --- a/BepInEx/Patches/Managers/GameAPP_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using TMPro; -using UnityEngine.EventSystems; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(GameAPP))] - public class GameAPP_Patch - { - [HarmonyPatch(nameof(GameAPP.Update))] - [HarmonyPrefix] - private static bool Update(GameAPP __instance) - { - Core.Instance.OnUpdate(); - - if (EventSystem.current?.currentSelectedGameObject != null) - { - if (EventSystem.current.currentSelectedGameObject.TryGetComponent(out TMP_InputField field)) - { - __instance.MusicUpdate(); - return false; - } - } - return true; - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/Garden_Patch.cs b/BepInEx/Patches/Managers/Garden_Patch.cs deleted file mode 100644 index 6548f63..0000000 --- a/BepInEx/Patches/Managers/Garden_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(Garden))] - public static class Garden_Patch - { - [HarmonyPatch(nameof(Garden.Awake))] - [HarmonyPostfix] - private static void Awake(Garden __instance) - { - foreach (TextMeshPro text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/BepInEx/Patches/Managers/IZBottomMenu_Patch.cs b/BepInEx/Patches/Managers/IZBottomMenu_Patch.cs deleted file mode 100644 index c114a24..0000000 --- a/BepInEx/Patches/Managers/IZBottomMenu_Patch.cs +++ /dev/null @@ -1,54 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(IZBottomMenu))] - public static class IZBottomMenu_Patch - { - [HarmonyPatch(nameof(IZBottomMenu.ChangeString))] - [HarmonyPostfix] - public static void ChangeStringz(IZBottomMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.levelName) - { - string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"]; - string[] parts = text.text.Split(",推荐难度:"); - - if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(text.text)) - { - string customName = (StringStore.translationString.ContainsKey(parts[0] + "_IZ")) ? parts[0] + "_IZ" : parts[0]; - text.text = string.Format(fStr, StringStore.TranslateText(customName), parts[1]); - } - - text.text = StringStore.TranslateText(text.text); - text.text = text.text.Replace("\n", " "); - } - } - - [HarmonyPatch(nameof(IZBottomMenu.SetLevelName))] - [HarmonyPostfix] - public static void SetLevelName(IZBottomMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.levelName) - { - string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"]; - string[] parts = text.text.Split(",推荐难度:"); - - if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(text.text)) - { - text.text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]); - } - - text.text = StringStore.TranslateText(text.text); - text.text = text.text.Replace("\n", " "); - } - } - } -} - - diff --git a/BepInEx/Patches/Managers/InGameUIMgr_Patch.cs b/BepInEx/Patches/Managers/InGameUIMgr_Patch.cs deleted file mode 100644 index 8d698ec..0000000 --- a/BepInEx/Patches/Managers/InGameUIMgr_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using HarmonyLib; -using System; - -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(InGameUI))] - public static class InGameUIMgr_Patch - { - [HarmonyPatch(nameof(InGameUI.Start))] - [HarmonyPostfix] - private static void Start(InGameUI __instance) - { - TextMeshProUGUI[] array = new TextMeshProUGUI[] - { - __instance.transform.GetChild(4).GetComponent(), - __instance.transform.GetChild(4).GetChild(0).GetComponent(), - __instance.transform.GetChild(5).GetComponent(), - __instance.transform.GetChild(5).GetChild(0).GetComponent(), - __instance.transform.GetChild(6).GetComponent(), - __instance.transform.GetChild(6).GetChild(0).GetComponent() - }; - TextMeshProUGUI[] array2 = array; - for (int i = 0; i < array2.Length; i++) - { - - array2[i] = StringStore.TranslateText(array2[i]); - array2[i].text = array2[i].text.Replace("\n", " "); - } - } - } -} diff --git a/BepInEx/Patches/Managers/InGameUI_Patch.cs b/BepInEx/Patches/Managers/InGameUI_Patch.cs deleted file mode 100644 index 6b2c63a..0000000 --- a/BepInEx/Patches/Managers/InGameUI_Patch.cs +++ /dev/null @@ -1,78 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(InGameUI))] - public static class InGameUI_Patch - { - [HarmonyPatch(nameof(InGameUI.Start))] - [HarmonyPostfix] - private static void Start(InGameUI __instance) - { - TextMeshProUGUI[] array = new TextMeshProUGUI[] - { - __instance.transform.GetChild(4).GetComponent(), - __instance.transform.GetChild(4).GetChild(0).GetComponent(), - __instance.transform.GetChild(5).GetComponent(), - __instance.transform.GetChild(5).GetChild(0).GetComponent(), - __instance.transform.GetChild(6).GetComponent(), - __instance.transform.GetChild(6).GetChild(0).GetComponent()}; - TextMeshProUGUI[] array2 = array; - for (int i = 0; i < array2.Length; i++) - { - string originalText = array2[i].text; - array2[i].text = array2[i].text.Replace("\n", " "); - Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)"); - - if (array2[i].text.Contains("配方:") && !checkFusionChallenge.IsMatch(array2[i].text)) - { - string[] lines = array2[i].text.Split(":"); - lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]); - if (lines[1] == "") - { - Log.LogError("Couldn't find plant! (Fusion Showcase)"); - lines[1] = StringStore.TranslateText(lines[1]); - } - array2[i].text = StringStore.TranslateText("配方:") + lines[1]; - array2[i].autoSizeTextContainer = true; - } - else - { - array2[i].text = (StringStore.translationString.ContainsKey(array2[i].text + "_MG")) ? StringStore.TranslateText(array2[i].text + "_MG") : StringStore.TranslateText(array2[i].text); - array2[i].text = array2[i].text.Replace("\n", " "); - } - } - } - - [HarmonyPatch(nameof(InGameUI.Update))] - [HarmonyPostfix] - private static void Update(InGameUI __instance) - { - foreach(TextMeshProUGUI txt in __instance.ShovelBank.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } - - [HarmonyPatch(typeof(InGameUI_IZ))] - public static class InGameUI_IZ_Patch - { - [HarmonyPatch(nameof(InGameUI_IZ.Update))] - [HarmonyPostfix] - private static void Update(InGameUI_IZ __instance) - { - foreach (TextMeshProUGUI txt in __instance.shovel.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/BepInEx/Patches/Managers/OppositeBuffManager_Patch.cs b/BepInEx/Patches/Managers/OppositeBuffManager_Patch.cs deleted file mode 100644 index b35fa41..0000000 --- a/BepInEx/Patches/Managers/OppositeBuffManager_Patch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using TMPro; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(OppositeBuffManager))] - public static class OppositeBuffManager_Patch - { - public static Dictionary buffLinks = TravelMgr_Patch.buffLinks; - public static Dictionary> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs; - public static string badPattern = @"^但(.*)"; - public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}"; - public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - [HarmonyPatch(nameof(OppositeBuffManager.Awake))] - [HarmonyPostfix] - private static void Awake(OppositeBuffManager __instance) - { - TranslateOppositeText(__instance.textA_bad, BuffType.Debuff, __instance.buffA.theDebuffID, true); - TranslateOppositeText(__instance.textA_good, __instance.buffA.theOptionType, __instance.buffA.theOptionID); - TranslateOppositeText(__instance.textB_bad, BuffType.Debuff, __instance.buffB.theDebuffID, true); - TranslateOppositeText(__instance.textB_good, __instance.buffB.theOptionType, __instance.buffB.theOptionID); - } - - public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List textList, BuffType buffType, int buffIndex, bool isBad = false) - { - string buff = translatedTravelBuffs[buffLinks[buffType]][buffIndex]; - - foreach (var text in textList) - { - if (isBad) - { - text.text = string.Format(badFormat, buff); - } - else - { - text.text = buff; - } - - text.font = fontAsset; - } - } - } -} diff --git a/BepInEx/Patches/Managers/SaveMenu_Patch.cs b/BepInEx/Patches/Managers/SaveMenu_Patch.cs deleted file mode 100644 index aa5d1f0..0000000 --- a/BepInEx/Patches/Managers/SaveMenu_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(SaveMenu))] - public static class SaveMenu_Patch - { - [HarmonyPatch(nameof(SaveMenu.Start))] - [HarmonyPostfix] - private static void Start(SaveMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.title.text = StringStore.TranslateText(__instance.title.text); - __instance.title.font = fontAsset; - __instance.title_shadow.text = StringStore.TranslateText(__instance.title_shadow.text); - __instance.title_shadow.font = fontAsset; - - foreach(SaveMenuBtn level in __instance.levels) - { - level.theName.text = StringStore.TranslateText(level.theName.text); - } - } - } -} diff --git a/BepInEx/Patches/Managers/TowerManager_Patch.cs b/BepInEx/Patches/Managers/TowerManager_Patch.cs deleted file mode 100644 index 71d3656..0000000 --- a/BepInEx/Patches/Managers/TowerManager_Patch.cs +++ /dev/null @@ -1,33 +0,0 @@ -using HarmonyLib; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using TMPro; -using BepInEx.Unity.IL2CPP; -using System.Collections.Generic; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(TowerManager))] - public static class TowerManager_Patch - { - public static List updatedText = []; - - public static void UpdateText() - { - foreach (Transform transform in updatedText) - { - if (transform != null) - { - transform.GetComponent().text = StringStore.TranslateText(transform.GetComponent().text); - } - } - } - - [HarmonyPatch(nameof(TowerManager.Update))] - [HarmonyPostfix] - public static void Update(TowerManager __instance) - { - - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/TravelBuffMgr_Patch.cs b/BepInEx/Patches/Managers/TravelBuffMgr_Patch.cs deleted file mode 100644 index c72829f..0000000 --- a/BepInEx/Patches/Managers/TravelBuffMgr_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using System; -using System.Text.Encodings.Web; -using System.Text.Json; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(TravelBuffMgr))] - public static class TravelBuffMgr_Patch - { - [HarmonyPatch(nameof(TravelBuffMgr.Awake))] - [HarmonyPostfix] - private static void Awake(TravelBuffMgr __instance) - { - __instance.text = AssetStore.StringStore.TranslateText(__instance.text); - __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); - } - - [HarmonyPatch(nameof(TravelBuffMgr.ShowText), new Type[] { typeof(int), typeof(int) })] - [HarmonyPostfix] - private static void ShowText(TravelBuffMgr __instance) - { - __instance.text = AssetStore.StringStore.TranslateText(__instance.text); - __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); - } - } -} diff --git a/BepInEx/Patches/Managers/TravelMgr_Patch.cs b/BepInEx/Patches/Managers/TravelMgr_Patch.cs deleted file mode 100644 index 51d56e8..0000000 --- a/BepInEx/Patches/Managers/TravelMgr_Patch.cs +++ /dev/null @@ -1,103 +0,0 @@ -using TMPro; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.IO; -using System.Threading.Tasks; -using HarmonyLib; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(TravelMgr))] - public static class TravelMgr_Patch - { - public static Dictionary buffLinks = new Dictionary() - { - { BuffType.AdvancedBuff, "advancedUpgrades" }, - { BuffType.UltimateBuff, "ultimateUpgrades" }, - { BuffType.UnlockPlant, "strongUltimates" }, - { BuffType.Debuff, "debuffs" }, - }; - - public static Dictionary> dumpedTravelBuffs = new Dictionary>() - { - { "advancedUpgrades", [] }, - { "ultimateUpgrades", [] }, - { "strongUltimates", [] }, - { "debuffs", [] } - }; - - public static Dictionary> translatedTravelBuffs = new Dictionary>(); - - public static void DumpTravelBuffs(Il2CppSystem.Collections.Generic.Dictionary source, Dictionary> dest, string index) - { - foreach (var i in source) - { - if (!Utils.CheckForUntranslatedText(i.Value)) - { - break; - } - dest[index].Add(i.Value); - } - } - - public static string MatchTravelBuff(string originalText) - { - string res = ""; - - foreach(var i in dumpedTravelBuffs) - { - if(i.Value.Contains(originalText)) - { - res = translatedTravelBuffs[i.Key][i.Value.IndexOf(originalText)]; - break; - } - } - - return res; - } - - [HarmonyPatch(nameof(TravelMgr.Awake))] - [HarmonyPrefix] - private static void Pre_Awake(TravelMgr __instance) - { - // Dump buffs - - dumpedTravelBuffs = new Dictionary>() // reset dump - { - { "advancedUpgrades", [] }, - { "ultimateUpgrades", [] }, - { "strongUltimates", [] }, - { "debuffs", [] } - }; - - DumpTravelBuffs(TravelMgr.advancedBuffs, dumpedTravelBuffs, "advancedUpgrades"); - DumpTravelBuffs(TravelMgr.ultimateBuffs, dumpedTravelBuffs, "ultimateUpgrades"); - DumpTravelBuffs(TravelMgr.unlocks, dumpedTravelBuffs, "strongUltimates"); - DumpTravelBuffs(TravelMgr.debuffs, dumpedTravelBuffs, "debuffs"); - - string dumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps); - var options = new JsonSerializerOptions - { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - WriteIndented = true - }; - File.WriteAllText(Path.Combine(dumpDir, "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, options)); - - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - string travelBuffDir = Path.Combine(stringDir, "travel_buffs.json"); - - if(!File.Exists(travelBuffDir)) - { - File.WriteAllText(travelBuffDir, JsonSerializer.Serialize(dumpedTravelBuffs, options)); - } - - string travelBuffs = File.ReadAllText(Path.Combine(stringDir, "travel_buffs.json")); - - translatedTravelBuffs = JsonSerializer.Deserialize>>(travelBuffs); - } - } -} \ No newline at end of file diff --git a/BepInEx/Patches/Managers/TreasureManager_Patch.cs b/BepInEx/Patches/Managers/TreasureManager_Patch.cs deleted file mode 100644 index 6375434..0000000 --- a/BepInEx/Patches/Managers/TreasureManager_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(TreasureManager))] - public static class TreasureManager_Patch - { - [HarmonyPatch(nameof(TreasureManager.Update))] - [HarmonyPostfix] - private static void Update(TreasureManager __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.evaText) - { - txt.autoSizeTextContainer = false; - - if (txt.text != "Evacuate") - { - txt.text = StringStore.TranslateText(txt.text); - txt.name = txt.text + "_EVACUATE"; - txt.font = fontAsset; - } - } - } - } -} - - diff --git a/BepInEx/Patches/Managers/UIMgr_Patch.cs b/BepInEx/Patches/Managers/UIMgr_Patch.cs deleted file mode 100644 index 12f5d50..0000000 --- a/BepInEx/Patches/Managers/UIMgr_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers -{ - [HarmonyPatch(typeof(UIMgr))] - public class UIMgr_Patch - { - //[HarmonyPatch(nameof(UIMgr.EnterMainMenu))] - //[HarmonyPostfix] - //private static void EnterMainMenu(UIMgr __instance) - //{ - // // Log.LogInfo("Entered Main Menu"); - // #if MULTI_LANGUAGE - // WarningStore.WarningReload(Utils.Language); - // #else - // WarningStore.WarningReload(); - // #endif - //} - } -} \ No newline at end of file diff --git a/BepInEx/Patches/OtherManagers/AchievementClip_Patch.cs b/BepInEx/Patches/OtherManagers/AchievementClip_Patch.cs deleted file mode 100644 index 2c3de3d..0000000 --- a/BepInEx/Patches/OtherManagers/AchievementClip_Patch.cs +++ /dev/null @@ -1,73 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using TMPro; -using Newtonsoft.Json; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; -using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.AlmanacPlantBank_Patch; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers -{ - [HarmonyPatch(typeof(AchievementClip))] - public static class AchievementClip_Patch - { - [HarmonyPatch(nameof(AchievementClip.Start))] - [HarmonyPostfix] - private static void Start(AchievementClip __instance) - { - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string achievementDir = GetAssetDir(AssetType.Almanac, Utils.Language); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - string achievementDir = GetAssetDir(AssetType.Almanac); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - string path = Path.Combine(achievementDir, "AchievementsTextTranslate.json"); - - #if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } - #endif - - if (!File.Exists(path)) return; - - string json; - json = File.ReadAllText(path); - Dictionary achievementsTexts = new Dictionary(); - achievementsTexts = JsonConvert.DeserializeObject>(json); - - TextMeshProUGUI text1 = __instance.introduce.transform.GetChild(1).GetComponent(); - TextMeshProUGUI text2 = __instance.introduce.transform.GetChild(2).GetComponent(); - TextMeshProUGUI name1 = __instance.image.transform.GetChild(0).GetComponent(); - - - text1.text = achievementsTexts[__instance._index].Name; - text1.font = fontAsset; - text2.text = achievementsTexts[__instance._index].Name; - text2.font = fontAsset; - name1.text = achievementsTexts[__instance._index].Text; - name1.font = fontAsset; - } - } - - public class AchievementObject - { - public Achievement achievement { get; set; } - public string Name { get; set; } - public string Text { get; set; } - - public AchievementObject(Achievement achievement = Achievement.Welcome, string name = "", string text = "") - { - this.achievement = achievement; - Name = name; - Text = text; - } - } -} diff --git a/BepInEx/Patches/OtherManagers/GardenUI_Patch.cs b/BepInEx/Patches/OtherManagers/GardenUI_Patch.cs deleted file mode 100644 index d313017..0000000 --- a/BepInEx/Patches/OtherManagers/GardenUI_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using System; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers -{ - [HarmonyPatch(typeof(GardenUI))] - public static class GardenUI_Patch - { - [HarmonyPatch(nameof(GardenUI.Update))] - [HarmonyPostfix] - public static void Update(GardenUI __instance) - { - __instance.currentPageText = StringStore.TranslateText(__instance.currentPageText, false); - __instance.currentPageText2 = StringStore.TranslateText(__instance.currentPageText2, false); - - // Transform PageText = __instance.transform.Find("PageText"); - // StringStore.TranslateTextTransform(PageText.transform); - } - } -} diff --git a/BepInEx/Patches/OtherManagers/MenuText_Patch.cs b/BepInEx/Patches/OtherManagers/MenuText_Patch.cs deleted file mode 100644 index 8aaf4f2..0000000 --- a/BepInEx/Patches/OtherManagers/MenuText_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if FIX -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers -{ - [HarmonyPatch(typeof(MenuText))] - public static class MenuText_Patch - { - [HarmonyPatch(nameof(MenuText.UpdateText), new Type[] { typeof(string) })] - [HarmonyPostfix] - private static void UpdateTextPatch(MenuText __instance) - { - TextMeshProUGUI text_1 = __instance.transform.GetChild(0).Find("text1").GetComponent(); - text_1.text = StringStore.TranslateText(text_1.text); - TextMeshProUGUI text = __instance.transform.GetChild(0).Find("text").GetComponent(); - text.text = StringStore.TranslateText(text_1.text); - } - } -} -#endif \ No newline at end of file diff --git a/BepInEx/Patches/OtherManagers/ThanksMenu_Patch.cs b/BepInEx/Patches/OtherManagers/ThanksMenu_Patch.cs deleted file mode 100644 index cf94e6c..0000000 --- a/BepInEx/Patches/OtherManagers/ThanksMenu_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -using HarmonyLib; -using System; -using TMPro; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; - -namespace PvZ_Fusion_Translator__BepInEx_.Patches.OtherManagers -{ - [HarmonyPatch(typeof(ThanksMenu))] - public class ThanksMenu_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ThanksMenu.Update))] - private static void Update(ThanksMenu __instance) - { - TextMeshProUGUI textTransform = __instance.transform.GetChild(0).GetComponent(); - if (textTransform != null) - { - textTransform.text = StringStore.TranslateText(textTransform.text); - textTransform.autoSizeTextContainer = true; - } - } - } -} \ No newline at end of file diff --git a/BepInEx/PvZ Fusion Translator [BepInEx].csproj b/BepInEx/PvZ Fusion Translator [BepInEx].csproj deleted file mode 100644 index d1a8ddf..0000000 --- a/BepInEx/PvZ Fusion Translator [BepInEx].csproj +++ /dev/null @@ -1,614 +0,0 @@ - - - - net6.0 - PvZ_Fusion_Translator__BepInEx_ - BepInEx Port of PvZ Fusion Translator - 1.0.0 - true - latest - - https://api.nuget.org/v3/index.json; - https://nuget.bepinex.dev/v3/index.json; - https://nuget.samboy.dev/v3/index.json - - PvZ_Fusion_Translator__BepInEx_ - C:\Users\Admin\Downloads\PvZ FUSION VH FANMADE - C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.1.1 - Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate;DebugMulti - AnyCPU;x64 - - - - - - - - - - - True - false - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE;RELEASE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(GamePath)\BepInEx\core\0Harmony.dll - - - $(GamePath)\BepInEx\core\AsmResolver.dll - - - $(GamePath)\BepInEx\core\AsmResolver.DotNet.dll - - - $(GamePath)\BepInEx\core\AsmResolver.PE.dll - - - $(GamePath)\BepInEx\core\AsmResolver.PE.File.dll - - - $(GamePath)\BepInEx\interop\Assembly-CSharp.dll - - - $(GamePath)\BepInEx\core\AssetRipper.CIL.dll - - - $(GamePath)\BepInEx\core\AssetRipper.Primitives.dll - - - $(GamePath)\BepInEx\core\BepInEx.Core.dll - - - $(GamePath)\BepInEx\core\BepInEx.Preloader.Core.dll - - - $(GamePath)\BepInEx\core\BepInEx.Unity.Common.dll - - - $(GamePath)\BepInEx\core\BepInEx.Unity.IL2CPP.dll - - - $(GamePath)\BepInEx\core\Cpp2IL.Core.dll - - - $(GamePath)\BepInEx\core\Disarm.dll - - - $(GamePath)\BepInEx\core\Gee.External.Capstone.dll - - - $(GamePath)\BepInEx\core\Iced.dll - - - $(GamePath)\BepInEx\core\Il2CppInterop.Common.dll - - - $(GamePath)\BepInEx\core\Il2CppInterop.Generator.dll - - - $(GamePath)\BepInEx\core\Il2CppInterop.HarmonySupport.dll - - - $(GamePath)\BepInEx\core\Il2CppInterop.Runtime.dll - - - $(GamePath)\BepInEx\interop\Il2CppMono.Security.dll - - - $(GamePath)\BepInEx\interop\Il2Cppmscorlib.dll - - - $(GamePath)\BepInEx\interop\Il2CppSystem.dll - - - $(GamePath)\BepInEx\interop\Il2CppSystem.Configuration.dll - - - $(GamePath)\BepInEx\interop\Il2CppSystem.Core.dll - - - $(GamePath)\BepInEx\interop\Il2CppSystem.Xml.dll - - - $(GamePath)\BepInEx\core\LibCpp2IL.dll - - - $(GamePath)\BepInEx\core\Mono.Cecil.dll - - - $(GamePath)\BepInEx\core\Mono.Cecil.Mdb.dll - - - $(GamePath)\BepInEx\core\Mono.Cecil.Pdb.dll - - - $(GamePath)\BepInEx\core\Mono.Cecil.Rocks.dll - - - $(GamePath)\BepInEx\core\MonoMod.RuntimeDetour.dll - - - $(GamePath)\BepInEx\core\MonoMod.Utils.dll - - - $(GamePath)\BepInEx\core\SemanticVersioning.dll - - - $(GamePath)\BepInEx\core\StableNameDotNet.dll - - - $(GamePath)\BepInEx\interop\Unity.2D.Animation.Runtime.dll - - - $(GamePath)\BepInEx\interop\Unity.Burst.dll - - - $(GamePath)\BepInEx\interop\Unity.Burst.Unsafe.dll - - - $(GamePath)\BepInEx\interop\Unity.Collections.dll - - - $(GamePath)\BepInEx\interop\Unity.Collections.LowLevel.ILSupport.dll - - - $(GamePath)\BepInEx\interop\Unity.InternalAPIEngineBridge.001.dll - - - $(GamePath)\BepInEx\interop\Unity.Mathematics.dll - - - $(GamePath)\BepInEx\interop\Unity.RenderPipeline.Universal.ShaderLibrary.dll - - - $(GamePath)\BepInEx\interop\Unity.RenderPipelines.Core.Runtime.dll - - - $(GamePath)\BepInEx\interop\Unity.RenderPipelines.Universal.Runtime.dll - - - $(GamePath)\BepInEx\interop\Unity.TextMeshPro.dll - - - $(GamePath)\BepInEx\interop\Unity.VisualScripting.Core.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AccessibilityModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AIModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AndroidJNIModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AnimationModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AssetBundleModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.AudioModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ClothModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ClusterInputModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ClusterRendererModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ContentLoadModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.CoreModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.CrashReportingModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.DirectorModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.DSPGraphModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.GameCenterModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.GIModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.GridModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.HotReloadModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ImageConversionModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.IMGUIModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.InputLegacyModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.InputModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.JSONSerializeModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.LocalizationModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ParticleSystemModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.PerformanceReportingModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.Physics2DModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.PhysicsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ProfilerModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.PropertiesModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.ScreenCaptureModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.SharedInternalsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.SpriteMaskModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.SpriteShapeModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.StreamingModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.SubstanceModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.SubsystemsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TerrainModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TerrainPhysicsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TextCoreFontEngineModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TextCoreTextEngineModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TextRenderingModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TilemapModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.TLSModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UI.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UIElementsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UIModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UmbraModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityAnalyticsCommonModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityAnalyticsModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityConnectModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityCurlModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityTestProtocolModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityWebRequestAssetBundleModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityWebRequestAudioModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityWebRequestModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityWebRequestTextureModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.UnityWebRequestWWWModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.VehiclesModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.VFXModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.VideoModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.VirtualTexturingModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.VRModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.WindModule.dll - - - $(GamePath)\BepInEx\interop\UnityEngine.XRModule.dll - - - $(GamePath)\BepInEx\core\WasmDisassembler.dll - - - $(GamePath)\BepInEx\interop\__Generated.dll - - - $(GamePath)\BepInEx\interop\Assembly-CSharp.dll - - - $(GamePath)\BepInEx\plugins\AudioImportLib.BepInEx.dll - - - $(GamePath)\BepInEx\core\Newtonsoft.Json.dll - - - - - - - - - diff --git a/BepInEx/Utils.cs b/BepInEx/Utils.cs deleted file mode 100644 index a09ed3a..0000000 --- a/BepInEx/Utils.cs +++ /dev/null @@ -1,430 +0,0 @@ -using BepInEx; -using BepInEx.Configuration; -using PvZ_Fusion_Translator__BepInEx_.AssetStore; -using PvZ_Fusion_Translator__BepInEx_.Patches.Managers; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Text.RegularExpressions; -using TMPro; -using Unity.Burst.Intrinsics; -using Unity.VisualScripting.FullSerializer; -using UnityEngine; -using UnityEngine.Experimental.Rendering; -using UnityEngine.UI; -using static AlmanacPlantBank; -using static PvZ_Fusion_Translator__BepInEx_.FileLoader; - -namespace PvZ_Fusion_Translator__BepInEx_ -{ - public class Utils - { - public static Dictionary> plantIndices = new Dictionary>(); - - public static void RegisterPlantIndices() - { - plantIndices = new Dictionary>(); - string originalJson; - string translatedJson; - - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string dumpDir = GetAssetDir(AssetType.Dumps); - string originalPath = Path.Combine(dumpDir, "LawnStrings.json"); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - if ((!File.Exists(path)) || (!File.Exists(originalPath))) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - } - else - { - originalJson = File.ReadAllText(originalPath); - translatedJson = File.ReadAllText(path); - AlmanacPlantBank.PlantData originalPlantData = JsonUtility.FromJson(originalJson); - AlmanacPlantBank.PlantData translatedPlantData = JsonUtility.FromJson(translatedJson); - - for (int i = 0; i < originalPlantData.plants.Count; i++) - { - var originalPlantInfo = originalPlantData.plants[i]; - AlmanacPlantBank.PlantInfo translatedPlantInfo = null; - - foreach (var info in translatedPlantData.plants) - { - if (info.seedType == originalPlantInfo.seedType) - { - translatedPlantInfo = info; - } - } - - if (translatedPlantInfo != null) - { - var temp = new KeyValuePair(translatedPlantInfo.seedType, translatedPlantInfo.name); - plantIndices.Add(originalPlantInfo.seedType, temp); - } - } - } - } - - public static Dictionary> recipeLinks = new Dictionary>(); - - public static void RegisterRecipeLinks() - { - recipeLinks.Clear(); - - Il2CppSystem.Array mixData = MixData.data.Cast(); - int rows = mixData.GetLength(0); - int columns = mixData.GetLength(1); - - foreach (PlantType plantType in Enum.GetValues(typeof(PlantType))) - { - int seedType = (int)plantType; - - recipeLinks.Add(seedType, new()); - - if (seedType > 0) - { - foreach (PlantType checkType in Enum.GetValues(typeof(PlantType))) - { - if (checkType > 0) - { - int[] checks = [mixData.GetValue(seedType, (int)checkType).Unbox(), mixData.GetValue((int)checkType, seedType).Unbox()]; - - if (checks[0] != 0) - { - recipeLinks[seedType].Add(checks[0]); - } - - if (checks[1] != 0) - { - recipeLinks[seedType].Add(checks[1]); - } - } - } - } - if (recipeLinks[seedType].Count > 0) - { - Log.LogDebug($"Found {recipeLinks[seedType].Count} fusions for {seedType}!"); - } - } - } - - internal static bool TryReplaceTexture2D(Texture2D ogTexture) - { - if (ogTexture != null) - { - if (TextureStore.textureDict.TryGetValue(ogTexture.name, out string texturePath)) - { - try - { - ImageConversion.LoadImage(ogTexture, File.ReadAllBytes(texturePath)); - - Core.Log.LogDebug("OK! Replaced Texture " + ogTexture.name); - - ogTexture.name = "replaced_" + ogTexture.name; - return true; - } - catch (Exception ex) - { - Log.LogError("Failed to replace texture: " + ogTexture.name + " at path: " + texturePath); - Log.LogError(ex.ToString()); - } - } - } - return false; - } - - internal static Texture2D LoadImage(string path) - { - if (!File.Exists(path)) - { - throw new FileNotFoundException($"The image file at path '{path}' does not exist."); - } - - byte[] array = File.ReadAllBytes(path); - Texture2D texture2D = new(2, 2, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None, 1, IntPtr.Zero, null); - ImageConversion.LoadImage(texture2D, array); - return texture2D; - } - - public static Color HexToColor(string hex) - { - - hex = hex.Replace("#", ""); - - float r = int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - float g = int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - float b = int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - - return new Color(r, g, b); - } - - public static void OpenSaveDirectory() - { - string saveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "LanPiaoPiao", "PlantsVsZombiesRH"); - Process.Start("explorer.exe", saveDirectory); - } - - public static void OpenTrello() - { - string website = "https://trello.com/b/DcdT1kUp"; - Process.Start(new ProcessStartInfo(website) { UseShellExecute = true }); - } - - public static string RemoveColorTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - // Remove opening color tags like - string withoutOpenTags = Regex.Replace(text, @"]+>", string.Empty, RegexOptions.IgnoreCase); - // Remove closing color tags like - string withoutCloseTags = Regex.Replace(withoutOpenTags, @"", string.Empty, RegexOptions.IgnoreCase); - return withoutCloseTags; - } - - public static string RemoveSizeTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - string withoutOpenTags = Regex.Replace(text, @"]+>", string.Empty, RegexOptions.IgnoreCase); - string withoutCloseTags = Regex.Replace(withoutOpenTags, @"", string.Empty, RegexOptions.IgnoreCase); - return withoutCloseTags; - } - - public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name) - { - GameObject newObj = new GameObject(name); - newObj.transform.position = originalText.transform.position; - newObj.AddComponent(); - newObj.AddComponent(); - newObj.AddComponent(); - newObj.transform.SetParent(parent); - newObj.transform.localScale = Vector3.one; - - UnityEngine.Object.Destroy(originalText); - return newObj; - } - - public static void ConvertButtonText(Transform original, string name) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Transform transform = original.FindChild(name); - Transform textTransform = transform.FindChild("text"); - string text = textTransform.GetComponent().text; - Color color = textTransform.GetComponent().color; - - TextMeshProUGUI newGoBackText = Utils.ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent(); - newGoBackText.autoSizeTextContainer = true; - newGoBackText.text = StringStore.TranslateText(text, false); - newGoBackText.font = fontAsset; - newGoBackText.color = color; - } - - public static string GetPlantNameFromAlmanac(PlantType thePlantType) - { - string json; - string thePlantName = ""; - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - Log.LogError("Plant name could not be found!"); - thePlantName = ""; - } - else - { - json = File.ReadAllText(path); - AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson(json); - - foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants) - { - if (plantInfo.seedType == (int)thePlantType) - { - thePlantName = plantInfo.name; - } - } - } - - return thePlantName; - } - - public static string GetPlantNameFromAlmanac(string theOriginalPlantName) - { - string originalJson; - string translatedJson; - string thePlantName = ""; - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string dumpDir = GetAssetDir(AssetType.Dumps); - string originalPath = Path.Combine(dumpDir, "LawnStrings.json"); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - if ((!File.Exists(path)) || (!File.Exists(originalPath))) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - Log.LogError("Plant name could not be found!"); - thePlantName = ""; - } - else - { - bool foundPlantName = false; - - originalJson = File.ReadAllText(originalPath); - translatedJson = File.ReadAllText(path); - AlmanacPlantBank.PlantData originalPlantData = JsonUtility.FromJson(originalJson); - AlmanacPlantBank.PlantData translatedPlantData = JsonUtility.FromJson(translatedJson); - - for (int i = 0; i < originalPlantData.plants.Count; i++) - { - AlmanacPlantBank.PlantInfo originalPlantInfo = originalPlantData.plants[i]; - KeyValuePair translatedPlantInfo = plantIndices[originalPlantInfo.seedType]; - - if (originalPlantInfo.name == theOriginalPlantName) - { - thePlantName = translatedPlantInfo.Value; - foundPlantName = true; - } - } - - if (!foundPlantName) - { - Log.LogInfo("Couldn't find plant name!"); - thePlantName = ""; - } - } - - return thePlantName; - } - - public static string GetZombieNameFromAlmanac(ZombieType theZombieType) - { - string json; - string theZombieName = ""; - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); - Log.LogError("Zombie name could not be found!"); - theZombieName = ""; - } - else - { - json = File.ReadAllText(path); - ZombieAlmanacData zombieData = JsonUtility.FromJson(json); - - foreach (ZombieInfo zombieInfo in zombieData.zombies) - { - if ((int)zombieInfo.theZombieType == (int)theZombieType) - { - theZombieName = zombieInfo.name; - } - } - } - - return theZombieName; - } - - - - public static bool CheckForUntranslatedText(string text) - { - Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); - try - { - Match match = regex.Match(text); - return match.Success; - } - catch(Exception e) - { - Log.LogError(e); - } - return false; - } - - -#if MULTI_LANGUAGE - internal static void ChangeLanguage(string language) - { - OldLanguage = Language; - - if (Enum.TryParse(language, out Utils.LanguageEnum lang)) - { - Utils.Language = lang; - } - else - { - // Handle invalid language string - Log.LogError($"Invalid language string: {language}"); - } - - WarningStore.isWarningMessageLoaded = false; - FontStore.Reload(); - StringStore.Reload(); - TextureStore.Reload(); - FileLoader.SaveLanguage(); - RegisterPlantIndices(); - PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings(); - } - #endif - - #if MULTI_LANGUAGE - public static Utils.LanguageEnum OldLanguage; - #endif - - public static Utils.LanguageEnum Language; - - public static string mainCategory = "PvZ_Fusion_Translator"; - - public static bool customTextures => Core.Instance != null && !Core.Instance.configDefaultTextures.Value; - public static bool customAudio => Core.Instance != null && !Core.Instance.configDefaultAudio.Value; - - public enum LanguageEnum - { - // first column - English, - French, - Italian, - German, - Spanish, - Portuguese, - - // second column - Javanese, //Filipino, - Vietnamese, - Indonesian, - Russian, //NOTE: legacy language - Japanese, - Korean, - - // third column - Ukrainian, - // Slovak, - //Polish, - Turkish, - //Arabic, - Romanian, - - LANG_END - } - - public enum ToggleEnum - { - Textures, - Audio, - TOGGLE_END - } - } - -} \ No newline at end of file diff --git a/MelonLoader/AssetStore/AudioStore.cs b/MelonLoader/AssetStore/AudioStore.cs deleted file mode 100644 index d37899e..0000000 --- a/MelonLoader/AssetStore/AudioStore.cs +++ /dev/null @@ -1,179 +0,0 @@ -using HarmonyLib; -using MelonLoader; -using MelonLoader.Utils; -using System.Reflection; -using UnityEngine; - -namespace PvZ_Fusion_Translator.AssetStore -{ - internal class AudioStore - { - public static Dictionary AudioClips = []; - public static Dictionary AudioClipNames = []; - - public static bool LogSounds; - - private static bool overrideEnabled; - private static readonly string customAudioPath = Path.Combine(MelonEnvironment.ModsDirectory, "PvZ_Fusion_Translator", "[Custom Audios]"); - private static readonly string[] allowedExts = [".wav", ".mp3", ".ogg"]; - - #if AUDIO_TESTING - public Canvas Canvas { get; set; } - public RectTransform songRectTransform { get; private set; } - #endif - - public static void Init() - { - LoadAudios(); - } - public static void LoadAudios() - { - if (!Directory.Exists(customAudioPath)) - Directory.CreateDirectory(customAudioPath); - - var category = MelonPreferences.CreateCategory("Audio Replace", ""); - category.CreateEntry("LogSounds", false); - LogSounds = category.GetEntry("LogSounds").Value; - MelonPreferences.Save(); - - string[] audioFiles = Directory.GetFiles(customAudioPath, "*", SearchOption.AllDirectories); - var ovrClip = audioFiles.SingleOrDefault(f => Path.GetFileNameWithoutExtension(f) == "REPLACE_ALL"); - if (ovrClip == null) - { - foreach (string file in audioFiles) - { - if (!allowedExts.Contains(Path.GetExtension(file))) - continue; - - AudioClip clip = AudioImportLib.API.LoadAudioClip(file); - AudioClips.Add(clip.name, clip); - Log.LogInfo("Added Override: " + clip.name); - } - } - else - { - AudioClip clip = AudioImportLib.API.LoadAudioClip(ovrClip); - AudioClips.Add(clip.name, clip); - overrideEnabled = true; - Log.LogInfo("Added Override: " + clip.name); - } - - Type audioSourceType = typeof(AudioSource); - string sourceMethodName = "Play"; - MethodInfo prefixMethod = typeof(AudioStore).GetMethod("AudioPlayPatch", BindingFlags.Static | BindingFlags.Public); - if (prefixMethod == null) - { - Log.LogError($"Couldn't find method named \"AudioPlayPatch\" in type <{typeof(Core)}>."); - return; - } - _ = Core.Instance.HarmonyInstance.Patch(AccessTools.Method(audioSourceType, sourceMethodName), new HarmonyMethod(prefixMethod)); - Core.Instance.HarmonyInstance.Patch(AccessTools.Method(audioSourceType, sourceMethodName, [typeof(ulong)]), new HarmonyMethod(prefixMethod)); - } - - #if AUDIO_TESTING - public static void InitializeCanvas() - { - - Transform canvasTransform; - - if (canvas != null) return; // Prevent duplicate canvas creation - - canvas = new GameObject("AudioSourceCanvas").AddComponent(); - canvas.renderMode = RenderMode.ScreenSpaceOverlay; - - CanvasScaler scaler = canvas.gameObject.AddComponent(); - scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize; - scaler.referenceResolution = new Vector2(1920, 1080); - - canvas.gameObject.AddComponent(); - - // Add a RectTransform for positioning text - GameObject songTextObject = new GameObject("SongText"); - songTextObject.transform.SetParent(canvas.transform); - - songRectTransform = songTextObject.AddComponent(); - songRectTransform.anchorMin = new Vector2(1, 1); // Top-right corner - songRectTransform.anchorMax = new Vector2(1, 1); - songRectTransform.pivot = new Vector2(1, 1); - songRectTransform.anchoredPosition = new Vector2(-20, -20); // Adjust margin - - // Add a TextMeshPro component for the text - var textComponent = songTextObject.AddComponent(); - textComponent.alignment = TextAlignmentOptions.Right; - textComponent.fontSize = 24; - textComponent.color = Color.white; - textComponent.text = "Current Song: None"; // Placeholder - } - - - public static void AudioSources() - { - if (!Directory.Exists(customAudioPath)) - Directory.CreateDirectory(customAudioPath); - string path = Path.Combine(customAudioPath, "audio_source.json"); - if (!File.Exists(path)) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - return; - } - string json; - json = File.ReadAllText(path); - - AudioClipNames = JsonSerializer.Deserialize>(json); - } - - public static (string, string) GetAudioSource(string clipName) - { - if (AudioClipNames.TryGetValue(clipName, out var audioSource)) - { - return audioSource; - } - else - { - return ("Music", "Source Unknown"); - } - } - - - public static void UpdateAudioSourceText(string clipName, string sourceName) - { - if (songRectTransform == null) InitializeCanvas(); - - var textComponent = songRectTransform.GetComponent(); - if (textComponent != null) - { - textComponent.text = $"Current Song: {clipName}\nSource: {sourceName}"; - } - } - #endif - - - public static void AudioPlayPatch(AudioSource __instance) - { - if(Utils.customAudio) - { - if (__instance.clip == null) - return; - - if (Il2CppRhythmGame.RhythmGameManager.Instance != null && __instance.clip.name == "loon") - return; - - if (LogSounds) - MelonLogger.Msg($"Playing \"{__instance.clip.name}\" from object \"{__instance.gameObject.name}\""); - - string audioClipName = overrideEnabled ? "REPLACE_ALL" : __instance.clip.name; - if (AudioClips.TryGetValue(audioClipName, out AudioClip replaceClip)) - { - __instance.pitch = 1; - __instance.clip = replaceClip; - } - - #if AUDIO_TESTING - // Update the displayed audio source - var (name, source) = GetAudioSource(__instance.clip.name); - UpdateAudioSourceText(name, source); - #endif - } - } - } -} diff --git a/MelonLoader/AssetStore/CheckSumStore.cs b/MelonLoader/AssetStore/CheckSumStore.cs deleted file mode 100644 index fc9ce51..0000000 --- a/MelonLoader/AssetStore/CheckSumStore.cs +++ /dev/null @@ -1,858 +0,0 @@ -#if OBFUSCATE -using System.Security.Cryptography; -using System.Text.Encodings.Web; -using System.Text.Json; -using static Newtonsoft.Json.JsonConvert; -using static PvZ_Fusion_Translator.FileLoader; -namespace PvZ_Fusion_Translator.AssetStore -{ - internal class CheckSumStore - { - private static Dictionary modifiedCheckSums = new Dictionary(); - - private static Dictionary checkSums = new Dictionary() - { - #if !RELEASE || RELEASE - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_CloseButton" , "G/++rbb7GMZv51CxHKdVINtAji/x9zyyhlcbCCWyP2s=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_CloseButtonHighlight" , "nNygYVELdiLcY0xbk0I1uX92NRazxns+I1u7p0M/e4w=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundDay" , "pExENxFbAGfBzLByFps1SX9AN1H6cL0QQK0jOFn3qu8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundNight" , "n3LXi5yONzLVTc0eNStQtLdlcEsihCi5iImxbB7rMdY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundNightPool" , "fe6efxJzsAn3i75Wg7WrCyAFVQhMKXnzh+uThkCJXV4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundPool" , "yKlIHtnBPI8tiUnlRCHYcCnqwarpiuzfOj4H3yGn40o=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_GroundRoof" , "cYTj11LkhWuJxO8j4h+s6+AG4JtgfZ2jfL4P/rWzGfc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_Imitater" , "9BD3A5dWXxgklYK4TTQ/G7d8A8OtZHgZrnq3hIrSlDY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexBack" , "KqSOHoWk3g/Vd1vtwL1X5X33ft8TkxHnupydPB/f8lI=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexButton" , "GWE8iGEa9rVJW3TGG0j2la9VwlxrJ/LfnLu0OMKxMZg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_IndexButtonHighlight" , "kbz2ezXWjIGUC7Q0k3cagXMuRLpnU7l4xGiX7WdSMJE=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_PlantCard" , "lLnAYniK6sDgRW62t1Q/GGh9zIWkBOia+oFzntBBjx8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieBack" , "r3fcC00ZRR8vQUTsPRj339mQZi4/pFcL4rewSbRtM7E=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieCard" , "Fp2qKy2IpiEkA1hZrgXgrxyOA6hteIEQ8sqPrOkaaI4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieWindow" , "mRlpQuXwIiUhKwkZXcK8sDZ6aQKnl43Y5Pbw5NMsKmk=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Almanac_ZombieWindow2" , "GPvh5nRvUqJMjRHwhqC4SUUB3BUKfCgTk6AWO8eGq/M=" }, - { "Dumps\\Default Textures [Do Not Remove]\\CursorClick" , "r7q8kCmXo9FHCC00VPswxjsGba2OMpE4UzBByode7KI=" }, - { "Dumps\\Default Textures [Do Not Remove]\\CursorDefault" , "xUv6VFWl/tzVsUa5heAlzlOyFjdzXsX9kT7EobZTIFQ=" }, - { "Dumps\\Default Textures [Do Not Remove]\\garden_new" , "jkDprxF6ApST91S4TzAGyzj2MC9umC8XCaasbstkBt8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\MainMenu" , "e2lbkFcEN6hqwDk3A0SHZJu7PwEcol1u/QZtvpq71gc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\MainMenutravel" , "fvORSzOzZ6sNDHL3qC/eA7tExSe/TsLIBswcuuFgFZ4=" }, - { "Dumps\\Default Textures [Do Not Remove]\\plant" , "ophzSlF5tmOXKn/2lHZUYiE4pMibPTqBvfQMnuBSzb8=" }, - { "Dumps\\Default Textures [Do Not Remove]\\Present" , "YHoZLVSxMkA8c2u2RCP1tJbFFZZxeulpuGTGp7AtpWA=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentOpen" , "TL+KhicnGWIIOcEyMdTErS1SyBO5citeF37g3CxRiuo=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentOpenZ" , "Ij60phw5j3rhjwMyGiVUOuvp0lelEJqtYQHEECc6l14=" }, - { "Dumps\\Default Textures [Do Not Remove]\\PresentZ" , "fZF3EH0YB37P7j1LBJN9jIwniyCy1Oe2Tw2BsSGc4iA=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedBank" , "BjG7XCi4XIPZO+NHAgksjgSUoO3JPJrL7BGFEWNaQ0A=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Background" , "RB2fot78wqAGxeIIBuG8ZEnytADs/yxhdh3Jre74nMo=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button" , "/KtMBXY5AmPsmt98HVMAuoDrocKr7s/+g7/6wfMJIxY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button2" , "JYwHTIvcmX8NS1wxlb7u1nMPG4BRA2mgm6R2IM/9NXk=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button2_Glow" , "NRov8DgO5+9rqTXQASV8izLAp302/o5ufZgVrvb7aig=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button_Disabled" , "nvfQ1CN+p9h1rUqVhOOLAlCmsdehs2qgVz6kmWERGkU=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedChooser_Button_Glow" , "Wg8LhHovWpNtScBLZbhcjgqQcr4C2pehb3QS2bpmO1Y=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedfog" , "SN9MPqY76N6ucf+vzs22J+2Bs23+1Tl56f7GrT3Z9Yc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedlinkage" , "kqQiioaMU/fAv9+eTzdzV7KizreB80Qio2e9cyWtaOY=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedp" , "i7wDlTSmSBueQ2sCWU7usRbfGoncupi6+plQrjv9A8w=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacketSilhouette" , "AVSM7MUReK4oLDUajmkWjQqT577of/ZhaAepDOQk54o=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Larger" , "C7ZuQNW+xi8YNyYtz09aAXOYP/t56u01WwgYo7FT0Tc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Night" , "YVCLQ3WeIUjevo0Wtf2xAOnDGAAzjl44bRHS1T5ProE=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Other" , "kiidD0VdJ/U0xYxtM7f9uvUYsK2VHFIZU3750doVtHc=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SeedPacket_Pool" , "8MQOevWJrWgIsnWhYi2xt61yxoJARcINzSYzRG7yrnM=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seedroof" , "zluDS1sgaJ4iHXt4PfJ3tqi+LVduGKB9+WLdWZZH0ik=" }, - { "Dumps\\Default Textures [Do Not Remove]\\seeds" , "JNHpZfk3qR+yWd4fhWsdNF+JxtfTOjTAKxLs61X0+co=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_almanac_shadow" , "SdZZ5VOq567+489ffjHcTbgWj3KjI01YKZgdUGj9yis=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Flower3" , "kIzmQGfYT3nCObTtM+C6F7WgE8oCj4M+Qq2II0n2IXw=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf1" , "OwGYCIlBbK5j1dZxBjHlPkvswRy+QHgYVXvmOYoMt6E=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf2" , "0ea/nJV5ziIA2Aher2Exfgz6lDuGDjqHf6Ra/bsmMrg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf3" , "nzELmsj1XUXJmOhMLixHLBzW5TGhZCkwoAOaRpRJlYw=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf4" , "pXEZUhFqr2KC1pCQLB6MwwJhBM5ZI2teGOvYPgr011U=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaf5" , "SeX0iGZoN8ZbhKZSkonw9I7MS3lBVHVqzko1hX80LUg=" }, - { "Dumps\\Default Textures [Do Not Remove]\\SelectorScreen_Leaves" , "Fny+WEQ2N1yzFhdAPhR/zoK0P2HY4GDckluVL6u6Kz0=" }, - { "Dumps\\Default Textures [Do Not Remove]\\ShovelBank" , "Pas2yhjcl+HVwsIm68o9PRjAR72y5lTQm85e2vuYgBE=" }, - - // English - { "Localization\\English\\Textures\\Game\\FinalWave" , "0O9Esd6GUDRmYE9NtcuIvmRzZU6RKUeR4U6Xiy5qi6o=" }, - { "Localization\\English\\Textures\\Game\\FlagMeterLevelProgress" , "CzuBH4sm7Nid4zloZF3i0bpNcA9ILPhrmOxVYI4IggA=" }, - { "Localization\\English\\Textures\\Game\\HugeWave" , "n9O7b5CuD9Yu+ccecqsmm4ofp10MAw6eoZmIxnX8WwM=" }, - { "Localization\\English\\Textures\\Game\\StartPlant" , "IIz47Bh/4MjFKaZaHx5PAxz97YukBkSqHv8nnN7tMLM=" }, - { "Localization\\English\\Textures\\Game\\StartReady" , "lhaXbwp0oHTrX1JFyJE8hnabkzj4bgNyWdFDMn32cbo=" }, - { "Localization\\English\\Textures\\Game\\StartSet" , "WPtmG9W8kFZQthgaycm6P17wmnqWW55CnU2JjsOGJkU=" }, - { "Localization\\English\\Textures\\Logo\\标题合集" , "IfcPnZSGmfNl1jdd4RiGaD2o3XHs/K0R7HKKLzcFftE=" }, - { "Localization\\English\\Textures\\Menu\\NewAdv" , "6UYMHlQ5SdT+gX7cJLy0iwyCXdxblrjdNe2l/OCeDcc=" }, - { "Localization\\English\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Adventure_button" , "7PPDxa4AOg4Q/ioviwKYKx2ftu82+zlvJdbeqWlGaBQ=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "+Drt7kOZRfinB9t8BsklSl8Np6NxDPJ21XvYuVoiwbY=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Almanac" , "Th6/Pun/NEn6797dnzdq8XnCqY9/oIORszG6K3xSFbo=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "hp6y9BUvolJ0bQdU1FY1Oyt57fizZFx8Q3zXYR4t/BI=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenges_button" , "LDMp8hCkHDSIrN9F92K93txxjFZ69qKyfG429oRyGfc=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "rSB360yGYMYQyNUJYb2xMCgGmSFAl7plLTr1BDMA8W8=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenge_button" , "0DWLUXJ5RYKci+loCThNfHEpk7tKV08vifffcK8owNg=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "AXW4pkVR9twu7/SJYvqScPeNswIoefGCBJXDf7SsXFA=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Help1" , "bwLeNCc4/VtLyocaVQhB++/7t2l4ngYQg+3r95RSMDs=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Help2" , "B7p5vi9AyiidPL4nvBTVdL+WhUbsKzHEIHyWWAut1KU=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Options1" , "TJEiHNySrGFxBP85FeP3hl4TcLCVjX1VXYt0navnK04=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Options2" , "SehcWmqt2cxQhPlcJqUKGeRyl0VgxGymyrVKLyGH9LA=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Quit1" , "zbJL06XIJDi1PjiR52BZCmNSYaRCWLb13owTgv9hVw0=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Quit2" , "diLLwcdEED5M+H4Y35Rnyu+W+R6FU7qVDs7DteLWFtw=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "9JoXGZoVFEVUJR+s/mEye3rkTIYwGLZCiajp12bAP/g=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "b2xzl7F7FEkFZpxGKwEwasmF5BkxaZJArAhcnPQ+Ng4=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign1" , "RhYg1ymYR4mEqL0do6dIqRxts+BG9GlB4d5dc+gMjsU=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign2" , "aV7MGtWrsnh5O2ikBof66Y4n+w9xhbQbkOObNP2GysY=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "bov/KzSszIVUaDK3x1AFJZU5kbiBArl+tBybTxi7cS4=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_ZenGarden" , "8x4Y+E/DvSPrr1sY1k3trPVtqLrRuUUVWktfLIx5qTI=" }, - { "Localization\\English\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "ldiEJGQVyYvquwZuPy/aYNf+Am24dG6iILuw/1k3dNQ=" }, - { "Localization\\English\\Textures\\Menu\\SZW" , "2FoSx111GS6QF3dQoUlqhsbVbDSB0MrnUFKilgsIyzo=" }, - { "Localization\\English\\Textures\\Menu\\thanks" , "bffGVtPUS70M8mNXyKDE9aU+XqGMLITegGGOaPMVL84=" }, - { "Localization\\English\\Textures\\Menu\\travel" , "vy+5i0dx1+DIECxAsVv/co8gIwM9zk8djIKCHbG9ykI=" }, - { "Localization\\English\\Textures\\Menu\\钥匙经典" , "PAPsrNZRY9UetFgFnEwZKdN1TgNbCrU7ZtaPZVzBxvg=" }, - { "Localization\\English\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\English\\Textures\\Particles\\ExplosionPowie" , "cuikfX+3LOtSw3EPB6DnjANO5bKkoYCMdWSm+StmW70=" }, - { "Localization\\English\\Textures\\Particles\\ExplosionSpudow" , "4pJ/gZsuKRsAbUL1YWsaaJC9NxrzhqUiQe6glK07ydU=" }, - { "Localization\\English\\Textures\\Particles\\guang" , "kh0dcDxOXgh8+Eq1TmKdJug5PdR+nzZrK5iS5Nkw7Gw=" }, - { "Localization\\English\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\English\\Textures\\Particles\\SunExplosionPowie" , "3bSjOYpanuLnsl58oYUzOAXt94nony6Drq8qdpfRSGQ=" }, - - { "Localization\\English\\Strings\\translation_regexs" , "rjxlsJwClOAJERCe9XmYJB1q+TX6h0p5zDHqCyu/9wE=" }, - { "Localization\\English\\Strings\\translation_strings" , "zsQF+z4URSZY7yuqTfuOIdc/sfcq6g1Hi6ZeedfBFS4=" }, - - { "Localization\\English\\Almanac\\LawnStringsTranslate" , "7BFCUmTVKh5MdefAGxiqgbVtWHcyq9Jg/e8jCWcGI2A=" }, - { "Localization\\English\\Almanac\\ZombieStringsTranslate" , "4KU0HKBDqw5VPbvDqzByDS4nGSG0UAHZ6ek7iv0FOUA=" }, - { "Localization\\English\\Almanac\\AchievementsTextTranslate" , "Y0rNgt02JEkiv/jacilOR0NgACVjqyWpQNQrF9t9PIs=" }, - - // French - { "Localization\\French\\Strings\\translation_regexs" , "Pv4R3N7SkRz8Ksp9DkHR+xMn3Tv7+t57FAwEYDveH4U=" }, - { "Localization\\French\\Strings\\translation_strings" , "atzVMZyXEHG93wcM7Uqz0tTHsWK+dxc1csQxLhHF5wA=" }, - - { "Localization\\French\\Textures\\Game\\FinalWave" , "VTTPmIlVoXW7tU/sQyTlZZq2dy3qOlVs7cmPQYd2PMU=" }, - { "Localization\\French\\Textures\\Game\\FlagMeterLevelProgress" , "DVG5/OyuPfwy7dNOE8NCKmqZK0tKpwsr7As0df3c+0Y=" }, - { "Localization\\French\\Textures\\Game\\StartPlant" , "RkTaTLEoVW4TnXBg+UL3YlG+sdqg+WhP934sTpLlzzk=" }, - { "Localization\\French\\Textures\\Game\\StartReady" , "8/MDcBU6dbIHN1vESmyp27QWxIbifrZZn4IDxKldW3c=" }, - { "Localization\\French\\Textures\\Game\\StartSet" , "8+doc0lYZ2a3W3qpbMSeRturIOWpmyhHw9COvM4Ctkk=" }, - { "Localization\\French\\Textures\\Menu\\NewAdv" , "4noYYWThghcWgV9BCO4WJjEGqHg+SblIoCoCKgTXdAo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Adventure_button" , "ZRxJ77hv8I2NmSiK6LTDgnOG9obBh+ueMa3R/NDCd5I=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "MoCVUnQ+U8HdUtA4haA7Cx3CmlC/hvVuvYc9bakMtW0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Almanac" , "8txwE7D0UbRCH0hzukyZBACcCn1f9yiXLvhzBIkfKCg=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "WoiG0xkTP5oLEYBWOwnf+kkvbY3jD/xTVYgjBQ6/RLQ=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenges_button" , "3NEwHpNoT1jEl+4gDpOYQ/9osW9rvdfdmiJ0ALIV8Uw=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "RD2hIoFhO7AU6nmtrp5iJwjptYy6ociYKGUJxNsYHd0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenge_button" , "eQO5Wj2FOU2kLRMmI6Hhp3lir/hmYhOGrct5dL6utI0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "3cetfrmDbZHx1uumNbBApG5p8I2T8spnrqVhPqSxkI8=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Help1" , "2yINgPeQqUy6b/mzw/2mFfTxWUlzQrJoYC4Yz/VoGy0=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Help2" , "aaUDGQU1+0ltVD4OF2Luc/6pXK7LZ4B5jL9BtSNRnjo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Options1" , "Lpt1mXltCSkn+9BeMOT+CzTxcQ7cwUtFem+I1tWHdqE=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Options2" , "MNNGXO8AboJJf9tMKXLpIB6j1foAj6bcHopNhHcpRVo=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Quit1" , "6NILc8MqiGcQ3ttSKGfDOEOgvUnIUNO/DWBIeNi4/pM=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Quit2" , "rwTFCgy3kNLCcBM5J6EjguUP4NuvfkDNJjks94eaP/g=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "UYwa4CPhRF8CiWro6Y22GfFQOlk8xCQ6Mldkgk4Jn0c=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "MzBfCyymyT0E4mGUdhps7O6IHJdHtwNtGoi3kRAS8Ok=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign1" , "T2Ci2ItAeYw0hMbOP87XJefKbaye8Fhv5tN4H3V7TFg=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign2" , "KnPecN+vhvShgMagZGtPKPzMLcc+N3Kqsrlt51YiKRU=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "v2L4jFj8hcIeJzle9LA0OLcCKwXXYdPVBucdslPTlF8=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_ZenGarden" , "ngbC53eTpHs9VaU1qViFJeJVCNhoZcvojiFpeqrXjMc=" }, - { "Localization\\French\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "F/nkF7zPU6FyWpOaxMim7/NbS6mH23er3ihfF2tVUSk=" }, - { "Localization\\French\\Textures\\Menu\\SZW" , "Z0uAEbNYk36lyCsPXGXnmjO0L3C1E68aA54stVpbYYs=" }, - { "Localization\\French\\Textures\\Menu\\thanks" , "bzYfnWlAyBzLCflijFAld5m0LBmzDS5vyCbUJs+cn0U=" }, - { "Localization\\French\\Textures\\Menu\\travel" , "Ca4e7HNOAXOUzKQAw+1+H1JRI14D1yLEn5cdXHmFcMo=" }, - { "Localization\\French\\Textures\\Menu\\钥匙经典" , "E+VDMHWhhtf9MwVo8SB9b2eDTE1v3u5Wd5DxoM935fo=" }, - { "Localization\\French\\Textures\\Particles\\Doom" , "q/QV2mCopjFnbwQUUTvoPtcyGV/UAwuxjB9v+GDm3OE=" }, - { "Localization\\French\\Textures\\Particles\\ExplosionPowie" , "mqTy7LXjfh1v7kEtwHzIckWjm/4P97dCs4CbyvzOESU=" }, - { "Localization\\French\\Textures\\Particles\\ExplosionSpudow" , "zFpkHlUNR9jWL/H8FQWy8habmtvu2wtMi/PpClRax2c=" }, - { "Localization\\French\\Textures\\Particles\\Sproing" , "FSStD7Lw1uNrSHqZkZCKrY+hcA6O1DOMKe/6R+jqNdk=" }, - - { "Localization\\French\\Almanac\\LawnStringsTranslate" , "sjZ1qRYGKM3sKMimzIlfmd3e2T5gIV38wy3bU75pLjU=" }, - { "Localization\\French\\Almanac\\ZombieStringsTranslate" , "k6XiNRnACedQuAMhh2CHx9jwMfPEJTbG/UZpubs7EM8=" }, - { "Localization\\French\\Almanac\\AchievementsTextTranslate" , "cFzYB+rYT5//+JpvEHa8Or97RYJZdAI0zK3Pr0Fw9hU=" }, - - // Italian - { "Localization\\Italian\\Strings\\translation_regexs" , "Fr7kZcK4cwoN6WsCARX06Od+PkzCv/FTetj7ME0cIok=" }, - { "Localization\\Italian\\Strings\\translation_strings" , "gXM9MZ66TBCflwXl3hMvH46U70kU2w3i4o0EQAd6Xp8=" }, - - { "Localization\\Italian\\Textures\\Game\\FinalWave" , "J7mSpIXvwo0JbrS8RLLWr8jS5KwRcMoDT6aSIVykhiU=" }, - { "Localization\\Italian\\Textures\\Game\\FlagMeterLevelProgress" , "pwnHiUlgXSYUhEXhBWe1XUeeWfYTb0oTY9/UlerGPuU=" }, - { "Localization\\Italian\\Textures\\Game\\StartPlant" , "6OqWQtc8U0Qm8qyhkdhgOmLhR3yGVnLOFhZ6ZrDIjy4=" }, - { "Localization\\Italian\\Textures\\Game\\StartReady" , "3QPcKBCGX8TLM8xCqCDJqY0uCsRg0vUxGzmTkvfXujM=" }, - { "Localization\\Italian\\Textures\\Game\\StartSet" , "VS5T89S8Do4xqRwxSBt9kjV9o/minfu3M//piKAJVkQ=" }, - { "Localization\\Italian\\Textures\\Menu\\NewAdv" , "UEsXovFnKuglsJ9S59cnJjDnhfDyTAXtLtVEnw9oOD8=" }, - { "Localization\\Italian\\Textures\\Menu\\options_menuback" , "WjWI+u05cf2sNThCp2EaWE58r2HwXRIP1gfwvwNo84k=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "s4XJiAhMaWGMpyzt/fGQG/dESF2XeQQ9x+1FQWyLkiU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "NrVoP4kXJ8zaw9/cdm2oRPo08C3oCa24xCO23d11UBo=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Almanac" , "cOdUtbMj5hqPyHoYfORNboSUikAGyoNtKO7DicYANRI=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "ComYfg7rKwHPcmZENPfQP5T9TFQ0ARRmVye2nGAc+3A=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "DMY8d7mlP2ZmBHZz6BjYM1SEFlkFWp9VuIbB7+bMVwk=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "/OvCfFYFwlvf+DefR1/XYIAQ7djymbF4EK1kiLJzXHU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "0XDQd6EaJkRSnYezFxhMFFAse/i2ZlRVmW+Fn9kSWnY=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "UfKNb+QqlwzBdu1eORqEeDB9lVVKmGMpqRSExUAUAak=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Help1" , "RoyqJT79KbODd3PfK28pDvvnhcps9XVDxNNT1GjXu38=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Help2" , "UQdoBeSlI04NXh+VYjUyN9l3gT5p/CDRAU1jUsFqerU=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Options1" , "3ebMHMsiekRjU3Rnc5t+yIkeHNpyZi8/Oulst4WWacg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Options2" , "PFlm0Sdy/1Kajr32uINpR6i7YXQ54a8dq0+OI0R8zec=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Quit1" , "bPWwEE74Tdb583NcXB8e5W/meXVvmwuWkuajv+/R5Ro=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Quit2" , "vBdX54EEKdZkJgiFcCQPtzRPoj0NSKTq7UA7rWDSTBg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "ZPkJ309XC1P5w3x4IPhItEeLd5WVlU0mIaBoHX3b5Bg=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "8VuUajuH7+8MJqROk/3XFQOEx541qi89ykuQCNaJ+L0=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "1tP+grtgWPu5HtvUa2ox+9assN+Wgj63wBkJoskr6K8=" }, - { "Localization\\Italian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "sZuiY1fbj5mg0TXaMok/qJFwoYf3+OxkN+Bk3pbTjs8=" }, - { "Localization\\Italian\\Textures\\Menu\\SZW" , "6cXREWl13sjqgdz3Zf5kT1N7bCoIc7LyrHg3WNMVTyE=" }, - { "Localization\\Italian\\Textures\\Menu\\thanks" , "I2nKJztoIdeVy/CyGYN/r/DB+Gvv3geaFxOdtMdf3ao=" }, - { "Localization\\Italian\\Textures\\Particles\\Doom" , "8E+/HlnnJa52eoBgLYjMyjBCsb5bhc/rTnsJKs2hucA=" }, - { "Localization\\Italian\\Textures\\Particles\\ExplosionPowie" , "u2bgHV+XPb4gSz8CagwJdbKWszej9uoIcbM1Z5GRto8=" }, - { "Localization\\Italian\\Textures\\Particles\\ExplosionSpudow" , "CciMCMupOdEov98dK59e2wF2izCwW8jpBkwQE/EV/JY=" }, - { "Localization\\Italian\\Textures\\Particles\\Sproing" , "nYlKAmcK0rADsk4KS7FaQ3FZBfl+IGQuXb7O1GCML6Y=" }, - - { "Localization\\Italian\\Almanac\\LawnStringsTranslate" , "npd2sE+VJ46XdwqP4cx+Jg7/mgxFiUUgpxEKxDrBUKk=" }, - { "Localization\\Italian\\Almanac\\ZombieStringsTranslate" , "GEhXXOMNHS12b+dR5Q6cxYrORjjyywpkPEKB3QzCn+I=" }, - { "Localization\\Italian\\Almanac\\AchievementsTextTranslate" , "Z4YUscuIUlrlLiaYWHTEvNjztVt291fLjJjkfc/lYBE=" }, - - // German - { "Localization\\German\\Strings\\translation_regexs" , "v3wwSqcUG/g71BrZXhYkpxDYebHeO52n1I8QjjlOuUw=" }, - { "Localization\\German\\Strings\\translation_strings" , "LGDwWtGeEnEvv31TnvXdkVUEs5od34WPNQ0od7WKy60=" }, - - { "Localization\\German\\Textures\\Game\\FinalWave" , "+MHS0Xz4nzGw+0knMtj5vJYSxaaT0KH/g8DWXUOv788=" }, - { "Localization\\German\\Textures\\Game\\FlagMeterLevelProgress" , "M0XScRnevh24JLXF48cG2GecSHlbP4vGUerW0xk63OA=" }, - { "Localization\\German\\Textures\\Game\\StartPlant" , "ab42rVDpP/bDtBjg9LvrfVmEf3E2Bry1pwOnMo8vF+A=" }, - { "Localization\\German\\Textures\\Game\\StartReady" , "7vV3VLAlAKbjXTBzaxlN+ulcOimET/gMvohDzyjFXoI=" }, - { "Localization\\German\\Textures\\Game\\StartSet" , "nNyPtyTiTsCPalXr/MgQob6EEb8kgyPZjMWmbXu3YFw=" }, - { "Localization\\German\\Textures\\Menu\\NewAdv" , "Lx7kxZzwBLios8g7raYwDDPcz2X48SshJaWuklBYUDc=" }, - { "Localization\\German\\Textures\\Menu\\options_menuback" , "WjWI+u05cf2sNThCp2EaWE58r2HwXRIP1gfwvwNo84k=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Adventure_button" , "8NsCGe3aSbZ00AJFlELTtD1hOJlu+RojAAvvD77ICpw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "LcyIKu9BsVtJapQUrpkdefPiA+JTYkak3fg87Tx45JU=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Almanac" , "JrkVQQByD5XSa77HI5+MVGkrc+3nTDyKEP+Kuij6gPo=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "zUlJJqGxLiwafOpBogGO+zX621Q3EnetL+u5vROt6JQ=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenges_button" , "SWZKSjn8ytu5outezry04hHXcTmQD+f6KlWn4nlIZCA=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "9S0JmpQLSGprElTl2MzQoSuT+Eemhj7vaQ20lwi8Ynw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenge_button" , "VRVyZIq8PBKunX8767vh70F/SA85Cifao+kvi7HMIHE=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "WIH6pTlcbWqOMk+H2OYsBft0jVBwYT7hhWiiWaZzT8s=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Help1" , "t9KLP/pCP5dWxWp7nAPjon/4224sE+yY2sX+MhqRJ1Q=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Help2" , "KZ7sZ8Q9Jus9Su3Tu3FLWmWJssq/RPnuOO/eQ7HgaXI=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Options1" , "nqTlln74GhHYs6GKAqcsoS7AzDnOD1jOjvfBBzMOEyo=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Options2" , "xtg2c+bnhPszl8u8BTma6O/xMxiZ/asBAA5jRCbWtek=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Quit1" , "xyxc8phjdNVui7E7RHFSSlu8OGIXw8HW2QpBCrKokmQ=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Quit2" , "PBuRnBbzOk257Jm2i3ISLoz3oeDzy6LNurXaf9LKV2E=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "92BwDgaXMJZXqrcCxdIm8XcZai1NuGH0amcno5E2uU0=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "YzxTyUcR2OvQ1ctFTKq3kd47A0tgiXp/kPQC/hgdom4=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign1" , "T0wrDENK1CD3OgeosDNa4ab28lsSi9JmM7v8wbxB4bs=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign2" , "9SZQ6SvrqFn5kPXbF1JD7F5uMfvGyV0xkar2qCvb2UM=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "jJD+LiAoEzsnPJeUFt2Gpf+e2P8JjKpnfLDDPh6Zcho=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_ZenGarden" , "5Z6wqSVe04hmNHCPdPrDlJrXqgblhY6OG843O19GVmw=" }, - { "Localization\\German\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "z6YuoHbmClwoKeBjsLa0wypSdcB3QrEh2wzzYnDk6Ek=" }, - { "Localization\\German\\Textures\\Menu\\SZW" , "op9D5nHLxn/WZ/TVVaeji8hj9qRQl1DeuHZF/rj/ZMA=" }, - { "Localization\\German\\Textures\\Menu\\thanks" , "myLBgPcIux3cNkPd833r01ZqJsCqBTty31xJE68ZD28=" }, - { "Localization\\German\\Textures\\Menu\\travel" , "ASg2t1qO64hqGJMqDTQ8da8KotTKpkGtzKIaKuO1MqU=" }, - { "Localization\\German\\Textures\\Menu\\钥匙经典" , "KuqwMj6aedb2J7e8rVQpMa5Ie97lAFbGuwGFZq3POJo=" }, - { "Localization\\German\\Textures\\Particles\\Doom" , "rY5dss0ZrDcUHYVTddyesRpU+r0HoF5eiBM4iDMhHhY=" }, - { "Localization\\German\\Textures\\Particles\\ExplosionPowie" , "Gu4iuRPXhL3KAlUjBjbBOpjPthKXlViQ+8lw2sreTNY=" }, - { "Localization\\German\\Textures\\Particles\\ExplosionSpudow" , "z0h6r4O2FdV1r4CbGVd4nmEpGHZeo8dM2wV9suiZq8o=" }, - { "Localization\\German\\Almanac\\AchievementsTextTranslate" , "12tsG4qJrdtX0dxUOa532CyrC+cF403BfFg3fsjRO+I=" }, - { "Localization\\German\\Almanac\\LawnStringsTranslate" , "Vqqn/gcnY7SIPEVbIxSBi6DXSVBwMyVCQvhOs4KCoJQ=" }, - { "Localization\\German\\Almanac\\ZombieStringsTranslate" , "RlBdepGFFohgICk5idOkRFo9t8FxUuiMw4hoo6eYs0Y=" }, - - // Spanish - { "Localization\\Spanish\\Strings\\translation_regexs" , "4QFp251QrntXDcXjGrGYje8gvuKNHAxVp4FfLm0uHI4=" }, - { "Localization\\Spanish\\Strings\\translation_strings" , "BT+eTs1l2eWCDb+5CGgJJmjyAGqTulKOh2VuDIkwxTE=" }, - - { "Localization\\Spanish\\Textures\\Game\\FinalWave" , "fcYpg8VM7fWplgQdj87NOj5jtGgCPzvW4c2fJOUiJIs=" }, - { "Localization\\Spanish\\Textures\\Game\\FlagMeterLevelProgress" , "4MdtfTqEleDpziEenobp9O5cP3L/nZk18gdT9xW2O9c=" }, - { "Localization\\Spanish\\Textures\\Game\\HugeWave" , "n9O7b5CuD9Yu+ccecqsmm4ofp10MAw6eoZmIxnX8WwM=" }, - { "Localization\\Spanish\\Textures\\Game\\StartPlant" , "s7phwlweOMyWGCtCtFoLSMSC/VQSxFPVoB9T+RZQyhk=" }, - { "Localization\\Spanish\\Textures\\Game\\StartReady" , "DRI5gg//9pDb5dOaR0PhlBzuhP2lryhT6aeklSCUTxY=" }, - { "Localization\\Spanish\\Textures\\Game\\StartSet" , "eiX7QvBlF+EcJrXsOxqOkzu0VF/6hb04uNRRHRA/RMA=" }, - { "Localization\\Spanish\\Textures\\Logo\\标题合集" , "zt6CxJgEU+kegWGRKzQKwJynE91Nbpk9hgSby2zHW/o=" }, - { "Localization\\Spanish\\Textures\\Menu\\MainMenu" , "ZTaVNrPrxtSad5bo89RQVNXxaprYLZuGsl6dvuAoJR4=" }, - { "Localization\\Spanish\\Textures\\Menu\\MainMenutravel" , "w7iF3kfdiOg8EdbPKZlfxfObZXSAdqAMzfDMtM+4Dd8=" }, - { "Localization\\Spanish\\Textures\\Menu\\NewAdv" , "itgAdOEzcDj7sUA11u4xX3BwY7vssEdui606FpUUrEk=" }, - { "Localization\\Spanish\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Adventure_button" , "yE5gPHXKy3xnVBFtSTC0zjhfl0tCrc6sHPK8AiiO/s0=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "gwHOCHLV9NAvvChiQt5X95UOLaStVZogt4DWAokvACg=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Almanac" , "xfqV6GfWdsrPhlVIduoQ6x5QWnci7DRO0E8qC6lItDA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "a7NCRdhsKTG4/8CLniWG2j/3MbUh68YmT1QJWAVNCDI=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenges_button" , "LDMp8hCkHDSIrN9F92K93txxjFZ69qKyfG429oRyGfc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "rSB360yGYMYQyNUJYb2xMCgGmSFAl7plLTr1BDMA8W8=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenge_button" , "OT8c2V3GBYxsCMO2nHs7+DbKkdHupmjujVexo/jm1us=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "utQuQr3NQGeGxfmtc3CC7s86/jTGH3SipAkDrAXVbxY=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Help1" , "+W/tytQsNLMSqPE3QnC43MgqBsU0H9XNrjk4RHundLA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Help2" , "WNPFp01iipCzzArymTAcu4VLz5E+Hcm/bnjMZZ0eQ60=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_LevelNumbers" , "ES369OPOoW1RsrCvYQbKaUt0GF3zXXgUd3ZPnjDWXhc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Options1" , "zOkXmvvFsyjLO/nq0Dgl88rTSrJWwBPMp6QiAobyqMw=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Options2" , "MycGypHA2qhq7cgAk97vlPX1gfxmeXoMxQ0FaKwQpkA=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Quit1" , "jtBCpgu/bShFN1ykigQtCjLb+U9aABHugP/8ezHmYxU=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Quit2" , "bbTsQCx08UTWFdM/0csjqYB8rSvCJJm3hZMWSDFmeI4=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Store" , "6gVEuBsk1/udDoEATm2tgmWMCkdme0+oxngcJAKrmP4=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "grdusCpWrRqZfBuNB1Dj7bKFzyQk3xFReAqoAEKYFhY=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "s6uGdZuYk0R0xmSa8KsCsZAziQC3F6AWyZaL+vqPi2Y=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "5iaDwlH8qBI3YyWWjyJ/azvzoOMuThRgYykZeAu55/I=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign1" , "EzxodXEKdnZDB+CRtpfAMzlGaoqBoXhO79UprQAErmw=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign2" , "vibMNgMtv+f43drQs5FWDYv/WaUn6VC3RVZv0qioywc=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "esQplw+1F5GBRJA2KPKbZWTQvPEpQp+d2oyym7Bz2OQ=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_ZenGarden" , "6TrN8Qb2J40RES+YBsBdk9b9A1yy81/+0ZCGSfOqmQM=" }, - { "Localization\\Spanish\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "zr7f1egwQiGj+qJiAM11sWpvRVgGkj1E3q2Tpa6t82Y=" }, - { "Localization\\Spanish\\Textures\\Menu\\SZW" , "zXZkY8n4Xa4BRXd2P7CrPeV/oyoImKa3aHZN0AQxrDA=" }, - { "Localization\\Spanish\\Textures\\Menu\\thanks" , "a38UKni0HkBOxxZOz8YLEuRomcdqRxH+cUxIiZv+57s=" }, - { "Localization\\Spanish\\Textures\\Menu\\travel" , "gyGKFv33M2THt9HsNOGXrzayuTk2O6eW7SpR+gq+6Ac=" }, - { "Localization\\Spanish\\Textures\\Menu\\钥匙经典" , "2x/0/QLjwKGhOFxClKDi+wmB+d0n3/B9Y48pW8Kr/uc=" }, - { "Localization\\Spanish\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - - { "Localization\\Spanish\\Almanac\\LawnStringsTranslate" , "EyMLq+zINvouAEcKNy8fPEu0YIJ98NSLqpMs1NX/U1Y=" }, - { "Localization\\Spanish\\Almanac\\ZombieStringsTranslate" , "tVcpi3GfFH/0aqsaeCuzszFYi6s1IxzO6Zw7wnB0flU=" }, - { "Localization\\Spanish\\Almanac\\AchievementsTextTranslate" , "9PRacAZIbZjZZfc6/qoAggpiW2yZfKjWY7C4im+a2xg=" }, - - // Portuguese - { "Localization\\Portuguese\\Strings\\translation_regexs" , "rzeZrvBSmqIGxLs/jHRAJycnkaoKthMidVOItF2PrbY=" }, - { "Localization\\Portuguese\\Strings\\translation_strings" , "j+vbHq7c9x5Rarc0yFX5eSQmHHtdXsgRqpCxJ9SGKi4=" }, - - { "Localization\\Portuguese\\Textures\\Game\\FinalWave" , "MK0QFrw4Fco5s9xq+8quKs1Li+SinkQuh2OxfZA4gqo=" }, - { "Localization\\Portuguese\\Textures\\Game\\FlagMeterLevelProgress" , "YnkJry/FceiULgkq9RJleesNqgLp/SeKiE5MJA7Kplk=" }, - { "Localization\\Portuguese\\Textures\\Game\\HugeWave" , "jRqYPyzJm7kTbLeaSosHlGLWoUjF1mWqtVNdwtAcvuY=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartPlant" , "7IkydSAOydpjYX1+LSb+Fpt0M0KRmVcwdvjGgXJYMKg=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartReady" , "xoyag2YhVyujDnM/xAq9Xtym8HGKl/h1GCda1mfM3PM=" }, - { "Localization\\Portuguese\\Textures\\Game\\StartSet" , "92OXIRhqJJhmdtb0W/WMNVi1t5hdEzpiwzfX/7p4vRI=" }, - { "Localization\\Portuguese\\Textures\\Logo\\标题合集" , "Ac0MlmlulBOa2w5peHxP7KhJFPAGObirxua3kWLlstY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\MainMenu" , "LNnYLNOJryrvG5XIO+ObgE3Nohxjo9n07UjaGjfVHSQ=" }, - { "Localization\\Portuguese\\Textures\\Menu\\MainMenutravel" , "ZwjI2ybianrOFPEfrLP/38t6y4QB7D6B8hAfr7fvSQ8=" }, - { "Localization\\Portuguese\\Textures\\Menu\\NewAdv" , "gxMOlYYsojAuEQkjdLIM46dkx4ssCH+ncPdK3QBlAFk=" }, - { "Localization\\Portuguese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "6yGbPdJMpbrmHUm9VSCVKHQxJ1sy0YgM42EhxRr1FLQ=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "rdyOJvSoNOHM6uNuL6ehbayGUaOUE/CWs8ZzbzOCafs=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Almanac" , "+5i+4oc5FJDlzzC86ewxR6aaGt2pB6snfvsCpJGL3gw=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "NBmzBkLDe+lMK/wxbV3p2L2hhByBUBP8onsYXO8Pxnk=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "mAy8FXDBpR1tsmwAkNvYB+kg8KKZLxmOtVP3d3DWiJ0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "jbM14CqEIK+GnRKoKUna7P78p4c74g8NNPEbp01f0VY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "TXWmZyG1TjBnem8kcFVv93RfUnYHf8CqV1n5BQyTGLo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "qUrCJfUYlEO32SCoPx89AzteV5hba2xzEjqCcNI2cJo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Flower3" , "KQThbd2XxKVgA/b9DE8RKwYoNRGTCvOOlGfIlmdnNFI=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Help1" , "gJxez2SDkvOvUtS7q3E6xlnQWWWeG28KaXJSG5pqqeg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Help2" , "FHAsPhSc3efXrwoZuiN3APOgXJQNf45znFcaoyZ7ZBE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_LevelNumbers" , "ES369OPOoW1RsrCvYQbKaUt0GF3zXXgUd3ZPnjDWXhc=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Options1" , "FQKd+uBul2bwIcr6nmNq1N3X25C8MRgjyGBy26OuR3g=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Options2" , "xZN/+5sa+0b2eDmS7WV2rw/IV6zglPmF9qan62eJHAg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Quit1" , "dLesJNU0+2/ep6cJnQBA2iUEgIOtve2ozeK9lBher/8=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Quit2" , "hvq+IpGRu+1Kvjz7g8797qjUIkMx8q3qcMyvJDnhMP4=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Store" , "WuaJyUo+GX7vDJ+R+MA6XRKF39j7lNZYOMCy+8wNzYE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "bDeLuhI74R/OTEAAqiIkJJfVyywn4s80lTrgGFNTzLA=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Survival_button" , "mAy8FXDBpR1tsmwAkNvYB+kg8KKZLxmOtVP3d3DWiJ0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "jbM14CqEIK+GnRKoKUna7P78p4c74g8NNPEbp01f0VY=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "1mherm3clK7CvLh9GpVqMII32w+w54mKZE7Z9fkkZZo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "3PVn0DR/33yNI2bjQnDDSSiFRUI+q+1j5lfk/R6JgxI=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "EqYk1lM+BEqgaAqOJXF2HRPkYTgc9j2iMyjcd7/w/Vg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "0iGZDDOUZGqqbMV0CNnjMPVNbNXmvyrJlDIkJ0SV2jE=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "r2YuP2O+mEVhGmapNpFRX8NTx1uY43oaU7kgZyzUhok=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "Ga88gKhsCeLtSoTYheuB6aPx5s34u9SqicGbLI/G6Ng=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "0xCUMxGOkVjkgU+fzmlzzSzC+acBGxKhmMjXT+idOk0=" }, - { "Localization\\Portuguese\\Textures\\Menu\\SZW" , "UVGfrlWecM6jEtNJPqjZ+zI66w3euAdOMNl1EPfKpxo=" }, - { "Localization\\Portuguese\\Textures\\Menu\\thanks" , "eHFnd+JUF/r6YRbpTtjmbs6Pywp92asO6TD/rLmO6Eg=" }, - { "Localization\\Portuguese\\Textures\\Menu\\travel" , "qmw+h5LBEWpIGaSe3HZF0XYUScF2VnGQxKWoD4cR2Pw=" }, - { "Localization\\Portuguese\\Textures\\Menu\\钥匙经典" , "g1DKaF3XxYSuiROmemzDz5C2cUcAQ7jPzuoV+nbC/Tw=" }, - { "Localization\\Portuguese\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\Portuguese\\Textures\\Particles\\ExplosionPowie" , "PHe2TsElYp9UvabT8sxF38JZc+4Hiz78HJyqH/Tzt3M=" }, - { "Localization\\Portuguese\\Textures\\Particles\\ExplosionSpudow" , "Hc/nhkiBIHrZzgdX8+zPYBVoGgNj8177Eqn/S/CvhUs=" }, - { "Localization\\Portuguese\\Textures\\Particles\\guang" , "zpzEG5fPPVYI3tf4DXE0hu3j5BlwIPSAKgcbpr/0wlw=" }, - { "Localization\\Portuguese\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\Portuguese\\Textures\\Particles\\SunExplosionPowie" , "Cx5JShdk8H2FKNujBTOylSR0708YuufHqWUZiV+sG6c=" }, - - { "Localization\\Portuguese\\Almanac\\LawnStringsTranslate" , "WilEedYB6brtG2gExyru8VCIPjYiH8KOvCZ3dXkSaUc=" }, - { "Localization\\Portuguese\\Almanac\\ZombieStringsTranslate" , "ihC0adgxNlZjMrbLFMrYbprM2fY5Po4GfxaGvLJiDaU=" }, - { "Localization\\Portuguese\\Almanac\\AchievementsTextTranslate" , "2gd4zJcz6giTsKjIyjIca3DkWOipeedtbQpX26AJnkE=" }, - - // Javanese - { "Localization\\Javanese\\Strings\\translation_regexs" , "ci3jGT0t5FHqstahiDanSlnoXjHtfNLKD1JV2ZmbARQ=" }, - { "Localization\\Javanese\\Strings\\translation_strings" , "r84OFD0SmodV4abyygiyDmwPcfDZTPPvZ5XA+sYHAIA=" }, - { "Localization\\Javanese\\Textures\\Game\\FinalWave" , "ZuqUOUgNV8tNZ0vzyn0ME2VOYbD1TuksAP900r94QP8=" }, - { "Localization\\Javanese\\Textures\\Game\\FlagMeterLevelProgress" , "bZUyDcbcLtz+uG7pnXncJEgBQn6dkE0HUuO0py5Qqtg=" }, - { "Localization\\Javanese\\Textures\\Game\\HugeWave" , "yNfz9nK3LRYy307H6xe9fbIkBM1WryMNkpUpX/AjaY8=" }, - { "Localization\\Javanese\\Textures\\Game\\StartPlant" , "vx2ZKMq6MPzgi/wQkTCHS3q2MKGfDSV/nR0Y6wcV1RM=" }, - { "Localization\\Javanese\\Textures\\Game\\StartReady" , "U/G1MHSRD5N3XYuLz4aj5DAnj2OSIL7lTLSakoTd8o8=" }, - { "Localization\\Javanese\\Textures\\Game\\StartSet" , "uX5YiWkb7Fh5TmEJAyj5llaUEPIv8HoIgtLhQ4cenMo=" }, - { "Localization\\Javanese\\Textures\\Logo\\标题合集" , "uAh1wGHTmqL+eelty5vhYB6aeXxyt0j4PMXgyDsWg6c=" }, - { "Localization\\Javanese\\Textures\\Menu\\MainMenu" , "OZ1gfSCjvhys6N8eeM0OZKX/z/FDLtX6HW3MA/UqgLs=" }, - { "Localization\\Javanese\\Textures\\Menu\\MainMenutravel" , "V7dmKMS/Ta7LUobEgFudX3hVXCs8GBulEYJUIkvn+do=" }, - { "Localization\\Javanese\\Textures\\Menu\\NewAdv" , "y9AUQwwNxsOnkPM5LY5DT80cQ/X6WmNsGmzzo1VZdyY=" }, - { "Localization\\Javanese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "5nPBRgfdFD0RWQ8j26FXzQBN630hSr+VRyKXr/9ALAM=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "39n+opclWXQEDzKDrsg2r0B5ZtCx7eMcryp13eJvZ1A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Almanac" , "MAucz/pmIdNnun4hLfp0PDrjESlsAZ/iL49NCYl6feQ=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Fea3OWEPntAYCFCP1DK0lrqQByQTQJ7TNWhS1wRfk3I=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "xdoeNs/98lT4BKon8Bcwk7m1S+fGbLeHgZISD9qVt1A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "91z8WbCI7XptpUtaN7mJ1BWz+0JNRMYNbDcoxzb7YhA=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "6W1spOrj4FB/SgOb8851XRMAnXoudOjNyl6z4Egw/rs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "2MhlockgUB7+YVxv096GrbPItf5IVWtuAiv/o65Dx3E=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Help1" , "TrxevH4mjIf4iCFdUXk/Skwq7Asg1dxteTGzqOjQk6o=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Help2" , "s8i2Ca+iB8CGihGdlzqFxZ8PYO7tdm4ODH3GiSqIyMA=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Options1" , "JmwncgGiBynAVjnGkPd0EKXh+MYkUhbpy7H90MYnfTE=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Options2" , "FBzi7WpQje1t1uadDIjcDCwVe994I+ICfmdx96NqrM4=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Quit1" , "N4yS6t5+p52vU93MbHeLgFik9uureOGgJFL8G4FwKho=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Quit2" , "NPtds1JqdvoLtHiAYxzyeM4RyvcrcYLu1HMSnO3252g=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StartAdventure_Button1" , "fIaIRMLy8g56ifWSPZmKH6CCQLia550aovyHGJIRUBQ=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StartAdventure_Highlight" , "n0+5ijqYlRWC/3l2JSqtZPnMDbFp7TLSeZefohaEqg8=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Store" , "6JxQIrwb++ekCR47/hQKyahxmMt0ntFDa8A6qETcs3M=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "8SnyShbhGdphCX4dqfWjuoQIZvlnpDsT7a9mrS6RLEs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Survival_button" , "/mMMNvV2V0X7oSVyKWhLryEO7Bo+eCgDiHozjd4I3/I=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "pNX/YY+qV9RmVt2dcXLTZ+magOEhQNxtxYCUQ4a+S4A=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "IlFeFIlDFW5QAMWwRrgwt9kvStq7pJXNYnWfa3o3zmo=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "aHyZVtF7SxvC8i5Cvj6eARj4+YrB64TZ5njk9whfdgk=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "aJ7MmKsDxiIuExTTP+b26x548jJC9PR2l5An3/Xdlv4=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "5G3x/AWLBZY10RKKdlll4yD9YFzTNqke1GJuTQk0nCo=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "S6vvweA+KTaP0m90S3lu8oitt0/kfc/XasW740bkeGs=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "kgnex+VH/1wjfCM0gLUPRQ16Nb/jeBOBwz7Uz+tBrKU=" }, - { "Localization\\Javanese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "cHufQXgZze8hFwdw5M1gzd/kgtMrFQGIaforUAQeVUk=" }, - { "Localization\\Javanese\\Textures\\Menu\\SZW" , "kJM+ICVWg9rIbVDkhX63KdViIjnVYH4IGC8rqvmnAQI=" }, - { "Localization\\Javanese\\Textures\\Menu\\thanks" , "UPSssI3shIEOMFKQKhRALT2SHpmBTMgHmxpBbRJmPIM=" }, - { "Localization\\Javanese\\Textures\\Menu\\travel" , "s0AOJiMph12ZnPEYyXZ66EbfBHl8xlwhHh70nlW3kkU=" }, - { "Localization\\Javanese\\Textures\\Menu\\钥匙经典" , "5VCHANL1SD1xv+QsPdIDIGeq1Ksw2Q0O9Z5fH1ilCBE=" }, - { "Localization\\Javanese\\Textures\\Particles\\Doom" , "OE2mWsoMv7SEqRWQJWzJ+A/5gQXeRtogIph28cHJyLI=" }, - { "Localization\\Javanese\\Textures\\Particles\\ExplosionPowie" , "P2jrh7tf2d/9EWHoMScwpkpm9ZSvd+ZACEJqSzen7lw=" }, - { "Localization\\Javanese\\Textures\\Particles\\ExplosionSpudow" , "PXVMwcdcn2pL3mN7O3JEMFvI78XGb/POvZ3Sh26bbOw=" }, - { "Localization\\Javanese\\Textures\\Particles\\guang" , "fWG+wb2CZqaSsaLhiscKXHpqWiyG7Z2qXtHhBzumlSU=" }, - { "Localization\\Javanese\\Textures\\Particles\\Sproing" , "+CRy8k+5wzAdG5wVPM3sTYny3hCmPURD42qnTOIv898=" }, - { "Localization\\Javanese\\Textures\\Particles\\SunExplosionPowie" , "ifNQQNn0abUE11stJvwS5wZQm2Y9kPhQx7bXtF0EnCs=" }, - - { "Localization\\Javanese\\Almanac\\LawnStringsTranslate" , "5JgLhxOJA5v4dmZIlUuj5IhDJAijMQov7xNm4mhcKTw=" }, - { "Localization\\Javanese\\Almanac\\ZombieStringsTranslate" , "XpsMKQ0tZON0zeC0NAjZZqC/4SgSBFieYpDBMit2WFo=" }, - { "Localization\\Javanese\\Almanac\\AchievementsTextTranslate" , "g+5/ND/fdGs4fX7mX88GFp1vdI5lAicu4UcOhjLWoO8=" }, - - // Vietnamese - { "Localization\\Vietnamese\\Strings\\translation_regexs" , "jkmDo2/shz/L1entNc/VMTHSwITTe1lDSWkXwu21HY0=" }, - { "Localization\\Vietnamese\\Strings\\translation_strings" , "DEcePF0ruVJLmtTWVL6cgpg6R14ha8loB7E1sEf6r1M=" }, - - { "Localization\\Vietnamese\\Textures\\Game\\FinalWave" , "Ut9Z9amTQgL3Pdcza22zTjKANBKZ9iGQGwuiV9yia90=" }, - { "Localization\\Vietnamese\\Textures\\Game\\FlagMeterLevelProgress" , "4pMjKlDTK/eLQtYWZy1yjgAsDizgOQLZZcA6lYdDbqA=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartPlant" , "Vu7L6nDEl62NmhpQF+79hPc/Os3iJogr1N3DGUPv/Nw=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartReady" , "z3YlFfGkneA4LSSqqtlpnwNLJq3h7gwtl1ZvcxdgUxE=" }, - { "Localization\\Vietnamese\\Textures\\Game\\StartSet" , "snzA81WMzGmssVb862bG95eMRmDGn8t3tBEtj0M/OL4=" }, - { "Localization\\Vietnamese\\Textures\\Logo\\标题合集" , "xqL8p6JTWYSMJmWxxOsA6ToA9bdeA1PrFSWsfarm2uw=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\NewAdv" , "HgyAiO6/YX6jfqzcfW08m/EeXqFRsaGQlIv09U3kHyM=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "vkeO+XAUZURjHfog5dqM2EWmx4Q/Hkgm2lxKWWuEn84=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "bmw+kDo75C0h/xHg7U01xvGQqzjHBjgOvYjuZDLdOU8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Almanac" , "1gsF1/5A/Wwg7X7NmYVvJi3vaavEqbAMDy96vLCElf0=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Euqlx4l5PGWP/VDni40lyo6XONI7UH+jjT9NGbIdaSI=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "anKXed+ijHNf2PnlyRHOdnPNHujFsjwehPuS096dDS8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "Fva/m+l9o97nj/niIO3eXfVP+I9hCK+Mhm0nrB/ZgBw=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "wSZkmGAeFCCEj0US6ZJaJACCwRuj6Tj5JNirlbkmCcc=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "NFH6cDojgh8QeUFF9EMBi+yBVCj2Pi20Up1qQH3EycU=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Help1" , "Y3CrU9B+tdD80MgmCUoWmpvmByahXIvI5tzUjPZZlQ4=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Help2" , "lYbzNUtHudgFvpoEaIQZ420RBmFJmxjrwNmVrq1V1KA=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Options1" , "PmdPi4VkTI/Dlal5s82jQ3xay2F9xA5n5pfcz0ad4bk=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Options2" , "31itkFsIYHeaNMjwiHXiOkeC4pA4onVejVbvMR9dhS4=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Quit1" , "AuhF4Z+C9UE6huKECVBDMRSs1sUEOCsX2yJRPFJ19do=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Quit2" , "JsbRYVZk+KV1870Nt8rlWb6Le2YLKXU8Gc8NXMCfg3o=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "GXlUgJI9mP+YYqwBU/e+0LeFh9VsCgRLepK3yYLd5JA=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "U5t2Fhn17ahAzH7h+nkgpEpEVf7qBBoGfHd3d9tYnVY=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "2xGQ6lS/KxIwjmv3iu5cWBPGucSLBqcT7bdp8KCDC80=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "nMB8AT0nDCBG0aHPxmTKIvVNMvhVm8wli2zU22edZR8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "QhWvlqpFpjF0GYW3LTRaF7hjogvFH0CjtIGZNS1Q0rc=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "2PjsUHvJWhcAdG/Wq6xydshRL0ufXkj61IQ1QBnAcjo=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "xQ3G4RgOY+/pR4ZjmPkY92Ei/qURxbSmXF3dEGpkuYU=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\SZW" , "0Rfvp6ZzoeqC0CN53g7VD1VjqTNY6pRbZyfJhPk16s8=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\thanks" , "9+56vhTLNddtzyzVQfaKvf7pUwBwQQYYleVVh8j2P2Q=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\travel" , "Vz1TbErS6YBlJK3xGVltUi+M2wLINDwv675IfMYK774=" }, - { "Localization\\Vietnamese\\Textures\\Menu\\钥匙经典" , "3vVVP4TSpnN+GhcKIorkVC6NiSXU90gQUhUFkp5JV9k=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\Doom" , "wGdj1YC7DgQ9gO+0qOUM3GvWkZvmSmFcdZPRuC0xWg4=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\ExplosionPowie" , "NLVTBUV+qnJSN8iDyN0/X5mCLuMf/gNf0eqQSNgyR/4=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\ExplosionSpudow" , "87XKk/0oU6tGGyCe1/2KzBHucjYc6fpEl6C5MQGz1bI=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\guang" , "4hMjrrMrOOkLgHlLzuIieJGzwy/SzmY/JI6KDKxA9EU=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\Sproing" , "Kt9TlS9eDVObwbNh9iy00bB5WjXufKPZv7i+mxUG9mw=" }, - { "Localization\\Vietnamese\\Textures\\Particles\\SunExplosionPowie" , "DGdHTnCA+6ovq0sE5TwBEayKAuF5cb+MEOv8xX5hmFU=" }, - - { "Localization\\Vietnamese\\Almanac\\LawnStringsTranslate" , "CM3FWxA/MKhudP9bRjsTNY0ozLJ1K0nOVs/awEvOrnA=" }, - { "Localization\\Vietnamese\\Almanac\\ZombieStringsTranslate" , "yFHjQbsTxaw621AXaHzJLDulElVB1YlKI+nUxvjJuus=" }, - { "Localization\\Vietnamese\\Almanac\\AchievementsTextTranslate" , "Pyeukawk/N5uiUBKDs/erVzIzA+uqZZhtP2amyCKKdY=" }, - - // Indonesian - { "Localization\\Indonesian\\Strings\\translation_regexs" , "4hmtjqn06LLDtClO8mlg13blxXj1hPwWdaSjygj7/2I=" }, - { "Localization\\Indonesian\\Strings\\translation_strings" , "qc4bxqtaJeZBI6nxL4jnf+VpQu/xpJKs/89IYfDcNC8=" }, - { "Localization\\Indonesian\\Textures\\Game\\FinalWave" , "EKjMvK+krWb8AEnvhL02z4ETUR4GEbtEspU8xTL0XJY=" }, - { "Localization\\Indonesian\\Textures\\Game\\FlagMeterLevelProgress" , "bZUyDcbcLtz+uG7pnXncJEgBQn6dkE0HUuO0py5Qqtg=" }, - { "Localization\\Indonesian\\Textures\\Game\\HugeWave" , "kHSyCA4DjKiacui1Z2Vij0VSKr3UqI7FeiZp6MiYeRI=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartPlant" , "lraovY3Nx09xinbn9lF3g5OQPBmBzwkCS9EX3PeKrKA=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartReady" , "WwJG+GIHjqZ/3PWlt7MmATmn8gegir5JdWLHSDOyONk=" }, - { "Localization\\Indonesian\\Textures\\Game\\StartSet" , "wnAy+G4MWwVp11UL9OovumPhS+bFoIw188yt7djqd5o=" }, - { "Localization\\Indonesian\\Textures\\Logo\\标题合集" , "i+dOUq/gv+NF4PbSsElYnsoi8WnrHFgTMCA+lEXwH9E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\FlagMeterLevelProgress" , "CzuBH4sm7Nid4zloZF3i0bpNcA9ILPhrmOxVYI4IggA=" }, - { "Localization\\Indonesian\\Textures\\Menu\\MainMenu" , "OZ1gfSCjvhys6N8eeM0OZKX/z/FDLtX6HW3MA/UqgLs=" }, - { "Localization\\Indonesian\\Textures\\Menu\\MainMenutravel" , "V7dmKMS/Ta7LUobEgFudX3hVXCs8GBulEYJUIkvn+do=" }, - { "Localization\\Indonesian\\Textures\\Menu\\NewAdv" , "y9AUQwwNxsOnkPM5LY5DT80cQ/X6WmNsGmzzo1VZdyY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\options_menuback" , "OGZ6SNFo8RbpPqWaO88qCzPm7r8Mv1WzUee9BlZDwFE=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "IZnCr7uu/muNeugOXMVymHMd5wJ+nfANiohpPnXKleo=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "qiAu0iMOKYUs9XDLgZ7LgVd+KiR0Xn0t0jtVNmjl2Yw=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Almanac" , "MAucz/pmIdNnun4hLfp0PDrjESlsAZ/iL49NCYl6feQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "Fea3OWEPntAYCFCP1DK0lrqQByQTQJ7TNWhS1wRfk3I=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "BTltkx67dDWnRIL/TaXUKcUYiQFT01zF0IicWldAV+E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "GCd2qh/rfLbLserDnSzPekRvxIS6W9q+FeNWfkEqTcg=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "6W1spOrj4FB/SgOb8851XRMAnXoudOjNyl6z4Egw/rs=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "2MhlockgUB7+YVxv096GrbPItf5IVWtuAiv/o65Dx3E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Help1" , "F3na7RpFGvO8bF5lvQbvJanJQmUqPEO5+vkKo4Cx220=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Help2" , "imagpCvSovqC6SkeR3BAJqH1u9ssin0C6jwIhx0wGpc=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Options1" , "DMwpZW09/p4CFkgsAqMPExEXzQYOb1TAWKURN4LOYc4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Options2" , "s6wcmSMPErvL/4QuRE7ZYWtCg6Nl6A3FeVL1pK8cOrQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Quit1" , "fNNNbsaNEYP3bl3KwlypWIDZNCpm4wVDYUDsjzBw1zU=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Quit2" , "Qm2506IHHfwXKMkqS3gS39hjjZnV3AP2IHJlOrhYpCI=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Store" , "6gVEuBsk1/udDoEATm2tgmWMCkdme0+oxngcJAKrmP4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "grdusCpWrRqZfBuNB1Dj7bKFzyQk3xFReAqoAEKYFhY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Survival_button" , "0DWLUXJ5RYKci+loCThNfHEpk7tKV08vifffcK8owNg=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Survival_highlight" , "AXW4pkVR9twu7/SJYvqScPeNswIoefGCBJXDf7SsXFA=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "Q24q+w0RftOK+HcQTDvjG5xDpIEYMdecJyGTNGoh9+U=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "S2IYcVmWghuxAVeaV67EnZ1ZjxyLuEmqLRhknUAQ9dQ=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign1" , "aJ7MmKsDxiIuExTTP+b26x548jJC9PR2l5An3/Xdlv4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign2" , "h5NWhUBnM+ro6J6xs7UDPEmT6055qZP49ppF4wIxePw=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "tu3PiZyJK6CcwaV78aQpqXcE5aLaHA9rPpgzMAbcEAk=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "MAMBtit0msOsty3zZ1yczih8NsF+4nA7fw7BkYMjCk0=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "B17BIhLDvt00Opiag4nqg9a6SvClVr3LlCjzMLI00iY=" }, - { "Localization\\Indonesian\\Textures\\Menu\\SZW" , "OWT6LXWuE7Tr3nH6wYMuUfh1+K9y4TRqtb570pm7veU=" }, - { "Localization\\Indonesian\\Textures\\Menu\\thanks" , "APJpvesl3m2b09ru53RG0MJWcbpia+teT/SnPrnO55E=" }, - { "Localization\\Indonesian\\Textures\\Menu\\travel" , "YP1AGn+G7iYrZ5NQy08TbVxMjFfH7HzdyAMJtwEQ5L4=" }, - { "Localization\\Indonesian\\Textures\\Menu\\钥匙经典" , "5VCHANL1SD1xv+QsPdIDIGeq1Ksw2Q0O9Z5fH1ilCBE=" }, - { "Localization\\Indonesian\\Textures\\Particles\\Doom" , "8vtJfi6ngoltUJQbyCLvp0RnoRZbbVN+piV6lwR8KgU=" }, - { "Localization\\Indonesian\\Textures\\Particles\\ExplosionPowie" , "mmL5xtnIBT3ffswqXHMiz0rXmbj85rCmiWGNnzQq1oM=" }, - { "Localization\\Indonesian\\Textures\\Particles\\ExplosionSpudow" , "PXVMwcdcn2pL3mN7O3JEMFvI78XGb/POvZ3Sh26bbOw=" }, - { "Localization\\Indonesian\\Textures\\Particles\\guang" , "fWG+wb2CZqaSsaLhiscKXHpqWiyG7Z2qXtHhBzumlSU=" }, - { "Localization\\Indonesian\\Textures\\Particles\\Sproing" , "+CRy8k+5wzAdG5wVPM3sTYny3hCmPURD42qnTOIv898=" }, - { "Localization\\Indonesian\\Textures\\Particles\\SunExplosionPowie" , "ifNQQNn0abUE11stJvwS5wZQm2Y9kPhQx7bXtF0EnCs=" }, - - { "Localization\\Indonesian\\Almanac\\LawnStringsTranslate" , "E/P7S2V3xWCnG/DZfW8shpV1ieJUvPf07U/TyJ9LPok=" }, - { "Localization\\Indonesian\\Almanac\\ZombieStringsTranslate" , "twHrylFgPp+RBQ6l10+QHIxgs/mI7p8lRC9etNsAKSU=" }, - { "Localization\\Indonesian\\Almanac\\AchievementsTextTranslate" , "eRZlZgKN2EtZV9BWYOPHPZHBuhLiHzYC3f/wDcwFnR4=" }, - - // Russian - { "Localization\\Russian\\Strings\\translation_regexs" , "6ASIdaFZLLTSdckI4evzynZY3CtCfTuG/BS0ENft/9I=" }, - { "Localization\\Russian\\Strings\\translation_strings" , "mRs9Kx+QyCO5PUScMWyr1P1f3cIMscK0pWjVP4iinL8=" }, - - { "Localization\\Russian\\Textures\\Game\\FinalWave" , "IOhfHr8EBtJYfpWWtELBUtmJNoxv1TdBFrhEfFPshVc=" }, - { "Localization\\Russian\\Textures\\Game\\FlagMeterLevelProgress" , "bGKyk8MpfsaYt95/NQ8kboA0Uxt6ay5PoL0l0RHZ/+M=" }, - { "Localization\\Russian\\Textures\\Game\\HugeWave" , "w1dq1brhzL0eGwj9GJS0vQZDgYVbWjDxRBx60xToKBc=" }, - { "Localization\\Russian\\Textures\\Game\\StartPlant" , "PIOtRaWW0ZdFMNBgyA3Ca4H4rMSLMvfXFvaY/ZZ/oEo=" }, - { "Localization\\Russian\\Textures\\Game\\StartReady" , "zUT1GiCxMDAPlxCyuYPmmztGxDCVdtjiB7C2+Qffpkg=" }, - { "Localization\\Russian\\Textures\\Game\\StartSet" , "ut3aHNTGhzVBNlvHTFIuyj+6SED8Pu9rOpIWKI0V8MQ=" }, - { "Localization\\Russian\\Textures\\Logo\\标题合集" , "qocM9muRdJBmjrs9yTHTknMLWX27aPY7AdMMdLIzd7c=" }, - { "Localization\\Russian\\Textures\\Menu\\NewAdv" , "PIDRlOMsgrLxpp51rWt//B2cBdmNKKEYTvuMUN0wFvI=" }, - { "Localization\\Russian\\Textures\\Menu\\options_menuback" , "HZfWszRsYXntilq2RRoQg6cYPNF7Api0ppAHYJ46wy4=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Adventure_button" , "UGbQ44kL1zXnsJcAr4vrZZu0hDSTEbtdKM2shtebg4w=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "drv1AX+e4D/mA+1IqymPQ5RllTfRatuI+a2/2YJD+GE=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Almanac" , "BdotPdigckPxfrORVW5EJucskfLdK06icpH+Q8mS9fs=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "XoTbNX+410xOdf6MX3BZiVlzD3MsWaqpF8KXZyxduXo=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenges_button" , "pcno2qw/DBMHX3VzGUHErYSAiQyGWseDJGjwHWZI//w=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "Bi5w/0q4C9CpWCjZGLLTHQek530srsp0/Kom4W29IG8=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenge_button" , "kfAEG09yl5h6dV0vHmPl6o72+Wu3kzvBXtyw62E1puk=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "VvP4urY9+U0EPEa19fByOzOX4yKuNzD7eLTuxlEBW2M=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Help1" , "jFKhKseKeZ+y1b1lLYBqfsM5GRGv6JVUa+Jo8sb9p0I=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Help2" , "c1xqKGKKyJhznB5vZpT8FkiSD/luKAEOVH7ZSr/rpp8=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Options1" , "BirUdLzY2B3sedbxZ1eqTwSo/l2UW+obPk+oZhhiSUw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Options2" , "SLSw+97otiN10CyE6nX6QqHmiOjQR8aYuBUveZ8Lx9c=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Quit1" , "B5L16JYjqNJSD5pA9vhEq/C4gzFkz7VYnzcORjOytxA=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Quit2" , "+7s74lMPYaJu+U+572MRvmOolp33Q5xmu/TMOmRvlZc=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StartAdventure_Button1" , "f+NFEqcMvJj20nysVA7mlGmFkJZAmmef+Gi8yUvwses=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StartAdventure_Highlight" , "f+NFEqcMvJj20nysVA7mlGmFkJZAmmef+Gi8yUvwses=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Store" , "N+M6I8pUzeEaetRaE1Wjh2j4g7a1uwrBnqR+7zbsxxQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_StoreHighlight" , "QiFOWjJqdoRZMbXfTuKJwTdm5a3E6vm0rGkXwMaMCYs=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "ta02SAcbm7ErKiwz4vpZzrtuptJComb4X2DAwx8GiJw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "28+kPzJUSqm5KKrUlA5GOAy5+q//1bknEniSze/Bb6M=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign1" , "8CV21tQ/HxANofuuTatQO1Ul8zXQYwo1rfzU6iozCiU=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign2" , "bG6o/CpJPm9XBfWq/m3f1cquTAOr5fbwRNtx7XEPcqg=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "v7BbNSzfQIVYLVrYSOIO2i1NbplOiQjYyQcR4rR8OJw=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_ZenGarden" , "WsYKxhTcuqTFT9jbeOne+W3/opToTbzZFnq7uGulJfQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "aGRi1WWchHxPisQdbkX9xmsALia6I1jo8JpysSHb4BQ=" }, - { "Localization\\Russian\\Textures\\Menu\\SZW" , "eaqxoi1/FlIyUCfEpJnFgl1xoSwqP1XRHFIaobQzD1A=" }, - { "Localization\\Russian\\Textures\\Menu\\thanks" , "Juq3A9M9V/jScckNECv+JB2U7W+y6YivxELZV/nN3JE=" }, - { "Localization\\Russian\\Textures\\Menu\\travel" , "8lXVCidvQOeh8y9kG7xN51Ch9VyL8ThZah/OI1RxN6c=" }, - { "Localization\\Russian\\Textures\\Menu\\钥匙经典" , "wwcruWy65C8iXjA+SY1dvx/hrSQ/KvVkX4OOOZ6lS/s=" }, - { "Localization\\Russian\\Textures\\Particles\\Doom" , "OWddkj4pnY9xmSIuQIL0vb6F091j8UY2PEC4tZ6P3p8=" }, - { "Localization\\Russian\\Textures\\Particles\\ExplosionPowie" , "KbPmKOHVvOH9njUEBWb6SJPEdGOLbpAG0CpliNyUefA=" }, - { "Localization\\Russian\\Textures\\Particles\\ExplosionSpudow" , "k1C6TaoPE0ZRw79UAjDwlRaLjf4Q/b2N6JM9SN1I5fc=" }, - { "Localization\\Russian\\Textures\\Particles\\guang" , "+Xd4hpZk2VEhgHr9HATWRhjEbg4WlmXkh5DA+gXevIs=" }, - { "Localization\\Russian\\Textures\\Particles\\Sproing" , "i33iY8w5LR7Kdqf2vVQ7UmE9SrWZ+5AGepTy5QINyHE=" }, - { "Localization\\Russian\\Textures\\Particles\\SunExplosionPowie" , "BCXJtvwnDvIzc7cFnxN3wxR7t2o1rqa6hulW54PJLrc=" }, - - { "Localization\\Russian\\Almanac\\LawnStringsTranslate" , "NwYjBl+2v0brh38S4AJpHHWDK/1hCJ5VVqY+Cf5jYkU=" }, - { "Localization\\Russian\\Almanac\\ZombieStringsTranslate" , "ejVysCnTehbMFkjAXN7n7NqWespRHmv5cXYM0hMlK0U=" }, - { "Localization\\Russian\\Almanac\\AchievementsTextTranslate" , "ST45TjReYXrBOfT3r2YeDakJm1SN/jtH/5z0Qp6Ms4c=" }, - - // Japanese - { "Localization\\Japanese\\Strings\\translation_regexs" , "YXerYuvclj9na6pQOefuVfJVER28OAb2EkG/kMLqrGQ=" }, - { "Localization\\Japanese\\Strings\\translation_strings" , "hXi0RiHTbzptiAHqko0CRwDDWW9zoRSdQpOXpd4U3BI=" }, - - { "Localization\\Japanese\\Textures\\Game\\FinalWave" , "tyOrI4m+7b595JZufjhesTYXqiSWuNg4Dlm0fN/ZzVg=" }, - { "Localization\\Japanese\\Textures\\Game\\FlagMeterLevelProgress" , "J8Gnugo3MCdQCFNaw91nOWKiYEJltD7EpScPvgJjVdQ=" }, - { "Localization\\Japanese\\Textures\\Game\\StartPlant" , "8+rIjUEkUtyYRsu9ZHsM6B26fT87U6BYHtjhef+sZSc=" }, - { "Localization\\Japanese\\Textures\\Game\\StartReady" , "G0wx/YkdgSZju5xUluqrq554u7ywOGxRPjQwfEEHwSo=" }, - { "Localization\\Japanese\\Textures\\Game\\StartSet" , "4jSRsYZN+mA3pMZQtjtxxo7z8PYpjyM4Ja1coeOERmQ=" }, - { "Localization\\Japanese\\Textures\\Menu\\NewAdv" , "9CgysaFPLkL+h3CB5zLiUxj7Z7xSZCTQKFr/pAvjW4I=" }, - { "Localization\\Japanese\\Textures\\Menu\\options_menuback" , "KcUX62UuqoR0UKas1yijEQP56fWbagBIpSwFIr4df+k=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Adventure_button" , "nqJjYCKTGCWuIHwSSRDpsJkPK7quA/4UgfX+EZsadsI=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "/oarc88nswGdHzRI7+ol5XUH8pqEudTJ/l4mtWr6ugw=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Almanac" , "GsHU22IdE1GMx+6eDcJoQ/+LJDJwLG3sovrPion7/68=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "7aHSIocT5JbGVTh7addi0+WrON9G6LPv2xmuDy/tPRg=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenges_button" , "ljfdR00zwozWSwI85JwzGAGQgjXL1sCNpr/+juvcx0M=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "hkii/10+OmfcVLNOB3ATpI5iHpPhw7mgiVRAs+kDsHc=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenge_button" , "tf/14faCSFk7b9vFFn64FAAUpLGZVmfInI4K0Qmx9aM=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "1ZC0zr0P3WkXzKvZ17YwkLID/6YYdTx9PZQimMSos6o=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Help1" , "8OR4iqxkdQ3PsxbobY+JaN/w0lXNc2A+Kbec/VJ/QVY=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Help2" , "i60mg9eK5WzjUA0iZfQtvDWq7HImRV14xNqfLzFmELo=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Options1" , "YJZBgCXj/ZH4F8zPo+t4dAGmGMSiDAcybs2xuu1LTiw=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Options2" , "yIbcIgBPjVP3JKNiF6dBPdJ90Yd+fKC+99KUjTfHOqQ=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Quit1" , "hkDaVb8qUDLKPp1MIyGY6x4teZAVev56kjJ7KihPMss=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Quit2" , "Tx8u8J/YpKF0lEd436EJfOMzXVzSWlsWDHBh5s73MU0=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "hn9D4J0aBhdrM23YNrZJXd2qbQrePLru5gCYBR34xgo=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "+RQ4US+xJ23ieUzvO3sBzHJBEmCz5wZz7Gv6UmFjtdk=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign1" , "78kL8cLZGoQdNcZjPbXFAkhN9A0zyCun8ieAOUvva3k=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign2" , "Fkn7CvIOoeB8QrUUtj2HySgUg5ZR+zvry6jythPN2BY=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "S2xZmAOn82/7uJ0q5Ej4tc59cheMme02Eb/CBjQjULI=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_ZenGarden" , "AE/8V2mkM15VErDDjg0g497fF4S3GYdSDRi9pDq0S+Q=" }, - { "Localization\\Japanese\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "KiN9KORVPhugq/laYeo+78CNeNW3CEVpVmi2J2WTNT8=" }, - { "Localization\\Japanese\\Textures\\Menu\\SZW" , "4jkQn+T+/oceMqVHefAyo7G/8LQ/3jZuF41rnEaFVy8=" }, - { "Localization\\Japanese\\Textures\\Menu\\thanks" , "aoTr0qV9HPJLz4WImY9FpU6mbB6Jy2WfOeXULgDWdlc=" }, - { "Localization\\Japanese\\Textures\\Menu\\travel" , "MwowpcnQ4BXqoE6I8n2iP6ZzmVSMNaUpyBkPIkaI2hE=" }, - { "Localization\\Japanese\\Textures\\Menu\\钥匙经典" , "FeQQRbKmP9uOZ37BtcHNjWH46zSe1tCrexTrnWcKX50=" }, - { "Localization\\Japanese\\Textures\\Particles\\Doom" , "x/jlt63Ryze1+Dhjm9A1M65LkwrpuN0tTwn6wq7OtPg=" }, - { "Localization\\Japanese\\Textures\\Particles\\ExplosionPowie" , "uEPr3YXyamejZGcJ9QYxkQ6GOnqK3Ddv5HsgBJCIyl0=" }, - { "Localization\\Japanese\\Textures\\Particles\\ExplosionSpudow" , "4wZzRVJGrKmZDuJXuA8O/0mvLJS08DrhfWiRk6Arb/M=" }, - { "Localization\\Japanese\\Textures\\Particles\\Sproing" , "pKet1LadsHBdq8mOR3IOtOngBHyfxdFLp2hipu8I4ZU=" }, - - { "Localization\\Japanese\\Almanac\\LawnStringsTranslate" , "D4riwyc3qc5fWLhnspeXCgCip2cb5k1/t0PlEPJ7wdY=" }, - { "Localization\\Japanese\\Almanac\\ZombieStringsTranslate" , "AzhgHGtIesVnO8aGJnpnY/C8+5eua2Z3wN887spfz7U=" }, - { "Localization\\Japanese\\Almanac\\AchievementsTextTranslate" , "PAk0G69Abd/8mqXxsrg1dChYjb3/Hmgp2UD9fqVnqXw=" }, - - // Korean - { "Localization\\Korean\\Strings\\translation_regexs" , "zWV/cHF92F+GrFwlSkGXyep2jqBDG5LAiGwyDtcG2rU=" }, - { "Localization\\Korean\\Strings\\translation_strings" , "qXdtfjxdZcK4Oe6ptsZd3Vg4rIavfM06ZkmMfmR8G1M=" }, - - { "Localization\\Korean\\Textures\\Game\\FinalWave" , "7I9i/6CVcPOhoL2n3/NUNOedbaIyQqlsj5U+jVQauu4=" }, - { "Localization\\Korean\\Textures\\Game\\FlagMeterLevelProgress" , "yMpBQDYecmFimlzSnsO8vdyEPp0Q6O5lAg0DWFS1m6M=" }, - { "Localization\\Korean\\Textures\\Game\\StartPlant" , "yGZNl/ELOvk/XqMp5pIhwrSLkAa/T+2pWcYb/tVC8CY=" }, - { "Localization\\Korean\\Textures\\Game\\StartReady" , "aNTSN8/FwAmu63eHs7wzdoDCnw3h3KWQ4SCiPtBoTdQ=" }, - { "Localization\\Korean\\Textures\\Game\\StartSet" , "PcrGZLSUL2xrPGTMzZJBc/xC05UdlWoCeHP8vNm8BjQ=" }, - { "Localization\\Korean\\Textures\\Menu\\NewAdv" , "LidoBW/vXZhokFRjg8MRy7daY4wehQ9vd3dBLwTsFLU=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Adventure_button" , "XvILct+pOLn9Ke3VvtlZPo4Zpob6wgAaNwb5w1+i3z0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Adventure_highlight" , "WTyEd+cIWl3fBF1guKAQuMvDdMDwFnsgyZXoklVRTdg=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Almanac" , "7DLBjkU41YWjh6up42n+2DU+UU4jzBcuCyIjoIQhK1E=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_AlmanacHighlight" , "1oUnvwRL6Jr+AwwXJKAB/jcmpWl+0UP69js6vIKZ9uY=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenges_button" , "qoPxgGKWuHKCg3pEmvkauWfmXFZWR0spWcoK6AvLysc=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenges_highlight" , "840p+IAAw8KPwkoNmvcWcOWwhpTzTtcLixzWr+MunS0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenge_button" , "FwlC3AOwWWeiqereusDpkRatqnKKN3c/xq5iPAhVo5Q=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Challenge_highlight" , "RZPSyMMXOr7W5aOWcr5xSR9XiANkWWVk6/OUnxxpUpI=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Help1" , "Akybqv0glw81aMYpGoosQ3PR7Ukhq+cD+ZlEUkLC5Yw=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Help2" , "6RZFnrYjpZM932niXc1qmRtAJm97GlDHzh3Q9c1u5b0=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Options1" , "D7hYM4ZPRbA395EUkLhG4jf7lfJqSUalp7oZJQ9/BEs=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Options2" , "1Z3SHvyiFsK7Wy9I2tFONcVYjF50Ho4L2+CbePFqng8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Quit1" , "eD9BNRKQU7qei+eAsCSIidMwvwEhuBLPcpZkb/Q/Ag8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Quit2" , "scNdtWjkMrgtwBdXiS809HfOY+2+ycPqUAgH6RcFOfk=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_Vasebreaker_button" , "QPWZp3PBXeJK8y9Pu7euFoRNVsywdr5tCC6gOsKmlL8=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_vasebreaker_highlight" , "VGJtLoUZ4+EYlQUMHSOAUFYPwFr30w5/NLyl0G4Ba2Q=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign1" , "CPf6iaNv3ftvdOMQwm/gJ8hXE/13KeS+GHzEBl6DrpM=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign2" , "8Lr0ONZOInR+ZHz9ZQHHdr6e4jkARbxkDIm181Q/yWM=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_WoodSign2_press" , "8JALSm+TKjNzIAtOd6DXJjkjc0bqEBXhPqlTO6sKZ0c=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_ZenGarden" , "b8bJJeKpQJhesrxy3c3JconWq1RJkMwkOBOi1JcKkUA=" }, - { "Localization\\Korean\\Textures\\Menu\\SelectorScreen_ZenGardenHighlight" , "CwZAzOBJFFY9AG2tvPN58JggPNNEws9zEbcgMlsWEpc=" }, - { "Localization\\Korean\\Textures\\Menu\\SZW" , "ONrElpWA/7WkJq833t+slKToiieJtZhbz2dv2QSuQB0=" }, - { "Localization\\Korean\\Textures\\Menu\\thanks" , "HYnZf9x5uNG5tu5jga94X9+rILjt40bnKSR1qjkXF8M=" }, - { "Localization\\Korean\\Textures\\Menu\\travel" , "T/ngmCI6ilQ6k/pV2XZloY5OICc0bbKz0iwg/mcXpPw=" }, - { "Localization\\Korean\\Textures\\Menu\\钥匙经典" , "iO5Z+/6R8Pz1GoIh+TX5KWkCFJsOxfYYrMSV//9UJ34=" }, - { "Localization\\Korean\\Textures\\Particles\\Doom" , "FqBUBeIvzyyXL+cqO4Fi6CKI5gZW5QXfHYPTOYoeteM=" }, - { "Localization\\Korean\\Textures\\Particles\\ExplosionPowie" , "cuikfX+3LOtSw3EPB6DnjANO5bKkoYCMdWSm+StmW70=" }, - { "Localization\\Korean\\Textures\\Particles\\ExplosionSpudow" , "4pJ/gZsuKRsAbUL1YWsaaJC9NxrzhqUiQe6glK07ydU=" }, - { "Localization\\Korean\\Textures\\Particles\\guang" , "kh0dcDxOXgh8+Eq1TmKdJug5PdR+nzZrK5iS5Nkw7Gw=" }, - { "Localization\\Korean\\Textures\\Particles\\Sproing" , "WtzrUuUsjp/GmOfoHApij3VLMn+Tr5qUZ6GGqqhUyD0=" }, - { "Localization\\Korean\\Textures\\Particles\\SunExplosionPowie" , "3bSjOYpanuLnsl58oYUzOAXt94nony6Drq8qdpfRSGQ=" }, - - { "Localization\\Korean\\Almanac\\LawnStringsTranslate" , "KRMiSTM91FoCR9sTGJU6hvsh0+sBMyHfqXwTSSea27M=" }, - { "Localization\\Korean\\Almanac\\ZombieStringsTranslate" , "xHI2LAW0JSEZN010GZPhPB60N0Csfbev2Mk5RwWFYyQ=" }, - { "Localization\\Korean\\Almanac\\AchievementsTextTranslate" , "J4/ZjY7vFNvwsMBx5eIwP7syuLD/+D7OaTY+YbUnq6s=" }, - - // Custom Textures - { "[Custom Textures]\\Almanac_GroundDay" , "ruvrVDVaICj+5PzN5FIcLTma+GtTb2AuKkHA42jTVBw=" }, - { "[Custom Textures]\\Almanac_GroundNight" , "uwrsmHM/IFY1n+AkYYmgEhoWRoaefOjP6sQMCWLtJ2s=" }, - { "[Custom Textures]\\Almanac_GroundNightPool" , "MQrZAvJDWs7k0c8cQjeNp5WNfB1Yns54Wqib63Glhsg=" }, - { "[Custom Textures]\\Almanac_GroundPool" , "fgHaxsX/KUXzAuRTLE7itRtmjPJ8YPo01Sy6Y2O5XWU=" }, - { "[Custom Textures]\\Almanac_PlantCard" , "1Spu2IG3EoCLn0MhAwMxydN2E8xcffFVfnKGk0KowLY=" }, - { "[Custom Textures]\\Almanac_ZombieBack" , "PUxcz+EA7ehsPkyA3gsicvaANh+7vX56yKbrCNFd8cI=" }, - { "[Custom Textures]\\Almanac_ZombieCard" , "S3QeUIrxZ3BJiovEyHBz0AYIoVzT2mQ1JA5hN3Ke8B0=" }, - { "[Custom Textures]\\Almanac_ZombieWindow" , "0JHTUpc1HdZ8/s/4NVKnchFmyrUaXgTgv3kUwS18zKo=" }, - { "[Custom Textures]\\Almanac_ZombieWindow2" , "NA9+T0M/4BihrNsGQVQCyxX2IO8xuyIKCm1PT6aB/vc=" }, - { "[Custom Textures]\\CursorClick" , "cELLXJkEQM+ULhcuL3GXdJ6Lw9iJF0grx3NuSfI3iGE=" }, - { "[Custom Textures]\\CursorDefault" , "AfBSPF65+ZXswrGKH5NRB/b5oa4WR5vuIet3xQ9/hqc=" }, - { "[Custom Textures]\\plant" , "JqOyre0JXBHjvWqUafUaBEfym62ZVhte6sP68TDn4xQ=" }, - { "[Custom Textures]\\SeedChooser_Background" , "RBVMr9F/IJiTVV9G9iZyUQguN6c+fQGb1BUoyuAKbyY=" }, - { "[Custom Textures]\\seedfog" , "l4gO/839bvGY3zk1/JPHPrZiD5sqVq0dCnCflUr/ilQ=" }, - { "[Custom Textures]\\seedp" , "amr82tmtplngahLPlu4wdPlq5adTKqUMXZoZ9qJ6u1U=" }, - { "[Custom Textures]\\SeedPacketSilhouette" , "W6vow+euXzdwjAufkJuRtdaIEiEPmbeeOkOHiQBNmHA=" }, - { "[Custom Textures]\\SeedPacket_Larger" , "+TZxcpkpyz49vmlkTAYyohpQuneLwrw1eJdYpbN6wAs=" }, - { "[Custom Textures]\\SeedPacket_Night" , "0pv9hCIOuoj9wfH2FP18kNwLkYUz0wuxVs3zl3OiHC0=" }, - { "[Custom Textures]\\SeedPacket_Other" , "Y/xlegVxGFn6Dt1nsDAEFSnslM3lyQ6WyCSl7RfwA5k=" }, - { "[Custom Textures]\\SeedPacket_Pool" , "4m5EDn8xfUtrZ/qENCISIRbZVQEjgk9UN1//AelB1Tw=" }, - { "[Custom Textures]\\seedroof" , "z9o/8qUJkgtys4WmPRvCt/wJz056+0Fjvfvk6pHwbLo=" }, - - { "Localization\\Spanish\\Textures\\[Custom Textures]\\CursorClick" , "4sKy7/xqFJqS/HVR1jUgMNvcPQdv6argIePfdcRhoIk=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\CursorDefault" , "zuNjht1GXgF/fOKCnW7KnOOaccjHRDB9m6giJvkKz1Q=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\garden_new" , "siziOyP+M2D5mI5ugtsjNI1O+zKcRqlHBDGrnSU1EV4=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\Present" , "glh2PeOuG8W1jQBiX8Xh0/4owPMGxFFXdOIc2siZ8Uo=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentOpen" , "9DQZ4GIEeqoATt6MA55HEvQrBueZ3FN9raMdqOIhOUI=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentOpenZ" , "BORx+RuCJUu8FLzDqdZcBFKFzMDbKB0KDZIkk4SnEmM=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\PresentZ" , "3VQDMgCU5gz1uGzQzRSatXOHd50q9nHozgkicb9wEQU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SeedBank" , "ffJswlQikAaPhUily+jKz59tjUUsysRTyPetub7pVw4=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SeedChooser_Background" , "Z3jzRdTSxhpLU9HqeYhcDz+CfP1SerwzYteBh2gEX8M=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\seeds" , "Yaqa1lY4mMxmksslr1WjcV3vYAwrcLT6AVVHEvHS6Mw=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf1" , "wAoIJKiNxAuEkhFW9QjUAXCbdQmq0Q5DtztG+1VWjig=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf2" , "hRe+ceHzLid2ltXXaJsfLg3YHkb0xSwvgFh62XqUnpg=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf3" , "sU5tHuXpjZGsDd0I5BMPmsHj0W4flayrCEhr36iudp8=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf4" , "UnezQl5tm4gUZ3DwYCzRM85siS2dZWuo0HHx09fc/LU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaf5" , "a73hDOb3r3gZAgpklCB2EkFjUaUbKJBXKhGT3tYosP0=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\SelectorScreen_Leaves" , "ll3lRI+y441evcV9CJoFufhI5VQeC2eIew9AFSW8xEU=" }, - { "Localization\\Spanish\\Textures\\[Custom Textures]\\ShovelBank" , "DUCNzvvDjIp8Kr8Clyx4eWwApiHiD8RmP+W05Mre+fI=" }, - - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundDay" , "HqSlvHQOonZvcid0jFZAj7az/P8uwKXZMT4Ukwyc8j0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundNight" , "qt947+pENaA91x4lYAYsNLcR6Xd6I1vNh/USyk45arw=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundNightPool" , "A92M4I2N2OfpN/y4R40ATVBrI2U+StgZQjIr0iVCEeU=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundPool" , "AmrvO/C5ggUeHr5+WOh16GWJ0jM1nXR+Vj/A87CRZ3U=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_GroundRoof" , "ftdvDcMiDrdIBIoOTcxU6b9qT+GmPEkH2+tG2HA8blk=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "1Spu2IG3EoCLn0MhAwMxydN2E8xcffFVfnKGk0KowLY=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "PUxcz+EA7ehsPkyA3gsicvaANh+7vX56yKbrCNFd8cI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "S3QeUIrxZ3BJiovEyHBz0AYIoVzT2mQ1JA5hN3Ke8B0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "0JHTUpc1HdZ8/s/4NVKnchFmyrUaXgTgv3kUwS18zKo=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "NA9+T0M/4BihrNsGQVQCyxX2IO8xuyIKCm1PT6aB/vc=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\plant" , "Q5VaxJhSrv/z55FH7YmLBovhYV3zLux887J0IdOpwnc=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedChooser_Background" , "jnVWbr791bRlpO5CYQ5ZC2WPH4d7j8O4ODW41hA88nk=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedfog" , "fyjLtioDqCumbQuOl+4jgUYFqK+cATeOzoNl1qgRttI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedp" , "8qE/ZB7wdjFq6bNr6jWeCsVhhUD+JWORmpXryejDmjI=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacketSilhouette" , "W6vow+euXzdwjAufkJuRtdaIEiEPmbeeOkOHiQBNmHA=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "TtCGi5F02Qx/ix9OXY86bMNjHCdch1E7De9wMTp3JIs=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Night" , "3QSOoNwMue9tK30JgCea/K2pGDlDv+Ibhp0NKRoZHN0=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Other" , "7tjrV9SIzPaSEpMspdF7tKANXMu6ggeuj4XSy/UVACM=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "U4zfEwx/0mUqIgUYvuQ10T+tWTqJ54V3RUJiA1+FJts=" }, - { "Localization\\Portuguese\\Textures\\[Custom Textures]\\seedroof" , "1W6A3m32iSQZ5WhJHK11tys1OQOvYLgdNGlUOe7wgnY=" }, - - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_IndexBack" , "S8wmWen4Za178Mkwwu8DJkKvvB2c2CRJbaRjIW/zvhw=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "O2UWyplpXK69pTFXYDSA5KiRyKAZ22LCDN71GIb5ZDg=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "L91uR40W1iPLqBd+ouENStDe9RN+xUOZtbF048MiD1U=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "3QvRtOtCpI6sqh26+Zbr9vTR9RB8oSXy4m7iS2snZUI=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "+LHsQLlwsYWEVS11F+SustquGoxjbGiyrs58XwyeYMw=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "e51IJA1bz9dDEvmXtO6CeL6/M6KMXDvojCbTz2MtnLk=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\garden_new" , "WxH9rTrIHkmQeu0ALKfFuI6JvXo1uKQlwvgIc72+lhI=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\plant" , "ZkLNZASMXf7P0621AH2sFm3rbulCrs7otMLrrxiaqsA=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedBank" , "+5f20e56ArqQ3Mt2BXtpSM2vO7SV+mWOzIBalIEh4Ew=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Background" , "kjv++O/zFxvPVoObxFTLXsH2MIp3zae4UJ8zu8kVOhY=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button" , "9d5FghH0XRShLwjivvcKtVqmlOQLZC/RqfT+Urv8PJo=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button_Disabled" , "iTsQO62+/80kG4jELlTnB/AXA8wvQKnqCgvQS4pDVlY=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedChooser_Button_Glow" , "cFJCF740SGrFKt7c5OOAcRSVdW5ZZ6sBuE+T3JSwgOU=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedfog" , "JFjRJErflXFgxgxXXGHr6fjLaVIpoYSS0hlWa5Fi09c=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedlinkage" , "3IAYdQXkrWvDMBpg5Zw4ZRU39zuY9OAd3lVhwp07aMk=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedp" , "oaPa7rvvRy+pP3yUvA82hSNJ9/LQIZ+RVGPfCYvaLUg=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacketSilhouette" , "ca+mkPyRnAjVIZZRieUCHFV2t3qiJnX2YQnd/z3iTvs=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "mFoaC4FBXiufdw/aG0SCLlxzpE1umDx3robELsUPhi8=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Night" , "KZEvxdx4nQnrYVPv8FY4DbVDAQBCjlllMnxXQHJ1gkE=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Other" , "EP7WPPrYdZvxAhRig/FBJWHEw67amJuOO9JO0Kqzh14=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "8eLUx9OWZORq3ItJcbQltcsyc6oPAW9PThEHoul/LY0=" }, - { "Localization\\Javanese\\Textures\\[Custom Textures]\\seedroof" , "HhNxpjbMgvt2FZdZZ7kfl546x6+5B4B97DgSH80wkMg=" }, - - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_IndexBack" , "DagukR2bViPz88Iu2B5w4QDMs4ykui/BYdk+lyaTK2o=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_PlantCard" , "O2UWyplpXK69pTFXYDSA5KiRyKAZ22LCDN71GIb5ZDg=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieBack" , "L91uR40W1iPLqBd+ouENStDe9RN+xUOZtbF048MiD1U=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieCard" , "3QvRtOtCpI6sqh26+Zbr9vTR9RB8oSXy4m7iS2snZUI=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieWindow" , "+LHsQLlwsYWEVS11F+SustquGoxjbGiyrs58XwyeYMw=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\Almanac_ZombieWindow2" , "e51IJA1bz9dDEvmXtO6CeL6/M6KMXDvojCbTz2MtnLk=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\garden_new" , "WxH9rTrIHkmQeu0ALKfFuI6JvXo1uKQlwvgIc72+lhI=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\plant" , "ZkLNZASMXf7P0621AH2sFm3rbulCrs7otMLrrxiaqsA=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedBank" , "+5f20e56ArqQ3Mt2BXtpSM2vO7SV+mWOzIBalIEh4Ew=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Background" , "kjv++O/zFxvPVoObxFTLXsH2MIp3zae4UJ8zu8kVOhY=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button" , "9d5FghH0XRShLwjivvcKtVqmlOQLZC/RqfT+Urv8PJo=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button_Disabled" , "iTsQO62+/80kG4jELlTnB/AXA8wvQKnqCgvQS4pDVlY=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedChooser_Button_Glow" , "cFJCF740SGrFKt7c5OOAcRSVdW5ZZ6sBuE+T3JSwgOU=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedfog" , "JFjRJErflXFgxgxXXGHr6fjLaVIpoYSS0hlWa5Fi09c=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedlinkage" , "3IAYdQXkrWvDMBpg5Zw4ZRU39zuY9OAd3lVhwp07aMk=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedp" , "oaPa7rvvRy+pP3yUvA82hSNJ9/LQIZ+RVGPfCYvaLUg=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Larger" , "mFoaC4FBXiufdw/aG0SCLlxzpE1umDx3robELsUPhi8=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Night" , "KZEvxdx4nQnrYVPv8FY4DbVDAQBCjlllMnxXQHJ1gkE=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Other" , "EP7WPPrYdZvxAhRig/FBJWHEw67amJuOO9JO0Kqzh14=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\SeedPacket_Pool" , "8eLUx9OWZORq3ItJcbQltcsyc6oPAW9PThEHoul/LY0=" }, - { "Localization\\Indonesian\\Textures\\[Custom Textures]\\seedroof" , "HhNxpjbMgvt2FZdZZ7kfl546x6+5B4B97DgSH80wkMg=" }, - #endif - }; - - static string GetCheckSum(string filename) - { - using (var md5 = SHA256.Create()) - { - byte[] bytes = md5.ComputeHash(File.ReadAllBytes(filename)); - return Convert.ToBase64String(bytes); - } - } - - public static void SaveCheckSum() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string checkSumString = JsonSerializer.Serialize(checkSums, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - File.WriteAllText(Path.Combine(stringDir, "MD5.json"), checkSumString); - } - - public static void SaveModifiedChecksum() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string modifiedCheckSumString = JsonSerializer.Serialize(modifiedCheckSums, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }); - File.WriteAllText(Path.Combine(stringDir, "Modified_MD5.json"), modifiedCheckSumString); - } - - public static bool IsModified(string filepath) - { - string fileName = Path.GetFileNameWithoutExtension(filepath); - string directory = Path.GetDirectoryName(filepath); - string slicedFilePath = directory.Substring(directory.IndexOf("PvZ_Fusion_Translator\\") + "PvZ_Fusion_Translator\\".Length); - string slicedKey = Path.Combine(slicedFilePath, fileName); - - #if DEBUG - if (!checkSums.ContainsKey(slicedKey)) - { - checkSums.Add(slicedKey, GetCheckSum(filepath)); - SaveCheckSum(); - modifiedCheckSums.Add(slicedKey, GetCheckSum(filepath)); - SaveModifiedChecksum(); - } - else - { - if ((checkSums[slicedKey] != GetCheckSum(filepath))) - { - checkSums[slicedKey] = GetCheckSum(filepath); - modifiedCheckSums.Add(slicedKey, GetCheckSum(filepath)); - SaveModifiedChecksum(); - } - } - #elif RELEASE - if (!checkSums.ContainsKey(slicedKey) | (checkSums[slicedKey] != GetCheckSum(filepath))) - { - return true; - } - #endif - return false; - } - - public static void ConvertMD5Json() - { - string stringDir = GetAssetDir(AssetType.Dumps); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - string checksumDumpPath = Path.Combine(stringDir, "MD5.json"); - string checksumConvertPath = Path.Combine(stringDir, "MD5Convert.txt"); - string json = File.ReadAllText(checksumDumpPath); - Dictionary dictionary = DeserializeObject>(json); - - using StreamWriter writer = new StreamWriter(checksumConvertPath); - foreach (var kvp in dictionary) - { - string checksumKey = kvp.Key.Replace("\\", "\\\\"); - writer.WriteLine($"{{ \"{kvp.Key}\" , \"{kvp.Value}\" }},"); - } - - Log.LogDebug($"MD5.json converted to MD5Convert.json at {checksumConvertPath}"); - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/AssetStore/DllStore.cs b/MelonLoader/AssetStore/DllStore.cs deleted file mode 100644 index 663f7ba..0000000 --- a/MelonLoader/AssetStore/DllStore.cs +++ /dev/null @@ -1,115 +0,0 @@ -/*using MelonLoader; -using MelonLoader.Utils; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace PvZ_Fusion_Translator.AssetStore -{ - public static class DllStore - { - public static Dictionary dllData = new Dictionary() - { - { "Blooms_QOL.dll", null }, - { "PvZ_Fusion_Translator.dll", null } - }; - public static bool updateOnClose = false; - - public static void Init(string gameVersion) => TryGetNewDll(gameVersion); - - public static void TryGetNewDll(string gameVersion) - { - bool ableToUpdate = true; - string unableReason = ""; - string getGameVersionRequest = Utils.GetDataFromWeb("https://raw.githubusercontent.com/SillyStar-Github/PvZF-Translation-DLLs/refs/heads/main/CURRENT_GAME_VER").Result; - if(getGameVersionRequest != null) - { - Log.LogDebug($"Requst game version: {getGameVersionRequest} -> {Utils.CalculateGameVersion(getGameVersionRequest)}"); - Log.LogDebug($"This game version: {gameVersion} -> {Utils.CalculateGameVersion(gameVersion)}"); - if (Utils.CalculateGameVersion(getGameVersionRequest) != Utils.CalculateGameVersion(gameVersion)) - { - ableToUpdate = false; - unableReason = "Incorrect game version..."; - } - } - else - { - ableToUpdate = false; - unableReason = "Couldn't get latest game version info..."; - } - - if (ableToUpdate) - { - foreach(var key in dllData.Keys) - { - byte[] newDllRequest = Utils.GetByteDataFromWeb($"https://raw.githubusercontent.com/SillyStar-Github/PvZF-Translation-DLLs/refs/heads/main/{key}").Result; - if(newDllRequest != null) - { - dllData[key] = newDllRequest; - SaveNewDll(key); - } - else - { - Log.LogError($"Couldn't get latest {key} data!"); - } - } - } - else - { - Log.LogError($"Unable to update! {unableReason}"); - } - } - - public static void SaveNewDll(string name) - { - byte[] newDllData = dllData[name]; - if(newDllData != null) - { - string basePath = MelonEnvironment.ModsDirectory; - string toSavePath = Path.Combine(basePath, name + ".update"); - File.WriteAllBytes(toSavePath, newDllData); - } - } - - public static void UpdateNewDll() - { - foreach(var pair in dllData) - { - if(pair.Value != null) - { - updateOnClose = true; - } - } - - if(updateOnClose) - { - int processId = (Process.GetCurrentProcess().Id); - - var assembly = Core.Instance.MelonAssembly.Assembly; - string programName = "PvZ_Fusion_Translator.Resources.ModUpdateUtil.exe"; - - using var exeResourceStream = assembly.GetManifestResourceStream(programName); - string tempPath = Path.Combine(MelonEnvironment.ModsDirectory, "ModUpdateUtil.exe"); - using (var fileStream = File.Create(tempPath)) - { - exeResourceStream.CopyTo(fileStream); - } - - Process.Start(new ProcessStartInfo - { - FileName = tempPath, - Arguments = $"{processId.ToString()} {string.Join(",", dllData.Keys)} \"{MelonEnvironment.ModsDirectory}\"", - UseShellExecute = true - }); - } - else - { - Log.LogError("Cannot update on close! All .dll data is null!"); - } - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/AssetStore/FontStore.cs b/MelonLoader/AssetStore/FontStore.cs deleted file mode 100644 index 48c5af1..0000000 --- a/MelonLoader/AssetStore/FontStore.cs +++ /dev/null @@ -1,150 +0,0 @@ -using Il2CppTMPro; -using MelonLoader; -using System.Reflection; -using UnityEngine; -using UnityEngine.TextCore.Text; - -namespace PvZ_Fusion_Translator.AssetStore -{ - public static class FontStore - { - internal static Dictionary fontAssetDict = []; - internal static Dictionary fontAssetDictSecondary = []; - - internal static void Init() - { - string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]"); - - AssetBundle assetBundle = Utils.GetAssetBundle(Path.Combine(fontsDir, "translation")); - - #if MULTI_LANGUAGE - foreach (string file in assetBundle.GetAllAssetNames()) - { - string fileName = Path.GetFileNameWithoutExtension(file); - - if (!fileName.EndsWith("_almanac") && !fileName.EndsWith("_fallback")) - { - TMP_FontAsset fontAsset = assetBundle.LoadAsset(file); - - fontAssetDict.Add(fileName, fontAsset); - - Log.LogInfo($"Font for language '{fileName}' loaded"); - } - } - - InitFallback(assetBundle); - #else - string defaultFontDir = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", "English.ttf"); - - TMP_FontAsset defaultFont = FontHandler.LoadTMPFont(defaultFontDir, true); - fontAssetDict.Add("English", defaultFont); - #endif - } - - internal static void InitFallback(AssetBundle assetBundle) - { - string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]"); - - foreach (string file in assetBundle.GetAllAssetNames()) - { - string fileName = Path.GetFileNameWithoutExtension(file); - - if (fileName.EndsWith("_almanac") || fileName.EndsWith("_fallback")) - { - TMP_FontAsset fallbackFont = assetBundle.LoadAsset(file); - - string fileNameLanguage = fileName.Replace("_fallback", "").Replace("_almanac", ""); - - Utils.TryAdd(fontAssetDictSecondary, fileName, fallbackFont); - - // Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded"); - } - } - AddFallback(); - } - - public static void AddFallback() - { - foreach (var lang in fontAssetDict.Keys) - { - if (fontAssetDict[lang].fallbackFontAssetTable == null) - { - fontAssetDict[lang].fallbackFontAssetTable = new Il2CppSystem.Collections.Generic.List(); - } - - if (fontAssetDictSecondary.ContainsKey(lang)) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - if (fontAssetDictSecondary.ContainsKey(lang + "_almanac")) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang + "_almanac"]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - if (fontAssetDictSecondary.ContainsKey(lang + "_fallback")) - { - fontAssetDict[lang].fallbackFontAssetTable.Add(fontAssetDictSecondary[lang + "_fallback"]); - Log.LogInfo("Fallback font for language '" + lang + "' added"); - continue; - } - } - } - - #if MULTI_LANGUAGE - public static TMP_FontAsset LoadTMPFont(string language) - { - if (fontAssetDict.TryGetValue(language.ToLower(), out TMP_FontAsset font)) - { - TMP_FontAsset fontAsset = font; - if (fontAsset.fallbackFontAssetTable != null) - { - // Log.LogInfo("Fallback font for language '" + language + "' loaded. The name of the FB Font is" + fontAsset.fallbackFontAssetTable[0].name); - } - return fontAsset; - } - return fontAssetDict.GetValueOrDefault("english"); - } - #else - public static TMP_FontAsset LoadTMPFont() - { - TMP_FontAsset defaultFont = fontAssetDict["English"]; - return defaultFont; - } - #endif - - public static TMP_FontAsset LoadTMPFontAlmanac(string language) - { - if (fontAssetDictSecondary.ContainsKey(language.ToLower())) - { - if (fontAssetDictSecondary.TryGetValue(language.ToLower(), out TMP_FontAsset almanacAsset)) - { - return almanacAsset; - } - } - if (fontAssetDictSecondary.ContainsKey(language.ToLower() + "_almanac")) - { - if (fontAssetDictSecondary.TryGetValue(language.ToLower() + "_almanac", out TMP_FontAsset almanacAsset)) - { - return almanacAsset; - } - } - - return fontAssetDict.GetValueOrDefault("english"); - } - - #if MULTI_LANGUAGE - public static void Reload() - { - // Get the current language - string currentLanguage = Utils.Language.ToString(); - - // Load the font for the current language - _ = LoadTMPFont(currentLanguage); - } - #endif - - } -} diff --git a/MelonLoader/AssetStore/StringStore.cs b/MelonLoader/AssetStore/StringStore.cs deleted file mode 100644 index f3df218..0000000 --- a/MelonLoader/AssetStore/StringStore.cs +++ /dev/null @@ -1,637 +0,0 @@ -using Il2CppTMPro; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.AssetStore -{ - public static class StringStore - { - internal static Dictionary stringsDict = []; - - public static Dictionary translationStringRegex = new(); - - public static Dictionary translationString = new(); - - public static Dictionary customLevelStringRegex = new(); - - public static Dictionary customLevelString = new(); - - public static Dictionary izLevelTipDictionary = new(); - - public static Dictionary izTipCollectionString = new(); - - public static Dictionary fsLevelTipDictionary = new(); - - public static Dictionary fsTipCollectionString = new(); - - public static Dictionary> patchesStore = new() - { - { "Difficulty", new Dictionary - { - { "English" , "Difficulty:" }, - { "French" , "Difficulté:" }, - { "Italian" , "Difficoltà:" }, - { "German" , "Schwierigkeit:" }, - { "Spanish" , "Dificultad:" }, - { "Portuguese" , "Dificuldade:" }, - { "Filipino" , "Ang Hirap:" }, - { "Vietnamese" , "Độ Khó:" }, - { "Indonesian" , "Kesulitan:" }, - { "Russian" , "Сложность:" }, - { "Japanese" , "困難:" }, - { "Korean", "난이도:" }, - { "Javanese" , "Kesulitan:" }, - { "Polish", "Trudność:"}, - { "Hungarian", "Nehézség:"}, - { "Arabic", "صعوبة:"}, - // { "Ukrainian" , "Складність:" }, - // { "Slovak" , "Náročnosť:" }, - } - }, - { "Zombies", new Dictionary - { - { "English" , "Zombies:" }, - { "French" , "Les Zombies:" }, - { "Italian" , "Zombi:" }, - { "German" , "Zombies:" }, - { "Spanish" , "Zombis:" }, - { "Portuguese" , "Zumbis:" }, - { "Filipino" , "Mga Zombie:" }, - { "Vietnamese" , "Thây Ma:" }, - { "Indonesian" , "Zombi:" }, - { "Russian" , "Зомби:" }, - { "Japanese" , "ゾンビ:" }, - { "Korean", "좀비:" }, - { "Javanese" , "Mayit:" }, - { "Polish" , "Zombi:" }, - { "Hungarian" , "Zombik:" }, - { "Arabic" , "الزومبي:" }, - // { "Ukrainian" , "Зомбі:" }, - // { "Slovak" , "Zombíci:"} - } - } - - }; - - internal static void Init() - { - FileLoader.LoadStrings(); - } - - internal static void Reload() - { - translationString.Clear(); - translationStringRegex.Clear(); - customLevelString.Clear(); - customLevelStringRegex.Clear(); - izLevelTipDictionary.Clear(); - izTipCollectionString.Clear(); - fsLevelTipDictionary.Clear(); - fsTipCollectionString.Clear(); - InGameText_Patch.currentText = ""; - Utils.RegisterPlantIndices(); - FileLoader.LoadStrings(); - } - - public static TextMeshPro TranslateText(TextMeshPro originalTMP, bool isLog = false) - { - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - string translatedText = TranslateText(originalTMP.text); - originalTMP.font = fontAsset; - originalTMP.text = translatedText; - - return originalTMP; - } - - public static TextMeshProUGUI TranslateText(TextMeshProUGUI originalTMP, bool isLog = false) - { - /*var frame = new StackTrace().GetFrame(1); - var method = frame.GetMethod(); - var className = method.DeclaringType.Name; - - Console.WriteLine($"tmp pro ugui: {className}.{method.Name}");*/ - - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - string translatedText = TranslateText(originalTMP.text); - originalTMP.font = fontAsset; - originalTMP.text = translatedText; - - return originalTMP; - } - - public static string TranslateText(string originalText, bool isLog = false) - { - string text = DoTranslateText(originalText, false); - string checkText; - #if DEBUG - Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); - Match match = regex.Match(text); - - if(match.Success) - { - // Log.LogDebug("Untranslated String: " + match.Value); - FileLoader.DumpUntranslatedStrings(text); - } - #endif - checkText = text; - - return checkText; - } - - public static string TranslateText(string originalText, string pattern, bool isLog = false) - { - if (TestRegex(originalText, pattern)) - { - if(translationStringRegex.ContainsKey(pattern)) - { - // Extract dynamic parts from the original text - var regex = new Regex(pattern); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = DoTranslateString(groupValue); - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(translationStringRegex[pattern], [.. dynamicParts]); - } - else if(customLevelStringRegex.ContainsKey(pattern)) - { - // Extract dynamic parts from the original text - var regex = new Regex(pattern); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in customLevelStringRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = customLevelString.ContainsKey(groupValue) - ? customLevelString[groupValue] - : groupValue; - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(customLevelStringRegex[pattern], [.. dynamicParts]); - } - else - { - return originalText; - } - } - else - { - if (isLog) - Log.LogDebug($"Text '{originalText}' not translated"); - FileLoader.DumpUntranslatedStrings(originalText); - return originalText; - } - } - - public static string DoTranslateString(string originalText, bool isLog = false) - { - if (string.IsNullOrEmpty(originalText)) - { - if (isLog) - Log.LogError("Text Null or Empty"); - - return string.Empty; - } - - if (translationString.ContainsKey(originalText)) - { - if (isLog) - Log.LogDebug($"Text '{originalText} found in translationString"); - return translationString[originalText]; - } - - if(izTipCollectionString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in izTipCollectionString"); - } - return izTipCollectionString[originalText]; - } - - if(fsTipCollectionString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in fsTipCollectionString"); - } - return fsTipCollectionString[originalText]; - } - - if(customLevelString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in customLevelString"); - } - return customLevelString[originalText]; - } - - if (Utils.plantIndiceString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in plantIndiceString"); - } - return Utils.plantIndiceString[originalText]; - } - - return originalText; - } - - public static string DoTranslateText(string originalText, bool isLog = false) - { - if (string.IsNullOrEmpty(originalText)) - { - if (isLog) - Log.LogError("Text Null or Empty"); - - return string.Empty; - } - - if (!Utils.CheckForUntranslatedText(originalText) && !(originalText).Contains("_")) return originalText; - - if (translationString.ContainsKey(originalText)) - { - if (isLog) - Log.LogDebug($"Text '{originalText} found in translationString"); - return translationString[originalText]; - } - - if(izTipCollectionString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in izTipCollectionString"); - } - return izTipCollectionString[originalText]; - } - - if(fsTipCollectionString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in fsTipCollectionString"); - } - return fsTipCollectionString[originalText]; - } - - if(customLevelString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in customLevelString"); - } - return customLevelString[originalText]; - } - - if (Utils.plantIndiceString.ContainsKey(originalText)) - { - if(isLog) - { - Log.LogDebug($"Text '{originalText}' found in plantIndiceString"); - } - return Utils.plantIndiceString[originalText]; - } - - // Regex-based dynamic translation - foreach (var entry in translationStringRegex) - { - if (TestRegex(originalText, entry.Key)) - { - // Extract dynamic parts from the original text - var regex = new Regex(entry.Key); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = DoTranslateString(groupValue); - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(entry.Value, [.. dynamicParts]); - } - } - - foreach (var entry in customLevelStringRegex) - { - if (TestRegex(originalText, entry.Key)) - { - // Extract dynamic parts from the original text - var regex = new Regex(entry.Key); - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - if (isLog) - Log.LogDebug("Text found in customLevelRegex {0}: {1}", match, groupCount); - - // List to hold formatted dynamic parts - List dynamicParts = []; - - // Loop through each group and determine its translation - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = customLevelString.ContainsKey(groupValue) - ? customLevelString[groupValue] - : groupValue; - dynamicParts.Add(translatedValue); - } - - // Format the output string with dynamic parts - return string.Format(entry.Value, [.. dynamicParts]); - } - } - - if (isLog) - Log.LogDebug($"Text '{originalText}' not translated"); - if(Utils.CheckForUntranslatedText(originalText)) - { - FileLoader.DumpUntranslatedStrings(originalText); - } - return originalText; - } - - public static string TranslateColorText(string originalText, bool isLog = false) - { - string text = TranslateColorSegments(originalText); - string checkText; -#if DEBUG - Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); - Match match = regex.Match(text); - - if (match.Success) - { - // Log.LogDebug("Untranslated String: " + match.Value); - FileLoader.DumpUntranslatedStrings(text); - } -#endif - checkText = text; - - return checkText; - } - - public static string TranslateColorSegments(string input) - { - string result = ""; - string pattern = @"]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+"; - string smallPattern = @"(]+>)(.*?)()"; - MatchCollection matches = Regex.Matches(input, pattern); - - for (int i = 0; i < matches.Count; i++) - { - Match match = matches[i]; - if (Regex.Match(match.Value, smallPattern, RegexOptions.Singleline).Success) - { - result += TranslateColorSegment(match.Value); - } - else - { - result += DoTranslateText(match.Value); - } - } - - return result; - } - - public static string TranslateColorSegment(string input) - { - string result = input; - string pattern = @"(]+>)(.*?)()"; - Match match = Regex.Match(input, pattern, RegexOptions.Singleline); - string translatedText = DoTranslateText(match.Groups[2].Value); - if(Utils.CheckForUntranslatedText(translatedText)) - { - FileLoader.DumpUntranslatedStrings(translatedText); - } - result = match.Groups[1].Value + translatedText + match.Groups[3].Value; - - return result; - } - public static bool TestRegex(string originalText, string pattern, bool singleLine = false) - { - RegexOptions options = (singleLine) ? RegexOptions.None : RegexOptions.Singleline; - return Regex.IsMatch(originalText, pattern, options); - } - - private static TextAlignmentOptions TextAnchorToTMPAlignment(TextAnchor anchor) - { - return anchor switch - { - TextAnchor.UpperLeft => TextAlignmentOptions.TopLeft, - TextAnchor.UpperCenter => TextAlignmentOptions.Top, - TextAnchor.UpperRight => TextAlignmentOptions.TopRight, - TextAnchor.MiddleLeft => TextAlignmentOptions.MidlineLeft, - TextAnchor.MiddleCenter => TextAlignmentOptions.Center, - TextAnchor.MiddleRight => TextAlignmentOptions.MidlineRight, - TextAnchor.LowerLeft => TextAlignmentOptions.BottomLeft, - TextAnchor.LowerCenter => TextAlignmentOptions.Bottom, - TextAnchor.LowerRight => TextAlignmentOptions.BottomRight, - _ => TextAlignmentOptions.Center - }; - } - - public static TextMeshProUGUI ConvertToTextMeshPro(UnityEngine.UI.Text oldText, TMP_FontAsset fontAsset, bool isLog = false) - { - if (oldText == null) - { - Log.LogError("UnityEngine.UI.Text component is null."); - return null; - } - - if (fontAsset == null) - { - Log.LogError("TMP_FontAsset is null. Conversion cannot proceed."); - return null; - } - - // Log.LogInfo($"Converting UnityEngine.UI.Text: {oldText.name}"); - - GameObject textObject = oldText.gameObject; - - // Preserve text content and settings - string originalText = oldText.text; - originalText = TranslateText(originalText, isLog); - TextAnchor alignment = oldText.alignment; - Color color = oldText.color; - - // Remove old Text component - UnityEngine.Object.DestroyImmediate(oldText); - - // Add TextMeshProUGUI component - TextMeshProUGUI newTMP = textObject.AddComponent(); - if (newTMP == null) - { - Log.LogError($"Failed to add TextMeshProUGUI to object: {textObject.name}"); - return null; - } - - // Configure TextMeshProUGUI - newTMP.text = originalText; - newTMP.color = color; - newTMP.alignment = TextAnchorToTMPAlignment(alignment); - newTMP.font = fontAsset; - - // Log.LogInfo($"Successfully converted {textObject.name} to TextMeshProUGUI."); - - return newTMP; - } - - public static void TranslateTextTransform(Transform baseTransform, bool isAutoTextContainer = false, bool isLog = false) - { - if (!baseTransform) return; - - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - - if (fontAsset == null) - { - #if MULTI_LANGUAGE - Log.LogError($"Font for language '{currentLanguage}' not found. Translation aborted."); - #else - Log.LogError("Font not found. Translation aborted."); - #endif - return; - } - - // Local function for processing transforms - void ProcessTextTransform(Transform textTransform) - { - if (!textTransform) return; - - // Handle TextMeshPro components - TextMeshPro textTMP = textTransform.GetComponent(); - if (textTMP) - { - textTMP.text = TranslateText(textTMP.text, isLog); - textTMP.autoSizeTextContainer = isAutoTextContainer; - textTMP.font = fontAsset; - } - - TextMeshProUGUI textTMPUGUI = textTransform.GetComponent(); - if (textTMPUGUI) - { - textTMPUGUI.text = TranslateText(textTMPUGUI.text, isLog); - textTMPUGUI.enableAutoSizing = isAutoTextContainer; - textTMPUGUI.font = fontAsset; - } - - // Handle UnityEngine.UI.Text components - UnityEngine.UI.Text textUI = textTransform.GetComponent(); - if (textUI) - { - ConvertToTextMeshPro(textUI, fontAsset, isLog); - } - } - - // Process specific text paths - ProcessTextTransform(baseTransform.Find("text")); - ProcessTextTransform(baseTransform.Find("text1")); - // ProcessTextTransform(baseTransform.Find("text2")); - - Transform shadowTransform = baseTransform.Find("text/shadow"); - if (shadowTransform) ProcessTextTransform(shadowTransform); - - shadowTransform = baseTransform.Find("text1/shadow"); - if (shadowTransform) ProcessTextTransform(shadowTransform); - - #if TESTING - Transform childTransform = baseTransform.GetChild(0); - if (childTransform) ProcessTextTransform(childTransform); - #endif - } - - public static void TranslateTextUI(TextMeshPro textTMP, bool? isAutoTextContainer = null, bool isLog = false) - { - string currentLanguage = Utils.Language.ToString(); - if (textTMP) - { - textTMP.text = TranslateText(textTMP.text, isLog); - if (isAutoTextContainer!=null) textTMP.autoSizeTextContainer = isAutoTextContainer.Value; - textTMP.font = FontStore.LoadTMPFont(currentLanguage); - } - } - public static void TranslateTextUI(TextMeshProUGUI textTMP, bool? isAutoTextContainer = null, bool isLog = false) - { - string currentLanguage = Utils.Language.ToString(); - if (textTMP) - { - string origText = textTMP.text; - - textTMP.text = TranslateText(origText, isLog) == "" ? origText : TranslateText(origText, isLog); - if (isAutoTextContainer != null) textTMP.autoSizeTextContainer = isAutoTextContainer.Value; - if (origText != textTMP.text) - textTMP.font = FontStore.LoadTMPFont(currentLanguage); - } - } - - public static void TranslateTextUI(TMP_InputField TextInput) - { - string currentLanguage = Utils.Language.ToString(); - if (TextInput) - { - string oriText = TextInput.m_Text; - TextInput.m_Text = TranslateText(oriText); - TextInput.m_OriginalText = TranslateText(oriText); - TextInput.fontAsset = FontStore.LoadTMPFont(currentLanguage); - } - } - - public static void LogAll() - { - Log.LogInfo("Logging all StringStore entries."); - Log.LogInfo("Regex Entries: {0}", translationStringRegex.Count); - Log.LogInfo("String Entries: {0}", translationString.Count); - } - } -} \ No newline at end of file diff --git a/MelonLoader/AssetStore/TextureStore.cs b/MelonLoader/AssetStore/TextureStore.cs deleted file mode 100644 index f5760d5..0000000 --- a/MelonLoader/AssetStore/TextureStore.cs +++ /dev/null @@ -1,67 +0,0 @@ -using MelonLoader; -using System.Collections; -using UnityEngine; - -namespace PvZ_Fusion_Translator.AssetStore -{ - public static class TextureStore - { - internal static Dictionary textureDict = []; - internal static Dictionary spriteDict = []; - - internal static void Init() => FileLoader.LoadTextures(); - - internal static void Reload() - { - textureDict.Clear(); - #if MULTI_LANGUAGE - RestoreTextures(); - #endif - FileLoader.LoadTextures(); - } - - public static IEnumerator ReplaceTexturesCoroutine() - { - while (true) - { - ReplaceTextures(); - yield return new WaitForSeconds(0.5f); // Adjust this interval as needed - } - } - - public static void ReplaceTextures() - { - Texture2D[] textures = Resources.FindObjectsOfTypeAll(); - foreach (Texture2D texture in textures) - { - if (texture.name.StartsWith("replaced_")) - continue; - - Utils.TryReplaceTexture2D(texture); - } - } - - #if MULTI_LANGUAGE - public static void RestoreTextures() - { - Texture2D[] textures = Resources.FindObjectsOfTypeAll(); - foreach (Texture2D texture in textures) - { - if (texture != null) - { - texture.name = texture.name.Replace("replaced_", ""); - } - } - } - #endif - - /*public static void LogAll() - { - Log.LogInfo("Logging all TextureStore entries."); - foreach (KeyValuePair entry in textureDict) - { - Log.LogInfo("TextureDict Entry: " + entry.Key + " | " + entry.Value); - } - }*/ - } -} diff --git a/MelonLoader/AssetStore/WarningStore.cs b/MelonLoader/AssetStore/WarningStore.cs deleted file mode 100644 index 7f753f1..0000000 --- a/MelonLoader/AssetStore/WarningStore.cs +++ /dev/null @@ -1,234 +0,0 @@ -//using System.Runtime.CompilerServices; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using UnityEngine; -//using UnityEngine.TextCore.Text; -//using static MelonLoader.MelonLogger; - -//namespace PvZ_Fusion_Translator.AssetStore -//{ -// public static class WarningStore -// { -// #if MULTI_LANGUAGE -// private static Dictionary warningMessages = new() -// { -// { "English", ("The only valid source of this translation is from this community:\n" + -// "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + -// "Plants Hybrid and superhybrid.online, they stole it.\n" + -// "Stray away from other sources as they may contain viruses.\n" + -// "Please visit our community for future updates.", -// "Okay! Got it.") }, -// { "French", ("La seule source valide pour cette traduction provient de cette\n" + -// "communauté :discord.gg/DPAC5ZVJ8T. Si vous l'avez obtenue \n" + -// "ailleurs, comme Plants Hybrid ou superhybrid.online, ils l'ont volée.\n" + -// "Évitez les autres sources, car elles peuvent contenir des virus.\n" + -// "Veuillez visiter notre communauté pour les mises à jour futures.", -// "D'accord !") }, -// { "Italian", ("L'unica fonte valida di questa traduzione è questa community:\n" + -// "discord.gg/DPAC5ZVJ8T. Se l'hai ottenuta altrove, come \n" + -// "Plants Hybrid e superhybrid.online, l'hanno rubata.\n" + -// "Evita altre fonti, potrebbero contenere virus.\n" + -// "Visita la nostra community per aggiornamenti futuri.", -// "Va bene! Ho capito.") }, -// { "German", ("Die einzige gültige Quelle für diese Übersetzung stammt aus\n" + -// "dieser Community: discord.gg/DPAC5ZVJ8T. Wenn Sie diese \n" + -// "irgendwo anders gefunden haben, z. B. bei Plants Hybrid oder \n" + -// "superhybrid.online, dann haben sie sie gestohlen.\n" + -// "Meiden Sie andere Quellen, da diese Viren enthalten könnten.\n" + -// "Bitte besuchen Sie unsere Community für zukünftige Updates.", -// "Okay, verstanden!") }, -// { "Spanish", ("La única fuente válida de esta traducción proviene de esta\n" + -// "comunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\n" + -// "otro lugar como Plants Hybrid o superhybrid.online, la robaron.\n" + -// "Manténgase alejado de otras fuentes, ya que podrían contener virus.\n" + -// "Por favor, visite nuestra comunidad para futuras actualizaciones.", -// "¡Entendido!") }, -// { "Portuguese", ("O lugar original e seguro dessa tradução vem daqui:\n" + -// "discord.gg/DPAC5ZVJ8T. Se você baixou ela de qualquer \n" + -// "lugar como Plants Hybrid ou superhybrid.online, eles\n" + -// "roubaram. Evite baixar deles, pode conter vírus.\n" + -// "Por favor, visite nossa comunidade para atualizações futuras.", -// "Okay, entendido.") }, -// { "Filipino", ("Ang tanging opisyal na source ng pagsasaling ito ay mula\n" + -// "lamang dito: discord.gg/DPAC5ZVJ8T. Kung nakuha nmo ito kahit \n" + -// "saan pa tulad ng Plants Hybrid at superhybrid.online, ito ay ninakaw. \n" + -// "Lumayo sa ibang source dahil posibleng may kasamang virus.\n" + -// "Paki-bisita ang aming komunidad para sa mga darating na update." , -// "Naiintindihan!") }, -// { "Vietnamese", ("Nguồn duy nhất hợp lệ của bản dịch này là từ cộng\n" + -// "đồng này: discord.gg/DPAC5ZVJ8T. Nếu bạn nhận \n" + -// "được nó ở bất cứ nơi nào khác như Plants Hybrid \n" + -// "hoặc superhybrid.online, họ đã ăn cắp nó.\n" + -// "Tránh xa các nguồn khác vì chúng có thể chứa \n" + -// "virus. Hãy ghé thăm cộng đồng của chúng tôi để \n" + -// "cập nhật trong tương lai.", -// "Đồng ý!") }, -// { "Indonesian", ("Satu-satunya sumber resmi dari terjemahan ini adalah \n" + -// "komunitas kami: discord.gg/DPAC5ZVJ8T. Jika Anda \n" + -// "mendapatkannya dari sumber lain seperti Plants Hybrid \n" + -// "dan superhybrid.online, mereka mencurinya. \n" + -// "Jauhi sumber lain karena mungkin ada virus.\n" + -// "Silakan kunjungi komunitas kami untuk pembaruan berikutnya.", -// "Oke! Mengerti.") }, -// { "Russian", ("Единственный проверенный источник этого перевода —\n" + -// "сообщество discord.gg/DPAC5ZVJ8T.\n" + -// "Или же его замена https://t.me/nekoshkindom\n" + -// "Если вы скачали этот мод где-либо ещё, возможно он содержит вирусы.\n" + -// "Программист перевода: LancerX0.\n" + -// "Переводчик: Nekosha.", "Хорошо!") }, -// { "Japanese", ("この翻訳の唯一の有効なソースは、このコミュニティからです:\n" + -// "discord.gg/DPAC5ZVJ8T.Plants Hybridやsuperhybrid.online、\n" + -// "YoutubeのBlue Flyが作っているもの、他のどこかでこれを入手した場合、\n" + -// "彼らはそれを盗んだことになります。ウイルスが含まれている可能性があるので、\n" + -// "他のソースからは離れてください。今後のアップデートについては、\n私たちのコミュニティをご覧ください。", -// "了解しました!") }, -// { "Korean", ("이 번역은 Bloom(discord.gg/DPAC5ZVJ8T)에서만\n" + -// "제공됩니다. Bloom 디스코드 이외의 다른서드 파티 사이트, \n" + -// "예를 들어 Plants Hybrid 및 superhybrid.online, 또는\n" + -// "유튜브 Blue Fly등에서 제공하는 파일은 무단으로 재배포된 것이며,\n" + -// "이런 사이트들에는 바이러스가 포함되어 있을 가능성이 높습니다. \n향후 업데이트를 위해 저희 디스코드를 방문해 주세요.", -// "확인") }, -// { "Javanese" , ("Sumber mung sing sah kanggo terjemahan iki saka komunitas iki:\n" + -// "discord.gg/DPAC5ZVJ8T. Yen sampeyan nemokake iki ing papan\n" + -// "liya kaya Plants Hybrid lan superhybrid.online, iku dicolong.\n" + -// "Aja nyedhaki sumber liya amarga bisa ngandhut virus. Mangga\n" + -// "ngunjungi komunitas kita kanggo nganyari ing mangsa ngarep.", -// "Oke! Ngertos.") }, -// { "Polish" , ("Jedynym wiarygodnym źródłem tego tłumaczenia jest ta społeczność:\n" + -// "discord.gg/DPAC5ZVJ8T. Jeśli znalazłeś to gdziekolwiek indziej, np. \n" + -// "Plants Hybrid i superhybrid.online, ukradli to.\n" + -// "Omijaj inne źródła, ponieważ mogą zawierać wirusy.\n" + -// "Odwiedź naszą społeczność, aby uzyskać przyszłe aktualizacje.", -// "Okay! Rozumiem.") }, -// { "Hungarian" , ("Ennek a fordításnak az egyetlen érvényes forrása ebből a közösségből származik:\n" + -// "discord.gg/DPAC5ZVJ8T. Ha ezt valahol máshol szerezted, például \n" + -// "Plants Hybrid és superhybrid.online oldalakon, akkor ők lopták.\n" + -// "Kerüld a többi forrást, mert vírusokat tartalmazhatnak.\n" + -// "Kérjük, látogass el közösségünkbe a jövőbeli frissítésekért.", -// "Oké! Értem.") }, -// { "Arabic" , ("The only valid source of this translation is from this community:\n" + -// "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + -// "Plants Hybrid and superhybrid.online, they stole it.\n" + -// "Stray away from other sources as they may contain viruses.\n" + -// "Please visit our community for future updates.", -// "Okay! Got it.") }, -// // { "OTHER" , ("A única fonte válida dessa tradução é desta\ncomunidade: discord.gg/DPAC5ZVJ8T. Se você obteve \nisso em qualquer lugar como Plants Hybrid\ne superhybrid.online,ou Blue Fly do Youtube,\nelses roubaram. Fique longe de sites falsos. Por favor,\nvisite nossa comunidade para futuras atualizações.", "¡Okei! Entendido.") } -// // { "OTHER" , ("Ang translation na ito ay galing dito lamang:\ndiscord.gg/DPAC5ZVJ8T. Pag nakuha niyo ito sa iba pa\nkagaya ng Plants Hybrid o superhybrid.online, anumang\nginawagawa ng Blue Fly mula sa Youtube, o anumang\nSub2Unlock links, scam sila. MAG INGAT dahil\nkasi baka may virus 'jan. Join kayo sa discord namin!\nFilipino Translation by ColinPogi" , "Tayo magsi-laro!") } -// }; -// #else -// public static string warningMessage = "La única fuente válida de esta traducción proviene de esta\ncomunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\notro lugar como Plants Hybrid o superhybrid.online, la robaron.\nManténgase alejado de otras fuentes, ya que podrían contener virus.\nPor favor, visite nuestra comunidad para futuras actualizaciones."; -// public static string okayButton = "¡Entendido!"; -// #endif - -// #if MULTI_LANGUAGE -// public static (string, string) GetWarningMessage(Utils.LanguageEnum language) -// { -// if (warningMessages.TryGetValue(language.ToString(), out var message)) -// { - -// return message; -// } -// else -// { -// return warningMessages["English"]; // Default to English if language code is not found -// } -// } -//#endif - -// public static void WarningLoad(NoticeMenu noticeMenu) -// { -// if (noticeMenu == null || noticeMenu.transform == null) -// { -// MelonLogger.Warning("[WarningStore] NoticeMenu or transform is null - ABORTING"); -// return; -// } - -//#if MULTI_LANGUAGE -// try -// { -// var (warningMessage, okayButton) = GetWarningMessage(Utils.Language); -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// Transform warningTransform = noticeMenu.transform.Find("窗口"); -// if (warningTransform == null) -// { -// MelonLogger.Warning("[WarningStore] '窗口' transform not found - ABORTING"); -// return; -// } - -// Transform warningTextTransform = warningTransform.Find("文字"); -// Transform warningTextShadowTransform = warningTransform.Find("文字2"); - -// if (warningTextTransform == null || warningTextShadowTransform == null) -// { -// MelonLogger.Warning("[WarningStore] Could not find text components (文字/文字2)"); -// return; -// } - -// TextMeshProUGUI warningText = warningTextTransform.GetComponent(); -// TextMeshProUGUI shadowText = warningTextShadowTransform.GetComponent(); - -// if (warningText == null || shadowText == null) -// { -// MelonLogger.Warning("[WarningStore] TextMeshProUGUI components missing"); -// return; -// } - -// warningText.text = warningMessage; -// shadowText.text = warningMessage; - -// if (fontAsset != null) -// { -// warningText.font = fontAsset; -// shadowText.font = fontAsset; -// } -// else -// { -// MelonLogger.Warning("[WarningStore] Font asset is null"); -// } - -// MelonLogger.Msg("Warning message loaded successfully!"); -// } -// catch (Exception e) -// { -// MelonLogger.Error($"Critical error in WarningLoad: {e}"); -// } -//#endif -// } -//#if MULTI_LANGUAGE -// public static bool isWarningMessageLoaded = false; - -// public static void WarningReload(Utils.LanguageEnum language, NoticeMenu noticeMenu) -// { -// if (noticeMenu == null) -// { -// MelonLogger.Warning("[WarningStore] NoticeMenu is null in WarningReload"); -// return; -// } - -// if (Utils.OldLanguage.ToString() == language.ToString() && Utils.OldLanguage.ToString() != "English") -// { -// return; -// } - -// if (!isWarningMessageLoaded) -// { -// WarningLoad(noticeMenu); -// isWarningMessageLoaded = true; -// } -// } -//#else -// public static bool isWarningMessageLoaded = false; - -// public static void WarningReload() -// { -// if (!WarningStore.isWarningMessageLoaded) -// { -// WarningStore.WarningLoad(); -// WarningStore.isWarningMessageLoaded = true; -// } -// } -//#endif -// } -//} \ No newline at end of file diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs deleted file mode 100644 index a93977c..0000000 --- a/MelonLoader/Core.cs +++ /dev/null @@ -1,132 +0,0 @@ -using MelonLoader; -using MelonLoader.Utils; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.Managers; -using PvZ_Fusion_Translator.Patches.Modes.Super_Editor; -using UnityEngine; -using static PvZ_Fusion_Translator.FileLoader; - -[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun / cassidy / Teyliu", null)] -[assembly: MelonGame("LanPiaoPiao", "PlantsVsZombiesRH")] - -namespace PvZ_Fusion_Translator -{ - public class Core : MelonMod - { - private static DateTime dtStart; - private static DateTime? dtStartToast; - private static string toast_txt; - public static bool isInitialized = false; - public static Core Instance { get; private set; } - - object replaceTextureRoutine = null; - - public override void OnEarlyInitializeMelon() => dtStart = DateTime.Now; - - public override void OnInitializeMelon() - { - base.OnInitializeMelon(); - Instance = this; - - Config(); - #if MULTI_LANGUAGE - FileLoader.LoadLanguage(); - #endif - TextureStore.Init(); - StringStore.Init(); - AudioStore.Init(); - FontStore.Init(); - - isInitialized = true; - } - - public override void OnLateInitializeMelon() - { - dtStart = DateTime.Now; - replaceTextureRoutine = MelonCoroutines.Start(TextureStore.ReplaceTexturesCoroutine()); - LoadTravelBuffs(); - Utils.RegisterPlantIndices(); - } - - public override void OnDeinitializeMelon() - { - MelonCoroutines.Stop(replaceTextureRoutine); - #if MULTI_LANGUAGE - FileLoader.SaveLanguage(); - #endif - //DllStore.UpdateNewDll(); - #if OBFUSCATE && !RELEASE - CheckSumStore.ConvertMD5Json(); - #endif - } - - public static void ShowToast(string message) - { - toast_txt = message; - dtStartToast = new DateTime?(DateTime.Now); - } - - public override void OnLateUpdate() - { - #if DEBUG - ModFeatures.OnLateUpdate(); - #endif - - if (Input.GetKeyDown(KeyCode.Insert)) - { - Utils.OpenSaveDirectory(); - } - - if (Input.GetKeyDown(KeyCode.PageUp)) - { - Utils.OpenOnlineAlmanac(); - } - - TowerManager_Patch.UpdateText(); - - if (CustomLevelMenu_Patch.requestTimer > 0) - { - CustomLevelMenu_Patch.requestTimer -= Time.deltaTime; - if(CustomLevelMenu_Patch.requestTimer < 0) - { - CustomLevelMenu_Patch.requestTimer = 0; - } - } - } - - public override void OnGUI() - { - #if DEBUG - if (dtStartToast != null) - { - GUI.Button(new Rect(10f, 10f, 200f, 20f), "\n" + toast_txt + "\n"); - TimeSpan? timeSpan = DateTime.Now - dtStartToast; - TimeSpan t = new(0, 0, 0, 2); - if (timeSpan > t) - { - dtStartToast = null; - } - } - #endif - } - - public String modsDirectory => Path.Combine(MelonEnvironment.ModsDirectory, "PvZ_Fusion_Translator"); - - public MelonPreferences_Entry configDefaultTextures; - public MelonPreferences_Entry configDefaultAudio; - public MelonPreferences_Entry configUseLocal; - public MelonPreferences_Entry configLanguage; - - private void Config() - { - var category = MelonPreferences.CreateCategory("PvZ_Fusion_Translator", "Fusion Translator Settings"); - - configDefaultTextures = category.CreateEntry("DefaultTextures", false); - configDefaultAudio = category.CreateEntry("DefaultAudio", false); - configUseLocal = category.CreateEntry("UseLocal", false); - configLanguage = category.CreateEntry("Language", "English"); - - MelonPreferences.Save(); - } - } -} \ No newline at end of file diff --git a/MelonLoader/FileLoader.cs b/MelonLoader/FileLoader.cs deleted file mode 100644 index f3d9e36..0000000 --- a/MelonLoader/FileLoader.cs +++ /dev/null @@ -1,1232 +0,0 @@ -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppInterop.Runtime.InteropTypes.Arrays; -using JetBrains.Annotations; -using MelonLoader; -using MelonLoader.TinyJSON; -using Newtonsoft.Json; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.GameObjects; -using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; -using PvZ_Fusion_Translator.Patches.Modes.Odyssey; -using PvZ_Fusion_Translator.Patches.OtherManagers; -using System.CodeDom.Compiler; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using UnityEngine; - -namespace PvZ_Fusion_Translator -{ - internal static class FileLoader - { - internal enum AssetType - { - Textures, - Strings, - Dumps, - Almanac, - Sprites - } - - public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null) - { - string languagePath = language.HasValue ? ("Localization" + Path.DirectorySeparatorChar + language.ToString()) : string.Empty; - return Path.Combine(Core.Instance.modsDirectory, languagePath, assetType.ToString()); - } - // private static string GetAssetDir(AssetType assetType) => Path.Combine(Core.Instance.modsDirectory, assetType.ToString()); - - internal static void LoadStrings() => LoadStrings(Utils.Language); - - internal static void LoadStrings(Utils.LanguageEnum language) - { - string stringDir = GetAssetDir(AssetType.Strings, Utils.Language); - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - - if(!Utils.useLocal) - { - // load translationStrings - string translationStringsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/translation_strings.json").Result; - - if(translationStringsContent != null) - { - LoadTranslationStrings(translationStringsContent); - } - else - { - string translationStringsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "translation_strings.json"); - if(File.Exists(translationStringsPath)) - { - LoadTranslationStrings(File.ReadAllText(translationStringsPath)); - } - } - - // load translationRegexs - string translationRegexsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/translation_regexs.json").Result; - - if(translationRegexsContent != null) - { - LoadTranslationRegexs(translationRegexsContent); - } - else - { - string translationRegexsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "translation_regexs.json"); - if(File.Exists(translationRegexsPath)) - { - LoadTranslationRegexs(File.ReadAllText(translationRegexsPath)); - } - } - - string customLevelStringsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/customlevel_strings.json").Result; - - if(customLevelStringsContent != null) - { - LoadCustomLevelStrings(customLevelStringsContent); - } - else - { - string customLevelStringsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "customlevel_strings.json"); - if(File.Exists(customLevelStringsPath)) - { - LoadCustomLevelStrings(File.ReadAllText(customLevelStringsPath)); - } - } - - // load translationRegexs - string customLevelRegexsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/customlevel_regexs.json").Result; - - if(customLevelRegexsContent != null) - { - LoadCustomLevelRegexs(customLevelRegexsContent); - } - else - { - string customLevelRegexsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "customlevel_regexs.json"); - if(File.Exists(customLevelRegexsPath)) - { - LoadCustomLevelRegexs(File.ReadAllText(customLevelRegexsPath)); - } - } - - // load changelog - - LoadChangelogText(); - - // load tips - string izTipsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/tips_iz.json").Result; - - if(izTipsContent != null) - { - LoadIZStrings(izTipsContent); - } - else - { - string izTipsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_iz.json"); - if(File.Exists(izTipsPath)) - { - LoadIZStrings(File.ReadAllText(izTipsPath)); - } - } - - string fsTipsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/tips_fs.json").Result; - - if(fsTipsContent != null) - { - LoadFSStrings(fsTipsContent); - } - else - { - string fsTipsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_fs.json"); - if(File.Exists(fsTipsPath)) - { - LoadFSStrings(File.ReadAllText(fsTipsPath)); - } - } - - // load almanacs - - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - - if(!Directory.Exists(almanacDir)) - { - Directory.CreateDirectory(almanacDir); - } - - string plantAlmanacContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Almanac/LawnStringsTranslate.json").Result; - - if(plantAlmanacContent != null) - { - AlmanacPlantMenu_Patch.LoadPlantAlmanacData(plantAlmanacContent); - } - else - { - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - if(File.Exists(path)) - { - AlmanacPlantMenu_Patch.LoadPlantAlmanacData(File.ReadAllText(path)); - } - } - - string zombieAlmanacContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Almanac/ZombieStringsTranslate.json").Result; - - if(zombieAlmanacContent != null) - { - AlmanacZombieMenu_Patch.almanacJson = zombieAlmanacContent; - } - else - { - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - if(File.Exists(path)) - { - AlmanacZombieMenu_Patch.almanacJson = File.ReadAllText(path); - } - } - - 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) - { - LoadDetailStrings(detailStringsContent); - } - else - { - string path = Path.Combine(almanacDir, "DetailStringsTranslate.json"); - if(File.Exists(path)) - { - LoadDetailStrings(File.ReadAllText(path)); - } - } - - // load travel_buffs - - LoadTravelBuffs(); - - // load abyss buffs - - //Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); - - SaveStrings(); - DumpJson(); - } - else - { - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - try - { - foreach (string filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories)) - { - - #if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } - #endif - - string fileName = Path.GetFileNameWithoutExtension(filepath); - StringStore.stringsDict[fileName] = filepath; - #if DEBUG - Log.LogInfo("Loading File : " + filepath); - #endif - string jsonString = File.ReadAllText(filepath); - if (fileName.EndsWith("translation_strings")) - { - LoadTranslationStrings(jsonString); - } - else if (fileName.EndsWith("translation_regexs")) - { - LoadTranslationRegexs(jsonString); - } - else if (fileName.EndsWith("customlevel_strings")) - { - LoadCustomLevelStrings(jsonString); - } - else if (fileName.EndsWith("customlevel_regexs")) - { - LoadCustomLevelRegexs(jsonString); - } - else if(fileName.EndsWith("tips_iz")) - { - LoadIZStrings(jsonString); - } - else if(fileName.EndsWith("tips_fs")) - { - LoadFSStrings(jsonString); - } - //else if(fileName.EndsWith("abyss_buffs")) - //{ - // Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); - //} - else if (fileName.EndsWith("travel_buffs")) - { - LoadTravelBuffs(); - } - } - - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - - if(!Directory.Exists(almanacDir)) - { - Directory.CreateDirectory(almanacDir); - } - - string plantAlmanacPath = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - if(File.Exists(plantAlmanacPath)) - { - AlmanacPlantMenu_Patch.LoadPlantAlmanacData(File.ReadAllText(plantAlmanacPath)); - } - - string zombieAlmanacPath = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - if(File.Exists(zombieAlmanacPath)) - { - AlmanacZombieMenu_Patch.almanacJson = File.ReadAllText(zombieAlmanacPath); - } - - string detailStringsPath = Path.Combine(almanacDir, "DetailStringsTranslate.json"); - if(File.Exists(detailStringsPath)) - { - LoadDetailStrings(File.ReadAllText(detailStringsPath)); - } - - LoadChangelogText(); - - SaveStrings(); - DumpJson(); - } - catch (Exception e) - { - Log.LogError("Error loading string."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - Log.LogInfo("Strings loaded successfully."); - } - - internal static void LoadTranslationStrings(string content) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(content); - foreach (var (key, value) in dictionary) - { - StringStore.translationString[key] = value; - } - } - - internal static void LoadTranslationRegexs(string content) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(content); - foreach (var (key, value) in dictionary) - { - StringStore.translationStringRegex[key] = value; - } - Zombie_Patch.LoadHPStrings(); - } - - internal static void LoadCustomLevelStrings(string content) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(content); - foreach (var (key, value) in dictionary) - { - StringStore.customLevelString[key] = value; - } - } - - internal static void LoadCustomLevelRegexs(string content) - { - Dictionary dictionary = System.Text.Json.JsonSerializer.Deserialize>(content); - foreach (var (key, value) in dictionary) - { - StringStore.customLevelStringRegex[key] = value; - } - } - - internal static void LoadIZStrings(string content) - { - var izDump = DumpIZStrings(); - var izLevelData = izDump.Item1; - var izLevelDataDump = izDump.Item2; - - var izTranslatedTips = System.Text.Json.JsonSerializer.Deserialize>(content); - - foreach (var level in izLevelData) - { - string data = level.text; - LevelData levelData = JsonUtility.FromJson(data); - if(levelData.tips != null) - { - if(izTranslatedTips.ContainsKey(level.name) && !StringStore.izTipCollectionString.ContainsKey(levelData.tips)) - { - StringStore.izLevelTipDictionary.Add(level.name, izTranslatedTips[level.name]); - StringStore.izTipCollectionString.Add(levelData.tips, izTranslatedTips[level.name]); - } - } - } - } - - internal static void LoadFSStrings(string content) - { - var fusionShowcaseDump = DumpFSStrings(); - var fusionShowcaseData = fusionShowcaseDump.Item1; - var fusionShowcaseDataDump = fusionShowcaseDump.Item2; - - var fsTranslatedTips = System.Text.Json.JsonSerializer.Deserialize>(content); - - foreach (var level in fusionShowcaseData) - { - string data = level.text; - LevelData levelData = JsonUtility.FromJson(data); - if (levelData.tips != null) - { - if (fsTranslatedTips.ContainsKey(level.name) && !StringStore.fsTipCollectionString.ContainsKey(levelData.tips)) - { - StringStore.fsLevelTipDictionary.Add(level.name, fsTranslatedTips[level.name]); - StringStore.fsTipCollectionString.Add(levelData.tips, fsTranslatedTips[level.name]); - } - } - } - } - - internal static void LoadDetailStrings(string content) - { - var detailStringsDump = DumpDetailStrings(); - var detailStringsData = detailStringsDump.Item1; - var detailStrings = detailStringsDump.Item2; - - var translatedDetailStrings = System.Text.Json.JsonSerializer.Deserialize>(content); - AlmanacSelectMenu_Patch.detailStrings = translatedDetailStrings; - - foreach (var detailString in detailStringsData.details) - { - if (translatedDetailStrings.ContainsKey(detailString.title)) - { - if(!AlmanacSelectMenu_Patch.detailTranslateStrings.ContainsKey(detailString.text)) - { - AlmanacSelectMenu_Patch.detailTranslateStrings.Add(detailString.text, translatedDetailStrings[detailString.title]); - } - else - { - AlmanacSelectMenu_Patch.detailTranslateStrings[detailString.text] = translatedDetailStrings[detailString.title]; - } - } - } - } - - internal static void LoadChangelogText() - { - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - string changelogDir = Path.Combine(stringDir, "changelog.txt"); - string changelogText = ""; - if (!File.Exists(changelogDir)) - { - File.WriteAllText(changelogDir, ""); - } - - changelogText = File.ReadAllText(changelogDir); - - if(!Utils.useLocal) - { - string changelogContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/changelog.txt").Result; - - if(changelogContent != null) - { - changelogText = changelogContent; - } - } - else - { - changelogText = File.ReadAllText(changelogDir); - } - - NoticePauseMenu_Patch.changelogText = changelogText; - } - - internal static void LoadTravelBuffs() - { - if (!Utils.useLocal) - { - string travelBuffsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/travel_buffs.json").Result; - - if (travelBuffsContent != null) - { - TravelMgr_Patch.GenerateTranslatedTravelBuffs(travelBuffsContent); - } - else - { - string travelBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "travel_buffs.json"); - if (File.Exists(travelBuffsPath)) - { - TravelMgr_Patch.GenerateTranslatedTravelBuffs(File.ReadAllText(travelBuffsPath)); - } - } - } - else - { - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - - foreach (string filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories)) - { - string fileName = Path.GetFileNameWithoutExtension(filepath); - string jsonString = File.ReadAllText(filepath); - if (fileName.EndsWith("travel_buffs")) - { - TravelMgr_Patch.GenerateTranslatedTravelBuffs(jsonString); - } - } - } - } - - public static bool loadDefaultTextures = MelonPreferences.GetEntryValue("PvZ_Fusion_Translator", "DefaultTextures"); - internal static void LoadTextures() - { - // Default or Custom Texturse -> English Textures -> Localized Textures - try - { - if (Utils.customTextures) - { - LoadCustomTextures(); - } - } - catch (Exception e) - { - Log.LogError("Error loading texture setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - - #if MULTI_LANGUAGE - LoadLocalizedTextures(Utils.Language); - LoadLocalizedSprites(Utils.Language); - #else - LoadLocalizedTextures(); - #endif - - Log.LogInfo("Textures loaded successfully."); - } - - internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null) - { - string textureDir = GetAssetDir(AssetType.Textures, language); - - if (!Directory.Exists(textureDir)) - { - Directory.CreateDirectory(textureDir); - } - try - { - Dictionary localTOC = new Dictionary(); - string localTOCDir = Path.Combine(textureDir, "Texture_TOC.json"); - if (!File.Exists(localTOCDir)) - { - File.WriteAllText(localTOCDir, "{}"); - } - - string localTOCContent = File.ReadAllText(localTOCDir); - localTOC = System.Text.Json.JsonSerializer.Deserialize>(localTOCContent); - - string basePath = Core.Instance.modsDirectory; - - if (!Utils.useLocal) - { - string textureTOCRequest = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Textures/Texture_TOC.json").Result; - if (textureTOCRequest != null) - { - Dictionary textureTOC = JsonConvert.DeserializeObject>(textureTOCRequest); - - List toDownload = new(); - - foreach(var pair in textureTOC) - { - if(!localTOC.ContainsKey(pair.Key)) - { - toDownload.Add(pair.Key); - continue; - } - - if(pair.Value != localTOC[pair.Key]) - { - toDownload.Add(pair.Key); - } - - if(!File.Exists(Path.Combine(basePath, pair.Key))) - { - toDownload.Add(pair.Key); - continue; - } - } - - string toWriteText = SerializeWithIndentation(textureTOC); - File.WriteAllText(localTOCDir, toWriteText); - - foreach(string path in toDownload) - { - string downloadPath = Path.Combine(basePath, path); - - string baseUrl = $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; - string url = baseUrl + path; - - byte[] imageData = Utils.GetByteDataFromWeb(url).Result; - if(imageData != null) - { - string fileName = Path.GetFileName(downloadPath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[fileName] = imageData; - if(!Directory.Exists(Path.GetDirectoryName(downloadPath))) - { - Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); - } - File.WriteAllBytes(downloadPath, imageData); - } - } - } - } - - foreach (string filepath in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories)) - { - if (filepath.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) && loadDefaultTextures) - { - continue; - } - - if (!localTOC.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) - && (SerializeWithIndentation(localTOC) != "{}")) continue; - - #if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } - #endif - - #if DEBUG - Log.LogDebug("Loading File : " + filepath); - #endif - - byte[] imageData = File.ReadAllBytes(filepath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - internal static void LoadLocalizedSprites(Utils.LanguageEnum? language = null) - { - string textureDir = GetAssetDir(AssetType.Sprites, language); - - if (!Directory.Exists(textureDir)) - { - Directory.CreateDirectory(textureDir); - } - try - { - string trueTextureDir = GetAssetDir(AssetType.Textures, language); - Dictionary localTOC = new Dictionary(); - string localTOCDir = Path.Combine(trueTextureDir, "Texture_TOC.json"); - if (!File.Exists(localTOCDir)) - { - File.WriteAllText(localTOCDir, "{}"); - } - - string localTOCContent = File.ReadAllText(localTOCDir); - localTOC = System.Text.Json.JsonSerializer.Deserialize>(localTOCContent); - - string basePath = Core.Instance.modsDirectory; - - if(!Utils.useLocal) - { - string textureTOCRequest = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Textures/Texture_TOC.json").Result; - if (textureTOCRequest != null) - { - Dictionary textureTOC = JsonConvert.DeserializeObject>(textureTOCRequest); - - List toDownload = new(); - - foreach(var pair in textureTOC) - { - if(!localTOC.ContainsKey(pair.Key)) - { - toDownload.Add(pair.Key); - continue; - } - - if(pair.Value != localTOC[pair.Key]) - { - toDownload.Add(pair.Key); - } - - if(!File.Exists(Path.Combine(basePath, pair.Key))) - { - toDownload.Add(pair.Key); - continue; - } - } - - string toWriteText = SerializeWithIndentation(textureTOC); - File.WriteAllText(localTOCDir, toWriteText); - - foreach(string path in toDownload) - { - string downloadPath = Path.Combine(basePath, path); - - string baseUrl = $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; - string url = baseUrl + path; - - byte[] imageData = Utils.GetByteDataFromWeb(url).Result; - if(imageData != null) - { - string fileName = Path.GetFileName(downloadPath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.spriteDict[fileName] = imageData; - if(!Directory.Exists(Path.GetDirectoryName(downloadPath))) - { - Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); - } - File.WriteAllBytes(downloadPath, imageData); - } - } - } - } - - foreach (string filepath in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories)) - { - if (filepath.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) && loadDefaultTextures) - { - continue; - } - - if (!localTOC.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) - && (SerializeWithIndentation(localTOC) != "{}")) continue; - - #if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } - #endif - - #if DEBUG - Log.LogDebug("Loading File (Sprite): " + filepath); - #endif - - byte[] imageData = File.ReadAllBytes(filepath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.spriteDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - internal static void LoadDefaultTextures() - { - if(Utils.customTextures == false) - { - string textureDefaultDir = Path.Combine(Core.Instance.modsDirectory, AssetType.Dumps.ToString(), "Default Textures [Do Not Remove]"); - if (!Directory.Exists(textureDefaultDir)) - { - Directory.CreateDirectory(textureDefaultDir); - } - try - { - string trueTextureDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Textures]"); - Dictionary localTOC = new Dictionary(); - string localTOCDir = Path.Combine(trueTextureDir, "Default_TOC.json"); - if (!File.Exists(localTOCDir)) - { - File.WriteAllText(localTOCDir, "{}"); - } - - string localTOCContent = File.ReadAllText(localTOCDir); - localTOC = System.Text.Json.JsonSerializer.Deserialize>(localTOCContent); - - string basePath = Core.Instance.modsDirectory; - - if (!Utils.useLocal) - { - string textureTOCRequest = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/{Uri.EscapeDataString("[Custom Textures]")}/Default_TOC.json").Result; - if (textureTOCRequest != null) - { - Dictionary textureTOC = JsonConvert.DeserializeObject>(textureTOCRequest); - - List toDownload = new(); - - foreach (var pair in textureTOC) - { - if (!localTOC.ContainsKey(pair.Key)) - { - toDownload.Add(pair.Key); - continue; - } - - if (pair.Value != localTOC[pair.Key]) - { - toDownload.Add(pair.Key); - } - - if(!File.Exists(Path.Combine(basePath, pair.Key))) - { - toDownload.Add(pair.Key); - continue; - } - } - - string toWriteText = SerializeWithIndentation(textureTOC); - File.WriteAllText(localTOCDir, toWriteText); - - foreach (string path in toDownload) - { - string downloadPath = Path.Combine(basePath, path); - - string baseUrl = $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; - string url = baseUrl + path; - - byte[] imageData = Utils.GetByteDataFromWeb(url).Result; - if (imageData != null) - { - string fileName = Path.GetFileName(downloadPath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[fileName] = imageData; - if(!Directory.Exists(Path.GetDirectoryName(downloadPath))) - { - Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); - } - File.WriteAllBytes(downloadPath, imageData); - } - } - } - } - - foreach (string filepath in Directory.EnumerateFiles(textureDefaultDir, "*.png", SearchOption.AllDirectories)) - { - if (!localTOC.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) - && (SerializeWithIndentation(localTOC) != "{}")) continue; - - #if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } - #endif - - byte[] imageData = File.ReadAllBytes(filepath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - } - - internal static void LoadCustomTextures() - { - string texturePackDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Textures]"); - - if (!Directory.Exists(texturePackDir)) - { - Directory.CreateDirectory(texturePackDir); - } - try - { - string trueTextureDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Textures]"); - Dictionary localTOC = new Dictionary(); - string localTOCDir = Path.Combine(trueTextureDir, "Custom_TOC.json"); - if (!File.Exists(localTOCDir)) - { - File.WriteAllText(localTOCDir, "{}"); - } - - string localTOCContent = File.ReadAllText(localTOCDir); - localTOC = System.Text.Json.JsonSerializer.Deserialize>(localTOCContent); - - string basePath = Core.Instance.modsDirectory; - - if (!Utils.useLocal) - { - string textureTOCRequest = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/{Uri.EscapeDataString("[Custom Textures]")}/Custom_TOC.json").Result; - if (textureTOCRequest != null) - { - Dictionary textureTOC = JsonConvert.DeserializeObject>(textureTOCRequest); - - List toDownload = new(); - - foreach (var pair in textureTOC) - { - if (!localTOC.ContainsKey(pair.Key)) - { - toDownload.Add(pair.Key); - continue; - } - - if (pair.Value != localTOC[pair.Key]) - { - toDownload.Add(pair.Key); - continue; - } - - if(!File.Exists(Path.Combine(basePath, pair.Key))) - { - toDownload.Add(pair.Key); - continue; - } - } - - string toWriteText = SerializeWithIndentation(textureTOC); - File.WriteAllText(localTOCDir, toWriteText); - - foreach (string path in toDownload) - { - string downloadPath = Path.Combine(basePath, path); - - string baseUrl = $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; - string url = baseUrl + path; - - byte[] imageData = Utils.GetByteDataFromWeb(url).Result; - if (imageData != null) - { - string fileName = Path.GetFileName(downloadPath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[fileName] = imageData; - if(!Directory.Exists(Path.GetDirectoryName(downloadPath))) - { - Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); - } - File.WriteAllBytes(downloadPath, imageData); - } - } - } - } - - foreach (string filepath in Directory.EnumerateFiles(texturePackDir, "*.png", SearchOption.AllDirectories)) - { - #if OBFUSCATE - if (CheckSumStore.IsModified(filepath)) - { - Log.LogError("File {0} was modified!" , filepath); - continue; - } - #endif - - if (!localTOC.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) - && (SerializeWithIndentation(localTOC) != "{}")) continue; - - byte[] imageData = File.ReadAllBytes(filepath); - Texture2D texture2D = Utils.LoadImage(imageData); - TextureStore.textureDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; - } - } - - catch (Exception e) - { - Log.LogError("Error loading Texture."); - Log.LogError(e.GetType() + " " + e.Message); - } - } - - internal static void SaveStrings() - { - #if MULTI_LANGUAGE - string stringDir = GetAssetDir(AssetType.Strings, Utils.Language); - #else - string stringDir = GetAssetDir(AssetType.Strings); - #endif - if (!Directory.Exists(stringDir)) - { - Directory.CreateDirectory(stringDir); - } - - // save regexs - - string translationStringRegex = SerializeWithIndentation(StringStore.translationStringRegex, 2); - - File.WriteAllText(Path.Combine(stringDir, "translation_regexs.json"), translationStringRegex); - - // save strings - - string translationString = SerializeWithIndentation(StringStore.translationString, 2); - - File.WriteAllText(Path.Combine(stringDir, "translation_strings.json"), translationString); - - // save iz tips - - string izTipCollectionString = SerializeWithIndentation(StringStore.izLevelTipDictionary, 1, ' '); - - File.WriteAllText(Path.Combine(stringDir, "tips_iz.json"), izTipCollectionString); - - // save fs tips - - string fsLevelTipDictionary = SerializeWithIndentation(StringStore.fsLevelTipDictionary); - - File.WriteAllText(Path.Combine(stringDir, "tips_fs.json"), fsLevelTipDictionary); - - // save changelog - - if(NoticePauseMenu_Patch.changelogText != "") - { - File.WriteAllText(Path.Combine(stringDir, "changelog.txt"), NoticePauseMenu_Patch.changelogText); - } - - // save abyss buffs - - //if(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData != new Dictionary()) - //{ - // string abyssBuffData = SerializeWithIndentation(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData, 2); - // File.WriteAllText(Path.Combine(stringDir, "abyss_buffs.json"), abyssBuffData); - //} - - // save almanacs - - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - - if(AlmanacPlantMenu_Patch.almanacJson != "") - { - string plantAlmanac = SerializeWithIndentation(AlmanacPlantMenu_Patch.almanacJson); - - File.WriteAllText(Path.Combine(almanacDir, "LawnStringsTranslate.json"), AlmanacPlantMenu_Patch.almanacJson); - } - - if(AlmanacZombieMenu_Patch.almanacJson != "") - { - string zombieAlmanac = SerializeWithIndentation(AlmanacZombieMenu_Patch.almanacJson); - - File.WriteAllText(Path.Combine(almanacDir, "ZombieStringsTranslate.json"), AlmanacZombieMenu_Patch.almanacJson); - } - - if(AlmanacSelectMenu_Patch.detailStrings != new Dictionary()) - { - string detailStrings = SerializeWithIndentation(AlmanacSelectMenu_Patch.detailStrings); - - File.WriteAllText(Path.Combine(almanacDir, "DetailStringsTranslate.json"), detailStrings); - } - } - - public static string SerializeWithIndentation(T value, int size = 4, char indentChar = ' ') - { - var stringBuilder = new StringBuilder(); - var stringWriter = new StringWriter(); - using (JsonTextWriter writer = new JsonTextWriter(stringWriter)) - { - writer.Formatting = Formatting.Indented; - writer.Indentation = size; - writer.IndentChar = indentChar; - - Newtonsoft.Json.JsonSerializer serializer = new Newtonsoft.Json.JsonSerializer(); - serializer.Serialize(writer, value, typeof(T)); - } - - return stringWriter.ToString(); - } - - public static void DumpJson() - { - string dumpDir = GetAssetDir(AssetType.Dumps); - - if (!Directory.Exists(dumpDir)) - { - Directory.CreateDirectory(dumpDir); - } - string LawnStrings = Resources.Load("LawnStrings").text; - string ZombieStrings = Resources.Load("ZombieStrings").text; - //string AbyssBuffData = Resources.Load("AbyssBuffData").text; - File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings); - File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings); - //File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData); - - // dump iz tips - var izDump = DumpIZStrings(); - var izLevelData = izDump.Item1; - var izLevelDataDump = izDump.Item2; - - File.WriteAllText(Path.Combine(dumpDir, "tips_iz.json"), System.Text.Json.JsonSerializer.Serialize(izLevelDataDump, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - - // dump fusion showcase tips - var fusionShowcaseDump = DumpFSStrings(); - var fusionShowcaseData = fusionShowcaseDump.Item1; - var fusionShowcaseDataDump = fusionShowcaseDump.Item2; - - File.WriteAllText(Path.Combine(dumpDir, "tips_fs.json"), System.Text.Json.JsonSerializer.Serialize(fusionShowcaseDataDump, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - - // dump almanac mechanics - var detailStringsDump = DumpDetailStrings(); - var detailStringsData = detailStringsDump.Item1; - var detailStrings = detailStringsDump.Item2; - - File.WriteAllText(Path.Combine(dumpDir, "DetailStrings.json"), System.Text.Json.JsonSerializer.Serialize(detailStrings, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - - /*Dictionary achievementsList = new Dictionary(); - foreach (Il2CppSystem.Collections.Generic.KeyValuePair> entry in AchievementClip.achievementsText) - { - achievementsList.Add(entry.Key, new AchievementObject(entry.Key, entry.Value.Item1, entry.Value.Item2)); - } - File.WriteAllText(Path.Combine(dumpDir, "AchievementsText.json"), System.Text.Json.JsonSerializer.Serialize(achievementsList, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - }));*/ - } - - public static ValueTuple, Dictionary> DumpIZStrings() - { - var izLevelData = Resources.LoadAll("izleveldata"); - Dictionary izLevelDataDump = new Dictionary(); - foreach (var level in izLevelData) - { - string data = level.text; - LevelData levelData = JsonUtility.FromJson(data); - if(levelData.tips != null) - { - izLevelDataDump.Add(level.name, levelData.tips); - } - } - return new ValueTuple, Dictionary>(izLevelData, izLevelDataDump); - } - - public static ValueTuple, Dictionary> DumpFSStrings() - { - var fusionShowcaseData = Resources.LoadAll("leveldata/explore"); - Dictionary fusionShowcaseDataDump = new Dictionary(); - foreach (var level in fusionShowcaseData) - { - string data = level.text; - LevelData levelData = JsonUtility.FromJson(data); - if (levelData.tips != null) - { - fusionShowcaseDataDump.Add(level.name, levelData.tips); - } - } - return new ValueTuple, Dictionary>(fusionShowcaseData, fusionShowcaseDataDump); - } - - public static ValueTuple> DumpDetailStrings() - { - string detailStringsData = Resources.Load("detailstrings").text; - Il2CppAlmanacData.AlmanacData detailStrings = JsonUtility.FromJson(detailStringsData); - - Dictionary detailStringsDump = new Dictionary(); - foreach (var detailString in detailStrings.details) - { - if(detailStringsDump.ContainsKey(detailString.title)) - { - detailStringsDump[detailString.title] = detailString.text; - } - else - { - detailStringsDump.Add(detailString.title, detailString.text); - } - } - return new ValueTuple>(detailStrings, detailStringsDump); - } - - #if DEBUG - public static void DumpUntranslatedStrings(string text) - { - string dumpDir = GetAssetDir(AssetType.Dumps); - string jsonFile = Path.Combine(dumpDir, "UntranslatedStrings.json"); - - if (!Directory.Exists(dumpDir)) - { - Directory.CreateDirectory(dumpDir); - } - - if (!File.Exists(jsonFile)) - { - File.WriteAllText(jsonFile, "{}"); // Initialize empty JSON object - } - - string json = File.ReadAllText(jsonFile); - var untranslatedStrings = System.Text.Json.JsonSerializer.Deserialize>(json); - - if (!untranslatedStrings.ContainsKey(text)) - { - untranslatedStrings[text] = text; - var options = new JsonSerializerOptions - { - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, - WriteIndented = true - }; - File.WriteAllText(jsonFile, System.Text.Json.JsonSerializer.Serialize(untranslatedStrings, options)); - } - } - #endif - - - #if MULTI_LANGUAGE - internal static void LoadLanguage() - { - try - { - // Load the language preference as a string and parse it into the enum - string languageName = MelonPreferences.GetEntryValue("PvZ_Fusion_Translator", "Language"); - if (Enum.TryParse(languageName, out Utils.LanguageEnum loadedLanguage)) - { - Utils.Language = loadedLanguage; - } - else - { - Log.LogWarning($"Invalid language '{languageName}' found in preferences. Falling back to English."); - Utils.Language = Utils.LanguageEnum.English; // Default fallback - } - Log.LogWarning($"Loaded language {languageName}"); - } - catch (Exception e) - { - Log.LogError("Error loading language setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - Log.LogInfo($"Language has been loaded: {Utils.Language}"); - } - - internal static void SaveLanguage() - { - try - { - // Save the current language as a string - MelonPreferences.SetEntryValue("PvZ_Fusion_Translator", "Language", Utils.Language.ToString()); - - // Ensure changes are written to the config file - // MelonPreferences.Save(); - } - catch (Exception e) - { - Log.LogError("Error saving language setting."); - Log.LogError($"{e.GetType()} {e.Message}"); - } - // Log.LogInfo($"Language has been saved: {Utils.Language}"); - } - #endif - } -} \ No newline at end of file diff --git a/MelonLoader/FontHandler.cs b/MelonLoader/FontHandler.cs deleted file mode 100644 index a2cad5a..0000000 --- a/MelonLoader/FontHandler.cs +++ /dev/null @@ -1,43 +0,0 @@ -using Il2CppTMPro; -using MelonLoader.Utils; -using UnityEngine; - -namespace PvZ_Fusion_Translator -{ - public static class FontHandler - { - public static Font LoadFont(this string pathFromModsFolder, bool throwException) - { - string fontFilePath = Path.Combine(MelonEnvironment.ModsDirectory, pathFromModsFolder); - if (!File.Exists(fontFilePath)) - { - if (throwException) - Log.LogWarning($"Font not found at path: '{fontFilePath}'."); - return null; - } - Font font = new(); - Font.Internal_CreateFontFromPath(font, fontFilePath); - return font; - } - - public static TMP_FontAsset ConvertToTMP(this Font font) - { - TMP_FontAsset fontAsset = TMP_FontAsset.CreateFontAsset(font); - if (fontAsset == null) - { - Log.LogWarning($"Failed to create TMP_FontAsset from font '{font.name}'."); - return null; - } - return fontAsset; - } - - public static TMP_FontAsset LoadTMPFont(this string pathFromModsFolder, bool throwException) - { - Font font = pathFromModsFolder.LoadFont(throwException); - if (!font) - return null; - TMP_FontAsset fontAsset = font.ConvertToTMP(); - return fontAsset; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Log.cs b/MelonLoader/Log.cs deleted file mode 100644 index d7d93b6..0000000 --- a/MelonLoader/Log.cs +++ /dev/null @@ -1,25 +0,0 @@ -using MelonLoader; -using MelonLoader.Logging; -using System.Drawing; - -namespace PvZ_Fusion_Translator -{ - internal static class Log - { - public static void LogDebug(object txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); - public static void LogDebug(string txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); - public static void LogDebug(string txt, params object[] args) => Melon.Logger.Msg(ColorARGB.Gray, txt, args); - - public static void LogInfo(object txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); - public static void LogInfo(string txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); - public static void LogInfo(string txt, params object[] args) => Melon.Logger.Msg(ColorARGB.Blue, txt, args); - - public static void LogWarning(object txt) => Melon.Logger.Warning(txt); - public static void LogWarning(string txt) => Melon.Logger.Warning(txt); - public static void LogWarning(string txt, params object[] args) => Melon.Logger.Warning(txt, args); - - public static void LogError(object txt) => Melon.Logger.Error(txt); - public static void LogError(string txt) => Melon.Logger.Error(txt); - public static void LogError(string txt, params object[] args) => Melon.Logger.Error(txt, args); - } -} \ No newline at end of file diff --git a/MelonLoader/ModFeatures.cs b/MelonLoader/ModFeatures.cs deleted file mode 100644 index ca2703b..0000000 --- a/MelonLoader/ModFeatures.cs +++ /dev/null @@ -1,95 +0,0 @@ -//#if DEBUG -using Il2Cpp; -using Il2CppGameLevel; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.Modes.Super_Editor; -using UnityEngine; - -namespace PvZ_Fusion_Translator -{ - public static class ModFeatures - { - public enum ModType - { - ReloadStrings, - ReloadTextures, - ExportLevelStrings - } - - private class ModFeature - { - public string Name { get; private set; } - public ModType ModType { get; private set; } - public KeyCode KeyCode { get; private set; } - public bool IsActive { get; set; } - - public ModFeature(string Name, ModType ModType, KeyCode KeyCode, bool defaultValue = false) - { - this.Name = Name; - this.ModType = ModType; - this.KeyCode = KeyCode; - this.IsActive = defaultValue; - } - - public void ToggleFeature() - { - if (this.ModType == ModType.ReloadStrings) - { - StringStore.Reload(); - Core.ShowToast("Strings Reloaded!"); - return; - } - - if (this.ModType == ModType.ReloadTextures) - { - TextureStore.Reload(); - Core.ShowToast("Textures Reloaded!"); - return; - } - - if (this.ModType == ModType.ExportLevelStrings) - { - CustomMenu customMenu = UnityEngine.Object.FindObjectOfType(); - if (!customMenu) return; - if(customMenu.isActiveAndEnabled) - { - Patches.Modes.Super_Editor.GameLevel.LevelManager_Patch.ExportLevelStrings(customMenu.LevelData); - Core.ShowToast("Dumped level strings!"); - } - return; - } - } - } - - private static Dictionary featureLists = new() - { - {ModType.ReloadStrings,new ModFeature("Reload Strings",ModType.ReloadStrings,KeyCode.Home, true)}, - {ModType.ReloadTextures,new ModFeature("Reload Textures",ModType.ReloadTextures,KeyCode.End, true)}, - {ModType.ExportLevelStrings,new ModFeature("Export Level Strings",ModType.ExportLevelStrings,KeyCode.N, true)} - }; - - - public static void ToggleFeature(ModType ModType) - { - if (!featureLists.ContainsKey(ModType)) - return; - - featureLists[ModType].ToggleFeature(); - } - - public static void OnLateUpdate() - { - foreach (var (type, feature) in featureLists) - { - if (feature.KeyCode != KeyCode.None && Enum.IsDefined(typeof(KeyCode), feature.KeyCode)) - { - if (Input.GetKeyDown(feature.KeyCode)) - { - feature.ToggleFeature(); - } - } - } - } - } -} -//#endif \ No newline at end of file diff --git a/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs b/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs deleted file mode 100644 index 4fc812f..0000000 --- a/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs +++ /dev/null @@ -1,400 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppCore; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.Modes.Odyssey; -using System.Text.RegularExpressions; -using System.Xml.Linq; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(InGameText))] - public static class InGameText_Patch - { - public static string currentText = ""; - - [HarmonyPatch(nameof(InGameText.ShowText))] - [HarmonyPostfix] - public static void ShowText(InGameText __instance) - { - TranslateInGameText(__instance); - } - - [HarmonyPatch(nameof(InGameText.DebugWarning))] - [HarmonyPostfix] - public static void DebugWarning(InGameText __instance) - { - TranslateInGameText(__instance); - } - - [HarmonyPatch(nameof(InGameText.Update))] - [HarmonyPostfix] - public static void Update(InGameText __instance) - { - TranslateInGameText(__instance); - } - - public static void TranslateInGameText(InGameText __instance) - { - TextMeshProUGUI txt = null; - - if (__instance.textMesh == null || __instance.textHead == null) - { - if (__instance.TryGetComponent(out TextMeshProUGUI selfTxt)) - { - txt = selfTxt; - } - } - else - { - txt = __instance.textMesh; - } - - if(txt != null) - { - if (!txt.gameObject.active) return; - - TranslateInGameTextMesh(txt); - } - } - - public static void TranslateInGameTextMesh(TextMeshProUGUI txt) - { - if (txt == null) return; - if (txt.text == currentText) return; - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - string originalText = txt.text; - string lockedPlantMatch = CheckLockedMessage(originalText); - string travelMatch = TravelMgr_Patch.MatchTravelBuff(originalText); - int godsGachaCheck = CheckGodsGachaPopup(originalText); - string godsGachaMatch = ""; - string superEditorPlantMatch = CheckSuperEditorPopup(originalText); - string customLevelRegexMatch = CheckCustomLevelRegex(originalText); - string qualityCheckMatch = CheckQualityUpgrade(originalText); - - switch(godsGachaCheck) - { - case 1: - case 2: - case 3: - godsGachaMatch = TranslateGodsGachaPopup(originalText, godsGachaCheck); - break; - default: - break; - } - - if(godsGachaMatch != "") - { - txt.text = godsGachaMatch; - if (txt.gameObject.name.Contains("main")) - { - originalText = txt.text; - Transform shadowText = txt.transform.parent.Find("Text_shadow"); - if (shadowText != null) - { - shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); - } - } - } - else if (travelMatch != "") - { - txt.text = TravelMgr_Patch.AddBuffName(travelMatch); - if (txt.gameObject.name.Contains("main")) - { - originalText = txt.text; - Transform shadowText = txt.transform.parent.Find("Text_shadow"); - if (shadowText != null) - { - shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); - } - } - } - else if(qualityCheckMatch != "") - { - txt.text = qualityCheckMatch; - } - else if(superEditorPlantMatch != "") - { - txt.text = superEditorPlantMatch; - } - else if(lockedPlantMatch != "") - { - txt.text = lockedPlantMatch; - } - else if(customLevelRegexMatch != "") - { - txt.text = customLevelRegexMatch; - } - else if((Regex.Match(txt.text, @"(]*>.*?)", RegexOptions.Singleline).Success) && - !StringStore.translationString.ContainsKey(txt.text) && - !StringStore.fsTipCollectionString.ContainsKey(txt.text) && - !StringStore.izTipCollectionString.ContainsKey(txt.text) && - !StringStore.customLevelString.ContainsKey(txt.text)) - { - txt.text = StringStore.TranslateColorText(txt.text, true); - if (txt.gameObject.name.Contains("main")) - { - originalText = txt.text; - Transform shadowText = txt.transform.parent.Find("Text_shadow"); - if (shadowText != null) - { - shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); - } - } - } - else - { - txt.text = StringStore.TranslateText(txt.text, true); - if (txt.gameObject.name.Contains("main")) - { - originalText = txt.text; - Transform shadowText = txt.transform.parent.Find("Text_shadow"); - if (shadowText != null) - { - shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); - } - } - } - txt.font = fontAsset; - - currentText = txt.text; - } - - public static string namePlantedPattern = "种植了:([^\\s]+)"; - public static string nameUpgradedPattern = "升级成功:([^\\s]+) -> ([^\\s]+)"; - public static string nameAlreadyPlantedPattern = "场上已经有一个([^\\s]+)了"; - public static string upgradePathRemovedPattern = "已移除路线:([^\\s]+)"; - - public static string lockedPlantPattern = "^([\\s\\S]+)\\+([\\S]+)$"; - public static string multiLockedPlantPattern = "^或 ([\\s\\S]+)\\+([\\S]+)$"; - - public static string qualityChangePattern = "诸神注视着你,并选中了一个他们喜欢的词条\n植物【([\\S]+)】的词条【强化:([\\S]+)】获得品质升级\n当前品质:([\\S]+)"; - - public static Dictionary fallbackFStrs = new Dictionary() - { - { namePlantedPattern, "{0} planted!"}, - { nameUpgradedPattern, "{0} successfully upgraded to {1}!"}, - { nameAlreadyPlantedPattern, "{0} already exists on the lawn!"}, - { upgradePathRemovedPattern, "Upgrade Path removed for {0}" }, - { @"([^\s]+)\((\d+)\)", "{0}({1})" }, - { lockedPlantPattern, "{0} + {1}" }, - { multiLockedPlantPattern, "or {0} + {1}" }, - { qualityChangePattern, "The gods are watching you, and they have granted you an upgrade!\nThe {1} upgrade for {0} has been upgraded.\nCurrent Quality: {2}" } - }; - - public static int CheckGodsGachaPopup(string originalText) - { - int res = 0; - - if (Regex.IsMatch(originalText, namePlantedPattern)) - { - res = 1; - } - else if(Regex.IsMatch(originalText, nameUpgradedPattern)) - { - res = 2; - } - else if(Regex.IsMatch(originalText, nameAlreadyPlantedPattern)) - { - res = 3; - } - - return res; - } - - public static string TranslateGodsGachaPopup(string originalText, int type) - { - string res = originalText; - - switch(type) - { - case 1: - res = StringStore.TranslateText(originalText, namePlantedPattern); - break; - case 2: - res = StringStore.TranslateText(originalText, nameUpgradedPattern); - break; - case 3: - res = StringStore.TranslateText(originalText, nameAlreadyPlantedPattern); - break; - default: - break; - } - - return res; - } - - public static string TranslatePlantNameParts(string originalText, string pattern) - { - string res = ""; - string fStr = ""; - Match match = Regex.Match(originalText, pattern); - if(match.Success) - { - GroupCollection groups = match.Groups; - fStr = StringStore.translationStringRegex.ContainsKey(pattern) ? StringStore.translationStringRegex[pattern] : fallbackFStrs[pattern]; - List dynamicParts = []; - for(int i = 1; i < groups.Count; i++) - { - string group = groups[i].Value; - string plantName = Utils.GetPlantNameFromAlmanac(group); - dynamicParts.Add(plantName); - } - res = string.Format(fStr, [.. dynamicParts]); - } - return res; - } - - public static string TranslatePlantNameParts(string originalText, string pattern, string fallback) - { - string res = ""; - string fStr = ""; - Match match = Regex.Match(originalText, pattern); - if(match.Success) - { - GroupCollection groups = match.Groups; - fStr = StringStore.translationStringRegex.ContainsKey(pattern) ? StringStore.translationStringRegex[pattern] : fallback; - List dynamicParts = []; - for(int i = 1; i < groups.Count; i++) - { - string group = groups[i].Value; - string plantName = Utils.GetPlantNameFromAlmanac(group); - if (plantName == "") plantName = StringStore.TranslateText(group); - dynamicParts.Add(plantName); - } - res = string.Format(fStr, [.. dynamicParts]); - } - return res; - } - - public static string CheckSuperEditorPopup(string originalText) - { - string res = ""; - - if(Regex.IsMatch(originalText, upgradePathRemovedPattern)) - { - res = StringStore.TranslateText(originalText, upgradePathRemovedPattern); - } - else if(Regex.IsMatch(originalText, "当前全部基础植物:(.*)")) - { - string pattern = "当前全部基础植物:(.*)"; - Match match = Regex.Match(originalText, pattern); - if(match.Success) - { - GroupCollection groups = match.Groups; - string plantNameGroup = groups[1].Value; - string[] plantNames = plantNameGroup.Split(" "); - string plantRes = ""; - string shortPattern = @"([^\s]+)\((\d+)\)"; - foreach (string plantName in plantNames) - { - Match shortMatch = Regex.Match(plantName, shortPattern); - if(shortMatch.Success) - { - string fStr = StringStore.translationStringRegex.ContainsKey(shortPattern) ? StringStore.translationStringRegex[shortPattern] : fallbackFStrs[shortPattern]; - string shortRes = string.Format(fStr, [Utils.GetPlantNameFromAlmanac(shortMatch.Groups[1].Value), shortMatch.Groups[2].Value]); - plantRes += shortRes + " "; - } - } - res = StringStore.TranslateText("当前全部基础植物:" + plantRes); - } - } - - return res; - } - - public static string CheckLockedMessage(string originalText) - { - string res = ""; - - Regex lockedPlantRegex = new Regex(lockedPlantPattern); - Regex multiLockedPlantRegex = new Regex(multiLockedPlantPattern); - - if(lockedPlantRegex.IsMatch(originalText)) - { - if(originalText.Contains("\n")) - { - string[] lines = originalText.Split("\n"); - if (lockedPlantRegex.IsMatch(lines[0])) - { - string firstLine = lines[0]; - Match match = lockedPlantRegex.Match(firstLine); - GroupCollection groups = match.Groups; - if (Utils.plantIndiceString.ContainsKey(groups[1].Value) && Utils.plantIndiceString.ContainsKey(groups[2].Value)) - { - firstLine = StringStore.TranslateText(firstLine, lockedPlantPattern); - List translatedLines = new List() { firstLine }; - for(int i = 1; i < lines.Length; i++) - { - string nextLine = lines[i]; - string translatedNextLine = StringStore.TranslateText(nextLine, multiLockedPlantPattern); - translatedLines.Add(translatedNextLine); - } - res = string.Join("\n", translatedLines); - } - else - { - return ""; - } - } - } - else - { - if (lockedPlantRegex.IsMatch(originalText)) - { - Match match = lockedPlantRegex.Match(originalText); - GroupCollection groups = match.Groups; - if (Utils.plantIndiceString.ContainsKey(groups[1].Value) && Utils.plantIndiceString.ContainsKey(groups[2].Value)) - { - res = StringStore.TranslateText(originalText, lockedPlantPattern); - } - else - { - return ""; - } - } - } - } - - return res; - } - - public static string CheckCustomLevelRegex(string originalText) - { - string res = ""; - - foreach(var pair in StringStore.customLevelStringRegex) - { - if(StringStore.TestRegex(originalText, pair.Key)) - { - res = StringStore.TranslateText(originalText, pair.Key); - } - } - foreach(var pair in StringStore.translationStringRegex) - { - if(StringStore.TestRegex(originalText, pair.Key)) - { - res = ""; - } - } - return res; - } - - public static string CheckQualityUpgrade(string originalText) - { - string res = ""; - - if(Regex.IsMatch(originalText, qualityChangePattern)) - { - res = StringStore.TranslateText(originalText, qualityChangePattern); - } - - return res; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs deleted file mode 100644 index 9b7a3a3..0000000 --- a/MelonLoader/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -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(true)) - { - txt.text = StringStore.translationString.ContainsKey(txt.text + "_code") ? StringStore.TranslateText(txt.text + "_code") : StringStore.TranslateText(txt.text); - } - } - } -} diff --git a/MelonLoader/Patches/BaseTextObjects/TMP_InputField_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TMP_InputField_Patch.cs deleted file mode 100644 index 0465668..0000000 --- a/MelonLoader/Patches/BaseTextObjects/TMP_InputField_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(TMP_InputField))] - public static class TMP_InputField_Patch - { - [HarmonyPatch(nameof(TMP_InputField.OnEnable))] - [HarmonyPostfix] - public static void OnEnable(TMP_InputField __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - string text = StringStore.TranslateText(__instance.text); - __instance.m_Text = StringStore.TranslateText(text); - __instance.m_OriginalText = StringStore.TranslateText(text); - __instance.m_TextComponent.text = StringStore.TranslateText(text); - } - } - } -} diff --git a/MelonLoader/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs deleted file mode 100644 index e7444ca..0000000 --- a/MelonLoader/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs +++ /dev/null @@ -1,110 +0,0 @@ -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(TextMeshProUGUI))] - public static class TextMeshProUGUI_Patch - { - [HarmonyPatch(nameof(TextMeshProUGUI.OnEnable))] - [HarmonyPostfix] - private static void OnEnable(TextMeshProUGUI __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - __instance.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - - if (!Utils.CheckForUntranslatedText(__instance.text) && !(__instance.text).Contains("_")) return; - - if(__instance.transform.parent != null) - { - if(__instance.transform.parent.name.Contains("DrawCardsText")) - { - return; - } - - if(__instance.transform.parent.parent != null) - { - if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) - { - return; - } - } - } - - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - - if (__instance.name.StartsWith("LevelName")) - { - __instance.text = __instance.text.Replace("\n", " "); - - if ((__instance.name == "LevelName2" || __instance.name == "LevelName3") && !(__instance.gameObject.transform.parent.name.Contains("Difficulty") || __instance.gameObject.name.Contains("Difficulty"))) - { - TowerManager_Patch.updatedText.Add(__instance.transform); - } - } - if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) - { - __instance.fontSizeMin = 10; - __instance.fontSize = 12; - } - - // __instance.ForceMeshUpdate(); - } - } - - /*[HarmonyPatch(nameof(TextMeshProUGUI.Awake))] - [HarmonyPostfix] - private static void Awake(TextMeshProUGUI __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - if (__instance.transform.parent.parent != null) - { - if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) - { - return; - } - } - - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - - if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) - { - __instance.fontSizeMin = 10; - __instance.fontSize = 12; - } - - if (__instance.text == "Полный Хаос" && __instance.transform.parent.parent.Find("Image").GetComponent().activeSprite.name == "Present") - { - __instance.text += "\nБесконечно"; - } - - // __instance.ForceMeshUpdate(); - } - }*/ - } - - /*[HarmonyPatch(typeof(TMP_SubMeshUI))] - public static class TMP_SubMeshUI_Patch - { - [HarmonyPatch(nameof(TMP_SubMeshUI.OnEnable))] - [HarmonyPostfix] - public static void OnEnable(TMP_SubMeshUI __instance) - { - if (!string.IsNullOrEmpty(__instance.textComponent.text)) - { - string text = StringStore.TranslateText(__instance.textComponent.text); - __instance.m_TextComponent.text = StringStore.TranslateText(text); - __instance.textComponent.text = StringStore.TranslateText(text); - } - } - }*/ -} diff --git a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs deleted file mode 100644 index 2be83f5..0000000 --- a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs +++ /dev/null @@ -1,33 +0,0 @@ -using HarmonyLib; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.BaseTextObjects -{ - [HarmonyPatch(typeof(TextMeshPro))] - public static class TextMeshPro_Patch - { - [HarmonyPatch(nameof(TextMeshPro.OnEnable))] - [HarmonyPostfix] - private static void OnEnable(TextMeshPro __instance) - { - if (!string.IsNullOrEmpty(__instance.text)) - { - if(__instance.transform.parent.name.Contains("DrawCardsText")) - { - return; - } - else if (__instance.transform.parent.name.StartsWith("AlmanacHelp") || __instance.transform.parent.name.StartsWith("CardBank")) - { - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = false; - return; - } else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant") || __instance.transform.name.Contains("Name") || __instance.transform.name.Contains("Tips") || __instance.transform.parent.name.Contains("Signboard") || __instance.transform.parent.name.Contains("text"))) - { - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = true; - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/AlmanacBuffMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacBuffMenu_Patch.cs deleted file mode 100644 index 968af10..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacBuffMenu_Patch.cs +++ /dev/null @@ -1,100 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Drawing; -using static Il2Cpp.AlmanacBuffMenu; -using static PvZ_Fusion_Translator.FileLoader; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using static PvZ_Fusion_Translator.Utils; -using Unity.VisualScripting; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacBuffMenu))] - public static class AlmanacBuffMenu_Patch - { - [HarmonyPatch(nameof(AlmanacBuffMenu.Awake))] - [HarmonyPostfix] - public static void Post_Awake(AlmanacBuffMenu __instance) - { - foreach(AlmanacCardUI cardUI in __instance.cards) - { - AlmanacBuffMenu.CardInfo cardInfo = __instance.cardInfos[cardUI]; - var buffData = FindBuffData(cardInfo.description); - - if (buffData.Item1 == null || buffData.Item3 == null) continue; - - cardUI.cost.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; - } - - Post_OnCardClick(__instance); - } - - [HarmonyPatch(nameof(AlmanacBuffMenu.SetAllCards))] - [HarmonyPatch(nameof(AlmanacBuffMenu.Start))] - [HarmonyPatch(nameof(AlmanacBuffMenu.InitMenu))] - [HarmonyPostfix] - public static void Post_SetAllCards(AlmanacBuffMenu __instance) - { - foreach(AlmanacCardUI cardUI in __instance.cards) - { - AlmanacBuffMenu.CardInfo cardInfo = __instance.cardInfos[cardUI]; - var buffData = FindBuffData(cardInfo.description); - if (buffData.Item1 == null || buffData.Item3 == null) continue; - - cardUI.cost.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; - } - - Post_OnToolClick(__instance); - - Post_OnCardClick(__instance); - } - - [HarmonyPatch(nameof(AlmanacBuffMenu.OnToolClick))] - [HarmonyPostfix] - public static void Post_OnToolClick(AlmanacBuffMenu __instance) - { - foreach(TextMeshProUGUI txt in __instance.toolButton.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - [HarmonyPatch(nameof(AlmanacBuffMenu.OnCardClick))] - [HarmonyPostfix] - public static void Post_OnCardClick(AlmanacBuffMenu __instance) - { - var buffData = FindBuffData(__instance.buffDescription.text); - - if (buffData.Item1 == null || buffData.Item3 == null) - { - return; - } - - __instance.buffTitle.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; - __instance.buffTitle.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - string buffFStr = StringStore.translationStringRegex.ContainsKey("BUFF_NAME_FORMAT") ? StringStore.translationStringRegex["BUFF_NAME_FORMAT"] : "{0}: {1}"; - string fBuffDesc = string.Format(buffFStr, buffData.Item1, buffData.Item3); - __instance.buffDescription.text = (buffData.Item4) ? fBuffDesc + "\n\n" : buffData.Item3 + "\n\n"; - __instance.buffDescription.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - string colorHex = StringStore.translationString.ContainsKey("MOD_ALMANAC_COL") ? StringStore.TranslateText("MOD_ALMANAC_COL") : "#000000"; - System.Drawing.Color descriptionColor = ColorTranslator.FromHtml(colorHex); - __instance.buffDescription.color = new UnityEngine.Color(descriptionColor.R / 255.0f, descriptionColor.G / 255.0f, descriptionColor.B / 255.0f); - - __instance.buffDescription.fontSizeMax = 18; - __instance.buffDescription.margin = new Vector4(8, 4, 25, 0); - - __instance.buffDescription.enableWordWrapping = true; - __instance.buffDescription.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.buffDescription.ForceMeshUpdate(); - - Post_OnToolClick(__instance); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacCardUI_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacCardUI_Patch.cs deleted file mode 100644 index 9cdf33e..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacCardUI_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacCardUI))] - public static class AlmanacCardUI_Patch - { - [HarmonyPatch(nameof(AlmanacCardUI.Awake))] - [HarmonyPostfix] - public static void Awake(AlmanacCardUI __instance) - { - if (!Utils.CheckForUntranslatedText(__instance.cost.text)) return; - __instance.cost.text = StringStore.TranslateText(__instance.cost.text); - } - - /*[HarmonyPatch(nameof(AlmanacCardUI.OnPointerDown))] - [HarmonyPostfix] - public static void OnPointerDown(AlmanacCardUI __instance) - { - foreach (AlmanacCardUI almanacCardUI in __instance.menu.GetComponentsInChildren()) - { - AlmanacCardUI_Patch.Awake(almanacCardUI); - } - }*/ - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacPlantMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacPlantMenu_Patch.cs deleted file mode 100644 index 39a454d..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacPlantMenu_Patch.cs +++ /dev/null @@ -1,137 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using MelonLoader.TinyJSON; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.Json; -using System.Text.RegularExpressions; -using Unity.Collections; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.UIElements; -using static PvZ_Fusion_Translator.FileLoader; -using static PvZ_Fusion_Translator.Utils; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacPlantMenu))] - public static class AlmanacPlantMenu_Patch - { - public static string almanacJson = ""; - public static Dictionary plantInfoDict = new(); - - [HarmonyPatch(nameof(AlmanacPlantMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AlmanacPlantMenu __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren(true)) - { - bool isPlantName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background"; - if (text.gameObject.name != "Description" && !isPlantName && !text.gameObject.name.Contains("Cost")) - { - text.text = StringStore.TranslateText(text.text); - text.font = font; - text.autoSizeTextContainer = true; - } - } - - foreach (AlmanacCardUI almanacCardUI in __instance.GetComponentsInChildren()) - { - AlmanacCardUI_Patch.Awake(almanacCardUI); - } - - // skin button resize - - AlmanacPlantWindow window = __instance.window; - GameObject skinButton = window.skinButton; - GameObject skinTextObj = skinButton.transform.Find("text_1").gameObject; - skinButton.transform.localScale /= 1.75f; - skinButton.transform.localPosition = new Vector3(0.0f, 111.345f, 0.0f); - skinButton.transform.GetChild(1).Translate(new Vector3(-0.35f, 0)); - skinButton.transform.GetChild(2).Translate(new Vector3(0.35f, 0)); - } - - [HarmonyPatch(nameof(AlmanacPlantMenu.SearchChanged))] - [HarmonyPrefix] - public static bool SearchChanged(AlmanacPlantMenu __instance, ref TMP_InputField inputField) - { - string search = inputField.text; - if (search != StringStore.TranslateText("搜索") && search != "") - { - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - string json = AlmanacPlantMenu_Patch.almanacJson; - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - - AlmanacData plantData = JsonUtility.FromJson(json); - - Il2CppSystem.Collections.Generic.List searchedPlants = new(); - - foreach (PlantInfo plantInfo in plantData.plants) - { - if (plantInfo.name.ToLower().Contains(search.ToLower())) - { - searchedPlants.Add((PlantType)plantInfo.seedType); - } - else if ($"{plantInfo.seedType}".ToLower().StartsWith(search.ToLower())) - { - searchedPlants.Add((PlantType)plantInfo.seedType); - } - } - - __instance.ShowPlants(searchedPlants); - - return false; - } - - return true; - } - - [HarmonyPatch(nameof(AlmanacPlantMenu.ShowPlants), argumentTypes: [typeof(Il2CppSystem.Func)])] - [HarmonyPostfix] - public static void ShowPlants(AlmanacPlantMenu __instance, ref Func condition) - { - foreach (AlmanacCardUI cardUI in __instance.cards) - { - AlmanacCardUI_Patch.Awake(cardUI); - } - } - - [HarmonyPatch(nameof(AlmanacPlantMenu.ClassicMix))] - [HarmonyPostfix] - public static void ClassicMix(AlmanacPlantMenu __instance) - { - foreach (AlmanacCardUI cardUI in __instance.cards) - { - AlmanacCardUI_Patch.Awake(cardUI); - } - } - - public static void LoadPlantAlmanacData(string json) - { - if (json == null) return; - - almanacJson = json; - - var plantData = JsonUtility.FromJson(almanacJson); - - foreach (Il2CppAlmanacData.PlantInfo plantInfo in plantData.plants) - { - if(plantInfoDict.ContainsKey(plantInfo.seedType)) - { - plantInfoDict[plantInfo.seedType] = plantInfo; - } - else - { - plantInfoDict.Add(plantInfo.seedType, plantInfo); - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacPlantWindow_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacPlantWindow_Patch.cs deleted file mode 100644 index b752d26..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacPlantWindow_Patch.cs +++ /dev/null @@ -1,69 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.UI; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacPlantWindow))] - public static class AlmanacPlantWindow_Patch - { - [HarmonyPatch(nameof(AlmanacPlantWindow.UpdateText))] - [HarmonyPostfix] - private static void UpdateText(AlmanacPlantWindow __instance) - { - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); - - string json = AlmanacPlantMenu_Patch.almanacJson; - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey((currentLanguage + "_almanac").ToLower()) || FontStore.fontAssetDictSecondary.ContainsKey((currentLanguage).ToLower())) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - - TMP_FontAsset fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString()); - - AlmanacData plantData = JsonUtility.FromJson(json); - - if(AlmanacPlantMenu_Patch.plantInfoDict.ContainsKey((int)__instance.currentPlantType)) - { - PlantInfo plantInfo = AlmanacPlantMenu_Patch.plantInfoDict[(int)__instance.currentPlantType]; - - foreach (TextMeshProUGUI text in __instance.showedPlantName) - { - text.autoSizeTextContainer = false; - text.text = $"{Utils.RemoveSizeTags(plantInfo.name)} ({plantInfo.seedType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - - char[] toTrim = Environment.NewLine.ToCharArray(); - __instance.showedPlantIntroduce.text = Utils.RemoveSizeTags(plantInfo.info) + "\n\n" + Utils.RemoveSizeTags(plantInfo.introduce) + "\n\n" + Utils.RemoveSizeTags(plantInfo.cost).TrimStart(toTrim) + "\n\n"; - __instance.showedPlantIntroduce.font = fontAsset; - __instance.showedPlantIntroduce.fontSizeMax = 21; - __instance.showedPlantIntroduce.margin = new Vector4(6, 2, 12, 0); - - __instance.showedPlantIntroduce.enableWordWrapping = true; - __instance.showedPlantIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedPlantIntroduce.ForceMeshUpdate(); - - float textHeight = __instance.showedPlantIntroduce.preferredHeight; - __instance.plantTextContent.sizeDelta = new Vector2(__instance.plantTextContent.sizeDelta.x, textHeight); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacSelectMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacSelectMenu_Patch.cs deleted file mode 100644 index c335bb3..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacSelectMenu_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using Unity.Collections; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.UIElements; -using static PvZ_Fusion_Translator.FileLoader; -using static PvZ_Fusion_Translator.Utils; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacSelectMenu))] - public static class AlmanacSelectMenu_Patch - { - public static Dictionary detailStrings = new Dictionary(); - public static Dictionary detailTranslateStrings = new Dictionary(); - - [HarmonyPatch(nameof(AlmanacSelectMenu.Awake))] - [HarmonyPostfix] - public static void Awake(AlmanacSelectMenu __instance) - { - TranslateAlmanacSelectMenu(__instance); - - foreach(UIButton uiButton in __instance.GetComponentsInChildren()) - { - if(uiButton.gameObject.name.Contains("Selection(Clone)")) - { - uiButton.clickEvent.AddListener(new Action(() => { TranslateAlmanacSelectMenu(__instance); })); - } - } - } - - [HarmonyPatch(nameof(AlmanacSelectMenu.InitMenu))] - [HarmonyPostfix] - public static void InitMenu(AlmanacSelectMenu __instance) - { - TranslateAlmanacSelectMenu(__instance); - } - - public static void TranslateAlmanacSelectMenu(AlmanacSelectMenu __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = detailTranslateStrings.ContainsKey(txt.text) ? detailTranslateStrings[txt.text] : StringStore.TranslateText(txt.text); - txt.font = font; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacZombieMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacZombieMenu_Patch.cs deleted file mode 100644 index 17e6a27..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacZombieMenu_Patch.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.UI; -using static PvZ_Fusion_Translator.FileLoader; -using static PvZ_Fusion_Translator.Utils; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacZombieMenu))] - public static class AlmanacZombieMenu_Patch - { - public static string almanacJson = ""; - - [HarmonyPatch(nameof(AlmanacZombieMenu.Start))] - [HarmonyPostfix] - private static void Start(AlmanacZombieMenu __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren(true)) - { - if (text.gameObject.name.Contains("Cost")) continue; - - bool isZombieName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background"; - if (text.gameObject.name != "Description" && !isZombieName) - { - text.text = StringStore.TranslateText(text.text); - text.font = font; - text.autoSizeTextContainer = true; - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/AlmanacZombieWindow_Patch.cs b/MelonLoader/Patches/GameObjects/AlmanacZombieWindow_Patch.cs deleted file mode 100644 index 49a4852..0000000 --- a/MelonLoader/Patches/GameObjects/AlmanacZombieWindow_Patch.cs +++ /dev/null @@ -1,77 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.UI; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(AlmanacZombieWindow))] - public static class AlmanacZombieWindow_Patch - { - [HarmonyPatch(nameof(AlmanacZombieWindow.UpdateText))] - [HarmonyPostfix] - private static void UpdateText(AlmanacZombieWindow __instance) - { - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - - string json = AlmanacZombieMenu_Patch.almanacJson; - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey((currentLanguage + "_almanac").ToLower()) || FontStore.fontAssetDictSecondary.ContainsKey((currentLanguage).ToLower())) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - - TMP_FontAsset fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString()); - - Il2CppAlmanacData.AlmanacData zombieAlmanacData = JsonUtility.FromJson(json); - var zombieDataDic = ZombieDataManager.zombieDataDic; - - foreach (Il2CppAlmanacData.ZombieInfo zombieInfo in zombieAlmanacData.zombies) - { - if (zombieInfo.theZombieType == __instance.currentZombieType) - { - foreach (TextMeshProUGUI text in __instance.showedZombieName) - { - text.autoSizeTextContainer = false; - text.text = $"{Utils.RemoveSizeTags(zombieInfo.name)} ({(int)zombieInfo.theZombieType})"; - text.font = fontAsset; - text.fontSizeMax = 21; - } - - ZombieDataManager.ZombieData zombieData = zombieDataDic[__instance.currentZombieType]; - - string spawnInfo = ""; - string spawnInfoFormat = StringStore.translationStringRegex.ContainsKey("出怪等级: (\\d+)\n出怪权重: (\\d+)") ? StringStore.translationStringRegex["出怪等级: (\\d+)\n出怪权重: (\\d+)"] : null; - if(spawnInfoFormat != null) - { - spawnInfo = string.Format(spawnInfoFormat, [zombieData.summonLevel, zombieData.summonWeight]) + "\n\n"; - } - - __instance.showedZombieIntroduce.text = Utils.RemoveSizeTags(zombieInfo.info) + "\n\n" + spawnInfo + Utils.RemoveSizeTags(zombieInfo.introduce) + "\n\n"; - __instance.showedZombieIntroduce.font = fontAsset; - __instance.showedZombieIntroduce.fontSizeMax = 21; - __instance.showedZombieIntroduce.margin = new Vector4(3, 2, 12, 0); - - __instance.showedZombieIntroduce.enableWordWrapping = true; - __instance.showedZombieIntroduce.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - __instance.showedZombieIntroduce.ForceMeshUpdate(); - - float textHeight = __instance.showedZombieIntroduce.preferredHeight; - __instance.zombieTextContent.sizeDelta = new Vector2(__instance.zombieTextContent.sizeDelta.x, textHeight); - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/Almanac_Patch.cs b/MelonLoader/Patches/GameObjects/Almanac_Patch.cs deleted file mode 100644 index d1e2885..0000000 --- a/MelonLoader/Patches/GameObjects/Almanac_Patch.cs +++ /dev/null @@ -1,54 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; -using Unity.VisualScripting; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(Almanac))] - public static class Almanac_Patch - { - [HarmonyPatch(nameof(Almanac.Awake))] - [HarmonyPostfix] - private static void Awake(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - } - - /*[HarmonyPatch(nameof(Almanac.OldAlmanac))] - [HarmonyPostfix] - private static void OldAlmanac(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - }*/ - - [HarmonyPatch(nameof(Almanac.AnimSwitch))] - [HarmonyPostfix] - private static void AnimSwitch(Almanac __instance) - { - TranslateAlmanacMenu(__instance); - } - - public static void TranslateAlmanacMenu(Almanac __instance) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - if (text.gameObject.name.Contains("Cost")) continue; - - if(text.text == "关闭") - { - text.text = StringStore.TranslateText("合上"); - } - else - { - text.text = StringStore.TranslateText(text.text); - } - text.font = font; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs deleted file mode 100644 index 49c2fa3..0000000 --- a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs +++ /dev/null @@ -1,67 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using static MelonLoader.MelonLogger; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(BaseMenu))] - public static class BaseMenu_Patch - { - [HarmonyPatch(nameof(BaseMenu.Awake))] - [HarmonyPrefix] - private static void Pre_Awake(BaseMenu __instance) - { - if(__instance.name.Contains("NoticePauseMenu")) - { - NoticePauseMenu_Patch.Pre_Awake(__instance); - } - } - - [HarmonyPatch(nameof(BaseMenu.Awake))] - [HarmonyPostfix] - private static void Post_Awake(BaseMenu __instance) - { - if(__instance.name.Contains("NoticePauseMenu")) - { - NoticePauseMenu_Patch.Post_Awake(__instance); - } - - if(__instance.name.StartsWith("MainMenu(Clone)")) - { - MainMenu_Patch.AnimOver(__instance); - } - - if(__instance.name.StartsWith("PlantDamageMenu")) - { - PlantDamageMenu_Patch.Awake(__instance); - } - - TranslateBaseMenuTransform(__instance, "Level"); - TranslateBaseMenuTransform(__instance, "Levels"); - TranslateBaseMenuTransform(__instance, "CustomLevel"); - - StringStore.TranslateTextTransform(__instance.transform.Find("Goback")); - StringStore.TranslateTextTransform(__instance.transform.Find("Switich")); - } - - public static void TranslateBaseMenuTransform(BaseMenu __instance, string levelsName) - { - Transform levels = __instance.transform.Find(levelsName); - if (levels != null) - { - List children = levels.GetComponentsInChildren(true).ToList(); - foreach (Transform child in children) - { - if (child.name == "Nextpage" || child.name == "LastPage" || child.name == "BackToIndex") - { - StringStore.TranslateTextTransform(child); - } - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/Board_Patch.cs b/MelonLoader/Patches/GameObjects/Board_Patch.cs deleted file mode 100644 index 328e768..0000000 --- a/MelonLoader/Patches/GameObjects/Board_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(Board))] - public static class Board_Patch - { - [HarmonyPatch(nameof(Board.Update))] - [HarmonyPostfix] - private static void Update(Board __instance) - { - foreach (SpriteRenderer spriteRenderer in __instance.GetComponentsInChildren()) - { - if (spriteRenderer.sprite != null) - { - if (TextureStore.spriteDict.ContainsKey(spriteRenderer.sprite.name) && spriteRenderer.drawMode != SpriteDrawMode.Sliced) - { - spriteRenderer.drawMode = SpriteDrawMode.Sliced; - } - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs deleted file mode 100644 index 1238676..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(Advanture_Btn))] - public static class Advanture_Btn_Patch - { - [HarmonyPatch(nameof(Advanture_Btn.Start))] - [HarmonyPostfix] - private static void Start(Advanture_Btn __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs deleted file mode 100644 index 621e118..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - //[HarmonyPatch(typeof(BackToIndex))] - //public class BackToIndex_Patch - // { - // [HarmonyPostfix] - // [HarmonyPatch(nameof(BackToIndex.Awake))] - // public static void Awake(BackToIndex __instance) - // { - // StringStore.TranslateTextTransform(__instance.transform.GetChild(0)); - // } - //} -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs deleted file mode 100644 index ed70973..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(CustomLevelEnter))] - public static class CustomLevelEnter_Patch - { - [HarmonyPatch(nameof(CustomLevelEnter.Start))] - [HarmonyPostfix] - private static void Start(CustomLevelEnter __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = (StringStore.translationString.ContainsKey(originalKey + "_IZ")) ? StringStore.TranslateText(originalKey + "_IZ") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs deleted file mode 100644 index 1e7e111..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(ExploreMakeSceneButton))] - public class ExploreMakeSceneButton_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ExploreMakeSceneButton.Start))] - public static void Start(ExploreMakeSceneButton __instance) - { - __instance.sceneText.text = (StringStore.translationString.ContainsKey(__instance.sceneText.text + "_FS")) ? StringStore.TranslateText(__instance.sceneText.text + "_FS") : StringStore.TranslateText(__instance.sceneText.text); - __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs deleted file mode 100644 index 49d638f..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(ExploreMakeZombieButton))] - public class ExploreMakeZombieButton_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ExploreMakeZombieButton.Start))] - public static void Start(ExploreMakeZombieButton __instance) - { - __instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType); - __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs deleted file mode 100644 index 6964c15..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(GodShootingLevelButton))] - public static class GodShootingLevelButton_Patch - { - [HarmonyPatch(nameof(GodShootingLevelButton.Awake))] - [HarmonyPostfix] - private static void Awake(GodShootingLevelButton __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = (StringStore.translationString.ContainsKey(originalKey + "_GS")) ? StringStore.TranslateText(originalKey + "_GS") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs deleted file mode 100644 index 62b7911..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs +++ /dev/null @@ -1,41 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(InGameBtn))] - public static class InGameBtn_Patch - { - [HarmonyPatch(nameof(InGameBtn.Start))] - [HarmonyPostfix] - private static void Start(InGameBtn __instance) - { - Transform sceneText = __instance.transform.FindChild("SceneText"); - if(sceneText != null) - { - TextMeshProUGUI sceneTextTMP = sceneText.transform.GetComponent(); - if(sceneTextTMP != null) - { - sceneTextTMP = AssetStore.StringStore.TranslateText(sceneTextTMP); - } - Transform sceneTextShadow = sceneText.transform.FindChild("SceneText"); - if(sceneTextShadow != null) - { - TextMeshProUGUI sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); - if (sceneTextShadowTMP != null) - { - sceneTextShadowTMP = AssetStore.StringStore.TranslateText(sceneTextShadowTMP); - } - } - } - - foreach(TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs deleted file mode 100644 index 86a42f0..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - public static class LevelSaveEnter_Patch - { - public static void TranslateEnter(LevelSaveEnter __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.text.text = StringStore.TranslateText(__instance.text.text); - __instance.text.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs deleted file mode 100644 index 097df1f..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using UnityEngine; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(MainMenu_Btn))] - public static class MainMenu_Btn_Patch - { - //public static List speechBubbles = new List(); - - //[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))] - //[HarmonyPostfix] - //private static void OnMouseEnter(MainMenu_Btn __instance) - //{ - // string textToShow = null; - - // if(__instance.transform.parent.name == "recipe") - // { - // textToShow = "探索模式"; - // } - // else if (__instance.name == "mysterious") - // { - // textToShow = "神秘模式"; - // } - - // if(textToShow != null) - // { - // InGameText.Instance.ShowText(textToShow, 2.0f); - // } - // } - } - -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs deleted file mode 100644 index 8ccfcf0..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(NormalBtn))] - public class NormalBtn_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))] - public static void OnMouseUpAsButton(NormalBtn __instance) - { - if(__instance.transform.childCount > 0) - { - Transform banTransform = __instance.transform.GetChild(0); - if (banTransform != null) - { - banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs deleted file mode 100644 index 45d94df..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs +++ /dev/null @@ -1,393 +0,0 @@ -#if MULTI_LANGUAGE -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.UIElements; -using static MelonLoader.MelonLogger; -using Object = UnityEngine.Object; - -public class OptionButtonData -{ - public OptionBtn Button { get; set; } - public Vector3 Position { get; set; } - 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 shifted = false; -} - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - internal class OptLanguageBtn_Patch - { - public static Dictionary LanguageBtnDict = new(); - public static Dictionary ToggleBtnDict = new(); - private static bool buttonsCreated = false; - private static bool togglesCreated = false; - private static OptionBtn cachedTemplateButton; - private static OptionBtn cachedTemplateToggleButton; - - private const float startX = 4.3241f + 2.56f; - private const float startY = 2.7769f; - private const float ySpacing = 1.2505f; - - private const float toggleStartX = 4.3241f; - private const float toggleStartY = -0.9746f; - - private static List AvailableLanguages; - private static List AvailableToggles; - private const int LanguagesPerPage = 5; - private static int currentPage = 0; - public static OptionBtn[] buttonSlots = new OptionBtn[6]; // 5 language buttons + 1 next button - public static OptionBtn[] toggleSlots = new OptionBtn[3]; - - public static void CreateLanguageButtons(OptionBtn templateButton) - { - if (buttonsCreated) return; - buttonsCreated = true; - cachedTemplateButton = templateButton; - - AvailableLanguages = Enum.GetValues(typeof(Utils.LanguageEnum)) - .Cast() - .Where(lang => lang != Utils.LanguageEnum.LANG_END) - .ToList(); - - for (int i = 0; i < 6; i++) - { - var newButton = Object.Instantiate(templateButton, templateButton.transform.parent); - newButton.tag = "LangOpt"; - foreach(Transform child in newButton.GetComponentsInChildren()) - { - child.tag = "LangOpt"; - } - newButton.optionType = 80 + i; - - float yPos = startY - i * ySpacing; - Vector3 pos = new(startX, yPos); - newButton.transform.position = pos; - - buttonSlots[i] = newButton; - - LanguageBtnDict[newButton.GetInstanceID()] = new OptionButtonData - { - Button = newButton, - Position = pos - }; - } - - UpdatePage(); - } - - public static void CreateToggleButtons(OptionBtn templateButton) - { - if (togglesCreated) return; - togglesCreated = true; - cachedTemplateToggleButton = templateButton; - - AvailableToggles = Enum.GetValues(typeof(Utils.ToggleEnum)) - .Cast() - .Where(lang => lang != Utils.ToggleEnum.TOGGLE_END) - .ToList(); - - for (int i = 0; i < 3; i++) - { - var newButton = Object.Instantiate(templateButton, templateButton.transform.parent); - newButton.tag = "LangOpt"; - foreach(Transform child in newButton.GetComponentsInChildren()) - { - child.tag = "LangOpt"; - } - 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() - { - int startIndex = currentPage * LanguagesPerPage; - int langCount = AvailableLanguages.Count; - int toggleCount = (togglesCreated) ? AvailableToggles.Count : 0; - - for (int i = 0; i < 5; i++) - { - var btn = buttonSlots[i]; - var data = LanguageBtnDict[btn.GetInstanceID()]; - - if (startIndex + i < langCount) - { - var lang = AvailableLanguages[startIndex + i]; - data.Language = lang; - data.IsNextButton = false; - btn.gameObject.SetActive(true); - - string languageName = Utils.LanguageNames.ContainsKey(lang) ? Utils.LanguageNames[lang] : lang.ToString(); - UpdateButtonText(btn, languageName, FontStore.LoadTMPFont(lang.ToString())); - } - else - { - data.Language = null; - data.IsNextButton = false; - btn.gameObject.SetActive(false); - } - } - - if (togglesCreated) - { - for (int i = 0; i < 3; 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); - string buttonText = Utils.ToggleNames.ContainsKey(toggle) ? Utils.ToggleNames[toggle] : toggle.ToString(); - UpdateButtonText(btn, StringStore.TranslateText(buttonText), FontStore.LoadTMPFont(Utils.Language.ToString())); - string sourceMsg = ""; - switch(i) - { - case 0: - sourceMsg = "" + (!(Utils.customTextures) ? "Texture Source:\nDefault" : "Texture Source:\nCustom"); - FlashMessage(btn, sourceMsg, 0.1f, false); - break; - case 1: - sourceMsg = "" + (!(Utils.customAudio) ? "Audio Source:\nDefault" : "Audio Source:\nCustom"); - FlashMessage(btn, sourceMsg, 0.1f, false); - break; - case 2: - sourceMsg = "" + (!(Utils.useLocal) ? "Translation Source:\nOnline" : "Translation Source:\nLocal"); - FlashMessage(btn, sourceMsg, 0.1f, false); - break; - default: - break; - } - } - else - { - data.Language = null; - data.IsNextButton = false; - btn.gameObject.SetActive(false); - } - } - } - - // "Next" button always visible at index 5 - var nextBtn = buttonSlots[5]; - var nextData = LanguageBtnDict[nextBtn.GetInstanceID()]; - nextData.Language = null; - nextData.IsNextButton = true; - nextBtn.gameObject.SetActive(true); - UpdateButtonText(nextBtn, "Next"); - } - - public static void UpdateButtonText(OptionBtn button, string languageName, TMP_FontAsset fontAsset = null) - { - TMP_FontAsset defaultAsset = FontStore.LoadTMPFont("English"); - - for (int i = 0; i < 3; i++) - { - Transform textTransform = button.transform.GetChild(i); - if (textTransform != null) - { - if (i == 0) textTransform.gameObject.SetActive(false); - - TextMeshProUGUI text = textTransform.GetComponent(); - if (text != null) - { - if (i == 0) - { - text.text = ""; - text.color = Color.red; - } - else - { - text.text = languageName; - } - text.fontSize = 16; - text.font = (fontAsset != null) ? fontAsset : defaultAsset; - text.autoSizeTextContainer = false; - } - } - } - } - - public static void FlashMessage(OptionBtn button, string message, float yShift = 0.0f, bool useTimer = true) - { - var child = button.transform.GetChild(0); - if (child != null) - { - var text = child.GetComponent(); - string originalMsg = ""; - if (text != null) - { - originalMsg = text.text; - 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); - - if(useTimer) - { - System.Threading.Tasks.Task.Delay(1000).ContinueWith(_ => - { - if (button != null && child != null && child.gameObject.activeSelf) - { - OptionButtonData buttonData = ToggleBtnDict[button.GetInstanceID()]; - if(buttonData.Toggle != null) - { - string sourceMsg = originalMsg; - switch(buttonData.Toggle) - { - case Utils.ToggleEnum.Textures: - sourceMsg = "" + (!(Utils.customTextures) ? "Texture Source:\nDefault" : "Texture Source:\nCustom"); - break; - case Utils.ToggleEnum.Audio: - sourceMsg = "" + (!(Utils.customAudio) ? "Audio Source:\nDefault" : "Audio Source:\nCustom"); - break; - default: - break; - } - text.text = sourceMsg; - } - - } - }); - } - } - } - - private static void ToggleCustomAssets(string type) - { - if (type != "Textures" && type != "Audio" && type != "SwapLocal") return; - - if(type == "Textures") - { - Utils.customTextures = !Utils.customTextures; - MelonPreferences.SetEntryValue("PvZ_Fusion_Translator", "DefaultTextures", !Utils.customTextures); - TextureStore.Reload(); - object replaceTextureRoutine = MelonCoroutines.Start(TextureStore.ReplaceTexturesCoroutine()); - } - - if (type == "Audio") - { - Utils.customAudio = (Utils.customAudio) ? false : true; - MelonPreferences.SetEntryValue("PvZ_Fusion_Translator", "DefaultAudio", !Utils.customAudio); - } - - if (type == "SwapLocal") - { - Utils.WarnLocalData(); - } - - MelonPreferences.Save(); - } - - [HarmonyPatch(typeof(OptionBtn))] - public static class OptLangBtn_Patch - { - public static void Awake(OptionBtn __instance) - { - if (!buttonsCreated || cachedTemplateButton == null) - { - buttonsCreated = false; - togglesCreated = false; - CreateLanguageButtons(__instance); - CreateToggleButtons(__instance); - } - } - - [HarmonyPatch("OnMouseUpAsButton")] - [HarmonyPrefix] - private static void OnMouseUpAsButton(OptionBtn __instance) - { - if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) - { - if (btnData.IsNextButton) - { - currentPage = (currentPage + 1) % (int)Math.Ceiling((float)AvailableLanguages.Count / LanguagesPerPage); - UpdatePage(); - return; - } - - if (btnData.Language is Utils.LanguageEnum selectedLang) - { - string currentLang = Utils.Language.ToString(); - - if (currentLang == selectedLang.ToString()) - { - FlashMessage(btnData.Button, "Already Selected!"); - } - else - { - Utils.ChangeLanguage(selectedLang.ToString()); - Debug.Log($"Language changed to: {selectedLang}"); - FlashMessage(btnData.Button, "Language Changed!"); - } - } - } - - if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) - { - string toggleType = toggleData.Toggle.ToString(); - ToggleCustomAssets(toggleType); - if (toggleType == "Textures") - { - FlashMessage(toggleData.Button, "Toggled custom textures!\n(Restart Required)", 0.1f); - } - else if (toggleType == "Audio") - { - FlashMessage(toggleData.Button, "Toggled custom audio!", 0.1f); - } - } - } - - [HarmonyPatch(nameof(OptionBtn.Update))] - [HarmonyPostfix] - private static void Update(OptionBtn __instance) - { - if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) - { - btnData.Button.transform.position = btnData.Position; - } - - if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) - { - toggleData.Button.transform.position = toggleData.Position; - } - } - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs deleted file mode 100644 index e4d1e07..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs +++ /dev/null @@ -1,69 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(OptionBtn))] - public static class OptionBtn_Patch - { - [HarmonyPatch(nameof(OptionBtn.Awake))] - [HarmonyPostfix] - private static void Awake(OptionBtn __instance) - { - Transform text_1Transform = __instance.transform.GetChild(0)?.transform; - if (text_1Transform != null) - { - TextMeshProUGUI text_1 = text_1Transform.GetComponent(); - text_1 = StringStore.TranslateText(text_1); - text_1.autoSizeTextContainer = false; - } - - Transform textTransform = __instance.transform.GetChild(1)?.transform; - if (textTransform != null) - { - TextMeshProUGUI text = textTransform.GetComponent(); - text = StringStore.TranslateText(text); - text.autoSizeTextContainer = false; - } - - Transform text2Transform = __instance.transform.GetChild(2)?.transform; - if (text2Transform != null) - { - TextMeshProUGUI text2 = text2Transform.GetComponent(); - text2 = StringStore.TranslateText(text2); - text2.autoSizeTextContainer = false; - } - } - - [HarmonyPatch("OnMouseUpAsButton")] - [HarmonyPostfix] - private static void OnMouseUpAsButtonPostfix(OptionBtn __instance) - { - Transform text_1Transform = __instance.transform.GetChild(0)?.transform; - if (text_1Transform != null) - { - TextMeshProUGUI text_1 = text_1Transform.GetComponent(); - text_1 = StringStore.TranslateText(text_1); - text_1.autoSizeTextContainer = false; - } - - Transform textTransform = __instance.transform.GetChild(1)?.transform; - if (textTransform != null) - { - TextMeshProUGUI text = textTransform.GetComponent(); - text = StringStore.TranslateText(text); - text.autoSizeTextContainer = false; - } - - Transform text2Transform = __instance.transform.GetChild(2)?.transform; - if (text2Transform != null) - { - TextMeshProUGUI text2 = text2Transform.GetComponent(); - text2 = StringStore.TranslateText(text2); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs deleted file mode 100644 index 2dfd98e..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs +++ /dev/null @@ -1,43 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppPVPScaryPot; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - /*[HarmonyPatch(typeof(PVPPotBtn))] - public class PVPPotBtn_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(PVPPotBtn.OnMouseUpAsButton))] - public static void OnMouseUpAsButton(PVPPotBtn __instance) - { - Transform sceneText = __instance.transform.FindChild("text"); - if(sceneText != null) - { - TextMeshProUGUI sceneTextTMP = sceneText.transform.GetComponent(); - if(sceneTextTMP != null) - { - sceneTextTMP.text = StringStore.TranslateText(sceneTextTMP.text); - } - } - Transform sceneTextShadow = sceneText.transform.FindChild("text_1"); - if(sceneTextShadow != null) - { - TextMeshProUGUI sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); - if (sceneTextShadowTMP != null) - { - sceneTextShadowTMP.text = StringStore.TranslateText(sceneTextShadowTMP.text); - } - } - - if (__instance.name.Equals("ChangeBg_3") || __instance.name.Equals("ChangeBg_4")) - { - __instance.gameObject.SetActive(false); - __instance.gameObject.SetActive(true); - } - } - }*/ -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs deleted file mode 100644 index 501706f..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs +++ /dev/null @@ -1,15 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(PauseMenu_Btn))] - public static class PauseMenu_Btn_Patch - { - [HarmonyPatch(nameof(PauseMenu_Btn.Start))] - [HarmonyPostfix] - private static void Start(PauseMenu_Btn __instance) => StringStore.TranslateTextTransform(__instance.transform); - } - -} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs deleted file mode 100644 index f9b16ac..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -#if FIX -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(SaveMenuBtn))] - public static class SaveMenuBtn_Patch - { - [HarmonyPatch(nameof(SaveMenuBtn.OnMouseUpAsButton))] - [HarmonyPostfix] - private static void OnMouseUpAsButton(SaveMenuBtn __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.theName.text = StringStore.TranslateText(__instance.theName.text); - __instance.theName.font = fontAsset; - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs deleted file mode 100644 index 4afc43c..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; -//using UnityEngine.UI; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(UIBtn))] -// public static class UIBtn_Patch -// { -// [HarmonyPatch(nameof(UIBtn.Awake))] -// [HarmonyPostfix] -// private static void Postfix_Awake(UIBtn __instance) -// { -// if(__instance.TryGetComponent(out BackToIndex component)) -// { -// Utils.ConvertButtonText(__instance.transform.parent, component.name); -// } -// } -// } -//} diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs deleted file mode 100644 index 515f9d8..0000000 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.UI; -using UnityEngine.UIElements; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIButton))] - public static class UIButton_Patch - { - [HarmonyPatch(typeof(UIButton), nameof(UIButton.Start))] - [HarmonyPostfix] - public static void Start(UIButton __instance) - { - if(__instance.transform.childCount >= 2) - { - TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - if (__instance.transform.name == "Goback") - { - text.text = "合上"; - } - text.text = StringStore.TranslateText(text.text); - text.font = font; - } - } - else - { - StringStore.TranslateTextTransform(__instance.transform); - if(__instance.transform.name == "Goback") - { - foreach(TextMeshProUGUI text in __instance.transform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - } - } - - [HarmonyPatch(nameof(UIButton.OnMouseUpAsButton))] - [HarmonyPostfix] - public static void Postfix_OnMouseUpAsButton(UIButton __instance) - { - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/Close_Patch.cs b/MelonLoader/Patches/GameObjects/Close_Patch.cs deleted file mode 100644 index fb6ff9a..0000000 --- a/MelonLoader/Patches/GameObjects/Close_Patch.cs +++ /dev/null @@ -1,53 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(Close))] - public static class Close_Patch - { - [HarmonyPatch(nameof(Close.Start))] - [HarmonyPostfix] - private static void Close_Start(Close __instance) - { - - TextMeshPro closeText = __instance.transform.GetChild(0).GetComponent(); - closeText.text = "合上"; - closeText = StringStore.TranslateText(closeText); - closeText.autoSizeTextContainer = true; - - Transform AlmanacTransform = __instance.transform.parent.transform; - - Transform nameTransform = AlmanacTransform.Find("Name"); - if (nameTransform != null) - { - TextMeshPro nameTMP = nameTransform.transform.GetComponent(); - if (nameTMP) - { - nameTMP = StringStore.TranslateText(nameTMP); - nameTMP.autoSizeTextContainer = true; - } - - Transform nameShadowTransform = nameTransform.Find("NameShadow"); - if (nameShadowTransform) - { - TextMeshPro nameShadowTMP = nameShadowTransform.transform.GetComponent(); - if (nameShadowTMP) - { - nameShadowTMP = StringStore.TranslateText(nameShadowTMP); - nameShadowTMP.autoSizeTextContainer = true; - } - } - } - - StringStore.TranslateTextTransform(AlmanacTransform.Find("Back"), true); - StringStore.TranslateTextTransform(AlmanacTransform.Find("NextPage")); - StringStore.TranslateTextTransform(AlmanacTransform.Find("LastPage")); - - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ConfirmMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ConfirmMenu_Patch.cs deleted file mode 100644 index 6dc92b7..0000000 --- a/MelonLoader/Patches/GameObjects/ConfirmMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ConfirmMenu))] - public static class ConfirmMenu_Patch - { - [HarmonyPatch(nameof(ConfirmMenu.SetTitle))] - [HarmonyPostfix] - private static void SetTitle(ConfirmMenu __instance) - { - foreach(TextMeshProUGUI title in __instance.title) - { - title.text = StringStore.TranslateText(title.text); - title.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs b/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs deleted file mode 100644 index 9bef668..0000000 --- a/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(CrisisZombieWindow))] - public static class CrisisZombieWindow_Patch - { - [HarmonyPatch(nameof(CrisisZombieWindow.Start))] - [HarmonyPostfix] - private static void Start(CrisisZombieWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(CrisisZombieWindow.SetZombieType))] - [HarmonyPostfix] - private static void SetZombieType(CrisisZombieWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/CustomSettings_Patch.cs b/MelonLoader/Patches/GameObjects/CustomSettings_Patch.cs deleted file mode 100644 index 18ee55a..0000000 --- a/MelonLoader/Patches/GameObjects/CustomSettings_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using PvZ_Fusion_Translator.AssetStore; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(CustomSettings))] -// public static class CustomSettings_Patch -// { -// [HarmonyPatch(nameof(CustomSettings.Awake))] -// [HarmonyPostfix] -// private static void Awake(CustomSettings __instance) -// { -// __instance.textMesh = StringStore.TranslateText(__instance.textMesh); -// } - -// [HarmonyPatch(nameof(CustomSettings.ChangeText))] -// [HarmonyPostfix] -// private static void ChangeText(CustomSettings __instance) -// { -// __instance.textMesh = StringStore.TranslateText(__instance.textMesh); -// } -// } -//} diff --git a/MelonLoader/Patches/GameObjects/CustomSun_Patch.cs b/MelonLoader/Patches/GameObjects/CustomSun_Patch.cs deleted file mode 100644 index 5d71423..0000000 --- a/MelonLoader/Patches/GameObjects/CustomSun_Patch.cs +++ /dev/null @@ -1,46 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(CustomSun))] - public static class CustomSun_Patch - { - [HarmonyPatch(nameof(CustomSun.Awake))] - [HarmonyPostfix] - private static void Awake(CustomSun __instance) - { - if (__instance.inputField.gameObject.activeSelf) - { - string oriTextSun = __instance.inputField.m_Text; - __instance.inputField.gameObject.SetActive(false); - __instance.inputField.m_Text = StringStore.TranslateText(oriTextSun); - __instance.inputField.m_OriginalText = StringStore.TranslateText(oriTextSun); - __instance.inputField.gameObject.SetActive(true); - } - - if (__instance.setFlags.gameObject.activeSelf) - { - string oriTextFlags = __instance.setFlags.m_Text; - __instance.setFlags.gameObject.SetActive(false); - __instance.setFlags.m_Text = StringStore.TranslateText(oriTextFlags); - __instance.setFlags.m_OriginalText = StringStore.TranslateText(oriTextFlags); - __instance.setFlags.gameObject.SetActive(true); - } - - Transform lookZombieTransform = __instance.lookZombie.transform.GetChild(0).transform; - if (lookZombieTransform != null) - { - TextMeshProUGUI lookZombieTMP = lookZombieTransform.GetComponent(); - if (lookZombieTMP != null) - { - lookZombieTMP = StringStore.TranslateText(lookZombieTMP); - } - } - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/EveBuffMenu_Patch.cs b/MelonLoader/Patches/GameObjects/EveBuffMenu_Patch.cs deleted file mode 100644 index 51725ab..0000000 --- a/MelonLoader/Patches/GameObjects/EveBuffMenu_Patch.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(EveBuffMenu))] - public static class EveBuffMenu_Patch - { - [HarmonyPatch(nameof(EveBuffMenu.Start))] - [HarmonyPostfix] - private static void Start(EveBuffMenu __instance) - { - foreach (EveOptionWindow window in __instance.windows) - { - EveOptionWindow_Patch.TranslateEveOptionWindow(window); - } - - foreach (TextMeshProUGUI text in __instance.quitButton.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - - [HarmonyPatch(nameof(EveBuffMenu.InitWindows))] - [HarmonyPostfix] - private static void InitWindows(EveBuffMenu __instance) - { - foreach(EveOptionWindow window in __instance.windows) - { - EveOptionWindow_Patch.TranslateEveOptionWindow(window); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/EveOptionWindow_Patch.cs b/MelonLoader/Patches/GameObjects/EveOptionWindow_Patch.cs deleted file mode 100644 index 3d0a4c0..0000000 --- a/MelonLoader/Patches/GameObjects/EveOptionWindow_Patch.cs +++ /dev/null @@ -1,50 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(EveOptionWindow))] - public static class EveOptionWindow_Patch - { - [HarmonyPatch(nameof(EveOptionWindow.SetType))] - [HarmonyPostfix] - private static void SetType(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - [HarmonyPatch(nameof(EveOptionWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - [HarmonyPatch(nameof(EveOptionWindow.SelectedByRow))] - [HarmonyPostfix] - private static void SelectedByRow(EveOptionWindow __instance) - { - TranslateEveOptionWindow(__instance); - } - - public static void TranslateEveOptionWindow(EveOptionWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - - foreach (TextMeshProUGUI text in __instance.buttonText) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ExploreEnterWindow_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreEnterWindow_Patch.cs deleted file mode 100644 index 648d2e2..0000000 --- a/MelonLoader/Patches/GameObjects/ExploreEnterWindow_Patch.cs +++ /dev/null @@ -1,73 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreEnterWindow))] - public static class ExploreEnterWindow_Patch - { - [HarmonyPatch(nameof(ExploreEnterWindow.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - - if(__instance.nameText.text == "") - { - StringStore.TranslateText(__instance.nameText.text); - } - - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))] - [HarmonyPostfix] - private static void SetInfo(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - - if (__instance.nameText.text == "") - { - StringStore.TranslateText(__instance.nameText.text); - } - - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetIcon))] - [HarmonyPostfix] - private static void SetIcon(ExploreEnterWindow __instance) - { - PlantType thePlantType = (PlantType)__instance.selfType; - - __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); - - if (__instance.nameText.text == "") - { - StringStore.TranslateText(__instance.nameText.text); - } - - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ExploreEnterWindow.SetDisable))] - [HarmonyPostfix] - private static void SetDisable(ExploreEnterWindow __instance) - { - if (__instance.disabled) - { - __instance.nameText.text = StringStore.TranslateText("敬请期待"); - } - - __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs deleted file mode 100644 index 4116c29..0000000 --- a/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs +++ /dev/null @@ -1,72 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreMakeMenu))] - public static class ExploreMakeMenu_Patch - { - [HarmonyPatch(nameof(ExploreMakeMenu.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.InitMenu))] - [HarmonyPostfix] - private static void InitMenu(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if(txt.text.Contains("关卡制作中:")) - { - string plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]); - txt.text = String.Format(StringStore.translationStringRegex["关卡制作中:([^\\s]+)"], plantName); - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.ViewScene))] - [HarmonyPostfix] - private static void ViewScene(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons))] - [HarmonyPostfix] - private static void InitZombieButtons(ExploreMakeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs deleted file mode 100644 index 63a4f66..0000000 --- a/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System.Numerics; -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ExploreMenu))] - public static class ExploreMenu_Patch - { - [HarmonyPatch(nameof(ExploreMenu.Awake))] - [HarmonyPostfix] - private static void Awake(ExploreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - } - - Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel"); - } - - [HarmonyPatch(nameof(ExploreMenu.UpdateWindows))] - [HarmonyPostfix] - private static void UpdateWindows(ExploreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs b/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs deleted file mode 100644 index b04fd27..0000000 --- a/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(FruitNinjaSelectWindow))] - public static class FruitNinjaSelectWindow_Patch - { - [HarmonyPatch(nameof(FruitNinjaSelectWindow.SetType))] - [HarmonyPostfix] - private static void SetType(FruitNinjaSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(FruitNinjaSelectWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(FruitNinjaSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/GardenPlant_Patch.cs b/MelonLoader/Patches/GameObjects/GardenPlant_Patch.cs deleted file mode 100644 index 92ad5ec..0000000 --- a/MelonLoader/Patches/GameObjects/GardenPlant_Patch.cs +++ /dev/null @@ -1,29 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using Il2CppZenGarden; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(GardenPlant))] - public static class GardenPlant_Patch - { - [HarmonyPatch(nameof(GardenPlant.Start))] - [HarmonyPostfix] - private static void Start(GardenPlant __instance) - { - __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); - } - - [HarmonyPatch(nameof(GardenPlant.UpdateInfo))] - [HarmonyPostfix] - private static void UpdateInfo(GardenPlant __instance) - { - - __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/GardenStoreMenu_Patch.cs b/MelonLoader/Patches/GameObjects/GardenStoreMenu_Patch.cs deleted file mode 100644 index fcb586d..0000000 --- a/MelonLoader/Patches/GameObjects/GardenStoreMenu_Patch.cs +++ /dev/null @@ -1,40 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppAlmanacData; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Drawing; -using Il2CppZenGarden; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(GardenStoreMenu))] - public static class GardenStoreMenu_Patch - { - [HarmonyPatch(nameof(GardenStoreMenu.InitGoodsList))] - [HarmonyPatch(nameof(GardenStoreMenu.GetDatas))] - [HarmonyPatch(nameof(GardenStoreMenu.PurchaseGoods))] - [HarmonyPatch(nameof(GardenStoreMenu.Update))] - [HarmonyPatch(nameof(GardenStoreMenu.Start))] - [HarmonyPostfix] - public static void TranslateGardenStoreMenu(GardenStoreMenu __instance) - { - foreach(GardenShopSlot slot in __instance.GetComponentsInChildren()) - { - TranslateGardenShopSlot(slot); - } - } - - [HarmonyPatch(nameof(GardenShopSlot.Start))] - [HarmonyPostfix] - public static void TranslateGardenShopSlot(GardenShopSlot __instance) - { - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs b/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs deleted file mode 100644 index 4932b4b..0000000 --- a/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs +++ /dev/null @@ -1,44 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using static MelonLoader.MelonLogger; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(GodShootingMenu))] - public static class GodShootingMenu_Patch - { - [HarmonyPatch(nameof(GodShootingMenu.Start))] - [HarmonyPostfix] - private static void Start(GodShootingMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.transform.Find("Background").GetComponentsInChildren()) - { - text.autoSizeTextContainer = true; - text.text = StringStore.TranslateText(text.text); - } - - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(GodShootingMenu.ShowRoutes))] - [HarmonyPostfix] - private static void ShowRoutes(GodShootingMenu __instance) - { - foreach(var route in __instance.routes) - { - if (route.Value == null) continue; - - foreach(TextMeshProUGUI text in route.Value.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/LevelResultMenu_Patch.cs b/MelonLoader/Patches/GameObjects/LevelResultMenu_Patch.cs deleted file mode 100644 index 3f52c2c..0000000 --- a/MelonLoader/Patches/GameObjects/LevelResultMenu_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2Cpp; -using UnityEngine; -using HarmonyLib; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(LevelResultMenu))] - public static class LevelResultMenu_Patch - { - [HarmonyPatch(nameof(LevelResultMenu.Start))] - [HarmonyPatch(nameof(LevelResultMenu.ShowResult))] - [HarmonyPostfix] - public static void Awake(LevelResultMenu __instance) - { - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/LoseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/LoseMenu_Patch.cs deleted file mode 100644 index 2ba8b25..0000000 --- a/MelonLoader/Patches/GameObjects/LoseMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(LoseMenu))] - public static class LoseMenu_Patch - { - public static void TranslateLoseMenu(BaseMenu __instance) - { - if(__instance.TryGetComponent(out LoseMenu loseMenu)) - { - loseMenu.title.text = StringStore.TranslateText(loseMenu.title.text); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs b/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs deleted file mode 100644 index 770d936..0000000 --- a/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs +++ /dev/null @@ -1,109 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; -using Unity.VisualScripting; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.Rendering; -using UnityEngine.UIElements; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(MainMenu))] - public class MainMenu_Patch - { - public static void AnimOver(BaseMenu __instance) - { - Transform changelogObj = __instance.transform.Find("Grave/UpdateInfoButton"); - Transform langObj = UnityEngine.Object.Instantiate(changelogObj, changelogObj.position + new Vector3(0.0f, 0.855f), changelogObj.rotation, __instance.transform.Find("Grave")); - langObj.name = "LanguagesButton"; - __instance.collider2Ds.Add(langObj.GetComponent()); - UIButton langBtn = langObj.GetComponent(); - - foreach(TextMeshProUGUI text in langObj.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("Languages"); - } - - langBtn.clickEvent = new UnityEvent(); - langBtn.clickEvent.AddListener(new Action(() => OpenLanguageMenu(langBtn.gameObject))); - } - - public static void OpenLanguageMenu(GameObject langBtn) - { - UIMgr.EnterOptionMenu(); - GameObject newOptionsMenu = GameAPP.canvasUp.Find("OptionMenu(Clone)").gameObject; - newOptionsMenu.name = "LanguageMenu"; - - List toKeep = new List() { "Background", "F", "Goback"}; - foreach(Transform child in newOptionsMenu.GetComponentsInChildren()) - { - if(!toKeep.Contains(child.name) && !toKeep.Contains(child.parent.name) && child.name != "LanguageMenu") - { - child.gameObject.SetActive(false); - } - } - - OptionBtn templateButton = newOptionsMenu.transform.Find("Buttons/F").GetComponent(); - OptLanguageBtn_Patch.OptLangBtn_Patch.Awake(templateButton); - - UIButton goBackButton = newOptionsMenu.transform.Find("Goback").GetComponent(); - - newOptionsMenu.transform.Find("Buttons/F").gameObject.SetActive(false); - newOptionsMenu.transform.Find("Buttons").gameObject.SetActive(true); - - foreach (TextMeshProUGUI text in newOptionsMenu.transform.Find("Background").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("Language Settings"); - } - - /*GameObject optionMenuAnchor = UnityEngine.Object.Instantiate(assetBundle.LoadAsset("OptionMenu").TryCast(), GameAPP.canvasUp); - optionMenuAnchor.transform.SetParent(newOptionsMenu.transform, false); - Transform messageAnchor = optionMenuAnchor.transform.Find("MessageAnchor"); - Transform plantAnchor = optionMenuAnchor.transform.Find("PlantAnchor"); - - System.Random random = new System.Random(); - var plantTypes = Enum.GetValues(typeof(PlantType)); - PlantType randomPlantChoice = (PlantType)plantTypes.GetValue(random.Next(plantTypes.Length)); - - if(!GameAPP.resourcesManager.plantPrefabs.ContainsKey(randomPlantChoice) || GameAPP.resourcesManager.plantPrefabs[randomPlantChoice] == null) - { - randomPlantChoice = (PlantType)plantTypes.GetValue(random.Next(plantTypes.Length)); - } - - if (GameAPP.resourcesManager.plantPrefabs[randomPlantChoice] != null) - { - GameObject plant = CreatePlant.SetPlantInAlmamac(plantAnchor.position, (int)randomPlantChoice); - plant.transform.SetParent(newOptionsMenu.transform); - SortingGroup sortingGroup = plant.AddComponent(); - sortingGroup.sortingLayerName = "UI"; - sortingGroup.sortingOrder = 20001; - //plant.transform.position = new Vector3(-7.21f, -3.66f); - UnityEngine.Object.Destroy(plant.GetComponent()); - }*/ - - /*GameObject messageObj = new GameObject(); - messageObj.name = "MultilangMessage"; - messageObj.transform.SetParent(newOptionsMenu.transform); - TextMeshProUGUI messageText = messageObj.AddComponent(); - messageObj.transform.localScale = Vector3.one; - messageText.autoSizeTextContainer = false; - messageText.font = FontStore.LoadTMPFont(Utils.LanguageEnum.English.ToString()); - messageText.text = "Hello this is multilanguage choose language over there ------>";*/ - } - - [HarmonyPatch(nameof(MainMenu.EnterUpdateUrl))] - [HarmonyPrefix] - public static bool Pre_EnterUpdateUrl(MainMenu __instance) - { - System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo - { - FileName = @"https://github.com/Teyliu/PVZF-Translation", - UseShellExecute = true - }); - return false; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/Brain_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/Brain_Patch.cs deleted file mode 100644 index 58a09e7..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/Brain_Patch.cs +++ /dev/null @@ -1,57 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Brain))] - public static class Brain_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.Awake))] - private static void Awake(Brain __instance) - { - // reposition original points - Transform pointsTransform = __instance.points.transform; - GameObject pointsObject = __instance.points.gameObject; - pointsTransform.position = new Vector3(-6.5f, pointsTransform.position.y, pointsTransform.position.z); - - // instantiate and move new shadow - GameObject pointsShadowObject = UnityEngine.Object.Instantiate(pointsObject, parent: pointsTransform); - pointsShadowObject.SetActive(true); - Transform pointsShadowTransform = pointsShadowObject.transform; - pointsShadowTransform.position = new Vector3(-6.485f, pointsTransform.position.y - 0.015f, pointsTransform.position.z); - - // set points text - TextMeshPro pointsShadowText = pointsShadowObject.GetComponent(); - pointsShadowText.text = __instance.points.text; - pointsShadowText.sortingOrder -= 2; - pointsShadowText.color = Color.black; - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.Update))] - private static void Update(Brain __instance) - { - if(__instance.transform.Find("Points").GetChild(0) != null) - { - TextMeshPro shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); - shadowText.text = __instance.points.text; - } - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Brain.WinAction))] - private static void WinAction(Brain __instance) - { - if (__instance.transform.Find("Points").GetChild(0) != null) - { - TextMeshPro shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); - shadowText.text = __instance.points.text; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/DY_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/DY_Patch.cs deleted file mode 100644 index 10b48b2..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/DY_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(DY))] - public static class DY_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(DY.Update))] - private static void Update(DY __instance) - { - __instance.TextMeshPro.text = StringStore.TranslateText(__instance.TextMeshPro.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/GameLose_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/GameLose_Patch.cs deleted file mode 100644 index e55957f..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/GameLose_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using Il2CppCore; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(GameLose))] - public static class GameLose_Patch - { - [HarmonyPatch(nameof(GameLose.UpdateSecondChanceTimer))] - public static void UpdateSecondChanceTimer(GameLose __instance) - { - if (InGameText.Instance == null) return; - - if (InGameText.Instance.timer < 0) return; - - InGameText_Patch.TranslateInGameText(InGameText.Instance); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs deleted file mode 100644 index 370d592..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2Cpp; -using HarmonyLib; -using UnityEngine; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using Unity.VisualScripting; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(HealthSlider))] - public static class HealthSlider_Patch - { - public static TMP_FontAsset fontAsset = null; - - [HarmonyPatch(nameof(HealthSlider.Start))] - [HarmonyPostfix] - public static void Post_Start(HealthSlider __instance) - { - if(!fontAsset) - { - fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - [HarmonyPatch(nameof(HealthSlider.UpdateText))] - [HarmonyPostfix] - public static void Post_UpdateText(HealthSlider __instance) - { - if(!fontAsset) fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - if (__instance.healthText.font != fontAsset) __instance.healthText.font = fontAsset; - - foreach(TextMeshProUGUI txt in __instance.healthTextContainer.GetComponentsInChildren(true)) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs deleted file mode 100644 index ff0bb5d..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(JigsawClip))] - public static class JigsawClip_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(JigsawClip.Awake))] - private static void Postfix_Awake(JigsawClip __instance) - { - if (!__instance || !__instance.description) return; - - StringStore.TranslateTextUI(__instance.description); - } - [HarmonyPostfix] - [HarmonyPatch(nameof(JigsawClip.Update))] - private static void Postfix_Update(JigsawClip __instance) - { - if (!__instance || !__instance.description) return; - - if (__instance.description.text != StringStore.TranslateText(__instance.description.text)) - { - StringStore.TranslateTextUI(__instance.description); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs deleted file mode 100644 index d4a1c82..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - /*[HarmonyPatch(typeof(LanternUmbrella))] - public class LanternUmbrella_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(LanternUmbrella.Update))] - private static void Update(LanternUmbrella __instance) - { - __instance.energyText = StringStore.TranslateText(__instance.energyText); - __instance.energyTextShadow = StringStore.TranslateText(__instance.energyTextShadow); - } - }*/ -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs deleted file mode 100644 index ea419b4..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(MagnetBox))] - public class MagnetBox_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(MagnetBox.Update))] - private static void Update(MagnetBox __instance) - { - StringStore.TranslateTextTransform(__instance.transform); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs deleted file mode 100644 index a46f208..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(MagnetInterface))] - public class MagnetInterface_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(MagnetInterface.Update))] - private static void Update(MagnetInterface __instance) - { - StringStore.TranslateTextTransform(__instance.transform); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/Money_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/Money_Patch.cs deleted file mode 100644 index 3caa1d1..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/Money_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Money))] - public static class Money_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Money.Update))] - private static void Update(Money __instance) - { - if (!Utils.CheckForUntranslatedText(__instance.beanCount.text)) return; - __instance.beanCount.text = StringStore.TranslateText(__instance.beanCount.text); - __instance.beanCount2.text = StringStore.TranslateText(__instance.beanCount2.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/Plant_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/Plant_Patch.cs deleted file mode 100644 index b46f0db..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/Plant_Patch.cs +++ /dev/null @@ -1,47 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - /*[HarmonyPatch(typeof(Plant))] - public static class Plant_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(Plant.Awake))] - private static void Awake(Plant __instance) - { - if (!(__instance.thePlantType == PlantType.SuperMachineNut || __instance.thePlantType == PlantType.MachineNut)) - return; - __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = ChangeHPText(__instance.healthSlider.healthTextShadow.text); - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(Plant.UpdateText))] - private static void Update(Plant __instance) - { - if (!(__instance.thePlantType == PlantType.SuperMachineNut || __instance.thePlantType == PlantType.MachineNut)) - return; - if (__instance.thePlantHealth < __instance.thePlantMaxHealth) - return; - __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = ChangeHPText(__instance.healthSlider.healthTextShadow.text); - } - - static string ChangeHPText(string originalText) - { - var regex = new Regex(@"(\d+)\d\d\d/(\d)000"); - if (regex.IsMatch(originalText)) - { - var match = regex.Match(originalText); - int groupCount = match.Groups.Count; - - List dynamicParts = new List(); - - for (int i = 1; i < groupCount; i++) - dynamicParts.Add(match.Groups[i].Value); - return originalText = string.Format("{0}k/{1}k", [.. dynamicParts]); - } - return originalText; - } - }*/ -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs deleted file mode 100644 index 6b55d0a..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(PlayerName))] - public static class PlayerName_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(PlayerName.Update))] - private static void Update(PlayerName __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - } - } -}*/ \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs deleted file mode 100644 index 4a54d10..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2Cpp; -using UnityEngine; -using HarmonyLib; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(PumpinerChestMenu))] - public static class PumpinerChestMenu_Patch - { - [HarmonyPatch(nameof(PumpinerChestMenu.InitPlants))] - [HarmonyPostfix] - public static void Post_InitPlants(PumpinerChestMenu __instance) - { - Transform closeBtnTransform = __instance.transform.Find("SampleButton"); - TextMeshProUGUI txt = closeBtnTransform.GetComponentInChildren(); - txt.text = StringStore.TranslateText("合上"); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs deleted file mode 100644 index a5c1d73..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(SelectYourPlants))] - public static class SelectYourPlants_Patch - { - [HarmonyPatch(nameof(SelectYourPlants.Awake))] - [HarmonyPostfix] - private static void Awake(SelectYourPlants __instance) - { - __instance.TextMeshProUGUI = StringStore.TranslateText(__instance.TextMeshProUGUI); - __instance.TextMeshProUGUI.autoSizeTextContainer = true; - - __instance.TextMeshProUGUI2 = StringStore.TranslateText(__instance.TextMeshProUGUI2); - __instance.TextMeshProUGUI2.autoSizeTextContainer = true; - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs deleted file mode 100644 index 875809e..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(SpecialCard))] - public static class SpecialCard_Patch - { - [HarmonyPatch(nameof(SpecialCard.Awake))] - [HarmonyPatch(nameof(SpecialCard.Start))] - [HarmonyPatch(nameof(SpecialCard.ClickedEvent))] - [HarmonyPostfix] - public static void Post_Awake(SpecialCard __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs deleted file mode 100644 index 8128ccc..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs +++ /dev/null @@ -1,16 +0,0 @@ -using HarmonyLib; -using Il2Cpp; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(TrainingDummy), nameof(TrainingDummy.UpdateHealthText))] - public static class TrainingDummy_Patch - { - [HarmonyPostfix] - public static void UpdateHealthText(TrainingDummy __instance) - { - Zombie_Patch.TranslateHpUI_T(__instance.healthText, __instance); - //Zombie_Patch.TranslateHpUI_T(__instance.healthTextShadow, __instance); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs deleted file mode 100644 index 60dc971..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(TreasureMoney))] - public static class TreasureMoney_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(TreasureMoney.Update))] - private static void Update(TreasureMoney __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs deleted file mode 100644 index 2ab8b59..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIProgress2))] - public static class UIProgress2_Patch - { - [HarmonyPatch(nameof(UIProgress2.Update))] - [HarmonyPostfix] - private static void Update(UIProgress2 __instance) - { - __instance.t.text = StringStore.TranslateText(__instance.t.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs deleted file mode 100644 index 9443605..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs +++ /dev/null @@ -1,17 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - /*[HarmonyPatch(typeof(UltimateChomper), nameof(UltimateChomper.UpdateText))] - public static class UltimateChomper_Patch - { - [HarmonyPostfix] - public static void UpdateText(UltimateChomper __instance) - { - StringStore.TranslateText(__instance.killingText); - StringStore.TranslateText(__instance.killingTextShadow); - } - }*/ -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/MinorObjects/Zombie_Patch.cs b/MelonLoader/Patches/GameObjects/MinorObjects/Zombie_Patch.cs deleted file mode 100644 index 6dd850a..0000000 --- a/MelonLoader/Patches/GameObjects/MinorObjects/Zombie_Patch.cs +++ /dev/null @@ -1,178 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; -using Il2CppTMPro; -using System.Reflection.Metadata.Ecma335; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects -{ - [HarmonyPatch(typeof(Zombie))] - public static class Zombie_Patch - { - private static Dictionary HPStrings = new Dictionary() - { - { "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" }, - { "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT1 armor: {2}/{3}\nT2 armor: {4}/{5}" }, - { "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT1 armor: {2}/{3}" }, - { "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT2 armor: {2}/{3}" }, - { "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" } - }; - - public static void LoadHPStrings() - { - foreach (var hp in HPStrings) - if (StringStore.translationStringRegex.ContainsKey(hp.Key)) - HPStrings[hp.Key] = StringStore.translationStringRegex[hp.Key]; - } - - [HarmonyPatch(nameof(Zombie.Start))] - [HarmonyPostfix] - public static void Start(Zombie __instance) - { - TranslateHpUI(__instance.healthText, __instance); - //TranslateHpUI(__instance.healthTextShadow, __instance); - - if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0)) - __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); - } - - [HarmonyPatch(nameof(Zombie.UpdateHealthText))] - [HarmonyPostfix] - public static void Update(Zombie __instance) - { - if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth) - return; - - if (__instance.healthText == null) return; - - TranslateHpUI(__instance.healthText, __instance); - //TranslateHpUI(__instance.healthTextShadow, __instance); - - if (__instance.healthText.transform.rotation != Quaternion.Euler(0f, 0f, 0f)) - __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); - } - - public static void TranslateHpUI(TextMeshPro textTMP, Zombie __instance) - { - if (textTMP) - { - string origText = textTMP.text; - string translatedText = origText; - if (translatedText == null) return; - string pattern = "(\\d+)阶\n([\\s\\S]+)"; - if (StringStore.TestRegex(translatedText, pattern)) - { - var match = Regex.Match(translatedText, pattern, RegexOptions.Singleline); - string tier = match.Groups[1].Value; - string healthText = TranslateHPText(match.Groups[2].Value, __instance); - string fStr = StringStore.translationStringRegex[pattern]; - translatedText = string.Format(fStr, [tier, healthText]); - } - else - { - translatedText = TranslateHPText(origText, __instance); - } - textTMP.text = translatedText == origText ? origText : translatedText; - textTMP.autoSizeTextContainer = false; - if (translatedText != origText) - textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - public static void TranslateHpUI_T(TextMeshPro textTMP, TrainingDummy __instance) - { - if (textTMP) - { - string origText = textTMP.text; - string translatedText = TranslateHPText_T(origText, __instance); - textTMP.text = translatedText == origText ? origText : translatedText; - textTMP.autoSizeTextContainer = false; - if (translatedText != origText) - textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - public static string TranslateHPText(string originalText, Zombie __instance) - { - if(originalText == null) - { - return originalText; - } - - string finalText = __instance.healthText.text; - int fIndex = -1; - bool found = false; - - for(int i = 0; i < HPStrings.Count; i++) - { - var hp = HPStrings.ElementAt(i); - if(Regex.Match(originalText, hp.Key, RegexOptions.Singleline).Success) - { - fIndex = i; - found = true; - } - } - - if(fIndex > -1 && found) - { - string fStr = HPStrings.ElementAt(fIndex).Value; - - switch (fIndex) - { - case 1: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth); - break; - case 2: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth); - break; - case 3: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth); - break; - case 4: - finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth); - break; - default: - break; - } - } - - return finalText; - } - - public static string TranslateHPText_T(string originalText, TrainingDummy __instance) - { - string finalText = __instance.healthText.text; - int fIndex = -1; - bool found = false; - - for (int i = 0; i < HPStrings.Count; i++) - { - var hp = HPStrings.ElementAt(i); - Regex regex = new Regex(hp.Key); - if (regex.IsMatch(originalText)) - { - fIndex = i; - found = true; - } - } - - if (fIndex > -1 && found) - { - string fStr = HPStrings.ElementAt(fIndex).Value; - - switch (fIndex) - { - case 0: - finalText = string.Format(fStr, __instance.lastDamage, __instance.CurrentDPS, __instance.totalDamage); - break; - default: - break; - } - } - - return finalText; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs deleted file mode 100644 index e050e37..0000000 --- a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.UI; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - public class NoticePauseMenu_Patch - { - public static string changelogText = ""; - - public static void Pre_Awake(BaseMenu __instance) - { - GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; - - TextMeshProUGUI contentText = contentObject.GetComponent(); - File.WriteAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "changelog.txt"), contentText.text); - - string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); - string changelogDir = Path.Combine(stringDir, "changelog.txt"); - - if (!File.Exists(changelogDir)) - { - File.WriteAllText(changelogDir, contentText.text); - } - } - - public static void Post_Awake(BaseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - FileLoader.LoadChangelogText(); - - GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; - - TextMeshProUGUI contentText = contentObject.GetComponent(); - contentText.text = changelogText; - contentText.margin = new Vector4(6, 2, 12, 0); - - contentText.enableWordWrapping = true; - contentText.overflowMode = TextOverflowModes.ScrollRect; - - Canvas.ForceUpdateCanvases(); - contentText.ForceMeshUpdate(); - - //float textHeight = contentText.preferredHeight; - //RectTransform contentRect = contentObject.GetComponent(); - //contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, textHeight); - - ContentSizeFitter sizeFitter = contentObject.AddComponent(); - sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/OtherMenu_Patch.cs b/MelonLoader/Patches/GameObjects/OtherMenu_Patch.cs deleted file mode 100644 index 8fed8a9..0000000 --- a/MelonLoader/Patches/GameObjects/OtherMenu_Patch.cs +++ /dev/null @@ -1,20 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.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); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs b/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs deleted file mode 100644 index a3d21b0..0000000 --- a/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs +++ /dev/null @@ -1,33 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using static MelonLoader.MelonLogger; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PVPRandomManager))] - public static class PVPRandomManager_Patch - { - [HarmonyPatch(nameof(PVPRandomManager.Start))] - [HarmonyPostfix] - private static void Start(PVPRandomManager __instance) - { - foreach(TextMeshPro text in __instance.texts) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(PVPRandomManager.Update))] - [HarmonyPostfix] - private static void ZombieEnterHouse(PVPRandomManager __instance) - { - foreach(TextMeshPro text in __instance.texts) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs b/MelonLoader/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs deleted file mode 100644 index 50c7f38..0000000 --- a/MelonLoader/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantCardPackageBuilder))] - public static class PlantCardPackageBuilder_Patch - { - [HarmonyPatch(nameof(PlantCardPackageBuilder.UpdateText))] - [HarmonyPostfix] - private static void UpdateText(PlantCardPackageBuilder __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.text.text = StringStore.TranslateText(__instance.text.text); - __instance.text.font = fontAsset; - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/PlantDamageMenu_Patch.cs b/MelonLoader/Patches/GameObjects/PlantDamageMenu_Patch.cs deleted file mode 100644 index f29c099..0000000 --- a/MelonLoader/Patches/GameObjects/PlantDamageMenu_Patch.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantDamageMenu))] - public static class PlantDamageMenu_Patch - { - public static void Awake(BaseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == text.text).Key; - text.text = StringStore.translationString.ContainsKey(originalKey + "_RM") ? StringStore.TranslateText(originalKey + "_RM") : StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - [HarmonyPatch(nameof(PlantDamageMenu.Awake))] - [HarmonyPatch(nameof(PlantDamageMenu.InitCards))] - [HarmonyPostfix] - public static void InitCards(PlantDamageMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == text.text).Key; - text.text = StringStore.translationString.ContainsKey(originalKey + "_RM") ? StringStore.TranslateText(originalKey + "_RM") : StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs b/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs deleted file mode 100644 index 1643d0d..0000000 --- a/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs +++ /dev/null @@ -1,94 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantDataMenu))] - public static class PlantDataMenu_Patch - { - [HarmonyPatch(nameof(PlantDataMenu.Start))] - [HarmonyPostfix] - public static void Post_Start(PlantDataMenu __instance) - { - TranslatePlantDataMenu(__instance); - } - - /*[HarmonyPatch(nameof(PlantDataMenu.Update))] - [HarmonyPostfix] - public static void Post_Update(PlantDataMenu __instance) - { - TranslatePlantDataMenu(__instance); - }*/ - - [HarmonyPatch(nameof(PlantDataMenu.InitDataFromPlant))] - [HarmonyPostfix] - public static void Post_InitDataFromPlant(PlantDataMenu __instance) - { - TranslatePlantDataMenu(__instance); - } - - public static void TranslatePlantDataMenu(PlantDataMenu __instance) - { - if (!__instance) return; - - PlantType thePlantType = __instance.plant.thePlantType; - string plantName = Utils.GetPlantNameFromAlmanac(thePlantType); - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI text in __instance.nameText) - { - text.text = plantName; - text.font = fontAsset; - } - - foreach(TextMeshProUGUI text in __instance.infoText) - { - string toTranslate = text.text; - string startColorTag = ""; - - string colorPattern = @"(]+>)(.*?)()"; - Match match = Regex.Match(toTranslate, colorPattern); - if(match.Success) - { - startColorTag = match.Groups[1].Value; - toTranslate = match.Groups[2].Value; - } - - string[] parts = toTranslate.Split("\n"); - List translatedParts = new List(); - - foreach(string part in parts) - { - translatedParts.Add(StringStore.TranslateText(part)); - } - - string joinedTranslation = String.Join("\n", translatedParts); - - if(startColorTag != "") - { - text.text = startColorTag + joinedTranslation + ""; - } - else - { - text.text = joinedTranslation; - } - - text.font = fontAsset; - } - - foreach(TextMeshProUGUI text in __instance.toggles.transform.Find("Viewport/Content/Toggles").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/PlantInfoWindow_Patch.cs b/MelonLoader/Patches/GameObjects/PlantInfoWindow_Patch.cs deleted file mode 100644 index f749978..0000000 --- a/MelonLoader/Patches/GameObjects/PlantInfoWindow_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader.TinyJSON; -using PvZ_Fusion_Translator.AssetStore; -using Unity.Collections; -using UnityEngine; -using UnityEngine.UIElements; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlantInfoWindow))] - public static class PlantInfoWindow_Patch - { - [HarmonyPatch(nameof(PlantInfoWindow.InitText))] - [HarmonyPostfix] - private static void InitText(PlantInfoWindow __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - BigGardenPlant thePlant = __instance.plant; - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if (txt.name.Contains("Introduce") && thePlant != null) - { - PlantType thePlantType = thePlant.thePlantType; - txt.text = StringStore.TranslateText(txt.text); - - string text = txt.text; - string[] lines = text.Split("\n"); - - lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType); - string updatedText = String.Join("\n", lines); - - txt.text = updatedText; - } - else - { - txt.text = StringStore.TranslateText(txt.text); - } - - txt.font = fontAsset; - } - - Transform parentWindowTransform = __instance.transform.parent; - Transform returnPlantTransform = parentWindowTransform.FindChild("Close"); - - foreach(TextMeshProUGUI txt in returnPlantTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/PlayerSaveMenu_Patch.cs b/MelonLoader/Patches/GameObjects/PlayerSaveMenu_Patch.cs deleted file mode 100644 index d550ff9..0000000 --- a/MelonLoader/Patches/GameObjects/PlayerSaveMenu_Patch.cs +++ /dev/null @@ -1,36 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlayerSaveMenu))] - public static class PlayerSaveMenu_Patch - { - [HarmonyPatch(nameof(PlayerSaveMenu.CreatePlayerData))] - [HarmonyPostfix] - public static void CreatePlayerData(PlayerSaveMenu __instance) - { - TranslateCreatePlayerSaveMenu(); - } - - [HarmonyPatch(nameof(PlayerSaveMenu.ResetName))] - [HarmonyPostfix] - public static void ResetName(PlayerSaveMenu __instance) - { - TranslateCreatePlayerSaveMenu(); - } - - public static void TranslateCreatePlayerSaveMenu() - { - Transform reNameMenuTransform = GameAPP.canvasUp.Find("ReNameMenu(Clone)"); - if(reNameMenuTransform.TryGetComponent(out ReNameMenu reNameMenu)) - { - reNameMenu.title.text = StringStore.TranslateText(reNameMenu.title.text); - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/PlayerShootingMenu_Patch.cs b/MelonLoader/Patches/GameObjects/PlayerShootingMenu_Patch.cs deleted file mode 100644 index 3e47e10..0000000 --- a/MelonLoader/Patches/GameObjects/PlayerShootingMenu_Patch.cs +++ /dev/null @@ -1,40 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlayerShootingMenu))] - public static class PlayerShootingMenu_Patch - { - [HarmonyPatch(nameof(PlayerShootingMenu.Update))] - [HarmonyPostfix] - private static void Update(PlayerShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(PlayerShootingMenu.Refresh))] - [HarmonyPostfix] - private static void Refresh(PlayerShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Transform refreshTransform = __instance.transform.FindChild("Button"); - foreach (TextMeshProUGUI text in refreshTransform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - text.autoSizeTextContainer = false; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/PlayerShootingWindow_Patch.cs b/MelonLoader/Patches/GameObjects/PlayerShootingWindow_Patch.cs deleted file mode 100644 index de7a336..0000000 --- a/MelonLoader/Patches/GameObjects/PlayerShootingWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(PlayerShootingWindow))] - public static class PlayerShootingWindow_Patch - { - [HarmonyPatch(nameof(PlayerShootingWindow.SetType))] - [HarmonyPostfix] - private static void SetType(PlayerShootingWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(PlayerShootingWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(PlayerShootingWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/ReNameMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ReNameMenu_Patch.cs deleted file mode 100644 index 5a1ce8e..0000000 --- a/MelonLoader/Patches/GameObjects/ReNameMenu_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ReNameMenu))] - public static class ReNameMenu_Patch - { - [HarmonyPatch(nameof(ReNameMenu.SetTitle))] - [HarmonyPostfix] - public static void SetTitle(ReNameMenu __instance) - { - __instance.title.text = StringStore.TranslateText(__instance.title.text); - } - - [HarmonyPatch(nameof(ReNameMenu.SetInputText))] - [HarmonyPostfix] - public static void SetInputText(ReNameMenu __instance) - { - __instance.input.text = StringStore.TranslateText(__instance.input.text); - } - } -} diff --git a/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs b/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs deleted file mode 100644 index 57db19c..0000000 --- a/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(RogueCardWindow))] - public static class RogueCardWindow_Patch - { - [HarmonyPatch(nameof(RogueCardWindow.InitCard))] - [HarmonyPostfix] - private static void InitCard(RogueCardWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(RogueCardWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(RogueCardWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs b/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs deleted file mode 100644 index c231ce3..0000000 --- a/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs +++ /dev/null @@ -1,44 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.TextCore.Text; -using UnityEngine.UI; -using static MelonLoader.MelonLogger; -using static System.Net.Mime.MediaTypeNames; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - - [HarmonyPatch(typeof(RogueStartMenu))] - public static class RogueStartMenu_Patch - { - [HarmonyPatch(nameof(RogueStartMenu.SetLeader))] - [HarmonyPostfix] - private static void SetLeader(RogueStartMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(RogueStartMenu.EnterGame))] - [HarmonyPostfix] - private static void EnterGame(RogueStartMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} diff --git a/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs b/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs deleted file mode 100644 index f307a4f..0000000 --- a/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs +++ /dev/null @@ -1,58 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(SeedLibrary))] - public static class SeedLibrary_Patch - { - [HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode))] - [HarmonyPostfix] - private static void ChangeSafeMode(SeedLibrary __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - //foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - //{ - // txt.text = StringStore.TranslateText(txt.text); - // txt.font = fontAsset; - //} - - Transform safetyBoxButtonTransform = __instance.transform.FindChild("SafeBox").FindChild("StartSafeMode"); - - if (__instance.safeMode == false && safetyBoxButtonTransform != null) - { - foreach (TextMeshProUGUI txt in safetyBoxButtonTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - } - } - } - - [HarmonyPatch(nameof(SeedLibrary.Start))] - [HarmonyPatch(nameof(SeedLibrary.SetAllCards))] - [HarmonyPostfix] - private static void SetAllCards(SeedLibrary __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - //foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - //{ - // txt.text = StringStore.TranslateText(txt.text); - // txt.font = fontAsset; - //} - - foreach(TextMeshProUGUI txt in __instance.page.GetComponentsInChildren(true)) - { - txt.font = fontAsset; - if (!Utils.CheckForUntranslatedText(txt.text)) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ShootingMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ShootingMenu_Patch.cs deleted file mode 100644 index 7735106..0000000 --- a/MelonLoader/Patches/GameObjects/ShootingMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - /*[HarmonyPatch(typeof(ShootingMenu))] - public static class ShootingMenu_Patch - { - [HarmonyPatch(nameof(ShootingMenu.Update))] - [HarmonyPostfix] - private static void Update(ShootingMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - }*/ -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs b/MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs deleted file mode 100644 index 79580b5..0000000 --- a/MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs +++ /dev/null @@ -1,73 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - /*[HarmonyPatch(typeof(ShootingSelectWindow))] - public static class ShootingSelectWindow_Patch - { - [HarmonyPatch(nameof(ShootingSelectWindow.InitPlantType))] - [HarmonyPostfix] - private static void InitCard(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.SetUpgradePlantTypes))] - [HarmonyPostfix] - private static void SetUpgradePlantTypes(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.GetMaxIndexInRoutes))] - [HarmonyPostfix] - private static void GetMaxIndexInRoutes(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - - [HarmonyPatch(nameof(ShootingSelectWindow.Start))] - [HarmonyPostfix] - private static void Start(ShootingSelectWindow __instance) - { - Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); - TextMeshProUGUI introduceText = introduceTransform.GetComponent(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - introduceText.text = StringStore.TranslateText(introduceText.text); - introduceText.font = fontAsset; - } - }*/ -} diff --git a/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs b/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs deleted file mode 100644 index 744fa5b..0000000 --- a/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(SpriteRenderer))] - public static class SpriteRenderer_Patch - { - [HarmonyPatch(nameof(SpriteRenderer.InvokeSpriteChanged))] - [HarmonyPostfix] - private static void InvokeSpriteChanged(SpriteRenderer __instance) - { - if (__instance.sprite != null) - { - if (TextureStore.spriteDict.ContainsKey(__instance.sprite.name) && __instance.drawMode != SpriteDrawMode.Sliced) - { - __instance.drawMode = SpriteDrawMode.Sliced; - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/TowerOption_Patch.cs b/MelonLoader/Patches/GameObjects/TowerOption_Patch.cs deleted file mode 100644 index 1dcceda..0000000 --- a/MelonLoader/Patches/GameObjects/TowerOption_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(TowerOption))] -// public static class TowerOption_Patch -// { -// [HarmonyPatch(nameof(TowerOption.Start))] -// [HarmonyPostfix] -// private static void Postfix_Start(TowerOption __instance) -// { -// //TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren(true); -// __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); -// __instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString()); -// } -// } -//}} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/TowerUpgradeMenu_Patch.cs b/MelonLoader/Patches/GameObjects/TowerUpgradeMenu_Patch.cs deleted file mode 100644 index 4b863b3..0000000 --- a/MelonLoader/Patches/GameObjects/TowerUpgradeMenu_Patch.cs +++ /dev/null @@ -1,40 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(TowerUpgradeMenu))] - public static class TowerUpgradeMenu_Patch - { - [HarmonyPatch(nameof(TowerUpgradeMenu.Awake))] - [HarmonyPostfix] - private static void Awake(TowerUpgradeMenu __instance) - { - __instance.des.text = StringStore.TranslateText(__instance.des.text); - __instance.des2.text = StringStore.TranslateText(__instance.des2.text); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - - [HarmonyPatch(nameof(TowerUpgradeMenu.SetText))] - [HarmonyPostfix] - private static void SetText(TowerUpgradeMenu __instance) - { - __instance.des.text = StringStore.TranslateText(__instance.des.text); - __instance.des2.text = StringStore.TranslateText(__instance.des2.text); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs deleted file mode 100644 index c7b6c5b..0000000 --- a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIDifficulty))] - public static class UIDifficulty_Patch - { - [HarmonyPatch(nameof(UIDifficulty.Update))] - [HarmonyPostfix] - private static void Update(UIDifficulty __instance) - { - if (!Utils.CheckForUntranslatedText(__instance.t.text)) return; - __instance.t.text = StringStore.TranslateText(__instance.t.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/UIZombieNum_Patch.cs b/MelonLoader/Patches/GameObjects/UIZombieNum_Patch.cs deleted file mode 100644 index 9401da2..0000000 --- a/MelonLoader/Patches/GameObjects/UIZombieNum_Patch.cs +++ /dev/null @@ -1,29 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(UIZombieNum))] - public static class UIZombieNum_Patch - { - [HarmonyPatch(nameof(UIZombieNum.Update))] - [HarmonyPostfix] - private static void Update(UIZombieNum __instance) - { - - #if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - string zombieText = StringStore.TranslateText(__instance.t.text); - __instance.t.text = zombieText; - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - string zombieText = StringStore.patchesStore["Zombies"]["Spanish"]; - __instance.t.text = string.Format(zombieText + " {0}", Board.Instance.enermyCount); - #endif - - __instance.t.font = fontAsset; - } - } -} diff --git a/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs b/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs deleted file mode 100644 index f3103ff..0000000 --- a/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs +++ /dev/null @@ -1,96 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(WarningMenu))] - public static class WarningMenu_Patch - { - [HarmonyPatch(nameof(WarningMenu.Start))] - [HarmonyPostfix] - private static void Start(WarningMenu __instance) - { - TranslateInvestmentWarning(__instance); - } - - [HarmonyPatch(nameof(WarningMenu.EnableChallengeMode))] - [HarmonyPostfix] - private static void EnableChallengeMode(WarningMenu __instance) - { - TranslateInvestmentWarning(__instance); - } - - [HarmonyPatch(nameof(WarningMenu.Cancel))] - [HarmonyPostfix] - private static void Cancel(WarningMenu __instance) - { - TranslateInvestmentWarning(__instance); - } - - public static void TranslateInvestmentWarning(WarningMenu __instance) - { - Transform normalModeTransform = __instance.transform.Find("Normal"); - Transform challengeModeTransform = __instance.transform.Find("Challenge"); - - if (normalModeTransform != null) - { - TextMeshProUGUI text = normalModeTransform.Find("text").GetComponent(); - TextMeshProUGUI textShadow = normalModeTransform.Find("text (1)").GetComponent(); - - text.text = StringStore.translationString.ContainsKey("普通模式_IV") ? StringStore.TranslateText("普通模式_IV") : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); - text.alignment = TextAlignmentOptions.Center; - text.autoSizeTextContainer = true; - textShadow.text = Utils.RemoveColorTags(text.text); - textShadow.alignment = TextAlignmentOptions.Center; - textShadow.autoSizeTextContainer = true; - } - - if (challengeModeTransform != null) - { - TextMeshProUGUI text = challengeModeTransform.Find("text").GetComponent(); - TextMeshProUGUI textShadow = challengeModeTransform.Find("text (1)").GetComponent(); - - text.text = StringStore.translationString.ContainsKey("诅咒模式_IV") ? StringStore.TranslateText("诅咒模式_IV") : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); - text.alignment = TextAlignmentOptions.Center; - text.autoSizeTextContainer = true; - textShadow.text = Utils.RemoveColorTags(text.text); - textShadow.alignment = TextAlignmentOptions.Center; - textShadow.autoSizeTextContainer = true; - } - - if (__instance.tutor != null) - { - foreach (TextMeshProUGUI text in __instance.tutor.GetComponentsInChildren()) - { - if (text.gameObject.name == "text1") - { - text.text = StringStore.TranslateText(text.text); - if (text.transform.parent.Find("text").TryGetComponent(out TextMeshProUGUI textShadow)) - { - textShadow.text = Utils.RemoveColorTags(text.text); - } - } - } - } - - if (__instance.challenge != null) - { - foreach (TextMeshProUGUI text in __instance.challenge.GetComponentsInChildren()) - { - if (text.gameObject.name == "text1") - { - text.text = StringStore.TranslateText(text.text); - if (text.transform.parent.Find("text").TryGetComponent(out TextMeshProUGUI textShadow)) - { - textShadow.text = Utils.RemoveColorTags(text.text); - } - } - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/AbyssDevelopMenu_Patch.cs b/MelonLoader/Patches/Managers/AbyssDevelopMenu_Patch.cs deleted file mode 100644 index a0f32d7..0000000 --- a/MelonLoader/Patches/Managers/AbyssDevelopMenu_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssDevelopMenu))] - public static class AbyssDevelopMenu_Patch - { - [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))] - [HarmonyPostfix] - private static void UpdateInfo(AbyssDevelopMenu __instance) - { - __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); - __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); - } - } -} diff --git a/MelonLoader/Patches/Managers/AbyssMenu2_Patch.cs b/MelonLoader/Patches/Managers/AbyssMenu2_Patch.cs deleted file mode 100644 index bbd5a58..0000000 --- a/MelonLoader/Patches/Managers/AbyssMenu2_Patch.cs +++ /dev/null @@ -1,74 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssMenu2))] - public static class AbyssMenu2_Patch - { - [HarmonyPatch(nameof(AbyssMenu2.Start))] - [HarmonyPostfix] - private static void Start(AbyssMenu2 __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); - __instance.buffCountText.font = fontAsset; - - __instance.money.text = StringStore.TranslateText(__instance.money.text); - __instance.money.font = fontAsset; - - __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); - __instance.refreshText.font = fontAsset; - - __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); - __instance.statistics.font = fontAsset; - - Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; - if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform); - - Transform moneyTransform = __instance.transform.FindChild("Money").transform; - if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform); - - Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; - if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform); - - Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; - if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform); - } - - [HarmonyPatch(nameof(AbyssMenu2.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu2 __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); - __instance.buffCountText.font = fontAsset; - - __instance.money.text = StringStore.TranslateText(__instance.money.text); - __instance.money.font = fontAsset; - - __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); - __instance.refreshText.font = fontAsset; - - __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); - __instance.statistics.font = fontAsset; - - Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; - if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform); - - Transform moneyTransform = __instance.transform.FindChild("Money").transform; - if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform); - - Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; - if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform); - - Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; - if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform); - } - } -} diff --git a/MelonLoader/Patches/Managers/AbyssMenu_Patch.cs b/MelonLoader/Patches/Managers/AbyssMenu_Patch.cs deleted file mode 100644 index aa48391..0000000 --- a/MelonLoader/Patches/Managers/AbyssMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(AbyssMenu))] - public static class AbyssMenu_Patch - { - [HarmonyPatch(nameof(AbyssMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, false); - txt.font = fontAsset; - } - - - } - } -} diff --git a/MelonLoader/Patches/Managers/AlmanacMgrZombie_Patch.cs b/MelonLoader/Patches/Managers/AlmanacMgrZombie_Patch.cs deleted file mode 100644 index a47e22c..0000000 --- a/MelonLoader/Patches/Managers/AlmanacMgrZombie_Patch.cs +++ /dev/null @@ -1,128 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(AlmanacMgrZombie))] - public static partial class AlmanacMgrZombie_Patch - { - [HarmonyPatch(nameof(AlmanacMgrZombie.InitNameAndInfoFromJson))] - [HarmonyPostfix] - private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance) - { -#if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); -#else - string almanacDir = almanacDir = GetAssetDir(AssetType.Almanac); - string currentLanguage = "English"; -#endif - string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); - return; - } - -#if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } -#endif - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - -#if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); -#else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); -#endif - - TextMeshPro component = __instance.info.GetComponent(); - TextMeshPro component2 = __instance.zombieName.GetComponent(); - TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent(); - - ZombieAlmanacData zombieData = JsonUtility.FromJson(json); - - foreach (ZombieInfo zombieInfo in zombieData.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; - } - } - - if (File.Exists(moddedPath)) - { - string moddedJson; - moddedJson = File.ReadAllText(moddedPath); - - ZombieAlmanacData moddedZombieData = JsonUtility.FromJson(moddedJson); - - foreach (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))] - [HarmonyPrefix] - private static bool OnMouseDown(AlmanacMgrZombie __instance) - { - TextMeshPro component = __instance.info.GetComponent(); - if (component != null) - { - component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; - return false; - } - return true; - } - } -}*/ \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs b/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs deleted file mode 100644 index 236fc5c..0000000 --- a/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs +++ /dev/null @@ -1,200 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(AlmanacPlantBank))] - public static partial class AlmanacPlantBank_Patch - { - [HarmonyPatch(nameof(AlmanacPlantBank.InitNameAndInfoFromJson))] - [HarmonyPostfix] - private static void InitNameAndInfoFromJson(Il2Cpp.AlmanacPlantBank __instance) - { -#if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); -#else - string almanacDir = GetAssetDir(AssetType.Almanac); - string currentLanguage = "English"; -#endif - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); - - if (!File.Exists(path)) - { - Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); - return; - } - -#if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } -#endif - - string json; - json = File.ReadAllText(path); - - bool hasAlmanacFont = false; - TMP_FontAsset almanacFontAsset = null; - if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) - { - almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); - hasAlmanacFont = true; - } - -#if MULTI_LANGUAGE - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); -#else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); -#endif - - TextMeshPro component = __instance.introduce.GetComponent(); - TextMeshPro component2 = __instance.plantName.GetComponent(); - TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent(); - TextMeshPro component4 = __instance.cost.GetComponent(); - - AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson(json); - - foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants) - { - if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name)) - { - 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 ?? string.Empty); - 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; - } - } - - if (File.Exists(moddedPath)) - { - string moddedJson; - moddedJson = File.ReadAllText(moddedPath); - - AlmanacPlantBank.PlantData moddedPlantData = JsonUtility.FromJson(moddedJson); - - foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants) - { - if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name)) - { - 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 ?? string.Empty); - 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; - } - - [HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))] - [HarmonyPrefix] - private static bool OnMouseDown(AlmanacPlantBank __instance) - { - TextMeshPro component = __instance.introduce.GetComponent(); - if (component != null) - { - component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; - return false; - } - return true; - } - - [HarmonyPatch(nameof(AlmanacPlantBank.PVPInit))] - [HarmonyPostfix] - private static void PVPInit(Il2Cpp.AlmanacPlantBank __instance) - { - TextMeshPro component = __instance.introduce.GetComponent(); - if (component != null) - { - component.autoSizeTextContainer = false; - } - - Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0); - if (banTransform != null) - { - banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); - } - } - - [HarmonyPatch(nameof(AlmanacPlantBank.Start))] - [HarmonyPostfix] - public static void Post_Start(AlmanacPlantBank __instance) - { - GameObject skinTextObj = __instance.skinButton.transform.GetChild(0).gameObject; - GameObject skinShadowTextObj = UnityEngine.Object.Instantiate(skinTextObj, parent: __instance.skinButton.transform); - TextMeshPro skinShadowText = skinShadowTextObj.GetComponent(); - skinShadowText.text = StringStore.TranslateText("换肤_S"); - skinShadowText.sortingOrder -= 2; - skinShadowTextObj.transform.Translate(new Vector3(0.015f, -0.015f, 0)); - skinTextObj.transform.Translate(new Vector3(-0.022f, 0)); - skinShadowTextObj.transform.Translate(new Vector3(-0.022f, 0)); - __instance.skinButton.transform.localScale /= 1.75f; - __instance.skinButton.transform.Translate(new Vector3(-0.075f, -0.15f, 0)); - __instance.skinButton.transform.GetChild(1).Translate(new Vector3(0.35f, 0)); - __instance.skinButton.transform.GetChild(2).Translate(new Vector3(-0.35f, 0)); - } - } -}*/ \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/CanvasUpUI_Patch.cs b/MelonLoader/Patches/Managers/CanvasUpUI_Patch.cs deleted file mode 100644 index 6efb242..0000000 --- a/MelonLoader/Patches/Managers/CanvasUpUI_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(CanvasUpUI))] - public static class CanvasUpUI_Patch - { - [HarmonyPatch(nameof(CanvasUpUI.Start))] - [HarmonyPostfix] - public static void Start(CanvasUpUI __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => (x.Value == text.text || x.Value.Replace("\n", "") == text.text)).Key; - text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text); - if(text.gameObject.name.Contains("LevelName")) - { - text.text = text.text.Replace("\n", " "); - } - text.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/ChessManager_Patch.cs b/MelonLoader/Patches/Managers/ChessManager_Patch.cs deleted file mode 100644 index 8ff4841..0000000 --- a/MelonLoader/Patches/Managers/ChessManager_Patch.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.TextCore.Text; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(ChessManager))] - public static class ChessManager_Patch - { - [HarmonyPatch(nameof(ChessManager.Start))] - [HarmonyPostfix] - private static void Postfix_Start(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ChessManager.Update))] - [HarmonyPostfix] - private static void Postfix_Update(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(ChessManager.UpdateText))] - [HarmonyPostfix] - private static void Postfix_UpdateText(ChessManager __instance) - { - __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); - __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } -} diff --git a/MelonLoader/Patches/Managers/CustomLevelShower_Patch.cs b/MelonLoader/Patches/Managers/CustomLevelShower_Patch.cs deleted file mode 100644 index 8ed0487..0000000 --- a/MelonLoader/Patches/Managers/CustomLevelShower_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if FIX -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(CustomLevelShower))] - public static class CustomLevelShower_Patch - { - [HarmonyPatch(nameof(CustomLevelShower.Show))] - [HarmonyPostfix] - private static void Show(CustomLevelShower __instance) - { - foreach (Transform transform in __instance.pages) - { - StringStore.TranslateTextTransform(transform); - } - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/DifficultyMgr_Patch.cs b/MelonLoader/Patches/Managers/DifficultyMgr_Patch.cs deleted file mode 100644 index 3d05ff1..0000000 --- a/MelonLoader/Patches/Managers/DifficultyMgr_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(DifficultyMgr))] - public static class DifficultyMgr_Patch - { - [HarmonyPatch(nameof(DifficultyMgr.Update))] - [HarmonyPostfix] - private static void DifficultyMgr_Update(DifficultyMgr __instance) - { - __instance.t = StringStore.TranslateText(__instance.t); - __instance.t.autoSizeTextContainer = false; - } - } -} diff --git a/MelonLoader/Patches/Managers/DrawCardManager_Patch.cs b/MelonLoader/Patches/Managers/DrawCardManager_Patch.cs deleted file mode 100644 index 0db3ecf..0000000 --- a/MelonLoader/Patches/Managers/DrawCardManager_Patch.cs +++ /dev/null @@ -1,78 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; -using System.Text.RegularExpressions; -using UnityEngine; -using UnityEngine.TextCore.Text; -using static MelonLoader.MelonLogger; - -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(DrawCardManager))] - public static class DrawCardManager_Patch - { - public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - [HarmonyPatch(nameof(DrawCardManager.Awake))] - [HarmonyPostfix] - private static void Awake(DrawCardManager __instance) - { - fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - [HarmonyPatch(nameof(DrawCardManager.UpdateText))] - [HarmonyPostfix] - private static void Postfix_UpdateText(DrawCardManager __instance) - { - KeyValuePair regexPair = new KeyValuePair("抽取次数:\n(\\d+)/(\\d+)\n当前up植物:\n([^\\s]+)\nup刷新倒计时:\n(\\d+)", "Draw Count:\n{0}/{1}\nCurrent Up:\n{2}\nNext Up in: \n{3}s"); - - foreach(TextMeshProUGUI txt in __instance.texts) - { - if(Regex.IsMatch(txt.text, regexPair.Key)) - { - txt.text = TranslateGashaponText(txt.text, regexPair.Key, regexPair.Value, __instance.up); - txt.font = fontAsset; - } - } - } - - public static string TranslateGashaponText(string originalText, string pattern, string fallback, PlantType up) - { - string res = ""; - string fStr = ""; - Match match = Regex.Match(originalText, pattern); - if(match.Success) - { - GroupCollection groups = match.Groups; - fStr = StringStore.translationStringRegex.ContainsKey(pattern) ? StringStore.translationStringRegex[pattern] : fallback; - List dynamicParts = []; - for(int i = 1; i < groups.Count; i++) - { - string group = groups[i].Value; - string translatedGroup = ""; - if(i == 3 && up != PlantType.Peashooter) - { - translatedGroup = Utils.GetPlantNameFromAlmanac(up); - } - else - { - translatedGroup = StringStore.TranslateText(group); - } - dynamicParts.Add(translatedGroup); - } - res = string.Format(fStr, [.. dynamicParts]); - } - return res; - } - - /*[HarmonyPatch(nameof(DrawCardManager.Update))] - [HarmonyPostfix] - private static void Postfix_Update(DrawCardManager __instance) - { - Postfix_UpdateText(__instance); - }*/ - } -} - diff --git a/MelonLoader/Patches/Managers/EndlessMgr_Patch.cs b/MelonLoader/Patches/Managers/EndlessMgr_Patch.cs deleted file mode 100644 index de57cbf..0000000 --- a/MelonLoader/Patches/Managers/EndlessMgr_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(EndlessMgr))] - public static class EndlessMgr_Patch - { - [HarmonyPatch(nameof(EndlessMgr.Awake))] - [HarmonyPostfix] - private static void Awake(EndlessMgr __instance) - { - Transform textTransform = __instance.transform.GetChild(2); - if (textTransform != null && textTransform.gameObject.activeSelf) - { - TextMeshProUGUI textTMP = textTransform.GetComponent(); - if (textTMP != null) - { - textTMP = StringStore.TranslateText(textTMP); - } - } - } - } -} diff --git a/MelonLoader/Patches/Managers/Garden_Patch.cs b/MelonLoader/Patches/Managers/Garden_Patch.cs deleted file mode 100644 index 698e2a5..0000000 --- a/MelonLoader/Patches/Managers/Garden_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(Garden))] - public static class Garden_Patch - { - [HarmonyPatch(nameof(Garden.Awake))] - [HarmonyPostfix] - private static void Awake(Garden __instance) - { - foreach (TextMeshPro text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs b/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs deleted file mode 100644 index 8630912..0000000 --- a/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs +++ /dev/null @@ -1,52 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(IZBottomMenu))] - public static class IZBottomMenu_Patch - { - [HarmonyPatch(nameof(IZBottomMenu.ChangeString))] - [HarmonyPostfix] - public static void ChangeStringz(IZBottomMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.levelName) - { - string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"]; - string[] parts = text.text.Split(",推荐难度:"); - - if(new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(text.text)) - { - string customName = (StringStore.translationString.ContainsKey(parts[0] + "_IZ")) ? parts[0] + "_IZ" : parts[0]; - text.text = string.Format(fStr, StringStore.TranslateText(customName), parts[1]); - } - - text.text = StringStore.TranslateText(text.text); - text.text = text.text.Replace("\n", " "); - } - } - - [HarmonyPatch(nameof(IZBottomMenu.SetLevelName))] - [HarmonyPostfix] - public static void SetLevelName(IZBottomMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.levelName) - { - string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"]; - string[] parts = text.text.Split(",推荐难度:"); - - if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(text.text)) - { - text.text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]); - } - - text.text = StringStore.TranslateText(text.text); - text.text = text.text.Replace("\n", " "); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/InGameUI_Patch.cs b/MelonLoader/Patches/Managers/InGameUI_Patch.cs deleted file mode 100644 index b9878bc..0000000 --- a/MelonLoader/Patches/Managers/InGameUI_Patch.cs +++ /dev/null @@ -1,87 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; -using System.Text.RegularExpressions; -using Unity.Collections; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(InGameUI))] - public static class InGameUI_Patch - { - public static string travelAdventurePattern = "^旅行冒险 ([^\\s:]+)"; - public static string travelAdventureFallback = "Odyssey Adventure: {0}"; - - [HarmonyPatch(nameof(InGameUI.Start))] - [HarmonyPostfix] - private static void Start(InGameUI __instance) - { - SetLevelName(__instance); - } - - [HarmonyPatch(nameof(InGameUI.SetUniqueText))] - [HarmonyPostfix] - private static void SetUniqueText(InGameUI __instance) - { - SetLevelName(__instance); - } - - [HarmonyPatch(nameof(InGameUI.SetLevelName))] - [HarmonyPostfix] - private static void SetLevelName(InGameUI __instance) - { - foreach (TextMeshProUGUI text in __instance.levelNameText) - { - if (text.text == null) continue; - - string originalText = text.text; - text.text = text.text.Replace("\n", " "); - - Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)"); - Regex checkTravelAdv = new Regex(travelAdventurePattern); - - if(checkTravelAdv.IsMatch(originalText)) - { - text.text = InGameText_Patch.TranslatePlantNameParts(originalText, travelAdventurePattern, travelAdventureFallback); - } - else if (text.text.Contains("配方:") && !checkFusionChallenge.IsMatch(text.text)) - { - string[] lines = text.text.Split(":"); - lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]); - if (lines[1] == "") - { - Log.LogError("Couldn't find plant! (Fusion Showcase)"); - lines[1] = StringStore.TranslateText(lines[1]); - } - text.text = StringStore.TranslateText("配方:") + lines[1]; - text.autoSizeTextContainer = true; - } - else - { - text.text = (StringStore.translationString.ContainsKey(text.text + "_MG")) ? StringStore.TranslateText(text.text + "_MG") : StringStore.TranslateText(text.text); - text.text = text.text.Replace("\n", " "); - } - } - } - - /*[HarmonyPatch(nameof(InGameUI.Update))] - [HarmonyPostfix] - private static void Update(InGameUI __instance) - { - if (!__instance.board.boardTag.isDrawCards) return; - - KeyValuePair regexPair = new KeyValuePair("抽取次数:\n(\\d+)/(\\d+)\n当前up植物:\n([^\\s]+)\nup刷新倒计时:\n(\\d+)", "Draw Count:\n{0}/{1}\nCurrent Up:\n{2}\nNext Up in: \n{3}s"); - - foreach(TextMeshProUGUI txt in __instance.DrawCardsHead.GetComponentsInChildren()) - { - if(Regex.IsMatch(txt.text, regexPair.Key)) - { - txt.text = InGameText_Patch.TranslatePlantNameParts(txt.text, regexPair.Key, regexPair.Value); - } - } - }*/ - } -} diff --git a/MelonLoader/Patches/Managers/PVPScareyPot_Patch.cs b/MelonLoader/Patches/Managers/PVPScareyPot_Patch.cs deleted file mode 100644 index 3302de1..0000000 --- a/MelonLoader/Patches/Managers/PVPScareyPot_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Il2Cpp; -using UnityEngine; -using HarmonyLib; -using Il2CppPVPScaryPot; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(PVPScareyPot))] - public static class PVPScareyPot_Patch - { - [HarmonyPatch(nameof(PVPScareyPot.Awake))] - [HarmonyPatch(nameof(PVPScareyPot.Start))] - [HarmonyPatch(nameof(PVPScareyPot.AutoRuleUpdate))] - [HarmonyPatch(nameof(PVPScareyPot.RandomCardUpdate))] - [HarmonyPatch(nameof(PVPScareyPot.Update))] - [HarmonyPostfix] - public static void TranslatePlayerDatas(PVPScareyPot __instance) - { - TranslatePlayerData(__instance.player1); - TranslatePlayerData(__instance.player2); - TranslatePlayerData(__instance.currentPlayer); - } - - public static void TranslatePlayerData(PVPScareyPot.PlayerData playerData) - { - if(playerData != null) - { - playerData.textMesh.text = StringStore.TranslateText(playerData.textMesh.text); - playerData.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - } - } -} diff --git a/MelonLoader/Patches/Managers/SaveMenu_Patch.cs b/MelonLoader/Patches/Managers/SaveMenu_Patch.cs deleted file mode 100644 index 0f5ae09..0000000 --- a/MelonLoader/Patches/Managers/SaveMenu_Patch.cs +++ /dev/null @@ -1,37 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(SaveMenu))] - public static class SaveMenu_Patch - { - [HarmonyPatch(nameof(SaveMenu.Start))] - [HarmonyPatch(nameof(SaveMenu.CreateLevelEnter))] - [HarmonyPatch(nameof(SaveMenu.InitLevelSaveEnters))] - [HarmonyPostfix] - private static void Start(SaveMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.menuTitle.text = StringStore.TranslateText(__instance.menuTitle.text); - __instance.menuTitle.font = fontAsset; - - foreach(LevelSaveEnter enter in __instance.GetComponentsInChildren()) - { - LevelSaveEnter_Patch.TranslateEnter(enter); - } - } - - [HarmonyPatch(nameof(SaveMenu.OnEditSelectedButtonClicked))] - [HarmonyPostfix] - private static void OnEditSelectedButtonClicked(SaveMenu __instance) - { - - } - } -} diff --git a/MelonLoader/Patches/Managers/Screen_Patch.cs b/MelonLoader/Patches/Managers/Screen_Patch.cs deleted file mode 100644 index da7c0ed..0000000 --- a/MelonLoader/Patches/Managers/Screen_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(Screen))] - public static class Screen_Patch - { - [HarmonyPatch(nameof(Screen.SetResolution), argumentTypes: [typeof(int), typeof(int), typeof(bool)])] - [HarmonyPrefix] - private static bool SetResolution(Screen __instance) - { - if(EventSystem.current.currentSelectedGameObject != null) - { - if (EventSystem.current.currentSelectedGameObject.TryGetComponent(out TMP_InputField field)) - { - return false; - } - } - return true; - } - } -} diff --git a/MelonLoader/Patches/Managers/TowerManager_Patch.cs b/MelonLoader/Patches/Managers/TowerManager_Patch.cs deleted file mode 100644 index 3088e45..0000000 --- a/MelonLoader/Patches/Managers/TowerManager_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(TowerManager))] - public static class TowerManager_Patch - { - public static List updatedText = []; - - public static void UpdateText() - { - foreach (Transform transform in updatedText) - { - if (transform != null) - { - if(transform.gameObject.active) - { - transform.GetComponent().text = StringStore.TranslateText(transform.GetComponent().text); - } - } - } - } - } -} diff --git a/MelonLoader/Patches/Managers/UIMgr_Patch.cs b/MelonLoader/Patches/Managers/UIMgr_Patch.cs deleted file mode 100644 index e3e1bad..0000000 --- a/MelonLoader/Patches/Managers/UIMgr_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Managers -{ - [HarmonyPatch(typeof(UIMgr))] - public class UIMgr_Patch - { - [HarmonyPatch(nameof(UIMgr.EnterLoseMenu))] - [HarmonyPostfix] - private static void EnterLoseMenu(UIMgr __instance) - { - LoseMenu loseMenu = GameObject.FindObjectOfType(); - loseMenu.title.text = StringStore.TranslateText(loseMenu.title.text); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs deleted file mode 100644 index a226fe5..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; -//using UnityEngine.TextCore.Text; -//using UnityEngine.UI; -//using static MelonLoader.MelonLogger; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ - -// [HarmonyPatch(typeof(AbyssBagMenu))] -// public static class AbyssBagMenu_Patch -// { -// [HarmonyPatch(nameof(AbyssBagMenu.Awake))] -// [HarmonyPostfix] -// private static void Awake_Post(AbyssCheckInBag __instance) -// { -// foreach(TextMeshProUGUI text in __instance.transform.FindChild("Background").GetComponentsInChildren()) -// { -// text.text = text.text + "_深渊"; -// text.text = StringStore.TranslateText("背包_深渊"); -// text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); -// } -// AbyssMenu2.Instance.UpdateIcons(); -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs deleted file mode 100644 index f83d585..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs +++ /dev/null @@ -1,54 +0,0 @@ -#if FIX -using System.Text.RegularExpressions; -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using MelonLoader; - -namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -{ - [HarmonyPatch(typeof(AbyssBuffButton))] - public static class AbyssBuffButton_Patch - { - [HarmonyPatch(nameof(AbyssBuffButton.SetType))] - [HarmonyPostfix] - private static void SetType(AbyssBuffButton __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Regex regex = new Regex("([^\\s]+)\n价格:(\\d+)"); - - if (regex.IsMatch(__instance.description.text)) - { - Match match = regex.Match(__instance.description.text); - int groupCount = match.Groups.Count; - - List 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); - MelonLogger.Msg(translatedValue); - } - - __instance.description.text = string.Format(StringStore.translationStringRegex["([^\\s]+)\n价格:(\\d+)"], [.. dynamicParts]); - __instance.description.font = fontAsset; - } - } - - [HarmonyPatch(nameof(AbyssBuffButton.SetSold))] - [HarmonyPostfix] - private static void SetSold(AbyssBuffButton __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.description.text = StringStore.TranslateText(__instance.description.text); - __instance.description.font = fontAsset; - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssBuffData_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssBuffData_Patch.cs deleted file mode 100644 index 0858150..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssBuffData_Patch.cs +++ /dev/null @@ -1,125 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using MelonLoader; -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Text.Json; -//using System.Threading.Tasks; -//using Unity.VisualScripting; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator.Patches.Managers -//{ -// [HarmonyPatch(typeof(AbyssBuffData))] -// public static class AbyssBuffData_Patch -// { -// [HarmonyPatch(nameof(AbyssBuffData.LoadData))] -// [HarmonyPostfix] -// public static void Pre_LoadData(AbyssBuffData __instance) -// { -// string originalAbyssBuffStr = Resources.Load("AbyssBuffData").text; -// Dictionary> originalAbyssBuffData = JsonSerializer.Deserialize>>(originalAbyssBuffStr); -// List infos = originalAbyssBuffData["infos"]; -// Il2CppSystem.Collections.Generic.Dictionary> result = new(); - -// string abyssBuffDataDir = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"); -// if (!File.Exists(abyssBuffDataDir)) -// { -// File.WriteAllText(abyssBuffDataDir, originalAbyssBuffStr); -// } - -// Dictionary abyssBuffData = JsonSerializer.Deserialize>(File.ReadAllText(abyssBuffDataDir)); - -// for (int i = 0; i < infos.Count; i++) -// { -// AbyssBuffInfo originalTuple = infos[i]; -// Il2CppSystem.ValueTuple translatedTuple = new(); - -// translatedTuple.Item1 = abyssBuffData.ContainsKey(originalTuple.name) ? abyssBuffData[originalTuple.name] : originalTuple.name; -// translatedTuple.Item2 = abyssBuffData.ContainsKey(originalTuple.introduce) ? abyssBuffData[originalTuple.introduce] : originalTuple.introduce; -// translatedTuple.Item3 = originalTuple.value; - -// foreach (var x in AbyssBuffData.buffDatas) -// { -// if (x.Value.Item1 == originalTuple.name) -// { -// AbyssBuffData.buffDatas[x.Key] = translatedTuple; -// break; -// } -// } -// } -// } -// } - -// public enum AbyssBuffClone -// { -// 生存_聚塑, -// 生存_启命, -// 生存_坚定, -// 生存_弥合, -// 生存_警戒, -// 生存_霸体, -// 生存_共存, -// 生存_护盾, -// 生存_治疗, -// 生存_主宰, -// 寒冰_聚塑, -// 寒冰_刺骨, -// 寒冰_凛风, -// 寒冰_冻结, -// 寒冰_保护, -// 寒冰_折磨, -// 寒冰_扩散, -// 寒冰_凝神, -// 寒冰_破冰, -// 寒冰_永冻, -// 魅惑_聚塑, -// 魅惑_感应, -// 魅惑_催眠, -// 魅惑_无畏, -// 魅惑_脆弱, -// 魅惑_黑曜, -// 魅惑_转世, -// 魅惑_支援, -// 魅惑_沉重, -// 魅惑_共鸣, -// 烈焰_聚塑, -// 烈焰_爆破, -// 烈焰_怒火, -// 烈焰_红唇, -// 烈焰_融化, -// 烈焰_燃烧, -// 烈焰_浴火, -// 烈焰_鬼火, -// 烈焰_诅咒, -// 烈焰_太阳, -// 通用_断水, -// 通用_千斤, -// 通用_急迫, -// 通用_折扣, -// 通用_密植, -// 通用_超级, -// 通用_究极, -// 通用_极速, -// 通用_强力, -// 通用_专注, -// 通用_迸发, -// 通用_投资, -// 通用_机遇, -// 通用_命运, -// 通用_时停, -// 通用_升级, -// 蒜毒_聚塑, -// 蒜毒_腐蚀, -// 蒜毒_侵蚀, -// 蒜毒_血清, -// 蒜毒_混乱, -// 蒜毒_虚弱, -// 蒜毒_反胃, -// 蒜毒_虫噬, -// 蒜毒_百毒, -// 蒜毒_爆裂 -// } -//} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs deleted file mode 100644 index 9353590..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs +++ /dev/null @@ -1,133 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader.TinyJSON; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Text.RegularExpressions; -using UnityEngine.TextCore.Text; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssBuffMenu))] - public static class AbyssBuffMenu_Patch - { - public static Dictionary abyssBuffData = new Dictionary(); - - [HarmonyPatch(nameof(AbyssBuffMenu.Awake))] - [HarmonyPostfix] - public static void Post_Awake(AbyssBuffMenu __instance) - { - LoadAbyssBuffData(); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - - TranslateWindows(__instance, fontAsset); - } - - [HarmonyPatch(nameof(AbyssBuffMenu.SelectWindow))] - [HarmonyPostfix] - public static void Post_SelectWindow(AbyssBuffMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - TranslateWindows(__instance, fontAsset); - } - - [HarmonyPatch(nameof(AbyssBuffMenu.SetFavorite))] - [HarmonyPostfix] - public static void Post_SetFavorite(AbyssBuffMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - if (abyssBuffData.ContainsKey(text.text)) - { - text.text = abyssBuffData[text.text]; - } - else - { - string translatedRegex = TranslateAbyssBuffRegex(text.text); - if (translatedRegex != null) - { - text.text = translatedRegex; - } - } - - text.font = fontAsset; - } - } - - public static void LoadAbyssBuffData() - { - abyssBuffData.Clear(); - - string abyssBuffText = "{}"; - - if(!Utils.useLocal) - { - string abyssBuffsContent = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/abyss_buffs.json").Result; - - if(abyssBuffsContent != null) - { - abyssBuffText = abyssBuffsContent; - } - else - { - string abyssBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "abyss_buffs.json"); - if(File.Exists(abyssBuffsPath)) - { - abyssBuffText = File.ReadAllText(abyssBuffsPath); - } - } - } - else - { - abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json")); - } - - abyssBuffData = JsonSerializer.Deserialize>(abyssBuffText); - } - - public static string TranslateAbyssBuffRegex(string originalText) - { - foreach (var x in abyssBuffData) - { - if (x.Key.Contains("{value}")) - { - string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)"); - if (Regex.IsMatch(originalText, pattern)) - { - var regex = new Regex(pattern); - var match = regex.Match(originalText); - - return string.Format(x.Value.Replace("value", "0"), match.Groups[1].Value); - } - } - } - - return null; - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs deleted file mode 100644 index 413a7a6..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; -//using UnityEngine.TextCore.Text; -//using UnityEngine.UI; -//using static MelonLoader.MelonLogger; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ - -// [HarmonyPatch(typeof(AbyssCheckInBag))] -// public static class AbyssCheckInBag_Patch -// { -// [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))] -// [HarmonyPostfix] -// private static void MoveFromBag(AbyssCheckInBag __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } - -// [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))] -// [HarmonyPostfix] -// private static void SellIcon(AbyssCheckInBag __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs deleted file mode 100644 index fede3de..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs +++ /dev/null @@ -1,26 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects -//{ -// [HarmonyPatch(typeof(AbyssCheckSellMenu))] -// public static class AbyssCheckSellMenu_Patch -// { -// [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))] -// [HarmonyPostfix] -// private static void SellIcon(AbyssCheckSellMenu __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } - -// [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))] -// [HarmonyPostfix] -// private static void MoveInBag(AbyssCheckSellMenu __instance) -// { -// AbyssMenu2.Instance.UpdateIcons(); -// } -// } -//} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs deleted file mode 100644 index 549f1e7..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs +++ /dev/null @@ -1,48 +0,0 @@ -//using System.Text.RegularExpressions; -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine.TextCore.Text; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(AbyssDevelopMenu))] -// public static class AbyssDevelopMenu_Patch -// { - -// [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))] -// [HarmonyPostfix] -// private static void UpdateInfo(AbyssDevelopMenu __instance) -// { -// __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); -// __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); - -// TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent(); -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)"; - -// Regex regex = new Regex(regexStr); - -// if (regex.IsMatch(upgradeCostText.text)) -// { -// Match match = regex.Match(upgradeCostText.text); -// int groupCount = match.Groups.Count; - -// List 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); -// } - -// upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]); -// upgradeCostText.font = fontAsset; -// } -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssGoods_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssGoods_Patch.cs deleted file mode 100644 index 70a5b12..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssGoods_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssGoods))] - public static class AbyssGoods_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(AbyssGoods.Start))] - private static void Start(AbyssGoods __instance) - { - __instance.costText.text = StringStore.TranslateText(__instance.costText.text, false); - __instance.costText_shadow.text = StringStore.TranslateText(__instance.costText_shadow.text, false); - __instance.hasText.text = StringStore.TranslateText(__instance.hasText.text, false); - __instance.hasText_shadow.text = StringStore.TranslateText(__instance.hasText_shadow.text, false); - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssInfo_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssInfo_Patch.cs deleted file mode 100644 index 1ac118d..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssInfo_Patch.cs +++ /dev/null @@ -1,12 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using System.Threading.Tasks; - -//namespace PvZ_Fusion_Translator.Patches.Managers -//{ -// public class AbyssInfo_Patch -// { -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs deleted file mode 100644 index ab7e8d1..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssLevelEnter))] - public static class AbyssLevelEnter_Patch - { - [HarmonyPatch(nameof(AbyssLevelEnter.SetLevel))] - [HarmonyPostfix] - private static void SetLevel(AbyssLevelEnter __instance) - { - __instance.levelName = StringStore.TranslateText(__instance.levelName); - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssMenu2_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssMenu2_Patch.cs deleted file mode 100644 index 2749e73..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssMenu2_Patch.cs +++ /dev/null @@ -1,104 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; -//using UnityEngine.TextCore.Text; -//using UnityEngine.UI; -//using static MelonLoader.MelonLogger; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ - -// [HarmonyPatch(typeof(AbyssMenu2))] -// public static class AbyssMenu2_Patch -// { -// private static void UpdateAbyss2Text(AbyssMenu2 __instance) -// { -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); -// __instance.buffCountText.font = fontAsset; - -// __instance.money.text = StringStore.TranslateText(__instance.money.text); -// __instance.money.font = fontAsset; - -// __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); -// __instance.refreshText.font = fontAsset; - -// __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); -// __instance.statistics.font = fontAsset; - -// Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; -// if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform); - -// Transform moneyTransform = __instance.transform.FindChild("Money").transform; -// if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform); - -// Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; -// if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform); - -// Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; -// if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform); - -// Transform optionsTransform = __instance.transform.FindChild("Options").transform; -// foreach (AbyssBuffButton abyssBuffButton in optionsTransform.GetComponentsInChildren()) -// { -// foreach (TextMeshProUGUI textMesh in abyssBuffButton.GetComponentsInChildren()) -// { -// textMesh.text = StringStore.TranslateText(textMesh.text); -// } -// } - -// foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) -// { -// text.text = StringStore.TranslateText(text.text); -// text.font = fontAsset; -// } -// } - -// [HarmonyPatch(nameof(AbyssMenu2.Start))] -// [HarmonyPostfix] -// private static void Start(AbyssMenu2 __instance) -// { -// UpdateAbyss2Text(__instance); - -// Utils.ConvertButtonText(__instance.transform, "Help"); - -// // custom bag text :D - -// __instance.transform.FindChild("Bag").FindChild("text").GetComponent().text += "_深渊"; - -// Utils.ConvertButtonText(__instance.transform, "Bag"); -// } - -// [HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))] -// [HarmonyPostfix] -// private static void UpdateIcons(AbyssMenu2 __instance) -// { -// UpdateAbyss2Text(__instance); -// } - -// [HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))] -// [HarmonyPostfix] -// private static void UpdateBuff(AbyssMenu2 __instance) -// { -// UpdateAbyss2Text(__instance); -// } - -// [HarmonyPatch(nameof(AbyssMenu2.BuyBuff))] -// [HarmonyPostfix] -// private static void BuyBuff(AbyssMenu2 __instance) -// { -// UpdateAbyss2Text(__instance); -// } - -// [HarmonyPatch(nameof(AbyssMenu2.ShowBag))] -// [HarmonyPostfix] -// private static void ShowBag(AbyssMenu2 __instance) -// { -// UpdateAbyss2Text(__instance); -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssMenu_Patch.cs deleted file mode 100644 index 93c1b32..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssMenu_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using Unity.VisualScripting; -using UnityEngine; -using System.Text.RegularExpressions; -using UnityEngine.UI; -using MelonLoader.Utils; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssMenu))] - public static class AbyssMenu_Patch - { - [HarmonyPatch(nameof(AbyssMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)"); - txt.font = fontAsset; - } - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - - [HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))] - [HarmonyPostfix] - private static void UpdateLevelInfo(AbyssMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.levelInfo) - { - txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)"); - txt.font = fontAsset; - } - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs deleted file mode 100644 index ee1c2d3..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs +++ /dev/null @@ -1,57 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssSelectBuffWindow))] - public static class AbyssSelectBuffWindow_Patch - { - [HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))] - [HarmonyPostfix] - private static void OnAnimOver(AbyssSelectBuffWindow __instance) - { - TranslateBuffWindow(__instance); - } - - [HarmonyPatch(nameof(AbyssSelectBuffWindow.SetBuff))] - [HarmonyPostfix] - private static void SetBuff(AbyssSelectBuffWindow __instance) - { - TranslateBuffWindow(__instance); - } - - public static void TranslateBuffWindow(AbyssSelectBuffWindow __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - AbyssBuffMenu_Patch.LoadAbyssBuffData(); - - foreach (TextMeshProUGUI titleText in __instance.titleText) - { - if (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(titleText.text)) - { - if(titleText.name.Contains("shadow")) - { - titleText.text = Utils.RemoveColorTags(AbyssBuffMenu_Patch.abyssBuffData[titleText.text]); - } - else - { - titleText.text = AbyssBuffMenu_Patch.abyssBuffData[titleText.text]; - } - } - titleText.font = fontAsset; - } - - string translatedIntroduceText = AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(__instance.introduce.text) ? AbyssBuffMenu_Patch.abyssBuffData[__instance.introduce.text] : AbyssBuffMenu_Patch.TranslateAbyssBuffRegex(__instance.introduce.text); - - if (translatedIntroduceText != null) - { - __instance.introduce.text = translatedIntroduceText; - __instance.introduce.font = fontAsset; - } - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs deleted file mode 100644 index 3ed38cd..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs +++ /dev/null @@ -1,55 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using MelonLoader; -//using PvZ_Fusion_Translator.AssetStore; -//using Unity.VisualScripting; -//using UnityEngine; -//using System.Text.RegularExpressions; - -//namespace PvZ_Fusion_Translator.Patches.GameObjects -//{ -// [HarmonyPatch(typeof(AbyssSettlementMenu))] -// public static class AbyssSettlementMenu_Patch -// { - -// [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))] -// [HarmonyPostfix] -// private static void InitSettle(AbyssSettlementMenu __instance) -// { -// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - -// string[] regexStrList = [ -// "第(\\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+)" -// ]; - -// foreach(string regexStr in regexStrList) -// { -// Regex regex = new Regex(regexStr); - -// if (regex.IsMatch(__instance.settleInfo.text)) -// { -// Match match = regex.Match(__instance.settleInfo.text); -// int groupCount = match.Groups.Count; - -// List 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[regexStr], [.. dynamicParts]); -// __instance.settleInfo.font = fontAsset; -// } -// } -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs b/MelonLoader/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs deleted file mode 100644 index 18946f0..0000000 --- a/MelonLoader/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Abyss -{ - /*[HarmonyPatch(typeof(AbyssStoreMenu))] - public static class AbyssStoreMenu_Patch - { - [HarmonyPatch(nameof(AbyssStoreMenu.Update))] - [HarmonyPostfix] - private static void Update(AbyssStoreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - text.font = fontAsset; - } - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Harvest/GardenBagMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/GardenBagMenu_Patch.cs deleted file mode 100644 index 958b0dc..0000000 --- a/MelonLoader/Patches/Modes/Harvest/GardenBagMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(GardenBagMenu))] - public static class GardenBagMenu_Patch - { - [HarmonyPatch(nameof(GardenBagMenu.Awake))] - [HarmonyPostfix] - private static void Awake(GardenBagMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Transform closeButtonTransform = __instance.transform.Find("Close"); - foreach(TextMeshProUGUI text in closeButtonTransform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/GardenCard_Patch.cs b/MelonLoader/Patches/Modes/Harvest/GardenCard_Patch.cs deleted file mode 100644 index d1baac8..0000000 --- a/MelonLoader/Patches/Modes/Harvest/GardenCard_Patch.cs +++ /dev/null @@ -1,24 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(GardenCard))] - public static class GardenCard_Patch - { - [HarmonyPatch(nameof(GardenCard.Start))] - [HarmonyPostfix] - private static void Start(GardenCard __instance) - { - __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); - } - - [HarmonyPatch(nameof(GardenCard.ChangeCardSprite))] - [HarmonyPostfix] - private static void ChangeCardSprite(GardenCard __instance) - { - __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); - } - } -} diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs deleted file mode 100644 index 2f5c947..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureConfirmMenu))] - public static class TreasureConfirmMenu_Patch - { - [HarmonyPatch(nameof(TreasureConfirmMenu.SetText))] - [HarmonyPostfix] - private static void SetText(TreasureConfirmMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs deleted file mode 100644 index 1033f57..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs +++ /dev/null @@ -1,38 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureEquipmentMenu))] - public static class TreasureEquipmentMenu_Patch - { - [HarmonyPatch(nameof(TreasureEquipmentMenu.Awake))] - [HarmonyPostfix] - private static void Awake(TreasureEquipmentMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureEquipmentMenu.UpdateCards))] - [HarmonyPostfix] - private static void UpdateCards(TreasureEquipmentMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs deleted file mode 100644 index e133b8f..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs +++ /dev/null @@ -1,30 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureEvacuateMenu))] - public static class TreasureEvacuateMenu_Patch - { - [HarmonyPatch(nameof(TreasureEvacuateMenu.Start))] - [HarmonyPostfix] - private static void Start(TreasureEvacuateMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - if(txt.name.Contains("text (1)")) - { - txt.name = txt.name + "_EVACUATE"; - } - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs deleted file mode 100644 index df5b950..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureMainMenu))] - public static class TreasureMainMenu_Patch - { - [HarmonyPatch(nameof(TreasureMainMenu.Update))] - [HarmonyPostfix] - private static void Update(TreasureMainMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureManager_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureManager_Patch.cs deleted file mode 100644 index 9e9f92f..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureManager_Patch.cs +++ /dev/null @@ -1,31 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureManager))] - public static class TreasureManager_Patch - { - [HarmonyPatch(nameof(TreasureManager.Update))] - [HarmonyPostfix] - private static void Update(TreasureManager __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach(TextMeshProUGUI txt in __instance.evaText) - { - txt.autoSizeTextContainer = false; - - if (txt.text != "Evacuate") - { - txt.text = StringStore.TranslateText(txt.text); - txt.name = txt.text + "_EVACUATE"; - txt.font = fontAsset; - } - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs deleted file mode 100644 index 05c3d8c..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureStoreMenu))] - public static class TreasureStoreMenu_Patch - { - [HarmonyPatch(nameof(TreasureStoreMenu.InitCards))] - [HarmonyPostfix] - private static void InitCards(TreasureStoreMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs deleted file mode 100644 index fc8c177..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs +++ /dev/null @@ -1,63 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppSystem; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; -using UnityEngine.UI; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureUpgradeMenu))] - public static class TreasureUpgradeMenu_Patch - { - [HarmonyPatch(nameof(TreasureUpgradeMenu.Start))] - [HarmonyPostfix] - private static void Start(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureUpgradeMenu.UpgradeWareHouse))] - [HarmonyPostfix] - private static void UpgradeWareHouse(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureUpgradeMenu.InitWareHouseUpgrade))] - [HarmonyPostfix] - private static void InitWareHouseUpgrade(TreasureUpgradeMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - - foreach (Text txt in __instance.GetComponentsInChildren()) - { - GameObject newTxtObj = Utils.ConvertToTextMeshProUGUI(txt.gameObject, txt.transform.parent, "text"); - TextMeshProUGUI newTxt = newTxtObj.GetComponent(); - newTxt.text = StringStore.TranslateText("植物商店"); - newTxt.autoSizeTextContainer = true; - newTxt.color = new Color(0, 0, 0.3922f, 1); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs b/MelonLoader/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs deleted file mode 100644 index edddd80..0000000 --- a/MelonLoader/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs +++ /dev/null @@ -1,64 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Harvest -{ - [HarmonyPatch(typeof(TreasureWarehouseMenu))] - public static class TreasureWarehouseMenu_Patch - { - [HarmonyPatch(nameof(TreasureWarehouseMenu.InitCards))] - [HarmonyPostfix] - private static void InitCards(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.QuickSell))] - [HarmonyPostfix] - private static void QuickSell(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.FastSell))] - [HarmonyPostfix] - private static void FastSell(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - - [HarmonyPatch(nameof(TreasureWarehouseMenu.EnterStore))] - [HarmonyPostfix] - private static void EnterStore(TreasureWarehouseMenu __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs deleted file mode 100644 index a8371aa..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs +++ /dev/null @@ -1,61 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using UnityEngine; -using UnityEngine.TextCore.Text; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(MultipleChoiceMenu))] - public static class MultipleChoiceMenu_Patch - { - public static TMP_FontAsset fontAsset => FontStore.LoadTMPFont(Utils.Language.ToString()); - - [HarmonyPatch(nameof(MultipleChoiceMenu.Awake))] - [HarmonyPatch(nameof(MultipleChoiceMenu.Cancel))] - [HarmonyPatch(nameof(MultipleChoiceMenu.Refresh))] - [HarmonyPatch(nameof(MultipleChoiceMenu.TurnPage))] - [HarmonyPatch(nameof(MultipleChoiceMenu.UpdateWindow))] - [HarmonyPostfix] - public static void Awake(MultipleChoiceMenu __instance) - { - foreach(BaseWindow window in __instance.windows) - { - TranslateWindowText(window.title); - TranslateWindowText(window.introduce); - } - - foreach(TheButton button in __instance.GetComponentsInChildren()) - { - foreach(TextMeshProUGUI txt in button.GetComponentsInChildren()) - { - txt.text = StringStore.translationString.ContainsKey(txt.text + "_MC") ? StringStore.TranslateText(txt.text + "_MC") : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } - - public static void TranslateWindowText(TextMeshProUGUI txt) - { - txt.font = fontAsset; - if(StringStore.customLevelString.ContainsKey(txt.text)) - { - txt.text = StringStore.customLevelString[txt.text]; - } - else if(Utils.GetPlantNameFromAlmanac(txt.text) != "") - { - txt.text = Utils.GetPlantNameFromAlmanac(txt.text); - } - else - { - txt.text = StringStore.translationString.ContainsKey(txt.text + "_MC") ? StringStore.TranslateText(txt.text + "_MC") : StringStore.TranslateText(txt.text); - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs deleted file mode 100644 index a29838f..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs +++ /dev/null @@ -1,52 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using System.Text.RegularExpressions; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - /*[HarmonyPatch(typeof(OppositeBuffManager))] - public static class OppositeBuffManager_Patch - { - public static Dictionary buffLinks = TravelMgr_Patch.buffLinks; - public static Dictionary> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs; - public static string badPattern = @"^但(.*)"; - public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}"; - public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - [HarmonyPatch(nameof(OppositeBuffManager.SetText))] - [HarmonyPostfix] - private static void SetText(OppositeBuffManager __instance) - { - *//*if (TravelMgr_Patch.travelBuffString.ContainsKey(__result)) - { - __result = TravelMgr_Patch.travelBuffString[__result]; - } - else if(TravelMgr_Patch.travelBuffString.ContainsKey(TravelMgr_Patch.RemoveBuffName(__result))) - { - __result = TravelMgr_Patch.travelBuffString[TravelMgr_Patch.RemoveBuffName(__result)]; - }*//* - } - - public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List textList, Il2CppSystem.Object buff, bool isBad = false) - { - string buffText = TravelMgr.Instance.GetText(buff); - - foreach (var text in textList) - { - if (isBad) - { - text.text = string.Format(badFormat, buffText); - } - else - { - text.text = buffText; - } - - text.font = fontAsset; - } - } - }*/ -} diff --git a/MelonLoader/Patches/Modes/Odyssey/ShootingManager_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/ShootingManager_Patch.cs deleted file mode 100644 index 514e1a9..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/ShootingManager_Patch.cs +++ /dev/null @@ -1,583 +0,0 @@ -using HarmonyLib; -using Il2CppGameLevel.RogueShooting; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(ShootingManager))] - public static class ShootingManager_Patch - { - [HarmonyPatch(nameof(ShootingManager.RegisterCoreBuff))] - [HarmonyPatch(nameof(ShootingManager.RegisterExpertBuff))] - [HarmonyPatch(nameof(ShootingManager.RegisterGetPlantBuff))] - [HarmonyPatch(nameof(ShootingManager.RegisterOtherBuff))] - [HarmonyPostfix] - public static void UpgradeBuff(ShootingManager __instance, ref Il2Cpp.MultipleChoiceMenu menu) - { - MultipleChoiceMenu_Patch.Awake(menu); - } - - public static void GetBuffs() - { - /*#region code - - AbyssSwordStar t0 = new(); - Bamboo t1 = new(); - BigChomper t4 = new(); - BigGatling t5 = new(); - CabbageCannon t6 = new(); - Cabbagepult t7 = new(); - Cactus t8 = new(); - Caltrop t9 = new(); - CaltropNut t10 = new(); - CattailLour t11 = new(); - CherryChomper t12 = new(); - CherryGatling t13 = new(); - CherrySquash t14 = new(); - Chomper t15 = new(); - Cornpult t17 = new(); - DoomCactus t20 = new(); - DoomChomper t21 = new(); - DoomSniper t22 = new(); - EmeraleBlover t23 = new(); - FireMelon t24 = new(); - FumeShroom t25 = new(); - GarlicFume t26 = new(); - GloomShroom t28 = new(); - GoldCabbage t29 = new(); - HelmetGatling t30 = new(); - HypnoEmperor t31 = new(); - HypnoNut t32 = new(); - HypnoShroom t33 = new(); - IceFumeShroom t34 = new(); - IcePuff t35 = new(); - IFVIronPuff t36 = new(); - IronPuff t37 = new(); - LanternSplit t38 = new(); - LanternUmbrella t39 = new(); - LaserUmbrella t40 = new(); - LotusBamboo t41 = new(); - Melonpult t42 = new(); - NuclearSquash t43 = new(); - ObsidianSpike t44 = new(); - ObsidianWallNut t45 = new(); - PeaMine t46 = new(); - Peashooter t47 = new(); - PortalCorn t48 = new(); - PotatoMine t49 = new(); - ScaredyDoom t54 = new(); - ScaredyShroom t55 = new(); - SmallPuff t57 = new(); - SniperPea t58 = new(); - SnowGatlingPuff t59 = new(); - SpikeRock t61 = new(); - Squalour t62 = new(); - Squash t63 = new(); - StarFruit t64 = new(); - SuperChomper t66 = new(); - SuperHypno t67 = new(); - SuperMelon t68 = new(); - SuperStar t69 = new(); - SuperThreePeater t70 = new(); - SwordStar t71 = new(); - TallNut t72 = new(); - ThreeMine t73 = new(); - ThreePeater t74 = new(); - ThreeSquash t75 = new(); - UltimateBamboo t76 = new(); - UltimateBigChomper t77 = new(); - UltimateBigGatling t78 = new(); - UltimateBlover t79 = new(); - UltimateCabbage t80 = new(); - UltimateCabbageCannon t81 = new(); - UltimateCactus t82 = new(); - UltimateChomper t83 = new(); - UltimateCorn t84 = new(); - UltimateDoomScared t85 = new(); - UltimateFume t86 = new(); - UltimateGatling t87 = new(); - UltimateGloom t88 = new(); - UltimateHelmetGatling t89 = new(); - UltimateHypno t90 = new(); - UltimateLanternSplit t91 = new(); - UltimateMelon t92 = new(); - UltimateMinigun t93 = new(); - UltimatePoisonFume t94 = new(); - UltimateSniperGatling t95 = new(); - UltimateSpring t96 = new(); - UltimateStar t97 = new(); - UltimateStarTorch t98 = new(); - UltimateTallNut t99 = new(); - UltimateWinterMelon t100 = new(); - Umbrellaleaf t101 = new(); - WallNut t103 = new(); - WinterMelon t104 = new(); - - Dictionary t = new(); - - #region 3 - - if(t0.Buffs != null) - { - Utils.TryAdd(t, t0.Role, t0.Role); - } - - if(t1.Buffs != null) - { - Utils.TryAdd(t, t1.Role, t1.Role); - } - - if(t4.Buffs != null) - { - Utils.TryAdd(t, t4.Role, t4.Role); - } - - if(t5.Buffs != null) - { - Utils.TryAdd(t, t5.Role, t5.Role); - } - - if(t6.Buffs != null) - { - Utils.TryAdd(t, t6.Role, t6.Role); - } - - if(t7.Buffs != null) - { - Utils.TryAdd(t, t7.Role, t7.Role); - } - - if(t8.Buffs != null) - { - Utils.TryAdd(t, t8.Role, t8.Role); - } - - if(t9.Buffs != null) - { - Utils.TryAdd(t, t9.Role, t9.Role); - } - - if(t10.Buffs != null) - { - Utils.TryAdd(t, t10.Role, t10.Role); - } - - if(t11.Buffs != null) - { - Utils.TryAdd(t, t11.Role, t11.Role); - } - - if(t12.Buffs != null) - { - Utils.TryAdd(t, t12.Role, t12.Role); - } - - if(t13.Buffs != null) - { - Utils.TryAdd(t, t13.Role, t13.Role); - } - - if(t14.Buffs != null) - { - Utils.TryAdd(t, t14.Role, t14.Role); - } - - if(t15.Buffs != null) - { - Utils.TryAdd(t, t15.Role, t15.Role); - } - - if(t17.Buffs != null) - { - Utils.TryAdd(t, t17.Role, t17.Role); - } - - if(t20.Buffs != null) - { - Utils.TryAdd(t, t20.Role, t20.Role); - } - - if(t21.Buffs != null) - { - Utils.TryAdd(t, t21.Role, t21.Role); - } - - if(t22.Buffs != null) - { - Utils.TryAdd(t, t22.Role, t22.Role); - } - - if(t23.Buffs != null) - { - Utils.TryAdd(t, t23.Role, t23.Role); - } - - if(t24.Buffs != null) - { - Utils.TryAdd(t, t24.Role, t24.Role); - } - - if(t25.Buffs != null) - { - Utils.TryAdd(t, t25.Role, t25.Role); - } - - if(t26.Buffs != null) - { - Utils.TryAdd(t, t26.Role, t26.Role); - } - - if(t28.Buffs != null) - { - Utils.TryAdd(t, t28.Role, t28.Role); - } - - if(t29.Buffs != null) - { - Utils.TryAdd(t, t29.Role, t29.Role); - } - - if(t30.Buffs != null) - { - Utils.TryAdd(t, t30.Role, t30.Role); - } - - if(t31.Buffs != null) - { - Utils.TryAdd(t, t31.Role, t31.Role); - } - - if(t32.Buffs != null) - { - Utils.TryAdd(t, t32.Role, t32.Role); - } - - if(t33.Buffs != null) - { - Utils.TryAdd(t, t33.Role, t33.Role); - } - - if(t34.Buffs != null) - { - Utils.TryAdd(t, t34.Role, t34.Role); - } - - if(t35.Buffs != null) - { - Utils.TryAdd(t, t35.Role, t35.Role); - } - - if(t36.Buffs != null) - { - Utils.TryAdd(t, t36.Role, t36.Role); - } - - if(t37.Buffs != null) - { - Utils.TryAdd(t, t37.Role, t37.Role); - } - - if(t38.Buffs != null) - { - Utils.TryAdd(t, t38.Role, t38.Role); - } - - if(t39.Buffs != null) - { - Utils.TryAdd(t, t39.Role, t39.Role); - } - - if(t40.Buffs != null) - { - Utils.TryAdd(t, t40.Role, t40.Role); - } - - if(t41.Buffs != null) - { - Utils.TryAdd(t, t41.Role, t41.Role); - } - - if(t42.Buffs != null) - { - Utils.TryAdd(t, t42.Role, t42.Role); - } - - if(t43.Buffs != null) - { - Utils.TryAdd(t, t43.Role, t43.Role); - } - - if(t44.Buffs != null) - { - Utils.TryAdd(t, t44.Role, t44.Role); - } - - if(t45.Buffs != null) - { - Utils.TryAdd(t, t45.Role, t45.Role); - } - - if(t46.Buffs != null) - { - Utils.TryAdd(t, t46.Role, t46.Role); - } - - if(t47.Buffs != null) - { - Utils.TryAdd(t, t47.Role, t47.Role); - } - - if(t48.Buffs != null) - { - Utils.TryAdd(t, t48.Role, t48.Role); - } - - if(t49.Buffs != null) - { - Utils.TryAdd(t, t49.Role, t49.Role); - } - - if(t54.Buffs != null) - { - Utils.TryAdd(t, t54.Role, t54.Role); - } - - if(t55.Buffs != null) - { - Utils.TryAdd(t, t55.Role, t55.Role); - } - - if(t57.Buffs != null) - { - Utils.TryAdd(t, t57.Role, t57.Role); - } - - if(t58.Buffs != null) - { - Utils.TryAdd(t, t58.Role, t58.Role); - } - - if(t59.Buffs != null) - { - Utils.TryAdd(t, t59.Role, t59.Role); - } - - if(t61.Buffs != null) - { - Utils.TryAdd(t, t61.Role, t61.Role); - } - - if(t62.Buffs != null) - { - Utils.TryAdd(t, t62.Role, t62.Role); - } - - if(t63.Buffs != null) - { - Utils.TryAdd(t, t63.Role, t63.Role); - } - - if(t64.Buffs != null) - { - Utils.TryAdd(t, t64.Role, t64.Role); - } - - if(t66.Buffs != null) - { - Utils.TryAdd(t, t66.Role, t66.Role); - } - - if(t67.Buffs != null) - { - Utils.TryAdd(t, t67.Role, t67.Role); - } - - if(t68.Buffs != null) - { - Utils.TryAdd(t, t68.Role, t68.Role); - } - - if(t69.Buffs != null) - { - Utils.TryAdd(t, t69.Role, t69.Role); - } - - if(t70.Buffs != null) - { - Utils.TryAdd(t, t70.Role, t70.Role); - } - - if(t71.Buffs != null) - { - Utils.TryAdd(t, t71.Role, t71.Role); - } - - if(t72.Buffs != null) - { - Utils.TryAdd(t, t72.Role, t72.Role); - } - - if(t73.Buffs != null) - { - Utils.TryAdd(t, t73.Role, t73.Role); - } - - if(t74.Buffs != null) - { - Utils.TryAdd(t, t74.Role, t74.Role); - } - - if(t75.Buffs != null) - { - Utils.TryAdd(t, t75.Role, t75.Role); - } - - if(t76.Buffs != null) - { - Utils.TryAdd(t, t76.Role, t76.Role); - } - - if(t77.Buffs != null) - { - Utils.TryAdd(t, t77.Role, t77.Role); - } - - if(t78.Buffs != null) - { - Utils.TryAdd(t, t78.Role, t78.Role); - } - - if(t79.Buffs != null) - { - Utils.TryAdd(t, t79.Role, t79.Role); - } - - if(t80.Buffs != null) - { - Utils.TryAdd(t, t80.Role, t80.Role); - } - - if(t81.Buffs != null) - { - Utils.TryAdd(t, t81.Role, t81.Role); - } - - if(t82.Buffs != null) - { - Utils.TryAdd(t, t82.Role, t82.Role); - } - - if(t83.Buffs != null) - { - Utils.TryAdd(t, t83.Role, t83.Role); - } - - if(t84.Buffs != null) - { - Utils.TryAdd(t, t84.Role, t84.Role); - } - - if(t85.Buffs != null) - { - Utils.TryAdd(t, t85.Role, t85.Role); - } - - if(t86.Buffs != null) - { - Utils.TryAdd(t, t86.Role, t86.Role); - } - - if(t87.Buffs != null) - { - Utils.TryAdd(t, t87.Role, t87.Role); - } - - if(t88.Buffs != null) - { - Utils.TryAdd(t, t88.Role, t88.Role); - } - - if(t89.Buffs != null) - { - Utils.TryAdd(t, t89.Role, t89.Role); - } - - if(t90.Buffs != null) - { - Utils.TryAdd(t, t90.Role, t90.Role); - } - - if(t91.Buffs != null) - { - Utils.TryAdd(t, t91.Role, t91.Role); - } - - if(t92.Buffs != null) - { - Utils.TryAdd(t, t92.Role, t92.Role); - } - - if(t93.Buffs != null) - { - Utils.TryAdd(t, t93.Role, t93.Role); - } - - if(t94.Buffs != null) - { - Utils.TryAdd(t, t94.Role, t94.Role); - } - - if(t95.Buffs != null) - { - Utils.TryAdd(t, t95.Role, t95.Role); - } - - if(t96.Buffs != null) - { - Utils.TryAdd(t, t96.Role, t96.Role); - } - - if(t97.Buffs != null) - { - Utils.TryAdd(t, t97.Role, t97.Role); - } - - if(t98.Buffs != null) - { - Utils.TryAdd(t, t98.Role, t98.Role); - } - - if(t99.Buffs != null) - { - Utils.TryAdd(t, t99.Role, t99.Role); - } - - if(t100.Buffs != null) - { - Utils.TryAdd(t, t100.Role, t100.Role); - } - - if(t101.Buffs != null) - { - Utils.TryAdd(t, t101.Role, t101.Role); - } - - if(t103.Buffs != null) - { - Utils.TryAdd(t, t103.Role, t103.Role); - } - - if(t104.Buffs != null) - { - Utils.TryAdd(t, t104.Role, t104.Role); - } - - #endregion - - File.WriteAllText("tge_roles.json", FileLoader.SerializeWithIndentation(t)); - - #endregion*/ - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs deleted file mode 100644 index 2ec60a3..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using UnityEngine; -using MelonLoader; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(SynergyDisplay))] - public static class SynergyDisplay_Patch - { - [HarmonyPatch(nameof(SynergyDisplay.Start))] - [HarmonyPostfix] - public static void Start(SynergyDisplay __instance) - { - __instance.text.text = TranslateInvestDisplay(__instance.text.text); - } - - public static string TranslateInvestDisplay(string originalText) - { - string[] parts = originalText.Split("\n\n"); - List translatedParts = new List(); - foreach(string part in parts) - { - translatedParts.Add(StringStore.TranslateColorText(part)); - } - return String.Join("\n\n", translatedParts); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs deleted file mode 100644 index 4411728..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelAdvantureMenu))] - public static class TravelAdvantureMenu_Patch - { - [HarmonyPatch(nameof(TravelAdvantureMenu.Awake))] - [HarmonyPostfix] - public static void Awake(TravelAdvantureMenu __instance) - { - foreach(CustomButton_enterGame button in __instance.GetComponentsInChildren()) - { - string plantName = Utils.GetPlantNameFromAlmanac(button.levelName.text); - if(Utils.Language == Utils.LanguageEnum.Arabic) - { - button.levelName.text = StringStore.TranslateText(button.levelName.text); - } - else - { - button.levelName.text = (plantName != "") ? plantName : StringStore.TranslateText(button.levelName.text); - } - } - } - - [HarmonyPatch(nameof(TravelAdvantureMenu.LookWeak))] - [HarmonyPostfix] - public static void LookWeak(TravelAdvantureMenu __instance) - { - Awake(__instance); - } - - [HarmonyPatch(nameof(TravelAdvantureMenu.LookUlti))] - [HarmonyPostfix] - public static void LookUlti(TravelAdvantureMenu __instance) - { - Awake(__instance); - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs deleted file mode 100644 index 84c83bc..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs +++ /dev/null @@ -1,35 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using UnityEngine; -using MelonLoader; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelBuffMenu))] - public static class TravelBuffMenu_Patch - { - [HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))] - [HarmonyPostfix] - public static void RefeshOptions(TravelBuffMenu __instance) - { - foreach (TravelBuffOptionButton button in __instance.options) - { - TravelBuffOptionButton_Patch.TranslateOptionButton(button); - } - } - - [HarmonyPatch(nameof(TravelBuffMenu.Awake))] - [HarmonyPostfix] - public static void Awake(TravelBuffMenu __instance) - { - Transform refreshTransform = __instance.transform.Find("Refresh"); - foreach (TextMeshProUGUI text in refreshTransform.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs deleted file mode 100644 index 7d583df..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs +++ /dev/null @@ -1,27 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; -//using System.Text.Encodings.Web; -//using System.Text.Json; - -//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -//{ -// [HarmonyPatch(typeof(TravelBuffMgr))] -// public static class TravelBuffMgr_Patch -// { -// [HarmonyPatch(nameof(TravelBuffMgr.Awake))] -// [HarmonyPostfix] -// private static void Awake(TravelBuffMgr __instance) -// { -// __instance.text = AssetStore.StringStore.TranslateText(__instance.text); -// __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); -// } - -// [HarmonyPatch(nameof(TravelBuffMgr.ShowText), new Type[] { typeof(int), typeof(int) })] -// [HarmonyPostfix] -// private static void ShowText(TravelBuffMgr __instance) -// { -// __instance.text = AssetStore.StringStore.TranslateText(__instance.text); -// __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); -// } -// } -//} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs deleted file mode 100644 index a20704f..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs +++ /dev/null @@ -1,51 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using static MelonLoader.MelonLogger; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelBuffOptionButton))] - public static class TravelBuffOptionButton_Patch - { - [HarmonyPatch(nameof(TravelBuffOptionButton.Awake))] - [HarmonyPostfix] - public static void Awake(TravelBuffOptionButton __instance) - { - TranslateOptionButton(__instance); - } - - [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))] - [HarmonyPostfix] - public static void OnAnimOver(TravelBuffOptionButton __instance) - { - TranslateOptionButton(__instance); - } - - public static void TranslateOptionButton(TravelBuffOptionButton button) - { - if(TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text)) - { - string translatedBuff = travelBuffString[button.introduce.text]; - button.introduce.text = AddBuffName(translatedBuff); - } - - if(!Utils.CheckForUntranslatedText(button.introduce.text)) - { - button.introduce.text = AddBuffName(button.introduce.text); - } - - if(!TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text) && Utils.CheckForUntranslatedText(button.introduce.text)) - { - button.introduce.text = StringStore.TranslateText(button.introduce.text); - } - } - } - - //List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - //string buff = (__instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText("无"); - //__instance.introduce.text = buff; -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelBuff_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelBuff_Patch.cs deleted file mode 100644 index fbed59a..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelBuff_Patch.cs +++ /dev/null @@ -1,18 +0,0 @@ -//using HarmonyLib; -//using Il2Cpp; - -//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -//{ -// [HarmonyPatch(typeof(TravelBuff))] -// public static class TravelBuff_Patch -// { -// [HarmonyPatch(nameof(TravelBuff.OnMouseUpAsButton))] -// [HarmonyPostfix] -// private static void OnMouseUpAsButton() -// { -// if (TravelBuffMgr.Instance == null) return; -// TravelBuffMgr.Instance.text = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text); -// TravelBuffMgr.Instance.text2 = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text2); -// } -// } -//} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs deleted file mode 100644 index bef66f2..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelInvestMenu))] - public static class TravelInvestMenu_Patch - { - [HarmonyPatch(nameof(TravelInvestMenu.Start))] - [HarmonyPostfix] - private static void Start(TravelInvestMenu __instance) - { - Transform titleText = __instance.transform.Find("Title"); - TextMeshProUGUI shadowText = titleText.GetComponent(); - - TextMeshProUGUI regularText = titleText.transform.Find("Title2").GetComponent(); - regularText.text = StringStore.TranslateText(regularText.text); - - shadowText.text = Utils.RemoveColorTags(regularText.text); - } - - [HarmonyPatch(nameof(TravelInvestMenu.RefreshBuff))] - [HarmonyPostfix] - private static void RefreshBuff(TravelInvestMenu __instance, ref TravelBuffOptionButton option) - { - TravelBuffOptionButton_Patch.TranslateOptionButton(option); - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs deleted file mode 100644 index 53c1360..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs +++ /dev/null @@ -1,70 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using UnityEngine; -using MelonLoader; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelLookBuff))] - public static class TravelLookBuff_Patch - { - [HarmonyPatch(nameof(TravelLookBuff.Clear))] - [HarmonyPostfix] - public static void Post_Clear(TravelLookBuff __instance) - { - __instance.introduce.text = StringStore.TranslateText("无"); - __instance.set = false; - - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))] - [HarmonyPostfix] - public static void Post_OnMouseUpAsButton(TravelLookBuff __instance) - { - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(TravelLookBuff.SetBuff))] - [HarmonyPostfix] - public static void Post_SetBuff(TravelLookBuff __instance) - { - /*SortedDictionary buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = buffSet.ContainsKey(__instance.buffIndex) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText;*/ - - foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Introduce").GetComponentsInChildren()) - { - if(TravelMgr_Patch.travelBuffString.ContainsKey(text.text)) - { - string translatedBuff = travelBuffString[text.text]; - text.text = AddBuffName(translatedBuff); - } - - if(!Utils.CheckForUntranslatedText(text.text)) - { - text.text = AddBuffName(text.text); - } - - 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()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs deleted file mode 100644 index cda2c7a..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs +++ /dev/null @@ -1,46 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelLookMenu))] - public static class TravelLookMenu_Patch - { - public static string savedAssetString = ""; - - [HarmonyPatch(nameof(TravelLookMenu.Start))] - [HarmonyPostfix] - private static void Postfix_Start(TravelLookMenu __instance) - { - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - Transform quitButtonTransform = __instance.transform.Find("Quit"); - foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText("合上"); - txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); - } - - __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); - savedAssetString = __instance.treasureText.text; - } - - [HarmonyPatch(nameof(TravelLookMenu.Update))] - [HarmonyPostfix] - private static void Update(TravelLookMenu __instance) - { - if (savedAssetString != __instance.treasureText.text) - { - __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); - savedAssetString = __instance.treasureText.text; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs deleted file mode 100644 index e96322e..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs +++ /dev/null @@ -1,367 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Threading.Tasks; -using Unity.Collections; -using UnityEngine.Rendering; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - public class TravelBuffInfo - { - public string name = ""; - public string desc = ""; - - public TravelBuffInfo(string name_a = "", string desc_a = "") - { - name = name_a; - desc = desc_a; - } - } - - public class TravelBuffSet - { - public SortedDictionary advancedBuffs = new(); - public SortedDictionary ultimateBuffs = new(); - public SortedDictionary debuffs = new(); - public SortedDictionary unlocks = new(); - public SortedDictionary investmentBuffs = new(); - private Dictionary> _travelBuffSets = []; - - public TravelBuffSet() - { - advancedBuffs = new(); - ultimateBuffs = new(); - debuffs = new(); - unlocks = new(); - investmentBuffs = new(); - - _travelBuffSets = new() - { - { "advancedBuffs", advancedBuffs }, - { "ultimateBuffs", ultimateBuffs }, - { "debuffs", debuffs }, - { "unlocks", unlocks }, - { "investmentBuffs", investmentBuffs } - }; - } - - public SortedDictionary TryGet(string name) - { - switch(name) - { - case "advancedBuffs": - return advancedBuffs; - case "ultimateBuffs": - return ultimateBuffs; - case "debuffs": - return debuffs; - case "unlocks": - return unlocks; - case "investmentBuffs": - return investmentBuffs; - default: - return null; - } - } - - public IEnumerator>> GetEnumerator() - { - foreach(var item in _travelBuffSets) - { - yield return new(item.Key, item.Value); - } - } - } - - [HarmonyPatch(typeof(TravelMgr))] - public static class TravelMgr_Patch - { - public static readonly TravelBuffSet templateTravelBuffs = new(); - - public static TravelBuffSet dumpedTravelBuffs = new(); - - public static TravelBuffSet translatedTravelBuffs = new(); - - public static Dictionary travelBuffString = new() - { - - }; - - public static Dictionary buffLinks = new() - { - { BuffType.AdvancedBuff, "advancedBuffs" }, - { BuffType.UltimateBuff, "ultimateBuffs" }, - { BuffType.Debuff, "debuffs" }, - { BuffType.UnlockPlant, "unlocks" }, - { BuffType.InvestmentBuff, "investmentBuffs" } - }; - - [HarmonyPatch(nameof(TravelMgr.GetText))] - [HarmonyPostfix] - public static void GetText(TravelMgr __instance, ref string __result) - { - if (travelBuffString.ContainsKey(__result)) - { - __result = travelBuffString[__result]; - } - else if(travelBuffString.ContainsKey(RemoveBuffName(__result))) - { - __result = travelBuffString[RemoveBuffName(__result)]; - } - else - { - __result = StringStore.TranslateText(__result); - } - } - - public static void DumpTravelBuffs() - { - TravelMgr.Instance.GetPlantBuffUnlockCount(PlantType.DoomGatling); - - dumpedTravelBuffs = new(); - travelBuffString.Clear(); - - foreach (var pair in TravelDictionary.advancedBuffsText) - { - Utils.TryAdd(dumpedTravelBuffs.advancedBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value)); - Utils.TryAdd(travelBuffString, pair.Value, pair.Value); - } - - foreach (var pair in TravelDictionary.ultimateBuffsText) - { - Utils.TryAdd(dumpedTravelBuffs.ultimateBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value)); - Utils.TryAdd(travelBuffString, pair.Value, pair.Value); - } - - foreach (var pair in TravelDictionary.debuffData) - { - Utils.TryAdd(dumpedTravelBuffs.debuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value.Item1)); - Utils.TryAdd(travelBuffString, pair.Value.Item1, pair.Value.Item1); - } - - foreach (var pair in TravelDictionary.unlocksText) - { - Utils.TryAdd(dumpedTravelBuffs.unlocks, (int)pair.Key, new TravelBuffInfo("", pair.Value)); - Utils.TryAdd(travelBuffString, pair.Value, pair.Value); - } - - foreach (var pair in TravelMgr.InvestBuffsData) - { - Utils.TryAdd(dumpedTravelBuffs.investmentBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value.GetDescription())); - Utils.TryAdd(travelBuffString, pair.Value.GetDescription(), pair.Value.GetDescription()); - } - - File.WriteAllText(Path.Combine(GetAssetDir(AssetType.Dumps), "travel_buffs.json"), SerializeWithIndentation(dumpedTravelBuffs)); - - string translatedTravelBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "travel_buffs.json"); - - if (!File.Exists(translatedTravelBuffsPath)) - { - File.WriteAllText(translatedTravelBuffsPath, SerializeWithIndentation(dumpedTravelBuffs)); - translatedTravelBuffs = dumpedTravelBuffs; - } - } - - //System.Text.Json.JsonSerializer.Deserialize>>(travelBuffsContent); - public static void GenerateTranslatedTravelBuffs(string travelBuffsContent) - { - if (!Core.isInitialized) return; - - DumpTravelBuffs(); - - TravelBuffSet travelBuffs = Newtonsoft.Json.JsonConvert.DeserializeObject(travelBuffsContent); - translatedTravelBuffs = travelBuffs; - travelBuffString.Clear(); - - foreach(var i in travelBuffs) - { - var originalBuffSet = dumpedTravelBuffs.TryGet(i.Item1); - foreach(var j in originalBuffSet) - { - TravelBuffInfo originalBuff = j.Value; - var translatedBuffSet = travelBuffs.TryGet(i.Item1); - - if (j.Value.desc == originalBuff.desc) - { - if (translatedBuffSet.ContainsKey(j.Key)) - { - Utils.TryAdd(travelBuffString, originalBuff.desc, translatedBuffSet[j.Key].desc); - } - } - else if(j.Value.desc == RemoveBuffName(originalBuff.desc)) - { - if (translatedBuffSet.ContainsKey(j.Key)) - { - Utils.TryAdd(travelBuffString, originalBuff.desc, translatedBuffSet[j.Key].desc); - } - } - - /*var translatedBuffSet = travelBuffs[i.Key]; - if(translatedBuffSet.ContainsKey(j.Key)) - { - string translatedBuff = travelBuffs[i.Key][j.Key]; - travelBuffString[originalBuff] = translatedBuff; - }*/ - } - } - - string travelBuffsToSave = SerializeWithIndentation(TravelMgr_Patch.translatedTravelBuffs); - string stringDir = GetAssetDir(AssetType.Strings, Utils.Language); - File.WriteAllText(Path.Combine(stringDir, "travel_buffs.json"), travelBuffsToSave); - } - - public static string MatchTravelBuff(string originalText) - { - string res = ""; - - foreach (var i in dumpedTravelBuffs) - { - foreach (var j in dumpedTravelBuffs.TryGet(i.Item1)) - { - if (j.Value.desc == originalText || j.Value.desc == RemoveBuffName(originalText)) - { - var translatedBuffSet = translatedTravelBuffs.TryGet(i.Item1); - if (translatedBuffSet.ContainsKey(j.Key)) - { - res = translatedBuffSet[j.Key].desc; - } - break; - } - } - - if (res != "") break; - } - - return res; - } - - public static string RemoveBuffName(string buffText) - { - string res = buffText; - int firstColon = res.IndexOf(":"); - if(firstColon > 0) - { - res = res.Substring(firstColon + 1); - } - return res; - } - - public static Dictionary modifierNameDict = new Dictionary() - { - { "advancedBuffs", "COMMON_MODIFIER_TAG" }, - { "ultimateBuffs", "EPIC_MODIFIER_TAG" }, - { "debuffs", "ZOMBIE_MODIFIER_TAG" }, - { "unlocks", "UNLOCK_MODIFIER_TAG" }, - { "investmentBuffs", "INVEST_MODIFIER_TAG" } - }; - - public static Dictionary fallbackNameDict = new Dictionary() - { - { "COMMON_MODIFIER_TAG", "Common Modifier" }, - { "EPIC_MODIFIER_TAG", "Epic Modifier" }, - { "ZOMBIE_MODIFIER_TAG", "Zombie Modifier" }, - { "UNLOCK_MODIFIER_TAG", "Unlock Modifier" }, - { "INVEST_MODIFIER_TAG", "Investment Modifier" } - }; - - public static string TranslateNameTag(string originalText) - { - string res = originalText; - - string nameTag = modifierNameDict[originalText]; - res = StringStore.translationString.ContainsKey(nameTag) ? StringStore.TranslateText(nameTag) : fallbackNameDict[nameTag]; - - return res; - } - - public static ValueTuple FindBuffData(string buffText) - { - ValueTuple res = new(); - foreach(var pair1 in translatedTravelBuffs) - { - foreach(var pair2 in pair1.Item2) - { - if(buffText == pair2.Value.desc) - { - if(pair2.Value.name != "") - { - res.Item1 = pair2.Value.name; - res.Item4 = true; - } - else - { - res.Item1 = TranslateNameTag(pair1.Item1); - res.Item4 = false; - } - res.Item2 = pair2.Key; - } - } - } - - foreach(var pair1 in dumpedTravelBuffs) - { - foreach(var pair2 in pair1.Item2) - { - if(buffText == pair2.Value.desc) - { - if(pair2.Value.name != "") - { - res.Item1 = pair2.Value.name; - res.Item4 = true; - } - else - { - res.Item1 = TranslateNameTag(pair1.Item1); - res.Item4 = false; - } - res.Item2 = pair2.Key; - } - } - } - - string finalBuffText = buffText; - if(travelBuffString.ContainsKey(buffText)) - { - finalBuffText = travelBuffString[buffText]; - } - else - { - finalBuffText = StringStore.TranslateText(buffText); - } - res.Item3 = finalBuffText; - - return res; - } - - public static string fallbackFBuffStr = "{0}: {1}"; - - public static string AddBuffName(string buffText) - { - string translatedBuff = buffText; - if(Utils.CheckForUntranslatedText(buffText)) - { - if(travelBuffString.ContainsKey(buffText)) - { - translatedBuff = travelBuffString[buffText]; - } - } - var buffData = FindBuffData(translatedBuff); - if(buffData.Item1 != null && buffData.Item3 != null) - { - string buffFStr = StringStore.translationStringRegex.ContainsKey("BUFF_NAME_FORMAT") ? StringStore.translationStringRegex["BUFF_NAME_FORMAT"] : "{0}: {1}"; - string fBuffDesc = string.Format(buffFStr, buffData.Item1, buffData.Item3); - translatedBuff = fBuffDesc; - } - - return translatedBuff; - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs deleted file mode 100644 index 5d58593..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelRefresh))] - public static class TravelRefresh_Patch - { - [HarmonyPatch(nameof(TravelRefresh.Awake))] - [HarmonyPostfix] - private static void Awake(TravelRefresh __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); - } - - [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))] - [HarmonyPostfix] - private static void OnMouseUpAsButton(TravelRefresh __instance) - { - __instance.text = StringStore.TranslateText(__instance.text); - __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs deleted file mode 100644 index b8fc49f..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs +++ /dev/null @@ -1,93 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -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 -{ - [HarmonyPatch(typeof(TravelStoreWindow))] - public static class TravelStoreWindow_Patch - { - [HarmonyPatch(nameof(TravelStoreWindow.SetType))] - [HarmonyPostfix] - private static void SetType(TravelStoreWindow __instance) - { - /*var buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - - string buff = __instance.show != null && __instance.introduce.text != "词条已选完" ? buffSet[__instance.buffIndex] : StringStore.TranslateText("词条已选完");*/ - string originalText = __instance.introduce.text; - string affinityPattern = "([\\s\\S]+)(\\\n)([\\s\\S]+)(<\\/color>)"; - if(Regex.IsMatch(__instance.introduce.text, affinityPattern, options: RegexOptions.Singleline)) - { - 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 = AddBuffName(startText) + affinities; - } - else - { - __instance.introduce.text = AddBuffName(originalText); - } - - foreach (var text in __instance.buttonText) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(TravelStoreWindow.UpdateButtonText))] - [HarmonyPostfix] - private static void UpdateButtonText(TravelStoreWindow __instance) - { - foreach (var text in __instance.buttonText) - { - text.text = StringStore.TranslateText(text.text); - } - } - - public static string TranslateAffinities(string originalText) - { - string result = ""; - List translatedAffinities = []; - - string[] lines = originalText.Split('\n'); - - foreach(string line in lines) - { - if (string.IsNullOrEmpty(line)) continue; - - string fStr = StringStore.translationStringRegex.ContainsKey("【([^\\s]+)】_IV") ? StringStore.translationStringRegex["【([^\\s]+)】_IV"] : "[{0}]"; - - // 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 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 - string translatedAffinity = string.Format(fStr, [.. dynamicParts]); - translatedAffinities.Add(translatedAffinity); - } - - result = "\n" + "" + String.Join("\n", translatedAffinities) + ""; - return result; - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs deleted file mode 100644 index dc07b75..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs +++ /dev/null @@ -1,96 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelStore))] - public static class TravelStore_Patch - { - [HarmonyPatch(nameof(TravelStore.Start))] - [HarmonyPostfix] - private static void Start(TravelStore __instance) - { - TranslateStoreText(__instance); - } - - [HarmonyPatch(nameof(TravelStore.Update))] - [HarmonyPostfix] - private static void Update(TravelStore __instance) - { - TranslateStoreText(__instance); - } - - [HarmonyPatch(nameof(TravelStore.RefreshBuff))] - [HarmonyPostfix] - private static void RefreshBuff(TravelStore __instance) - { - TranslateStoreText(__instance); - } - - [HarmonyPatch(nameof(TravelStore.SelectBuff))] - [HarmonyPostfix] - private static void SelectBuff(TravelStore __instance, ref TravelStoreWindow window) - { - TranslateStoreText(__instance); - - foreach (var text in window.buttonText) - { - text.text = StringStore.TranslateText(text.text); - } - - __instance.investText.text = TranslateInvestText(__instance.investText.text); - __instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text); - } - - public static void TranslateStoreText(TravelStore __instance) - { - __instance.investText.text = TranslateInvestText(__instance.investText.text); - __instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text); - - foreach (var text in __instance.pointText) - { - text.text = StringStore.TranslateText(text.text); - } - foreach (var text in __instance.refreshText) - { - text.text = StringStore.TranslateText(text.text); - } - foreach(var text in __instance.transform.Find("Quit").GetComponentsInChildren()) - { - text.text = StringStore.TranslateText("合上"); - } - } - - public static string TranslateInvestText(string investText) - { - string res = investText; - - if(!Utils.CheckForUntranslatedText(res)) - { - return res; - } - - string[] investStats = investText.Split("\n\n"); - List translatedInvestStats = new List(); - foreach(string investStat in investStats) - { - string[] lines = investStat.Split("\n"); - List translatedLines = new List(); - foreach(string line in lines) - { - translatedLines.Add(StringStore.TranslateColorText(line)); - } - string translatedInvestStat = String.Join("\n", translatedLines); - translatedInvestStats.Add(translatedInvestStat); - } - - res = String.Join("\n\n", translatedInvestStats); - - return res; - } - } -} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs deleted file mode 100644 index 4c1f8a0..0000000 --- a/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs +++ /dev/null @@ -1,107 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; -using UnityEngine; -using System.Text.RegularExpressions; - -namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -{ - [HarmonyPatch(typeof(TravelSynergyMenu))] - public static class TravelSynergyMenu_Patch - { - [HarmonyPatch(nameof(TravelSynergyMenu.Awake))] - [HarmonyPostfix] - public static void Awake(TravelSynergyMenu __instance) - { - Transform background = __instance.transform.Find("Background"); - Transform tip = __instance.transform.Find("Text (TMP)"); - - foreach(TextMeshProUGUI text in background.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - - foreach (TextMeshProUGUI text in tip.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } - - [HarmonyPatch(typeof(SynergyNode))] - public static class SynergyNode_Patch - { - [HarmonyPatch(nameof(SynergyNode.InitNode))] - [HarmonyPostfix] - public static void InitNode(SynergyNode __instance) - { - int firstNewlineIndex = __instance.synergyTitle.text.IndexOf("\n"); - string title = __instance.synergyTitle.text.Substring(0, firstNewlineIndex); - string description = __instance.synergyTitle.text.Substring(firstNewlineIndex + 1); - description = (description.Substring(0, 8) == "") ? description.Substring(8) : description; - - string pattern = @"]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+"; - string smallPattern = @"(]+>)(.*?)()"; - MatchCollection matches = Regex.Matches(description, pattern); - string translatedDescription = ""; - foreach(Match match in matches) - { - Match colorMatch = Regex.Match(match.Value, smallPattern, RegexOptions.Singleline); - if (colorMatch.Success) - { - translatedDescription += colorMatch.Groups[1].Value + TranslateSegment(colorMatch.Groups[2].Value) + colorMatch.Groups[3].Value; - } - else - { - translatedDescription += TranslateSegment(match.Value) + "\n"; - } - } - - __instance.synergyTitle.text = "" + StringStore.TranslateColorText(title) + "\n" + translatedDescription; - } - - public static string TranslateSegment(string text) - { - string res = ""; - - List parts = SplitSecondNewLines(text); - - foreach(string part in parts) - { - string temp = ""; - string[] lines = part.Split('\n'); - if(lines.Length > 1) - { - temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]); - } - res += temp + "\n"; - } - return res.Substring(0, res.Length - 1); - } - - public static List SplitSecondNewLines(string originalText) - { - List results = new List(); - - string[] lines = originalText.Split('\n'); - for (int i = 0; i < lines.Length; i += 2) - { - string res = ""; - if(i + 1 < lines.Length) - { - res = lines[i] + "\n" + lines[i + 1]; - results.Add(res); - } - else - { - res = lines[i]; - results.Add(res); - } - } - - return results; - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs deleted file mode 100644 index 0564ff5..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs +++ /dev/null @@ -1,77 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureEvolutionMenu))] - public static class AdvantureEvolutionMenu_Patch - { - [HarmonyPatch(nameof(AdvantureMenu.Awake))] - [HarmonyPostfix] - public static void Awake(AdvantureEvolutionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - Transform baseWindow = __instance.transform.Find("BaseWindow"); - Transform advancedWindow = __instance.transform.Find("AdvancedWindow"); - - if(baseWindow != null) - { - foreach(TextMeshProUGUI text in baseWindow.GetComponentsInChildren()) - { - if(text.gameObject.name.Contains("Name")) - { - text.text = Utils.GetPlantNameFromAlmanac(__instance.thePlantType); - } - } - } - - if (advancedWindow != null) - { - foreach (TextMeshProUGUI text in advancedWindow.GetComponentsInChildren()) - { - if (text.gameObject.name.Contains("Name")) - { - text.text = Utils.GetPlantNameFromAlmanac(__instance.thePlantType); - } - } - } - } - - [HarmonyPatch(nameof(AdvantureEvolutionMenu.UpdateText))] - [HarmonyPostfix] - public static void UpdateText(AdvantureEvolutionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureEvolutionMenu.RollEvolution))] - [HarmonyPostfix] - public static void RollEvolution(AdvantureEvolutionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureEvolutionMenu.RollEvolutionGood))] - [HarmonyPostfix] - public static void RollEvolutionGood(AdvantureEvolutionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs deleted file mode 100644 index 4f9751f..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs +++ /dev/null @@ -1,21 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureHelpMenu))] - public static class AdvantureHelpMenu_Patch - { - [HarmonyPatch(nameof(AdvantureHelpMenu.InitText))] - [HarmonyPostfix] - private static void InitText(AdvantureHelpMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs deleted file mode 100644 index 46814ba..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureMenu2))] - public static class AdvantureMenu2_Patch - { - [HarmonyPatch(nameof(AdvantureMenu2.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureMenu2 __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureMenu2.AdjustDifficulty))] - [HarmonyPostfix] - private static void AdjustDifficulty(AdvantureMenu2 __instance) - { - __instance.difficulty.text = StringStore.TranslateText(__instance.difficulty.text); - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureMenu_Patch.cs deleted file mode 100644 index 91c593b..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureMenu_Patch.cs +++ /dev/null @@ -1,64 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureMenu))] - public static class AdvantureMenu_Patch - { - [HarmonyPatch(nameof(AdvantureMenu.Start))] - [HarmonyPostfix] - private static void Start(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.ChangeDifficulty))] - [HarmonyPostfix] - private static void ChangeDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.GetChapterDifficulty))] - [HarmonyPostfix] - private static void GetChapterDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.UpdateChapterDifficulty))] - [HarmonyPostfix] - private static void UpdateChapterDifficulty(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - [HarmonyPatch(nameof(AdvantureMenu.UpdateStarCount))] - [HarmonyPostfix] - private static void UpdateStarCount(AdvantureMenu __instance) - { - TranslateAdvantureMenu(__instance); - } - - public static void TranslateAdvantureMenu(AdvantureMenu __instance) - { - bool hasSBString = StringStore.translationString.ContainsKey(__instance.difficulty.text + "_SB"); - __instance.difficulty.text = Utils.RemoveSizeTags(hasSBString ? StringStore.TranslateText(__instance.difficulty.text + "_SB") : StringStore.TranslateText(__instance.difficulty.text)); - __instance.chapterDifficulty.text = StringStore.TranslateText(__instance.chapterDifficulty.text); - __instance.starCount.text = StringStore.TranslateText(__instance.starCount.text); - - foreach (TextMeshProUGUI text in __instance.title) - { - text.text = StringStore.TranslateText(text.text); - } - - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs deleted file mode 100644 index 2aac117..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs +++ /dev/null @@ -1,56 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureMissionMenu))] - public static class AdvantureMissionMenu_Patch - { - [HarmonyPatch(nameof(AdvantureMissionMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureMissionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - - [HarmonyPatch(nameof(AdvantureMissionMenu.InitText))] - [HarmonyPostfix] - private static void InitText(AdvantureMissionMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - - [HarmonyPatch(nameof(AdvantureMissionMenu.SwitchAward))] - [HarmonyPostfix] - private static void SwitchAward(AdvantureMissionMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.contant.GetComponentsInChildren()) - { - text.text = StringStore.TranslateColorText(text.text); - } - - //foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - //{ - // text.text = StringStore.TranslateText(text.text); - //} - } - } -} diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs deleted file mode 100644 index 2b8c4b1..0000000 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs +++ /dev/null @@ -1,61 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Starbound -{ - [HarmonyPatch(typeof(AdvantureStarMenu))] - public static class AdvantureStarMenu_Patch - { - [HarmonyPatch(nameof(AdvantureStarMenu.Awake))] - [HarmonyPostfix] - private static void Awake(AdvantureStarMenu __instance) - { - foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.GetNodes))] - [HarmonyPostfix] - private static void GetNodes(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.UpdateStarText))] - [HarmonyPostfix] - private static void UpdateStarText(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.InitTalents))] - [HarmonyPostfix] - private static void InitTalents(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - - [HarmonyPatch(nameof(AdvantureStarMenu.ResetAward))] - [HarmonyPostfix] - private static void ResetAward(AdvantureStarMenu __instance) - { - foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) - { - text.text = StringStore.TranslateText(text.text); - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs deleted file mode 100644 index a99986d..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs +++ /dev/null @@ -1,104 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppGameLevel; -using Il2CppGameLevel.EventNodes; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Threading.Tasks; -using Unity.VisualScripting.FullSerializer; -using UnityEngine; -using UnityEngine.UIElements; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomButton_enterGame))] - public static class CustomButton_enterGame_Patch - { - [HarmonyPatch(nameof(CustomButton_enterGame.LoadOnlineLevelAsync))] - [HarmonyPostfix] - public static void LoadOnlineLevelAsync(CustomButton_enterGame __instance) - { - string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); - Dictionary dumpData = new Dictionary(); - - if (!File.Exists(dumpPath)) - { - File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - - dumpData = JsonSerializer.Deserialize>(File.ReadAllText(dumpPath)); - - string dumpStringsPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_strings.json"); - Dictionary dumpStringsData = new Dictionary(); - - if (!File.Exists(dumpStringsPath)) - { - File.WriteAllText(dumpStringsPath, System.Text.Json.JsonSerializer.Serialize(dumpStringsData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - - dumpStringsData = JsonSerializer.Deserialize>(File.ReadAllText(dumpStringsPath)); - - var level = __instance; - - if(level.onlineLevelInfo != null) - { - string levelId = level.onlineLevelInfo.levelId; - if(levelId != null) - { - SerializedLevelData serializedLevel = level.serializedLevel; - if(CustomLevelMenu_Patch.translatedLevelData.ContainsKey(levelId)) - { - TranslatedLevelData levelData = CustomLevelMenu_Patch.translatedLevelData[levelId]; - level.levelName.text = levelData.name; - serializedLevel.name = levelData.name; - serializedLevel.boardConfig.startTip = levelData.startTip; - } - else - { - TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.onlineLevelInfo.levelName, serializedLevel.boardConfig.startTip); - - if (dumpData.ContainsKey(levelId)) - { - dumpData[levelId] = dumpedLevelData; - } - else - { - dumpData.Add(levelId, dumpedLevelData); - } - } - - /*level.levelData.SerializedLevelData - foreach()*/ - } - } - else - { - level.levelName.text = StringStore.TranslateText(level.levelName.text); - } - - File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - File.WriteAllText(dumpStringsPath, System.Text.Json.JsonSerializer.Serialize(dumpStringsData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - } -} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs deleted file mode 100644 index 31eead2..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs +++ /dev/null @@ -1,175 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using Newtonsoft.Json; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Threading.Tasks; -using System.Threading.Tasks; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomLevelMenu))] - public static class CustomLevelMenu_Patch - { - public static Dictionary translatedLevelData = new Dictionary(); - public static float requestTimer = 0f; - - [HarmonyPatch(nameof(CustomLevelMenu.LoadOnlineFiles))] - [HarmonyPostfix] - public static void LoadOnlineFiles(CustomLevelMenu __instance) - { - if (!Utils.useLocal) - { - LoadOnlineData(); - } - else - { - LoadLocalData(); - } - } - - [HarmonyPatch(nameof(CustomLevelMenu.InitLocalWindows))] - [HarmonyPostfix] - public static void InitWindows(CustomLevelMenu __instance) - { - TranslateLevelButtons(__instance); - } - - [HarmonyPatch(nameof(CustomLevelMenu.InitOnlineWindow))] - [HarmonyPostfix] - public static void InitOnlineWindow(CustomLevelMenu __instance) - { - TranslateLevelButtons(__instance); - } - - [HarmonyPatch(nameof(CustomLevelMenu.ReloadFiles))] - [HarmonyPostfix] - public static void ReloadFiles(CustomLevelMenu __instance) - { - TranslateLevelButtons(__instance); - } - - public static void TranslateLevelButtons(CustomLevelMenu __instance) - { - string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); - Dictionary dumpData = new Dictionary(); - - 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) - { - if(level.onlineLevelInfo != null) - { - string levelId = level.onlineLevelInfo.levelId; - if(levelId != null) - { - if(translatedLevelData.ContainsKey(levelId)) - { - TranslatedLevelData levelData = translatedLevelData[levelId]; - level.levelName.text = levelData.name; - level.serializedLevel.name = levelData.name; - level.serializedLevel.boardConfig.startTip = levelData.startTip; - } - else - { - TranslatedLevelData dumpedLevelData = new TranslatedLevelData(level.onlineLevelInfo.levelName, level.serializedLevel.boardConfig.startTip); - dumpData.Add(levelId, dumpedLevelData); - } - } - } - else - { - level.levelName.text = StringStore.TranslateText(level.levelName.text); - } - } - - File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - - public static async System.Threading.Tasks.Task> GetTranslatedLevelData() - { - string levelDataString = Utils.GetDataFromWeb($"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language.ToString()}/Strings/custom_level_data.json").Result; - if(levelDataString != null) - { - Dictionary levelDataJson = JsonConvert.DeserializeObject>(levelDataString); - return levelDataJson; - } - else - { - new CancellationTokenSource().Cancel(); - return null; - } - } - - public static void LoadOnlineData() - { - if (requestTimer <= 0) - { - requestTimer = 5f; // 5 seconds in between request attempts to prevent any issues with github - - translatedLevelData = new Dictionary(); - - var translatedLevelDataRequest = System.Threading.Tasks.Task.Run(() => GetTranslatedLevelData()); - - if (translatedLevelDataRequest.Result != null) - { - translatedLevelData = translatedLevelDataRequest.Result; - Log.LogInfo($"Successfully loaded level data for {Utils.Language.ToString()}!"); - } - else - { - Log.LogError($"Couldn't find level data for {Utils.Language.ToString()}!"); - } - } - else - { - Log.LogInfo($"Please wait before requesting levels again! Current cooldown: {Math.Round(requestTimer, 3)}s"); - } - } - - public static void LoadLocalData() - { - translatedLevelData = new Dictionary(); - string assetDir = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "custom_level_data.json"); - if (!File.Exists(assetDir)) - { - File.CreateText(assetDir); - File.WriteAllText(assetDir, "{}"); - } - string levelDataString = File.ReadAllText(assetDir); - Dictionary levelDataJson = JsonConvert.DeserializeObject>(levelDataString); - translatedLevelData = levelDataJson; - } - } - - public class TranslatedLevelData - { - public string name { get; set; } - public string startTip { get; set; } - - public TranslatedLevelData(string name, string startTip) - { - this.name = name; - this.startTip = startTip; - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs b/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs deleted file mode 100644 index b0cd093..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs +++ /dev/null @@ -1,29 +0,0 @@ -/*using MelonLoader; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using Il2CppGameLevel; -using PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomMenuPage_event))] - public static class CustomMenuPage_event_Patch - { - [HarmonyPatch(nameof(CustomMenuPage_event.InitializeNodeEditor))] - [HarmonyPostfix] - public static void InitializeNodeEditor(CustomMenuPage_event __instance) - { - RuntimeEventNodeEditor_Patch.Update(__instance.nodeEditor); - NodeInfoPanel_Patch.UpdatePanelContent(__instance.nodeInfoPanel); - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs deleted file mode 100644 index cc0df54..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs +++ /dev/null @@ -1,32 +0,0 @@ -using MelonLoader; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomMenuPage_initZombies))] - public static class CustomMenuPage_initZombies_Patch - { - [HarmonyPatch(nameof(CustomMenuPage_initZombies.SubWave))] - [HarmonyPostfix] - public static void SubWave(CustomMenuPage_initZombies __instance) - { - __instance.currentWaveText.text = StringStore.TranslateText(__instance.currentWaveText.text); - } - - [HarmonyPatch(nameof(CustomMenuPage_initZombies.AddWave))] - [HarmonyPostfix] - public static void AddWave(CustomMenuPage_initZombies __instance) - { - __instance.currentWaveText.text = StringStore.TranslateText(__instance.currentWaveText.text); - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs deleted file mode 100644 index 7b0d4dd..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs +++ /dev/null @@ -1,34 +0,0 @@ -using MelonLoader; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomMenu_page3))] - public static class CustomMenuPage_page3_Patch - { - [HarmonyPatch(nameof(CustomMenu_page3.UpdateCardsText))] - [HarmonyPostfix] - public static void UpdateCardsText(CustomMenu_page3 __instance) - { - string plantName = Utils.GetPlantNameFromAlmanac(__instance.nameText.text); - __instance.nameText.text = (plantName != "") ? (plantName) : StringStore.TranslateText(__instance.nameText.text); - } - - [HarmonyPatch(nameof(CustomMenu_page3.UpdateAdvancedInfo))] - [HarmonyPostfix] - public static void UpdateAdvancedInfo(CustomMenu_page3 __instance) - { - string plantName = Utils.GetPlantNameFromAlmanac(__instance.nameText.text); - __instance.nameText.text = (plantName != "") ? (plantName) : StringStore.TranslateText(__instance.nameText.text); - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs deleted file mode 100644 index a019938..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs +++ /dev/null @@ -1,65 +0,0 @@ -using MelonLoader; -using HarmonyLib; -using UnityEngine; -using Il2Cpp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomMenuPage_shooting))] - public static class CustomMenuPage_shooting_Patch - { - [HarmonyPatch(nameof(CustomMenuPage_shooting.CreateRoute))] - [HarmonyPostfix] - public static void CreateRoute(CustomMenuPage_shooting __instance) - { - TranslateRoutes(__instance); - } - - [HarmonyPatch(nameof(CustomMenuPage_shooting.CreateStage))] - [HarmonyPostfix] - public static void CreateStage(CustomMenuPage_shooting __instance) - { - TranslateRoutes(__instance); - } - - [HarmonyPatch(nameof(CustomMenuPage_shooting.Awake))] - [HarmonyPostfix] - public static void Awake(CustomMenuPage_shooting __instance) - { - TranslateRoutes(__instance); - } - - [HarmonyPatch(nameof(CustomMenuPage_shooting.SearchRoute))] - [HarmonyPostfix] - public static void SearchRoute(CustomMenuPage_shooting __instance) - { - TranslateRoutes(__instance); - } - - [HarmonyPatch(nameof(CustomMenuPage_shooting.SearchAllRoute))] - [HarmonyPostfix] - public static void SearchAllRoute(CustomMenuPage_shooting __instance) - { - TranslateRoutes(__instance); - } - - public static void TranslateRoutes(CustomMenuPage_shooting __instance) - { - foreach(TextMeshProUGUI text in __instance.scollContent.GetComponentsInChildren()) - { - if (text.name == "PlantText") - { - string plantName = Utils.GetPlantNameFromAlmanac(text.text); - text.text = (plantName != "") ? plantName : StringStore.TranslateText(text.text); - } - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs deleted file mode 100644 index 103d448..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs +++ /dev/null @@ -1,80 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppGameLevel; -using Il2CppTMPro; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Threading.Tasks; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor -{ - [HarmonyPatch(typeof(CustomOnlineMenu))] - public static class CustomOnlineMenu_Patch - { - [HarmonyPatch(nameof(CustomOnlineMenu.EditLevel))] - [HarmonyPostfix] - public static void EditLevel(CustomOnlineMenu __instance) - { - TranslateLevelName(__instance); - } - - [HarmonyPatch(nameof(CustomOnlineMenu.Start))] - [HarmonyPostfix] - public static void Start(CustomOnlineMenu __instance) - { - TranslateLevelName(__instance); - } - - public static void TranslateLevelName(CustomOnlineMenu __instance) - { - string translatedText = StringStore.TranslateText(__instance.title.text); - __instance.title.text = translatedText; - __instance.title2.text = translatedText; - - TranslateLevelData(__instance.levelData); - } - - public static void TranslateLevelData(CustomLevelData levelData) - { - Dictionary dumpData = new Dictionary(); - - if(levelData != null) - { - string levelId = levelData.levelId; - if(levelId != null) - { - if(CustomLevelMenu_Patch.translatedLevelData.ContainsKey(levelId)) - { - TranslatedLevelData translatedLevelData = CustomLevelMenu_Patch.translatedLevelData[levelId]; - levelData.Name = translatedLevelData.name; - levelData.SerializedLevelData.name = translatedLevelData.name; - levelData.SerializedLevelData.boardConfig.startTip = translatedLevelData.startTip; - } - else - { - TranslatedLevelData dumpedLevelData = new TranslatedLevelData(levelData.Name, levelData.SerializedLevelData.boardConfig.startTip); - dumpData.Add(levelId, dumpedLevelData); - } - } - } - else - { - levelData.Name = StringStore.TranslateText(levelData.Name); - } - - string dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); - File.WriteAllText(dumpPath, System.Text.Json.JsonSerializer.Serialize(dumpData, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs deleted file mode 100644 index 91d43fc..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HarmonyLib; -using Il2CppGameLevel.EventNodes; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes -{ - [HarmonyPatch(typeof(RuntimeEventNodeEditor))] - public static class RuntimeEventNodeEditor_Patch - { - public static TMP_FontAsset fontAsset => FontStore.LoadTMPFont(Utils.Language.ToString()); - - [HarmonyPatch(nameof(RuntimeEventNodeEditor.Update))] - [HarmonyPostfix] - public static void Update(RuntimeEventNodeEditor __instance) - { - // translate the new screens (3.7) - TranslateFullTransform(__instance.nodeInfoPanel.transform); - TranslateFullTransform(__instance.attributePanel.transform); - TranslateFullTransform(__instance.canvas.transform); - if(__instance.TryGetComponent(out EventNodeContextMenu eventNodeContextMenu)) - { - TranslateFullTransform(eventNodeContextMenu.transform); - } - } - - public static void TranslateFullTransform(Transform transform) - { - if (transform == null) return; - - foreach(TextMeshProUGUI txt in transform.GetComponentsInChildren()) - { - txt.text = RuntimeNodeUI_Patch.TranslateCodeText(txt.text); - txt.font = fontAsset; - } - - foreach(TMP_InputField inputField in transform.GetComponentsInChildren()) - { - TMP_InputField_Patch.OnEnable(inputField); - foreach(TextMeshProUGUI txt in inputField.GetComponentsInChildren(true)) - { - txt.text = RuntimeNodeUI_Patch.TranslateCodeText(txt.text); - } - } - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs deleted file mode 100644 index 540f243..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs +++ /dev/null @@ -1,143 +0,0 @@ -using HarmonyLib; -using Il2CppGameLevel.EventNodes; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.BaseTextObjects; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes -{ - [HarmonyPatch(typeof(RuntimeNodeUI))] - public static class RuntimeNodeUI_Patch - { - [HarmonyPatch(nameof(RuntimeNodeUI.Awake))] - [HarmonyPatch(nameof(RuntimeNodeUI.CreatePorts))] - [HarmonyPatch(nameof(RuntimeNodeUI.CreateValueEditUI))] - [HarmonyPatch(nameof(RuntimeNodeUI.GetPortUI))] - [HarmonyPatch(nameof(RuntimeNodeUI.UpdateDisplay))] - [HarmonyPatch(nameof(RuntimeNodeUI.UpdateSelectionVisual))] - [HarmonyPatch(nameof(RuntimeNodeUI.UpdateVisable))] - [HarmonyPostfix] - public static void Post_UpdateDisplay(RuntimeNodeUI __instance) - { - if (!__instance.isActiveAndEnabled) return; - - if (__instance.Node == null) return; - - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - __instance.titleText.text = TranslateCodeText(__instance.titleText.text); - __instance.titleText.font = fontAsset; - - foreach(TextMeshProUGUI txt in __instance.inputPortsContainer.GetComponentsInChildren()) - { - txt.text = TranslateCodeText(txt.text); - txt.font = fontAsset; - } - - foreach(TextMeshProUGUI txt in __instance.outputPortsContainer.GetComponentsInChildren()) - { - txt.text = TranslateCodeText(txt.text); - txt.font = fontAsset; - } - - if ( - __instance.GetComponentsInChildren().Count == 0 - && __instance.GetComponentsInChildren().Count == 0 - && __instance.Node.nodeType != "PlantTypeValueNode" - && __instance.Node.nodeType != "SinglePlantTypeListNode" - && __instance.Node.nodeType != "ZombieTypeValueNode" - ) return; - - if (__instance.Node != null) - { - if(__instance.Node.nodeType == "PlantTypeValueNode") - { - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if(txt.gameObject.name.Contains("Label")) - { - if (Utils.CheckForUntranslatedText(txt.text)) - { - PlantTypeValueNode castedNode = __instance.Node.TryCast(); - if (castedNode != null) - { - string portName = castedNode.value_PortName; - string plantName = Utils.GetPlantNameFromAlmanac(castedNode.value, removeTags: true); - txt.text = (plantName != "") ? plantName : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } - } - } - - if(__instance.Node.nodeType == "SinglePlantTypeListNode") - { - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if (txt.gameObject.name.Contains("Label")) - { - if (Utils.CheckForUntranslatedText(txt.text)) - { - SinglePlantTypeListNode castedNode = __instance.Node.TryCast(); - if (castedNode != null) - { - string portName = castedNode.plantTypeList_PortName; - string plantName = Utils.GetPlantNameFromAlmanac(castedNode.plantType, removeTags: true); - txt.text = (plantName != "") ? plantName : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } - } - } - - if(__instance.Node.nodeType == "ZombieTypeValueNode") - { - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - if(txt.gameObject.name.Contains("Label")) - { - if(Utils.CheckForUntranslatedText(txt.text)) - { - ZombieTypeValueNode castedNode = __instance.Node.TryCast(); - if(castedNode != null) - { - string portName = castedNode.value_PortName; - string zombieName = Utils.GetZombieNameFromAlmanac(castedNode.value, removeTags: true); - txt.text = (zombieName != "") ? zombieName : StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } - } - } - } - } - } - - if(__instance.GetComponentsInChildren().Count > 0) - { - foreach(TMP_Dropdown dropdown in __instance.GetComponentsInChildren()) - { - TMP_Dropdown_Patch.CreateDropdownList(dropdown); - } - } - - if(__instance.GetComponentsInChildren().Count > 0) - { - foreach(TMP_InputField inputField in __instance.GetComponentsInChildren()) - { - TMP_InputField_Patch.OnEnable(inputField); - foreach(TextMeshProUGUI txt in inputField.GetComponentsInChildren(true)) - { - txt.text = TranslateCodeText(txt.text); - } - } - } - } - - public static string TranslateCodeText(string originalText) - { - return StringStore.translationString.ContainsKey(originalText + "_code") ? StringStore.TranslateText(originalText + "_code") : StringStore.TranslateText(originalText); - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs deleted file mode 100644 index 57b919a..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs +++ /dev/null @@ -1,280 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppGameLevel; -using Il2CppGameLevel.EventNodes; -using MelonLoader; -using PvZ_Fusion_Translator.AssetStore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Encodings.Web; -using System.Text.Json; -using System.Threading.Tasks; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel -{ - [HarmonyPatch(typeof(LevelManager))] - public static class LevelManager_Patch - { - [HarmonyPatch(nameof(LevelManager.SaveLevelData))] - [HarmonyPrefix] - public static void Pre_SaveLevelData(LevelManager __instance, ref SerializedLevelData serializedLevelData) - { - if (serializedLevelData.name == "未命名关卡") - { - serializedLevelData.name = StringStore.translationString.ContainsKey("LEVEL_UNNAMED") ? StringStore.TranslateText("LEVEL_UNNAMED") : "Unnamed"; - } - } - - public static void ExportLevelStrings(SerializedLevelData serializedLevelData) - { - string levelDataString = JsonUtility.ToJson(serializedLevelData); - ReferenceLevelData referenceLevelData = Newtonsoft.Json.JsonConvert.DeserializeObject(levelDataString); - EventNodeGraph eventNodeGraph = serializedLevelData.eventNodeGraph; - eventNodeGraph.BuildCache(); - - List stringValueNodeIds = new List(); - List stringConcatNodeIds = new List(); - List showTextNodeIds = new List(); - List addOptionNodeIds = new List(); - - foreach (var reference in referenceLevelData.references.RefIds) - { - string nodeType = reference.data.nodeType; - string nodeId = reference.data.nodeId; - - if (nodeType == "ShowTextNode") - { - if(!showTextNodeIds.Contains(nodeId)) - { - showTextNodeIds.Add(nodeId); - } - } - else if (nodeType == "AddMultipleChoiceOptionNode") - { - if(!addOptionNodeIds.Contains(nodeId)) - { - addOptionNodeIds.Add(nodeId); - } - } - } - - foreach (var reference in referenceLevelData.references.RefIds) - { - string nodeType = reference.data.nodeType; - string nodeId = reference.data.nodeId; - - switch(nodeType) - { - case "StringValueNode": - case "FloatToStringNode": - case "StringConcatNode": - stringValueNodeIds.Add(nodeId); - if(nodeType == "StringConcatNode") - { - stringConcatNodeIds.Add(nodeId); - } - break; - default: - break; - } - } - - Dictionary> stringConcatNodePairs = new(); - - foreach(var connection in eventNodeGraph.connections) - { - string sourceNodeId = connection.sourceNodeId; - string sourcePortName = connection.sourcePortName; - string targetNodeId = connection.targetNodeId; - string targetPortName = connection.targetPortName; - - if(stringValueNodeIds.Contains(sourceNodeId)) - { - if(stringConcatNodeIds.Contains(targetNodeId)) - { - if(stringConcatNodePairs.ContainsKey(targetNodeId)) - { - ValueTuple temp = stringConcatNodePairs[targetNodeId]; - switch(targetPortName) - { - case "A": - temp.Item1 = sourceNodeId; - stringConcatNodePairs[targetNodeId] = temp; - break; - case "B": - temp.Item2 = sourceNodeId; - stringConcatNodePairs[targetNodeId] = temp; - break; - default: - break; - } - } - else - { - stringConcatNodePairs.Add(targetNodeId, new ValueTuple()); - ValueTuple temp = stringConcatNodePairs[targetNodeId]; - switch(targetPortName) - { - case "A": - temp.Item1 = sourceNodeId; - stringConcatNodePairs[targetNodeId] = temp; - break; - case "B": - temp.Item2 = sourceNodeId; - stringConcatNodePairs[targetNodeId] = temp; - break; - default: - break; - } - } - } - } - } - - string GetStringNodeValue(EventNodeBase eventNodeBase) - { - string stringValue = ""; - - switch(eventNodeBase.nodeType) - { - case "StringValueNode": - StringValueNode stringNode = eventNodeBase.TryCast(); - stringValue = stringNode.value; - break; - case "FloatToStringNode": - stringValue = "([^\\s]+)"; - break; - case "StringConcatNode": - StringConcatNode stringConcatNode = eventNodeBase.TryCast(); - stringConcatNode.InitializeConnections(eventNodeGraph); - stringValue = GetStringNodeValue(stringConcatNode.aSourceNode) + GetStringNodeValue(stringConcatNode.bSourceNode); - break; - default: - break; - } - - return stringValue; - } - - string baseDumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps); - string levelDumpDir = Path.Combine(baseDumpDir, "CustomLevels.json"); - if (!File.Exists(levelDumpDir)) File.WriteAllText(levelDumpDir, "{}"); - Dictionary dump = JsonSerializer.Deserialize>(File.ReadAllText(levelDumpDir)); - - foreach(string showTextNodeId in showTextNodeIds) - { - ShowTextNode showTextNode = eventNodeGraph.GetNodeById(showTextNodeId).TryCast(); - showTextNode.InitializeConnections(eventNodeGraph); - string value = GetStringNodeValue(showTextNode.textSourceNode); - if (!dump.ContainsKey(value)) - { - dump.Add(value, value); - } - } - - foreach(string addOptionId in addOptionNodeIds) - { - AddMultipleChoiceOptionNode addOptionNode = eventNodeGraph.GetNodeById(addOptionId).TryCast(); - addOptionNode.InitializeConnections(eventNodeGraph); - string titleValue = GetStringNodeValue(addOptionNode.titleSourceNode); - if (!dump.ContainsKey(titleValue)) - { - dump.Add(titleValue, titleValue); - } - string descriptionValue = GetStringNodeValue(addOptionNode.descriptionSourceNode); - if (!dump.ContainsKey(descriptionValue)) - { - dump.Add(descriptionValue, descriptionValue); - } - } - - File.WriteAllText(levelDumpDir, JsonSerializer.Serialize(dump, new JsonSerializerOptions - { - WriteIndented = true, - Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping - })); - } - - // reference level data classes - - public class ReferenceLevelData - { - public References references { get; set; } - } - - 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 Position - { - public double x { get; set; } - public double y { get; set; } - } - - public class References - { - public int version { get; set; } - public List 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; } - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs deleted file mode 100644 index 1cd3db6..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Il2Cpp; -using Il2CppRhythmGameEditor; -using Il2CppRhythmGame; -using HarmonyLib; -using UnityEngine; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.RhythmGameEditor -{ - [HarmonyPatch(typeof(RhythmGameChartEditorUI))] - public static class RhythmGameChartEditorUI_Patch - { - [HarmonyPatch(nameof(RhythmGameChartEditorUI.Awake))] - [HarmonyPostfix] - public static void Awake(RhythmGameChartEditorUI __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.font = fontAsset; - if (!Utils.CheckForUntranslatedText(txt.text)) continue; - txt.text = StringStore.TranslateText(txt.text); - } - - foreach(TextMeshProUGUI txt in __instance.dropdown.GetComponentsInChildren(true)) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - - [HarmonyPatch(nameof(RhythmGameChartEditorUI.Start))] - [HarmonyPostfix] - public static void Start(RhythmGameChartEditorUI __instance) - { - Awake(__instance); - } - - [HarmonyPatch(nameof(RhythmGameChartEditorUI.InitializeSubSystems))] - [HarmonyPostfix] - public static void InitializeSubSystems(RhythmGameChartEditorUI __instance) - { - Awake(__instance); - } - - [HarmonyPatch(nameof(RhythmGameChartEditorUI.Update))] - [HarmonyPostfix] - public static void Update(RhythmGameChartEditorUI __instance) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach(TextMeshProUGUI txt in __instance.transform.Find("TopPanel").GetComponentsInChildren()) - { - txt.font = fontAsset; - txt.text = StringStore.TranslateText(txt.text); - } - - foreach(TheButton btn in __instance.transform.GetComponentsInChildren()) - { - foreach(TextMeshProUGUI txt in btn.GetComponentsInChildren()) - { - if (!Utils.CheckForUntranslatedText(txt.text)) continue; - txt.text = StringStore.TranslateText(txt.text); - } - } - - foreach(TextMeshProUGUI txt in __instance.dropdown.GetComponentsInChildren(true)) - { - if (!Utils.CheckForUntranslatedText(txt.text)) continue; - txt.text = Utils.RemoveSizeTags(StringStore.TranslateText(txt.text)); - } - } - - [HarmonyPatch(nameof(RhythmGameChartEditorUI.UpdateUI))] - [HarmonyPostfix] - public static void UpdateUI(RhythmGameChartEditorUI __instance) - { - foreach(TextMeshProUGUI txt in __instance.dropdown.GetComponentsInChildren(true)) - { - txt.text = StringStore.TranslateText(txt.text); - } - } - - [HarmonyPatch(nameof(RhythmGameChartEditorUI.UpdateSelectedNoteInfo))] - [HarmonyPostfix] - public static void UpdateSelectedNoteInfo(RhythmGameChartEditorUI __instance) - { - __instance.selectedNoteInfoText.text = StringStore.TranslateText(__instance.selectedNoteInfoText.text); - } - } -} diff --git a/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs b/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs deleted file mode 100644 index e9e3eff..0000000 --- a/MelonLoader/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using HarmonyLib; -using Il2Cpp; -using Il2CppRhythmGame; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; - -namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.RhythmGameEditor -{ - [HarmonyPatch(typeof(RhythmGameManager))] - public static class RhythmGameManager_Patch - { - [HarmonyPatch(nameof(RhythmGameManager.Awake))] - [HarmonyPatch(nameof(RhythmGameManager.ComboUpdate))] - [HarmonyPostfix] - public static void Awake(RhythmGameManager __instance) - { - if(__instance.comboText) - { - __instance.comboText.autoSizeTextContainer = false; - __instance.comboText.ForceMeshUpdate(); - } - } - - [HarmonyPatch(nameof(RhythmGameManager.OnNoteClicked))] - [HarmonyPostfix] - public static void OnNoteClicked(RhythmGameManager __instance) - { - if (!__instance.particle) return; - - TextParticle txtParticle = __instance.particle.GetComponent(); - if(txtParticle) - { - TextMeshPro txt = txtParticle.text.GetComponent(); - - if(txt) - { - string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; - txt.text = StringStore.translationString.ContainsKey(originalKey + "_RG") ? StringStore.TranslateText(originalKey + "_RG") : StringStore.TranslateText(txt.text); - txt.autoSizeTextContainer = false; - txt.ForceMeshUpdate(); - } - } - } - } -} diff --git a/MelonLoader/Patches/OtherManagers/AchievementClip_Patch.cs b/MelonLoader/Patches/OtherManagers/AchievementClip_Patch.cs deleted file mode 100644 index 3b295f4..0000000 --- a/MelonLoader/Patches/OtherManagers/AchievementClip_Patch.cs +++ /dev/null @@ -1,71 +0,0 @@ -/*using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using Newtonsoft.Json; -using PvZ_Fusion_Translator.AssetStore; -using static PvZ_Fusion_Translator.FileLoader; -using static PvZ_Fusion_Translator.Patches.Managers.AlmanacPlantBank_Patch; - -namespace PvZ_Fusion_Translator.Patches.OtherManagers -{ - [HarmonyPatch(typeof(AchievementClip))] - public static class AchievementClip_Patch - { - [HarmonyPatch(nameof(AchievementClip.Start))] - [HarmonyPostfix] - private static void Start(AchievementClip __instance) - { - #if MULTI_LANGUAGE - string currentLanguage = Utils.Language.ToString(); - string achievementDir = GetAssetDir(AssetType.Almanac, Utils.Language); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage); - #else - string achievementDir = GetAssetDir(AssetType.Almanac); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - #endif - string path = Path.Combine(achievementDir, "AchievementsTextTranslate.json"); - - #if OBFUSCATE - if (CheckSumStore.IsModified(path)) - { - Log.LogError("File {0} was modified!", path); - return; - } - #endif - - if (!File.Exists(path)) return; - - string json; - json = File.ReadAllText(path); - Dictionary achievementsTexts = new Dictionary(); - achievementsTexts = JsonConvert.DeserializeObject>(json); - - TextMeshProUGUI text1 = __instance.introduce.transform.GetChild(1).GetComponent(); - TextMeshProUGUI text2 = __instance.introduce.transform.GetChild(2).GetComponent(); - TextMeshProUGUI name1 = __instance.image.transform.GetChild(0).GetComponent(); - - - text1.text = achievementsTexts[__instance._index].Name; - text1.font = fontAsset; - text2.text = achievementsTexts[__instance._index].Name; - text2.font = fontAsset; - name1.text = achievementsTexts[__instance._index].Text; - name1.font = fontAsset; - } - } - - public class AchievementObject - { - public Achievement achievement { get; set; } - public string Name { get; set; } - public string Text { get; set; } - - public AchievementObject(Achievement achievement = Achievement.Welcome, string name = "", string text = "") - { - this.achievement = achievement; - Name = name; - Text = text; - } - } -} -*/ \ No newline at end of file diff --git a/MelonLoader/Patches/OtherManagers/GardenUI_Patch.cs b/MelonLoader/Patches/OtherManagers/GardenUI_Patch.cs deleted file mode 100644 index 6219f62..0000000 --- a/MelonLoader/Patches/OtherManagers/GardenUI_Patch.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; -using Il2CppZenGarden; - -namespace PvZ_Fusion_Translator.Patches.OtherManagers -{ - [HarmonyPatch(typeof(GardenUI))] - public static class GardenUI_Patch - { - [HarmonyPatch(nameof(GardenUI.Update))] - [HarmonyPostfix] - public static void Update(GardenUI __instance) - { - __instance.currentPageText = StringStore.TranslateText(__instance.currentPageText, false); - - // Transform PageText = __instance.transform.Find("PageText"); - // StringStore.TranslateTextTransform(PageText.transform); - } - } -} diff --git a/MelonLoader/Patches/OtherManagers/MenuText_Patch.cs b/MelonLoader/Patches/OtherManagers/MenuText_Patch.cs deleted file mode 100644 index be63d9f..0000000 --- a/MelonLoader/Patches/OtherManagers/MenuText_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if FIX -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.OtherManagers -{ - [HarmonyPatch(typeof(MenuText))] - public static class MenuText_Patch - { - [HarmonyPatch(nameof(MenuText.UpdateText), new Type[] { typeof(string) })] - [HarmonyPostfix] - private static void UpdateTextPatch(MenuText __instance) - { - TextMeshProUGUI text_1 = __instance.transform.GetChild(0).Find("text1").GetComponent(); - text_1.text = StringStore.TranslateText(text_1.text); - TextMeshProUGUI text = __instance.transform.GetChild(0).Find("text").GetComponent(); - text.text = StringStore.TranslateText(text_1.text); - } - } -} -#endif \ No newline at end of file diff --git a/MelonLoader/Patches/OtherManagers/ThanksMenu_Patch.cs b/MelonLoader/Patches/OtherManagers/ThanksMenu_Patch.cs deleted file mode 100644 index 267a80b..0000000 --- a/MelonLoader/Patches/OtherManagers/ThanksMenu_Patch.cs +++ /dev/null @@ -1,23 +0,0 @@ -using HarmonyLib; -using Il2Cpp; -using Il2CppTMPro; -using PvZ_Fusion_Translator.AssetStore; - -namespace PvZ_Fusion_Translator.Patches.OtherManagers -{ - [HarmonyPatch(typeof(ThanksMenu))] - public class ThanksMenu_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(ThanksMenu.Update))] - private static void Update(ThanksMenu __instance) - { - TextMeshProUGUI textTransform = __instance.transform.GetChild(0).GetComponent(); - if (textTransform != null) - { - textTransform.text = StringStore.TranslateText(textTransform.text); - textTransform.autoSizeTextContainer = true; - } - } - } -} \ No newline at end of file diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj deleted file mode 100644 index 816e321..0000000 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ /dev/null @@ -1,596 +0,0 @@ - - - net6.0 - enable - disable - PvZ_Fusion_Translator - default - false - 1.0.0.0 - 1.0.0.0 - en-US - PvZ_Fusion_Translator - latest - enable - Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate - D:\PvZ Fusion\Game Files - AnyCPU;ARM64;x64 - - - - - - - - - - - - - - - - - - - - - - - $(GamePath)\Mods\AudioImportLib.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Assembly-CSharp.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppMono.Security.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2Cppmscorlib.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppSystem.Configuration.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppSystem.Core.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppSystem.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppSystem.Xml.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2Cpp__Generated.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.2D.Animation.Runtime.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.Burst.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.Burst.Unsafe.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.Collections.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.Collections.LowLevel.ILSupport.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.InternalAPIEngineBridge.001.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.Mathematics.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.RenderPipeline.Universal.ShaderLibrary.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.RenderPipelines.Core.Runtime.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.RenderPipelines.Universal.Runtime.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.TextMeshPro.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Unity.VisualScripting.Core.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AccessibilityModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AIModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AndroidJNIModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AnimationModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ARModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AssetBundleModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.AudioModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ClothModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ContentLoadModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.CoreModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.CrashReportingModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.DirectorModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.DSPGraphModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.GameCenterModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.GIModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.GridModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.HotReloadModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ImageConversionModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.IMGUIModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.InputLegacyModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.InputModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.JSONSerializeModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.LocalizationModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ParticleSystemModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.PerformanceReportingModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.Physics2DModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.PhysicsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ProfilerModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.PropertiesModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.ScreenCaptureModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.SharedInternalsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.SpriteMaskModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.SpriteShapeModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.StreamingModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.SubstanceModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.SubsystemsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TerrainModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TerrainPhysicsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TextCoreFontEngineModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TextCoreTextEngineModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TextRenderingModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TilemapModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.TLSModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UI.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UIElementsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UIModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UmbraModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityAnalyticsCommonModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityAnalyticsModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityConnectModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityCurlModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityTestProtocolModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityWebRequestAssetBundleModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityWebRequestAudioModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityWebRequestModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityWebRequestTextureModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.UnityWebRequestWWWModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.VehiclesModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.VFXModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.VideoModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.VRModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.WindModule.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\UnityEngine.XRModule.dll - - - $(GamePath)\MelonLoader\net6\MelonLoader.dll - - - $(GamePath)\MelonLoader\net6\0Harmony.dll - - - $(GamePath)\MelonLoader\net6\Il2CppInterop.Runtime.dll - - - $(GamePath)\MelonLoader\net6\Il2CppInterop.Common.dll - - - $(GamePath)\MelonLoader\Il2CppAssemblies\Il2CppCore.dll - - - - - - True - false - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;DEBUG;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;CHEAT;TESTING;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);CHEAT;DEBUG - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);OTHER;OBFUSCATE - - - - $(DefineConstants);MULTI_LANGUAGE;OBFUSCATE;RELEASE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs deleted file mode 100644 index 375a205..0000000 --- a/MelonLoader/Utils.cs +++ /dev/null @@ -1,704 +0,0 @@ -using Harmony; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using MelonLoader.TinyJSON; -using Newtonsoft.Json; -using PvZ_Fusion_Translator.AssetStore; -using PvZ_Fusion_Translator.Patches.GameObjects; -using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; -using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; -using PvZ_Fusion_Translator.Patches.Modes.Super_Editor; -using System.Diagnostics; -using System.Reflection; -using System.Text.RegularExpressions; -using Unity.Burst.Intrinsics; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.Experimental.Rendering; -using UnityEngine.UI; -using static MelonLoader.MelonLogger; -using static PvZ_Fusion_Translator.FileLoader; - -namespace PvZ_Fusion_Translator -{ - public class Utils - { - internal static bool TryReplaceTexture2D(Texture2D ogTexture) - { - if (ogTexture != null) - { - if (TextureStore.textureDict.TryGetValue(ogTexture.name, out byte[] textureData)) - { - try - { - ImageConversion.LoadImage(ogTexture, textureData); - - Log.LogDebug("OK! Replaced Texture " + ogTexture.name); - - ogTexture.name = "replaced_" + ogTexture.name; - return true; - } - catch (Exception ex) - { - Log.LogError("Failed to replace texture: " + ogTexture.name); - Log.LogError(ex.ToString()); - } - } - } - return false; - } - - internal static Texture2D LoadImage(string path) - { - if (!File.Exists(path)) - { - throw new FileNotFoundException($"The image file at path '{path}' does not exist."); - } - - byte[] array = File.ReadAllBytes(path); - Texture2D texture2D = new(2, 2, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None, 1, IntPtr.Zero, null); - ImageConversion.LoadImage(texture2D, array); - return texture2D; - } - - internal static Texture2D LoadImage(byte[] bytes) - { - if (bytes == null) - { - throw new FileNotFoundException($"Byte array was null."); - } - - byte[] array = bytes; - Texture2D texture2D = new(2, 2, GraphicsFormat.R8G8B8A8_UNorm, TextureCreationFlags.None, 1, IntPtr.Zero, null); - ImageConversion.LoadImage(texture2D, array); - return texture2D; - } - - public static Color HexToColor(string hex) - { - - hex = hex.Replace("#", ""); - - float r = int.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - float g = int.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - float b = int.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber) / 255f; - - return new Color(r, g, b); - } - - public static void OpenSaveDirectory() - { - string saveDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "LanPiaoPiao", "PlantsVsZombiesRH"); - Process.Start("explorer.exe", saveDirectory); - } - - public static void OpenOnlineAlmanac() - { - string website = "https://carroti4ch.itch.io/almanac"; - Process.Start(new ProcessStartInfo(website) { UseShellExecute = true }); - } - - public static string RemoveColorTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - // Remove opening color tags like - string withoutOpenTags = Regex.Replace(text, @"]+>", string.Empty, RegexOptions.IgnoreCase); - // Remove closing color tags like - string withoutCloseTags = Regex.Replace(withoutOpenTags, @"", string.Empty, RegexOptions.IgnoreCase); - return withoutCloseTags; - } - - public static string RemoveSizeTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - // Remove opening size tags like - string withoutOpenTags = Regex.Replace(text, @"]+>", string.Empty, RegexOptions.IgnoreCase); - // Remove closing size tags like - string withoutCloseTags = Regex.Replace(withoutOpenTags, @"", string.Empty, RegexOptions.IgnoreCase); - return withoutCloseTags; - } - - public static string RemoveFormatTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - string withoutUnderlineTags = Regex.Replace(text, @"", string.Empty, RegexOptions.IgnoreCase); - string withoutUnderlineCloseTags = Regex.Replace(withoutUnderlineTags, @"", string.Empty, RegexOptions.IgnoreCase); - string withoutItalicTags = Regex.Replace(withoutUnderlineCloseTags, @"", string.Empty, RegexOptions.IgnoreCase); - string withoutItalicCloseTags = Regex.Replace(withoutItalicTags, @"", string.Empty, RegexOptions.IgnoreCase); - - return withoutItalicCloseTags; - } - - public static string RemoveAllTags(string text) - { - if (string.IsNullOrEmpty(text)) - return text ?? string.Empty; - - return RemoveColorTags(RemoveSizeTags(RemoveFormatTags(text))); - } - - public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name) - { - GameObject newObj = new GameObject(name); - newObj.transform.position = originalText.transform.position; - newObj.AddComponent(); - newObj.AddComponent(); - newObj.AddComponent(); - newObj.transform.SetParent(parent); - newObj.transform.localScale = Vector3.one; - - UnityEngine.Object.Destroy(originalText); - return newObj; - } - - public static void ConvertButtonText(Transform original, string name) - { - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - - Transform transform = original.FindChild(name); - Transform textTransform = transform.FindChild("text"); - string text = textTransform.GetComponent().text; - Color color = textTransform.GetComponent().color; - - TextMeshProUGUI newGoBackText = Utils.ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent(); - newGoBackText.autoSizeTextContainer = true; - newGoBackText.text = StringStore.TranslateText(text, false); - newGoBackText.font = fontAsset; - newGoBackText.color = color; - } - - public static string GetPlantNameFromAlmanac(PlantType thePlantType, bool removeTags = false, bool log = false) - { - bool foundPlantName = false; - string thePlantName = ""; - - if(plantIndices.ContainsKey((int)thePlantType)) - { - foundPlantName = true; - thePlantName = plantIndices[(int)thePlantType].Value; - } - - if (!foundPlantName) - { - if(log) - { - Log.LogInfo("Couldn't find plant name!"); - } - thePlantName = ""; - } - - thePlantName = (removeTags) ? RemoveAllTags(thePlantName) : thePlantName; - - return thePlantName; - } - - public static string GetPlantNameFromAlmanac(string theOriginalPlantName, bool removeTags = false, bool log = false) - { - bool foundPlantName = false; - string thePlantName = ""; - - if(plantIndiceString.ContainsKey(theOriginalPlantName)) - { - foundPlantName = true; - thePlantName = plantIndiceString[theOriginalPlantName]; - } - - if (!foundPlantName) - { - if(log) - { - Log.LogInfo("Couldn't find plant name!"); - } - thePlantName = ""; - } - - thePlantName = (removeTags) ? RemoveAllTags(thePlantName) : thePlantName; - - return thePlantName; - } - - public static string GetZombieNameFromAlmanac(ZombieType theZombieType, bool removeTags = false) - { - string json; - string theZombieName = ""; - - string currentLanguage = Utils.Language.ToString(); - - json = AlmanacZombieMenu_Patch.almanacJson; - Il2CppAlmanacData.AlmanacData zombieData = JsonUtility.FromJson(json); - - foreach (Il2CppAlmanacData.ZombieInfo zombieInfo in zombieData.zombies) - { - if ((int)zombieInfo.theZombieType == (int)theZombieType) - { - theZombieName = zombieInfo.name; - } - } - - theZombieName = (removeTags) ? RemoveAllTags(theZombieName) : theZombieName; - - return theZombieName; - } - - public static Dictionary> plantIndices = new Dictionary>(); - public static Dictionary plantIndiceString = new Dictionary(); - - public static void RegisterPlantIndices() - { - plantIndices = new Dictionary>(); - plantIndiceString = new Dictionary(); - string originalJson; - string translatedJson; - - string currentLanguage = Utils.Language.ToString(); - string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); - string dumpDir = GetAssetDir(AssetType.Dumps); - string originalPath = Path.Combine(dumpDir, "LawnStrings.json"); - string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); - - if ((!File.Exists(originalPath))) - { - Log.LogError($"LawnStrings.json file not found at path: {originalPath}"); - } - else - { - try - { - originalJson = File.ReadAllText(originalPath); - translatedJson = AlmanacPlantMenu_Patch.almanacJson; - Il2CppAlmanacData.AlmanacData originalPlantData = JsonUtility.FromJson(originalJson); - Il2CppAlmanacData.AlmanacData translatedPlantData = JsonUtility.FromJson(translatedJson); - - foreach (Il2CppAlmanacData.PlantInfo originalPlantInfo in originalPlantData.plants) - { - if(!plantIndiceString.ContainsKey(originalPlantInfo.name)) - { - plantIndiceString.Add(originalPlantInfo.name, originalPlantInfo.name); - } - Il2CppAlmanacData.PlantInfo translatedPlantInfo = null; - - foreach (Il2CppAlmanacData.PlantInfo info in translatedPlantData.plants) - { - if (info.seedType == originalPlantInfo.seedType) - { - translatedPlantInfo = info; - } - } - - if (translatedPlantInfo != null) - { - if(translatedPlantInfo.name != null) - { - KeyValuePair temp = new KeyValuePair(translatedPlantInfo.seedType, translatedPlantInfo.name); - plantIndices.Add(originalPlantInfo.seedType, temp); - plantIndiceString[originalPlantInfo.name] = translatedPlantInfo.name; - } - } - } - } - catch (Exception e) - { - Log.LogError(e); - } - } - } - - public static void TryAdd(Dictionary dict, A key, B val) - { - if (dict.ContainsKey(key)) - { - dict[key] = val; - } - else - { - dict.Add(key, val); - } - } - - public static void TryAdd(SortedDictionary dict, A key, B val) - { - if (dict.ContainsKey(key)) - { - dict[key] = val; - } - else - { - dict.Add(key, val); - } - } - - public static AssetBundle GetAssetBundle(Assembly assembly, string assetBundlePath, bool log = false) - { - try - { - if (assembly != null) - { - Stream manifestResourceStream = assembly.GetManifestResourceStream($"PvZ_Fusion_Translator.Resources.{assetBundlePath}"); - using (manifestResourceStream) - { - if (manifestResourceStream == null) - { - throw new Exception("Stream was null."); - } - - byte[] array = new byte[manifestResourceStream.Length]; - manifestResourceStream.Read(array, 0, array.Length); - AssetBundle assetBundle = AssetBundle.LoadFromMemory(array); - ArgumentNullException.ThrowIfNull(assetBundle, "assetBundle"); - if(log) - { - Log.LogDebug($"AssetBundle {assetBundlePath} has successfully been loaded."); - } - return assetBundle; - } - } - - throw new Exception($"AssetBundle {assetBundlePath} was null."); - } - catch (Exception value) - { - throw new ArgumentException($"Failed to load {assetBundlePath}. \n{value}"); - } - } - - public static AssetBundle GetAssetBundle(string path) - { - AssetBundle assetBundle = AssetBundle.LoadFromFile(path); - return assetBundle; - } - - /*public static Dictionary> recipeLinks = new Dictionary>(); - - public static void RegisterRecipeLinks() - { - recipeLinks.Clear(); - - Il2CppSystem.Array mixData = MixData.data.Cast(); - int rows = mixData.GetLength(0); - int columns = mixData.GetLength(1); - - foreach (PlantType plantType in Enum.GetValues(typeof(PlantType))) - { - int seedType = (int)plantType; - - recipeLinks.Add(seedType, new()); - - if (seedType > 0) - { - foreach (PlantType checkType in Enum.GetValues(typeof(PlantType))) - { - if (checkType > 0) - { - int[] checks = [mixData.GetValue(seedType, (int)checkType).Unbox(), mixData.GetValue((int)checkType, seedType).Unbox()]; - - if (checks[0] != 0) - { - recipeLinks[seedType].Add(checks[0]); - } - - if (checks[1] != 0) - { - recipeLinks[seedType].Add(checks[1]); - } - } - } - } - if (recipeLinks[seedType].Count > 0) - { - Log.LogDebug($"Found {recipeLinks[seedType].Count} fusions for {seedType}!"); - } - } - }*/ - - public static Regex untranslatedRegex = new("\\p{IsCJKUnifiedIdeographs}+"); - - public static bool CheckForUntranslatedText(string text) - { - try - { - Match match = untranslatedRegex.Match(text); - return match.Success; - } - catch(Exception e) - { - Log.LogError(e); - } - return false; - } - - public static bool useLocal = MelonPreferences.GetEntryValue("PvZ_Fusion_Translator", "UseLocal"); - - public static void WarnLocalData() - { - BaseMenu newMenu = GameAPP.UIManager.Push(UIType.ConfirmMenu, GameAPP.canvasUp); - ConfirmMenu confirmMenu = newMenu.gameObject.GetComponent(); - - string modeTo = (Utils.useLocal) ? "online mode" : "local mode"; - confirmMenu.SetTitle($"WARNING: This button is meant for translator testing and can overwrite/interfere with the translation files saved in your installation. Proceed with caution. You are switching to {modeTo}.\nOnline Mode: Default, strings will auto-sync with the latest version when opening the game\nLocal Mode: Strings are only loaded from your installaion and do not update (meant for translators)"); - confirmMenu.transform.Find("window/text").GetComponent().text = Utils.RemoveColorTags(confirmMenu.transform.Find("window/text").GetComponent().text); - UIButton confirmButton = confirmMenu.transform.Find("Image").GetComponent(); - UIButton cancelButton = confirmMenu.transform.Find("Image2").GetComponent(); - - confirmButton.clickEvent = new UnityEvent(); - confirmButton.clickEvent.AddListener(new Action(() => SwapLocalData())); - confirmButton.clickEvent.AddListener(new Action(() => CursorChange.SetDefaultCursor())); - confirmButton.clickEvent.AddListener(new Action(() => GameAPP.UIManager.Pop())); - } - - public static void SwapLocalData() - { - Utils.useLocal = (Utils.useLocal) ? false : true; - MelonPreferences.SetEntryValue("PvZ_Fusion_Translator", "UseLocal", Utils.useLocal); - ChangeLanguage(Utils.Language.ToString()); - string sourceMsg = "" + (!(Utils.useLocal) ? "Translation Source:\nOnline" : "Translation Source:\nLocal"); - OptLanguageBtn_Patch.FlashMessage(OptLanguageBtn_Patch.toggleSlots[2], sourceMsg, 0.1f, false); - CursorChange.SetDefaultCursor(); - } - - public static async Task GetDataFromWeb(string url, bool isLog = true) - { - if (isLog) - { - Log.LogInfo($"Attempting to read {url}"); - } - HttpClient client = new HttpClient(); - try - { - var dataRequest = await client.GetAsync(url); - if(dataRequest.StatusCode == System.Net.HttpStatusCode.OK) - { - if (isLog) - { - Log.LogInfo($"Successfully loaded data from {url}!"); - } - - string content = await dataRequest.Content.ReadAsStringAsync(); - return content; - } - else - { - if (isLog) - { - Log.LogError($"Failed to load data from {url}! Falling back..."); - Log.LogError($"Status code: {dataRequest.StatusCode}"); - } - new CancellationTokenSource().Cancel(); - return null; - } - } - catch(Exception ex) - { - Log.LogError($"Failed to load data from {url}! Falling back..."); - Log.LogError(ex); - new CancellationTokenSource().Cancel(); - return null; - } - } - - public static async Task GetByteDataFromWeb(string url, bool isLog = true) - { - if (isLog) - { - Log.LogInfo($"Attempting to read {url}"); - } - HttpClient client = new HttpClient(); - try - { - var dataRequest = await client.GetAsync(url); - if (dataRequest.StatusCode == System.Net.HttpStatusCode.OK) - { - if (isLog) - { - Log.LogInfo($"Successfully loaded data from {url}!"); - } - - byte[] content = await dataRequest.Content.ReadAsByteArrayAsync(); - return content; - } - else - { - if (isLog) - { - Log.LogError($"Failed to load data from {url}! Falling back..."); - Log.LogError($"Status code: {dataRequest.StatusCode}"); - } - new CancellationTokenSource().Cancel(); - return null; - } - } - catch(Exception ex) - { - Log.LogError($"Failed to load data from {url}! Falling back..."); - Log.LogError(ex); - new CancellationTokenSource().Cancel(); - return null; - } - } - - public static async Task GetDataFromWebWithInput(string url, bool isLog = true) - { - if (isLog) - { - Log.LogInfo($"Attempting to read {url}"); - } - HttpClient client = new HttpClient(); - - using var request = new HttpRequestMessage() - { - Method = HttpMethod.Get, - RequestUri = new Uri(url) - }; - request.Headers.Add("Accept", "*/*"); - request.Headers.Add("Accept-Encoding", "gzip, deflate, br"); - request.Headers.Add("User-Agent", "TranslatorMod"); - - - var dataRequest = await client.SendAsync(request); - if(dataRequest.StatusCode == System.Net.HttpStatusCode.OK) - { - if (isLog) - { - Log.LogInfo($"Successfully loaded data from {url}!"); - } - - string content = await dataRequest.Content.ReadAsStringAsync(); - return content; - } - else - { - if (isLog) - { - Log.LogError($"Failed to load data from {url}! Falling back..."); - Log.LogError($"Status code: {dataRequest.StatusCode}"); - } - new CancellationTokenSource().Cancel(); - return null; - } - } - - public static int CalculateGameVersion(string gameVersion) - { - int res = 0; - string[] gameVersionParts = gameVersion.Split('.'); - - int startingPower = (int)Math.Max(gameVersionParts.Length, 3); - for (int i = 0; i < startingPower; i++) - { - int factor = 0; - if (i < gameVersionParts.Length) - { - factor = int.Parse(gameVersionParts[i]); - } - int power = startingPower - i; - res += factor * (int)Math.Pow(10, power - 1); - } - - return res; - } - - #if MULTI_LANGUAGE - internal static void ChangeLanguage(string language) - { - OldLanguage = Language; - - if (Enum.TryParse(language, out Utils.LanguageEnum lang)) - { - Utils.Language = lang; - } - else - { - // Handle invalid language string - Log.LogError($"Invalid language string: {language}"); - } - - //WarningStore.isWarningMessageLoaded = false; - FontStore.Reload(); - StringStore.Reload(); - TextureStore.Reload(); - FileLoader.SaveLanguage(); - RegisterPlantIndices(); - Zombie_Patch.LoadHPStrings(); - } - #endif - - #if MULTI_LANGUAGE - public static Utils.LanguageEnum OldLanguage; - #endif - - public static Utils.LanguageEnum Language; - - public static bool customTextures = !MelonPreferences.GetEntryValue("PvZ_Fusion_Translator", "DefaultTextures"); - public static bool customAudio = !MelonPreferences.GetEntryValue("PvZ_Fusion_Translator", "DefaultAudio"); - - public enum LanguageEnum - { - // first column - English, - Chinese_cn, - French, - //Italian, - German, - Spanish, - - - // second column - //Portuguese, - //Javanese, - //Filipino, - Vietnamese, - Indonesian, - //Russian, //NOTE: legacy language - Japanese, - - - // third column - Korean, - Ukrainian, - // Slovak, - //Polish, - //Turkish, - Arabic, - Romanian, - - LANG_END - } - - public static Dictionary LanguageNames = new Dictionary() - { - { LanguageEnum.English, "English"}, - { LanguageEnum.Chinese_cn, "简体中文"}, - { LanguageEnum.French, "Français"}, - { LanguageEnum.German, "Deutsch"}, - { LanguageEnum.Spanish, "Español"}, - { LanguageEnum.Vietnamese, "Tiếng Việt"}, - { LanguageEnum.Indonesian, "Bahasa Indonesia"}, - { LanguageEnum.Japanese, "日本語"}, - { LanguageEnum.Korean, "한국어"}, - { LanguageEnum.Ukrainian, "українська"}, - { LanguageEnum.Arabic, "ﺔﻴﺑﺮﻌﻟا"}, - { LanguageEnum.Romanian, "Română"} - }; - - public static Dictionary ToggleNames = new Dictionary() - { - { ToggleEnum.Textures, "Change Texture\nSource"}, - { ToggleEnum.Audio, "Change Audio\nSource"}, - { ToggleEnum.SwapLocal, "Change Translation\nSource"} - }; - - public enum ToggleEnum - { - Textures, - Audio, - SwapLocal, - TOGGLE_END - } - } -} \ No newline at end of file diff --git a/PvZ Fusion Translator.sln b/PvZ Fusion Translator.sln deleted file mode 100644 index 7b38d36..0000000 --- a/PvZ Fusion Translator.sln +++ /dev/null @@ -1,146 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 18 -VisualStudioVersion = 18.7.11911.148 stable -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}" - ProjectSection(SolutionItems) = preProject - README.md = README.md - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PvZ Fusion Translator [BepInEx]", "BepInEx\PvZ Fusion Translator [BepInEx].csproj", "{395E60A0-A884-61F2-EF18-BC94BB7D9C69}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PvZ Fusion Translator [MelonLoader]", "MelonLoader\PvZ Fusion Translator [MelonLoader].csproj", "{A058E167-7411-D3CA-0C9F-40F030C12860}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - DebugEnglish|Any CPU = DebugEnglish|Any CPU - DebugEnglish|ARM64 = DebugEnglish|ARM64 - DebugEnglish|x64 = DebugEnglish|x64 - DebugObfuscate|Any CPU = DebugObfuscate|Any CPU - DebugObfuscate|ARM64 = DebugObfuscate|ARM64 - DebugObfuscate|x64 = DebugObfuscate|x64 - DebugTesting|Any CPU = DebugTesting|Any CPU - DebugTesting|ARM64 = DebugTesting|ARM64 - DebugTesting|x64 = DebugTesting|x64 - ReleaseEnglish|Any CPU = ReleaseEnglish|Any CPU - ReleaseEnglish|ARM64 = ReleaseEnglish|ARM64 - ReleaseEnglish|x64 = ReleaseEnglish|x64 - ReleaseMulti|Any CPU = ReleaseMulti|Any CPU - ReleaseMulti|ARM64 = ReleaseMulti|ARM64 - ReleaseMulti|x64 = ReleaseMulti|x64 - ReleaseObfuscate|Any CPU = ReleaseObfuscate|Any CPU - ReleaseObfuscate|ARM64 = ReleaseObfuscate|ARM64 - ReleaseObfuscate|x64 = ReleaseObfuscate|x64 - ReleaseOther|Any CPU = ReleaseOther|Any CPU - ReleaseOther|ARM64 = ReleaseOther|ARM64 - ReleaseOther|x64 = ReleaseOther|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|Any CPU.Build.0 = Debug|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|ARM64.Build.0 = Debug|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|x64.ActiveCfg = Debug|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.Debug|x64.Build.0 = Debug|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|Any CPU.ActiveCfg = DebugEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|Any CPU.Build.0 = DebugEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|ARM64.ActiveCfg = DebugEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|ARM64.Build.0 = DebugEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|x64.ActiveCfg = DebugEnglish|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugEnglish|x64.Build.0 = DebugEnglish|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|Any CPU.ActiveCfg = DebugObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|Any CPU.Build.0 = DebugObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|ARM64.ActiveCfg = DebugObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|ARM64.Build.0 = DebugObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|x64.ActiveCfg = DebugObfuscate|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugObfuscate|x64.Build.0 = DebugObfuscate|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|Any CPU.ActiveCfg = DebugTesting|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|Any CPU.Build.0 = DebugTesting|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|ARM64.ActiveCfg = DebugTesting|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|ARM64.Build.0 = DebugTesting|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|x64.ActiveCfg = DebugTesting|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.DebugTesting|x64.Build.0 = DebugTesting|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|Any CPU.ActiveCfg = ReleaseEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|Any CPU.Build.0 = ReleaseEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|ARM64.ActiveCfg = ReleaseEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|ARM64.Build.0 = ReleaseEnglish|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|x64.ActiveCfg = ReleaseEnglish|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseEnglish|x64.Build.0 = ReleaseEnglish|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|Any CPU.ActiveCfg = ReleaseMulti|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|Any CPU.Build.0 = ReleaseMulti|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|ARM64.ActiveCfg = ReleaseMulti|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|ARM64.Build.0 = ReleaseMulti|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|x64.ActiveCfg = ReleaseMulti|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseMulti|x64.Build.0 = ReleaseMulti|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|Any CPU.ActiveCfg = ReleaseObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|Any CPU.Build.0 = ReleaseObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|ARM64.ActiveCfg = ReleaseObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|ARM64.Build.0 = ReleaseObfuscate|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|x64.ActiveCfg = ReleaseObfuscate|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseObfuscate|x64.Build.0 = ReleaseObfuscate|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|Any CPU.ActiveCfg = ReleaseOther|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|Any CPU.Build.0 = ReleaseOther|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|ARM64.ActiveCfg = ReleaseOther|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|ARM64.Build.0 = ReleaseOther|Any CPU - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|x64.ActiveCfg = ReleaseOther|x64 - {395E60A0-A884-61F2-EF18-BC94BB7D9C69}.ReleaseOther|x64.Build.0 = ReleaseOther|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|ARM64.Build.0 = Debug|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|x64.ActiveCfg = Debug|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.Debug|x64.Build.0 = Debug|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|Any CPU.ActiveCfg = DebugEnglish|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|Any CPU.Build.0 = DebugEnglish|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|ARM64.ActiveCfg = DebugEnglish|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|ARM64.Build.0 = DebugEnglish|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|x64.ActiveCfg = DebugEnglish|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugEnglish|x64.Build.0 = DebugEnglish|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|Any CPU.ActiveCfg = DebugObfuscate|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|Any CPU.Build.0 = DebugObfuscate|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|ARM64.ActiveCfg = DebugObfuscate|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|ARM64.Build.0 = DebugObfuscate|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|x64.ActiveCfg = DebugObfuscate|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugObfuscate|x64.Build.0 = DebugObfuscate|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|Any CPU.ActiveCfg = DebugTesting|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|Any CPU.Build.0 = DebugTesting|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|ARM64.ActiveCfg = DebugTesting|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|ARM64.Build.0 = DebugTesting|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|x64.ActiveCfg = DebugTesting|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.DebugTesting|x64.Build.0 = DebugTesting|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|Any CPU.ActiveCfg = ReleaseEnglish|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|Any CPU.Build.0 = ReleaseEnglish|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|ARM64.ActiveCfg = ReleaseEnglish|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|ARM64.Build.0 = ReleaseEnglish|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|x64.ActiveCfg = ReleaseEnglish|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseEnglish|x64.Build.0 = ReleaseEnglish|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|Any CPU.ActiveCfg = ReleaseMulti|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|Any CPU.Build.0 = ReleaseMulti|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|ARM64.ActiveCfg = ReleaseMulti|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|ARM64.Build.0 = ReleaseMulti|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|x64.ActiveCfg = ReleaseMulti|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseMulti|x64.Build.0 = ReleaseMulti|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|Any CPU.ActiveCfg = ReleaseObfuscate|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|Any CPU.Build.0 = ReleaseObfuscate|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|ARM64.ActiveCfg = ReleaseObfuscate|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|ARM64.Build.0 = ReleaseObfuscate|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|x64.ActiveCfg = ReleaseObfuscate|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseObfuscate|x64.Build.0 = ReleaseObfuscate|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|Any CPU.ActiveCfg = ReleaseOther|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|Any CPU.Build.0 = ReleaseOther|Any CPU - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|ARM64.ActiveCfg = ReleaseOther|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|ARM64.Build.0 = ReleaseOther|ARM64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|x64.ActiveCfg = ReleaseOther|x64 - {A058E167-7411-D3CA-0C9F-40F030C12860}.ReleaseOther|x64.Build.0 = ReleaseOther|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {ECF1E7B1-C1AD-41F5-BC76-4862410A89AA} - EndGlobalSection -EndGlobal diff --git a/PvZ Fusion Translator.sln.DotSettings.user b/PvZ Fusion Translator.sln.DotSettings.user new file mode 100644 index 0000000..ad79a6e --- /dev/null +++ b/PvZ Fusion Translator.sln.DotSettings.user @@ -0,0 +1,6 @@ + + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded + ForceIncluded \ No newline at end of file diff --git a/PvZ Fusion Translator.slnx b/PvZ Fusion Translator.slnx new file mode 100644 index 0000000..ae87c1e --- /dev/null +++ b/PvZ Fusion Translator.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/README.md b/README.md index b0992a5..ec3ebf4 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,3 @@ PvZ Fusion Translator is a **Melon Mod** that allows for an easier method of tra # Contribution If you'd like to contribute in any way, please join us on our [Discord](https://discord.gg/DPAC5ZVJ8T). - diff --git a/Source/AssetStore/AudioStore.cs b/Source/AssetStore/AudioStore.cs new file mode 100644 index 0000000..77fb4d4 --- /dev/null +++ b/Source/AssetStore/AudioStore.cs @@ -0,0 +1,166 @@ +// ReSharper disable once RedundantUsingDirective +using System.Reflection; +// ReSharper disable once RedundantUsingDirective +using HarmonyLib; + +namespace PvZ_Fusion_Translator.AssetStore; + +internal static class AudioStore +{ + public static readonly Dictionary AudioClips = []; + + public static Dictionary AudioClipNames = []; + + private static bool s_overrideEnabled; + + private static readonly string s_customAudioPath = Path.Combine(Core.ModDirectory, "[Custom Audios]"); + + private static readonly string[] s_allowedExts = [".wav", ".mp3", ".ogg"]; + + public static Canvas Canvas { get; set; } + + public static RectTransform SongRectTransform { get; private set; } + + public static void Init() => LoadAudios(); + + public static void LoadAudios() + { + if (!Directory.Exists(s_customAudioPath)) + Directory.CreateDirectory(s_customAudioPath); + + var audioFiles = Directory.GetFiles(s_customAudioPath, "*", SearchOption.AllDirectories); + var ovrClip = audioFiles.SingleOrDefault(f => Path.GetFileNameWithoutExtension(f) == "REPLACE_ALL"); + + if (ovrClip == null) + foreach (var clip in audioFiles + .Where(file => s_allowedExts.Contains(Path.GetExtension(file))) + .Select(file => AudioImportLibAPI.LoadAudioClip(file))) + { + AudioClips.Add(clip.name, clip); + Log.LogInfo("Added Override: " + clip.name); + } + else + { + var clip = AudioImportLibAPI.LoadAudioClip(ovrClip); + AudioClips.Add(clip.name, clip); + s_overrideEnabled = true; + Log.LogInfo("Added Override: " + clip.name); + } +#if MELONLOADER + var audioSourceType = typeof(AudioSource); + const string SourceMethodName = "Play"; + var prefixMethod = typeof(AudioStore).GetMethod(nameof(AudioPlayPatch), BindingFlags.Static | BindingFlags.Public); + + if (prefixMethod == null) + { + Log.LogError($"Couldn't find method named \"AudioPlayPatch\" in type <{typeof(AudioStore)}>."); + return; + } + + _ = Core.Instance.HarmonyInstance.Patch( + AccessTools.Method(audioSourceType, SourceMethodName), + new(prefixMethod) + ); + + Core.Instance.HarmonyInstance.Patch( + AccessTools.Method(audioSourceType, SourceMethodName, [typeof(ulong)]), + new(prefixMethod) + ); +#endif + } + + public static void InitializeCanvas() + { + Debug.Assert(ModFeatures.IsAudioTesting, nameof(ModFeatures.IsAudioTesting)); + + if (Canvas != null) + return; // Prevent duplicate canvas creation + + Canvas = new GameObject("AudioSourceCanvas").AddComponent(); + Canvas.renderMode = RenderMode.ScreenSpaceOverlay; + + var scaler = Canvas.gameObject.AddComponent(); + scaler.uiScaleMode = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize; + scaler.referenceResolution = new(1920, 1080); + + Canvas.gameObject.AddComponent(); + + // Add a RectTransform for positioning text + var songTextObject = new GameObject("SongText"); + songTextObject.transform.SetParent(Canvas.transform); + + SongRectTransform = songTextObject.AddComponent(); + SongRectTransform.anchorMin = new(1, 1); // Top-right corner + SongRectTransform.anchorMax = new(1, 1); + SongRectTransform.pivot = new(1, 1); + SongRectTransform.anchoredPosition = new(-20, -20); // Adjust margin + + // Add a TextMeshPro component for the text + var textComponent = songTextObject.AddComponent(); + textComponent.alignment = TextAlignmentOptions.Right; + textComponent.fontSize = 24; + textComponent.color = Color.white; + textComponent.text = "Current Song: None"; // Placeholder + } + + public static void AudioSources() + { + if (!Directory.Exists(s_customAudioPath)) + Directory.CreateDirectory(s_customAudioPath); + + var path = Path.Combine(s_customAudioPath, "audio_source.json"); + + if (!File.Exists(path)) + { + Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); + return; + } + + var json = File.ReadAllText(path); + AudioClipNames = System.Text.Json.JsonSerializer.Deserialize>(json); + } + + public static (string, string) GetAudioSource(string clipName) => + AudioClipNames.TryGetValue(clipName, out var audioSource) ? audioSource : ("Music", "Source Unknown"); + + public static void UpdateAudioSourceText(string clipName, string sourceName) + { + if (SongRectTransform == null) + InitializeCanvas(); + + var textComponent = SongRectTransform.GetComponent(); + + if (textComponent != null) + textComponent.text = $"Current Song: {clipName}\nSource: {sourceName}"; + } + + public static void AudioPlayPatch(AudioSource __instance) + { + if (Core.Instance.ConfigDefaultAudio.Value) + return; + + if (__instance.clip == null) + return; + + if (RhythmGameManager.Instance != null && __instance.clip.name == "loon") + return; + + if (ModFeatures.IsAudioTesting) + Log.LogInfo($"Playing \"{__instance.clip.name}\" from object \"{__instance.gameObject.name}\""); + + var audioClipName = s_overrideEnabled ? "REPLACE_ALL" : __instance.clip.name; + + if (AudioClips.TryGetValue(audioClipName, out var replaceClip)) + { + __instance.pitch = 1; + __instance.clip = replaceClip; + } + + if (!ModFeatures.IsAudioTesting) + return; + + // Update the displayed audio source + var (name, source) = GetAudioSource(__instance.clip.name); + UpdateAudioSourceText(name, source); + } +} diff --git a/Source/AssetStore/DllStore.cs b/Source/AssetStore/DllStore.cs new file mode 100644 index 0000000..ed7eeeb --- /dev/null +++ b/Source/AssetStore/DllStore.cs @@ -0,0 +1,111 @@ +#if false +using System.Diagnostics; + +namespace PvZ_Fusion_Translator.AssetStore; + +public static class DllStore +{ + public static readonly Dictionary DLLData = new() + { + { "Blooms_QOL.dll", null }, + { "PvZ_Fusion_Translator.dll", null }, + }; + + public static bool UpdateOnClose { get; set; } + + public static void Init(string gameVersion) => TryGetNewDll(gameVersion); + + public static void TryGetNewDll(string gameVersion) + { + var ableToUpdate = true; + var unableReason = ""; + + var getGameVersionRequest = Utils.GetDataFromWeb( + "https://raw.githubusercontent.com/SillyStar-Github/PvZF-Translation-DLLs/refs/heads/main/CURRENT_GAME_VER" + ) + .Result; + + if (getGameVersionRequest != null) + { + Log.LogDebug( + $"Requst game version: {getGameVersionRequest} -> {Utils.CalculateGameVersion(getGameVersionRequest)}" + ); + + Log.LogDebug($"This game version: {gameVersion} -> {Utils.CalculateGameVersion(gameVersion)}"); + + if (Utils.CalculateGameVersion(getGameVersionRequest) != Utils.CalculateGameVersion(gameVersion)) + { + ableToUpdate = false; + unableReason = "Incorrect game version..."; + } + } + else + { + ableToUpdate = false; + unableReason = "Couldn't get latest game version info..."; + } + + if (ableToUpdate) + foreach (var key in DLLData.Keys) + { + var newDllRequest = Utils.GetByteDataFromWeb( + $"https://raw.githubusercontent.com/SillyStar-Github/PvZF-Translation-DLLs/refs/heads/main/{key}" + ) + .Result; + + if (newDllRequest != null) + { + DLLData[key] = newDllRequest; + SaveNewDll(key); + } + else + Log.LogError($"Couldn't get latest {key} data!"); + } + else + Log.LogError($"Unable to update! {unableReason}"); + } + + public static void SaveNewDll(string name) + { + var newDllData = DLLData[name]; + + if (newDllData == null) + return; + + var basePath = MelonEnvironment.ModsDirectory; + var toSavePath = Path.Combine(basePath, name + ".update"); + File.WriteAllBytes(toSavePath, newDllData); + } + + public static void UpdateNewDll() + { + UpdateOnClose = DLLData.Any(pair => pair.Value is not null); + + if (!UpdateOnClose) + { + Log.LogError("Cannot update on close! All .dll data is null!"); + return; + } + + var assembly = Core.Instance.MelonAssembly.Assembly; + const string ProgramName = "PvZ_Fusion_Translator.Resources.ModUpdateUtil.exe"; + + using var exeResourceStream = assembly.GetManifestResourceStream(ProgramName); + var tempPath = Path.Combine(MelonEnvironment.ModsDirectory, "ModUpdateUtil.exe"); + + // ReSharper disable once PossibleNullReferenceException + using (var fileStream = File.Create(tempPath)) + exeResourceStream.CopyTo(fileStream); + + Process.Start( + new ProcessStartInfo + { + FileName = tempPath, + Arguments = + $"{Environment.ProcessId} {string.Join(",", DLLData.Keys)} \"{MelonEnvironment.ModsDirectory}\"", + UseShellExecute = true, + } + ); + } +} +#endif diff --git a/Source/AssetStore/FontStore.cs b/Source/AssetStore/FontStore.cs new file mode 100644 index 0000000..68f7bb4 --- /dev/null +++ b/Source/AssetStore/FontStore.cs @@ -0,0 +1,117 @@ +namespace PvZ_Fusion_Translator.AssetStore; + +public static class FontStore +{ + internal static readonly Dictionary FontAssetDict = [], FontAssetDictSecondary = []; + + internal static void Init() + { + var fontsDir = Path.Combine(Core.ModDirectory, "[Custom Fonts]"); + var assetBundle = Utils.GetAssetBundle(Path.Combine(fontsDir, "translation")); + + if (ModFeatures.IsMultiLanguage) + { + foreach (var file in assetBundle.GetAllAssetNames()) + { + var fileName = Path.GetFileNameWithoutExtension(file); + + if (fileName.EndsWith("_almanac") || fileName.EndsWith("_fallback")) + continue; + + var fontAsset = assetBundle.LoadAsset(file); + FontAssetDict.Add(fileName, fontAsset); + Log.LogInfo($"Font for language '{fileName}' loaded"); + } + + InitFallback(assetBundle); + } + else + { + var defaultFontDir = Path.Combine("[Custom Fonts]", "English.ttf"); + var defaultFont = FontHandler.LoadTMPFont(defaultFontDir, true); + FontAssetDict.Add("English", defaultFont); + } + } + + internal static void InitFallback(AssetBundle assetBundle) + { + foreach (var file in assetBundle.GetAllAssetNames()) + { + var fileName = Path.GetFileNameWithoutExtension(file); + + if (!fileName.EndsWith("_almanac") && !fileName.EndsWith("_fallback")) + continue; + + var fallbackFont = assetBundle.LoadAsset(file); + var fileNameLanguage = fileName.Replace("_fallback", "").Replace("_almanac", ""); + Utils.TryAdd(FontAssetDictSecondary, fileName, fallbackFont); + + if (ModFeatures.IsDebug) + Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded"); + } + + AddFallback(); + } + + public static void AddFallback() + { + foreach (var lang in FontAssetDict.Keys) + { + FontAssetDict[lang].fallbackFontAssetTable ??= new(); + + if (FontAssetDictSecondary.TryGetValue(lang, out var value)) + { + FontAssetDict[lang].fallbackFontAssetTable.Add(value); + Log.LogInfo("Fallback font for language '" + lang + "' added"); + continue; + } + + if (FontAssetDictSecondary.TryGetValue(lang + "_almanac", out var valueAlmanac)) + { + FontAssetDict[lang].fallbackFontAssetTable.Add(valueAlmanac); + Log.LogInfo("Fallback font for language '" + lang + "' added"); + continue; + } + + if (!FontAssetDictSecondary.TryGetValue(lang + "_fallback", out var valueFallback)) + continue; + + FontAssetDict[lang].fallbackFontAssetTable.Add(valueFallback); + Log.LogInfo("Fallback font for language '" + lang + "' added"); + } + } + + public static TMP_FontAsset LoadTMPFont(string language) + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + + if (!FontAssetDict.TryGetValue(language.ToLower(), out var font)) + return FontAssetDict.GetValueOrDefault("english"); + + if (ModFeatures.IsDebug && font.fallbackFontAssetTable != null) + Log.LogInfo( + $"Fallback font for language '{language}' loaded. The name of the FB Font is{font.fallbackFontAssetTable[0].name}" + ); + + return font; + } + + public static TMP_FontAsset LoadTMPFont() + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + var defaultFont = FontAssetDict["English"]; + return defaultFont; + } + + public static TMP_FontAsset LoadTMPFontAlmanac(string language) => + FontAssetDictSecondary.TryGetValue(language.ToLower(), out var first) ? first : + FontAssetDictSecondary.TryGetValue(language.ToLower() + "_almanac", out var second) ? second : + FontAssetDict.GetValueOrDefault("english"); + + public static void Reload() + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + // Get the current language and load its corresponding font. + _ = LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/AssetStore/StringStore.cs b/Source/AssetStore/StringStore.cs new file mode 100644 index 0000000..97668a6 --- /dev/null +++ b/Source/AssetStore/StringStore.cs @@ -0,0 +1,613 @@ +using PvZ_Fusion_Translator.Patches.BaseTextObjects; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.AssetStore; + +public static class StringStore +{ + // ReSharper disable once CollectionNeverQueried.Global + internal static readonly Dictionary StringsDict = []; + + public static readonly Dictionary TranslationStringRegex = new(); + + public static readonly Dictionary TranslationString = new(); + + public static readonly Dictionary CustomLevelStringRegex = new(); + + public static readonly Dictionary CustomLevelString = new(); + + public static readonly Dictionary IZLevelTipDictionary = new(); + + public static readonly Dictionary IZTipCollectionString = new(); + + public static readonly Dictionary FSLevelTipDictionary = new(); + + public static readonly Dictionary FSTipCollectionString = new(); + + public static readonly Dictionary> PatchesStore = new() + { + { + "Difficulty", new() + { + { "English", "Difficulty:" }, + { "French", "Difficulté:" }, + { "Italian", "Difficoltà:" }, + { "German", "Schwierigkeit:" }, + { "Spanish", "Dificultad:" }, + { "Portuguese", "Dificuldade:" }, + { "Filipino", "Ang Hirap:" }, + { "Vietnamese", "Độ Khó:" }, + { "Indonesian", "Kesulitan:" }, + { "Russian", "Сложность:" }, + { "Japanese", "困難:" }, + { "Korean", "난이도:" }, + { "Javanese", "Kesulitan:" }, + { "Polish", "Trudność:" }, + { "Hungarian", "Nehézség:" }, + { "Arabic", "صعوبة:" }, + // { "Ukrainian" , "Складність:" }, + // { "Slovak" , "Náročnosť:" }, + } + }, + { + "Zombies", new() + { + { "English", "Zombies:" }, + { "French", "Les Zombies:" }, + { "Italian", "Zombi:" }, + { "German", "Zombies:" }, + { "Spanish", "Zombis:" }, + { "Portuguese", "Zumbis:" }, + { "Filipino", "Mga Zombie:" }, + { "Vietnamese", "Thây Ma:" }, + { "Indonesian", "Zombi:" }, + { "Russian", "Зомби:" }, + { "Japanese", "ゾンビ:" }, + { "Korean", "좀비:" }, + { "Javanese", "Mayit:" }, + { "Polish", "Zombi:" }, + { "Hungarian", "Zombik:" }, + { "Arabic", "الزومبي:" }, + // { "Ukrainian" , "Зомбі:" }, + // { "Slovak" , "Zombíci:"} + } + }, + }; + + internal static void Init() => FileLoader.LoadStrings(); + + internal static void Reload() + { + TranslationString.Clear(); + TranslationStringRegex.Clear(); + CustomLevelString.Clear(); + CustomLevelStringRegex.Clear(); + IZLevelTipDictionary.Clear(); + IZTipCollectionString.Clear(); + FSLevelTipDictionary.Clear(); + FSTipCollectionString.Clear(); + InGameText_Patch.CurrentText = ""; + Utils.RegisterPlantIndices(); + FileLoader.LoadStrings(); + } + + public static TextMeshPro TranslateText(TextMeshPro originalTMP, bool isLog = false) + { + var fontAsset = FontStore.LoadTMPFont(ModFeatures.IsMultiLanguage ? Utils.Language.ToString() : null); + var translatedText = TranslateText(originalTMP.text); + originalTMP.font = fontAsset; + originalTMP.text = translatedText; + return originalTMP; + } + + public static TextMeshProUGUI TranslateText(TextMeshProUGUI originalTMP, bool isLog = false) + { + var fontAsset = ModFeatures.IsMultiLanguage + ? FontStore.LoadTMPFont(Utils.Language.ToString()) + : FontStore.LoadTMPFont(); + + var translatedText = TranslateText(originalTMP.text); + originalTMP.font = fontAsset; + originalTMP.text = translatedText; + return originalTMP; + } + + public static string TranslateText(string originalText, bool isLog = false) + { + var text = DoTranslateText(originalText); + + if (!ModFeatures.IsDebug) + return text; + + Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); + var match = regex.Match(text); + + if (match.Success) + FileLoader.DumpUntranslatedStrings(text); + + return text; + } + + public static string TranslateText(string originalText, string pattern, bool isLog = false) + { + if (TestRegex(originalText, pattern)) + { + if (TranslationStringRegex.TryGetValue(pattern, out var value)) + { + // Extract dynamic parts from the original text + var regex = new Regex(pattern); + var match = regex.Match(originalText); + var groupCount = match.Groups.Count; + + if (isLog) + Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); + + // List to hold formatted dynamic parts + List dynamicParts = []; + + // Loop through each group and determine its translation + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + var translatedValue = DoTranslateString(groupValue); + dynamicParts.Add(translatedValue); + } + + // Format the output string with dynamic parts + return string.Format(value, [..dynamicParts]); + } + + if (!CustomLevelStringRegex.TryGetValue(pattern, out var value1)) + return originalText; + + { + // Extract dynamic parts from the original text + var regex = new Regex(pattern); + var match = regex.Match(originalText); + var groupCount = match.Groups.Count; + + if (isLog) + Log.LogDebug("Text found in customLevelStringRegex {0}: {1}", match, groupCount); + + // List to hold formatted dynamic parts + List dynamicParts = []; + + // Loop through each group and determine its translation + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + var translatedValue = CustomLevelString.GetValueOrDefault(groupValue, groupValue); + dynamicParts.Add(translatedValue); + } + + // Format the output string with dynamic parts + return string.Format(value1, [..dynamicParts]); + } + } + + if (isLog) + Log.LogDebug($"Text '{originalText}' not translated"); + + FileLoader.DumpUntranslatedStrings(originalText); + return originalText; + } + + public static string DoTranslateString(string originalText, bool isLog = false) + { + if (string.IsNullOrEmpty(originalText)) + { + if (isLog) + Log.LogError("Text Null or Empty"); + + return string.Empty; + } + + if (TranslationString.TryGetValue(originalText, out var s)) + { + if (isLog) + Log.LogDebug($"Text '{originalText} found in translationString"); + + return s; + } + + if (IZTipCollectionString.TryGetValue(originalText, out var translateString)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in izTipCollectionString"); + + return translateString; + } + + if (FSTipCollectionString.TryGetValue(originalText, out var doTranslateString)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in fsTipCollectionString"); + + return doTranslateString; + } + + if (CustomLevelString.TryGetValue(originalText, out var s1)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in customLevelString"); + + return s1; + } + + if (!Utils.PlantIndiceString.TryGetValue(originalText, out var translateString1)) + return originalText; + + if (isLog) + Log.LogDebug($"Text '{originalText}' found in plantIndiceString"); + + return translateString1; + } + + public static string DoTranslateText(string originalText, bool isLog = false) + { + if (string.IsNullOrEmpty(originalText)) + { + if (isLog) + Log.LogError("Text Null or Empty"); + + return string.Empty; + } + + if (!Utils.CheckForUntranslatedText(originalText) && !originalText.Contains('_')) + return originalText; + + if (TranslationString.TryGetValue(originalText, out var text)) + { + if (isLog) + Log.LogDebug($"Text '{originalText} found in translationString"); + + return text; + } + + if (IZTipCollectionString.TryGetValue(originalText, out var translateText)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in izTipCollectionString"); + + return translateText; + } + + if (FSTipCollectionString.TryGetValue(originalText, out var doTranslateText)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in fsTipCollectionString"); + + return doTranslateText; + } + + if (CustomLevelString.TryGetValue(originalText, out var text1)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in customLevelString"); + + return text1; + } + + if (Utils.PlantIndiceString.TryGetValue(originalText, out var translateText1)) + { + if (isLog) + Log.LogDebug($"Text '{originalText}' found in plantIndiceString"); + + return translateText1; + } + + // Regex-based dynamic translation + foreach (var entry in TranslationStringRegex) + if (TestRegex(originalText, entry.Key)) + { + // Extract dynamic parts from the original text + var regex = new Regex(entry.Key); + var match = regex.Match(originalText); + var groupCount = match.Groups.Count; + + if (isLog) + Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount); + + // List to hold formatted dynamic parts + List dynamicParts = []; + + // Loop through each group and determine its translation + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + var translatedValue = DoTranslateString(groupValue); + dynamicParts.Add(translatedValue); + } + + // Format the output string with dynamic parts + return string.Format(entry.Value, [..dynamicParts]); + } + + foreach (var entry in CustomLevelStringRegex) + if (TestRegex(originalText, entry.Key)) + { + // Extract dynamic parts from the original text + var regex = new Regex(entry.Key); + var match = regex.Match(originalText); + var groupCount = match.Groups.Count; + + if (isLog) + Log.LogDebug("Text found in customLevelRegex {0}: {1}", match, groupCount); + + // List to hold formatted dynamic parts + List dynamicParts = []; + + // Loop through each group and determine its translation + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + var translatedValue = CustomLevelString.GetValueOrDefault(groupValue, groupValue); + dynamicParts.Add(translatedValue); + } + + // Format the output string with dynamic parts + return string.Format(entry.Value, [..dynamicParts]); + } + + if (isLog) + Log.LogDebug($"Text '{originalText}' not translated"); + + if (Utils.CheckForUntranslatedText(originalText)) + FileLoader.DumpUntranslatedStrings(originalText); + + return originalText; + } + + public static string TranslateColorText(string originalText, bool isLog = false) + { + var text = TranslateColorSegments(originalText); + + if (!ModFeatures.IsDebug) + return text; + + Regex regex = new("\\p{IsCJKUnifiedIdeographs}+"); + var match = regex.Match(text); + + if (match.Success) + // Log.LogDebug("Untranslated String: " + match.Value); + FileLoader.DumpUntranslatedStrings(text); + + return text; + } + + public static string TranslateColorSegments(string input) + { + var result = ""; + const string Pattern = @"]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+"; + const string SmallPattern = "(]+>)(.*?)()"; + var matches = Regex.Matches(input, Pattern); + + for (var i = 0; i < matches.Count; i++) + { + var match = matches[i]; + + if (Regex.Match(match.Value, SmallPattern, RegexOptions.Singleline).Success) + result += TranslateColorSegment(match.Value); + else + result += DoTranslateText(match.Value); + } + + return result; + } + + public static string TranslateColorSegment(string input) + { + const string Pattern = "(]+>)(.*?)()"; + var match = Regex.Match(input, Pattern, RegexOptions.Singleline); + var translatedText = DoTranslateText(match.Groups[2].Value); + + if (Utils.CheckForUntranslatedText(translatedText)) + FileLoader.DumpUntranslatedStrings(translatedText); + + return match.Groups[1].Value + translatedText + match.Groups[3].Value; + } + + public static bool TestRegex(string originalText, string pattern, bool singleLine = false) + { + var options = singleLine ? RegexOptions.None : RegexOptions.Singleline; + return Regex.IsMatch(originalText, pattern, options); + } + + private static TextAlignmentOptions TextAnchorToTMPAlignment(TextAnchor anchor) => + anchor switch + { + TextAnchor.UpperLeft => TextAlignmentOptions.TopLeft, + TextAnchor.UpperCenter => TextAlignmentOptions.Top, + TextAnchor.UpperRight => TextAlignmentOptions.TopRight, + TextAnchor.MiddleLeft => TextAlignmentOptions.MidlineLeft, + TextAnchor.MiddleCenter => TextAlignmentOptions.Center, + TextAnchor.MiddleRight => TextAlignmentOptions.MidlineRight, + TextAnchor.LowerLeft => TextAlignmentOptions.BottomLeft, + TextAnchor.LowerCenter => TextAlignmentOptions.Bottom, + TextAnchor.LowerRight => TextAlignmentOptions.BottomRight, + _ => TextAlignmentOptions.Center, + }; + + public static TextMeshProUGUI ConvertToTextMeshPro( + UnityEngine.UI.Text oldText, + TMP_FontAsset fontAsset, + bool isLog = false + ) + { + if (oldText == null) + { + Log.LogError("UnityEngine.UI.Text component is null."); + return null; + } + + if (fontAsset == null) + { + Log.LogError("TMP_FontAsset is null. Conversion cannot proceed."); + return null; + } + + // Log.LogInfo($"Converting UnityEngine.UI.Text: {oldText.name}"); + + var textObject = oldText.gameObject; + + // Preserve text content and settings + var originalText = oldText.text; + originalText = TranslateText(originalText, isLog); + var alignment = oldText.alignment; + var color = oldText.color; + + // Remove old Text component + UnityEngine.Object.DestroyImmediate(oldText); + + // Add TextMeshProUGUI component + var newTMP = textObject.AddComponent(); + + if (newTMP == null) + { + Log.LogError($"Failed to add TextMeshProUGUI to object: {textObject.name}"); + return null; + } + + // Configure TextMeshProUGUI + newTMP.text = originalText; + newTMP.color = color; + newTMP.alignment = TextAnchorToTMPAlignment(alignment); + newTMP.font = fontAsset; + + // Log.LogInfo($"Successfully converted {textObject.name} to TextMeshProUGUI."); + + return newTMP; + } + + public static void TranslateTextTransform( + Transform baseTransform, + bool isAutoTextContainer = false, + bool isLog = false + ) + { + if (!baseTransform) + return; + + var currentLanguage = ModFeatures.IsMultiLanguage ? Utils.Language.ToString() : null; + var fontAsset = FontStore.LoadTMPFont(currentLanguage); + + if (fontAsset == null) + { + Log.LogError( + ModFeatures.IsMultiLanguage + ? $"Font for language '{currentLanguage}' not found. Translation aborted." + : "Font not found. Translation aborted." + ); + + return; + } + + // Local function for processing transforms + void ProcessTextTransform(Transform textTransform) + { + if (!textTransform) + return; + + // Handle TextMeshPro components + var textTMP = textTransform.GetComponent(); + + if (textTMP) + { + textTMP.text = TranslateText(textTMP.text, isLog); + textTMP.autoSizeTextContainer = isAutoTextContainer; + textTMP.font = fontAsset; + } + + var textTmpugui = textTransform.GetComponent(); + + if (textTmpugui) + { + textTmpugui.text = TranslateText(textTmpugui.text, isLog); + textTmpugui.enableAutoSizing = isAutoTextContainer; + textTmpugui.font = fontAsset; + } + + // Handle UnityEngine.UI.Text components + var textUI = textTransform.GetComponent(); + + if (textUI) + ConvertToTextMeshPro(textUI, fontAsset, isLog); + } + + // Process specific text paths + ProcessTextTransform(baseTransform.Find("text")); + ProcessTextTransform(baseTransform.Find("text1")); + // ProcessTextTransform(baseTransform.Find("text2")); + + var shadowTransform = baseTransform.Find("text/shadow"); + + if (shadowTransform) + ProcessTextTransform(shadowTransform); + + shadowTransform = baseTransform.Find("text1/shadow"); + + if (shadowTransform) + ProcessTextTransform(shadowTransform); + + if (!ModFeatures.IsTesting) + return; + + var childTransform = baseTransform.GetChild(0); + + if (childTransform) + ProcessTextTransform(childTransform); + } + + public static void TranslateTextUI(TextMeshPro textTMP, bool? isAutoTextContainer = null, bool isLog = false) + { + var currentLanguage = Utils.Language.ToString(); + + if (!textTMP) + return; + + textTMP.text = TranslateText(textTMP.text, isLog); + + if (isAutoTextContainer != null) + textTMP.autoSizeTextContainer = isAutoTextContainer.Value; + + textTMP.font = FontStore.LoadTMPFont(currentLanguage); + } + + public static void TranslateTextUI(TextMeshProUGUI textTMP, bool? isAutoTextContainer = null, bool isLog = false) + { + var currentLanguage = Utils.Language.ToString(); + + if (!textTMP) + return; + + var origText = textTMP.text; + + textTMP.text = TranslateText(origText, isLog) == "" ? origText : TranslateText(origText, isLog); + + if (isAutoTextContainer != null) + textTMP.autoSizeTextContainer = isAutoTextContainer.Value; + + if (origText != textTMP.text) + textTMP.font = FontStore.LoadTMPFont(currentLanguage); + } + + public static void TranslateTextUI(TMP_InputField textInput) + { + var currentLanguage = Utils.Language.ToString(); + + if (!textInput) + return; + + var oriText = textInput.m_Text; + textInput.m_Text = TranslateText(oriText); + textInput.m_OriginalText = TranslateText(oriText); + textInput.fontAsset = FontStore.LoadTMPFont(currentLanguage); + } + + public static void LogAll() + { + Log.LogInfo("Logging all StringStore entries."); + Log.LogInfo("Regex Entries: {0}", TranslationStringRegex.Count); + Log.LogInfo("String Entries: {0}", TranslationString.Count); + } +} diff --git a/Source/AssetStore/TextureStore.cs b/Source/AssetStore/TextureStore.cs new file mode 100644 index 0000000..f030b7a --- /dev/null +++ b/Source/AssetStore/TextureStore.cs @@ -0,0 +1,55 @@ +using System.Collections; + +namespace PvZ_Fusion_Translator.AssetStore; + +public static class TextureStore +{ + internal static readonly Dictionary TextureDict = [], SpriteDict = []; + + internal static void Init() => FileLoader.LoadTextures(); + + internal static void Reload() + { + TextureDict.Clear(); + + if (ModFeatures.IsMultiLanguage) + RestoreTextures(); + + FileLoader.LoadTextures(); + } + + public static IEnumerator ReplaceTexturesCoroutine() + { + while (true) + { + ReplaceTextures(); + yield return new WaitForSeconds(0.5f); // Adjust this interval as needed + } // ReSharper disable once IteratorNeverReturns + } + + public static void ReplaceTextures() + { + foreach (var texture in Resources + .FindObjectsOfTypeAll() + .Where(texture => !texture.name.StartsWith("replaced_"))) + Utils.TryReplaceTexture2D(texture); + } + + public static void RestoreTextures() + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + + Texture2D[] textures = Resources.FindObjectsOfTypeAll(); + + foreach (var texture in textures.Where(texture => texture != null)) + texture.name = texture.name.Replace("replaced_", ""); + } + + public static void LogAll() + { + Log.LogInfo("Logging all TextureStore entries."); + + foreach (var entry in TextureDict) + Log.LogInfo("TextureDict Entry: " + entry.Key + " | " + entry.Value); + } +} diff --git a/Source/AssetStore/WarningStore.cs b/Source/AssetStore/WarningStore.cs new file mode 100644 index 0000000..1544dfd --- /dev/null +++ b/Source/AssetStore/WarningStore.cs @@ -0,0 +1,285 @@ +#if false +namespace PvZ_Fusion_Translator.AssetStore; + +public static class WarningStore +{ + private static readonly Dictionary s_warningMessages = new() + { + { + "English", + (""" + The only valid source of this translation is from this community: + discord.gg/DPAC5ZVJ8T. If you got this anywhere else like + Plants Hybrid and superhybrid.online, they stole it. + Stray away from other sources as they may contain viruses. + Please visit our community for future updates. + """, "Okay! Got it.") + }, + { + "French", + (""" + La seule source valide pour cette traduction provient de cette + communauté :discord.gg/DPAC5ZVJ8T. Si vous l'avez obtenue + ailleurs, comme Plants Hybrid ou superhybrid.online, ils l'ont volée. + Évitez les autres sources, car elles peuvent contenir des virus. + Veuillez visiter notre communauté pour les mises à jour futures. + """, "D'accord !") + }, + { + "Italian", + (""" + L'unica fonte valida di questa traduzione è questa community: + discord.gg/DPAC5ZVJ8T. Se l'hai ottenuta altrove, come + Plants Hybrid e superhybrid.online, l'hanno rubata. + Evita altre fonti, potrebbero contenere virus. + Visita la nostra community per aggiornamenti futuri. + """, "Va bene! Ho capito.") + }, + { + "German", + (""" + Die einzige gültige Quelle für diese Übersetzung stammt aus + dieser Community: discord.gg/DPAC5ZVJ8T. Wenn Sie diese + irgendwo anders gefunden haben, z. B. bei Plants Hybrid oder + superhybrid.online, dann haben sie sie gestohlen. + Meiden Sie andere Quellen, da diese Viren enthalten könnten. + Bitte besuchen Sie unsere Community für zukünftige Updates. + """, "Okay, verstanden!") + }, + { + "Spanish", + (""" + La única fuente válida de esta traducción proviene de esta + comunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier + otro lugar como Plants Hybrid o superhybrid.online, la robaron. + Manténgase alejado de otras fuentes, ya que podrían contener virus. + Por favor, visite nuestra comunidad para futuras actualizaciones. + """, "¡Entendido!") + }, + { + "Portuguese", + (""" + O lugar original e seguro dessa tradução vem daqui: + discord.gg/DPAC5ZVJ8T. Se você baixou ela de qualquer + lugar como Plants Hybrid ou superhybrid.online, eles + roubaram. Evite baixar deles, pode conter vírus. + Por favor, visite nossa comunidade para atualizações futuras. + """, "Okay, entendido.") + }, + { + "Filipino", + (""" + Ang tanging opisyal na source ng pagsasaling ito ay mula + lamang dito: discord.gg/DPAC5ZVJ8T. Kung nakuha nmo ito kahit + saan pa tulad ng Plants Hybrid at superhybrid.online, ito ay ninakaw. + Lumayo sa ibang source dahil posibleng may kasamang virus. + Paki-bisita ang aming komunidad para sa mga darating na update. + """, "Naiintindihan!") + }, + { + "Vietnamese", + (""" + Nguồn duy nhất hợp lệ của bản dịch này là từ cộng + đồng này: discord.gg/DPAC5ZVJ8T. Nếu bạn nhận + được nó ở bất cứ nơi nào khác như Plants Hybrid + hoặc superhybrid.online, họ đã ăn cắp nó. + Tránh xa các nguồn khác vì chúng có thể chứa + virus. Hãy ghé thăm cộng đồng của chúng tôi để + cập nhật trong tương lai. + """, "Đồng ý!") + }, + { + "Indonesian", + (""" + Satu-satunya sumber resmi dari terjemahan ini adalah + komunitas kami: discord.gg/DPAC5ZVJ8T. Jika Anda + mendapatkannya dari sumber lain seperti Plants Hybrid + dan superhybrid.online, mereka mencurinya. + Jauhi sumber lain karena mungkin ada virus. + Silakan kunjungi komunitas kami untuk pembaruan berikutnya. + """, "Oke! Mengerti.") + }, + { + "Russian", (""" + Единственный проверенный источник этого перевода — + сообщество discord.gg/DPAC5ZVJ8T. + Или же его замена https://t.me/nekoshkindom + Если вы скачали этот мод где-либо ещё, возможно он содержит вирусы. + Программист перевода: LancerX0. + Переводчик: Nekosha. + """, "Хорошо!") + }, + { + "Japanese", (""" + この翻訳の唯一の有効なソースは、このコミュニティからです: + discord.gg/DPAC5ZVJ8T.Plants Hybridやsuperhybrid.online、 + YoutubeのBlue Flyが作っているもの、他のどこかでこれを入手した場合、 + 彼らはそれを盗んだことになります。ウイルスが含まれている可能性があるので、 + 他のソースからは離れてください。今後のアップデートについては、 + 私たちのコミュニティをご覧ください。 + """, + "了解しました!") + }, + { + "Korean", (""" + 이 번역은 Bloom(discord.gg/DPAC5ZVJ8T)에서만 + 제공됩니다. Bloom 디스코드 이외의 다른서드 파티 사이트, + 예를 들어 Plants Hybrid 및 superhybrid.online, 또는 + 유튜브 Blue Fly등에서 제공하는 파일은 무단으로 재배포된 것이며, + 이런 사이트들에는 바이러스가 포함되어 있을 가능성이 높습니다. + 향후 업데이트를 위해 저희 디스코드를 방문해 주세요. + """, + "확인") + }, + { + "Javanese", (""" + Sumber mung sing sah kanggo terjemahan iki saka komunitas iki: + discord.gg/DPAC5ZVJ8T. Yen sampeyan nemokake iki ing papan + liya kaya Plants Hybrid lan superhybrid.online, iku dicolong. + Aja nyedhaki sumber liya amarga bisa ngandhut virus. Mangga + ngunjungi komunitas kita kanggo nganyari ing mangsa ngarep. + """, + "Oke! Ngertos.") + }, + { + "Polish", (""" + Jedynym wiarygodnym źródłem tego tłumaczenia jest ta społeczność: + discord.gg/DPAC5ZVJ8T. Jeśli znalazłeś to gdziekolwiek indziej, np. + Plants Hybrid i superhybrid.online, ukradli to. + Omijaj inne źródła, ponieważ mogą zawierać wirusy. + Odwiedź naszą społeczność, aby uzyskać przyszłe aktualizacje. + """, + "Okay! Rozumiem.") + }, + { + "Hungarian", ( + """ + Ennek a fordításnak az egyetlen érvényes forrása ebből a közösségből származik: + discord.gg/DPAC5ZVJ8T. Ha ezt valahol máshol szerezted, például + Plants Hybrid és superhybrid.online oldalakon, akkor ők lopták. + Kerüld a többi forrást, mert vírusokat tartalmazhatnak. + Kérjük, látogass el közösségünkbe a jövőbeli frissítésekért. + """, + "Oké! Értem.") + }, + { + "Arabic", (""" + The only valid source of this translation is from this community: + discord.gg/DPAC5ZVJ8T. If you got this anywhere else like + Plants Hybrid and superhybrid.online, they stole it. + Stray away from other sources as they may contain viruses. + Please visit our community for future updates. + """, + "Okay! Got it.") + }, + // { "OTHER" , ("A única fonte válida dessa tradução é desta\ncomunidade: discord.gg/DPAC5ZVJ8T. Se você obteve \nisso em qualquer lugar como Plants Hybrid\ne superhybrid.online,ou Blue Fly do Youtube,\nelses roubaram. Fique longe de sites falsos. Por favor,\nvisite nossa comunidade para futuras atualizações.", "¡Okei! Entendido.") }, + // { "OTHER" , ("Ang translation na ito ay galing dito lamang:\ndiscord.gg/DPAC5ZVJ8T. Pag nakuha niyo ito sa iba pa\nkagaya ng Plants Hybrid o superhybrid.online, anumang\nginawagawa ng Blue Fly mula sa Youtube, o anumang\nSub2Unlock links, scam sila. MAG INGAT dahil\nkasi baka may virus 'jan. Join kayo sa discord namin!\nFilipino Translation by ColinPogi", "Tayo magsi-laro!") }, + }; + + public static bool IsWarningMessageLoaded { get; set; } + + public static string WarningMessage { get; set; } = + "La única fuente válida de esta traducción proviene de esta\ncomunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\notro lugar como Plants Hybrid o superhybrid.online, la robaron.\nManténgase alejado de otras fuentes, ya que podrían contener virus.\nPor favor, visite nuestra comunidad para futuras actualizaciones."; + + public static string OkayButton { get; set; } = "¡Entendido!"; + + // ReSharper disable once UnusedTupleComponentInReturnValue + public static (string, string) GetWarningMessage(Utils.LanguageEnum language) + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + + return s_warningMessages.TryGetValue(language.ToString(), out var message) + ? message + : s_warningMessages["English"]; // Default to English if language code is not found + } + + public static void WarningLoad(NoticeMenu noticeMenu) + { + if (noticeMenu == null || noticeMenu.transform == null) + { + Log.LogWarning("[WarningStore] NoticeMenu or transform is null - ABORTING"); + return; + } + + if (!ModFeatures.IsMultiLanguage) + return; + + try + { + var (localizedWarningMessage, _) = GetWarningMessage(Utils.Language); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + Transform warningTransform = noticeMenu.transform.Find("窗口"); + + if (warningTransform == null) + { + Log.LogWarning("[WarningStore] '窗口' transform not found - ABORTING"); + return; + } + + var warningTextTransform = warningTransform.Find("文字"); + var warningTextShadowTransform = warningTransform.Find("文字2"); + + if (warningTextTransform == null || warningTextShadowTransform == null) + { + Log.LogWarning("[WarningStore] Could not find text components (文字/文字2)"); + return; + } + + var warningText = warningTextTransform.GetComponent(); + var shadowText = warningTextShadowTransform.GetComponent(); + + if (warningText == null || shadowText == null) + { + Log.LogWarning("[WarningStore] TextMeshProUGUI components missing"); + return; + } + + warningText.text = localizedWarningMessage; + shadowText.text = localizedWarningMessage; + + if (fontAsset != null) + { + warningText.font = fontAsset; + shadowText.font = fontAsset; + } + else + Log.LogWarning("[WarningStore] Font asset is null"); + + Log.LogInfo("Warning message loaded successfully!"); + } + catch (Exception e) + { + Log.LogError($"Critical error in WarningLoad: {e}"); + } + } + + public static void WarningReload(Utils.LanguageEnum language, NoticeMenu noticeMenu) + { + if (!ModFeatures.IsMultiLanguage) + { + if (IsWarningMessageLoaded) + return; + + WarningStore.WarningLoad(); + IsWarningMessageLoaded = true; + return; + } + + if (noticeMenu == null) + { + Log.LogWarning("[WarningStore] NoticeMenu is null in WarningReload"); + return; + } + + if (Utils.OldLanguage.ToString() == language.ToString() && Utils.OldLanguage.ToString() != "English") + return; + + if (IsWarningMessageLoaded) + return; + + WarningLoad(noticeMenu); + IsWarningMessageLoaded = true; + } +} +#endif diff --git a/Source/Core.cs b/Source/Core.cs new file mode 100644 index 0000000..921e028 --- /dev/null +++ b/Source/Core.cs @@ -0,0 +1,276 @@ +global using UnityEngine; +#if MELONLOADER +global using MelonLoader; +global using MelonLoader.Logging; +global using MelonLoader.Utils; +global using Il2Cpp; +global using Il2CppAlmanacData; +global using Il2CppCore; +global using Il2CppGameLevel; // ReSharper disable once RedundantUsingDirective.Global +global using Il2CppGameLevel.Abyss; +global using Il2CppGameLevel.EventNodes; +global using Il2CppGameLevel.RogueShooting; +global using Il2CppPVPScaryPot; +global using Il2CppRhythmGame; +global using Il2CppRhythmGameEditor; +global using Il2CppTMPro; +global using Il2CppZenGarden; +global using AudioImportLibAPI = AudioImportLib.API; +global using Il2CppAlmanacDataClass = Il2CppAlmanacData.AlmanacData; +global using Il2CppLevelData = Il2Cpp.LevelData; +global using Il2CppPlantInfo = Il2CppAlmanacData.PlantInfo; +#elif BEPINEX +global using AlmanacData; +global using BepInEx; +global using BepInEx.Configuration; +global using BepInEx.Logging; +global using BepInEx.Unity.IL2CPP; +global using BepInEx.Unity.IL2CPP.Utils; +global using Core; +global using GameLevel; +global using GameLevel.Abyss; +global using GameLevel.EventNodes; +global using GameLevel.RogueShooting; +global using PVPScaryPot; +global using RhythmGame; +global using RhythmGameEditor; +global using TMPro; +global using ZenGarden; +global using AudioImportLibAPI = AudioImportLib.BepInEx.API; +global using Il2CppAlmanacDataClass = AlmanacData.AlmanacData; +global using Il2CppLevelData = LevelData; +global using Il2CppPlantInfo = AlmanacData.PlantInfo; +#endif +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.Managers; +using PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +#if MELONLOADER +[assembly: + MelonGame("LanPiaoPiao", "PlantsVsZombiesRH"), + MelonInfo( + typeof(PvZ_Fusion_Translator.Core), + "PvZ Fusion Translator", + "231.0.0", + "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun / cassidy / Teyliu / Emik" + )] +#endif + +namespace PvZ_Fusion_Translator; +#pragma warning disable CA1822 // ReSharper disable once ClassNeverInstantiated.Global +#if MELONLOADER +public class Core : MelonMod +#elif BEPINEX +[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "3.1.1"), BepInProcess("PlantsVsZombiesRH.exe")] +public class Core : BasePlugin +#endif +{ +#if BEPINEX + public sealed class UnityCoroutineHelper : MonoBehaviour + { + // ReSharper disable once MemberHidesStaticFromOuterClass + public static UnityCoroutineHelper Instance { get; private set; } + + public void Awake() => Instance = this; + } +#endif + public static string ModDirectory => +#if MELONLOADER + Path.Combine(MelonEnvironment.ModsDirectory, "PvZ_Fusion_Translator"); +#elif BEPINEX + Path.Combine(Paths.PluginPath, "PvZ_Fusion_Translator"); +#endif + public static bool IsInitialized { get; set; } + + public static Core Instance { get; private set; } +#if MELONLOADER + public MelonPreferences_Entry ConfigDefaultAudio, ConfigDefaultTextures, ConfigUseLocal; + + public MelonPreferences_Entry ConfigLanguage; + + private object _replaceTextureRoutine; +#elif BEPINEX + public static MonoBehaviour MonoInstance { get; private set; } + + public ConfigEntry ConfigDefaultAudio, ConfigDefaultTextures, ConfigUseLocal; + + public ConfigEntry ConfigLanguage; + + public new static ManualLogSource Log { get; private set; } + + private Coroutine _replaceTextureRoutine; +#endif + private static DateTime? s_dtStartToast; + + private static string s_toastText; +#if MELONLOADER + public static object Coroutine(System.Collections.IEnumerator enumerator) => + MelonCoroutines.Start(enumerator); +#elif BEPINEX + public static Coroutine Coroutine(System.Collections.IEnumerator enumerator) => + MonoInstance.StartCoroutine(enumerator); +#endif +#if MELONLOADER + public override void OnInitializeMelon() +#elif BEPINEX + public override void Load() +#endif + { + Instance = this; + LoadConfig(); + + if (ModFeatures.IsMultiLanguage) + FileLoader.LoadLanguage(); + + _replaceTextureRoutine = Coroutine(TextureStore.ReplaceTexturesCoroutine()); + TextureStore.Init(); + StringStore.Init(); + AudioStore.Init(); + FontStore.Init(); +#if MELONLOADER + base.OnInitializeMelon(); +#elif BEPINEX + Log = base.Log; + Utils.RegisterPlantIndices(); + MonoInstance = AddComponent(); + HarmonyLib.Harmony.CreateAndPatchAll(System.Reflection.Assembly.GetExecutingAssembly()); +#endif + IsInitialized = true; + } +#if MELONLOADER + public override void OnLateInitializeMelon() + { + FileLoader.LoadTravelBuffs(); + Utils.RegisterPlantIndices(); + } + + public override void OnDeinitializeMelon() + { + MelonCoroutines.Stop(_replaceTextureRoutine); + + if (ModFeatures.IsMultiLanguage) + FileLoader.SaveLanguage(); + } +#elif BEPINEX + public override bool Unload() + { + if (_replaceTextureRoutine != null) + { + MonoInstance.StopCoroutine(_replaceTextureRoutine); + Log.LogDebug("Coroutine Stopped"); + } + + FileLoader.SaveLanguage(); + return true; + } +#endif + public static void ShowToast(string message) + { + s_toastText = message; + s_dtStartToast = new(DateTime.Now.Ticks); + } +#if MELONLOADER + public override void OnLateUpdate() +#elif BEPINEX + public void OnUpdate() +#endif + { + if (ModFeatures.IsDebug) + ModFeatures.OnLateUpdate(); + + if (Input.GetKeyDown(KeyCode.Insert)) + Utils.OpenSaveDirectory(); + + if (Input.GetKeyDown(KeyCode.PageUp)) + Utils.OpenOnlineAlmanac(); + + TowerManager_Patch.UpdateText(); + + if (CustomLevelMenu_Patch.RequestTimer <= 0) + return; + + CustomLevelMenu_Patch.RequestTimer -= Time.deltaTime; + + if (CustomLevelMenu_Patch.RequestTimer < 0) + CustomLevelMenu_Patch.RequestTimer = 0; + } +#if MELONLOADER + public override void OnGUI() +#elif BEPINEX + public void OnGUI() +#endif + { + if (!ModFeatures.IsDebug) + return; + + if (s_dtStartToast is null) + return; + + GUI.Button(new(10, 10, 200, 20), $"\n{s_toastText}\n"); + var timeSpan = DateTime.Now - s_dtStartToast; + TimeSpan t = new(0, 0, 0, 2); + + if (timeSpan > t) + s_dtStartToast = null; + } +#if MELONLOADER + private void LoadConfig() + { + var category = MelonPreferences.CreateCategory("PvZ_Fusion_Translator", "Fusion Translator Settings"); + + ConfigDefaultTextures = category.CreateEntry("DefaultTextures", false); + ConfigDefaultAudio = category.CreateEntry("DefaultAudio", false); + ConfigUseLocal = category.CreateEntry("UseLocal", false); + ConfigLanguage = category.CreateEntry("Language", "English"); + + MelonPreferences.Save(); + } +#elif BEPINEX + private void LoadConfig() + { + const string MainCategory = "PvZ_Fusion_Translator"; + + if (!Config.TryGetEntry(new(MainCategory, "DefaultTextures"), out ConfigDefaultTextures)) + ConfigDefaultTextures = Config.Bind( + new(MainCategory, "DefaultTextures"), + false, + new("Use Default Textures + Translation Textures", new AcceptableValueList(true, false)) + ); + + Debug.Assert(Config.TryGetEntry(new(MainCategory, "DefaultTextures"), out ConfigDefaultTextures)); + + if (!Config.TryGetEntry(new(MainCategory, "DefaultAudio"), out ConfigDefaultAudio)) + ConfigDefaultAudio = Config.Bind( + new(MainCategory, "DefaultAudio"), + false, + new("Use Default Audio", new AcceptableValueList(true, false)) + ); + + Debug.Assert(Config.TryGetEntry(new(MainCategory, "DefaultAudio"), out ConfigDefaultAudio)); + + if (!Config.TryGetEntry(new(MainCategory, "UseLocal"), out ConfigDefaultAudio)) + ConfigUseLocal = Config.Bind( + new(MainCategory, "UseLocal"), + false, + new("Use Local", new AcceptableValueList(true, false)) + ); + + Debug.Assert(Config.TryGetEntry(new(MainCategory, "DefaultAudio"), out ConfigDefaultAudio)); + + string[] supportedLanguages = + [ + "English", "French", "Italian", "German", "Spanish", "Portuguese", "Indonesian", + "Vietnamese", "Javanese", "Russian", "Japanese", "Korean", + ]; + + if (!Config.TryGetEntry(new(MainCategory, "Language"), out ConfigLanguage)) + ConfigLanguage = Config.Bind( + new(MainCategory, "Language"), + "English", + new("Load the Game in this Language", new AcceptableValueList(supportedLanguages)) + ); + + Debug.Assert(Config.TryGetEntry(new(MainCategory, "Language"), out ConfigLanguage)); + } +#endif +} diff --git a/Source/FileLoader.cs b/Source/FileLoader.cs new file mode 100644 index 0000000..e451ba7 --- /dev/null +++ b/Source/FileLoader.cs @@ -0,0 +1,1142 @@ +using Il2CppInterop.Runtime.InteropTypes.Arrays; +using Newtonsoft.Json; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.GameObjects; +using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; +using PvZ_Fusion_Translator.Patches.Modes.Odyssey; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace PvZ_Fusion_Translator; + +// ReSharper disable AssignNullToNotNullAttribute Unity.UnknownResource +internal static class FileLoader +{ + internal enum AssetType + { + Textures, Strings, Dumps, Almanac, Sprites, + } + + public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null) + { + var languagePath = language.HasValue + ? "Localization" + Path.DirectorySeparatorChar + language + : string.Empty; + + return Path.Combine(Core.ModDirectory, languagePath, assetType.ToString()); + } + + // private static string GetAssetDir(AssetType assetType) => + // Path.Combine(Core.Instance.modsDirectory, assetType.ToString()); + + internal static void LoadStrings() => LoadStrings(Utils.Language); + + internal static void LoadStrings(Utils.LanguageEnum language) + { + var stringDir = GetAssetDir(AssetType.Strings, Utils.Language); + + if (!Directory.Exists(stringDir)) + Directory.CreateDirectory(stringDir); + + if (!Core.Instance.ConfigUseLocal.Value) + { + // load translationStrings + var translationStringsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/translation_strings.json" + ) + .Result; + + if (translationStringsContent != null) + LoadTranslationStrings(translationStringsContent); + else + { + var translationStringsPath = Path.Combine( + GetAssetDir(AssetType.Strings, Utils.Language), + "translation_strings.json" + ); + + if (File.Exists(translationStringsPath)) + LoadTranslationStrings(File.ReadAllText(translationStringsPath)); + } + + // load translationRegexs + var translationRegexsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/translation_regexs.json" + ) + .Result; + + if (translationRegexsContent != null) + LoadTranslationRegexs(translationRegexsContent); + else + { + var translationRegexsPath = Path.Combine( + GetAssetDir(AssetType.Strings, Utils.Language), + "translation_regexs.json" + ); + + if (File.Exists(translationRegexsPath)) + LoadTranslationRegexs(File.ReadAllText(translationRegexsPath)); + } + + var customLevelStringsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/customlevel_strings.json" + ) + .Result; + + if (customLevelStringsContent != null) + LoadCustomLevelStrings(customLevelStringsContent); + else + { + var customLevelStringsPath = Path.Combine( + GetAssetDir(AssetType.Strings, Utils.Language), + "customlevel_strings.json" + ); + + if (File.Exists(customLevelStringsPath)) + LoadCustomLevelStrings(File.ReadAllText(customLevelStringsPath)); + } + + // load translationRegexs + var customLevelRegexsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/customlevel_regexs.json" + ) + .Result; + + if (customLevelRegexsContent != null) + LoadCustomLevelRegexs(customLevelRegexsContent); + else + { + var customLevelRegexsPath = Path.Combine( + GetAssetDir(AssetType.Strings, Utils.Language), + "customlevel_regexs.json" + ); + + if (File.Exists(customLevelRegexsPath)) + LoadCustomLevelRegexs(File.ReadAllText(customLevelRegexsPath)); + } + + // load changelog + + LoadChangelogText(); + + // load tips + var izTipsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/tips_iz.json" + ) + .Result; + + if (izTipsContent != null) + LoadIZStrings(izTipsContent); + else + { + var izTipsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_iz.json"); + + if (File.Exists(izTipsPath)) + LoadIZStrings(File.ReadAllText(izTipsPath)); + } + + var fsTipsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/tips_fs.json" + ) + .Result; + + if (fsTipsContent != null) + LoadFsStrings(fsTipsContent); + else + { + var fsTipsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "tips_fs.json"); + + if (File.Exists(fsTipsPath)) + LoadFsStrings(File.ReadAllText(fsTipsPath)); + } + + // load almanacs + + var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + + if (!Directory.Exists(almanacDir)) + Directory.CreateDirectory(almanacDir); + + var plantAlmanacContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Almanac/LawnStringsTranslate.json" + ) + .Result; + + if (plantAlmanacContent != null) + AlmanacPlantMenu_Patch.LoadPlantAlmanacData(plantAlmanacContent); + else + { + var path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); + + if (File.Exists(path)) + AlmanacPlantMenu_Patch.LoadPlantAlmanacData(File.ReadAllText(path)); + } + + var zombieAlmanacContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Almanac/ZombieStringsTranslate.json" + ) + .Result; + + if (zombieAlmanacContent != null) + AlmanacZombieMenu_Patch.AlmanacJson = zombieAlmanacContent; + else + { + var path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); + + if (File.Exists(path)) + AlmanacZombieMenu_Patch.AlmanacJson = File.ReadAllText(path); + } + + var detailStringsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Almanac/DetailStringsTranslate.json" + ) + .Result; + + if (detailStringsContent != null) + LoadDetailStrings(detailStringsContent); + else + { + var path = Path.Combine(almanacDir, "DetailStringsTranslate.json"); + + if (File.Exists(path)) + LoadDetailStrings(File.ReadAllText(path)); + } + + // load travel_buffs + + LoadTravelBuffs(); + + // load abyss buffs + + //Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); + + SaveStrings(); + DumpJson(); + } + else + { + if (!Directory.Exists(stringDir)) + Directory.CreateDirectory(stringDir); + + try + { + foreach (var filepath in Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories)) + { + var fileName = Path.GetFileNameWithoutExtension(filepath); + StringStore.StringsDict[fileName] = filepath; + + if (ModFeatures.IsDebug) + Log.LogInfo("Loading File : " + filepath); + + var jsonString = File.ReadAllText(filepath); + + if (fileName.EndsWith("translation_strings")) + LoadTranslationStrings(jsonString); + else if (fileName.EndsWith("translation_regexs")) + LoadTranslationRegexs(jsonString); + else if (fileName.EndsWith("customlevel_strings")) + LoadCustomLevelStrings(jsonString); + else if (fileName.EndsWith("customlevel_regexs")) + LoadCustomLevelRegexs(jsonString); + else if (fileName.EndsWith("tips_iz")) + LoadIZStrings(jsonString); + else if (fileName.EndsWith("tips_fs")) + LoadFsStrings(jsonString); + //else if(fileName.EndsWith("abyss_buffs")) + //{ + // Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); + //} + else if (fileName.EndsWith("travel_buffs")) + LoadTravelBuffs(); + } + + var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + + if (!Directory.Exists(almanacDir)) + Directory.CreateDirectory(almanacDir); + + var plantAlmanacPath = Path.Combine(almanacDir, "LawnStringsTranslate.json"); + + if (File.Exists(plantAlmanacPath)) + AlmanacPlantMenu_Patch.LoadPlantAlmanacData(File.ReadAllText(plantAlmanacPath)); + + var zombieAlmanacPath = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); + + if (File.Exists(zombieAlmanacPath)) + AlmanacZombieMenu_Patch.AlmanacJson = File.ReadAllText(zombieAlmanacPath); + + var detailStringsPath = Path.Combine(almanacDir, "DetailStringsTranslate.json"); + + if (File.Exists(detailStringsPath)) + LoadDetailStrings(File.ReadAllText(detailStringsPath)); + + LoadChangelogText(); + + SaveStrings(); + DumpJson(); + } + catch (Exception e) + { + Log.LogError("Error loading string."); + Log.LogError(e.GetType() + " " + e.Message); + } + } + + Log.LogInfo("Strings loaded successfully."); + } + + internal static void LoadTranslationStrings(string content) + { + var dictionary = + System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var (key, value) in dictionary) + StringStore.TranslationString[key] = value; + } + + internal static void LoadTranslationRegexs(string content) + { + var dictionary = + System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var (key, value) in dictionary) + StringStore.TranslationStringRegex[key] = value; + + Zombie_Patch.LoadHpStrings(); + } + + internal static void LoadCustomLevelStrings(string content) + { + var dictionary = + System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var (key, value) in dictionary) + StringStore.CustomLevelString[key] = value; + } + + internal static void LoadCustomLevelRegexs(string content) + { + var dictionary = + System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var (key, value) in dictionary) + StringStore.CustomLevelStringRegex[key] = value; + } + + internal static void LoadIZStrings(string content) + { + var (izLevelData, _) = DumpIZStrings(); + + var izTranslatedTips = System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var level in izLevelData) + { + var data = level.text; + var levelData = JsonUtility.FromJson(data); + + if (levelData.tips == null) + continue; + + if (!izTranslatedTips.ContainsKey(level.name) || + StringStore.IZTipCollectionString.ContainsKey(levelData.tips)) + continue; + + StringStore.IZLevelTipDictionary.Add(level.name, izTranslatedTips[level.name]); + StringStore.IZTipCollectionString.Add(levelData.tips, izTranslatedTips[level.name]); + } + } + + internal static void LoadFsStrings(string content) + { + var (fusionShowcaseData, _) = DumpFSStrings(); + + var fsTranslatedTips = System.Text.Json.JsonSerializer.Deserialize>(content); + + foreach (var level in fusionShowcaseData) + { + var data = level.text; + var levelData = JsonUtility.FromJson(data); + + if (levelData.tips == null) + continue; + + if (!fsTranslatedTips.ContainsKey(level.name) || + StringStore.FSTipCollectionString.ContainsKey(levelData.tips)) + continue; + + StringStore.FSLevelTipDictionary.Add(level.name, fsTranslatedTips[level.name]); + StringStore.FSTipCollectionString.Add(levelData.tips, fsTranslatedTips[level.name]); + } + } + + internal static void LoadDetailStrings(string content) + { + var (detailStringsData, _) = DumpDetailStrings(); + + var translatedDetailStrings = System.Text.Json.JsonSerializer.Deserialize>(content); + AlmanacSelectMenu_Patch.DetailStrings = translatedDetailStrings; + + foreach (var detailString in detailStringsData.details) + if (translatedDetailStrings.TryGetValue(detailString.title, out var s)) + AlmanacSelectMenu_Patch.DetailTranslateStrings[detailString.text] = s; + } + + internal static void LoadChangelogText() + { + var stringDir = GetAssetDir(AssetType.Strings, Utils.Language); + var changelogDir = Path.Combine(stringDir, "changelog.txt"); + + if (!File.Exists(changelogDir)) + File.WriteAllText(changelogDir, ""); + + var changelogText = File.ReadAllText(changelogDir); + + if (!Core.Instance.ConfigUseLocal.Value) + { + var changelogContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/changelog.txt" + ) + .Result; + + if (changelogContent != null) + changelogText = changelogContent; + } + else + changelogText = File.ReadAllText(changelogDir); + + NoticePauseMenu_Patch.ChangelogText = changelogText; + } + + internal static void LoadTravelBuffs() + { + if (!Core.Instance.ConfigUseLocal.Value) + { + var travelBuffsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/travel_buffs.json" + ) + .Result; + + if (travelBuffsContent != null) + TravelMgr_Patch.GenerateTranslatedTravelBuffs(travelBuffsContent); + else + { + var travelBuffsPath = Path.Combine( + GetAssetDir(AssetType.Strings, Utils.Language), + "travel_buffs.json" + ); + + if (File.Exists(travelBuffsPath)) + TravelMgr_Patch.GenerateTranslatedTravelBuffs(File.ReadAllText(travelBuffsPath)); + } + } + else + { + var stringDir = GetAssetDir(AssetType.Strings, Utils.Language); + + foreach (var jsonString in from filepath in + Directory.EnumerateFiles(stringDir, "*.json", SearchOption.AllDirectories) + let fileName = Path.GetFileNameWithoutExtension(filepath) + let jsonString = File.ReadAllText(filepath) + where fileName.EndsWith("travel_buffs") + select jsonString) + TravelMgr_Patch.GenerateTranslatedTravelBuffs(jsonString); + } + } + + internal static void LoadTextures() + { + // Default or Custom Texturse -> English Textures -> Localized Textures + try + { + if (!Core.Instance.ConfigDefaultTextures.Value) + LoadCustomTextures(); + } + catch (Exception e) + { + Log.LogError("Error loading texture setting."); + Log.LogError($"{e.GetType()} {e.Message}"); + } + + if (ModFeatures.IsMultiLanguage) + { + LoadLocalizedTextures(Utils.Language); + LoadLocalizedSprites(Utils.Language); + } + else + LoadLocalizedTextures(); + + Log.LogInfo("Textures loaded successfully."); + } + + // ReSharper disable once FunctionComplexityOverflow + internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null) + { + var textureDir = GetAssetDir(AssetType.Textures, language); + + if (!Directory.Exists(textureDir)) + Directory.CreateDirectory(textureDir); + + try + { + var localTocDir = Path.Combine(textureDir, "Texture_TOC.json"); + + if (!File.Exists(localTocDir)) + File.WriteAllText(localTocDir, "{}"); + + var localTocContent = File.ReadAllText(localTocDir); + var localToc = System.Text.Json.JsonSerializer.Deserialize>(localTocContent); + + var basePath = Core.ModDirectory; + + if (!Core.Instance.ConfigUseLocal.Value) + { + var textureTocRequest = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Textures/Texture_TOC.json" + ) + .Result; + + if (textureTocRequest != null) + { + var textureToc = + JsonConvert.DeserializeObject>(textureTocRequest); + + List toDownload = new(); + + foreach (var pair in textureToc) + { + if (!localToc.TryGetValue(pair.Key, out var value)) + { + toDownload.Add(pair.Key); + continue; + } + + if (pair.Value != value) + toDownload.Add(pair.Key); + + if (!File.Exists(Path.Combine(basePath, pair.Key))) + toDownload.Add(pair.Key); + } + + var toWriteText = SerializeWithIndentation(textureToc); + File.WriteAllText(localTocDir, toWriteText); + + foreach (var path in toDownload) + { + var downloadPath = Path.Combine(basePath, path); + + const string BaseUrl = + "https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; + + var imageData = Utils.GetByteDataFromWeb($"{BaseUrl}{path}").Result; + + if (imageData == null) + continue; + + var fileName = Path.GetFileName(downloadPath); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[fileName] = imageData; + + if (!Directory.Exists(Path.GetDirectoryName(downloadPath))) + Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); + + File.WriteAllBytes(downloadPath, imageData); + } + } + } + + foreach (var path in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories) + .Where( + p => (!p.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) || + !Core.Instance.ConfigDefaultTextures.Value) && + (localToc.ContainsKey(p.Replace(basePath + "\\", "").Replace("\\", "/")) || + SerializeWithIndentation(localToc) == "{}") + )) + { + if (ModFeatures.IsDebug) + Log.LogDebug("Loading File : " + path); + + var imageData = File.ReadAllBytes(path); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[Path.GetFileNameWithoutExtension(path)] = imageData; + } + } + + catch (Exception e) + { + Log.LogError("Error loading Texture."); + Log.LogError(e.GetType() + " " + e.Message); + } + } + + // ReSharper disable once FunctionComplexityOverflow + internal static void LoadLocalizedSprites(Utils.LanguageEnum? language = null) + { + var textureDir = GetAssetDir(AssetType.Sprites, language); + + if (!Directory.Exists(textureDir)) + Directory.CreateDirectory(textureDir); + + try + { + var trueTextureDir = GetAssetDir(AssetType.Textures, language); + var localTocDir = Path.Combine(trueTextureDir, "Texture_TOC.json"); + + if (!File.Exists(localTocDir)) + File.WriteAllText(localTocDir, "{}"); + + var localTocContent = File.ReadAllText(localTocDir); + var localToc = System.Text.Json.JsonSerializer.Deserialize>(localTocContent); + + var basePath = Core.ModDirectory; + + if (!Core.Instance.ConfigUseLocal.Value) + { + var textureTocRequest = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Textures/Texture_TOC.json" + ) + .Result; + + if (textureTocRequest != null) + { + var textureToc = + JsonConvert.DeserializeObject>(textureTocRequest); + + List toDownload = new(); + + foreach (var pair in textureToc) + { + if (!localToc.TryGetValue(pair.Key, out var value)) + { + toDownload.Add(pair.Key); + continue; + } + + if (pair.Value != value) + toDownload.Add(pair.Key); + + if (!File.Exists(Path.Combine(basePath, pair.Key))) + toDownload.Add(pair.Key); + } + + var toWriteText = SerializeWithIndentation(textureToc); + File.WriteAllText(localTocDir, toWriteText); + + foreach (var path in toDownload) + { + var downloadPath = Path.Combine(basePath, path); + + const string BaseUrl = + "https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; + + var url = $"{BaseUrl}{path}"; + + var imageData = Utils.GetByteDataFromWeb(url).Result; + + if (imageData == null) + continue; + + var fileName = Path.GetFileName(downloadPath); + _ = Utils.LoadImage(imageData); + TextureStore.SpriteDict[fileName] = imageData; + + if (!Directory.Exists(Path.GetDirectoryName(downloadPath))) + Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); + + File.WriteAllBytes(downloadPath, imageData); + } + } + } + + foreach (var path in Directory.EnumerateFiles(textureDir, "*.png", SearchOption.AllDirectories) + .Where( + p => (!p.Contains("[Custom Textures]", StringComparison.OrdinalIgnoreCase) || + !Core.Instance.ConfigDefaultTextures.Value) && + (localToc.ContainsKey(p.Replace(basePath + "\\", "").Replace("\\", "/")) || + SerializeWithIndentation(localToc) == "{}") + )) + { + if (ModFeatures.IsDebug) + Log.LogDebug("Loading File (Sprite): " + path); + + var imageData = File.ReadAllBytes(path); + _ = Utils.LoadImage(imageData); + TextureStore.SpriteDict[Path.GetFileNameWithoutExtension(path)] = imageData; + } + } + + catch (Exception e) + { + Log.LogError("Error loading Texture."); + Log.LogError(e.GetType() + " " + e.Message); + } + } + + internal static void LoadDefaultTextures() + { + if (!Core.Instance.ConfigDefaultTextures.Value) + return; + + var textureDefaultDir = Path.Combine( + Core.ModDirectory, + nameof(AssetType.Dumps), + "Default Textures [Do Not Remove]" + ); + + if (!Directory.Exists(textureDefaultDir)) + Directory.CreateDirectory(textureDefaultDir); + + try + { + var trueTextureDir = Path.Combine(Core.ModDirectory, "[Custom Textures]"); + var localTocDir = Path.Combine(trueTextureDir, "Default_TOC.json"); + + if (!File.Exists(localTocDir)) + File.WriteAllText(localTocDir, "{}"); + + var localTocContent = File.ReadAllText(localTocDir); + var localToc = System.Text.Json.JsonSerializer.Deserialize>(localTocContent); + + var basePath = Core.ModDirectory; + + if (!Core.Instance.ConfigUseLocal.Value) + { + var textureTocRequest = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/{Uri.EscapeDataString("[Custom Textures]")}/Default_TOC.json" + ) + .Result; + + if (textureTocRequest != null) + { + var textureToc = + JsonConvert.DeserializeObject>(textureTocRequest); + + List toDownload = new(); + + foreach (var pair in textureToc) + { + if (!localToc.TryGetValue(pair.Key, out var value)) + { + toDownload.Add(pair.Key); + continue; + } + + if (pair.Value != value) + toDownload.Add(pair.Key); + + if (!File.Exists(Path.Combine(basePath, pair.Key))) + toDownload.Add(pair.Key); + } + + var toWriteText = SerializeWithIndentation(textureToc); + File.WriteAllText(localTocDir, toWriteText); + + foreach (var path in toDownload) + { + var downloadPath = Path.Combine(basePath, path); + + const string BaseUrl = + "https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; + + var url = $"{BaseUrl}{path}"; + + var imageData = Utils.GetByteDataFromWeb(url).Result; + + if (imageData == null) + continue; + + var fileName = Path.GetFileName(downloadPath); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[fileName] = imageData; + + if (!Directory.Exists(Path.GetDirectoryName(downloadPath))) + Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); + + File.WriteAllBytes(downloadPath, imageData); + } + } + } + + foreach (var filepath in Directory.EnumerateFiles( + textureDefaultDir, + "*.png", + SearchOption.AllDirectories + )) + { + if (!localToc.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) && + SerializeWithIndentation(localToc) != "{}") + continue; + + var imageData = File.ReadAllBytes(filepath); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; + } + } + + catch (Exception e) + { + Log.LogError("Error loading Texture."); + Log.LogError(e.GetType() + " " + e.Message); + } + } + + internal static void LoadCustomTextures() + { + var texturePackDir = Path.Combine(Core.ModDirectory, "[Custom Textures]"); + + if (!Directory.Exists(texturePackDir)) + Directory.CreateDirectory(texturePackDir); + + try + { + var trueTextureDir = Path.Combine(Core.ModDirectory, "[Custom Textures]"); + var localTocDir = Path.Combine(trueTextureDir, "Custom_TOC.json"); + + if (!File.Exists(localTocDir)) + File.WriteAllText(localTocDir, "{}"); + + var localTocContent = File.ReadAllText(localTocDir); + var localToc = System.Text.Json.JsonSerializer.Deserialize>(localTocContent); + + var basePath = Core.ModDirectory; + + if (!Core.Instance.ConfigUseLocal.Value) + { + var textureTocRequest = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/{Uri.EscapeDataString("[Custom Textures]")}/Custom_TOC.json" + ) + .Result; + + if (textureTocRequest != null) + { + var textureToc = + JsonConvert.DeserializeObject>(textureTocRequest); + + List toDownload = new(); + + foreach (var pair in textureToc) + { + if (!localToc.TryGetValue(pair.Key, out var value) || pair.Value != value) + { + toDownload.Add(pair.Key); + continue; + } + + if (!File.Exists(Path.Combine(basePath, pair.Key))) + toDownload.Add(pair.Key); + } + + var toWriteText = SerializeWithIndentation(textureToc); + File.WriteAllText(localTocDir, toWriteText); + + foreach (var path in toDownload) + { + var downloadPath = Path.Combine(basePath, path); + + const string BaseUrl = + "https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/"; + + var url = $"{BaseUrl}{path}"; + + var imageData = Utils.GetByteDataFromWeb(url).Result; + + if (imageData == null) + continue; + + var fileName = Path.GetFileName(downloadPath); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[fileName] = imageData; + + if (!Directory.Exists(Path.GetDirectoryName(downloadPath))) + Directory.CreateDirectory(Path.GetDirectoryName(downloadPath)); + + File.WriteAllBytes(downloadPath, imageData); + } + } + } + + foreach (var filepath in Directory.EnumerateFiles(texturePackDir, "*.png", SearchOption.AllDirectories)) + { + if (!localToc.ContainsKey(filepath.Replace(basePath + "\\", "").Replace("\\", "/")) && + SerializeWithIndentation(localToc) != "{}") + continue; + + var imageData = File.ReadAllBytes(filepath); + _ = Utils.LoadImage(imageData); + TextureStore.TextureDict[Path.GetFileNameWithoutExtension(filepath)] = imageData; + } + } + + catch (Exception e) + { + Log.LogError("Error loading Texture."); + Log.LogError(e.GetType() + " " + e.Message); + } + } + + internal static void SaveStrings() + { + var stringDir = GetAssetDir(AssetType.Strings, ModFeatures.IsMultiLanguage ? Utils.Language : null); + + if (!Directory.Exists(stringDir)) + Directory.CreateDirectory(stringDir); + + // save regexs + + var translationStringRegex = SerializeWithIndentation(StringStore.TranslationStringRegex, 2); + + File.WriteAllText(Path.Combine(stringDir, "translation_regexs.json"), translationStringRegex); + + // save strings + + var translationString = SerializeWithIndentation(StringStore.TranslationString, 2); + + File.WriteAllText(Path.Combine(stringDir, "translation_strings.json"), translationString); + + // save iz tips + + var izTipCollectionString = SerializeWithIndentation(StringStore.IZLevelTipDictionary, 1, ' '); + + File.WriteAllText(Path.Combine(stringDir, "tips_iz.json"), izTipCollectionString); + + // save fs tips + + var fsLevelTipDictionary = SerializeWithIndentation(StringStore.FSLevelTipDictionary); + + File.WriteAllText(Path.Combine(stringDir, "tips_fs.json"), fsLevelTipDictionary); + + // save changelog + + if (NoticePauseMenu_Patch.ChangelogText != "") + File.WriteAllText(Path.Combine(stringDir, "changelog.txt"), NoticePauseMenu_Patch.ChangelogText); + + // save abyss buffs + + //if(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData != new Dictionary()) + //{ + // string abyssBuffData = SerializeWithIndentation(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData, 2); + // File.WriteAllText(Path.Combine(stringDir, "abyss_buffs.json"), abyssBuffData); + //} + + // save almanacs + + var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + + if (AlmanacPlantMenu_Patch.AlmanacJson != "") + File.WriteAllText( + Path.Combine(almanacDir, "LawnStringsTranslate.json"), + AlmanacPlantMenu_Patch.AlmanacJson + ); + + if (AlmanacZombieMenu_Patch.AlmanacJson != "") + File.WriteAllText( + Path.Combine(almanacDir, "ZombieStringsTranslate.json"), + AlmanacZombieMenu_Patch.AlmanacJson + ); + + if (AlmanacSelectMenu_Patch.DetailStrings == new Dictionary()) + return; + + var detailStrings = SerializeWithIndentation(AlmanacSelectMenu_Patch.DetailStrings); + + File.WriteAllText(Path.Combine(almanacDir, "DetailStringsTranslate.json"), detailStrings); + } + + public static string SerializeWithIndentation(T value, int size = 4, char indentChar = ' ') + { + var stringWriter = new StringWriter(); + + using (JsonTextWriter writer = new(stringWriter)) + { + writer.Formatting = Formatting.Indented; + writer.Indentation = size; + writer.IndentChar = indentChar; + + Newtonsoft.Json.JsonSerializer serializer = new(); + serializer.Serialize(writer, value, typeof(T)); + } + + return stringWriter.ToString(); + } + + public static void DumpJson() + { + var dumpDir = GetAssetDir(AssetType.Dumps); + + if (!Directory.Exists(dumpDir)) + Directory.CreateDirectory(dumpDir); + + var lawnStrings = Resources.Load("LawnStrings").text; + var zombieStrings = Resources.Load("ZombieStrings").text; + //string AbyssBuffData = Resources.Load("AbyssBuffData").text; + File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), lawnStrings); + File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), zombieStrings); + //File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData); + + // Dump IZ tips. + var (_, izLevelDataDump) = DumpIZStrings(); + + File.WriteAllText( + Path.Combine(dumpDir, "tips_iz.json"), + System.Text.Json.JsonSerializer.Serialize( + izLevelDataDump, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + // Dump fusion showcase tips. + var (_, fusionShowcaseDataDump) = DumpFSStrings(); + + File.WriteAllText( + Path.Combine(dumpDir, "tips_fs.json"), + System.Text.Json.JsonSerializer.Serialize( + fusionShowcaseDataDump, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + // Dump almanac mechanics. + var (_, detailStrings) = DumpDetailStrings(); + + File.WriteAllText( + Path.Combine(dumpDir, "DetailStrings.json"), + System.Text.Json.JsonSerializer.Serialize( + detailStrings, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + } + + public static (Il2CppArrayBase, Dictionary) DumpIZStrings() + { + var izLevelData = Resources.LoadAll("izleveldata"); + var izLevelDataDump = new Dictionary(); + + foreach (var level in izLevelData) + { + var data = level.text; + var levelData = JsonUtility.FromJson(data); + + if (levelData.tips != null) + izLevelDataDump.Add(level.name, levelData.tips); + } + + return (izLevelData, izLevelDataDump); + } + + public static (Il2CppArrayBase, Dictionary) DumpFSStrings() + { + var fusionShowcaseData = Resources.LoadAll("leveldata/explore"); + var fusionShowcaseDataDump = new Dictionary(); + + foreach (var level in fusionShowcaseData) + { + var data = level.text; + var levelData = JsonUtility.FromJson(data); + + if (levelData.tips != null) + fusionShowcaseDataDump.Add(level.name, levelData.tips); + } + + return (fusionShowcaseData, fusionShowcaseDataDump); + } + + public static (Il2CppAlmanacDataClass, Dictionary) DumpDetailStrings() + { + var detailStringsData = Resources.Load("detailstrings").text; + var detailStrings = JsonUtility.FromJson(detailStringsData); + Dictionary detailStringsDump = new(); + + foreach (var detailString in detailStrings.details) + detailStringsDump[detailString.title] = detailString.text; + + return (detailStrings, detailStringsDump); + } + + public static void DumpUntranslatedStrings(string text) + { + Debug.Assert(ModFeatures.IsDebug, nameof(ModFeatures.IsDebug)); + Log.LogDebug($"Untranslated String: {text}"); + var dumpDir = GetAssetDir(AssetType.Dumps); + var jsonFile = Path.Combine(dumpDir, "UntranslatedStrings.json"); + + if (!Directory.Exists(dumpDir)) + Directory.CreateDirectory(dumpDir); + + if (!File.Exists(jsonFile)) + File.WriteAllText(jsonFile, "{}"); // Initialize empty JSON object + + var json = File.ReadAllText(jsonFile); + var untranslatedStrings = System.Text.Json.JsonSerializer.Deserialize>(json); + + if (!untranslatedStrings.TryAdd(text, text)) + return; + + JsonSerializerOptions options = new() + { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + WriteIndented = true, + }; + + File.WriteAllText(jsonFile, System.Text.Json.JsonSerializer.Serialize(untranslatedStrings, options)); + } + + internal static void LoadLanguage() + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + + try + { + // Load the language preference as a string and parse it into the enum + var languageName = Core.Instance.ConfigLanguage.Value; + + if (Enum.TryParse(languageName, out Utils.LanguageEnum loadedLanguage)) + Utils.Language = loadedLanguage; + else + { + Log.LogWarning($"Invalid language '{languageName}' found in preferences. Falling back to English."); + Utils.Language = Utils.LanguageEnum.English; // Default fallback + } + + Log.LogWarning($"Loaded language {languageName}"); + } + catch (Exception e) + { + Log.LogError("Error loading language setting."); + Log.LogError($"{e.GetType()} {e.Message}"); + } + + Log.LogInfo($"Language has been loaded: {Utils.Language}"); + } + + internal static void SaveLanguage() + { + Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + + try + { + // Save the current language as a string + Core.Instance.ConfigLanguage.Value = Utils.Language.ToString(); + + // Ensure changes are written to the config file + // MelonPreferences.Save(); + } + catch (Exception e) + { + Log.LogError("Error saving language setting."); + Log.LogError($"{e.GetType()} {e.Message}"); + } + // Log.LogInfo($"Language has been saved: {Utils.Language}"); + } +} diff --git a/Source/FontHandler.cs b/Source/FontHandler.cs new file mode 100644 index 0000000..dd730fc --- /dev/null +++ b/Source/FontHandler.cs @@ -0,0 +1,43 @@ +namespace PvZ_Fusion_Translator; + +public static class FontHandler +{ + public static Font LoadFont(string pathFromModFolder, bool throwException) + { + var fontFilePath = Path.Combine(Core.ModDirectory, pathFromModFolder); + + if (!File.Exists(fontFilePath)) + { + if (throwException) + Log.LogWarning($"Font not found at path: '{fontFilePath}'."); + + return null; + } + + Font font = new(); + Font.Internal_CreateFontFromPath(font, fontFilePath); + return font; + } + + public static TMP_FontAsset ConvertToTMP(this Font font) + { + var fontAsset = TMP_FontAsset.CreateFontAsset(font); + + if (fontAsset != null) + return fontAsset; + + Log.LogWarning($"Failed to create TMP_FontAsset from font '{font.name}'."); + return null; + } + + public static TMP_FontAsset LoadTMPFont(string pathFromModFolder, bool throwException) + { + var font = LoadFont(pathFromModFolder, throwException); + + if (!font) + return null; + + var fontAsset = font.ConvertToTMP(); + return fontAsset; + } +} diff --git a/Source/Log.cs b/Source/Log.cs new file mode 100644 index 0000000..04bd92f --- /dev/null +++ b/Source/Log.cs @@ -0,0 +1,60 @@ +// ReSharper disable once RedundantUsingDirective +using System.Drawing; + +namespace PvZ_Fusion_Translator; + +internal static class Log +{ +#if MELONLOADER + public static void LogDebug(object txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); + + public static void LogDebug(string txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); + + public static void LogDebug(string txt, params object[] args) => + Melon.Logger.Msg(ColorARGB.Gray, txt, args); + + public static void LogInfo(object txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); + + public static void LogInfo(string txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); + + public static void LogInfo(string txt, params object[] args) => + Melon.Logger.Msg(ColorARGB.Blue, txt, args); + + public static void LogWarning(object txt) => Melon.Logger.Warning(txt); + + public static void LogWarning(string txt) => Melon.Logger.Warning(txt); + + public static void LogWarning(string txt, params object[] args) => Melon.Logger.Warning(txt, args); + + public static void LogError(object txt) => Melon.Logger.Error(txt); + + public static void LogError(string txt) => Melon.Logger.Error(txt); + + public static void LogError(string txt, params object[] args) => Melon.Logger.Error(txt, args); +#elif BEPINEX + + public static void LogDebug(object txt) => Core.Log.LogDebug(txt); + + public static void LogDebug(string txt) => Core.Log.LogDebug(txt); + + public static void LogDebug(string txt, params object[] args) => Core.Log.LogDebug(string.Format(txt, args)); + + public static void LogInfo(object txt) => Core.Log.LogInfo(txt); + + public static void LogInfo(string txt) => Core.Log.LogInfo(txt); + + public static void LogInfo(string txt, params object[] args) => Core.Log.LogInfo(string.Format(txt, args)); + + public static void LogWarning(object txt) => Core.Log.LogWarning(txt); + + public static void LogWarning(string txt) => Core.Log.LogWarning(txt); + + public static void LogWarning(string txt, params object[] args) => Core.Log.LogWarning(string.Format(txt, args)); + + public static void LogError(object txt) => Core.Log.LogError(txt); + + public static void LogError(string txt) => Core.Log.LogError(txt); + + public static void LogError(string txt, params object[] args) => Core.Log.LogError(string.Format(txt, args)); +#endif +} diff --git a/Source/ModFeatures.cs b/Source/ModFeatures.cs new file mode 100644 index 0000000..2b7335e --- /dev/null +++ b/Source/ModFeatures.cs @@ -0,0 +1,97 @@ +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator; + +public static class ModFeatures +{ + public enum ModType + { + ReloadStrings, ReloadTextures, ExportLevelStrings, + } + + private sealed class ModFeature(string name, ModType modType, KeyCode keyCode, bool defaultValue = false) + { + // ReSharper disable once UnusedMember.Local + public string Name { get; private set; } = name; + + // ReSharper disable once MemberCanBePrivate.Local + public ModType ModType { get; } = modType; + + public KeyCode KeyCode { get; } = keyCode; + + // ReSharper disable once UnusedMember.Local + public bool IsActive { get; set; } = defaultValue; + + public void ToggleFeature() + { + switch (ModType) + { + case ModType.ReloadStrings: + StringStore.Reload(); + Core.ShowToast("Strings Reloaded!"); + return; + case ModType.ReloadTextures: + TextureStore.Reload(); + Core.ShowToast("Textures Reloaded!"); + return; + case ModType.ExportLevelStrings: + var customMenu = UnityEngine.Object.FindObjectOfType(); + + if (!customMenu) + return; + + if (!customMenu.isActiveAndEnabled) + return; + + Patches.Modes.Super_Editor.GameLevel.LevelManager_Patch + .ExportLevelStrings(customMenu.LevelData); + + Core.ShowToast("Dumped level strings!"); + return; + default: return; + } + } + } + + public static bool IsDebug { get; } = IsDefined("PVZ_FUSION_TRANSLATOR_DEBUG"); + + public static bool IsTesting { get; } = IsDefined("PVZ_FUSION_TRANSLATOR_TESTING"); + + public static bool IsAudioTesting { get; } = IsDefined("PVZ_FUSION_TRANSLATOR_AUDIO_TESTING"); + + public static bool IsMultiLanguage { get; } = IsDefined("PVZ_FUSION_TRANSLATOR_MULTI_LANGUAGE", true); + + private static readonly Dictionary s_featureLists = new() + { + { ModType.ReloadStrings, new("Reload Strings", ModType.ReloadStrings, KeyCode.Home, true) }, + { ModType.ReloadTextures, new("Reload Textures", ModType.ReloadTextures, KeyCode.End, true) }, + { + ModType.ExportLevelStrings, + new("Export Level Strings", ModType.ExportLevelStrings, KeyCode.N, true) + }, + }; + + public static void ToggleFeature(ModType modType) + { + if (s_featureLists.TryGetValue(modType, out var list)) + list.ToggleFeature(); + } + + public static void OnLateUpdate() + { + foreach (var (_, feature) in s_featureLists) + if (feature.KeyCode != KeyCode.None && Enum.IsDefined(feature.KeyCode)) + if (Input.GetKeyDown(feature.KeyCode)) + feature.ToggleFeature(); + } + + private static bool IsDefined(string env, bool fallback = false) + { + var ret = + Environment.GetEnvironmentVariable(env)?.ToUpperInvariant() is not "FALSE" and not "0" and var value && + (!string.IsNullOrWhiteSpace(value) || fallback); + + Log.LogInfo($"The feature '{env}' is {(ret ? "enabled" : "disabled")}."); + return ret; + } +} diff --git a/Source/Patches/BaseTextObjects/InGameText_Patch.cs b/Source/Patches/BaseTextObjects/InGameText_Patch.cs new file mode 100644 index 0000000..695c26a --- /dev/null +++ b/Source/Patches/BaseTextObjects/InGameText_Patch.cs @@ -0,0 +1,369 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.Modes.Odyssey; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.BaseTextObjects; + +[HarmonyPatch(typeof(InGameText))] +public static class InGameText_Patch +{ +#pragma warning disable CA2211 + public static string CurrentText = ""; +#pragma warning restore CA2211 + [HarmonyPatch(nameof(InGameText.ShowText)), HarmonyPostfix] + public static void ShowText(InGameText __instance) => TranslateInGameText(__instance); + + [HarmonyPatch(nameof(InGameText.DebugWarning)), HarmonyPostfix] + public static void DebugWarning(InGameText __instance) => TranslateInGameText(__instance); + + [HarmonyPatch(nameof(InGameText.Update)), HarmonyPostfix] + public static void Update(InGameText __instance) => TranslateInGameText(__instance); + + public static void TranslateInGameText(InGameText __instance) + { + TextMeshProUGUI txt = null; + + if (__instance.textMesh == null || __instance.textHead == null) + { + if (__instance.TryGetComponent(out TextMeshProUGUI selfTxt)) + txt = selfTxt; + } + else + txt = __instance.textMesh; + + if (txt == null) + return; + + if (!txt.gameObject.active) + return; + + TranslateInGameTextMesh(txt); + } + + public static void TranslateInGameTextMesh(TextMeshProUGUI txt) + { + if (txt == null) + return; + + if (txt.text == CurrentText) + return; + + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var originalText = txt.text; + var lockedPlantMatch = CheckLockedMessage(originalText); + var travelMatch = TravelMgr_Patch.MatchTravelBuff(originalText); + var godsGachaCheck = CheckGodsGachaPopup(originalText); + var godsGachaMatch = ""; + var superEditorPlantMatch = CheckSuperEditorPopup(originalText); + var customLevelRegexMatch = CheckCustomLevelRegex(originalText); + var qualityCheckMatch = CheckQualityUpgrade(originalText); + + godsGachaMatch = godsGachaCheck switch + { + 1 or 2 or 3 => TranslateGodsGachaPopup(originalText, godsGachaCheck), + _ => godsGachaMatch, + }; + + if (godsGachaMatch != "") + { + txt.text = godsGachaMatch; + + if (txt.gameObject.name.Contains("main")) + { + originalText = txt.text; + var shadowText = txt.transform.parent.Find("Text_shadow"); + + if (shadowText != null) + shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); + } + } + else if (travelMatch != "") + { + txt.text = TravelMgr_Patch.AddBuffName(travelMatch); + + if (txt.gameObject.name.Contains("main")) + { + originalText = txt.text; + var shadowText = txt.transform.parent.Find("Text_shadow"); + + if (shadowText != null) + shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); + } + } + else if (qualityCheckMatch != "") + txt.text = qualityCheckMatch; + else if (superEditorPlantMatch != "") + txt.text = superEditorPlantMatch; + else if (lockedPlantMatch != "") + txt.text = lockedPlantMatch; + else if (customLevelRegexMatch != "") + txt.text = customLevelRegexMatch; + else if (Regex.Match(txt.text, "(]*>.*?)", RegexOptions.Singleline).Success && + !StringStore.TranslationString.ContainsKey(txt.text) && + !StringStore.FSTipCollectionString.ContainsKey(txt.text) && + !StringStore.IZTipCollectionString.ContainsKey(txt.text) && + !StringStore.CustomLevelString.ContainsKey(txt.text)) + { + txt.text = StringStore.TranslateColorText(txt.text, true); + + if (txt.gameObject.name.Contains("main")) + { + originalText = txt.text; + var shadowText = txt.transform.parent.Find("Text_shadow"); + + if (shadowText != null) + shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); + } + } + else + { + txt.text = StringStore.TranslateText(txt.text, true); + + if (txt.gameObject.name.Contains("main")) + { + originalText = txt.text; + var shadowText = txt.transform.parent.Find("Text_shadow"); + + if (shadowText != null) + shadowText.GetComponent().text = Utils.RemoveColorTags(originalText); + } + } + + txt.font = fontAsset; + + CurrentText = txt.text; + } + + public const string NamePlantedPattern = "种植了:([^\\s]+)"; + public const string NameUpgradedPattern = @"升级成功:([^\s]+) -> ([^\s]+)"; + public const string NameAlreadyPlantedPattern = "场上已经有一个([^\\s]+)了"; + public const string UpgradePathRemovedPattern = "已移除路线:([^\\s]+)"; + + public const string LockedPlantPattern = @"^([\s\S]+)\+([\S]+)$"; + public const string MultiLockedPlantPattern = @"^或 ([\s\S]+)\+([\S]+)$"; + + public const string QualityChangePattern = + """ + 诸神注视着你,并选中了一个他们喜欢的词条 + 植物【([\S]+)】的词条【强化:([\S]+)】获得品质升级 + 当前品质:([\S]+) + """; + + public static readonly Dictionary FallbackFStrs = new() + { + { NamePlantedPattern, "{0} planted!" }, + { NameUpgradedPattern, "{0} successfully upgraded to {1}!" }, + { NameAlreadyPlantedPattern, "{0} already exists on the lawn!" }, + { UpgradePathRemovedPattern, "Upgrade Path removed for {0}" }, + { @"([^\s]+)\((\d+)\)", "{0}({1})" }, + { LockedPlantPattern, "{0} + {1}" }, + { MultiLockedPlantPattern, "or {0} + {1}" }, + { + QualityChangePattern, + """ + The gods are watching you, and they have granted you an upgrade! + The {1} upgrade for {0} has been upgraded. + Current Quality: {2} + """ + }, + }; + + public static int CheckGodsGachaPopup(string originalText) + { + var res = 0; + + if (Regex.IsMatch(originalText, NamePlantedPattern)) + res = 1; + else if (Regex.IsMatch(originalText, NameUpgradedPattern)) + res = 2; + else if (Regex.IsMatch(originalText, NameAlreadyPlantedPattern)) + res = 3; + + return res; + } + + public static string TranslateGodsGachaPopup(string originalText, int type) => + type switch + { + 1 => StringStore.TranslateText(originalText, NamePlantedPattern), + 2 => StringStore.TranslateText(originalText, NameUpgradedPattern), + 3 => StringStore.TranslateText(originalText, NameAlreadyPlantedPattern), + _ => originalText, + }; + + public static string TranslatePlantNameParts(string originalText, string pattern) + { + var res = ""; + var match = Regex.Match(originalText, pattern); + + if (!match.Success) + return res; + + var groups = match.Groups; + + var fStr = StringStore.TranslationStringRegex.TryGetValue(pattern, out var value) + ? value + : FallbackFStrs[pattern]; + + List dynamicParts = []; + + for (var i = 1; i < groups.Count; i++) + { + var group = groups[i].Value; + var plantName = Utils.GetPlantNameFromAlmanac(group); + dynamicParts.Add(plantName); + } + + res = string.Format(fStr, [..dynamicParts]); + + return res; + } + + public static string TranslatePlantNameParts(string originalText, string pattern, string fallback) + { + var res = ""; + var match = Regex.Match(originalText, pattern); + + if (!match.Success) + return res; + + var groups = match.Groups; + + var fStr = StringStore.TranslationStringRegex.GetValueOrDefault(pattern, fallback); + + List dynamicParts = []; + + for (var i = 1; i < groups.Count; i++) + { + var group = groups[i].Value; + var plantName = Utils.GetPlantNameFromAlmanac(group); + + if (plantName == "") + plantName = StringStore.TranslateText(group); + + dynamicParts.Add(plantName); + } + + res = string.Format(fStr, [..dynamicParts]); + + return res; + } + + public static string CheckSuperEditorPopup(string originalText) + { + var res = ""; + + if (Regex.IsMatch(originalText, UpgradePathRemovedPattern)) + res = StringStore.TranslateText(originalText, UpgradePathRemovedPattern); + else if (Regex.IsMatch(originalText, "当前全部基础植物:(.*)")) + { + const string Pattern = "当前全部基础植物:(.*)"; + var match = Regex.Match(originalText, Pattern); + + if (!match.Success) + return res; + + var groups = match.Groups; + var plantNameGroup = groups[1].Value; + var plantNames = plantNameGroup.Split(" "); + var plantRes = ""; + const string ShortPattern = @"([^\s]+)\((\d+)\)"; + + foreach (var shortMatch in plantNames + .Select(plantName => Regex.Match(plantName, ShortPattern)) + .Where(shortMatch => shortMatch.Success)) + { + var fStr = StringStore.TranslationStringRegex.TryGetValue(ShortPattern, out var value) + ? value + : FallbackFStrs[ShortPattern]; + + var shortRes = string.Format( + fStr, + [Utils.GetPlantNameFromAlmanac(shortMatch.Groups[1].Value), shortMatch.Groups[2].Value] + ); + + plantRes += shortRes + " "; + } + + res = StringStore.TranslateText("当前全部基础植物:" + plantRes); + } + + return res; + } + + public static string CheckLockedMessage(string originalText) + { + var res = ""; + + var lockedPlantRegex = new Regex(LockedPlantPattern); + // var multiLockedPlantRegex = new Regex(MultiLockedPlantPattern); + + if (!lockedPlantRegex.IsMatch(originalText)) + return res; + + if (originalText.Contains('\n')) + { + var lines = originalText.Split("\n"); + + if (!lockedPlantRegex.IsMatch(lines[0])) + return res; + + var firstLine = lines[0]; + var match = lockedPlantRegex.Match(firstLine); + var groups = match.Groups; + + if (Utils.PlantIndiceString.ContainsKey(groups[1].Value) && + Utils.PlantIndiceString.ContainsKey(groups[2].Value)) + { + firstLine = StringStore.TranslateText(firstLine, LockedPlantPattern); + var translatedLines = new List { firstLine }; + + for (var i = 1; i < lines.Length; i++) + { + var nextLine = lines[i]; + var translatedNextLine = StringStore.TranslateText(nextLine, MultiLockedPlantPattern); + translatedLines.Add(translatedNextLine); + } + + res = string.Join("\n", translatedLines); + } + else + return ""; + } + else + { + if (!lockedPlantRegex.IsMatch(originalText)) + return res; + + var match = lockedPlantRegex.Match(originalText); + var groups = match.Groups; + + if (Utils.PlantIndiceString.ContainsKey(groups[1].Value) && + Utils.PlantIndiceString.ContainsKey(groups[2].Value)) + res = StringStore.TranslateText(originalText, LockedPlantPattern); + else + return ""; + } + + return res; + } + + public static string CheckCustomLevelRegex(string originalText) => + StringStore.TranslationStringRegex.All(p => !StringStore.TestRegex(originalText, p.Key)) && + StringStore.CustomLevelStringRegex.FirstOrDefault(p => StringStore.TestRegex(originalText, p.Key)) is + { Key: var key } + ? StringStore.TranslateText(originalText, key) + : null; + + public static string CheckQualityUpgrade(string originalText) + { + var res = ""; + + if (Regex.IsMatch(originalText, QualityChangePattern)) + res = StringStore.TranslateText(originalText, QualityChangePattern); + + return res; + } +} diff --git a/Source/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs b/Source/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs new file mode 100644 index 0000000..0d8ca89 --- /dev/null +++ b/Source/Patches/BaseTextObjects/TMP_Dropdown_Patch.cs @@ -0,0 +1,49 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +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) + { + var txt = __instance.captionText; + + txt.text = StringStore.TranslationString.ContainsKey(txt.text + "_code") + ? StringStore.TranslateText(txt.text + "_code") + : StringStore.TranslateText(txt.text); + } + + if (__instance.itemText) + { + var txt = __instance.itemText; + + txt.text = StringStore.TranslationString.ContainsKey(txt.text + "_code") + ? StringStore.TranslateText(txt.text + "_code") + : StringStore.TranslateText(txt.text); + } + + foreach (var dropdownItem in __instance.m_Items) + { + var 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 (var txt in __instance.GetComponentsInChildren(true)) + txt.text = StringStore.TranslationString.ContainsKey(txt.text + "_code") + ? StringStore.TranslateText(txt.text + "_code") + : StringStore.TranslateText(txt.text); + } +} diff --git a/Source/Patches/BaseTextObjects/TMP_InputField_Patch.cs b/Source/Patches/BaseTextObjects/TMP_InputField_Patch.cs new file mode 100644 index 0000000..dead5d1 --- /dev/null +++ b/Source/Patches/BaseTextObjects/TMP_InputField_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.BaseTextObjects; + +[HarmonyPatch(typeof(TMP_InputField))] +public static class TMP_InputField_Patch +{ + [HarmonyPatch(nameof(TMP_InputField.OnEnable)), HarmonyPostfix] + public static void OnEnable(TMP_InputField __instance) + { + if (string.IsNullOrEmpty(__instance.text)) + return; + + var text = StringStore.TranslateText(__instance.text); + __instance.m_Text = StringStore.TranslateText(text); + __instance.m_OriginalText = StringStore.TranslateText(text); + __instance.m_TextComponent.text = StringStore.TranslateText(text); + } +} diff --git a/Source/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs b/Source/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs new file mode 100644 index 0000000..2351352 --- /dev/null +++ b/Source/Patches/BaseTextObjects/TextMeshProUGUI_Patch.cs @@ -0,0 +1,95 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.Patches.Managers; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.BaseTextObjects; + +[HarmonyPatch(typeof(TextMeshProUGUI))] +public static class TextMeshProUGUI_Patch +{ + [HarmonyPatch(nameof(TextMeshProUGUI.OnEnable)), HarmonyPostfix] + private static void OnEnable(TextMeshProUGUI __instance) + { + if (string.IsNullOrEmpty(__instance.text)) + return; + + __instance.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + if (!Utils.CheckForUntranslatedText(__instance.text) && !__instance.text.Contains('_')) + return; + + if (__instance.transform.parent != null) + { + if (__instance.transform.parent.name.Contains("DrawCardsText")) + return; + + if (__instance.transform.parent.parent != null) + if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) + return; + } + + __instance = StringStore.TranslateText(__instance); + __instance.autoSizeTextContainer = false; + + if (__instance.name.StartsWith("LevelName")) + { + __instance.text = __instance.text.Replace("\n", " "); + + if (__instance.name is "LevelName2" or "LevelName3" && + !(__instance.gameObject.transform.parent.name.Contains("Difficulty") || + __instance.gameObject.name.Contains("Difficulty"))) + TowerManager_Patch.UpdatedText.Add(__instance.transform); + } + + if (__instance.transform.parent == null || !__instance.transform.parent.name.StartsWith("Window")) + return; + + __instance.fontSizeMin = 10; + __instance.fontSize = 12; + // __instance.ForceMeshUpdate(); + } +#if false + [HarmonyPatch(nameof(TextMeshProUGUI.Awake)), HarmonyPostfix] + private static void Awake(TextMeshProUGUI __instance) + { + if (string.IsNullOrEmpty(__instance.text)) + return; + + if (__instance.transform.parent.parent != null) + if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu")) + return; + + __instance = StringStore.TranslateText(__instance); + __instance.autoSizeTextContainer = false; + + if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) + { + __instance.fontSizeMin = 10; + __instance.fontSize = 12; + } + + if (__instance.text == "Полный Хаос" && + __instance.transform.parent.parent.Find("Image").GetComponent().activeSprite.name == + "Present") + __instance.text += "\nБесконечно"; + + // __instance.ForceMeshUpdate(); + } +#endif +} +#if false +[HarmonyPatch(typeof(TMP_SubMeshUI))] +public static class TMP_SubMeshUI_Patch +{ + [HarmonyPatch(nameof(TMP_SubMeshUI.OnEnable)), HarmonyPostfix] + public static void OnEnable(TMP_SubMeshUI __instance) + { + if (string.IsNullOrEmpty(__instance.textComponent.text)) + return; + + var text = StringStore.TranslateText(__instance.textComponent.text); + __instance.m_TextComponent.text = StringStore.TranslateText(text); + __instance.textComponent.text = StringStore.TranslateText(text); + } +} +#endif diff --git a/Source/Patches/BaseTextObjects/TextMeshPro_Patch.cs b/Source/Patches/BaseTextObjects/TextMeshPro_Patch.cs new file mode 100644 index 0000000..90e1d25 --- /dev/null +++ b/Source/Patches/BaseTextObjects/TextMeshPro_Patch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.BaseTextObjects; + +[HarmonyPatch(typeof(TextMeshPro))] +public static class TextMeshPro_Patch +{ + [HarmonyPatch(nameof(TextMeshPro.OnEnable)), HarmonyPostfix] + private static void OnEnable(TextMeshPro __instance) + { + if (string.IsNullOrEmpty(__instance.text)) + return; + + if (__instance.transform.parent.name.Contains("DrawCardsText")) + return; + + if (__instance.transform.parent.name.StartsWith("AlmanacHelp") || + __instance.transform.parent.name.StartsWith("CardBank")) + { + __instance = StringStore.TranslateText(__instance); + __instance.autoSizeTextContainer = false; + return; + } + + if (__instance.transform.name.Contains("AlmanacZombie") || + __instance.transform.name.Contains("AlmanacPlant") || + __instance.transform.name.Contains("Name") || + __instance.transform.name.Contains("Tips") || + __instance.transform.parent.name.Contains("Signboard") || + __instance.transform.parent.name.Contains("text")) + return; + + __instance = StringStore.TranslateText(__instance); + __instance.autoSizeTextContainer = true; + } +} diff --git a/Source/Patches/GameObjects/AlmanacBuffMenu_Patch.cs b/Source/Patches/GameObjects/AlmanacBuffMenu_Patch.cs new file mode 100644 index 0000000..82a0eb3 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacBuffMenu_Patch.cs @@ -0,0 +1,98 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Drawing; +using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacBuffMenu))] +public static class AlmanacBuffMenu_Patch +{ + [HarmonyPatch(nameof(AlmanacBuffMenu.Awake)), HarmonyPostfix] + public static void Post_Awake(AlmanacBuffMenu __instance) + { + foreach (var cardUI in __instance.cards) + { + var cardInfo = __instance.cardInfos[cardUI]; + var buffData = FindBuffData(cardInfo.description); + + if (buffData.Item1 == null || buffData.Item3 == null) + continue; + + cardUI.cost.text = buffData.Item4 ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; + } + + Post_OnCardClick(__instance); + } + + [HarmonyPatch(nameof(AlmanacBuffMenu.SetAllCards)), HarmonyPatch(nameof(AlmanacBuffMenu.Start)), + HarmonyPatch(nameof(AlmanacBuffMenu.InitMenu)), HarmonyPostfix] + public static void Post_SetAllCards(AlmanacBuffMenu __instance) + { + foreach (var cardUI in __instance.cards) + { + var cardInfo = __instance.cardInfos[cardUI]; + var buffData = FindBuffData(cardInfo.description); + + if (buffData.Item1 == null || buffData.Item3 == null) + continue; + + cardUI.cost.text = buffData.Item4 ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; + } + + Post_OnToolClick(__instance); + + Post_OnCardClick(__instance); + } + + [HarmonyPatch(nameof(AlmanacBuffMenu.OnToolClick)), HarmonyPostfix] + public static void Post_OnToolClick(AlmanacBuffMenu __instance) + { + foreach (var txt in __instance.toolButton.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } + + [HarmonyPatch(nameof(AlmanacBuffMenu.OnCardClick)), HarmonyPostfix] + public static void Post_OnCardClick(AlmanacBuffMenu __instance) + { + var buffData = FindBuffData(__instance.buffDescription.text); + + if (buffData.Item1 == null || buffData.Item3 == null) + return; + + __instance.buffTitle.text = buffData.Item4 ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}"; + __instance.buffTitle.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var buffFStr = StringStore.TranslationStringRegex.GetValueOrDefault("BUFF_NAME_FORMAT", "{0}: {1}"); + + var fBuffDesc = string.Format(buffFStr, buffData.Item1, buffData.Item3); + __instance.buffDescription.text = buffData.Item4 ? fBuffDesc + "\n\n" : buffData.Item3 + "\n\n"; + __instance.buffDescription.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var colorHex = StringStore.TranslationString.ContainsKey("MOD_ALMANAC_COL") + ? StringStore.TranslateText("MOD_ALMANAC_COL") + : "#000000"; + + var descriptionColor = ColorTranslator.FromHtml(colorHex); + + __instance.buffDescription.color = new( + descriptionColor.R / 255.0f, + descriptionColor.G / 255.0f, + descriptionColor.B / 255.0f + ); + + __instance.buffDescription.fontSizeMax = 18; + __instance.buffDescription.margin = new(8, 4, 25, 0); + + __instance.buffDescription.enableWordWrapping = true; + __instance.buffDescription.overflowMode = TextOverflowModes.ScrollRect; + + Canvas.ForceUpdateCanvases(); + __instance.buffDescription.ForceMeshUpdate(); + + Post_OnToolClick(__instance); + } +} diff --git a/Source/Patches/GameObjects/AlmanacCardUI_Patch.cs b/Source/Patches/GameObjects/AlmanacCardUI_Patch.cs new file mode 100644 index 0000000..c870a04 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacCardUI_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacCardUI))] +public static class AlmanacCardUI_Patch +{ + [HarmonyPatch(nameof(AlmanacCardUI.Awake)), HarmonyPostfix] + public static void Awake(AlmanacCardUI __instance) + { + if (!Utils.CheckForUntranslatedText(__instance.cost.text)) + return; + + __instance.cost.text = StringStore.TranslateText(__instance.cost.text); + } +#if false + [HarmonyPatch(nameof(AlmanacCardUI.OnPointerDown)), HarmonyPostfix] + public static void OnPointerDown(AlmanacCardUI __instance) + { + foreach (var almanacCardUI in __instance.menu.GetComponentsInChildren()) + Awake(almanacCardUI); + } +#endif +} diff --git a/Source/Patches/GameObjects/AlmanacPlantMenu_Patch.cs b/Source/Patches/GameObjects/AlmanacPlantMenu_Patch.cs new file mode 100644 index 0000000..b6d26c3 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacPlantMenu_Patch.cs @@ -0,0 +1,94 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacPlantMenu))] +public static class AlmanacPlantMenu_Patch +{ +#pragma warning disable CA2211 + public static string AlmanacJson = ""; +#pragma warning restore CA2211 + public static readonly Dictionary PlantInfoDict = new(); + + [HarmonyPatch(nameof(AlmanacPlantMenu.Awake)), HarmonyPostfix] + private static void Awake(AlmanacPlantMenu __instance) + { + var font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in from text in __instance.GetComponentsInChildren(true) + let isPlantName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background" + where text.gameObject.name != "Description" && !isPlantName && !text.gameObject.name.Contains("Cost") + select text) + { + text.text = StringStore.TranslateText(text.text); + text.font = font; + text.autoSizeTextContainer = true; + } + + foreach (var almanacCardUI in __instance.GetComponentsInChildren()) + AlmanacCardUI_Patch.Awake(almanacCardUI); + + // skin button resize + + var window = __instance.window; + var skinButton = window.skinButton; + // var skinTextObj = skinButton.transform.Find("text_1").gameObject; + skinButton.transform.localScale /= 1.75f; + skinButton.transform.localPosition = new(0.0f, 111.345f, 0.0f); + skinButton.transform.GetChild(1).Translate(new(-0.35f, 0)); + skinButton.transform.GetChild(2).Translate(new(0.35f, 0)); + } + + [HarmonyPatch(nameof(AlmanacPlantMenu.SearchChanged)), HarmonyPrefix] + public static bool SearchChanged(AlmanacPlantMenu __instance, ref TMP_InputField inputField) + { + var search = inputField.text; + + if (search == StringStore.TranslateText("搜索") || search == "") + return true; + + var currentLanguage = Utils.Language.ToString(); + // var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + // var path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); + _ = FontStore.LoadTMPFont(currentLanguage); + + var plantData = JsonUtility.FromJson(AlmanacJson); + Il2CppSystem.Collections.Generic.List searchedPlants = new(); + + foreach (var plantInfo in plantData.plants) + if (plantInfo.name.ToLower().Contains(search.ToLower()) || + $"{plantInfo.seedType}".ToLower().StartsWith(search.ToLower())) + searchedPlants.Add((PlantType)plantInfo.seedType); + + __instance.ShowPlants(searchedPlants); + return false; + } + + [HarmonyPatch(nameof(AlmanacPlantMenu.ShowPlants), typeof(Il2CppSystem.Func)), + HarmonyPostfix] + public static void ShowPlants(AlmanacPlantMenu __instance, ref Func condition) + { + foreach (var cardUI in __instance.cards) + AlmanacCardUI_Patch.Awake(cardUI); + } + + [HarmonyPatch(nameof(AlmanacPlantMenu.ClassicMix)), HarmonyPostfix] + public static void ClassicMix(AlmanacPlantMenu __instance) + { + foreach (var cardUI in __instance.cards) + AlmanacCardUI_Patch.Awake(cardUI); + } + + public static void LoadPlantAlmanacData(string json) + { + if (json == null) + return; + + AlmanacJson = json; + var plantData = JsonUtility.FromJson(AlmanacJson); + + foreach (var plantInfo in plantData.plants) + PlantInfoDict[plantInfo.seedType] = plantInfo; + } +} diff --git a/Source/Patches/GameObjects/AlmanacPlantWindow_Patch.cs b/Source/Patches/GameObjects/AlmanacPlantWindow_Patch.cs new file mode 100644 index 0000000..c401707 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacPlantWindow_Patch.cs @@ -0,0 +1,71 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacPlantWindow))] +public static class AlmanacPlantWindow_Patch +{ + [HarmonyPatch(nameof(AlmanacPlantWindow.UpdateText)), HarmonyPostfix] + private static void UpdateText(AlmanacPlantWindow __instance) + { + var currentLanguage = Utils.Language.ToString(); + // var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + // var path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); + // var moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); + + var hasAlmanacFont = false; + + if (FontStore.FontAssetDictSecondary.ContainsKey((currentLanguage + "_almanac").ToLower()) || + FontStore.FontAssetDictSecondary.ContainsKey(currentLanguage.ToLower())) + { + _ = FontStore.LoadTMPFontAlmanac(currentLanguage); + hasAlmanacFont = true; + } + + var fontAsset = hasAlmanacFont + ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) + : FontStore.LoadTMPFont(Utils.Language.ToString()); + + // var plantData = JsonUtility.FromJson(AlmanacPlantMenu_Patch.AlmanacJson); + + if (!AlmanacPlantMenu_Patch.PlantInfoDict.ContainsKey((int)__instance.currentPlantType)) + return; + + var plantInfo = AlmanacPlantMenu_Patch.PlantInfoDict[(int)__instance.currentPlantType]; + + foreach (var text in __instance.showedPlantName) + { + text.autoSizeTextContainer = false; + text.text = $"{Utils.RemoveSizeTags(plantInfo.name)} ({plantInfo.seedType})"; + text.font = fontAsset; + text.fontSizeMax = 21; + } + + var toTrim = Environment.NewLine.ToCharArray(); + + __instance.showedPlantIntroduce.text = + $""" + {Utils.RemoveSizeTags(plantInfo.info)} + + {Utils.RemoveSizeTags(plantInfo.introduce)} + + {Utils.RemoveSizeTags(plantInfo.cost).TrimStart(toTrim)} + + + """; + + __instance.showedPlantIntroduce.font = fontAsset; + __instance.showedPlantIntroduce.fontSizeMax = 21; + __instance.showedPlantIntroduce.margin = new(6, 2, 12, 0); + + __instance.showedPlantIntroduce.enableWordWrapping = true; + __instance.showedPlantIntroduce.overflowMode = TextOverflowModes.ScrollRect; + + Canvas.ForceUpdateCanvases(); + __instance.showedPlantIntroduce.ForceMeshUpdate(); + + var textHeight = __instance.showedPlantIntroduce.preferredHeight; + __instance.plantTextContent.sizeDelta = new(__instance.plantTextContent.sizeDelta.x, textHeight); + } +} diff --git a/Source/Patches/GameObjects/AlmanacSelectMenu_Patch.cs b/Source/Patches/GameObjects/AlmanacSelectMenu_Patch.cs new file mode 100644 index 0000000..60c384f --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacSelectMenu_Patch.cs @@ -0,0 +1,40 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacSelectMenu))] +public static class AlmanacSelectMenu_Patch +{ +#pragma warning disable CA2211 + public static Dictionary DetailStrings = new(); +#pragma warning restore CA2211 + public static readonly Dictionary DetailTranslateStrings = new(); + + [HarmonyPatch(nameof(AlmanacSelectMenu.Awake)), HarmonyPostfix] + public static void Awake(AlmanacSelectMenu __instance) + { + TranslateAlmanacSelectMenu(__instance); + + foreach (var uiButton in __instance.GetComponentsInChildren() + .Where(uiButton => uiButton.gameObject.name.Contains("Selection(Clone)"))) + uiButton.clickEvent.AddListener(new Action(() => { TranslateAlmanacSelectMenu(__instance); })); + } + + [HarmonyPatch(nameof(AlmanacSelectMenu.InitMenu)), HarmonyPostfix] + public static void InitMenu(AlmanacSelectMenu __instance) => TranslateAlmanacSelectMenu(__instance); + + public static void TranslateAlmanacSelectMenu(AlmanacSelectMenu __instance) + { + var font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = DetailTranslateStrings.TryGetValue(txt.text, out var s) + ? s + : StringStore.TranslateText(txt.text); + + txt.font = font; + } + } +} diff --git a/Source/Patches/GameObjects/AlmanacZombieMenu_Patch.cs b/Source/Patches/GameObjects/AlmanacZombieMenu_Patch.cs new file mode 100644 index 0000000..24b7ca0 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacZombieMenu_Patch.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacZombieMenu))] +public static class AlmanacZombieMenu_Patch +{ +#pragma warning disable CA2211 + public static string AlmanacJson = ""; +#pragma warning restore CA2211 + [HarmonyPatch(nameof(AlmanacZombieMenu.Start)), HarmonyPostfix] + private static void Start(AlmanacZombieMenu __instance) + { + var font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in from text in __instance.GetComponentsInChildren(true) + where !text.gameObject.name.Contains("Cost") + let isZombieName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background" + where text.gameObject.name != "Description" && !isZombieName + select text) + { + text.text = StringStore.TranslateText(text.text); + text.font = font; + text.autoSizeTextContainer = true; + } + } +} diff --git a/Source/Patches/GameObjects/AlmanacZombieWindow_Patch.cs b/Source/Patches/GameObjects/AlmanacZombieWindow_Patch.cs new file mode 100644 index 0000000..5a4efa6 --- /dev/null +++ b/Source/Patches/GameObjects/AlmanacZombieWindow_Patch.cs @@ -0,0 +1,80 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(AlmanacZombieWindow))] +public static class AlmanacZombieWindow_Patch +{ + [HarmonyPatch(nameof(AlmanacZombieWindow.UpdateText)), HarmonyPostfix] + private static void UpdateText(AlmanacZombieWindow __instance) + { + var currentLanguage = Utils.Language.ToString(); + // var almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + // var path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); + var hasAlmanacFont = false; + + if (FontStore.FontAssetDictSecondary.ContainsKey((currentLanguage + "_almanac").ToLower()) || + FontStore.FontAssetDictSecondary.ContainsKey(currentLanguage.ToLower())) + { + _ = FontStore.LoadTMPFontAlmanac(currentLanguage); + hasAlmanacFont = true; + } + + var fontAsset = hasAlmanacFont + ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) + : FontStore.LoadTMPFont(Utils.Language.ToString()); + + var zombieAlmanacData = JsonUtility.FromJson(AlmanacZombieMenu_Patch.AlmanacJson); + var zombieDataDic = ZombieDataManager.zombieDataDic; + + foreach (var zombieInfo in zombieAlmanacData.zombies) + if (zombieInfo.theZombieType == __instance.currentZombieType) + { + foreach (var text in __instance.showedZombieName) + { + text.autoSizeTextContainer = false; + text.text = $"{Utils.RemoveSizeTags(zombieInfo.name)} ({(int)zombieInfo.theZombieType})"; + text.font = fontAsset; + text.fontSizeMax = 21; + } + + var zombieData = zombieDataDic[__instance.currentZombieType]; + + var spawnInfo = ""; + + var spawnInfoFormat = + StringStore.TranslationStringRegex.GetValueOrDefault("出怪等级: (\\d+)\n出怪权重: (\\d+)"); + + if (spawnInfoFormat != null) + spawnInfo = string.Format(spawnInfoFormat, [zombieData.summonLevel, zombieData.summonWeight]) + + "\n\n"; + + __instance.showedZombieIntroduce.text = + $""" + {Utils.RemoveSizeTags(zombieInfo.info)} + + {spawnInfo}{Utils.RemoveSizeTags(zombieInfo.introduce)} + + + """; + + __instance.showedZombieIntroduce.font = fontAsset; + __instance.showedZombieIntroduce.fontSizeMax = 21; + __instance.showedZombieIntroduce.margin = new(3, 2, 12, 0); + + __instance.showedZombieIntroduce.enableWordWrapping = true; + __instance.showedZombieIntroduce.overflowMode = TextOverflowModes.ScrollRect; + + Canvas.ForceUpdateCanvases(); + __instance.showedZombieIntroduce.ForceMeshUpdate(); + + var textHeight = __instance.showedZombieIntroduce.preferredHeight; + + __instance.zombieTextContent.sizeDelta = new( + __instance.zombieTextContent.sizeDelta.x, + textHeight + ); + } + } +} diff --git a/Source/Patches/GameObjects/Almanac_Patch.cs b/Source/Patches/GameObjects/Almanac_Patch.cs new file mode 100644 index 0000000..d98ca71 --- /dev/null +++ b/Source/Patches/GameObjects/Almanac_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(Almanac))] +public static class Almanac_Patch +{ + [HarmonyPatch(nameof(Almanac.Awake)), HarmonyPostfix] + private static void Awake(Almanac __instance) => TranslateAlmanacMenu(__instance); +#if false + [HarmonyPatch(nameof(Almanac.OldAlmanac)), HarmonyPostfix] + private static void OldAlmanac(Almanac __instance) => TranslateAlmanacMenu(__instance); +#endif + [HarmonyPatch(nameof(Almanac.AnimSwitch)), HarmonyPostfix] + private static void AnimSwitch(Almanac __instance) => TranslateAlmanacMenu(__instance); + + public static void TranslateAlmanacMenu(Almanac __instance) + { + var font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance + .GetComponentsInChildren() + .Where(text => !text.gameObject.name.Contains("Cost"))) + { + text.text = StringStore.TranslateText(text.text == "关闭" ? "合上" : text.text); + text.font = font; + } + } +} diff --git a/Source/Patches/GameObjects/BaseMenu_Patch.cs b/Source/Patches/GameObjects/BaseMenu_Patch.cs new file mode 100644 index 0000000..741a4f8 --- /dev/null +++ b/Source/Patches/GameObjects/BaseMenu_Patch.cs @@ -0,0 +1,48 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(BaseMenu))] +public static class BaseMenu_Patch +{ + [HarmonyPatch(nameof(BaseMenu.Awake)), HarmonyPrefix] + private static void Pre_Awake(BaseMenu __instance) + { + if (__instance.name.Contains("NoticePauseMenu")) + NoticePauseMenu_Patch.Pre_Awake(__instance); + } + + [HarmonyPatch(nameof(BaseMenu.Awake)), HarmonyPostfix] + private static void Post_Awake(BaseMenu __instance) + { + if (__instance.name.Contains("NoticePauseMenu")) + NoticePauseMenu_Patch.Post_Awake(__instance); + + if (__instance.name.StartsWith("MainMenu(Clone)")) + MainMenu_Patch.AnimOver(__instance); + + if (__instance.name.StartsWith("PlantDamageMenu")) + PlantDamageMenu_Patch.Awake(__instance); + + TranslateBaseMenuTransform(__instance, "Level"); + TranslateBaseMenuTransform(__instance, "Levels"); + TranslateBaseMenuTransform(__instance, "CustomLevel"); + + StringStore.TranslateTextTransform(__instance.transform.Find("Goback")); + StringStore.TranslateTextTransform(__instance.transform.Find("Switich")); + } + + public static void TranslateBaseMenuTransform(BaseMenu __instance, string levelsName) + { + var levels = __instance.transform.Find(levelsName); + + if (levels == null) + return; + + var children = levels.GetComponentsInChildren(true).ToList(); + + foreach (var child in children.Where(child => child.name is "Nextpage" or "LastPage" or "BackToIndex")) + StringStore.TranslateTextTransform(child); + } +} diff --git a/Source/Patches/GameObjects/Board_Patch.cs b/Source/Patches/GameObjects/Board_Patch.cs new file mode 100644 index 0000000..3caf107 --- /dev/null +++ b/Source/Patches/GameObjects/Board_Patch.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(Board))] +public static class Board_Patch +{ + [HarmonyPatch(nameof(Board.Update)), HarmonyPostfix] + private static void Update(Board __instance) + { + foreach (var spriteRenderer in __instance.GetComponentsInChildren() + .Where(sr => sr.sprite != null) + .Where(sr => TextureStore.SpriteDict.ContainsKey(sr.sprite.name) && sr.drawMode != SpriteDrawMode.Sliced)) + spriteRenderer.drawMode = SpriteDrawMode.Sliced; + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs new file mode 100644 index 0000000..e3e5063 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/Advanture_Btn_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(Advanture_Btn))] +public static class Advanture_Btn_Patch +{ + [HarmonyPatch(nameof(Advanture_Btn.Start)), HarmonyPostfix] + private static void Start(Advanture_Btn __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == txt.text).Key; + + txt.text = StringStore.TranslationString.ContainsKey(originalKey + "_MG") + ? StringStore.TranslateText(originalKey + "_MG") + : StringStore.TranslateText(txt.text); + + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs new file mode 100644 index 0000000..8be4542 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs @@ -0,0 +1,14 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(BackToIndex))] +public class BackToIndex_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(BackToIndex.Awake))] + public static void Awake(BackToIndex __instance) => + StringStore.TranslateTextTransform(__instance.transform.GetChild(0)); +} +#endif diff --git a/Source/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs new file mode 100644 index 0000000..4172eea --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/CustomLevelEnter_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(CustomLevelEnter))] +public static class CustomLevelEnter_Patch +{ + [HarmonyPatch(nameof(CustomLevelEnter.Start)), HarmonyPostfix] + private static void Start(CustomLevelEnter __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == txt.text).Key; + + txt.text = StringStore.TranslationString.ContainsKey(originalKey + "_IZ") + ? StringStore.TranslateText(originalKey + "_IZ") + : StringStore.TranslateText(txt.text); + + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs new file mode 100644 index 0000000..f3126de --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(ExploreMakeSceneButton))] +public class ExploreMakeSceneButton_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(ExploreMakeSceneButton.Start))] + public static void Start(ExploreMakeSceneButton __instance) + { + __instance.sceneText.text = StringStore.TranslationString.ContainsKey(__instance.sceneText.text + "_FS") + ? StringStore.TranslateText(__instance.sceneText.text + "_FS") + : StringStore.TranslateText(__instance.sceneText.text); + + __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs new file mode 100644 index 0000000..490ef0b --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(ExploreMakeZombieButton))] +public class ExploreMakeZombieButton_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(ExploreMakeZombieButton.Start))] + public static void Start(ExploreMakeZombieButton __instance) + { + __instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType); + __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs new file mode 100644 index 0000000..dd685c7 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(GodShootingLevelButton))] +public static class GodShootingLevelButton_Patch +{ + [HarmonyPatch(nameof(GodShootingLevelButton.Awake)), HarmonyPostfix] + private static void Awake(GodShootingLevelButton __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == txt.text).Key; + + txt.text = StringStore.TranslationString.ContainsKey(originalKey + "_GS") + ? StringStore.TranslateText(originalKey + "_GS") + : StringStore.TranslateText(txt.text); + + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs new file mode 100644 index 0000000..9d5ff7a --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/InGameBtn_Patch.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(InGameBtn))] +public static class InGameBtn_Patch +{ + [HarmonyPatch(nameof(InGameBtn.Start)), HarmonyPostfix] + private static void Start(InGameBtn __instance) + { + var sceneText = __instance.transform.FindChild("SceneText"); + + if (sceneText != null) + { + var sceneTextTMP = sceneText.transform.GetComponent(); + + if (sceneTextTMP != null) + StringStore.TranslateText(sceneTextTMP); + + var sceneTextShadow = sceneText.transform.FindChild("SceneText"); + + if (sceneTextShadow != null) + { + var sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); + + if (sceneTextShadowTMP != null) + StringStore.TranslateText(sceneTextShadowTMP); + } + } + + foreach (var text in __instance.transform.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs new file mode 100644 index 0000000..6ed8041 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/LevelSaveEnter_Patch.cs @@ -0,0 +1,14 @@ +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +public static class LevelSaveEnter_Patch +{ + public static void TranslateEnter(LevelSaveEnter __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.text.text = StringStore.TranslateText(__instance.text.text); + __instance.text.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs new file mode 100644 index 0000000..e898902 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/MainMenu_Btn_Patch.cs @@ -0,0 +1,25 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(MainMenu_Btn))] +public static class MainMenu_Btn_Patch +{ + public static List speechBubbles = new List(); + + [HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter)), HarmonyPostfix] + private static void OnMouseEnter(MainMenu_Btn __instance) + { + string textToShow = null; + + if (__instance.transform.parent.name == "recipe") + textToShow = "探索模式"; + else if (__instance.name == "mysterious") + textToShow = "神秘模式"; + + if (textToShow != null) + InGameText.Instance.ShowText(textToShow, 2.0f); + } +} +#endif diff --git a/Source/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs new file mode 100644 index 0000000..257f2d9 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs @@ -0,0 +1,21 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(NormalBtn))] +public class NormalBtn_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))] + public static void OnMouseUpAsButton(NormalBtn __instance) + { + if (__instance.transform.childCount <= 0) + return; + + var banTransform = __instance.transform.GetChild(0); + + if (banTransform != null) + banTransform.GetComponent().text = + StringStore.TranslateText(banTransform.GetComponent().text); + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs new file mode 100644 index 0000000..986f1f8 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/OptLanguageBtn_Patch.cs @@ -0,0 +1,415 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using Object = UnityEngine.Object; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +public sealed class OptionButtonData +{ + public OptionBtn Button { get; init; } + + public Vector3 Position { get; init; } + + /// if it is the "Next" button. + public Utils.LanguageEnum? Language { get; set; } + + /// if it is the "Next" button. + public Utils.ToggleEnum? Toggle { get; set; } + + public bool IsNextButton { get; set; } + + public bool Shifted; +} + +internal static class OptLanguageBtn_Patch +{ + public static readonly Dictionary LanguageBtnDict = new(), ToggleBtnDict = new(); + + private static bool s_buttonsCreated, s_togglesCreated; + + // ReSharper disable once NotAccessedField.Local + private static OptionBtn s_cachedTemplateButton, s_cachedTemplateToggleButton; + + private const float + StartX = 4.3241f + 2.56f, + StartY = 2.7769f, + YSpacing = 1.2505f, + ToggleStartX = 4.3241f, + ToggleStartY = -0.9746f; + + private static List s_availableLanguages; + + private static List s_availableToggles; + + private const int LanguagesPerPage = 5; + + private static int s_currentPage; + + // 5 language buttons + 1 next button + public static readonly OptionBtn[] ButtonSlots = new OptionBtn[6], ToggleSlots = new OptionBtn[3]; + + public static void CreateLanguageButtons(OptionBtn templateButton) + { + if (s_buttonsCreated) + return; + + s_buttonsCreated = true; + s_cachedTemplateButton = templateButton; + + s_availableLanguages = Enum.GetValues(typeof(Utils.LanguageEnum)) + .Cast() + .Where(lang => lang != Utils.LanguageEnum.LangEnd) + .ToList(); + + for (var i = 0; i < 6; i++) + { + var newButton = Object.Instantiate(templateButton, templateButton.transform.parent); + newButton.tag = "LangOpt"; + + foreach (var child in newButton.GetComponentsInChildren()) + child.tag = "LangOpt"; + + newButton.optionType = 80 + i; + + var yPos = StartY - i * YSpacing; + Vector3 pos = new(StartX, yPos); + newButton.transform.position = pos; + + ButtonSlots[i] = newButton; + + LanguageBtnDict[newButton.GetInstanceID()] = new() + { + Button = newButton, + Position = pos, + }; + } + + UpdatePage(); + } + + public static void CreateToggleButtons(OptionBtn templateButton) + { + if (s_togglesCreated) + return; + + s_togglesCreated = true; + s_cachedTemplateToggleButton = templateButton; + + s_availableToggles = Enum.GetValues() + .Where(lang => lang != Utils.ToggleEnum.ToggleEnd) + .ToList(); + + for (var i = 0; i < 3; i++) + { + var newButton = Object.Instantiate(templateButton, templateButton.transform.parent); + newButton.tag = "LangOpt"; + + foreach (var child in newButton.GetComponentsInChildren()) + child.tag = "LangOpt"; + + newButton.optionType = 100 + i; + + var yPos = ToggleStartY - i * YSpacing; + Vector3 pos = new(ToggleStartX, yPos); + newButton.transform.position = pos; + + ToggleSlots[i] = newButton; + + ToggleBtnDict[newButton.GetInstanceID()] = new() + { + Button = newButton, + Position = pos, + }; + } + + UpdatePage(); + } + + private static void UpdatePage() + { + var startIndex = s_currentPage * LanguagesPerPage; + var langCount = s_availableLanguages.Count; + var toggleCount = s_togglesCreated ? s_availableToggles.Count : 0; + + for (var i = 0; i < 5; i++) + { + var btn = ButtonSlots[i]; + var data = LanguageBtnDict[btn.GetInstanceID()]; + + if (startIndex + i < langCount) + { + var lang = s_availableLanguages[startIndex + i]; + data.Language = lang; + data.IsNextButton = false; + btn.gameObject.SetActive(true); + + var languageName = Utils.LanguageNames.TryGetValue(lang, out var name) ? name : lang.ToString(); + UpdateButtonText(btn, languageName, FontStore.LoadTMPFont(lang.ToString())); + } + else + { + data.Language = null; + data.IsNextButton = false; + btn.gameObject.SetActive(false); + } + } + + if (s_togglesCreated) + for (var i = 0; i < 3; i++) + { + var btn = ToggleSlots[i]; + var data = ToggleBtnDict[btn.GetInstanceID()]; + + if (i < toggleCount) + { + var toggle = s_availableToggles[i]; + data.Toggle = toggle; + data.IsNextButton = false; + btn.gameObject.SetActive(true); + + var buttonText = Utils.ToggleNames.TryGetValue(toggle, out var name) + ? name + : toggle.ToString(); + + UpdateButtonText( + btn, + StringStore.TranslateText(buttonText), + FontStore.LoadTMPFont(Utils.Language.ToString()) + ); + + string sourceMsg; + + switch (i) + { + case 0: + sourceMsg = + $"Texture Source:\n{(Core.Instance.ConfigDefaultTextures.Value ? "Default" : "Custom")}"; + + FlashMessage(btn, sourceMsg, 0.1f, false); + break; + case 1: + sourceMsg = + $"Audio Source:\n{(Core.Instance.ConfigDefaultAudio.Value ? "Default" : "Custom")}"; + + FlashMessage(btn, sourceMsg, 0.1f, false); + break; + case 2: + sourceMsg = + $"Translation Source:\n{(Core.Instance.ConfigUseLocal.Value ? "Local" : "Online")}"; + + FlashMessage(btn, sourceMsg, 0.1f, false); + break; + } + } + else + { + data.Language = null; + data.IsNextButton = false; + btn.gameObject.SetActive(false); + } + } + + // "Next" button always visible at index 5 + var nextBtn = ButtonSlots[5]; + var nextData = LanguageBtnDict[nextBtn.GetInstanceID()]; + nextData.Language = null; + nextData.IsNextButton = true; + nextBtn.gameObject.SetActive(true); + UpdateButtonText(nextBtn, "Next"); + } + + public static void UpdateButtonText(OptionBtn button, string languageName, TMP_FontAsset fontAsset = null) + { + var defaultAsset = FontStore.LoadTMPFont("English"); + + for (var i = 0; i < 3; i++) + { + var textTransform = button.transform.GetChild(i); + + if (textTransform == null) + continue; + + if (i == 0) + textTransform.gameObject.SetActive(false); + + var text = textTransform.GetComponent(); + + if (text == null) + continue; + + if (i == 0) + { + text.text = ""; + text.color = Color.red; + } + else + text.text = languageName; + + text.fontSize = 16; + text.font = fontAsset != null ? fontAsset : defaultAsset; + text.autoSizeTextContainer = false; + } + } + + public static void FlashMessage(OptionBtn button, string message, float yShift = 0.0f, bool useTimer = true) + { + var child = button.transform.GetChild(0); + + if (child == null) + return; + + var text = child.GetComponent(); + var originalMsg = ""; + + if (text != null) + { + originalMsg = text.text; + text.text = message; + var isToggle = ToggleBtnDict.TryGetValue(button.GetInstanceID(), out _); + + if (isToggle) + { + text.transform.position = new( + 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( + 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); + + if (useTimer) + Task.Delay(1000) + .ContinueWith( + _ => + { + if (button == null || child == null || !child.gameObject.activeSelf) + return; + + var buttonData = ToggleBtnDict[button.GetInstanceID()]; + + if (buttonData.Toggle == null) + return; + + var sourceMsg = buttonData.Toggle switch + { + Utils.ToggleEnum.Textures => + $"Texture Source:\n{(Core.Instance.ConfigDefaultAudio.Value ? "Default" : "Custom")}", + Utils.ToggleEnum.Audio => + $"Audio Source:\n{(Core.Instance.ConfigDefaultAudio.Value ? "Default" : "Custom")}", + _ => originalMsg, + }; + + text.text = sourceMsg; + } + ); + } + + private static void ToggleCustomAssets(string type) + { + switch (type) + { + case "Textures": + Core.Instance.ConfigDefaultTextures.Value = !Core.Instance.ConfigDefaultTextures.Value; + TextureStore.Reload(); + Core.Coroutine(TextureStore.ReplaceTexturesCoroutine()); + break; + case "Audio": + Core.Instance.ConfigDefaultAudio.Value = !Core.Instance.ConfigDefaultAudio.Value; + break; + case "SwapLocal": + Utils.WarnLocalData(); + break; + } + } + + [HarmonyPatch(typeof(OptionBtn))] + public static class OptLangBtn_Patch + { + public static void Awake(OptionBtn __instance) + { + if (s_buttonsCreated && s_cachedTemplateButton != null) + return; + + s_buttonsCreated = false; + s_togglesCreated = false; + CreateLanguageButtons(__instance); + CreateToggleButtons(__instance); + } + + [HarmonyPatch("OnMouseUpAsButton"), HarmonyPrefix] + private static void OnMouseUpAsButton(OptionBtn __instance) + { + if (!ModFeatures.IsMultiLanguage) + return; + + if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) + { + if (btnData.IsNextButton) + { + s_currentPage = (s_currentPage + 1) % + (int)Math.Ceiling((float)s_availableLanguages.Count / LanguagesPerPage); + + UpdatePage(); + return; + } + + if (btnData.Language is { } selectedLang) + { + var currentLang = Utils.Language.ToString(); + + if (currentLang == selectedLang.ToString()) + FlashMessage(btnData.Button, "Already Selected!"); + else + { + Utils.ChangeLanguage(selectedLang.ToString()); + Debug.Log($"Language changed to: {selectedLang}"); + FlashMessage(btnData.Button, "Language Changed!"); + } + } + } + + if (!ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) + return; + + var toggleType = toggleData.Toggle.ToString(); + ToggleCustomAssets(toggleType); + + switch (toggleType) + { + case "Textures": + FlashMessage(toggleData.Button, "Toggled custom textures!\n(Restart Required)", 0.1f); + break; + case "Audio": + FlashMessage(toggleData.Button, "Toggled custom audio!", 0.1f); + break; + } + } + + [HarmonyPatch(nameof(OptionBtn.Update)), HarmonyPostfix] + private static void Update(OptionBtn __instance) + { + if (!ModFeatures.IsMultiLanguage) + return; + + if (LanguageBtnDict.TryGetValue(__instance.GetInstanceID(), out var btnData)) + btnData.Button.transform.position = btnData.Position; + + if (ToggleBtnDict.TryGetValue(__instance.GetInstanceID(), out var toggleData)) + toggleData.Button.transform.position = toggleData.Position; + } + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs new file mode 100644 index 0000000..87c7a16 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/OptionBtn_Patch.cs @@ -0,0 +1,69 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(OptionBtn))] +public static class OptionBtn_Patch +{ + [HarmonyPatch(nameof(OptionBtn.Awake)), HarmonyPostfix] + private static void Awake(OptionBtn __instance) + { + var text1Transform = __instance.transform.GetChild(0)?.transform; + + if (text1Transform != null) + { + var text1 = text1Transform.GetComponent(); + text1 = StringStore.TranslateText(text1); + text1.autoSizeTextContainer = false; + } + + var textTransform = __instance.transform.GetChild(1)?.transform; + + if (textTransform != null) + { + var text = textTransform.GetComponent(); + text = StringStore.TranslateText(text); + text.autoSizeTextContainer = false; + } + + var text2Transform = __instance.transform.GetChild(2)?.transform; + + if (text2Transform == null) + return; + + var text2 = text2Transform.GetComponent(); + text2 = StringStore.TranslateText(text2); + text2.autoSizeTextContainer = false; + } + + [HarmonyPatch("OnMouseUpAsButton"), HarmonyPostfix] + private static void OnMouseUpAsButtonPostfix(OptionBtn __instance) + { + var text1Transform = __instance.transform.GetChild(0)?.transform; + + if (text1Transform != null) + { + var text1 = text1Transform.GetComponent(); + text1 = StringStore.TranslateText(text1); + text1.autoSizeTextContainer = false; + } + + var textTransform = __instance.transform.GetChild(1)?.transform; + + if (textTransform != null) + { + var text = textTransform.GetComponent(); + text = StringStore.TranslateText(text); + text.autoSizeTextContainer = false; + } + + var text2Transform = __instance.transform.GetChild(2)?.transform; + + if (text2Transform == null) + return; + + var text2 = text2Transform.GetComponent(); + StringStore.TranslateText(text2); + } +} diff --git a/Source/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs new file mode 100644 index 0000000..2f8980f --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/PVPPotBtn_Patch.cs @@ -0,0 +1,41 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(PVPPotBtn))] // ReSharper disable once InconsistentNaming +public class PVPPotBtn_Patch +{ + [HarmonyPostfix] + [HarmonyPatch(nameof(PVPPotBtn.OnMouseUpAsButton))] + public static void OnMouseUpAsButton(PVPPotBtn __instance) + { + Transform sceneText = __instance.transform.FindChild("text"); + + if (sceneText != null) + { + var sceneTextTMP = sceneText.transform.GetComponent(); + + if (sceneTextTMP != null) + sceneTextTMP.text = StringStore.TranslateText(sceneTextTMP.text); + } + + var sceneTextShadow = sceneText.transform.FindChild("text_1"); + + if (sceneTextShadow != null) + { + var sceneTextShadowTMP = sceneTextShadow.transform.GetComponent(); + + if (sceneTextShadowTMP != null) + sceneTextShadowTMP.text = StringStore.TranslateText(sceneTextShadowTMP.text); + } + + if (!__instance.name.Equals("ChangeBg_3") && !__instance.name.Equals("ChangeBg_4")) + return; + + __instance.gameObject.SetActive(false); + __instance.gameObject.SetActive(true); + } +} +#endif diff --git a/Source/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs new file mode 100644 index 0000000..ff5a572 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/PauseMenu_Btn_Patch.cs @@ -0,0 +1,11 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(PauseMenu_Btn))] +public static class PauseMenu_Btn_Patch +{ + [HarmonyPatch(nameof(PauseMenu_Btn.Start)), HarmonyPostfix] + private static void Start(PauseMenu_Btn __instance) => StringStore.TranslateTextTransform(__instance.transform); +} diff --git a/Source/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs new file mode 100644 index 0000000..fe68003 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/SaveMenuBtn_Patch.cs @@ -0,0 +1,18 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(SaveMenuBtn))] +public static class SaveMenuBtn_Patch +{ + [HarmonyPatch(nameof(SaveMenuBtn.OnMouseUpAsButton)), HarmonyPostfix] + private static void OnMouseUpAsButton(SaveMenuBtn __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + __instance.theName.text = StringStore.TranslateText(__instance.theName.text); + __instance.theName.font = fontAsset; + } +} +#endif diff --git a/Source/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs new file mode 100644 index 0000000..401b8f7 --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs @@ -0,0 +1,16 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(UIBtn))] +public static class UIBtn_Patch +{ + [HarmonyPatch(nameof(UIBtn.Awake)), HarmonyPostfix] + private static void Postfix_Awake(UIBtn __instance) + { + if (__instance.TryGetComponent(out BackToIndex component)) + Utils.ConvertButtonText(__instance.transform.parent, component.name); + } +} +#endif diff --git a/Source/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs b/Source/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs new file mode 100644 index 0000000..0d2d7fc --- /dev/null +++ b/Source/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs @@ -0,0 +1,46 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +[HarmonyPatch(typeof(UIButton))] +public static class UIButton_Patch +{ + [HarmonyPatch(typeof(UIButton), nameof(UIButton.Start)), HarmonyPostfix] + public static void Start(UIButton __instance) + { + if (__instance.transform.childCount >= 2) + { + var font = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance.transform.GetComponentsInChildren()) + { + if (__instance.transform.name == "Goback") + text.text = "合上"; + + text.text = StringStore.TranslateText(text.text); + text.font = font; + } + } + else + { + StringStore.TranslateTextTransform(__instance.transform); + + if (__instance.transform.name != "Goback") + return; + + foreach (var text in __instance.transform.GetComponentsInChildren()) + text.text = StringStore.TranslateText("合上"); + } + } + + [HarmonyPatch(nameof(UIButton.OnMouseUpAsButton)), HarmonyPostfix] + public static void Postfix_OnMouseUpAsButton(UIButton __instance) + { + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} diff --git a/Source/Patches/GameObjects/Close_Patch.cs b/Source/Patches/GameObjects/Close_Patch.cs new file mode 100644 index 0000000..e52fe75 --- /dev/null +++ b/Source/Patches/GameObjects/Close_Patch.cs @@ -0,0 +1,50 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(Close))] +public static class Close_Patch +{ + [HarmonyPatch(nameof(Close.Start)), HarmonyPostfix] + private static void Close_Start(Close __instance) + { + TextMeshPro closeText = __instance.transform.GetChild(0).GetComponent(); + closeText.text = "合上"; + closeText = StringStore.TranslateText(closeText); + closeText.autoSizeTextContainer = true; + + var almanacTransform = __instance.transform.parent.transform; + var nameTransform = almanacTransform.Find("Name"); + + if (nameTransform != null) + { + var nameTMP = nameTransform.transform.GetComponent(); + + if (nameTMP) + { + nameTMP = StringStore.TranslateText(nameTMP); + nameTMP.autoSizeTextContainer = true; + } + + var nameShadowTransform = nameTransform.Find("NameShadow"); + + if (nameShadowTransform) + { + var nameShadowTMP = nameShadowTransform.transform.GetComponent(); + + if (nameShadowTMP) + { + nameShadowTMP = StringStore.TranslateText(nameShadowTMP); + nameShadowTMP.autoSizeTextContainer = true; + } + } + } + + StringStore.TranslateTextTransform(almanacTransform.Find("Back"), true); + StringStore.TranslateTextTransform(almanacTransform.Find("NextPage")); + StringStore.TranslateTextTransform(almanacTransform.Find("LastPage")); + } +} +#endif diff --git a/Source/Patches/GameObjects/ConfirmMenu_Patch.cs b/Source/Patches/GameObjects/ConfirmMenu_Patch.cs new file mode 100644 index 0000000..cf1d270 --- /dev/null +++ b/Source/Patches/GameObjects/ConfirmMenu_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ConfirmMenu))] +public static class ConfirmMenu_Patch +{ + [HarmonyPatch(nameof(ConfirmMenu.SetTitle)), HarmonyPostfix] + private static void SetTitle(ConfirmMenu __instance) + { + foreach (var title in __instance.title) + { + title.text = StringStore.TranslateText(title.text); + title.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} diff --git a/Source/Patches/GameObjects/CrisisZombieWindow_Patch.cs b/Source/Patches/GameObjects/CrisisZombieWindow_Patch.cs new file mode 100644 index 0000000..6949958 --- /dev/null +++ b/Source/Patches/GameObjects/CrisisZombieWindow_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(CrisisZombieWindow))] +public static class CrisisZombieWindow_Patch +{ + [HarmonyPatch(nameof(CrisisZombieWindow.Start)), HarmonyPostfix] + private static void Start(CrisisZombieWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(CrisisZombieWindow.SetZombieType)), HarmonyPostfix] + private static void SetZombieType(CrisisZombieWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/CustomSettings_Patch.cs b/Source/Patches/GameObjects/CustomSettings_Patch.cs new file mode 100644 index 0000000..31a35b0 --- /dev/null +++ b/Source/Patches/GameObjects/CustomSettings_Patch.cs @@ -0,0 +1,18 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(CustomSettings))] +public static class CustomSettings_Patch +{ + [HarmonyPatch(nameof(CustomSettings.Awake)), HarmonyPostfix] + private static void Awake(CustomSettings __instance) => + __instance.textMesh = StringStore.TranslateText(__instance.textMesh); + + [HarmonyPatch(nameof(CustomSettings.ChangeText)), HarmonyPostfix] + private static void ChangeText(CustomSettings __instance) => + __instance.textMesh = StringStore.TranslateText(__instance.textMesh); +} +#endif diff --git a/Source/Patches/GameObjects/CustomSun_Patch.cs b/Source/Patches/GameObjects/CustomSun_Patch.cs new file mode 100644 index 0000000..8392ad7 --- /dev/null +++ b/Source/Patches/GameObjects/CustomSun_Patch.cs @@ -0,0 +1,42 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(CustomSun))] +public static class CustomSun_Patch +{ + [HarmonyPatch(nameof(CustomSun.Awake)), HarmonyPostfix] + private static void Awake(CustomSun __instance) + { + if (__instance.inputField.gameObject.activeSelf) + { + string oriTextSun = __instance.inputField.m_Text; + __instance.inputField.gameObject.SetActive(false); + __instance.inputField.m_Text = StringStore.TranslateText(oriTextSun); + __instance.inputField.m_OriginalText = StringStore.TranslateText(oriTextSun); + __instance.inputField.gameObject.SetActive(true); + } + + if (__instance.setFlags.gameObject.activeSelf) + { + string oriTextFlags = __instance.setFlags.m_Text; + __instance.setFlags.gameObject.SetActive(false); + __instance.setFlags.m_Text = StringStore.TranslateText(oriTextFlags); + __instance.setFlags.m_OriginalText = StringStore.TranslateText(oriTextFlags); + __instance.setFlags.gameObject.SetActive(true); + } + + Transform lookZombieTransform = __instance.lookZombie.transform.GetChild(0).transform; + + if (lookZombieTransform == null) + return; + + var lookZombieTMP = lookZombieTransform.GetComponent(); + + if (lookZombieTMP != null) + StringStore.TranslateText(lookZombieTMP); + } +} +#endif diff --git a/Source/Patches/GameObjects/EveBuffMenu_Patch.cs b/Source/Patches/GameObjects/EveBuffMenu_Patch.cs new file mode 100644 index 0000000..44e582c --- /dev/null +++ b/Source/Patches/GameObjects/EveBuffMenu_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(EveBuffMenu))] +public static class EveBuffMenu_Patch +{ + [HarmonyPatch(nameof(EveBuffMenu.Start)), HarmonyPostfix] + private static void Start(EveBuffMenu __instance) + { + foreach (var window in __instance.windows) + EveOptionWindow_Patch.TranslateEveOptionWindow(window); + + foreach (var text in __instance.quitButton.GetComponentsInChildren()) + text.text = StringStore.TranslateText("合上"); + } + + [HarmonyPatch(nameof(EveBuffMenu.InitWindows)), HarmonyPostfix] + private static void InitWindows(EveBuffMenu __instance) + { + foreach (var window in __instance.windows) + EveOptionWindow_Patch.TranslateEveOptionWindow(window); + } +} diff --git a/Source/Patches/GameObjects/EveOptionWindow_Patch.cs b/Source/Patches/GameObjects/EveOptionWindow_Patch.cs new file mode 100644 index 0000000..da59511 --- /dev/null +++ b/Source/Patches/GameObjects/EveOptionWindow_Patch.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(EveOptionWindow))] +public static class EveOptionWindow_Patch +{ + [HarmonyPatch(nameof(EveOptionWindow.SetType)), HarmonyPostfix] + private static void SetType(EveOptionWindow __instance) => TranslateEveOptionWindow(__instance); + + [HarmonyPatch(nameof(EveOptionWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(EveOptionWindow __instance) => TranslateEveOptionWindow(__instance); + + [HarmonyPatch(nameof(EveOptionWindow.SelectedByRow)), HarmonyPostfix] + private static void SelectedByRow(EveOptionWindow __instance) => TranslateEveOptionWindow(__instance); + + public static void TranslateEveOptionWindow(EveOptionWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + + foreach (var text in __instance.buttonText) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/ExploreEnterWindow_Patch.cs b/Source/Patches/GameObjects/ExploreEnterWindow_Patch.cs new file mode 100644 index 0000000..a5fd0b8 --- /dev/null +++ b/Source/Patches/GameObjects/ExploreEnterWindow_Patch.cs @@ -0,0 +1,56 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ExploreEnterWindow))] +public static class ExploreEnterWindow_Patch +{ + [HarmonyPatch(nameof(ExploreEnterWindow.Awake)), HarmonyPostfix] + private static void Awake(ExploreEnterWindow __instance) + { + var thePlantType = (PlantType)__instance.selfType; + + __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); + + if (__instance.nameText.text == "") + StringStore.TranslateText(__instance.nameText.text); + + __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(ExploreEnterWindow.SetInfo)), HarmonyPostfix] + private static void SetInfo(ExploreEnterWindow __instance) + { + var thePlantType = (PlantType)__instance.selfType; + + __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); + + if (__instance.nameText.text == "") + StringStore.TranslateText(__instance.nameText.text); + + __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(ExploreEnterWindow.SetIcon)), HarmonyPostfix] + private static void SetIcon(ExploreEnterWindow __instance) + { + var thePlantType = (PlantType)__instance.selfType; + + __instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType); + + if (__instance.nameText.text == "") + StringStore.TranslateText(__instance.nameText.text); + + __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(ExploreEnterWindow.SetDisable)), HarmonyPostfix] + private static void SetDisable(ExploreEnterWindow __instance) + { + if (__instance.disabled) + __instance.nameText.text = StringStore.TranslateText("敬请期待"); + + __instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/Patches/GameObjects/ExploreMakeMenu_Patch.cs b/Source/Patches/GameObjects/ExploreMakeMenu_Patch.cs new file mode 100644 index 0000000..5dd1873 --- /dev/null +++ b/Source/Patches/GameObjects/ExploreMakeMenu_Patch.cs @@ -0,0 +1,59 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ExploreMakeMenu))] +public static class ExploreMakeMenu_Patch +{ + [HarmonyPatch(nameof(ExploreMakeMenu.Awake)), HarmonyPostfix] + private static void Awake(ExploreMakeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(ExploreMakeMenu.InitMenu)), HarmonyPostfix] + private static void InitMenu(ExploreMakeMenu __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + if (txt.text.Contains("关卡制作中:")) + { + var plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]); + txt.text = string.Format(StringStore.TranslationStringRegex["关卡制作中:([^\\s]+)"], plantName); + } + else + txt.text = StringStore.TranslateText(txt.text); + } + + [HarmonyPatch(nameof(ExploreMakeMenu.ViewScene)), HarmonyPostfix] + private static void ViewScene(ExploreMakeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons)), HarmonyPostfix] + private static void InitZombieButtons(ExploreMakeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/ExploreMenu_Patch.cs b/Source/Patches/GameObjects/ExploreMenu_Patch.cs new file mode 100644 index 0000000..3bbd9e3 --- /dev/null +++ b/Source/Patches/GameObjects/ExploreMenu_Patch.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ExploreMenu))] +public static class ExploreMenu_Patch +{ + [HarmonyPatch(nameof(ExploreMenu.Awake)),HarmonyPostfix] + private static void Awake(ExploreMenu __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + txt.text = StringStore.TranslateText(txt.text); + + // var randomLevelTextTransform = __instance.transform.FindChild("RandomLevel"); + } + + [HarmonyPatch(nameof(ExploreMenu.UpdateWindows)),HarmonyPostfix] + private static void UpdateWindows(ExploreMenu __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + txt.text = StringStore.TranslateText(txt.text); + } +} diff --git a/Source/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs b/Source/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs new file mode 100644 index 0000000..c0b7a8e --- /dev/null +++ b/Source/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(FruitNinjaSelectWindow))] +public static class FruitNinjaSelectWindow_Patch +{ + [HarmonyPatch(nameof(FruitNinjaSelectWindow.SetType)), HarmonyPostfix] + private static void SetType(FruitNinjaSelectWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(FruitNinjaSelectWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(FruitNinjaSelectWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/GardenPlant_Patch.cs b/Source/Patches/GameObjects/GardenPlant_Patch.cs new file mode 100644 index 0000000..0ac3265 --- /dev/null +++ b/Source/Patches/GameObjects/GardenPlant_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(GardenPlant))] +public static class GardenPlant_Patch +{ + [HarmonyPatch(nameof(GardenPlant.Start)), HarmonyPostfix] + private static void Start(GardenPlant __instance) + { + __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); + } + + [HarmonyPatch(nameof(GardenPlant.UpdateInfo)), HarmonyPostfix] + private static void UpdateInfo(GardenPlant __instance) + { + __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + __instance.infoText.text = StringStore.TranslateText(__instance.infoText.text); + } +} diff --git a/Source/Patches/GameObjects/GardenStoreMenu_Patch.cs b/Source/Patches/GameObjects/GardenStoreMenu_Patch.cs new file mode 100644 index 0000000..1a5dd2f --- /dev/null +++ b/Source/Patches/GameObjects/GardenStoreMenu_Patch.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(GardenStoreMenu))] +public static class GardenStoreMenu_Patch +{ + [HarmonyPatch(nameof(GardenStoreMenu.InitGoodsList)), HarmonyPatch(nameof(GardenStoreMenu.GetDatas)), + HarmonyPatch(nameof(GardenStoreMenu.PurchaseGoods)), HarmonyPatch(nameof(GardenStoreMenu.Update)), + HarmonyPatch(nameof(GardenStoreMenu.Start)), HarmonyPostfix] + public static void TranslateGardenStoreMenu(GardenStoreMenu __instance) + { + foreach (var slot in __instance.GetComponentsInChildren()) + TranslateGardenShopSlot(slot); + } + + [HarmonyPatch(nameof(GardenShopSlot.Start)), HarmonyPostfix] + public static void TranslateGardenShopSlot(GardenShopSlot __instance) + { + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} diff --git a/Source/Patches/GameObjects/GodShootingMenu_Patch.cs b/Source/Patches/GameObjects/GodShootingMenu_Patch.cs new file mode 100644 index 0000000..b2e0a72 --- /dev/null +++ b/Source/Patches/GameObjects/GodShootingMenu_Patch.cs @@ -0,0 +1,34 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(GodShootingMenu))] +public static class GodShootingMenu_Patch +{ + [HarmonyPatch(nameof(GodShootingMenu.Start)), HarmonyPostfix] + private static void Start(GodShootingMenu __instance) + { + foreach (var text in __instance.transform.Find("Background").GetComponentsInChildren()) + { + text.autoSizeTextContainer = true; + text.text = StringStore.TranslateText(text.text); + } + + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(GodShootingMenu.ShowRoutes)), HarmonyPostfix] + private static void ShowRoutes(GodShootingMenu __instance) + { + foreach (var route in __instance.routes) + { + if (route.Value == null) + continue; + + foreach (var text in route.Value.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + } +} diff --git a/Source/Patches/GameObjects/LevelResultMenu_Patch.cs b/Source/Patches/GameObjects/LevelResultMenu_Patch.cs new file mode 100644 index 0000000..bd047ff --- /dev/null +++ b/Source/Patches/GameObjects/LevelResultMenu_Patch.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(LevelResultMenu))] +public static class LevelResultMenu_Patch +{ + [HarmonyPatch(nameof(LevelResultMenu.Start)), HarmonyPatch(nameof(LevelResultMenu.ShowResult)), HarmonyPostfix] + public static void Awake(LevelResultMenu __instance) + { + foreach (var txt in __instance.GetComponentsInChildren()) + txt.text = StringStore.TranslateText(txt.text); + } +} diff --git a/Source/Patches/GameObjects/LoseMenu_Patch.cs b/Source/Patches/GameObjects/LoseMenu_Patch.cs new file mode 100644 index 0000000..96862b6 --- /dev/null +++ b/Source/Patches/GameObjects/LoseMenu_Patch.cs @@ -0,0 +1,14 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(LoseMenu))] +public static class LoseMenu_Patch +{ + public static void TranslateLoseMenu(BaseMenu __instance) + { + if (__instance.TryGetComponent(out var loseMenu)) + loseMenu.title.text = StringStore.TranslateText(loseMenu.title.text); + } +} diff --git a/Source/Patches/GameObjects/MainMenu_Patch.cs b/Source/Patches/GameObjects/MainMenu_Patch.cs new file mode 100644 index 0000000..654e61f --- /dev/null +++ b/Source/Patches/GameObjects/MainMenu_Patch.cs @@ -0,0 +1,103 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(MainMenu))] +public class MainMenu_Patch +{ + public static void AnimOver(BaseMenu __instance) + { + var changelogObj = __instance.transform.Find("Grave/UpdateInfoButton"); + + var langObj = UnityEngine.Object.Instantiate( + changelogObj, + changelogObj.position + new Vector3(0.0f, 0.855f), + changelogObj.rotation, + __instance.transform.Find("Grave") + ); + + langObj.name = "LanguagesButton"; + __instance.collider2Ds.Add(langObj.GetComponent()); + var langBtn = langObj.GetComponent(); + + foreach (var text in langObj.GetComponentsInChildren()) + text.text = StringStore.TranslateText("Languages"); + + langBtn.clickEvent = new(); + langBtn.clickEvent.AddListener(new Action(() => OpenLanguageMenu(langBtn.gameObject))); + } + + public static void OpenLanguageMenu(GameObject langBtn) + { + UIMgr.EnterOptionMenu(); + var newOptionsMenu = GameAPP.canvasUp.Find("OptionMenu(Clone)").gameObject; + newOptionsMenu.name = "LanguageMenu"; + + var toKeep = new List { "Background", "F", "Goback" }; + + foreach (var child in newOptionsMenu.GetComponentsInChildren() + .Where(c => !toKeep.Contains(c.name) && !toKeep.Contains(c.parent.name) && c.name != "LanguageMenu")) + child.gameObject.SetActive(false); + + var templateButton = newOptionsMenu.transform.Find("Buttons/F").GetComponent(); + OptLanguageBtn_Patch.OptLangBtn_Patch.Awake(templateButton); + + // var goBackButton = newOptionsMenu.transform.Find("Goback").GetComponent(); + + newOptionsMenu.transform.Find("Buttons/F").gameObject.SetActive(false); + newOptionsMenu.transform.Find("Buttons").gameObject.SetActive(true); + + foreach (var text in newOptionsMenu.transform.Find("Background").GetComponentsInChildren()) + text.text = StringStore.TranslateText("Language Settings"); + + /*GameObject optionMenuAnchor = UnityEngine.Object.Instantiate(assetBundle.LoadAsset("OptionMenu").TryCast(), GameAPP.canvasUp); + optionMenuAnchor.transform.SetParent(newOptionsMenu.transform, false); + Transform messageAnchor = optionMenuAnchor.transform.Find("MessageAnchor"); + Transform plantAnchor = optionMenuAnchor.transform.Find("PlantAnchor"); + + System.Random random = new System.Random(); + var plantTypes = Enum.GetValues(typeof(PlantType)); + PlantType randomPlantChoice = (PlantType)plantTypes.GetValue(random.Next(plantTypes.Length)); + + if(!GameAPP.resourcesManager.plantPrefabs.ContainsKey(randomPlantChoice) || GameAPP.resourcesManager.plantPrefabs[randomPlantChoice] == null) + { + randomPlantChoice = (PlantType)plantTypes.GetValue(random.Next(plantTypes.Length)); + } + + if (GameAPP.resourcesManager.plantPrefabs[randomPlantChoice] != null) + { + GameObject plant = CreatePlant.SetPlantInAlmamac(plantAnchor.position, (int)randomPlantChoice); + plant.transform.SetParent(newOptionsMenu.transform); + SortingGroup sortingGroup = plant.AddComponent(); + sortingGroup.sortingLayerName = "UI"; + sortingGroup.sortingOrder = 20001; + //plant.transform.position = new Vector3(-7.21f, -3.66f); + UnityEngine.Object.Destroy(plant.GetComponent()); + }*/ + + /*GameObject messageObj = new GameObject(); + messageObj.name = "MultilangMessage"; + messageObj.transform.SetParent(newOptionsMenu.transform); + TextMeshProUGUI messageText = messageObj.AddComponent(); + messageObj.transform.localScale = Vector3.one; + messageText.autoSizeTextContainer = false; + messageText.font = FontStore.LoadTMPFont(Utils.LanguageEnum.English.ToString()); + messageText.text = "Hello this is multilanguage choose language over there ------>";*/ + } + + [HarmonyPatch(nameof(MainMenu.EnterUpdateUrl)), HarmonyPrefix] + public static bool Pre_EnterUpdateUrl(MainMenu __instance) + { + System.Diagnostics.Process.Start( + new System.Diagnostics.ProcessStartInfo + { + FileName = "https://github.com/Teyliu/PVZF-Translation", + UseShellExecute = true, + } + ); + + return false; + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/Brain_Patch.cs b/Source/Patches/GameObjects/MinorObjects/Brain_Patch.cs new file mode 100644 index 0000000..844d9ec --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/Brain_Patch.cs @@ -0,0 +1,48 @@ +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(Brain))] +public static class Brain_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(Brain.Awake))] + private static void Awake(Brain __instance) + { + // reposition original points + var pointsTransform = __instance.points.transform; + var pointsObject = __instance.points.gameObject; + pointsTransform.position = new(-6.5f, pointsTransform.position.y, pointsTransform.position.z); + + // instantiate and move new shadow + var pointsShadowObject = UnityEngine.Object.Instantiate(pointsObject, pointsTransform); + pointsShadowObject.SetActive(true); + var pointsShadowTransform = pointsShadowObject.transform; + pointsShadowTransform.position = new(-6.485f, pointsTransform.position.y - 0.015f, pointsTransform.position.z); + + // set points text + var pointsShadowText = pointsShadowObject.GetComponent(); + pointsShadowText.text = __instance.points.text; + pointsShadowText.sortingOrder -= 2; + pointsShadowText.color = Color.black; + } + + [HarmonyPostfix, HarmonyPatch(nameof(Brain.Update))] + private static void Update(Brain __instance) + { + if (__instance.transform.Find("Points").GetChild(0) == null) + return; + + var shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); + shadowText.text = __instance.points.text; + } + + [HarmonyPostfix, HarmonyPatch(nameof(Brain.WinAction))] + private static void WinAction(Brain __instance) + { + if (__instance.transform.Find("Points").GetChild(0) == null) + return; + + var shadowText = __instance.transform.Find("Points").GetChild(0).GetComponent(); + shadowText.text = __instance.points.text; + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/DY_Patch.cs b/Source/Patches/GameObjects/MinorObjects/DY_Patch.cs new file mode 100644 index 0000000..922b813 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/DY_Patch.cs @@ -0,0 +1,12 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(DY))] +public static class DyPatch +{ + [HarmonyPostfix, HarmonyPatch(nameof(DY.Update))] + private static void Update(DY __instance) => + __instance.TextMeshPro.text = StringStore.TranslateText(__instance.TextMeshPro.text); +} diff --git a/Source/Patches/GameObjects/MinorObjects/GameLose_Patch.cs b/Source/Patches/GameObjects/MinorObjects/GameLose_Patch.cs new file mode 100644 index 0000000..4160996 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/GameLose_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.Patches.BaseTextObjects; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(GameLose))] +public static class GameLose_Patch +{ + [HarmonyPatch(nameof(GameLose.UpdateSecondChanceTimer))] + public static void UpdateSecondChanceTimer(GameLose __instance) + { + if (InGameText.Instance == null) + return; + + if (InGameText.Instance.timer < 0) + return; + + InGameText_Patch.TranslateInGameText(InGameText.Instance); + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs b/Source/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs new file mode 100644 index 0000000..9af97c4 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/HealthSlider_Patch.cs @@ -0,0 +1,34 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(HealthSlider))] +public static class HealthSlider_Patch +{ +#pragma warning disable CA2211 + public static TMP_FontAsset FontAsset; +#pragma warning restore CA2211 + [HarmonyPatch(nameof(HealthSlider.Start)), HarmonyPostfix] + public static void Post_Start(HealthSlider __instance) + { + if (!FontAsset) + FontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(HealthSlider.UpdateText)), HarmonyPostfix] + public static void Post_UpdateText(HealthSlider __instance) + { + if (!FontAsset) + FontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + if (__instance.healthText.font != FontAsset) + __instance.healthText.font = FontAsset; + + foreach (var txt in __instance.healthTextContainer.GetComponentsInChildren(true)) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = FontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs b/Source/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs new file mode 100644 index 0000000..321901a --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/Jigsaw_Patch.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(JigsawClip))] +public static class JigsawClip_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(JigsawClip.Awake))] + private static void Postfix_Awake(JigsawClip __instance) + { + if (!__instance || !__instance.description) + return; + + StringStore.TranslateTextUI(__instance.description); + } + + [HarmonyPostfix, HarmonyPatch(nameof(JigsawClip.Update))] + private static void Postfix_Update(JigsawClip __instance) + { + if (!__instance || !__instance.description) + return; + + if (__instance.description.text != StringStore.TranslateText(__instance.description.text)) + StringStore.TranslateTextUI(__instance.description); + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs b/Source/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs new file mode 100644 index 0000000..ca783a0 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/LanternUmbrella_Patch.cs @@ -0,0 +1,17 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(LanternUmbrella))] +public class LanternUmbrella_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(LanternUmbrella.Update))] + private static void Update(LanternUmbrella __instance) + { + __instance.energyText = StringStore.TranslateText(__instance.energyText); + __instance.energyTextShadow = StringStore.TranslateText(__instance.energyTextShadow); + } +} +#endif diff --git a/Source/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs b/Source/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs new file mode 100644 index 0000000..d0a85a9 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/MagnetBox_Patch.cs @@ -0,0 +1,11 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(MagnetBox))] +public class MagnetBox_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(MagnetBox.Update))] + private static void Update(MagnetBox __instance) => StringStore.TranslateTextTransform(__instance.transform); +} diff --git a/Source/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs b/Source/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs new file mode 100644 index 0000000..d09156c --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/MagnetInterface_Patch.cs @@ -0,0 +1,11 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(MagnetInterface))] +public class MagnetInterface_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(MagnetInterface.Update))] + private static void Update(MagnetInterface __instance) => StringStore.TranslateTextTransform(__instance.transform); +} diff --git a/Source/Patches/GameObjects/MinorObjects/Money_Patch.cs b/Source/Patches/GameObjects/MinorObjects/Money_Patch.cs new file mode 100644 index 0000000..bf7e205 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/Money_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(Money))] +public static class Money_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(Money.Update))] + private static void Update(Money __instance) + { + if (!Utils.CheckForUntranslatedText(__instance.beanCount.text)) + return; + + __instance.beanCount.text = StringStore.TranslateText(__instance.beanCount.text); + __instance.beanCount2.text = StringStore.TranslateText(__instance.beanCount2.text); + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/Plant_Patch.cs b/Source/Patches/GameObjects/MinorObjects/Plant_Patch.cs new file mode 100644 index 0000000..a2a2734 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/Plant_Patch.cs @@ -0,0 +1,51 @@ +#if false +using System.Text.RegularExpressions; +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(Plant))] +public static class Plant_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(Plant.Awake))] + private static void Awake(Plant __instance) + { + if (__instance.thePlantType is not (PlantType.SuperMachineNut or PlantType.MachineNut)) + return; + + __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = + ChangeHPText(__instance.healthSlider.healthTextShadow.text); + } + + [HarmonyPostfix, HarmonyPatch(nameof(Plant.UpdateText))] + private static void Update(Plant __instance) + { + if (__instance.thePlantType is not (PlantType.SuperMachineNut or PlantType.MachineNut)) + return; + + if (__instance.thePlantHealth < __instance.thePlantMaxHealth) + return; + + __instance.healthSlider.healthText.text = __instance.healthSlider.healthTextShadow.text = + ChangeHPText(__instance.healthSlider.healthTextShadow.text); + } + + private static string ChangeHPText(string originalText) + { + var regex = new Regex(@"(\d+)\d\d\d/(\d)000"); + + if (!regex.IsMatch(originalText)) + return originalText; + + var match = regex.Match(originalText); + var groupCount = match.Groups.Count; + + var dynamicParts = new List(); + + for (var i = 1; i < groupCount; i++) + dynamicParts.Add(match.Groups[i].Value); + + return string.Format("{0}k/{1}k", [..dynamicParts]); + } +} +#endif diff --git a/Source/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs b/Source/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs new file mode 100644 index 0000000..40aa856 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/PlayerName_Patch.cs @@ -0,0 +1,15 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(PlayerName))] +public static class PlayerName_Patch +{ + [HarmonyPostfix] + [HarmonyPatch(nameof(PlayerName.Update))] + private static void Update(PlayerName __instance) => + __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); +} +#endif diff --git a/Source/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs b/Source/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs new file mode 100644 index 0000000..e93cfa5 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/PumpinerChestMenu_Patch.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(PumpinerChestMenu))] +public static class PumpinerChestMenu_Patch +{ + [HarmonyPatch(nameof(PumpinerChestMenu.InitPlants)), HarmonyPostfix] + public static void Post_InitPlants(PumpinerChestMenu __instance) + { + var closeBtnTransform = __instance.transform.Find("SampleButton"); + var txt = closeBtnTransform.GetComponentInChildren(); + txt.text = StringStore.TranslateText("合上"); + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs b/Source/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs new file mode 100644 index 0000000..c00a74b --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/SelectYourPlants_Patch.cs @@ -0,0 +1,20 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(SelectYourPlants))] +public static class SelectYourPlants_Patch +{ + [HarmonyPatch(nameof(SelectYourPlants.Awake)), HarmonyPostfix] + private static void Awake(SelectYourPlants __instance) + { + __instance.TextMeshProUGUI = StringStore.TranslateText(__instance.TextMeshProUGUI); + __instance.TextMeshProUGUI.autoSizeTextContainer = true; + + __instance.TextMeshProUGUI2 = StringStore.TranslateText(__instance.TextMeshProUGUI2); + __instance.TextMeshProUGUI2.autoSizeTextContainer = true; + } +} +#endif diff --git a/Source/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs b/Source/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs new file mode 100644 index 0000000..59f9cd0 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/SpecialCard_Patch.cs @@ -0,0 +1,21 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(SpecialCard))] +public static class SpecialCard_Patch +{ + [HarmonyPatch(nameof(SpecialCard.Awake)), HarmonyPatch(nameof(SpecialCard.Start)), + HarmonyPatch(nameof(SpecialCard.ClickedEvent)), HarmonyPostfix] + public static void Post_Awake(SpecialCard __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs b/Source/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs new file mode 100644 index 0000000..11a4e9d --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/TrainingDummy_Patch.cs @@ -0,0 +1,12 @@ +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(TrainingDummy), nameof(TrainingDummy.UpdateHealthText))] +public static class TrainingDummy_Patch +{ + [HarmonyPostfix] + public static void UpdateHealthText(TrainingDummy __instance) => + // Zombie_Patch.TranslateHpUI_T(__instance.healthTextShadow, __instance); + Zombie_Patch.TranslateHpUI_T(__instance.healthText, __instance); +} diff --git a/Source/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs b/Source/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs new file mode 100644 index 0000000..df80c69 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/TreasureMoney_Patch.cs @@ -0,0 +1,12 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(TreasureMoney))] +public static class TreasureMoney_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(TreasureMoney.Update))] + private static void Update(TreasureMoney __instance) => + __instance.text = StringStore.TranslateText(__instance.text); +} diff --git a/Source/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs b/Source/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs new file mode 100644 index 0000000..68b52c0 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/UIProgress2_Patch.cs @@ -0,0 +1,12 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(UIProgress2))] +public static class UIProgress2_Patch +{ + [HarmonyPatch(nameof(UIProgress2.Update)), HarmonyPostfix] + private static void Update(UIProgress2 __instance) => + __instance.t.text = StringStore.TranslateText(__instance.t.text); +} diff --git a/Source/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs b/Source/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs new file mode 100644 index 0000000..1b0ebe6 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/UltimateChomper_Patch.cs @@ -0,0 +1,17 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(UltimateChomper), nameof(UltimateChomper.UpdateText))] +public static class UltimateChomper_Patch +{ + [HarmonyPostfix] + public static void UpdateText(UltimateChomper __instance) + { + StringStore.TranslateText(__instance.killingText); + StringStore.TranslateText(__instance.killingTextShadow); + } +} +#endif diff --git a/Source/Patches/GameObjects/MinorObjects/Zombie_Patch.cs b/Source/Patches/GameObjects/MinorObjects/Zombie_Patch.cs new file mode 100644 index 0000000..49555a5 --- /dev/null +++ b/Source/Patches/GameObjects/MinorObjects/Zombie_Patch.cs @@ -0,0 +1,184 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; + +[HarmonyPatch(typeof(Zombie))] +public static class Zombie_Patch +{ + private static readonly Dictionary s_hpStrings = new() + { + { "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" }, + { + "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", + "HP: {0}/{1}\nT1 armor: {2}/{3}\nT2 armor: {4}/{5}" + }, + { "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT1 armor: {2}/{3}" }, + { "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT2 armor: {2}/{3}" }, + { @"^HP:(\d+)/(\d+)$", "HP: {0}/{1}" }, + }; + + public static void LoadHpStrings() + { + foreach (var hp in s_hpStrings) + if (StringStore.TranslationStringRegex.TryGetValue(hp.Key, out var value)) + s_hpStrings[hp.Key] = value; + } + + [HarmonyPatch(nameof(Zombie.Start)), HarmonyPostfix] + public static void Start(Zombie __instance) + { + TranslateHpUI(__instance.healthText, __instance); + //TranslateHpUI(__instance.healthTextShadow, __instance); + + if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0)) + __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); + } + + [HarmonyPatch(nameof(Zombie.UpdateHealthText)), HarmonyPostfix] + public static void Update(Zombie __instance) + { + if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth) + return; + + if (__instance.healthText == null) + return; + + TranslateHpUI(__instance.healthText, __instance); + //TranslateHpUI(__instance.healthTextShadow, __instance); + + if (__instance.healthText.transform.rotation != Quaternion.Euler(0f, 0f, 0f)) + __instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f); + } + + public static void TranslateHpUI(TextMeshPro textTMP, Zombie __instance) + { + if (!textTMP) + return; + + var origText = textTMP.text; + var translatedText = origText; + + if (translatedText == null) + return; + + const string Pattern = "(\\d+)阶\n([\\s\\S]+)"; + + if (StringStore.TestRegex(translatedText, Pattern)) + { + var match = Regex.Match(translatedText, Pattern, RegexOptions.Singleline); + var tier = match.Groups[1].Value; + var healthText = TranslateHpText(match.Groups[2].Value, __instance); + var fStr = StringStore.TranslationStringRegex[Pattern]; + translatedText = string.Format(fStr, [tier, healthText]); + } + else + translatedText = TranslateHpText(origText, __instance); + + textTMP.text = translatedText == origText ? origText : translatedText; + textTMP.autoSizeTextContainer = false; + + if (translatedText != origText) + textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + public static void TranslateHpUI_T(TextMeshPro textTMP, TrainingDummy __instance) + { + if (!textTMP) + return; + + var origText = textTMP.text; + var translatedText = TranslateHPText_T(origText, __instance); + textTMP.text = translatedText == origText ? origText : translatedText; + textTMP.autoSizeTextContainer = false; + + if (translatedText != origText) + textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + public static string TranslateHpText(string originalText, Zombie __instance) + { + if (originalText == null) + return null; + + var finalText = __instance.healthText.text; + var fIndex = -1; + var found = false; + + for (var i = 0; i < s_hpStrings.Count; i++) + { + var hp = s_hpStrings.ElementAt(i); + + if (!Regex.Match(originalText, hp.Key, RegexOptions.Singleline).Success) + continue; + + fIndex = i; + found = true; + } + + if (fIndex <= -1 || !found) + return finalText; + + var fStr = s_hpStrings.ElementAt(fIndex).Value; + + return fIndex switch + { + 1 => string.Format( + fStr, + __instance.theHealth, + __instance.theMaxHealth, + __instance.theFirstArmorHealth, + __instance.theFirstArmorMaxHealth, + __instance.theSecondArmorHealth, + __instance.theSecondArmorMaxHealth + ), + 2 => string.Format( + fStr, + __instance.theHealth, + __instance.theMaxHealth, + __instance.theFirstArmorHealth, + __instance.theFirstArmorMaxHealth + ), + 3 => string.Format( + fStr, + __instance.theHealth, + __instance.theMaxHealth, + __instance.theSecondArmorHealth, + __instance.theSecondArmorMaxHealth + ), + 4 => string.Format(fStr, __instance.theHealth, __instance.theMaxHealth), + _ => finalText, + }; + } + + public static string TranslateHPText_T(string originalText, TrainingDummy __instance) + { + var finalText = __instance.healthText.text; + var fIndex = -1; + var found = false; + + for (var i = 0; i < s_hpStrings.Count; i++) + { + var hp = s_hpStrings.ElementAt(i); + var regex = new Regex(hp.Key); + + if (!regex.IsMatch(originalText)) + continue; + + fIndex = i; + found = true; + } + + if (fIndex <= -1 || !found) + return finalText; + + var fStr = s_hpStrings.ElementAt(fIndex).Value; + + return fIndex switch + { + 0 => string.Format(fStr, __instance.lastDamage, __instance.CurrentDPS, __instance.totalDamage), + _ => finalText, + }; + } +} diff --git a/Source/Patches/GameObjects/NoticePauseMenu_Patch.cs b/Source/Patches/GameObjects/NoticePauseMenu_Patch.cs new file mode 100644 index 0000000..bb09216 --- /dev/null +++ b/Source/Patches/GameObjects/NoticePauseMenu_Patch.cs @@ -0,0 +1,53 @@ +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine.UI; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +public static class NoticePauseMenu_Patch +{ +#pragma warning disable CA2211 + public static string ChangelogText = ""; +#pragma warning restore CA2211 + public static void Pre_Awake(BaseMenu __instance) + { + var contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; + + var contentText = contentObject.GetComponent(); + + File.WriteAllText( + Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "changelog.txt"), + contentText.text + ); + + var stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); + var changelogDir = Path.Combine(stringDir, "changelog.txt"); + + if (!File.Exists(changelogDir)) + File.WriteAllText(changelogDir, contentText.text); + } + + public static void Post_Awake(BaseMenu __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + FileLoader.LoadChangelogText(); + + var contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; + + var contentText = contentObject.GetComponent(); + contentText.text = ChangelogText; + contentText.margin = new(6, 2, 12, 0); + + contentText.enableWordWrapping = true; + contentText.overflowMode = TextOverflowModes.ScrollRect; + + Canvas.ForceUpdateCanvases(); + contentText.ForceMeshUpdate(); + + //float textHeight = contentText.preferredHeight; + //RectTransform contentRect = contentObject.GetComponent(); + //contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, textHeight); + + var sizeFitter = contentObject.AddComponent(); + sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize; + } +} diff --git a/Source/Patches/GameObjects/OtherMenu_Patch.cs b/Source/Patches/GameObjects/OtherMenu_Patch.cs new file mode 100644 index 0000000..7cc2c99 --- /dev/null +++ b/Source/Patches/GameObjects/OtherMenu_Patch.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.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); + } +} diff --git a/Source/Patches/GameObjects/PVPRandomManager_Patch.cs b/Source/Patches/GameObjects/PVPRandomManager_Patch.cs new file mode 100644 index 0000000..db06f86 --- /dev/null +++ b/Source/Patches/GameObjects/PVPRandomManager_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PVPRandomManager))] // ReSharper disable once InconsistentNaming +public static class PVPRandomManager_Patch +{ + [HarmonyPatch(nameof(PVPRandomManager.Start)), HarmonyPostfix] + private static void Start(PVPRandomManager __instance) + { + foreach (var text in __instance.texts) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(PVPRandomManager.Update)), HarmonyPostfix] + private static void ZombieEnterHouse(PVPRandomManager __instance) + { + foreach (var text in __instance.texts) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs b/Source/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs new file mode 100644 index 0000000..7b7d914 --- /dev/null +++ b/Source/Patches/GameObjects/PlantCardPackageBuilder_Patch.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlantCardPackageBuilder))] +public static class PlantCardPackageBuilder_Patch +{ + [HarmonyPatch(nameof(PlantCardPackageBuilder.UpdateText)), HarmonyPostfix] + private static void UpdateText(PlantCardPackageBuilder __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.text.text = StringStore.TranslateText(__instance.text.text); + __instance.text.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/PlantDamageMenu_Patch.cs b/Source/Patches/GameObjects/PlantDamageMenu_Patch.cs new file mode 100644 index 0000000..e0ecb4c --- /dev/null +++ b/Source/Patches/GameObjects/PlantDamageMenu_Patch.cs @@ -0,0 +1,41 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlantDamageMenu))] +public static class PlantDamageMenu_Patch +{ + public static void Awake(BaseMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == text.text).Key; + + text.text = StringStore.TranslationString.ContainsKey(originalKey + "_RM") + ? StringStore.TranslateText(originalKey + "_RM") + : StringStore.TranslateText(text.text); + + text.font = fontAsset; + } + } + + [HarmonyPatch(nameof(PlantDamageMenu.Awake)), HarmonyPatch(nameof(PlantDamageMenu.InitCards)), HarmonyPostfix] + public static void InitCards(PlantDamageMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == text.text).Key; + + text.text = StringStore.TranslationString.ContainsKey(originalKey + "_RM") + ? StringStore.TranslateText(originalKey + "_RM") + : StringStore.TranslateText(text.text); + + text.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/PlantDataMenu_Patch.cs b/Source/Patches/GameObjects/PlantDataMenu_Patch.cs new file mode 100644 index 0000000..29b5eec --- /dev/null +++ b/Source/Patches/GameObjects/PlantDataMenu_Patch.cs @@ -0,0 +1,66 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlantDataMenu))] +public static class PlantDataMenu_Patch +{ + [HarmonyPatch(nameof(PlantDataMenu.Start)), HarmonyPostfix] + public static void Post_Start(PlantDataMenu __instance) => TranslatePlantDataMenu(__instance); +#if false + [HarmonyPatch(nameof(PlantDataMenu.Update)), HarmonyPostfix] + public static void Post_Update(PlantDataMenu __instance) => TranslatePlantDataMenu(__instance); +#endif + [HarmonyPatch(nameof(PlantDataMenu.InitDataFromPlant)), HarmonyPostfix] + public static void Post_InitDataFromPlant(PlantDataMenu __instance) => TranslatePlantDataMenu(__instance); + + public static void TranslatePlantDataMenu(PlantDataMenu __instance) + { + if (!__instance) + return; + + var thePlantType = __instance.plant.thePlantType; + var plantName = Utils.GetPlantNameFromAlmanac(thePlantType); + + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance.nameText) + { + text.text = plantName; + text.font = fontAsset; + } + + foreach (var text in __instance.infoText) + { + var toTranslate = text.text; + var startColorTag = ""; + + const string ColorPattern = "(]+>)(.*?)()"; + var match = Regex.Match(toTranslate, ColorPattern); + + if (match.Success) + { + startColorTag = match.Groups[1].Value; + toTranslate = match.Groups[2].Value; + } + + var parts = toTranslate.Split("\n"); + var translatedParts = parts.Select(part => StringStore.TranslateText(part)).ToList(); + + var joinedTranslation = string.Join("\n", translatedParts); + + if (startColorTag != "") + text.text = startColorTag + joinedTranslation + ""; + else + text.text = joinedTranslation; + + text.font = fontAsset; + } + + foreach (var text in __instance.toggles.transform.Find("Viewport/Content/Toggles") + .GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/GameObjects/PlantInfoWindow_Patch.cs b/Source/Patches/GameObjects/PlantInfoWindow_Patch.cs new file mode 100644 index 0000000..ce93672 --- /dev/null +++ b/Source/Patches/GameObjects/PlantInfoWindow_Patch.cs @@ -0,0 +1,43 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlantInfoWindow))] +public static class PlantInfoWindow_Patch +{ + [HarmonyPatch(nameof(PlantInfoWindow.InitText)), HarmonyPostfix] + private static void InitText(PlantInfoWindow __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var thePlant = __instance.plant; + + foreach (var txt in __instance.GetComponentsInChildren()) + { + if (txt.name.Contains("Introduce") && thePlant != null) + { + var thePlantType = thePlant.thePlantType; + txt.text = StringStore.TranslateText(txt.text); + + var text = txt.text; + var lines = text.Split("\n"); + + lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType); + var updatedText = string.Join("\n", lines); + + txt.text = updatedText; + } + else + txt.text = StringStore.TranslateText(txt.text); + + txt.font = fontAsset; + } + + var parentWindowTransform = __instance.transform.parent; + var returnPlantTransform = parentWindowTransform.FindChild("Close"); + + foreach (var txt in returnPlantTransform.GetComponentsInChildren()) + txt.text = StringStore.TranslateText("合上"); + } +} diff --git a/Source/Patches/GameObjects/PlayerSaveMenu_Patch.cs b/Source/Patches/GameObjects/PlayerSaveMenu_Patch.cs new file mode 100644 index 0000000..a16af80 --- /dev/null +++ b/Source/Patches/GameObjects/PlayerSaveMenu_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlayerSaveMenu))] +public static class PlayerSaveMenu_Patch +{ + [HarmonyPatch(nameof(PlayerSaveMenu.CreatePlayerData)), HarmonyPostfix] + public static void CreatePlayerData(PlayerSaveMenu __instance) => TranslateCreatePlayerSaveMenu(); + + [HarmonyPatch(nameof(PlayerSaveMenu.ResetName)), HarmonyPostfix] + public static void ResetName(PlayerSaveMenu __instance) => TranslateCreatePlayerSaveMenu(); + + public static void TranslateCreatePlayerSaveMenu() + { + var reNameMenuTransform = GameAPP.canvasUp.Find("ReNameMenu(Clone)"); + + if (reNameMenuTransform.TryGetComponent(out var reNameMenu)) + reNameMenu.title.text = StringStore.TranslateText(reNameMenu.title.text); + } +} diff --git a/Source/Patches/GameObjects/PlayerShootingMenu_Patch.cs b/Source/Patches/GameObjects/PlayerShootingMenu_Patch.cs new file mode 100644 index 0000000..bf0bb3e --- /dev/null +++ b/Source/Patches/GameObjects/PlayerShootingMenu_Patch.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlayerShootingMenu))] +public static class PlayerShootingMenu_Patch +{ + [HarmonyPatch(nameof(PlayerShootingMenu.Update)), HarmonyPostfix] + private static void Update(PlayerShootingMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(PlayerShootingMenu.Refresh)), HarmonyPostfix] + private static void Refresh(PlayerShootingMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var refreshTransform = __instance.transform.FindChild("Button"); + + foreach (var text in refreshTransform.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + text.autoSizeTextContainer = false; + } + } +} diff --git a/Source/Patches/GameObjects/PlayerShootingWindow_Patch.cs b/Source/Patches/GameObjects/PlayerShootingWindow_Patch.cs new file mode 100644 index 0000000..3b7be3f --- /dev/null +++ b/Source/Patches/GameObjects/PlayerShootingWindow_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(PlayerShootingWindow))] +public static class PlayerShootingWindow_Patch +{ + [HarmonyPatch(nameof(PlayerShootingWindow.SetType)), HarmonyPostfix] + private static void SetType(PlayerShootingWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(PlayerShootingWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(PlayerShootingWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/ReNameMenu_Patch.cs b/Source/Patches/GameObjects/ReNameMenu_Patch.cs new file mode 100644 index 0000000..e7c0f86 --- /dev/null +++ b/Source/Patches/GameObjects/ReNameMenu_Patch.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ReNameMenu))] +public static class ReNameMenu_Patch +{ + [HarmonyPatch(nameof(ReNameMenu.SetTitle)), HarmonyPostfix] + public static void SetTitle(ReNameMenu __instance) => + __instance.title.text = StringStore.TranslateText(__instance.title.text); + + [HarmonyPatch(nameof(ReNameMenu.SetInputText)), HarmonyPostfix] + public static void SetInputText(ReNameMenu __instance) => + __instance.input.text = StringStore.TranslateText(__instance.input.text); +} diff --git a/Source/Patches/GameObjects/RogueCardWindow_Patch.cs b/Source/Patches/GameObjects/RogueCardWindow_Patch.cs new file mode 100644 index 0000000..fe3ed8b --- /dev/null +++ b/Source/Patches/GameObjects/RogueCardWindow_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(RogueCardWindow))] +public static class RogueCardWindow_Patch +{ + [HarmonyPatch(nameof(RogueCardWindow.InitCard)), HarmonyPostfix] + private static void InitCard(RogueCardWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(RogueCardWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(RogueCardWindow __instance) + { + var introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/RogueStartMenu_Patch.cs b/Source/Patches/GameObjects/RogueStartMenu_Patch.cs new file mode 100644 index 0000000..564c177 --- /dev/null +++ b/Source/Patches/GameObjects/RogueStartMenu_Patch.cs @@ -0,0 +1,32 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(RogueStartMenu))] +public static class RogueStartMenu_Patch +{ + [HarmonyPatch(nameof(RogueStartMenu.SetLeader)), HarmonyPostfix] + private static void SetLeader(RogueStartMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(RogueStartMenu.EnterGame)), HarmonyPostfix] + private static void EnterGame(RogueStartMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/GameObjects/SeedLibrary_Patch.cs b/Source/Patches/GameObjects/SeedLibrary_Patch.cs new file mode 100644 index 0000000..8a8ff13 --- /dev/null +++ b/Source/Patches/GameObjects/SeedLibrary_Patch.cs @@ -0,0 +1,48 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(SeedLibrary))] +public static class SeedLibrary_Patch +{ + [HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode)), HarmonyPostfix] + private static void ChangeSafeMode(SeedLibrary __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + + //foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + //{ + // txt.text = StringStore.TranslateText(txt.text); + // txt.font = fontAsset; + //} + + var safetyBoxButtonTransform = __instance.transform.FindChild("SafeBox").FindChild("StartSafeMode"); + + if (__instance.safeMode || safetyBoxButtonTransform == null) + return; + + foreach (var txt in safetyBoxButtonTransform.GetComponentsInChildren()) + txt.text = StringStore.TranslateText("合上"); + } + + [HarmonyPatch(nameof(SeedLibrary.Start)), HarmonyPatch(nameof(SeedLibrary.SetAllCards)), HarmonyPostfix] + private static void SetAllCards(SeedLibrary __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + //foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + //{ + // txt.text = StringStore.TranslateText(txt.text); + // txt.font = fontAsset; + //} + + foreach (var txt in __instance.page.GetComponentsInChildren(true)) + { + txt.font = fontAsset; + + if (!Utils.CheckForUntranslatedText(txt.text)) + txt.text = StringStore.TranslateText(txt.text); + } + } +} diff --git a/Source/Patches/GameObjects/ShootingMenu_Patch.cs b/Source/Patches/GameObjects/ShootingMenu_Patch.cs new file mode 100644 index 0000000..1f85c77 --- /dev/null +++ b/Source/Patches/GameObjects/ShootingMenu_Patch.cs @@ -0,0 +1,22 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ShootingMenu))] +public static class ShootingMenu_Patch +{ + [HarmonyPatch(nameof(ShootingMenu.Update)), HarmonyPostfix] + private static void Update(ShootingMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/GameObjects/ShootingSelectWindow_Patch.cs b/Source/Patches/GameObjects/ShootingSelectWindow_Patch.cs new file mode 100644 index 0000000..04c919a --- /dev/null +++ b/Source/Patches/GameObjects/ShootingSelectWindow_Patch.cs @@ -0,0 +1,65 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(ShootingSelectWindow))] +public static class ShootingSelectWindow_Patch +{ + [HarmonyPatch(nameof(ShootingSelectWindow.InitPlantType)), HarmonyPostfix] + private static void InitCard(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(ShootingSelectWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(ShootingSelectWindow.SetUpgradePlantTypes)), HarmonyPostfix] + private static void SetUpgradePlantTypes(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(ShootingSelectWindow.GetMaxIndexInRoutes)), HarmonyPostfix] + private static void GetMaxIndexInRoutes(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(ShootingSelectWindow.Start)), HarmonyPostfix] + private static void Start(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + var introduceText = introduceTransform.GetComponent(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } +} +#endif diff --git a/Source/Patches/GameObjects/SpriteRenderer_Patch.cs b/Source/Patches/GameObjects/SpriteRenderer_Patch.cs new file mode 100644 index 0000000..d2e35d9 --- /dev/null +++ b/Source/Patches/GameObjects/SpriteRenderer_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(SpriteRenderer))] +public static class SpriteRenderer_Patch +{ + [HarmonyPatch(nameof(SpriteRenderer.InvokeSpriteChanged)), HarmonyPostfix] + private static void InvokeSpriteChanged(SpriteRenderer __instance) + { + if (__instance.sprite == null) + return; + + if (TextureStore.SpriteDict.ContainsKey(__instance.sprite.name) && __instance.drawMode != SpriteDrawMode.Sliced) + __instance.drawMode = SpriteDrawMode.Sliced; + } +} diff --git a/Source/Patches/GameObjects/TowerOption_Patch.cs b/Source/Patches/GameObjects/TowerOption_Patch.cs new file mode 100644 index 0000000..6277c0b --- /dev/null +++ b/Source/Patches/GameObjects/TowerOption_Patch.cs @@ -0,0 +1,18 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(TowerOption))] +public static class TowerOption_Patch +{ + [HarmonyPatch(nameof(TowerOption.Start)), HarmonyPostfix] + private static void Postfix_Start(TowerOption __instance) + { + //TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren(true); + __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); + __instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} +#endif diff --git a/Source/Patches/GameObjects/TowerUpgradeMenu_Patch.cs b/Source/Patches/GameObjects/TowerUpgradeMenu_Patch.cs new file mode 100644 index 0000000..ee77a93 --- /dev/null +++ b/Source/Patches/GameObjects/TowerUpgradeMenu_Patch.cs @@ -0,0 +1,34 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(TowerUpgradeMenu))] +public static class TowerUpgradeMenu_Patch +{ + [HarmonyPatch(nameof(TowerUpgradeMenu.Awake)), HarmonyPostfix] + private static void Awake(TowerUpgradeMenu __instance) + { + __instance.des.text = StringStore.TranslateText(__instance.des.text); + __instance.des2.text = StringStore.TranslateText(__instance.des2.text); + + foreach (var text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } + + [HarmonyPatch(nameof(TowerUpgradeMenu.SetText)), HarmonyPostfix] + private static void SetText(TowerUpgradeMenu __instance) + { + __instance.des.text = StringStore.TranslateText(__instance.des.text); + __instance.des2.text = StringStore.TranslateText(__instance.des2.text); + + foreach (var text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} diff --git a/Source/Patches/GameObjects/UIDifficulty_Patch.cs b/Source/Patches/GameObjects/UIDifficulty_Patch.cs new file mode 100644 index 0000000..fafb786 --- /dev/null +++ b/Source/Patches/GameObjects/UIDifficulty_Patch.cs @@ -0,0 +1,17 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(UIDifficulty))] +public static class UIDifficulty_Patch +{ + [HarmonyPatch(nameof(UIDifficulty.Update)), HarmonyPostfix] + private static void Update(UIDifficulty __instance) + { + if (!Utils.CheckForUntranslatedText(__instance.t.text)) + return; + + __instance.t.text = StringStore.TranslateText(__instance.t.text); + } +} diff --git a/Source/Patches/GameObjects/UIZombieNum_Patch.cs b/Source/Patches/GameObjects/UIZombieNum_Patch.cs new file mode 100644 index 0000000..cebf27a --- /dev/null +++ b/Source/Patches/GameObjects/UIZombieNum_Patch.cs @@ -0,0 +1,31 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(UIZombieNum))] +public static class UIZombieNum_Patch +{ + [HarmonyPatch(nameof(UIZombieNum.Update)), HarmonyPostfix] + private static void Update(UIZombieNum __instance) + { + TMP_FontAsset fontAsset; + + if (ModFeatures.IsMultiLanguage) + { + fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + __instance.t.text = StringStore.TranslateText(__instance.t.text); + } + else + { + fontAsset = FontStore.LoadTMPFont(); + + __instance.t.text = string.Format( + StringStore.PatchesStore["Zombies"]["Spanish"] + " {0}", + Board.Instance.enermyCount + ); + } + + __instance.t.font = fontAsset; + } +} diff --git a/Source/Patches/GameObjects/WarningMenu_Patch.cs b/Source/Patches/GameObjects/WarningMenu_Patch.cs new file mode 100644 index 0000000..531158b --- /dev/null +++ b/Source/Patches/GameObjects/WarningMenu_Patch.cs @@ -0,0 +1,77 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.GameObjects; + +[HarmonyPatch(typeof(WarningMenu))] +public static class WarningMenu_Patch +{ + [HarmonyPatch(nameof(WarningMenu.Start)), HarmonyPostfix] + private static void Start(WarningMenu __instance) => TranslateInvestmentWarning(__instance); + + [HarmonyPatch(nameof(WarningMenu.EnableChallengeMode)), HarmonyPostfix] + private static void EnableChallengeMode(WarningMenu __instance) => TranslateInvestmentWarning(__instance); + + [HarmonyPatch(nameof(WarningMenu.Cancel)), HarmonyPostfix] + private static void Cancel(WarningMenu __instance) => TranslateInvestmentWarning(__instance); + + public static void TranslateInvestmentWarning(WarningMenu __instance) + { + var normalModeTransform = __instance.transform.Find("Normal"); + var challengeModeTransform = __instance.transform.Find("Challenge"); + + if (normalModeTransform != null) + { + var text = normalModeTransform.Find("text").GetComponent(); + var textShadow = normalModeTransform.Find("text (1)").GetComponent(); + + text.text = StringStore.TranslationString.ContainsKey("普通模式_IV") + ? StringStore.TranslateText("普通模式_IV") + : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); + + text.alignment = TextAlignmentOptions.Center; + text.autoSizeTextContainer = true; + textShadow.text = Utils.RemoveColorTags(text.text); + textShadow.alignment = TextAlignmentOptions.Center; + textShadow.autoSizeTextContainer = true; + } + + if (challengeModeTransform != null) + { + var text = challengeModeTransform.Find("text").GetComponent(); + var textShadow = challengeModeTransform.Find("text (1)").GetComponent(); + + text.text = StringStore.TranslationString.ContainsKey("诅咒模式_IV") + ? StringStore.TranslateText("诅咒模式_IV") + : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); + + text.alignment = TextAlignmentOptions.Center; + text.autoSizeTextContainer = true; + textShadow.text = Utils.RemoveColorTags(text.text); + textShadow.alignment = TextAlignmentOptions.Center; + textShadow.autoSizeTextContainer = true; + } + + if (__instance.tutor != null) + foreach (var text in __instance.tutor.GetComponentsInChildren() + .Where(text => text.gameObject.name == "text1")) + { + text.text = StringStore.TranslateText(text.text); + + if (text.transform.parent.Find("text").TryGetComponent(out var textShadow)) + textShadow.text = Utils.RemoveColorTags(text.text); + } + + if (__instance.challenge == null) + return; + + foreach (var text in __instance.challenge.GetComponentsInChildren() + .Where(text => text.gameObject.name == "text1")) + { + text.text = StringStore.TranslateText(text.text); + + if (text.transform.parent.Find("text").TryGetComponent(out var textShadow)) + textShadow.text = Utils.RemoveColorTags(text.text); + } + } +} diff --git a/Source/Patches/Managers/AbyssDevelopMenu_Patch.cs b/Source/Patches/Managers/AbyssDevelopMenu_Patch.cs new file mode 100644 index 0000000..59f55d7 --- /dev/null +++ b/Source/Patches/Managers/AbyssDevelopMenu_Patch.cs @@ -0,0 +1,17 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(AbyssDevelopMenu))] +public static class AbyssDevelopMenu_Patch +{ + [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo)), HarmonyPostfix] + private static void UpdateInfo(AbyssDevelopMenu __instance) + { + __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); + __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); + } +} +#endif diff --git a/Source/Patches/Managers/AbyssMenu2_Patch.cs b/Source/Patches/Managers/AbyssMenu2_Patch.cs new file mode 100644 index 0000000..7c9f617 --- /dev/null +++ b/Source/Patches/Managers/AbyssMenu2_Patch.cs @@ -0,0 +1,86 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(AbyssMenu2))] +public static class AbyssMenu2_Patch +{ + [HarmonyPatch(nameof(AbyssMenu2.Start)), HarmonyPostfix] + private static void Start(AbyssMenu2 __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); + __instance.buffCountText.font = fontAsset; + + __instance.money.text = StringStore.TranslateText(__instance.money.text); + __instance.money.font = fontAsset; + + __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); + __instance.refreshText.font = fontAsset; + + __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); + __instance.statistics.font = fontAsset; + + Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; + + if (buffTextTransform != null) + StringStore.TranslateTextTransform(buffTextTransform); + + Transform moneyTransform = __instance.transform.FindChild("Money").transform; + + if (moneyTransform != null) + StringStore.TranslateTextTransform(moneyTransform); + + Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; + + if (buffCountTextTransform != null) + StringStore.TranslateTextTransform(buffCountTextTransform); + + Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; + + if (refreshTextTransform != null) + StringStore.TranslateTextTransform(refreshTextTransform); + } + + [HarmonyPatch(nameof(AbyssMenu2.Awake)), HarmonyPostfix] + private static void Awake(AbyssMenu2 __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); + __instance.buffCountText.font = fontAsset; + + __instance.money.text = StringStore.TranslateText(__instance.money.text); + __instance.money.font = fontAsset; + + __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); + __instance.refreshText.font = fontAsset; + + __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); + __instance.statistics.font = fontAsset; + + Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; + + if (buffTextTransform != null) + StringStore.TranslateTextTransform(buffTextTransform); + + Transform moneyTransform = __instance.transform.FindChild("Money").transform; + + if (moneyTransform != null) + StringStore.TranslateTextTransform(moneyTransform); + + Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; + + if (buffCountTextTransform != null) + StringStore.TranslateTextTransform(buffCountTextTransform); + + Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; + + if (refreshTextTransform != null) + StringStore.TranslateTextTransform(refreshTextTransform); + } +} +#endif diff --git a/Source/Patches/Managers/AbyssMenu_Patch.cs b/Source/Patches/Managers/AbyssMenu_Patch.cs new file mode 100644 index 0000000..9ee9d8c --- /dev/null +++ b/Source/Patches/Managers/AbyssMenu_Patch.cs @@ -0,0 +1,22 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(AbyssMenu))] +public static class AbyssMenu_Patch +{ + [HarmonyPatch(nameof(AbyssMenu.Awake)), HarmonyPostfix] + private static void Awake(AbyssMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.rukous) + { + txt.text = StringStore.TranslateText(txt.text, false); + txt.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/Managers/AlmanacMgrZombie_Patch.cs b/Source/Patches/Managers/AlmanacMgrZombie_Patch.cs new file mode 100644 index 0000000..02f472a --- /dev/null +++ b/Source/Patches/Managers/AlmanacMgrZombie_Patch.cs @@ -0,0 +1,95 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.FileLoader; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(AlmanacMgrZombie))] +public static partial class AlmanacMgrZombie_Patch +{ + [HarmonyPatch(nameof(AlmanacMgrZombie.InitNameAndInfoFromJson)), HarmonyPostfix] + private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance) + { + var (almanacDir, currentLanguage) = ModFeatures.IsMultiLanguage + ? (GetAssetDir(AssetType.Almanac, Utils.Language), Utils.Language.ToString()) + : (GetAssetDir(AssetType.Almanac), "English"); + + var path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); + var moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json"); + + if (!File.Exists(path)) + { + Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); + return; + } + + var json = File.ReadAllText(path); + var hasAlmanacFont = false; + TMP_FontAsset almanacFontAsset = null; + + if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || + FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) + { + almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); + hasAlmanacFont = true; + } + + FontStore.LoadTMPFont(ModFeatures.IsMultiLanguage ? Utils.Language.ToString() : null); + TextMeshPro component = __instance.info.GetComponent(); + TextMeshPro component2 = __instance.zombieName.GetComponent(); + TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent(); + + var zombieData = JsonUtility.FromJson(json); + + foreach (ZombieInfo zombieInfo in zombieData.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; + component.font = hasAlmanacFont ? almanacFontAsset : fontAsset; + component2.font = fontAsset; + component3.font = fontAsset; + } + + if (!File.Exists(moddedPath)) + return; + + var moddedJson = File.ReadAllText(moddedPath); + + var moddedZombieData = JsonUtility.FromJson(moddedJson); + + foreach (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; + component.font = hasAlmanacFont ? almanacFontAsset : fontAsset; + component2.font = fontAsset; + component3.font = fontAsset; + } + } + + [HarmonyPatch(nameof(AlmanacMgrZombie.OnMouseDown)), HarmonyPrefix] + private static bool OnMouseDown(AlmanacMgrZombie __instance) + { + TextMeshPro component = __instance.info.GetComponent(); + + if (component == null) + return true; + + component.pageToDisplay = + component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; + + return false; + } +} +#endif diff --git a/Source/Patches/Managers/AlmanacPlantBank_Patch.cs b/Source/Patches/Managers/AlmanacPlantBank_Patch.cs new file mode 100644 index 0000000..023dc57 --- /dev/null +++ b/Source/Patches/Managers/AlmanacPlantBank_Patch.cs @@ -0,0 +1,191 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.FileLoader; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(AlmanacPlantBank))] +public static partial class AlmanacPlantBank_Patch +{ + [HarmonyPatch(nameof(AlmanacPlantBank.InitNameAndInfoFromJson)), HarmonyPostfix] + private static void InitNameAndInfoFromJson(Il2Cpp.AlmanacPlantBank __instance) + { + var (almanacDir, currentLanguage) = ModFeatures.IsMultiLanguage + ? (GetAssetDir(AssetType.Almanac, Utils.Language), Utils.Language.ToString()) + : (GetAssetDir(AssetType.Almanac), "English"); + + var path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); + var moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json"); + + if (!File.Exists(path)) + { + Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); + return; + } + + var json = File.ReadAllText(path); + var hasAlmanacFont = false; + TMP_FontAsset almanacFontAsset = null; + + if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || + FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage)) + { + almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage); + hasAlmanacFont = true; + } + + var fontAsset = ModFeatures.IsMultiLanguage + ? FontStore.LoadTMPFont(Utils.Language.ToString()) + : FontStore.LoadTMPFont(); + + TextMeshPro component = __instance.introduce.GetComponent(); + TextMeshPro component2 = __instance.plantName.GetComponent(); + TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent(); + TextMeshPro component4 = __instance.cost.GetComponent(); + + AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson(json); + + foreach (var plantInfo in plantData.plants) + { + if (plantInfo.seedType != __instance.theSeedType || string.IsNullOrEmpty(plantInfo.name)) + continue; + + component.autoSizeTextContainer = false; + component.text = plantInfo.info + "\n\n" + plantInfo.introduce; + component.overflowMode = TextOverflowModes.Page; + + // fix dimensions for cost text + component.rectTransform.offsetMax = new(component.rectTransform.offsetMax.x, 27.3839f); + component.rectTransform.offsetMin = new(component.rectTransform.offsetMin.x, -29.3079f); + component.rectTransform.sizeDelta = new(component.rectTransform.sizeDelta.x, 50.917f); + + component.transform.localPosition = new( + 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 ?? string.Empty); + 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; + } + + if (!File.Exists(moddedPath)) + return; + + var moddedJson = File.ReadAllText(moddedPath); + AlmanacPlantBank.PlantData moddedPlantData = JsonUtility.FromJson(moddedJson); + + foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants) + { + if (plantInfo.seedType != __instance.theSeedType || string.IsNullOrEmpty(plantInfo.name)) + continue; + + component.autoSizeTextContainer = false; + component.text = plantInfo.info + "\n\n" + plantInfo.introduce; + component.overflowMode = TextOverflowModes.Page; + + // fix dimensions for cost text + component.rectTransform.offsetMax = new(component.rectTransform.offsetMax.x, 27.3839f); + component.rectTransform.offsetMin = new(component.rectTransform.offsetMin.x, -29.3079f); + component.rectTransform.sizeDelta = new(component.rectTransform.sizeDelta.x, 50.917f); + + component.transform.localPosition = new( + 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 ?? string.Empty); + 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; + } + } + + [HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown)), HarmonyPrefix] + private static bool OnMouseDown(AlmanacPlantBank __instance) + { + TextMeshPro component = __instance.introduce.GetComponent(); + + if (component == null) + return true; + + component.pageToDisplay = + component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1; + + return false; + } + + [HarmonyPatch(nameof(AlmanacPlantBank.PVPInit)), HarmonyPostfix] // ReSharper disable once InconsistentNaming + private static void PVPInit(Il2Cpp.AlmanacPlantBank __instance) + { + TextMeshPro component = __instance.introduce.GetComponent(); + + if (component != null) + component.autoSizeTextContainer = false; + + Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0); + + if (banTransform != null) + banTransform.GetComponent().text = + StringStore.TranslateText(banTransform.GetComponent().text); + } + + [HarmonyPatch(nameof(AlmanacPlantBank.Start)), HarmonyPostfix] + public static void Post_Start(AlmanacPlantBank __instance) + { + GameObject skinTextObj = __instance.skinButton.transform.GetChild(0).gameObject; + + var skinShadowTextObj = + UnityEngine.Object.Instantiate(skinTextObj, parent: __instance.skinButton.transform); + + var skinShadowText = skinShadowTextObj.GetComponent(); + skinShadowText.text = StringStore.TranslateText("换肤_S"); + skinShadowText.sortingOrder -= 2; + skinShadowTextObj.transform.Translate(new(0.015f, -0.015f, 0)); + skinTextObj.transform.Translate(new(-0.022f, 0)); + skinShadowTextObj.transform.Translate(new(-0.022f, 0)); + __instance.skinButton.transform.localScale /= 1.75f; + __instance.skinButton.transform.Translate(new Vector3(-0.075f, -0.15f, 0)); + __instance.skinButton.transform.GetChild(1).Translate(new Vector3(0.35f, 0)); + __instance.skinButton.transform.GetChild(2).Translate(new Vector3(-0.35f, 0)); + } +} +#endif diff --git a/Source/Patches/Managers/CanvasUpUI_Patch.cs b/Source/Patches/Managers/CanvasUpUI_Patch.cs new file mode 100644 index 0000000..bcb963c --- /dev/null +++ b/Source/Patches/Managers/CanvasUpUI_Patch.cs @@ -0,0 +1,30 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(CanvasUpUI))] +public static class CanvasUpUI_Patch +{ + [HarmonyPatch(nameof(CanvasUpUI.Start)), HarmonyPostfix] + public static void Start(CanvasUpUI __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var text in __instance.GetComponentsInChildren()) + { + var originalKey = StringStore.TranslationString + .FirstOrDefault(x => x.Value == text.text || x.Value.Replace("\n", "") == text.text) + .Key; + + text.text = StringStore.TranslationString.ContainsKey(originalKey + "_MG") + ? StringStore.TranslateText(originalKey + "_MG") + : StringStore.TranslateText(text.text); + + if (text.gameObject.name.Contains("LevelName")) + text.text = text.text.Replace("\n", " "); + + text.font = fontAsset; + } + } +} diff --git a/Source/Patches/Managers/ChessManager_Patch.cs b/Source/Patches/Managers/ChessManager_Patch.cs new file mode 100644 index 0000000..2afda22 --- /dev/null +++ b/Source/Patches/Managers/ChessManager_Patch.cs @@ -0,0 +1,29 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(ChessManager))] +public static class ChessManager_Patch +{ + [HarmonyPatch(nameof(ChessManager.Start)), HarmonyPostfix] + private static void Postfix_Start(ChessManager __instance) + { + __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); + __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(ChessManager.Update)), HarmonyPostfix] + private static void Postfix_Update(ChessManager __instance) + { + __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); + __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + [HarmonyPatch(nameof(ChessManager.UpdateText)), HarmonyPostfix] + private static void Postfix_UpdateText(ChessManager __instance) + { + __instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text); + __instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/Patches/Managers/CustomLevelShower_Patch.cs b/Source/Patches/Managers/CustomLevelShower_Patch.cs new file mode 100644 index 0000000..f611346 --- /dev/null +++ b/Source/Patches/Managers/CustomLevelShower_Patch.cs @@ -0,0 +1,17 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(CustomLevelShower))] +public static class CustomLevelShower_Patch +{ + [HarmonyPatch(nameof(CustomLevelShower.Show)), HarmonyPostfix] + private static void Show(CustomLevelShower __instance) + { + foreach (var transform in __instance.pages) + StringStore.TranslateTextTransform(transform); + } +} +#endif diff --git a/Source/Patches/Managers/DifficultyMgr_Patch.cs b/Source/Patches/Managers/DifficultyMgr_Patch.cs new file mode 100644 index 0000000..e2f2a15 --- /dev/null +++ b/Source/Patches/Managers/DifficultyMgr_Patch.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(DifficultyMgr))] +public static class DifficultyMgr_Patch +{ + [HarmonyPatch(nameof(DifficultyMgr.Update)), HarmonyPostfix] + private static void DifficultyMgr_Update(DifficultyMgr __instance) + { + __instance.t = StringStore.TranslateText(__instance.t); + __instance.t.autoSizeTextContainer = false; + } +} diff --git a/Source/Patches/Managers/DrawCardManager_Patch.cs b/Source/Patches/Managers/DrawCardManager_Patch.cs new file mode 100644 index 0000000..bb2f5a5 --- /dev/null +++ b/Source/Patches/Managers/DrawCardManager_Patch.cs @@ -0,0 +1,64 @@ +using System.Text.RegularExpressions; +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(DrawCardManager))] +public static class DrawCardManager_Patch +{ +#pragma warning disable CA2211 + public static TMP_FontAsset FontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); +#pragma warning restore CA2211 + [HarmonyPatch(nameof(DrawCardManager.Awake)), HarmonyPostfix] + private static void Awake(DrawCardManager __instance) => + FontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + [HarmonyPatch(nameof(DrawCardManager.UpdateText)), HarmonyPostfix] + private static void Postfix_UpdateText(DrawCardManager __instance) + { + var regexPair = new KeyValuePair( + "抽取次数:\n(\\d+)/(\\d+)\n当前up植物:\n([^\\s]+)\nup刷新倒计时:\n(\\d+)", + "Draw Count:\n{0}/{1}\nCurrent Up:\n{2}\nNext Up in: \n{3}s" + ); + + foreach (var txt in __instance.texts) + if (Regex.IsMatch(txt.text, regexPair.Key)) + { + txt.text = TranslateGashaponText(txt.text, regexPair.Key, regexPair.Value, __instance.up); + txt.font = FontAsset; + } + } + + public static string TranslateGashaponText(string originalText, string pattern, string fallback, PlantType up) + { + var res = ""; + var match = Regex.Match(originalText, pattern); + + if (!match.Success) + return res; + + var groups = match.Groups; + var fStr = StringStore.TranslationStringRegex.GetValueOrDefault(pattern, fallback); + List dynamicParts = []; + + for (var i = 1; i < groups.Count; i++) + { + var group = groups[i].Value; + + var translatedGroup = i == 3 && up != PlantType.Peashooter + ? Utils.GetPlantNameFromAlmanac(up) + : StringStore.TranslateText(group); + + dynamicParts.Add(translatedGroup); + } + + res = string.Format(fStr, [..dynamicParts]); + + return res; + } +#if false + [HarmonyPatch(nameof(DrawCardManager.Update)), HarmonyPostfix] + private static void Postfix_Update(DrawCardManager __instance) => Postfix_UpdateText(__instance); +#endif +} diff --git a/Source/Patches/Managers/EndlessMgr_Patch.cs b/Source/Patches/Managers/EndlessMgr_Patch.cs new file mode 100644 index 0000000..f58d512 --- /dev/null +++ b/Source/Patches/Managers/EndlessMgr_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(EndlessMgr))] +public static class EndlessMgr_Patch +{ + [HarmonyPatch(nameof(EndlessMgr.Awake)), HarmonyPostfix] + private static void Awake(EndlessMgr __instance) + { + var textTransform = __instance.transform.GetChild(2); + + if (textTransform == null || !textTransform.gameObject.activeSelf) + return; + + var textTMP = textTransform.GetComponent(); + + if (textTMP != null) + StringStore.TranslateText(textTMP); + } +} diff --git a/Source/Patches/Managers/Garden_Patch.cs b/Source/Patches/Managers/Garden_Patch.cs new file mode 100644 index 0000000..25caefd --- /dev/null +++ b/Source/Patches/Managers/Garden_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(Garden))] +public static class Garden_Patch +{ + [HarmonyPatch(nameof(Garden.Awake)), HarmonyPostfix] + private static void Awake(Garden __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} diff --git a/Source/Patches/Managers/IZBottomMenu_Patch.cs b/Source/Patches/Managers/IZBottomMenu_Patch.cs new file mode 100644 index 0000000..9a3ba34 --- /dev/null +++ b/Source/Patches/Managers/IZBottomMenu_Patch.cs @@ -0,0 +1,47 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(IZBottomMenu))] +public static class IZBottomMenu_Patch +{ + [HarmonyPatch(nameof(IZBottomMenu.ChangeString)), HarmonyPostfix] + public static void ChangeStringz(IZBottomMenu __instance) + { + foreach (var text in __instance.levelName) + { + var fStr = StringStore.TranslationStringRegex[@"([^\s]+),推荐难度:(\d+)"]; + var parts = text.text.Split(",推荐难度:"); + + if (new Regex(@"([^\s]+),推荐难度:(\d+)").IsMatch(text.text)) + { + var customName = StringStore.TranslationString.ContainsKey(parts[0] + "_IZ") + ? parts[0] + "_IZ" + : parts[0]; + + text.text = string.Format(fStr, StringStore.TranslateText(customName), parts[1]); + } + + text.text = StringStore.TranslateText(text.text); + text.text = text.text.Replace("\n", " "); + } + } + + [HarmonyPatch(nameof(IZBottomMenu.SetLevelName)), HarmonyPostfix] + public static void SetLevelName(IZBottomMenu __instance) + { + foreach (var text in __instance.levelName) + { + var fStr = StringStore.TranslationStringRegex[@"([^\s]+),推荐难度:(\d+)"]; + var parts = text.text.Split(",推荐难度:"); + + if (new Regex(@"([^\s]+),推荐难度:(\d+)").IsMatch(text.text)) + text.text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]); + + text.text = StringStore.TranslateText(text.text); + text.text = text.text.Replace("\n", " "); + } + } +} diff --git a/Source/Patches/Managers/InGameUI_Patch.cs b/Source/Patches/Managers/InGameUI_Patch.cs new file mode 100644 index 0000000..f5c588a --- /dev/null +++ b/Source/Patches/Managers/InGameUI_Patch.cs @@ -0,0 +1,81 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.BaseTextObjects; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(InGameUI))] +public static class InGameUI_Patch +{ + public const string TravelAdventurePattern = "^旅行冒险 ([^\\s:]+)"; + public const string TravelAdventureFallback = "Odyssey Adventure: {0}"; + + [HarmonyPatch(nameof(InGameUI.Start)), HarmonyPostfix] + private static void Start(InGameUI __instance) => SetLevelName(__instance); + + [HarmonyPatch(nameof(InGameUI.SetUniqueText)), HarmonyPostfix] + private static void SetUniqueText(InGameUI __instance) => SetLevelName(__instance); + + [HarmonyPatch(nameof(InGameUI.SetLevelName)), HarmonyPostfix] + private static void SetLevelName(InGameUI __instance) + { + foreach (var text in __instance.levelNameText) + { + if (text.text == null) + continue; + + var originalText = text.text; + text.text = text.text.Replace("\n", " "); + + var checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)"); + var checkTravelAdv = new Regex(TravelAdventurePattern); + + if (checkTravelAdv.IsMatch(originalText)) + text.text = InGameText_Patch.TranslatePlantNameParts( + originalText, + TravelAdventurePattern, + TravelAdventureFallback + ); + else if (text.text.Contains("配方:") && !checkFusionChallenge.IsMatch(text.text)) + { + var lines = text.text.Split(":"); + lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]); + + if (lines[1] == "") + { + Log.LogError("Couldn't find plant! (Fusion Showcase)"); + lines[1] = StringStore.TranslateText(lines[1]); + } + + text.text = StringStore.TranslateText("配方:") + lines[1]; + text.autoSizeTextContainer = true; + } + else + { + text.text = StringStore.TranslationString.ContainsKey(text.text + "_MG") + ? StringStore.TranslateText(text.text + "_MG") + : StringStore.TranslateText(text.text); + + text.text = text.text.Replace("\n", " "); + } + } + } +#if false + [HarmonyPatch(nameof(InGameUI.Update)), HarmonyPostfix] + private static void Update(InGameUI __instance) + { + if (!__instance.board.boardTag.isDrawCards) + return; + + KeyValuePair regexPair = new( + "抽取次数:\n(\\d+)/(\\d+)\n当前up植物:\n([^\\s]+)\nup刷新倒计时:\n(\\d+)", + "Draw Count:\n{0}/{1}\nCurrent Up:\n{2}\nNext Up in: \n{3}s" + ); + + foreach (var txt in __instance.DrawCardsHead.GetComponentsInChildren() + .Where(txt => Regex.IsMatch(txt.text, regexPair.Key))) + txt.text = InGameText_Patch.TranslatePlantNameParts(txt.text, regexPair.Key, regexPair.Value); + } +#endif +} diff --git a/Source/Patches/Managers/PVPScareyPot_Patch.cs b/Source/Patches/Managers/PVPScareyPot_Patch.cs new file mode 100644 index 0000000..ea68740 --- /dev/null +++ b/Source/Patches/Managers/PVPScareyPot_Patch.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(PVPScareyPot))] +public static class PvpScareyPotPatch +{ + [HarmonyPatch(nameof(PVPScareyPot.Awake)), HarmonyPatch(nameof(PVPScareyPot.Start)), + HarmonyPatch(nameof(PVPScareyPot.AutoRuleUpdate)), HarmonyPatch(nameof(PVPScareyPot.RandomCardUpdate)), + HarmonyPatch(nameof(PVPScareyPot.Update)), HarmonyPostfix] + public static void TranslatePlayerDatas(PVPScareyPot __instance) + { + TranslatePlayerData(__instance.player1); + TranslatePlayerData(__instance.player2); + TranslatePlayerData(__instance.currentPlayer); + } + + public static void TranslatePlayerData(PVPScareyPot.PlayerData playerData) + { + if (playerData == null) + return; + + playerData.textMesh.text = StringStore.TranslateText(playerData.textMesh.text); + playerData.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } +} diff --git a/Source/Patches/Managers/SaveMenu_Patch.cs b/Source/Patches/Managers/SaveMenu_Patch.cs new file mode 100644 index 0000000..48edc73 --- /dev/null +++ b/Source/Patches/Managers/SaveMenu_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(SaveMenu))] +public static class SaveMenu_Patch +{ + [HarmonyPatch(nameof(SaveMenu.Start)), HarmonyPatch(nameof(SaveMenu.CreateLevelEnter)), + HarmonyPatch(nameof(SaveMenu.InitLevelSaveEnters)), HarmonyPostfix] + private static void Start(SaveMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.menuTitle.text = StringStore.TranslateText(__instance.menuTitle.text); + __instance.menuTitle.font = fontAsset; + + foreach (var enter in __instance.GetComponentsInChildren()) + LevelSaveEnter_Patch.TranslateEnter(enter); + } + + [HarmonyPatch(nameof(SaveMenu.OnEditSelectedButtonClicked)), HarmonyPostfix] + private static void OnEditSelectedButtonClicked(SaveMenu __instance) { } +} diff --git a/Source/Patches/Managers/Screen_Patch.cs b/Source/Patches/Managers/Screen_Patch.cs new file mode 100644 index 0000000..a96d277 --- /dev/null +++ b/Source/Patches/Managers/Screen_Patch.cs @@ -0,0 +1,13 @@ +using HarmonyLib; +using UnityEngine.EventSystems; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(Screen))] +public static class Screen_Patch +{ + [HarmonyPatch(nameof(Screen.SetResolution), typeof(int), typeof(int), typeof(bool)), HarmonyPrefix] + private static bool SetResolution(Screen __instance) => + EventSystem.current.currentSelectedGameObject == null || + !EventSystem.current.currentSelectedGameObject.TryGetComponent(out _); +} diff --git a/Source/Patches/Managers/TowerManager_Patch.cs b/Source/Patches/Managers/TowerManager_Patch.cs new file mode 100644 index 0000000..40f5fe1 --- /dev/null +++ b/Source/Patches/Managers/TowerManager_Patch.cs @@ -0,0 +1,18 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(TowerManager))] +public static class TowerManager_Patch +{ + public static readonly List UpdatedText = []; + + public static void UpdateText() + { + foreach (var transform in UpdatedText.Where(transform => transform != null) + .Where(transform => transform.gameObject.active)) + transform.GetComponent().text = + StringStore.TranslateText(transform.GetComponent().text); + } +} diff --git a/Source/Patches/Managers/UIMgr_Patch.cs b/Source/Patches/Managers/UIMgr_Patch.cs new file mode 100644 index 0000000..c8308f2 --- /dev/null +++ b/Source/Patches/Managers/UIMgr_Patch.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using Object = UnityEngine.Object; + +namespace PvZ_Fusion_Translator.Patches.Managers; + +[HarmonyPatch(typeof(UIMgr))] +public class UIMgr_Patch +{ + [HarmonyPatch(nameof(UIMgr.EnterLoseMenu)), HarmonyPostfix] + private static void EnterLoseMenu(UIMgr __instance) + { + var loseMenu = Object.FindObjectOfType(); + loseMenu.title.text = StringStore.TranslateText(loseMenu.title.text); + } +} diff --git a/Source/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs new file mode 100644 index 0000000..007d42c --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssBagMenu_Patch.cs @@ -0,0 +1,24 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssBagMenu))] +public static class AbyssBagMenu_Patch +{ + [HarmonyPatch(nameof(AbyssBagMenu.Awake)), HarmonyPostfix] + private static void Awake_Post(AbyssCheckInBag __instance) + { + foreach (TextMeshProUGUI text in __instance.transform.FindChild("Background") + .GetComponentsInChildren()) + { + text.text += "_深渊"; + text.text = StringStore.TranslateText("背包_深渊"); + text.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + AbyssMenu2.Instance.UpdateIcons(); + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs b/Source/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs new file mode 100644 index 0000000..f6681a5 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssBuffButton_Patch.cs @@ -0,0 +1,55 @@ +#if false +using System.Text.RegularExpressions; +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssBuffButton))] +public static class AbyssBuffButton_Patch +{ + [HarmonyPatch(nameof(AbyssBuffButton.SetType)), HarmonyPostfix] + private static void SetType(AbyssBuffButton __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var regex = new Regex("([^\\s]+)\n价格:(\\d+)"); + + if (!regex.IsMatch(__instance.description.text)) + return; + + var match = regex.Match(__instance.description.text); + var groupCount = match.Groups.Count; + + List dynamicParts = []; + + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + + var translatedValue = StringStore.translationString.ContainsKey(groupValue) + ? StringStore.translationString[groupValue] + : groupValue; + + dynamicParts.Add(translatedValue); + MelonLogger.Msg(translatedValue); + } + + __instance.description.text = string.Format( + StringStore.translationStringRegex["([^\\s]+)\n价格:(\\d+)"], + [..dynamicParts] + ); + + __instance.description.font = fontAsset; + } + + [HarmonyPatch(nameof(AbyssBuffButton.SetSold)), HarmonyPostfix] + private static void SetSold(AbyssBuffButton __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.description.text = StringStore.TranslateText(__instance.description.text); + __instance.description.font = fontAsset; + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssBuffData_Patch.cs b/Source/Patches/Modes/Abyss/AbyssBuffData_Patch.cs new file mode 100644 index 0000000..deceaa0 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssBuffData_Patch.cs @@ -0,0 +1,127 @@ +#if false +using System.Text.Json; +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssBuffData))] +public static class AbyssBuffData_Patch +{ + [HarmonyPatch(nameof(AbyssBuffData.LoadData)), HarmonyPostfix] + public static void Pre_LoadData(AbyssBuffData __instance) + { + // ReSharper disable once Unity.UnknownResource + var originalAbyssBuffStr = Resources.Load("AbyssBuffData").text; + + Dictionary> originalAbyssBuffData = + JsonSerializer.Deserialize>>(originalAbyssBuffStr); + + List infos = originalAbyssBuffData["infos"]; + + Il2CppSystem.Collections.Generic.Dictionary> result = + new(); + + var abyssBuffDataDir = Path.Combine( + FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), + "abyss_buffs.json" + ); + + if (!File.Exists(abyssBuffDataDir)) + File.WriteAllText(abyssBuffDataDir, originalAbyssBuffStr); + + var abyssBuffData = JsonSerializer.Deserialize>(File.ReadAllText(abyssBuffDataDir)); + + foreach (AbyssBuffInfo originalTuple in infos) + { + Il2CppSystem.ValueTuple translatedTuple = new() + { + Item1 = abyssBuffData.TryGetValue(originalTuple.name, out var item1) + ? item1 + : originalTuple.name, + Item2 = abyssBuffData.TryGetValue(originalTuple.introduce, out var item2) + ? item2 + : originalTuple.introduce, + Item3 = originalTuple.value, + }; + + foreach (var x in AbyssBuffData.buffDatas) + if (x.Value.Item1 == originalTuple.name) + { + AbyssBuffData.buffDatas[x.Key] = translatedTuple; + break; + } + } + } +} + +// ReSharper disable InconsistentNaming +public enum AbyssBuffClone +{ + 生存_聚塑, + 生存_启命, + 生存_坚定, + 生存_弥合, + 生存_警戒, + 生存_霸体, + 生存_共存, + 生存_护盾, + 生存_治疗, + 生存_主宰, + 寒冰_聚塑, + 寒冰_刺骨, + 寒冰_凛风, + 寒冰_冻结, + 寒冰_保护, + 寒冰_折磨, + 寒冰_扩散, + 寒冰_凝神, + 寒冰_破冰, + 寒冰_永冻, + 魅惑_聚塑, + 魅惑_感应, + 魅惑_催眠, + 魅惑_无畏, + 魅惑_脆弱, + 魅惑_黑曜, + 魅惑_转世, + 魅惑_支援, + 魅惑_沉重, + 魅惑_共鸣, + 烈焰_聚塑, + 烈焰_爆破, + 烈焰_怒火, + 烈焰_红唇, + 烈焰_融化, + 烈焰_燃烧, + 烈焰_浴火, + 烈焰_鬼火, + 烈焰_诅咒, + 烈焰_太阳, + 通用_断水, + 通用_千斤, + 通用_急迫, + 通用_折扣, + 通用_密植, + 通用_超级, + 通用_究极, + 通用_极速, + 通用_强力, + 通用_专注, + 通用_迸发, + 通用_投资, + 通用_机遇, + 通用_命运, + 通用_时停, + 通用_升级, + 蒜毒_聚塑, + 蒜毒_腐蚀, + 蒜毒_侵蚀, + 蒜毒_血清, + 蒜毒_混乱, + 蒜毒_虚弱, + 蒜毒_反胃, + 蒜毒_虫噬, + 蒜毒_百毒, + 蒜毒_爆裂, +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs new file mode 100644 index 0000000..2036d3d --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssBuffMenu_Patch.cs @@ -0,0 +1,111 @@ +#if false +using System.Text.Json; +using System.Text.RegularExpressions; +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssBuffMenu))] +public static class AbyssBuffMenu_Patch +{ +#pragma warning disable CA2211 + public static Dictionary AbyssBuffData = new(); +#pragma warning restore CA2211 + [HarmonyPatch(nameof(AbyssBuffMenu.Awake)), HarmonyPostfix] + public static void Post_Awake(AbyssBuffMenu __instance) + { + LoadAbyssBuffData(); + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + + TranslateWindows(__instance, fontAsset); + } + + [HarmonyPatch(nameof(AbyssBuffMenu.SelectWindow)), HarmonyPostfix] + public static void Post_SelectWindow(AbyssBuffMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + TranslateWindows(__instance, fontAsset); + } + + [HarmonyPatch(nameof(AbyssBuffMenu.SetFavorite)), HarmonyPostfix] + public static void Post_SetFavorite(AbyssBuffMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + } + + public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset) + { + foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + if (AbyssBuffData.TryGetValue(text.text, out var value)) + text.text = value; + else + { + var translatedRegex = TranslateAbyssBuffRegex(text.text); + + if (translatedRegex != null) + text.text = translatedRegex; + } + + text.font = fontAsset; + } + } + + public static void LoadAbyssBuffData() + { + AbyssBuffData.Clear(); + + var abyssBuffText = "{}"; + + if (!Core.Instance.ConfigUseLocal.Value) + { + var abyssBuffsContent = Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/abyss_buffs.json" + ) + .Result; + + if (abyssBuffsContent != null) + abyssBuffText = abyssBuffsContent; + else + { + var abyssBuffsPath = Path.Combine( + GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), + "abyss_buffs.json" + ); + + if (File.Exists(abyssBuffsPath)) + abyssBuffText = File.ReadAllText(abyssBuffsPath); + } + } + else + abyssBuffText = File.ReadAllText( + Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json") + ); + + AbyssBuffData = JsonSerializer.Deserialize>(abyssBuffText); + } + + public static string TranslateAbyssBuffRegex(string originalText) => + (from x in AbyssBuffData + where x.Key.Contains("{value}") + let pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)") + where Regex.IsMatch(originalText, pattern) + let regex = new Regex(pattern) + let match = regex.Match(originalText) + select string.Format(x.Value.Replace("value", "0"), match.Groups[1].Value)).FirstOrDefault(); +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs b/Source/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs new file mode 100644 index 0000000..d54c1e3 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssCheckInBag_Patch.cs @@ -0,0 +1,15 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssCheckInBag))] +public static class AbyssCheckInBag_Patch +{ + [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag)), HarmonyPostfix] + private static void MoveFromBag(AbyssCheckInBag __instance) => AbyssMenu2.Instance.UpdateIcons(); + + [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon)), HarmonyPostfix] + private static void SellIcon(AbyssCheckInBag __instance) => AbyssMenu2.Instance.UpdateIcons(); +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs new file mode 100644 index 0000000..88a9487 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssCheckSellMenu_Patch.cs @@ -0,0 +1,15 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssCheckSellMenu))] +public static class AbyssCheckSellMenu_Patch +{ + [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon)), HarmonyPostfix] + private static void SellIcon(AbyssCheckSellMenu __instance) => AbyssMenu2.Instance.UpdateIcons(); + + [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag)), HarmonyPostfix] + private static void MoveInBag(AbyssCheckSellMenu __instance) => AbyssMenu2.Instance.UpdateIcons(); +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs new file mode 100644 index 0000000..50c8ac9 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssDevelopMenu_Patch.cs @@ -0,0 +1,48 @@ +#if false +using System.Text.RegularExpressions; +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssDevelopMenu))] +public static class AbyssDevelopMenu_Patch +{ + [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo)), HarmonyPostfix] + private static void UpdateInfo(AbyssDevelopMenu __instance) + { + __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text); + __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text); + + TextMeshProUGUI upgradeCostText = + __instance.transform.FindChild("UpgradeCost").GetComponent(); + + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + const string RegexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)"; + var regex = new Regex(RegexStr); + + if (!regex.IsMatch(upgradeCostText.text)) + return; + + var match = regex.Match(upgradeCostText.text); + var groupCount = match.Groups.Count; + + List dynamicParts = []; + + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + + var translatedValue = StringStore.translationString.ContainsKey(groupValue) + ? StringStore.translationString[groupValue] + : groupValue; + + dynamicParts.Add(translatedValue); + } + + upgradeCostText.text = string.Format(StringStore.translationStringRegex[RegexStr], [..dynamicParts]); + upgradeCostText.font = fontAsset; + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssGoods_Patch.cs b/Source/Patches/Modes/Abyss/AbyssGoods_Patch.cs new file mode 100644 index 0000000..eefd9ae --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssGoods_Patch.cs @@ -0,0 +1,18 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssGoods))] +public static class AbyssGoods_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(AbyssGoods.Start))] + private static void Start(AbyssGoods __instance) + { + __instance.costText.text = StringStore.TranslateText(__instance.costText.text, false); + __instance.costText_shadow.text = StringStore.TranslateText(__instance.costText_shadow.text, false); + __instance.hasText.text = StringStore.TranslateText(__instance.hasText.text, false); + __instance.hasText_shadow.text = StringStore.TranslateText(__instance.hasText_shadow.text, false); + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssInfo_Patch.cs b/Source/Patches/Modes/Abyss/AbyssInfo_Patch.cs new file mode 100644 index 0000000..c439084 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssInfo_Patch.cs @@ -0,0 +1,5 @@ +#if false +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +public class AbyssInfo_Patch; +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs b/Source/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs new file mode 100644 index 0000000..ffa83d6 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssLevelEnter_Patch.cs @@ -0,0 +1,14 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssLevelEnter))] +public static class AbyssLevelEnter_Patch +{ + [HarmonyPatch(nameof(AbyssLevelEnter.SetLevel)), HarmonyPostfix] + private static void SetLevel(AbyssLevelEnter __instance) => + __instance.levelName = StringStore.TranslateText(__instance.levelName); +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssMenu2_Patch.cs b/Source/Patches/Modes/Abyss/AbyssMenu2_Patch.cs new file mode 100644 index 0000000..052103e --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssMenu2_Patch.cs @@ -0,0 +1,88 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine.UI; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssMenu2))] +public static class AbyssMenu2_Patch +{ + private static void UpdateAbyss2Text(AbyssMenu2 __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text); + __instance.buffCountText.font = fontAsset; + + __instance.money.text = StringStore.TranslateText(__instance.money.text); + __instance.money.font = fontAsset; + + __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text); + __instance.refreshText.font = fontAsset; + + __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text); + __instance.statistics.font = fontAsset; + + Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform; + + if (buffTextTransform != null) + StringStore.TranslateTextTransform(buffTextTransform); + + Transform moneyTransform = __instance.transform.FindChild("Money").transform; + + if (moneyTransform != null) + StringStore.TranslateTextTransform(moneyTransform); + + Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform; + + if (buffCountTextTransform != null) + StringStore.TranslateTextTransform(buffCountTextTransform); + + Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform; + + if (refreshTextTransform != null) + StringStore.TranslateTextTransform(refreshTextTransform); + + Transform optionsTransform = __instance.transform.FindChild("Options").transform; + + foreach (AbyssBuffButton abyssBuffButton in optionsTransform.GetComponentsInChildren()) + { + foreach (TextMeshProUGUI textMesh in abyssBuffButton.GetComponentsInChildren()) + textMesh.text = StringStore.TranslateText(textMesh.text); + } + + foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + } + + [HarmonyPatch(nameof(AbyssMenu2.Start)), HarmonyPostfix] + private static void Start(AbyssMenu2 __instance) + { + UpdateAbyss2Text(__instance); + + Utils.ConvertButtonText(__instance.transform, "Help"); + + // custom bag text :D + + __instance.transform.FindChild("Bag").FindChild("text").GetComponent().text += "_深渊"; + + Utils.ConvertButtonText(__instance.transform, "Bag"); + } + + [HarmonyPatch(nameof(AbyssMenu2.UpdateIcons)), HarmonyPostfix] + private static void UpdateIcons(AbyssMenu2 __instance) => UpdateAbyss2Text(__instance); + + [HarmonyPatch(nameof(AbyssMenu2.UpdateBuff)), HarmonyPostfix] + private static void UpdateBuff(AbyssMenu2 __instance) => UpdateAbyss2Text(__instance); + + [HarmonyPatch(nameof(AbyssMenu2.BuyBuff)), HarmonyPostfix] + private static void BuyBuff(AbyssMenu2 __instance) => UpdateAbyss2Text(__instance); + + [HarmonyPatch(nameof(AbyssMenu2.ShowBag)), HarmonyPostfix] + private static void ShowBag(AbyssMenu2 __instance) => UpdateAbyss2Text(__instance); +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssMenu_Patch.cs new file mode 100644 index 0000000..46594bf --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssMenu_Patch.cs @@ -0,0 +1,48 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssMenu))] +public static class AbyssMenu_Patch +{ + [HarmonyPatch(nameof(AbyssMenu.Awake)), HarmonyPostfix] + private static void Awake(AbyssMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.levelInfo) + { + txt.text = StringStore.TranslateText( + txt.text, + "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)" + ); + + txt.font = fontAsset; + } + + foreach (var text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + } + + [HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo)), HarmonyPostfix] + private static void UpdateLevelInfo(AbyssMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.levelInfo) + { + txt.text = StringStore.TranslateText( + txt.text, + "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)" + ); + + txt.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs b/Source/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs new file mode 100644 index 0000000..381b11d --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssSelectBuffWindow_Patch.cs @@ -0,0 +1,45 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssSelectBuffWindow))] +public static class AbyssSelectBuffWindow_Patch +{ + [HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver)), HarmonyPostfix] + private static void OnAnimOver(AbyssSelectBuffWindow __instance) => TranslateBuffWindow(__instance); + + [HarmonyPatch(nameof(AbyssSelectBuffWindow.SetBuff)), HarmonyPostfix] + private static void SetBuff(AbyssSelectBuffWindow __instance) => TranslateBuffWindow(__instance); + + public static void TranslateBuffWindow(AbyssSelectBuffWindow __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + AbyssBuffMenu_Patch.LoadAbyssBuffData(); + + foreach (TextMeshProUGUI titleText in __instance.titleText) + { + if (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(titleText.text)) + { + if (titleText.name.Contains("shadow")) + titleText.text = Utils.RemoveColorTags(AbyssBuffMenu_Patch.abyssBuffData[titleText.text]); + else + titleText.text = AbyssBuffMenu_Patch.abyssBuffData[titleText.text]; + } + + titleText.font = fontAsset; + } + + string translatedIntroduceText = AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(__instance.introduce.text) + ? AbyssBuffMenu_Patch.abyssBuffData[__instance.introduce.text] + : AbyssBuffMenu_Patch.TranslateAbyssBuffRegex(__instance.introduce.text); + + if (translatedIntroduceText == null) + return; + + __instance.introduce.text = translatedIntroduceText; + __instance.introduce.font = fontAsset; + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs new file mode 100644 index 0000000..19547c4 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssSettlementMenu_Patch.cs @@ -0,0 +1,58 @@ +#if false +using System.Text.RegularExpressions; +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssSettlementMenu))] +public static class AbyssSettlementMenu_Patch +{ + [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle)), HarmonyPostfix] + private static void InitSettle(AbyssSettlementMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + string[] regexStrList = + [ + "第(\\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+)", + ]; + + foreach (var regexStr in regexStrList) + { + var regex = new Regex(regexStr); + + if (!regex.IsMatch(__instance.settleInfo.text)) + continue; + + var match = regex.Match(__instance.settleInfo.text); + var groupCount = match.Groups.Count; + + List dynamicParts = []; + + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + + var translatedValue = StringStore.translationString.ContainsKey(groupValue) + ? StringStore.translationString[groupValue] + : groupValue; + + dynamicParts.Add(translatedValue); + } + + __instance.settleInfo.text = string.Format( + StringStore.translationStringRegex[regexStr], + [..dynamicParts] + ); + + __instance.settleInfo.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs b/Source/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs new file mode 100644 index 0000000..7ab6c54 --- /dev/null +++ b/Source/Patches/Modes/Abyss/AbyssStoreMenu_Patch.cs @@ -0,0 +1,22 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Abyss; + +[HarmonyPatch(typeof(AbyssStoreMenu))] +public static class AbyssStoreMenu_Patch +{ + [HarmonyPatch(nameof(AbyssStoreMenu.Update)), HarmonyPostfix] + private static void Update(AbyssStoreMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/Modes/Harvest/GardenBagMenu_Patch.cs b/Source/Patches/Modes/Harvest/GardenBagMenu_Patch.cs new file mode 100644 index 0000000..712fb8d --- /dev/null +++ b/Source/Patches/Modes/Harvest/GardenBagMenu_Patch.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(GardenBagMenu))] +public static class GardenBagMenu_Patch +{ + [HarmonyPatch(nameof(GardenBagMenu.Awake)), HarmonyPostfix] + private static void Awake(GardenBagMenu __instance) + { + _ = FontStore.LoadTMPFont(Utils.Language.ToString()); + + var closeButtonTransform = __instance.transform.Find("Close"); + + foreach (var text in closeButtonTransform.GetComponentsInChildren()) + text.text = StringStore.TranslateText("合上"); + } +} diff --git a/Source/Patches/Modes/Harvest/GardenCard_Patch.cs b/Source/Patches/Modes/Harvest/GardenCard_Patch.cs new file mode 100644 index 0000000..fa239ba --- /dev/null +++ b/Source/Patches/Modes/Harvest/GardenCard_Patch.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(GardenCard))] +public static class GardenCard_Patch +{ + [HarmonyPatch(nameof(GardenCard.Start)), HarmonyPostfix] + private static void Start(GardenCard __instance) => + __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); + + [HarmonyPatch(nameof(GardenCard.ChangeCardSprite)), HarmonyPostfix] + private static void ChangeCardSprite(GardenCard __instance) => + __instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16"); +} diff --git a/Source/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs new file mode 100644 index 0000000..9527418 --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureConfirmMenu_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureConfirmMenu))] +public static class TreasureConfirmMenu_Patch +{ + [HarmonyPatch(nameof(TreasureConfirmMenu.SetText)), HarmonyPostfix] + private static void SetText(TreasureConfirmMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs new file mode 100644 index 0000000..29d5dbc --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureEquipmentMenu_Patch.cs @@ -0,0 +1,32 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureEquipmentMenu))] +public static class TreasureEquipmentMenu_Patch +{ + [HarmonyPatch(nameof(TreasureEquipmentMenu.Awake)), HarmonyPostfix] + private static void Awake(TreasureEquipmentMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureEquipmentMenu.UpdateCards)), HarmonyPostfix] + private static void UpdateCards(TreasureEquipmentMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs new file mode 100644 index 0000000..349ba76 --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureEvacuateMenu_Patch.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureEvacuateMenu))] +public static class TreasureEvacuateMenu_Patch +{ + [HarmonyPatch(nameof(TreasureEvacuateMenu.Start)), HarmonyPostfix] + private static void Start(TreasureEvacuateMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + + if (txt.name.Contains("text (1)")) + txt.name += "_EVACUATE"; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs new file mode 100644 index 0000000..16a00be --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureMainMenu_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureMainMenu))] +public static class TreasureMainMenu_Patch +{ + [HarmonyPatch(nameof(TreasureMainMenu.Update)), HarmonyPostfix] + private static void Update(TreasureMainMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureManager_Patch.cs b/Source/Patches/Modes/Harvest/TreasureManager_Patch.cs new file mode 100644 index 0000000..c4e7b39 --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureManager_Patch.cs @@ -0,0 +1,26 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureManager))] +public static class TreasureManager_Patch +{ + [HarmonyPatch(nameof(TreasureManager.Update)), HarmonyPostfix] + private static void Update(TreasureManager __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.evaText) + { + txt.autoSizeTextContainer = false; + + if (txt.text == "Evacuate") + continue; + + txt.text = StringStore.TranslateText(txt.text); + txt.name = txt.text + "_EVACUATE"; + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs new file mode 100644 index 0000000..81bb3f5 --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureStoreMenu_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureStoreMenu))] +public static class TreasureStoreMenu_Patch +{ + [HarmonyPatch(nameof(TreasureStoreMenu.InitCards)), HarmonyPostfix] + private static void InitCards(TreasureStoreMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs new file mode 100644 index 0000000..9d61ef3 --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureUpgradeMenu_Patch.cs @@ -0,0 +1,54 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine.UI; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureUpgradeMenu))] +public static class TreasureUpgradeMenu_Patch +{ + [HarmonyPatch(nameof(TreasureUpgradeMenu.Start)), HarmonyPostfix] + private static void Start(TreasureUpgradeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureUpgradeMenu.UpgradeWareHouse)), HarmonyPostfix] + private static void UpgradeWareHouse(TreasureUpgradeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureUpgradeMenu.InitWareHouseUpgrade)), HarmonyPostfix] + private static void InitWareHouseUpgrade(TreasureUpgradeMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + + foreach (var txt in __instance.GetComponentsInChildren()) + { + var newTxtObj = Utils.ConvertToTextMeshProUGUI(txt.gameObject, txt.transform.parent, "text"); + var newTxt = newTxtObj.GetComponent(); + newTxt.text = StringStore.TranslateText("植物商店"); + newTxt.autoSizeTextContainer = true; + newTxt.color = new(0, 0, 0.3922f, 1); + } + } +} diff --git a/Source/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs b/Source/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs new file mode 100644 index 0000000..56d0dac --- /dev/null +++ b/Source/Patches/Modes/Harvest/TreasureWarehouseMenu_Patch.cs @@ -0,0 +1,56 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Harvest; + +[HarmonyPatch(typeof(TreasureWarehouseMenu))] +public static class TreasureWarehouseMenu_Patch +{ + [HarmonyPatch(nameof(TreasureWarehouseMenu.InitCards)), HarmonyPostfix] + private static void InitCards(TreasureWarehouseMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureWarehouseMenu.QuickSell)), HarmonyPostfix] + private static void QuickSell(TreasureWarehouseMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureWarehouseMenu.FastSell)), HarmonyPostfix] + private static void FastSell(TreasureWarehouseMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(TreasureWarehouseMenu.EnterStore)), HarmonyPostfix] + private static void EnterStore(TreasureWarehouseMenu __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } +} diff --git a/Source/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs b/Source/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs new file mode 100644 index 0000000..8f9dbd0 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/MultipleChoiceMenu_Patch.cs @@ -0,0 +1,46 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(MultipleChoiceMenu))] +public static class MultipleChoiceMenu_Patch +{ + public static TMP_FontAsset FontAsset => FontStore.LoadTMPFont(Utils.Language.ToString()); + + [HarmonyPatch(nameof(MultipleChoiceMenu.Awake)), HarmonyPatch(nameof(MultipleChoiceMenu.Cancel)), + HarmonyPatch(nameof(MultipleChoiceMenu.Refresh)), HarmonyPatch(nameof(MultipleChoiceMenu.TurnPage)), + HarmonyPatch(nameof(MultipleChoiceMenu.UpdateWindow)), HarmonyPostfix] + public static void Awake(MultipleChoiceMenu __instance) + { + foreach (var window in __instance.windows) + { + TranslateWindowText(window.title); + TranslateWindowText(window.introduce); + } + + foreach (var txt in __instance.GetComponentsInChildren() + .SelectMany(button => button.GetComponentsInChildren())) + { + txt.text = StringStore.TranslationString.ContainsKey(txt.text + "_MC") + ? StringStore.TranslateText(txt.text + "_MC") + : StringStore.TranslateText(txt.text); + + txt.font = FontAsset; + } + } + + public static void TranslateWindowText(TextMeshProUGUI txt) + { + txt.font = FontAsset; + + if (StringStore.CustomLevelString.TryGetValue(txt.text, out var value)) + txt.text = value; + else if (Utils.GetPlantNameFromAlmanac(txt.text) != "") + txt.text = Utils.GetPlantNameFromAlmanac(txt.text); + else + txt.text = StringStore.TranslationString.ContainsKey(txt.text + "_MC") + ? StringStore.TranslateText(txt.text + "_MC") + : StringStore.TranslateText(txt.text); + } +} diff --git a/Source/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs b/Source/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs new file mode 100644 index 0000000..58f312e --- /dev/null +++ b/Source/Patches/Modes/Odyssey/OppositeBuffManager_Patch.cs @@ -0,0 +1,47 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(OppositeBuffManager))] +public static class OppositeBuffManager_Patch +{ + public static Dictionary buffLinks = TravelMgr_Patch.buffLinks; + + public static Dictionary> translatedTravelBuffs = + TravelMgr_Patch.translatedTravelBuffs; + + public const string BadPattern = @"^但(.*)"; + + public static readonly string BadFormat = StringStore.translationStringRegex.ContainsKey(BadPattern) + ? StringStore.translationStringRegex[BadPattern] + : "But, {0}"; + + public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + [HarmonyPatch(nameof(OppositeBuffManager.SetText)), HarmonyPostfix] + private static void SetText(OppositeBuffManager __instance) + { + if (TravelMgr_Patch.travelBuffString.ContainsKey(__result)) + __result = TravelMgr_Patch.travelBuffString[__result]; + else if (TravelMgr_Patch.travelBuffString.ContainsKey(TravelMgr_Patch.RemoveBuffName(__result))) + __result = TravelMgr_Patch.travelBuffString[TravelMgr_Patch.RemoveBuffName(__result)]; + } + + public static void TranslateOppositeText( + Il2CppSystem.Collections.Generic.List textList, + Il2CppSystem.Object buff, + bool isBad = false + ) + { + var buffText = TravelMgr.Instance.GetText(buff); + + foreach (var text in textList) + { + text.text = isBad ? string.Format(BadFormat, buffText) : buffText; + text.font = fontAsset; + } + } +} +#endif diff --git a/Source/Patches/Modes/Odyssey/ShootingManager_Patch.cs b/Source/Patches/Modes/Odyssey/ShootingManager_Patch.cs new file mode 100644 index 0000000..5678e28 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/ShootingManager_Patch.cs @@ -0,0 +1,575 @@ +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(ShootingManager))] +public static class ShootingManager_Patch +{ + [HarmonyPatch(nameof(ShootingManager.RegisterCoreBuff)), HarmonyPatch(nameof(ShootingManager.RegisterExpertBuff)), + HarmonyPatch(nameof(ShootingManager.RegisterGetPlantBuff)), + HarmonyPatch(nameof(ShootingManager.RegisterOtherBuff)), HarmonyPostfix] + public static void UpgradeBuff(ShootingManager __instance, ref MultipleChoiceMenu menu) => + MultipleChoiceMenu_Patch.Awake(menu); + + public static void GetBuffs() + { + /*#region code + + AbyssSwordStar t0 = new(); + Bamboo t1 = new(); + BigChomper t4 = new(); + BigGatling t5 = new(); + CabbageCannon t6 = new(); + Cabbagepult t7 = new(); + Cactus t8 = new(); + Caltrop t9 = new(); + CaltropNut t10 = new(); + CattailLour t11 = new(); + CherryChomper t12 = new(); + CherryGatling t13 = new(); + CherrySquash t14 = new(); + Chomper t15 = new(); + Cornpult t17 = new(); + DoomCactus t20 = new(); + DoomChomper t21 = new(); + DoomSniper t22 = new(); + EmeraleBlover t23 = new(); + FireMelon t24 = new(); + FumeShroom t25 = new(); + GarlicFume t26 = new(); + GloomShroom t28 = new(); + GoldCabbage t29 = new(); + HelmetGatling t30 = new(); + HypnoEmperor t31 = new(); + HypnoNut t32 = new(); + HypnoShroom t33 = new(); + IceFumeShroom t34 = new(); + IcePuff t35 = new(); + IFVIronPuff t36 = new(); + IronPuff t37 = new(); + LanternSplit t38 = new(); + LanternUmbrella t39 = new(); + LaserUmbrella t40 = new(); + LotusBamboo t41 = new(); + Melonpult t42 = new(); + NuclearSquash t43 = new(); + ObsidianSpike t44 = new(); + ObsidianWallNut t45 = new(); + PeaMine t46 = new(); + Peashooter t47 = new(); + PortalCorn t48 = new(); + PotatoMine t49 = new(); + ScaredyDoom t54 = new(); + ScaredyShroom t55 = new(); + SmallPuff t57 = new(); + SniperPea t58 = new(); + SnowGatlingPuff t59 = new(); + SpikeRock t61 = new(); + Squalour t62 = new(); + Squash t63 = new(); + StarFruit t64 = new(); + SuperChomper t66 = new(); + SuperHypno t67 = new(); + SuperMelon t68 = new(); + SuperStar t69 = new(); + SuperThreePeater t70 = new(); + SwordStar t71 = new(); + TallNut t72 = new(); + ThreeMine t73 = new(); + ThreePeater t74 = new(); + ThreeSquash t75 = new(); + UltimateBamboo t76 = new(); + UltimateBigChomper t77 = new(); + UltimateBigGatling t78 = new(); + UltimateBlover t79 = new(); + UltimateCabbage t80 = new(); + UltimateCabbageCannon t81 = new(); + UltimateCactus t82 = new(); + UltimateChomper t83 = new(); + UltimateCorn t84 = new(); + UltimateDoomScared t85 = new(); + UltimateFume t86 = new(); + UltimateGatling t87 = new(); + UltimateGloom t88 = new(); + UltimateHelmetGatling t89 = new(); + UltimateHypno t90 = new(); + UltimateLanternSplit t91 = new(); + UltimateMelon t92 = new(); + UltimateMinigun t93 = new(); + UltimatePoisonFume t94 = new(); + UltimateSniperGatling t95 = new(); + UltimateSpring t96 = new(); + UltimateStar t97 = new(); + UltimateStarTorch t98 = new(); + UltimateTallNut t99 = new(); + UltimateWinterMelon t100 = new(); + Umbrellaleaf t101 = new(); + WallNut t103 = new(); + WinterMelon t104 = new(); + + Dictionary t = new(); + + #region 3 + + if(t0.Buffs != null) + { + Utils.TryAdd(t, t0.Role, t0.Role); + } + + if(t1.Buffs != null) + { + Utils.TryAdd(t, t1.Role, t1.Role); + } + + if(t4.Buffs != null) + { + Utils.TryAdd(t, t4.Role, t4.Role); + } + + if(t5.Buffs != null) + { + Utils.TryAdd(t, t5.Role, t5.Role); + } + + if(t6.Buffs != null) + { + Utils.TryAdd(t, t6.Role, t6.Role); + } + + if(t7.Buffs != null) + { + Utils.TryAdd(t, t7.Role, t7.Role); + } + + if(t8.Buffs != null) + { + Utils.TryAdd(t, t8.Role, t8.Role); + } + + if(t9.Buffs != null) + { + Utils.TryAdd(t, t9.Role, t9.Role); + } + + if(t10.Buffs != null) + { + Utils.TryAdd(t, t10.Role, t10.Role); + } + + if(t11.Buffs != null) + { + Utils.TryAdd(t, t11.Role, t11.Role); + } + + if(t12.Buffs != null) + { + Utils.TryAdd(t, t12.Role, t12.Role); + } + + if(t13.Buffs != null) + { + Utils.TryAdd(t, t13.Role, t13.Role); + } + + if(t14.Buffs != null) + { + Utils.TryAdd(t, t14.Role, t14.Role); + } + + if(t15.Buffs != null) + { + Utils.TryAdd(t, t15.Role, t15.Role); + } + + if(t17.Buffs != null) + { + Utils.TryAdd(t, t17.Role, t17.Role); + } + + if(t20.Buffs != null) + { + Utils.TryAdd(t, t20.Role, t20.Role); + } + + if(t21.Buffs != null) + { + Utils.TryAdd(t, t21.Role, t21.Role); + } + + if(t22.Buffs != null) + { + Utils.TryAdd(t, t22.Role, t22.Role); + } + + if(t23.Buffs != null) + { + Utils.TryAdd(t, t23.Role, t23.Role); + } + + if(t24.Buffs != null) + { + Utils.TryAdd(t, t24.Role, t24.Role); + } + + if(t25.Buffs != null) + { + Utils.TryAdd(t, t25.Role, t25.Role); + } + + if(t26.Buffs != null) + { + Utils.TryAdd(t, t26.Role, t26.Role); + } + + if(t28.Buffs != null) + { + Utils.TryAdd(t, t28.Role, t28.Role); + } + + if(t29.Buffs != null) + { + Utils.TryAdd(t, t29.Role, t29.Role); + } + + if(t30.Buffs != null) + { + Utils.TryAdd(t, t30.Role, t30.Role); + } + + if(t31.Buffs != null) + { + Utils.TryAdd(t, t31.Role, t31.Role); + } + + if(t32.Buffs != null) + { + Utils.TryAdd(t, t32.Role, t32.Role); + } + + if(t33.Buffs != null) + { + Utils.TryAdd(t, t33.Role, t33.Role); + } + + if(t34.Buffs != null) + { + Utils.TryAdd(t, t34.Role, t34.Role); + } + + if(t35.Buffs != null) + { + Utils.TryAdd(t, t35.Role, t35.Role); + } + + if(t36.Buffs != null) + { + Utils.TryAdd(t, t36.Role, t36.Role); + } + + if(t37.Buffs != null) + { + Utils.TryAdd(t, t37.Role, t37.Role); + } + + if(t38.Buffs != null) + { + Utils.TryAdd(t, t38.Role, t38.Role); + } + + if(t39.Buffs != null) + { + Utils.TryAdd(t, t39.Role, t39.Role); + } + + if(t40.Buffs != null) + { + Utils.TryAdd(t, t40.Role, t40.Role); + } + + if(t41.Buffs != null) + { + Utils.TryAdd(t, t41.Role, t41.Role); + } + + if(t42.Buffs != null) + { + Utils.TryAdd(t, t42.Role, t42.Role); + } + + if(t43.Buffs != null) + { + Utils.TryAdd(t, t43.Role, t43.Role); + } + + if(t44.Buffs != null) + { + Utils.TryAdd(t, t44.Role, t44.Role); + } + + if(t45.Buffs != null) + { + Utils.TryAdd(t, t45.Role, t45.Role); + } + + if(t46.Buffs != null) + { + Utils.TryAdd(t, t46.Role, t46.Role); + } + + if(t47.Buffs != null) + { + Utils.TryAdd(t, t47.Role, t47.Role); + } + + if(t48.Buffs != null) + { + Utils.TryAdd(t, t48.Role, t48.Role); + } + + if(t49.Buffs != null) + { + Utils.TryAdd(t, t49.Role, t49.Role); + } + + if(t54.Buffs != null) + { + Utils.TryAdd(t, t54.Role, t54.Role); + } + + if(t55.Buffs != null) + { + Utils.TryAdd(t, t55.Role, t55.Role); + } + + if(t57.Buffs != null) + { + Utils.TryAdd(t, t57.Role, t57.Role); + } + + if(t58.Buffs != null) + { + Utils.TryAdd(t, t58.Role, t58.Role); + } + + if(t59.Buffs != null) + { + Utils.TryAdd(t, t59.Role, t59.Role); + } + + if(t61.Buffs != null) + { + Utils.TryAdd(t, t61.Role, t61.Role); + } + + if(t62.Buffs != null) + { + Utils.TryAdd(t, t62.Role, t62.Role); + } + + if(t63.Buffs != null) + { + Utils.TryAdd(t, t63.Role, t63.Role); + } + + if(t64.Buffs != null) + { + Utils.TryAdd(t, t64.Role, t64.Role); + } + + if(t66.Buffs != null) + { + Utils.TryAdd(t, t66.Role, t66.Role); + } + + if(t67.Buffs != null) + { + Utils.TryAdd(t, t67.Role, t67.Role); + } + + if(t68.Buffs != null) + { + Utils.TryAdd(t, t68.Role, t68.Role); + } + + if(t69.Buffs != null) + { + Utils.TryAdd(t, t69.Role, t69.Role); + } + + if(t70.Buffs != null) + { + Utils.TryAdd(t, t70.Role, t70.Role); + } + + if(t71.Buffs != null) + { + Utils.TryAdd(t, t71.Role, t71.Role); + } + + if(t72.Buffs != null) + { + Utils.TryAdd(t, t72.Role, t72.Role); + } + + if(t73.Buffs != null) + { + Utils.TryAdd(t, t73.Role, t73.Role); + } + + if(t74.Buffs != null) + { + Utils.TryAdd(t, t74.Role, t74.Role); + } + + if(t75.Buffs != null) + { + Utils.TryAdd(t, t75.Role, t75.Role); + } + + if(t76.Buffs != null) + { + Utils.TryAdd(t, t76.Role, t76.Role); + } + + if(t77.Buffs != null) + { + Utils.TryAdd(t, t77.Role, t77.Role); + } + + if(t78.Buffs != null) + { + Utils.TryAdd(t, t78.Role, t78.Role); + } + + if(t79.Buffs != null) + { + Utils.TryAdd(t, t79.Role, t79.Role); + } + + if(t80.Buffs != null) + { + Utils.TryAdd(t, t80.Role, t80.Role); + } + + if(t81.Buffs != null) + { + Utils.TryAdd(t, t81.Role, t81.Role); + } + + if(t82.Buffs != null) + { + Utils.TryAdd(t, t82.Role, t82.Role); + } + + if(t83.Buffs != null) + { + Utils.TryAdd(t, t83.Role, t83.Role); + } + + if(t84.Buffs != null) + { + Utils.TryAdd(t, t84.Role, t84.Role); + } + + if(t85.Buffs != null) + { + Utils.TryAdd(t, t85.Role, t85.Role); + } + + if(t86.Buffs != null) + { + Utils.TryAdd(t, t86.Role, t86.Role); + } + + if(t87.Buffs != null) + { + Utils.TryAdd(t, t87.Role, t87.Role); + } + + if(t88.Buffs != null) + { + Utils.TryAdd(t, t88.Role, t88.Role); + } + + if(t89.Buffs != null) + { + Utils.TryAdd(t, t89.Role, t89.Role); + } + + if(t90.Buffs != null) + { + Utils.TryAdd(t, t90.Role, t90.Role); + } + + if(t91.Buffs != null) + { + Utils.TryAdd(t, t91.Role, t91.Role); + } + + if(t92.Buffs != null) + { + Utils.TryAdd(t, t92.Role, t92.Role); + } + + if(t93.Buffs != null) + { + Utils.TryAdd(t, t93.Role, t93.Role); + } + + if(t94.Buffs != null) + { + Utils.TryAdd(t, t94.Role, t94.Role); + } + + if(t95.Buffs != null) + { + Utils.TryAdd(t, t95.Role, t95.Role); + } + + if(t96.Buffs != null) + { + Utils.TryAdd(t, t96.Role, t96.Role); + } + + if(t97.Buffs != null) + { + Utils.TryAdd(t, t97.Role, t97.Role); + } + + if(t98.Buffs != null) + { + Utils.TryAdd(t, t98.Role, t98.Role); + } + + if(t99.Buffs != null) + { + Utils.TryAdd(t, t99.Role, t99.Role); + } + + if(t100.Buffs != null) + { + Utils.TryAdd(t, t100.Role, t100.Role); + } + + if(t101.Buffs != null) + { + Utils.TryAdd(t, t101.Role, t101.Role); + } + + if(t103.Buffs != null) + { + Utils.TryAdd(t, t103.Role, t103.Role); + } + + if(t104.Buffs != null) + { + Utils.TryAdd(t, t104.Role, t104.Role); + } + + #endregion + + File.WriteAllText("tge_roles.json", FileLoader.SerializeWithIndentation(t)); + + #endregion*/ + } +} diff --git a/Source/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs b/Source/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs new file mode 100644 index 0000000..40e89e2 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(SynergyDisplay))] +public static class SynergyDisplay_Patch +{ + [HarmonyPatch(nameof(SynergyDisplay.Start)), HarmonyPostfix] + public static void Start(SynergyDisplay __instance) => + __instance.text.text = TranslateInvestDisplay(__instance.text.text); + + public static string TranslateInvestDisplay(string originalText) + { + var parts = originalText.Split("\n\n"); + var translatedParts = parts.Select(part => StringStore.TranslateColorText(part)).ToList(); + return string.Join("\n\n", translatedParts); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs b/Source/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs new file mode 100644 index 0000000..ce26516 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelAdvantureMenu_Patch.cs @@ -0,0 +1,28 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelAdvantureMenu))] +public static class TravelAdvantureMenu_Patch +{ + [HarmonyPatch(nameof(TravelAdvantureMenu.Awake)), HarmonyPostfix] + public static void Awake(TravelAdvantureMenu __instance) + { + foreach (var button in __instance.GetComponentsInChildren()) + { + var plantName = Utils.GetPlantNameFromAlmanac(button.levelName.text); + + if (Utils.Language == Utils.LanguageEnum.Arabic) + button.levelName.text = StringStore.TranslateText(button.levelName.text); + else + button.levelName.text = plantName != "" ? plantName : StringStore.TranslateText(button.levelName.text); + } + } + + [HarmonyPatch(nameof(TravelAdvantureMenu.LookWeak)), HarmonyPostfix] + public static void LookWeak(TravelAdvantureMenu __instance) => Awake(__instance); + + [HarmonyPatch(nameof(TravelAdvantureMenu.LookUlti)), HarmonyPostfix] + public static void LookUlti(TravelAdvantureMenu __instance) => Awake(__instance); +} diff --git a/Source/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs b/Source/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs new file mode 100644 index 0000000..fead17e --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelBuffMenu))] +public static class TravelBuffMenu_Patch +{ + [HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions)), HarmonyPostfix] + public static void RefeshOptions(TravelBuffMenu __instance) + { + foreach (var button in __instance.options) + TravelBuffOptionButton_Patch.TranslateOptionButton(button); + } + + [HarmonyPatch(nameof(TravelBuffMenu.Awake)), HarmonyPostfix] + public static void Awake(TravelBuffMenu __instance) + { + var refreshTransform = __instance.transform.Find("Refresh"); + + foreach (var text in refreshTransform.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs b/Source/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs new file mode 100644 index 0000000..98f9eca --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelBuffMgr_Patch.cs @@ -0,0 +1,23 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelBuffMgr))] +public static class TravelBuffMgr_Patch +{ + [HarmonyPatch(nameof(TravelBuffMgr.Awake)), HarmonyPostfix] + private static void Awake(TravelBuffMgr __instance) + { + __instance.text = AssetStore.StringStore.TranslateText(__instance.text); + __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); + } + + [HarmonyPatch(nameof(TravelBuffMgr.ShowText), typeof(int), typeof(int)), HarmonyPostfix] + private static void ShowText(TravelBuffMgr __instance) + { + __instance.text = AssetStore.StringStore.TranslateText(__instance.text); + __instance.text2 = AssetStore.StringStore.TranslateText(__instance.text2); + } +} +#endif diff --git a/Source/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs b/Source/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs new file mode 100644 index 0000000..45736d8 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelBuffOptionButton_Patch.cs @@ -0,0 +1,35 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelBuffOptionButton))] +public static class TravelBuffOptionButton_Patch +{ + [HarmonyPatch(nameof(TravelBuffOptionButton.Awake)), HarmonyPostfix] + public static void Awake(TravelBuffOptionButton __instance) => TranslateOptionButton(__instance); + + [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver)), HarmonyPostfix] + public static void OnAnimOver(TravelBuffOptionButton __instance) => TranslateOptionButton(__instance); + + public static void TranslateOptionButton(TravelBuffOptionButton button) + { + if (TravelBuffString.ContainsKey(button.introduce.text)) + { + var translatedBuff = TravelBuffString[button.introduce.text]; + button.introduce.text = AddBuffName(translatedBuff); + } + + if (!Utils.CheckForUntranslatedText(button.introduce.text)) + button.introduce.text = AddBuffName(button.introduce.text); + + if (!TravelBuffString.ContainsKey(button.introduce.text) && + Utils.CheckForUntranslatedText(button.introduce.text)) + button.introduce.text = StringStore.TranslateText(button.introduce.text); + } +} + +//List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; +//string buff = (__instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText("无"); +//__instance.introduce.text = buff; diff --git a/Source/Patches/Modes/Odyssey/TravelBuff_Patch.cs b/Source/Patches/Modes/Odyssey/TravelBuff_Patch.cs new file mode 100644 index 0000000..df2122d --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelBuff_Patch.cs @@ -0,0 +1,19 @@ +#if false +using HarmonyLib; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelBuff))] +public static class TravelBuff_Patch +{ + [HarmonyPatch(nameof(TravelBuff.OnMouseUpAsButton)), HarmonyPostfix] + private static void OnMouseUpAsButton() + { + if (TravelBuffMgr.Instance == null) + return; + + TravelBuffMgr.Instance.text = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text); + TravelBuffMgr.Instance.text2 = AssetStore.StringStore.TranslateText(TravelBuffMgr.Instance.text2); + } +} +#endif diff --git a/Source/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs b/Source/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs new file mode 100644 index 0000000..476adb7 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs @@ -0,0 +1,24 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelInvestMenu))] +public static class TravelInvestMenu_Patch +{ + [HarmonyPatch(nameof(TravelInvestMenu.Start)), HarmonyPostfix] + private static void Start(TravelInvestMenu __instance) + { + var titleText = __instance.transform.Find("Title"); + var shadowText = titleText.GetComponent(); + + var regularText = titleText.transform.Find("Title2").GetComponent(); + regularText.text = StringStore.TranslateText(regularText.text); + + shadowText.text = Utils.RemoveColorTags(regularText.text); + } + + [HarmonyPatch(nameof(TravelInvestMenu.RefreshBuff)), HarmonyPostfix] + private static void RefreshBuff(TravelInvestMenu __instance, ref TravelBuffOptionButton option) => + TravelBuffOptionButton_Patch.TranslateOptionButton(option); +} diff --git a/Source/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs b/Source/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs new file mode 100644 index 0000000..c15256d --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelLookBuff_Patch.cs @@ -0,0 +1,57 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelLookBuff))] +public static class TravelLookBuff_Patch +{ + [HarmonyPatch(nameof(TravelLookBuff.Clear)), HarmonyPostfix] + public static void Post_Clear(TravelLookBuff __instance) + { + __instance.introduce.text = StringStore.TranslateText("无"); + __instance.set = false; + + foreach (var text in __instance.transform.FindChild("Images") + .FindChild("Button") + .GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton)), HarmonyPostfix] + public static void Post_OnMouseUpAsButton(TravelLookBuff __instance) + { + foreach (var text in __instance.transform.FindChild("Images") + .FindChild("Button") + .GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(TravelLookBuff.SetBuff)), HarmonyPostfix] + public static void Post_SetBuff(TravelLookBuff __instance) + { + /*SortedDictionary buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; + string buffText = buffSet.ContainsKey(__instance.buffIndex) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); + __instance.introduce.text = buffText;*/ + + foreach (var text in __instance.transform.FindChild("Images") + .FindChild("Introduce") + .GetComponentsInChildren()) + { + if (TravelBuffString.TryGetValue(text.text, out var translatedBuff)) + text.text = AddBuffName(translatedBuff); + + if (!Utils.CheckForUntranslatedText(text.text)) + text.text = AddBuffName(text.text); + + if (!TravelBuffString.ContainsKey(text.text) && Utils.CheckForUntranslatedText(text.text)) + text.text = StringStore.TranslateText(text.text); + } + + foreach (var text in __instance.transform.FindChild("Images") + .FindChild("Button") + .GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs b/Source/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs new file mode 100644 index 0000000..ad6f659 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelLookMenu_Patch.cs @@ -0,0 +1,42 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelLookMenu))] +public static class TravelLookMenu_Patch +{ +#pragma warning disable CA2211 + public static string SavedAssetString = ""; +#pragma warning restore CA2211 + [HarmonyPatch(nameof(TravelLookMenu.Start)), HarmonyPostfix] + private static void Postfix_Start(TravelLookMenu __instance) + { + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + var quitButtonTransform = __instance.transform.Find("Quit"); + + foreach (var txt in quitButtonTransform.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText("合上"); + txt.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + + __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); + SavedAssetString = __instance.treasureText.text; + } + + [HarmonyPatch(nameof(TravelLookMenu.Update)), HarmonyPostfix] + private static void Update(TravelLookMenu __instance) + { + if (SavedAssetString == __instance.treasureText.text) + return; + + __instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text); + SavedAssetString = __instance.treasureText.text; + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelMgr_Patch.cs b/Source/Patches/Modes/Odyssey/TravelMgr_Patch.cs new file mode 100644 index 0000000..40ac83f --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelMgr_Patch.cs @@ -0,0 +1,312 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +public sealed class TravelBuffInfo(string nameA = "", string descA = "") +{ + public readonly string Name = nameA; + public readonly string Desc = descA; +} + +public sealed class TravelBuffSet +{ + public readonly SortedDictionary + AdvancedBuffs, + UltimateBuffs, + Debuffs, + Unlocks, + InvestmentBuffs; + + private readonly Dictionary> _travelBuffSets; + + public TravelBuffSet() + { + AdvancedBuffs = new(); + UltimateBuffs = new(); + Debuffs = new(); + Unlocks = new(); + InvestmentBuffs = new(); + + _travelBuffSets = new() + { + { "advancedBuffs", AdvancedBuffs }, + { "ultimateBuffs", UltimateBuffs }, + { "debuffs", Debuffs }, + { "unlocks", Unlocks }, + { "investmentBuffs", InvestmentBuffs }, + }; + } + + public SortedDictionary TryGet(string name) => + name switch + { + "advancedBuffs" => AdvancedBuffs, + "ultimateBuffs" => UltimateBuffs, + "debuffs" => Debuffs, + "unlocks" => Unlocks, + "investmentBuffs" => InvestmentBuffs, + _ => null, + }; + + public IEnumerator>> GetEnumerator() => + _travelBuffSets.Select(item => (item.Key, item.Value)).GetEnumerator(); +} + +[HarmonyPatch(typeof(TravelMgr))] +public static class TravelMgr_Patch +{ + public static readonly TravelBuffSet TemplateTravelBuffs = new(); + + public static readonly Dictionary TravelBuffString = new(); +#pragma warning disable CA2211 + public static TravelBuffSet DumpedTravelBuffs = new(); + + public static TravelBuffSet TranslatedTravelBuffs = new(); + + public static Dictionary BuffLinks = new() + { + { BuffType.AdvancedBuff, "advancedBuffs" }, + { BuffType.UltimateBuff, "ultimateBuffs" }, + { BuffType.Debuff, "debuffs" }, + { BuffType.UnlockPlant, "unlocks" }, + { BuffType.InvestmentBuff, "investmentBuffs" }, + }; +#pragma warning restore CA2211 + [HarmonyPatch(nameof(TravelMgr.GetText)), HarmonyPostfix] + public static void GetText(TravelMgr __instance, ref string result) + { + if (TravelBuffString.TryGetValue(result, out var value)) + result = value; + else if (TravelBuffString.ContainsKey(RemoveBuffName(result))) + result = TravelBuffString[RemoveBuffName(result)]; + else + result = StringStore.TranslateText(result); + } + + public static void DumpTravelBuffs() + { + TravelMgr.Instance.GetPlantBuffUnlockCount(PlantType.DoomGatling); + + DumpedTravelBuffs = new(); + TravelBuffString.Clear(); + + foreach (var pair in TravelDictionary.advancedBuffsText) + { + Utils.TryAdd(DumpedTravelBuffs.AdvancedBuffs, (int)pair.Key, new("", pair.Value)); + Utils.TryAdd(TravelBuffString, pair.Value, pair.Value); + } + + foreach (var pair in TravelDictionary.ultimateBuffsText) + { + Utils.TryAdd(DumpedTravelBuffs.UltimateBuffs, (int)pair.Key, new("", pair.Value)); + Utils.TryAdd(TravelBuffString, pair.Value, pair.Value); + } + + foreach (var pair in TravelDictionary.debuffData) + { + Utils.TryAdd(DumpedTravelBuffs.Debuffs, (int)pair.Key, new("", pair.Value.Item1)); + Utils.TryAdd(TravelBuffString, pair.Value.Item1, pair.Value.Item1); + } + + foreach (var pair in TravelDictionary.unlocksText) + { + Utils.TryAdd(DumpedTravelBuffs.Unlocks, (int)pair.Key, new("", pair.Value)); + Utils.TryAdd(TravelBuffString, pair.Value, pair.Value); + } + + foreach (var pair in TravelMgr.InvestBuffsData) + { + Utils.TryAdd( + DumpedTravelBuffs.InvestmentBuffs, + (int)pair.Key, + new("", pair.Value.Description) + ); + + Utils.TryAdd(TravelBuffString, pair.Value.Description, pair.Value.Description); + } + + File.WriteAllText( + Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "travel_buffs.json"), + FileLoader.SerializeWithIndentation(DumpedTravelBuffs) + ); + + var translatedTravelBuffsPath = Path.Combine( + FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), + "travel_buffs.json" + ); + + if (File.Exists(translatedTravelBuffsPath)) + return; + + File.WriteAllText(translatedTravelBuffsPath, FileLoader.SerializeWithIndentation(DumpedTravelBuffs)); + TranslatedTravelBuffs = DumpedTravelBuffs; + } + + //System.Text.Json.JsonSerializer.Deserialize>>(travelBuffsContent); + public static void GenerateTranslatedTravelBuffs(string travelBuffsContent) + { + if (!Core.IsInitialized) + return; + + DumpTravelBuffs(); + + var travelBuffs = Newtonsoft.Json.JsonConvert.DeserializeObject(travelBuffsContent); + TranslatedTravelBuffs = travelBuffs; + TravelBuffString.Clear(); + + foreach (var i in travelBuffs) + { + var originalBuffSet = DumpedTravelBuffs.TryGet(i.Item1); + + foreach (var (key, originalBuff) in originalBuffSet) + { + var translatedBuffSet = travelBuffs.TryGet(i.Item1); + + if (originalBuff.Desc != RemoveBuffName(originalBuff.Desc)) + continue; + + if (translatedBuffSet.TryGetValue(key, out var value)) + Utils.TryAdd(TravelBuffString, originalBuff.Desc, value.Desc); +#if false + var translatedBuffSet = travelBuffs[i.Key]; + + if (!translatedBuffSet.ContainsKey(j.Key)) + continue; + + string translatedBuff = travelBuffs[i.Key][j.Key]; + travelBuffString[originalBuff] = translatedBuff; +#endif + } + } + + var travelBuffsToSave = FileLoader.SerializeWithIndentation(TranslatedTravelBuffs); + var stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); + File.WriteAllText(Path.Combine(stringDir, "travel_buffs.json"), travelBuffsToSave); + } + + public static string MatchTravelBuff(string originalText) + { + var res = ""; + + foreach (var i in DumpedTravelBuffs) + { + foreach (var j in DumpedTravelBuffs.TryGet(i.Item1)) + if (j.Value.Desc == originalText || j.Value.Desc == RemoveBuffName(originalText)) + { + var translatedBuffSet = TranslatedTravelBuffs.TryGet(i.Item1); + + if (translatedBuffSet.TryGetValue(j.Key, out var value)) + res = value.Desc; + + break; + } + + if (res != "") + break; + } + + return res; + } + + public static string RemoveBuffName(string buffText) + { + var res = buffText; + var firstColon = res.IndexOf(":", StringComparison.Ordinal); + + if (firstColon > 0) + res = res[(firstColon + 1)..]; + + return res; + } + + public static readonly Dictionary ModifierNameDict = new() + { + { "advancedBuffs", "COMMON_MODIFIER_TAG" }, + { "ultimateBuffs", "EPIC_MODIFIER_TAG" }, + { "debuffs", "ZOMBIE_MODIFIER_TAG" }, + { "unlocks", "UNLOCK_MODIFIER_TAG" }, + { "investmentBuffs", "INVEST_MODIFIER_TAG" }, + }; + + public static readonly Dictionary FallbackNameDict = new() + { + { "COMMON_MODIFIER_TAG", "Common Modifier" }, + { "EPIC_MODIFIER_TAG", "Epic Modifier" }, + { "ZOMBIE_MODIFIER_TAG", "Zombie Modifier" }, + { "UNLOCK_MODIFIER_TAG", "Unlock Modifier" }, + { "INVEST_MODIFIER_TAG", "Investment Modifier" }, + }; + + public static string TranslateNameTag(string originalText) + { + var nameTag = ModifierNameDict[originalText]; + + return StringStore.TranslationString.ContainsKey(nameTag) + ? StringStore.TranslateText(nameTag) + : FallbackNameDict[nameTag]; + } + + public static ValueTuple FindBuffData(string buffText) + { + ValueTuple res = new(); + + foreach (var pair1 in TranslatedTravelBuffs) + { + foreach (var pair2 in pair1.Item2.Where(pair2 => buffText == pair2.Value.Desc)) + { + if (pair2.Value.Name != "") + { + res.Item1 = pair2.Value.Name; + res.Item4 = true; + } + else + { + res.Item1 = TranslateNameTag(pair1.Item1); + res.Item4 = false; + } + + res.Item2 = pair2.Key; + } + } + + foreach (var pair1 in DumpedTravelBuffs) + { + foreach (var pair2 in pair1.Item2.Where(pair2 => buffText == pair2.Value.Desc)) + { + (res.Item1, res.Item4) = pair2.Value.Name != "" + ? (pair2.Value.Name, true) + : (TranslateNameTag(pair1.Item1), false); + + res.Item2 = pair2.Key; + } + } + + var finalBuffText = TravelBuffString.TryGetValue(buffText, out var value) + ? value + : StringStore.TranslateText(buffText); + + res.Item3 = finalBuffText; + + return res; + } + + // public static string FallbackFBuffStr = "{0}: {1}"; + + public static string AddBuffName(string buffText) + { + var translatedBuff = buffText; + + if (Utils.CheckForUntranslatedText(buffText)) + if (TravelBuffString.TryGetValue(buffText, out var value)) + translatedBuff = value; + + var buffData = FindBuffData(translatedBuff); + + if (buffData is not { Item1: not null, Item3: not null }) + return translatedBuff; + + var buffFStr = StringStore.TranslationStringRegex.GetValueOrDefault("BUFF_NAME_FORMAT", "{0}: {1}"); + return string.Format(buffFStr, buffData.Item1, buffData.Item3); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelRefresh_Patch.cs b/Source/Patches/Modes/Odyssey/TravelRefresh_Patch.cs new file mode 100644 index 0000000..ae4aeca --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelRefresh_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelRefresh))] +public static class TravelRefresh_Patch +{ + [HarmonyPatch(nameof(TravelRefresh.Awake)), HarmonyPostfix] + private static void Awake(TravelRefresh __instance) + { + __instance.text = StringStore.TranslateText(__instance.text); + __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); + } + + [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton)), HarmonyPostfix] + private static void OnMouseUpAsButton(TravelRefresh __instance) + { + __instance.text = StringStore.TranslateText(__instance.text); + __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs b/Source/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs new file mode 100644 index 0000000..dd7b489 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelStoreWindow_Patch.cs @@ -0,0 +1,81 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; +using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelStoreWindow))] +public static class TravelStoreWindow_Patch +{ + [HarmonyPatch(nameof(TravelStoreWindow.SetType)), HarmonyPostfix] + private static void SetType(TravelStoreWindow __instance) + { +#if false + var buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; + + var buff = __instance.show != null && __instance.introduce.text != "词条已选完" + ? buffSet[__instance.buffIndex] + : StringStore.TranslateText("词条已选完"); +#endif + var originalText = __instance.introduce.text; + const string AffinityPattern = "([\\s\\S]+)(\\\n)([\\s\\S]+)(<\\/color>)"; + + if (Regex.IsMatch(__instance.introduce.text, AffinityPattern, RegexOptions.Singleline)) + { + var match = Regex.Match(__instance.introduce.text, AffinityPattern, RegexOptions.Singleline); + var startText = match.Groups[1].Value; + var affinityText = match.Groups[3].Value; + var affinities = TranslateAffinities(affinityText); + __instance.introduce.text = AddBuffName(startText) + affinities; + } + else + __instance.introduce.text = AddBuffName(originalText); + + foreach (var text in __instance.buttonText) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(TravelStoreWindow.UpdateButtonText)), HarmonyPostfix] + private static void UpdateButtonText(TravelStoreWindow __instance) + { + foreach (var text in __instance.buttonText) + text.text = StringStore.TranslateText(text.text); + } + + public static string TranslateAffinities(string originalText) + { + List translatedAffinities = []; + var lines = originalText.Split('\n'); + + foreach (var line in lines) + { + if (string.IsNullOrEmpty(line)) + continue; + + var fStr = StringStore.TranslationStringRegex.GetValueOrDefault("【([^\\s]+)】_IV", "[{0}]"); + + // Extract dynamic parts from the original text + var regex = new Regex("【([^\\s]+)】"); + var match = regex.Match(line); + var groupCount = match.Groups.Count; + + // List to hold formatted dynamic parts + List dynamicParts = []; + + // Loop through each group and determine its translation + for (var i = 1; i < groupCount; i++) + { + var groupValue = match.Groups[i].Value; + var translatedValue = StringStore.TranslationString.GetValueOrDefault(groupValue, groupValue); + dynamicParts.Add(translatedValue); + } + + // Format the output string with dynamic parts + var translatedAffinity = string.Format(fStr, [..dynamicParts]); + translatedAffinities.Add(translatedAffinity); + } + + return $"\n{string.Join("\n", translatedAffinities)}"; + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelStore_Patch.cs b/Source/Patches/Modes/Odyssey/TravelStore_Patch.cs new file mode 100644 index 0000000..ecb75d7 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelStore_Patch.cs @@ -0,0 +1,60 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelStore))] +public static class TravelStore_Patch +{ + [HarmonyPatch(nameof(TravelStore.Start)), HarmonyPostfix] + private static void Start(TravelStore __instance) => TranslateStoreText(__instance); + + [HarmonyPatch(nameof(TravelStore.Update)), HarmonyPostfix] + private static void Update(TravelStore __instance) => TranslateStoreText(__instance); + + [HarmonyPatch(nameof(TravelStore.RefreshBuff)), HarmonyPostfix] + private static void RefreshBuff(TravelStore __instance) => TranslateStoreText(__instance); + + [HarmonyPatch(nameof(TravelStore.SelectBuff)), HarmonyPostfix] + private static void SelectBuff(TravelStore __instance, ref TravelStoreWindow window) + { + TranslateStoreText(__instance); + + foreach (var text in window.buttonText) + text.text = StringStore.TranslateText(text.text); + + __instance.investText.text = TranslateInvestText(__instance.investText.text); + __instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text); + } + + public static void TranslateStoreText(TravelStore __instance) + { + __instance.investText.text = TranslateInvestText(__instance.investText.text); + __instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text); + + foreach (var text in __instance.pointText) + text.text = StringStore.TranslateText(text.text); + + foreach (var text in __instance.refreshText) + text.text = StringStore.TranslateText(text.text); + + foreach (var text in __instance.transform.Find("Quit").GetComponentsInChildren()) + text.text = StringStore.TranslateText("合上"); + } + + public static string TranslateInvestText(string investText) + { + if (!Utils.CheckForUntranslatedText(investText)) + return investText; + + var investStats = investText.Split("\n\n"); + + var translatedInvestStats = investStats + .Select(investStat => investStat.Split("\n")) + .Select(lines => lines.Select(line => StringStore.TranslateColorText(line)).ToList()) + .Select(translatedLines => string.Join("\n", translatedLines)) + .ToList(); + + return string.Join("\n\n", translatedInvestStats); + } +} diff --git a/Source/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs b/Source/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs new file mode 100644 index 0000000..4dc3e29 --- /dev/null +++ b/Source/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs @@ -0,0 +1,87 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey; + +[HarmonyPatch(typeof(TravelSynergyMenu))] +public static class TravelSynergyMenu_Patch +{ + [HarmonyPatch(nameof(TravelSynergyMenu.Awake)), HarmonyPostfix] + public static void Awake(TravelSynergyMenu __instance) + { + var background = __instance.transform.Find("Background"); + var tip = __instance.transform.Find("Text (TMP)"); + + foreach (var text in background.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + + foreach (var text in tip.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} + +[HarmonyPatch(typeof(SynergyNode))] +public static class SynergyNode_Patch +{ + [HarmonyPatch(nameof(SynergyNode.InitNode)), HarmonyPostfix] + public static void InitNode(SynergyNode __instance) + { + var firstNewlineIndex = __instance.synergyTitle.text.IndexOf("\n", StringComparison.Ordinal); + var title = __instance.synergyTitle.text[..firstNewlineIndex]; + var description = __instance.synergyTitle.text[(firstNewlineIndex + 1)..]; + description = description[..8] == "" ? description[8..] : description; + + const string Pattern = @"]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+"; + const string SmallPattern = "(]+>)(.*?)()"; + var matches = Regex.Matches(description, Pattern); + var translatedDescription = ""; + + foreach (Match match in matches) + { + var colorMatch = Regex.Match(match.Value, SmallPattern, RegexOptions.Singleline); + + if (colorMatch.Success) + translatedDescription += colorMatch.Groups[1].Value + + TranslateSegment(colorMatch.Groups[2].Value) + + colorMatch.Groups[3].Value; + else + translatedDescription += TranslateSegment(match.Value) + "\n"; + } + + __instance.synergyTitle.text = + "" + StringStore.TranslateColorText(title) + "\n" + translatedDescription; + } + + public static string TranslateSegment(string text) + { + var res = ""; + + var parts = SplitSecondNewLines(text); + + foreach (var part in parts) + { + var temp = ""; + var lines = part.Split('\n'); + + if (lines.Length > 1) + temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]); + + res += temp + "\n"; + } + + return res[..^1]; + } + + public static List SplitSecondNewLines(string originalText) + { + var results = new List(); + + var lines = originalText.Split('\n'); + + for (var i = 0; i < lines.Length; i += 2) + results.Add(i + 1 < lines.Length ? lines[i] + "\n" + lines[i + 1] : lines[i]); + + return results; + } +} diff --git a/Source/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs new file mode 100644 index 0000000..fb84b70 --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs @@ -0,0 +1,51 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureEvolutionMenu))] +public static class AdvantureEvolutionMenu_Patch +{ + [HarmonyPatch(nameof(AdvantureMenu.Awake)), HarmonyPostfix] + public static void Awake(AdvantureEvolutionMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); + + var baseWindow = __instance.transform.Find("BaseWindow"); + var advancedWindow = __instance.transform.Find("AdvancedWindow"); + + if (baseWindow != null) + foreach (var text in baseWindow.GetComponentsInChildren() + .Where(text => text.gameObject.name.Contains("Name"))) + text.text = Utils.GetPlantNameFromAlmanac(__instance.thePlantType); + + if (advancedWindow == null) + return; + + foreach (var text in advancedWindow.GetComponentsInChildren() + .Where(text => text.gameObject.name.Contains("Name"))) + text.text = Utils.GetPlantNameFromAlmanac(__instance.thePlantType); + } + + [HarmonyPatch(nameof(AdvantureEvolutionMenu.UpdateText)), HarmonyPostfix] + public static void UpdateText(AdvantureEvolutionMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); + } + + [HarmonyPatch(nameof(AdvantureEvolutionMenu.RollEvolution)), HarmonyPostfix] + public static void RollEvolution(AdvantureEvolutionMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); + } + + [HarmonyPatch(nameof(AdvantureEvolutionMenu.RollEvolutionGood)), HarmonyPostfix] + public static void RollEvolutionGood(AdvantureEvolutionMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); + } +} diff --git a/Source/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs new file mode 100644 index 0000000..238f3ca --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureHelpMenu_Patch.cs @@ -0,0 +1,15 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureHelpMenu))] +public static class AdvantureHelpMenu_Patch +{ + [HarmonyPatch(nameof(AdvantureHelpMenu.InitText)), HarmonyPostfix] + private static void InitText(AdvantureHelpMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs new file mode 100644 index 0000000..0b337ac --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureMenu2_Patch.cs @@ -0,0 +1,19 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureMenu2))] +public static class AdvantureMenu2_Patch +{ + [HarmonyPatch(nameof(AdvantureMenu2.Awake)), HarmonyPostfix] + private static void Awake(AdvantureMenu2 __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(AdvantureMenu2.AdjustDifficulty)), HarmonyPostfix] + private static void AdjustDifficulty(AdvantureMenu2 __instance) => + __instance.difficulty.text = StringStore.TranslateText(__instance.difficulty.text); +} diff --git a/Source/Patches/Modes/Starbound/AdvantureMenu_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureMenu_Patch.cs new file mode 100644 index 0000000..5f2c077 --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureMenu_Patch.cs @@ -0,0 +1,43 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureMenu))] +public static class AdvantureMenu_Patch +{ + [HarmonyPatch(nameof(AdvantureMenu.Start)), HarmonyPostfix] + private static void Start(AdvantureMenu __instance) => TranslateAdvantureMenu(__instance); + + [HarmonyPatch(nameof(AdvantureMenu.ChangeDifficulty)), HarmonyPostfix] + private static void ChangeDifficulty(AdvantureMenu __instance) => TranslateAdvantureMenu(__instance); + + [HarmonyPatch(nameof(AdvantureMenu.GetChapterDifficulty)), HarmonyPostfix] + private static void GetChapterDifficulty(AdvantureMenu __instance) => TranslateAdvantureMenu(__instance); + + [HarmonyPatch(nameof(AdvantureMenu.UpdateChapterDifficulty)), HarmonyPostfix] + private static void UpdateChapterDifficulty(AdvantureMenu __instance) => TranslateAdvantureMenu(__instance); + + [HarmonyPatch(nameof(AdvantureMenu.UpdateStarCount)), HarmonyPostfix] + private static void UpdateStarCount(AdvantureMenu __instance) => TranslateAdvantureMenu(__instance); + + public static void TranslateAdvantureMenu(AdvantureMenu __instance) + { + var hasSbString = StringStore.TranslationString.ContainsKey(__instance.difficulty.text + "_SB"); + + __instance.difficulty.text = Utils.RemoveSizeTags( + hasSbString + ? StringStore.TranslateText(__instance.difficulty.text + "_SB") + : StringStore.TranslateText(__instance.difficulty.text) + ); + + __instance.chapterDifficulty.text = StringStore.TranslateText(__instance.chapterDifficulty.text); + __instance.starCount.text = StringStore.TranslateText(__instance.starCount.text); + + foreach (var text in __instance.title) + text.text = StringStore.TranslateText(text.text); + + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs new file mode 100644 index 0000000..0c1c55c --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureMissionMenu_Patch.cs @@ -0,0 +1,41 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureMissionMenu))] +public static class AdvantureMissionMenu_Patch +{ + [HarmonyPatch(nameof(AdvantureMissionMenu.Awake)), HarmonyPostfix] + private static void Awake(AdvantureMissionMenu __instance) + { + foreach (var text in __instance.contant.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); +#if false + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); +#endif + } + + [HarmonyPatch(nameof(AdvantureMissionMenu.InitText)), HarmonyPostfix] + private static void InitText(AdvantureMissionMenu __instance) + { + foreach (var text in __instance.contant.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); +#if false + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); +#endif + } + + [HarmonyPatch(nameof(AdvantureMissionMenu.SwitchAward)), HarmonyPostfix] + private static void SwitchAward(AdvantureMissionMenu __instance) + { + foreach (var text in __instance.contant.GetComponentsInChildren()) + text.text = StringStore.TranslateColorText(text.text); +#if false + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); +#endif + } +} diff --git a/Source/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs b/Source/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs new file mode 100644 index 0000000..6230b24 --- /dev/null +++ b/Source/Patches/Modes/Starbound/AdvantureStarMenu_Patch.cs @@ -0,0 +1,43 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Starbound; + +[HarmonyPatch(typeof(AdvantureStarMenu))] +public static class AdvantureStarMenu_Patch +{ + [HarmonyPatch(nameof(AdvantureStarMenu.Awake)), HarmonyPostfix] + private static void Awake(AdvantureStarMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(AdvantureStarMenu.GetNodes)), HarmonyPostfix] + private static void GetNodes(AdvantureStarMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(AdvantureStarMenu.UpdateStarText)), HarmonyPostfix] + private static void UpdateStarText(AdvantureStarMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(AdvantureStarMenu.InitTalents)), HarmonyPostfix] + private static void InitTalents(AdvantureStarMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } + + [HarmonyPatch(nameof(AdvantureStarMenu.ResetAward)), HarmonyPostfix] + private static void ResetAward(AdvantureStarMenu __instance) + { + foreach (var text in __instance.GetComponentsInChildren()) + text.text = StringStore.TranslateText(text.text); + } +} diff --git a/Source/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs b/Source/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs new file mode 100644 index 0000000..5ce9a45 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomButton_enterGame_Patch.cs @@ -0,0 +1,108 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomButton_enterGame))] +public static class CustomButtonEnterGamePatch +{ + [HarmonyPatch(nameof(CustomButton_enterGame.LoadOnlineLevelAsync)), HarmonyPostfix] + public static void LoadOnlineLevelAsync(CustomButton_enterGame __instance) + { + var dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); + var dumpData = new Dictionary(); + + if (!File.Exists(dumpPath)) + File.WriteAllText( + dumpPath, + JsonSerializer.Serialize( + dumpData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + dumpData = JsonSerializer.Deserialize>(File.ReadAllText(dumpPath)); + + var dumpStringsPath = Path.Combine( + FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), + "custom_level_strings.json" + ); + + var dumpStringsData = new Dictionary(); + + if (!File.Exists(dumpStringsPath)) + File.WriteAllText( + dumpStringsPath, + JsonSerializer.Serialize( + dumpStringsData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + dumpStringsData = JsonSerializer.Deserialize>(File.ReadAllText(dumpStringsPath)); + + if (__instance.onlineLevelInfo != null) + { + var levelId = __instance.onlineLevelInfo.levelId; + + if (levelId != null) + { + var serializedLevel = __instance.serializedLevel; + + if (CustomLevelMenu_Patch.TranslatedLevelData.TryGetValue(levelId, out var levelData)) + { + __instance.levelName.text = levelData.Name; + serializedLevel.name = levelData.Name; + serializedLevel.boardConfig.startTip = levelData.StartTip; + } + else + { + var dumpedLevelData = new TranslatedLevelData( + __instance.onlineLevelInfo.levelName, + serializedLevel.boardConfig.startTip + ); + + dumpData[levelId] = dumpedLevelData; + } + + // foreach(var _ in level.levelData.SerializedLevelData) + } + } + else + __instance.levelName.text = StringStore.TranslateText(__instance.levelName.text); + + File.WriteAllText( + dumpPath, + JsonSerializer.Serialize( + dumpData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + File.WriteAllText( + dumpStringsPath, + JsonSerializer.Serialize( + dumpStringsData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + } +} diff --git a/Source/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs b/Source/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs new file mode 100644 index 0000000..11ba24b --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomLevelMenu_Patch.cs @@ -0,0 +1,164 @@ +using HarmonyLib; +using Newtonsoft.Json; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomLevelMenu))] +public static class CustomLevelMenu_Patch +{ +#pragma warning disable CA2211 + public static float RequestTimer; + + public static Dictionary TranslatedLevelData = new(); +#pragma warning restore CA2211 + [HarmonyPatch(nameof(CustomLevelMenu.LoadOnlineFiles)), HarmonyPostfix] + public static void LoadOnlineFiles(CustomLevelMenu __instance) + { + if (!Core.Instance.ConfigUseLocal.Value) + LoadOnlineData(); + else + LoadLocalData(); + } + + [HarmonyPatch(nameof(CustomLevelMenu.InitLocalWindows)), HarmonyPostfix] + public static void InitWindows(CustomLevelMenu __instance) => TranslateLevelButtons(__instance); + + [HarmonyPatch(nameof(CustomLevelMenu.InitOnlineWindow)), HarmonyPostfix] + public static void InitOnlineWindow(CustomLevelMenu __instance) => TranslateLevelButtons(__instance); + + [HarmonyPatch(nameof(CustomLevelMenu.ReloadFiles)), HarmonyPostfix] + public static void ReloadFiles(CustomLevelMenu __instance) => TranslateLevelButtons(__instance); + + public static void TranslateLevelButtons(CustomLevelMenu __instance) + { + var dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); + var dumpData = new Dictionary(); + + if (!File.Exists(dumpPath)) + File.WriteAllText( + dumpPath, + System.Text.Json.JsonSerializer.Serialize( + dumpData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + + foreach (var level in __instance.levels) + if (level.onlineLevelInfo != null) + { + var levelId = level.onlineLevelInfo.levelId; + + if (levelId == null) + continue; + + if (TranslatedLevelData.TryGetValue(levelId, out var levelData)) + { + level.levelName.text = levelData.Name; + level.serializedLevel.name = levelData.Name; + level.serializedLevel.boardConfig.startTip = levelData.StartTip; + } + else + { + var dumpedLevelData = new TranslatedLevelData( + level.onlineLevelInfo.levelName, + level.serializedLevel.boardConfig.startTip + ); + + dumpData.Add(levelId, dumpedLevelData); + } + } + else + level.levelName.text = StringStore.TranslateText(level.levelName.text); + + File.WriteAllText( + dumpPath, + System.Text.Json.JsonSerializer.Serialize( + dumpData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + } + + public static async Task> GetTranslatedLevelData() + { + var levelDataString = await Utils.GetDataFromWeb( + $"https://raw.githubusercontent.com/Teyliu/PVZF-Translation/refs/heads/main/PvZ_Fusion_Translator/Localization/{Utils.Language}/Strings/custom_level_data.json" + ); + + if (levelDataString != null) + { + var levelDataJson = JsonConvert.DeserializeObject>(levelDataString); + return levelDataJson; + } + + new CancellationTokenSource().Cancel(); + return null; + } + + public static void LoadOnlineData() + { + if (RequestTimer > 0) + { + Log.LogInfo( + $"Please wait before requesting levels again! Current cooldown: {Math.Round(RequestTimer, 3)}s" + ); + + return; + } + + // 5 seconds between request attempts to prevent any issues with GitHub + RequestTimer = 5f; + TranslatedLevelData = new(); + + var translatedLevelDataRequest = Task.Run(GetTranslatedLevelData); + + if (translatedLevelDataRequest.Result == null) + { + Log.LogError($"Couldn't find level data for {Utils.Language}!"); + return; + } + + TranslatedLevelData = translatedLevelDataRequest.Result; + Log.LogInfo($"Successfully loaded level data for {Utils.Language}!"); + } + + public static void LoadLocalData() + { + TranslatedLevelData = new(); + + var assetDir = Path.Combine( + FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), + "custom_level_data.json" + ); + + if (!File.Exists(assetDir)) + { + File.CreateText(assetDir); + File.WriteAllText(assetDir, "{}"); + } + + var levelDataString = File.ReadAllText(assetDir); + var levelDataJson = JsonConvert.DeserializeObject>(levelDataString); + TranslatedLevelData = levelDataJson; + } +} + +public sealed class TranslatedLevelData(string name, string startTip) +{ + // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global + public string Name { get; set; } = name; + + // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global + public string StartTip { get; set; } = startTip; +} diff --git a/Source/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs b/Source/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs new file mode 100644 index 0000000..6b8bb3d --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomMenuPage_event_Patch_B.cs @@ -0,0 +1,17 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomMenuPage_event))] // ReSharper disable once InconsistentNaming +public static class CustomMenuPage_event_Patch +{ + [HarmonyPatch(nameof(CustomMenuPage_event.InitializeNodeEditor)), HarmonyPostfix] + public static void InitializeNodeEditor(CustomMenuPage_event __instance) + { + RuntimeEventNodeEditor_Patch.Update(__instance.nodeEditor); + NodeInfoPanel_Patch.UpdatePanelContent(__instance.nodeInfoPanel); + } +} +#endif diff --git a/Source/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs b/Source/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs new file mode 100644 index 0000000..de0e9ae --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomMenuPage_initZombies_Patch.cs @@ -0,0 +1,16 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomMenuPage_initZombies))] +public static class CustomMenuPageInitZombiesPatch +{ + [HarmonyPatch(nameof(CustomMenuPage_initZombies.SubWave)), HarmonyPostfix] + public static void SubWave(CustomMenuPage_initZombies __instance) => + __instance.currentWaveText.text = StringStore.TranslateText(__instance.currentWaveText.text); + + [HarmonyPatch(nameof(CustomMenuPage_initZombies.AddWave)), HarmonyPostfix] + public static void AddWave(CustomMenuPage_initZombies __instance) => + __instance.currentWaveText.text = StringStore.TranslateText(__instance.currentWaveText.text); +} diff --git a/Source/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs b/Source/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs new file mode 100644 index 0000000..669e2e1 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomMenuPage_page3_Patch.cs @@ -0,0 +1,22 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomMenu_page3))] +public static class CustomMenuPagePage3Patch +{ + [HarmonyPatch(nameof(CustomMenu_page3.UpdateCardsText)), HarmonyPostfix] + public static void UpdateCardsText(CustomMenu_page3 __instance) + { + var plantName = Utils.GetPlantNameFromAlmanac(__instance.nameText.text); + __instance.nameText.text = plantName != "" ? plantName : StringStore.TranslateText(__instance.nameText.text); + } + + [HarmonyPatch(nameof(CustomMenu_page3.UpdateAdvancedInfo)), HarmonyPostfix] + public static void UpdateAdvancedInfo(CustomMenu_page3 __instance) + { + var plantName = Utils.GetPlantNameFromAlmanac(__instance.nameText.text); + __instance.nameText.text = plantName != "" ? plantName : StringStore.TranslateText(__instance.nameText.text); + } +} diff --git a/Source/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs b/Source/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs new file mode 100644 index 0000000..4fcb3d2 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomMenuPage_shooting_Patch.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomMenuPage_shooting))] +public static class CustomMenuPageShootingPatch +{ + [HarmonyPatch(nameof(CustomMenuPage_shooting.CreateRoute)), HarmonyPostfix] + public static void CreateRoute(CustomMenuPage_shooting __instance) => TranslateRoutes(__instance); + + [HarmonyPatch(nameof(CustomMenuPage_shooting.CreateStage)), HarmonyPostfix] + public static void CreateStage(CustomMenuPage_shooting __instance) => TranslateRoutes(__instance); + + [HarmonyPatch(nameof(CustomMenuPage_shooting.Awake)), HarmonyPostfix] + public static void Awake(CustomMenuPage_shooting __instance) => TranslateRoutes(__instance); + + [HarmonyPatch(nameof(CustomMenuPage_shooting.SearchRoute)), HarmonyPostfix] + public static void SearchRoute(CustomMenuPage_shooting __instance) => TranslateRoutes(__instance); + + [HarmonyPatch(nameof(CustomMenuPage_shooting.SearchAllRoute)), HarmonyPostfix] + public static void SearchAllRoute(CustomMenuPage_shooting __instance) => TranslateRoutes(__instance); + + public static void TranslateRoutes(CustomMenuPage_shooting __instance) + { + foreach (var text in __instance.scollContent.GetComponentsInChildren()) + if (text.name == "PlantText") + { + var plantName = Utils.GetPlantNameFromAlmanac(text.text); + text.text = plantName != "" ? plantName : StringStore.TranslateText(text.text); + } + } +} diff --git a/Source/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs b/Source/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs new file mode 100644 index 0000000..9ed876c --- /dev/null +++ b/Source/Patches/Modes/Super Editor/CustomOnlineMenu_Patch.cs @@ -0,0 +1,70 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor; + +[HarmonyPatch(typeof(CustomOnlineMenu))] +public static class CustomOnlineMenu_Patch +{ + [HarmonyPatch(nameof(CustomOnlineMenu.EditLevel)), HarmonyPostfix] + public static void EditLevel(CustomOnlineMenu __instance) => TranslateLevelName(__instance); + + [HarmonyPatch(nameof(CustomOnlineMenu.Start)), HarmonyPostfix] + public static void Start(CustomOnlineMenu __instance) => TranslateLevelName(__instance); + + public static void TranslateLevelName(CustomOnlineMenu __instance) + { + var translatedText = StringStore.TranslateText(__instance.title.text); + __instance.title.text = translatedText; + __instance.title2.text = translatedText; + + TranslateLevelData(__instance.levelData); + } + + public static void TranslateLevelData(CustomLevelData levelData) + { + var dumpData = new Dictionary(); + + if (levelData != null) + { + var levelId = levelData.levelId; + + if (levelId != null) + { + if (CustomLevelMenu_Patch.TranslatedLevelData.TryGetValue(levelId, out var translatedLevelData)) + { + levelData.Name = translatedLevelData.Name; + levelData.SerializedLevelData.name = translatedLevelData.Name; + levelData.SerializedLevelData.boardConfig.startTip = translatedLevelData.StartTip; + } + else + { + var dumpedLevelData = new TranslatedLevelData( + levelData.Name, + levelData.SerializedLevelData.boardConfig.startTip + ); + + dumpData.Add(levelId, dumpedLevelData); + } + } + } + else + levelData.Name = StringStore.TranslateText(levelData.Name); + + var dumpPath = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "custom_level_data.json"); + + File.WriteAllText( + dumpPath, + JsonSerializer.Serialize( + dumpData, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + } +} diff --git a/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs b/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs new file mode 100644 index 0000000..c3537fe --- /dev/null +++ b/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeEventNodeEditor_Patch.cs @@ -0,0 +1,43 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.BaseTextObjects; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes; + +[HarmonyPatch(typeof(RuntimeEventNodeEditor))] +public static class RuntimeEventNodeEditor_Patch +{ + public static TMP_FontAsset FontAsset => FontStore.LoadTMPFont(Utils.Language.ToString()); + + [HarmonyPatch(nameof(RuntimeEventNodeEditor.Update)), HarmonyPostfix] + public static void Update(RuntimeEventNodeEditor __instance) + { + // Translate the new screens. (version 3.7) + TranslateFullTransform(__instance.nodeInfoPanel.transform); + TranslateFullTransform(__instance.attributePanel.transform); + TranslateFullTransform(__instance.canvas.transform); + + if (__instance.TryGetComponent(out var eventNodeContextMenu)) + TranslateFullTransform(eventNodeContextMenu.transform); + } + + public static void TranslateFullTransform(Transform transform) + { + if (transform == null) + return; + + foreach (var txt in transform.GetComponentsInChildren()) + { + txt.text = RuntimeNodeUI_Patch.TranslateCodeText(txt.text); + txt.font = FontAsset; + } + + foreach (var inputField in transform.GetComponentsInChildren()) + { + TMP_InputField_Patch.OnEnable(inputField); + + foreach (var txt in inputField.GetComponentsInChildren(true)) + txt.text = RuntimeNodeUI_Patch.TranslateCodeText(txt.text); + } + } +} diff --git a/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs b/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs new file mode 100644 index 0000000..91985f0 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/GameLevel/EventNodes/RuntimeNodeUI_Patch.cs @@ -0,0 +1,119 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.BaseTextObjects; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel.EventNodes; + +[HarmonyPatch(typeof(RuntimeNodeUI))] +public static class RuntimeNodeUI_Patch +{ + [HarmonyPatch(nameof(RuntimeNodeUI.Awake)), HarmonyPatch(nameof(RuntimeNodeUI.CreatePorts)), + HarmonyPatch(nameof(RuntimeNodeUI.CreateValueEditUI)), HarmonyPatch(nameof(RuntimeNodeUI.GetPortUI)), + HarmonyPatch(nameof(RuntimeNodeUI.UpdateDisplay)), HarmonyPatch(nameof(RuntimeNodeUI.UpdateSelectionVisual)), + HarmonyPatch(nameof(RuntimeNodeUI.UpdateVisable)), HarmonyPostfix] + public static void Post_UpdateDisplay(RuntimeNodeUI __instance) + { + if (!__instance.isActiveAndEnabled) + return; + + if (__instance.Node == null) + return; + + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + __instance.titleText.text = TranslateCodeText(__instance.titleText.text); + __instance.titleText.font = fontAsset; + + foreach (var txt in __instance.inputPortsContainer.GetComponentsInChildren()) + { + txt.text = TranslateCodeText(txt.text); + txt.font = fontAsset; + } + + foreach (var txt in __instance.outputPortsContainer.GetComponentsInChildren()) + { + txt.text = TranslateCodeText(txt.text); + txt.font = fontAsset; + } + + if ( + __instance.GetComponentsInChildren().Count == 0 && + __instance.GetComponentsInChildren().Count == 0 && + __instance.Node.nodeType != "PlantTypeValueNode" && + __instance.Node.nodeType != "SinglePlantTypeListNode" && + __instance.Node.nodeType != "ZombieTypeValueNode" + ) + return; + + if (__instance.Node != null) + { + if (__instance.Node.nodeType == "PlantTypeValueNode") + foreach (var txt in __instance.GetComponentsInChildren()) + if (txt.gameObject.name.Contains("Label")) + if (Utils.CheckForUntranslatedText(txt.text)) + { + var castedNode = __instance.Node.TryCast(); + + if (castedNode == null) + continue; + + _ = castedNode.value_PortName; + var plantName = Utils.GetPlantNameFromAlmanac(castedNode.value, true); + txt.text = plantName != "" ? plantName : StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + + if (__instance.Node.nodeType == "SinglePlantTypeListNode") + foreach (var txt in __instance.GetComponentsInChildren()) + if (txt.gameObject.name.Contains("Label")) + if (Utils.CheckForUntranslatedText(txt.text)) + { + var castedNode = __instance.Node.TryCast(); + + if (castedNode == null) + continue; + + _ = castedNode.plantTypeList_PortName; + var plantName = Utils.GetPlantNameFromAlmanac(castedNode.plantType, true); + txt.text = plantName != "" ? plantName : StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + + if (__instance.Node.nodeType == "ZombieTypeValueNode") + foreach (var txt in __instance.GetComponentsInChildren()) + if (txt.gameObject.name.Contains("Label")) + if (Utils.CheckForUntranslatedText(txt.text)) + { + var castedNode = __instance.Node.TryCast(); + + if (castedNode == null) + continue; + + _ = castedNode.value_PortName; + var zombieName = Utils.GetZombieNameFromAlmanac(castedNode.value, true); + txt.text = zombieName != "" ? zombieName : StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + if (__instance.GetComponentsInChildren().Count > 0) + foreach (var dropdown in __instance.GetComponentsInChildren()) + TMP_Dropdown_Patch.CreateDropdownList(dropdown); + + if (__instance.GetComponentsInChildren().Count <= 0) + return; + + foreach (var inputField in __instance.GetComponentsInChildren()) + { + TMP_InputField_Patch.OnEnable(inputField); + + foreach (var txt in inputField.GetComponentsInChildren(true)) + txt.text = TranslateCodeText(txt.text); + } + } + + public static string TranslateCodeText(string originalText) => + StringStore.TranslationString.ContainsKey(originalText + "_code") + ? StringStore.TranslateText(originalText + "_code") + : StringStore.TranslateText(originalText); +} diff --git a/Source/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs b/Source/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs new file mode 100644 index 0000000..9564f0f --- /dev/null +++ b/Source/Patches/Modes/Super Editor/GameLevel/LevelManager_Patch.cs @@ -0,0 +1,317 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.GameLevel; + +[HarmonyPatch(typeof(LevelManager))] +public static class LevelManager_Patch +{ + [HarmonyPatch(nameof(LevelManager.SaveLevelData)), HarmonyPrefix] + public static void Pre_SaveLevelData(LevelManager __instance, ref SerializedLevelData serializedLevelData) + { + if (serializedLevelData.name == "未命名关卡") + serializedLevelData.name = StringStore.TranslationString.ContainsKey("LEVEL_UNNAMED") + ? StringStore.TranslateText("LEVEL_UNNAMED") + : "Unnamed"; + } + + public static void ExportLevelStrings(SerializedLevelData serializedLevelData) + { + var levelDataString = JsonUtility.ToJson(serializedLevelData); + var referenceLevelData = Newtonsoft.Json.JsonConvert.DeserializeObject(levelDataString); + var eventNodeGraph = serializedLevelData.eventNodeGraph; + eventNodeGraph.BuildCache(); + + var stringValueNodeIds = new List(); + var stringConcatNodeIds = new List(); + var showTextNodeIds = new List(); + var addOptionNodeIds = new List(); + + foreach (var reference in referenceLevelData.References.RefIds) + { + var nodeType = reference.Data.NodeType; + var nodeId = reference.Data.NodeId; + + switch (nodeType) + { + case "ShowTextNode": + if (!showTextNodeIds.Contains(nodeId)) + showTextNodeIds.Add(nodeId); + + break; + case "AddMultipleChoiceOptionNode": + if (!addOptionNodeIds.Contains(nodeId)) + addOptionNodeIds.Add(nodeId); + + break; + } + } + + foreach (var reference in referenceLevelData.References.RefIds) + { + var nodeType = reference.Data.NodeType; + var nodeId = reference.Data.NodeId; + + switch (nodeType) + { + case "StringValueNode": + case "FloatToStringNode": + case "StringConcatNode": + stringValueNodeIds.Add(nodeId); + + if (nodeType == "StringConcatNode") + stringConcatNodeIds.Add(nodeId); + + break; + } + } + + Dictionary> stringConcatNodePairs = new(); + + foreach (var connection in eventNodeGraph.connections) + { + var sourceNodeId = connection.sourceNodeId; + _ = connection.sourcePortName; + var targetNodeId = connection.targetNodeId; + var targetPortName = connection.targetPortName; + + if (!stringValueNodeIds.Contains(sourceNodeId)) + continue; + + if (!stringConcatNodeIds.Contains(targetNodeId)) + continue; + + if (stringConcatNodePairs.ContainsKey(targetNodeId)) + { + var temp = stringConcatNodePairs[targetNodeId]; + + switch (targetPortName) + { + case "A": + temp.Item1 = sourceNodeId; + stringConcatNodePairs[targetNodeId] = temp; + break; + case "B": + temp.Item2 = sourceNodeId; + stringConcatNodePairs[targetNodeId] = temp; + break; + } + } + else + { + stringConcatNodePairs.Add(targetNodeId, new()); + var temp = stringConcatNodePairs[targetNodeId]; + + switch (targetPortName) + { + case "A": + temp.Item1 = sourceNodeId; + stringConcatNodePairs[targetNodeId] = temp; + break; + case "B": + temp.Item2 = sourceNodeId; + stringConcatNodePairs[targetNodeId] = temp; + break; + } + } + } + + string GetStringNodeValue(EventNodeBase eventNodeBase) + { + var stringValue = ""; + + switch (eventNodeBase.nodeType) + { + case "StringValueNode": + var stringNode = eventNodeBase.Cast(); + stringValue = stringNode.value; + break; + case "FloatToStringNode": + stringValue = "([^\\s]+)"; + break; + case "StringConcatNode": + var stringConcatNode = eventNodeBase.Cast(); + stringConcatNode.InitializeConnections(eventNodeGraph); + + stringValue = GetStringNodeValue(stringConcatNode.aSourceNode) + + GetStringNodeValue(stringConcatNode.bSourceNode); + + break; + } + + return stringValue; + } + + var baseDumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps); + var levelDumpDir = Path.Combine(baseDumpDir, "CustomLevels.json"); + + if (!File.Exists(levelDumpDir)) + File.WriteAllText(levelDumpDir, "{}"); + + var dump = JsonSerializer.Deserialize>(File.ReadAllText(levelDumpDir)); + + foreach (var showTextNode in showTextNodeIds + .Select(showTextNodeId => eventNodeGraph.GetNodeById(showTextNodeId).Cast())) + { + showTextNode.InitializeConnections(eventNodeGraph); + var value = GetStringNodeValue(showTextNode.textSourceNode); + dump.TryAdd(value, value); + } + + foreach (var addOptionNode in addOptionNodeIds.Select( + addOptionId => eventNodeGraph.GetNodeById(addOptionId).Cast() + )) + { + addOptionNode.InitializeConnections(eventNodeGraph); + var titleValue = GetStringNodeValue(addOptionNode.titleSourceNode); + dump.TryAdd(titleValue, titleValue); + var descriptionValue = GetStringNodeValue(addOptionNode.descriptionSourceNode); + dump.TryAdd(descriptionValue, descriptionValue); + } + + File.WriteAllText( + levelDumpDir, + JsonSerializer.Serialize( + dump, + new JsonSerializerOptions + { + WriteIndented = true, + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, + } + ) + ); + } + + // Reference level data classes. + public sealed class ReferenceLevelData + { + public References References { get; set; } + } + + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class Data + { + public string NodeId { get; set; } + + public string NodeType { get; set; } + + public Position Position { get; set; } + + public string NodeName { get; set; } + + public string PlantPortName { get; set; } + + public string ColumnPortName { get; set; } + + public string RowPortName { get; set; } + + public string PlantTypePortName { get; set; } + + public object Value { get; set; } + + public string ValuePortName { get; set; } + + public string PlantTypeAPortName { get; set; } + + public string PlantTypeBPortName { get; set; } + + public string EqualPortName { get; set; } + + public string TriggerPortName { get; set; } + + public string CountPortName { get; set; } + + public string OutputPortName { get; set; } + + public string IndexPortName { get; set; } + + public string PlantsPortName { get; set; } + + public string PlantListPortName { get; set; } + + public string LoopBodyPortName { get; set; } + + public string CurrentPlantPortName { get; set; } + + public string CurrentIndexPortName { get; set; } + + public string OnCompletedPortName { get; set; } + + public string ConditionPortName { get; set; } + + public string ThenPortName { get; set; } + + public string ElsePortName { get; set; } + + public string APortName { get; set; } + + public string BPortName { get; set; } + + public string ResultPortName { get; set; } + + public string ShouldResetPortName { get; set; } + + public string OnCountPortName { get; set; } + + public int? StartValue { get; set; } + + public string ValueAPortName { get; set; } + + public string ValueBPortName { get; set; } + + public string GreaterPortName { get; set; } + + public string LessPortName { get; set; } + + public string DisplayText { get; set; } + + public double? Duration { get; set; } + + public string TextPortName { get; set; } + + public string DurationPortName { get; set; } + + public string INTPortName { get; set; } + + public string FloatPortName { get; set; } + } + + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class Position + { + public double X { get; set; } + + public double Y { get; set; } + } + + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class References + { + public int Version { get; set; } + + // ReSharper disable once CollectionNeverUpdated.Global + public List RefIds { get; set; } + } + + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class RefId + { + public int Rid { get; set; } + + public Type Type { get; set; } + + public Data Data { get; set; } + } + + // ReSharper disable once ClassNeverInstantiated.Global + public sealed class Type + { + public string Class { get; set; } + + public string Ns { get; set; } + + public string ASM { get; set; } + } +} diff --git a/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs b/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs new file mode 100644 index 0000000..67c9090 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameChartEditorUI_Patch.cs @@ -0,0 +1,66 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.RhythmGame; + +[HarmonyPatch(typeof(RhythmGameChartEditorUI))] +public static class RhythmGameChartEditorUI_Patch +{ + [HarmonyPatch(nameof(RhythmGameChartEditorUI.Awake)), HarmonyPostfix] + public static void Awake(RhythmGameChartEditorUI __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.GetComponentsInChildren()) + { + txt.font = fontAsset; + + if (!Utils.CheckForUntranslatedText(txt.text)) + continue; + + txt.text = StringStore.TranslateText(txt.text); + } + + foreach (var txt in __instance.dropdown.GetComponentsInChildren(true)) + txt.text = StringStore.TranslateText(txt.text); + } + + [HarmonyPatch(nameof(RhythmGameChartEditorUI.Start)), HarmonyPostfix] + public static void Start(RhythmGameChartEditorUI __instance) => Awake(__instance); + + [HarmonyPatch(nameof(RhythmGameChartEditorUI.InitializeSubSystems)), HarmonyPostfix] + public static void InitializeSubSystems(RhythmGameChartEditorUI __instance) => Awake(__instance); + + [HarmonyPatch(nameof(RhythmGameChartEditorUI.Update)), HarmonyPostfix] + public static void Update(RhythmGameChartEditorUI __instance) + { + var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (var txt in __instance.transform.Find("TopPanel").GetComponentsInChildren()) + { + txt.font = fontAsset; + txt.text = StringStore.TranslateText(txt.text); + } + + foreach (var txt in __instance.transform.GetComponentsInChildren() + .SelectMany( + b => b.GetComponentsInChildren().Where(t => Utils.CheckForUntranslatedText(t.text)) + )) + txt.text = StringStore.TranslateText(txt.text); + + foreach (var txt in __instance.dropdown.GetComponentsInChildren(true) + .Where(txt => Utils.CheckForUntranslatedText(txt.text))) + txt.text = Utils.RemoveSizeTags(StringStore.TranslateText(txt.text)); + } + + [HarmonyPatch(nameof(RhythmGameChartEditorUI.UpdateUI)), HarmonyPostfix] + public static void UpdateUI(RhythmGameChartEditorUI __instance) + { + foreach (var txt in __instance.dropdown.GetComponentsInChildren(true)) + txt.text = StringStore.TranslateText(txt.text); + } + + [HarmonyPatch(nameof(RhythmGameChartEditorUI.UpdateSelectedNoteInfo)), HarmonyPostfix] + public static void UpdateSelectedNoteInfo(RhythmGameChartEditorUI __instance) => + __instance.selectedNoteInfoText.text = StringStore.TranslateText(__instance.selectedNoteInfoText.text); +} diff --git a/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs b/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs new file mode 100644 index 0000000..10df0a3 --- /dev/null +++ b/Source/Patches/Modes/Super Editor/RhythmGame/RhythmGameManager_Patch.cs @@ -0,0 +1,44 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.Modes.Super_Editor.RhythmGame; + +[HarmonyPatch(typeof(RhythmGameManager))] +public static class RhythmGameManager_Patch +{ + [HarmonyPatch(nameof(RhythmGameManager.Awake)), HarmonyPatch(nameof(RhythmGameManager.ComboUpdate)), HarmonyPostfix] + public static void Awake(RhythmGameManager __instance) + { + if (!__instance.comboText) + return; + + __instance.comboText.autoSizeTextContainer = false; + __instance.comboText.ForceMeshUpdate(); + } + + [HarmonyPatch(nameof(RhythmGameManager.OnNoteClicked)), HarmonyPostfix] + public static void OnNoteClicked(RhythmGameManager __instance) + { + if (!__instance.particle) + return; + + var txtParticle = __instance.particle.GetComponent(); + + if (!txtParticle) + return; + + var txt = txtParticle.text.GetComponent(); + + if (!txt) + return; + + var originalKey = StringStore.TranslationString.FirstOrDefault(x => x.Value == txt.text).Key; + + txt.text = StringStore.TranslationString.ContainsKey(originalKey + "_RG") + ? StringStore.TranslateText(originalKey + "_RG") + : StringStore.TranslateText(txt.text); + + txt.autoSizeTextContainer = false; + txt.ForceMeshUpdate(); + } +} diff --git a/Source/Patches/OtherManagers/AchievementClip_Patch.cs b/Source/Patches/OtherManagers/AchievementClip_Patch.cs new file mode 100644 index 0000000..b60aad6 --- /dev/null +++ b/Source/Patches/OtherManagers/AchievementClip_Patch.cs @@ -0,0 +1,63 @@ +#if false +using HarmonyLib; +using Newtonsoft.Json; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.FileLoader; +using static PvZ_Fusion_Translator.Patches.Managers.AlmanacPlantBank_Patch; + +namespace PvZ_Fusion_Translator.Patches.OtherManagers; + +[HarmonyPatch(typeof(AchievementClip))] +public static class AchievementClip_Patch +{ + [HarmonyPatch(nameof(AchievementClip.Start)), HarmonyPostfix] + private static void Start(AchievementClip __instance) + { + var (achievementDir, fontAsset) = ModFeatures.IsMultiLanguage + ? (GetAssetDir(AssetType.Almanac, Utils.Language), FontStore.LoadTMPFont(Utils.Language.ToString())) + : (GetAssetDir(AssetType.Almanac), FontStore.LoadTMPFont()); + + var path = Path.Combine(achievementDir, "AchievementsTextTranslate.json"); + + if (!File.Exists(path)) + return; + + var json = File.ReadAllText(path); + + Dictionary achievementsTexts = + new Dictionary(); + + achievementsTexts = JsonConvert.DeserializeObject>(json); + + TextMeshProUGUI text1 = __instance.introduce.transform.GetChild(1).GetComponent(); + TextMeshProUGUI text2 = __instance.introduce.transform.GetChild(2).GetComponent(); + TextMeshProUGUI name1 = __instance.image.transform.GetChild(0).GetComponent(); + + text1.text = achievementsTexts[__instance._index].Name; + text1.font = fontAsset; + text2.text = achievementsTexts[__instance._index].Name; + text2.font = fontAsset; + name1.text = achievementsTexts[__instance._index].Text; + name1.font = fontAsset; + } +} + +// ReSharper disable once ClassNeverInstantiated.Global +public sealed class AchievementObject +{ + public Achievement achievement { get; set; } + + // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global + public string Name { get; set; } + + // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Global + public string Text { get; set; } + + public AchievementObject(Achievement achievement = Achievement.Welcome, string name = "", string text = "") + { + this.achievement = achievement; + Name = name; + Text = text; + } +} +#endif diff --git a/Source/Patches/OtherManagers/GardenUI_Patch.cs b/Source/Patches/OtherManagers/GardenUI_Patch.cs new file mode 100644 index 0000000..bd4594a --- /dev/null +++ b/Source/Patches/OtherManagers/GardenUI_Patch.cs @@ -0,0 +1,12 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.OtherManagers; + +[HarmonyPatch(typeof(GardenUI))] +public static class GardenUI_Patch +{ + [HarmonyPatch(nameof(GardenUI.Update)), HarmonyPostfix] + public static void Update(GardenUI __instance) => + __instance.currentPageText = StringStore.TranslateText(__instance.currentPageText); +} diff --git a/Source/Patches/OtherManagers/MenuText_Patch.cs b/Source/Patches/OtherManagers/MenuText_Patch.cs new file mode 100644 index 0000000..930b1f8 --- /dev/null +++ b/Source/Patches/OtherManagers/MenuText_Patch.cs @@ -0,0 +1,19 @@ +#if false +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.OtherManagers; + +[HarmonyPatch(typeof(MenuText))] +public static class MenuText_Patch +{ + [HarmonyPatch(nameof(MenuText.UpdateText), typeof(string)), HarmonyPostfix] + private static void UpdateTextPatch(MenuText __instance) + { + var text1 = __instance.transform.GetChild(0).Find("text1").GetComponent(); + text1.text = StringStore.TranslateText(text1.text); + var text = __instance.transform.GetChild(0).Find("text").GetComponent(); + text.text = StringStore.TranslateText(text1.text); + } +} +#endif diff --git a/Source/Patches/OtherManagers/ThanksMenu_Patch.cs b/Source/Patches/OtherManagers/ThanksMenu_Patch.cs new file mode 100644 index 0000000..07510fa --- /dev/null +++ b/Source/Patches/OtherManagers/ThanksMenu_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using PvZ_Fusion_Translator.AssetStore; + +namespace PvZ_Fusion_Translator.Patches.OtherManagers; + +[HarmonyPatch(typeof(ThanksMenu))] +public class ThanksMenu_Patch +{ + [HarmonyPostfix, HarmonyPatch(nameof(ThanksMenu.Update))] + private static void Update(ThanksMenu __instance) + { + var textTransform = __instance.transform.GetChild(0).GetComponent(); + + if (textTransform == null) + return; + + textTransform.text = StringStore.TranslateText(textTransform.text); + textTransform.autoSizeTextContainer = true; + } +} diff --git a/Source/PvZ Fusion Translator.csproj b/Source/PvZ Fusion Translator.csproj new file mode 100644 index 0000000..dee6099 --- /dev/null +++ b/Source/PvZ Fusion Translator.csproj @@ -0,0 +1,64 @@ + + + disable + false + latest + 1.0.0.0 + /home/emik/PvZ + enable + en-US + net6.0 + 1.0.0.0 + true + PvZ_Fusion_Translator + PvZ_Fusion_Translator + false + BepInEx + + + $(DefineConstants);BEPINEX + + https://api.nuget.org/v3/index.json; + https://nuget.bepinex.dev/v3/index.json; + https://nuget.samboy.dev/v3/index.json + + + + $(DefineConstants);MELONLOADER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Utils.cs b/Source/Utils.cs new file mode 100644 index 0000000..6958efd --- /dev/null +++ b/Source/Utils.cs @@ -0,0 +1,668 @@ +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.GameObjects; +using PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects; +using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects; +using System.Diagnostics; +using System.Reflection; +using System.Text.RegularExpressions; +using UnityEngine.Experimental.Rendering; +using UnityEngine.UI; + +namespace PvZ_Fusion_Translator; + +public static class Utils +{ + internal static bool TryReplaceTexture2D(Texture2D ogTexture) + { + if (ogTexture == null) + return false; + + if (!TextureStore.TextureDict.TryGetValue(ogTexture.name, out var textureData)) + return false; + + try + { + ImageConversion.LoadImage(ogTexture, textureData); + + Log.LogDebug("OK! Replaced Texture " + ogTexture.name); + + ogTexture.name = "replaced_" + ogTexture.name; + return true; + } + catch (Exception ex) + { + Log.LogError("Failed to replace texture: " + ogTexture.name); + Log.LogError(ex.ToString()); + } + + return false; + } + + internal static Texture2D LoadImage(string path) + { + if (!File.Exists(path)) + throw new FileNotFoundException($"The image file at path '{path}' does not exist."); + + var array = File.ReadAllBytes(path); + + Texture2D texture2D = new( + 2, + 2, + GraphicsFormat.R8G8B8A8_UNorm, + TextureCreationFlags.None, + 1, + IntPtr.Zero, + null + ); + + ImageConversion.LoadImage(texture2D, array); + return texture2D; + } + + internal static Texture2D LoadImage(byte[] bytes) + { + if (bytes == null) + throw new FileNotFoundException("Byte array was null."); + + Texture2D texture2D = new( + 2, + 2, + GraphicsFormat.R8G8B8A8_UNorm, + TextureCreationFlags.None, + 1, + IntPtr.Zero, + null + ); + + ImageConversion.LoadImage(texture2D, bytes); + return texture2D; + } + + public static Color HexToColor(string hex) + { + var r = int.Parse(hex.TrimStart("#")[..2], System.Globalization.NumberStyles.HexNumber) / 255f; + var g = int.Parse(hex.TrimStart("#")[2..4], System.Globalization.NumberStyles.HexNumber) / 255f; + var b = int.Parse(hex.TrimStart("#")[4..6], System.Globalization.NumberStyles.HexNumber) / 255f; + return new(r, g, b); + } + + public static void OpenSaveDirectory() + { + var saveDirectory = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + "AppData", + "LocalLow", + "LanPiaoPiao", + "PlantsVsZombiesRH" + ); + + Process.Start("explorer.exe", saveDirectory); + } + + public static void OpenOnlineAlmanac() + { + const string Website = "https://carroti4ch.itch.io/almanac"; + Process.Start(new ProcessStartInfo(Website) { UseShellExecute = true }); + } + + public static string RemoveColorTags(string text) + { + if (string.IsNullOrEmpty(text)) + return text ?? string.Empty; + + // Remove opening color tags like + var withoutOpenTags = Regex.Replace(text, "]+>", string.Empty, RegexOptions.IgnoreCase); + // Remove closing color tags like + var withoutCloseTags = Regex.Replace(withoutOpenTags, "", string.Empty, RegexOptions.IgnoreCase); + return withoutCloseTags; + } + + public static string RemoveSizeTags(string text) + { + if (string.IsNullOrEmpty(text)) + return text ?? string.Empty; + + // Remove opening size tags like + var withoutOpenTags = Regex.Replace(text, "]+>", string.Empty, RegexOptions.IgnoreCase); + // Remove closing size tags like + var withoutCloseTags = Regex.Replace(withoutOpenTags, "", string.Empty, RegexOptions.IgnoreCase); + return withoutCloseTags; + } + + public static string RemoveFormatTags(string text) + { + if (string.IsNullOrEmpty(text)) + return text ?? string.Empty; + + var withoutUnderlineTags = Regex.Replace(text, "", string.Empty, RegexOptions.IgnoreCase); + + var withoutUnderlineCloseTags = Regex.Replace( + withoutUnderlineTags, + "", + string.Empty, + RegexOptions.IgnoreCase + ); + + var withoutItalicTags = Regex.Replace( + withoutUnderlineCloseTags, + "", + string.Empty, + RegexOptions.IgnoreCase + ); + + var withoutItalicCloseTags = Regex.Replace( + withoutItalicTags, + "", + string.Empty, + RegexOptions.IgnoreCase + ); + + return withoutItalicCloseTags; + } + + public static string RemoveAllTags(string text) + { + if (string.IsNullOrEmpty(text)) + return text ?? string.Empty; + + return RemoveColorTags(RemoveSizeTags(RemoveFormatTags(text))); + } + + public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name) + { + GameObject newObj = new(name) + { + transform = + { + position = originalText.transform.position, + }, + }; + + newObj.AddComponent(); + newObj.AddComponent(); + newObj.AddComponent(); + newObj.transform.SetParent(parent); + newObj.transform.localScale = Vector3.one; + + UnityEngine.Object.Destroy(originalText); + return newObj; + } + + public static void ConvertButtonText(Transform original, string name) + { + var fontAsset = FontStore.LoadTMPFont(Language.ToString()); + + var transform = original.FindChild(name); + var textTransform = transform.FindChild("text"); + var text = textTransform.GetComponent().text; + var color = textTransform.GetComponent().color; + + var newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2") + .GetComponent(); + + newGoBackText.autoSizeTextContainer = true; + newGoBackText.text = StringStore.TranslateText(text); + newGoBackText.font = fontAsset; + newGoBackText.color = color; + } + + public static string GetPlantNameFromAlmanac(PlantType thePlantType, bool removeTags = false, bool log = false) + { + var foundPlantName = false; + var thePlantName = ""; + + if (PlantIndices.ContainsKey((int)thePlantType)) + { + foundPlantName = true; + thePlantName = PlantIndices[(int)thePlantType].Value; + } + + if (!foundPlantName) + { + if (log) + Log.LogInfo("Couldn't find plant name!"); + + thePlantName = ""; + } + + thePlantName = removeTags ? RemoveAllTags(thePlantName) : thePlantName; + + return thePlantName; + } + + public static string GetPlantNameFromAlmanac( + string theOriginalPlantName, + bool removeTags = false, + bool log = false + ) + { + var foundPlantName = false; + var thePlantName = ""; + + if (PlantIndiceString.TryGetValue(theOriginalPlantName, out var value)) + { + foundPlantName = true; + thePlantName = value; + } + + if (!foundPlantName) + { + if (log) + Log.LogInfo("Couldn't find plant name!"); + + thePlantName = ""; + } + + thePlantName = removeTags ? RemoveAllTags(thePlantName) : thePlantName; + + return thePlantName; + } + + public static string GetZombieNameFromAlmanac(ZombieType theZombieType, bool removeTags = false) + { + var theZombieName = ""; + var json = AlmanacZombieMenu_Patch.AlmanacJson; + var zombieData = JsonUtility.FromJson(json); + + foreach (var zombieInfo in zombieData.zombies) + if ((int)zombieInfo.theZombieType == (int)theZombieType) + theZombieName = zombieInfo.name; + + theZombieName = removeTags ? RemoveAllTags(theZombieName) : theZombieName; + + return theZombieName; + } + +#pragma warning disable CA2211 + public static Dictionary> PlantIndices = new(); + + public static Dictionary PlantIndiceString = new(); +#pragma warning restore CA2211 + public static void RegisterPlantIndices() + { + PlantIndices = new(); + PlantIndiceString = new(); + + var dumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps); + var originalPath = Path.Combine(dumpDir, "LawnStrings.json"); + + if (!File.Exists(originalPath)) + Log.LogError($"LawnStrings.json file not found at path: {originalPath}"); + else + try + { + var originalJson = File.ReadAllText(originalPath); + var translatedJson = AlmanacPlantMenu_Patch.AlmanacJson; + + var originalPlantData = JsonUtility.FromJson(originalJson); + var translatedPlantData = JsonUtility.FromJson(translatedJson); + + foreach (var originalPlantInfo in originalPlantData.plants) + { + if (!PlantIndiceString.ContainsKey(originalPlantInfo.name)) + PlantIndiceString.Add(originalPlantInfo.name, originalPlantInfo.name); + + Il2CppPlantInfo translatedPlantInfo = null; + + foreach (var info in translatedPlantData.plants) + if (info.seedType == originalPlantInfo.seedType) + translatedPlantInfo = info; + + if (translatedPlantInfo is not { name: not null }) + continue; + + KeyValuePair temp = new(translatedPlantInfo.seedType, translatedPlantInfo.name); + PlantIndices.Add(originalPlantInfo.seedType, temp); + PlantIndiceString[originalPlantInfo.name] = translatedPlantInfo.name; + } + } + catch (Exception e) + { + Log.LogError(e); + } + } + + public static void TryAdd(Dictionary dict, TA key, TB val) => dict[key] = val; + + public static void TryAdd(SortedDictionary dict, TA key, TB val) => dict[key] = val; + + public static AssetBundle GetAssetBundle(Assembly assembly, string assetBundlePath, bool log = false) + { + try + { + if (assembly == null) + throw new($"AssetBundle {assetBundlePath} was null."); + + using var manifestResourceStream = + assembly.GetManifestResourceStream($"PvZ_Fusion_Translator.Resources.{assetBundlePath}"); + + if (manifestResourceStream == null) + throw new("Stream was null."); + + var array = new byte[manifestResourceStream.Length]; + _ = manifestResourceStream.Read(array, 0, array.Length); + var assetBundle = AssetBundle.LoadFromMemory(array); + ArgumentNullException.ThrowIfNull(assetBundle); + + if (log) + Log.LogDebug($"AssetBundle {assetBundlePath} has successfully been loaded."); + + return assetBundle; + } + catch (Exception value) + { + throw new ArgumentException($"Failed to load {assetBundlePath}. \n{value}"); + } + } + + public static AssetBundle GetAssetBundle(string path) + { + var assetBundle = AssetBundle.LoadFromFile(path); + return assetBundle; + } +#if false + public static readonly Dictionary> recipeLinks = new(); + + public static void RegisterRecipeLinks() + { + recipeLinks.Clear(); + + Il2CppSystem.Array mixData = MixData.data.Cast(); + var rows = mixData.GetLength(0); + var columns = mixData.GetLength(1); + + foreach (var seedType in from PlantType plantType in Enum.GetValues(typeof(PlantType)) select (int)plantType) + { + recipeLinks.Add(seedType, new()); + + if (seedType > 0) + foreach (var checks in Enum.GetValues(typeof(PlantType)) + .Cast() + .Where(checkType => checkType > 0) + .Select( + int[] (checkType) => + [ + mixData.GetValue(seedType, (int)checkType).Unbox(), + mixData.GetValue((int)checkType, seedType).Unbox(), + ] + )) + { + if (checks[0] != 0) + recipeLinks[seedType].Add(checks[0]); + + if (checks[1] != 0) + recipeLinks[seedType].Add(checks[1]); + } + + if (recipeLinks[seedType].Count > 0) + Log.LogDebug($"Found {recipeLinks[seedType].Count} fusions for {seedType}!"); + } + } +#endif + public static readonly Regex UntranslatedRegex = new("\\p{IsCJKUnifiedIdeographs}+"); + + public static bool CheckForUntranslatedText(string text) + { + try + { + var match = UntranslatedRegex.Match(text); + return match.Success; + } + catch (Exception e) + { + Log.LogError(e); + } + + return false; + } + + public static void WarnLocalData() + { + var newMenu = GameAPP.UIManager.Push(UIType.ConfirmMenu, GameAPP.canvasUp); + var confirmMenu = newMenu.gameObject.GetComponent(); + + var modeTo = Core.Instance.ConfigUseLocal.Value ? "online mode" : "local mode"; + + confirmMenu.SetTitle( + $"WARNING: This button is meant for translator testing and can overwrite/interfere with the translation files saved in your installation. Proceed with caution. You are switching to {modeTo}.\nOnline Mode: Default, strings will auto-sync with the latest version when opening the game\nLocal Mode: Strings are only loaded from your installaion and do not update (meant for translators)" + ); + + confirmMenu.transform.Find("window/text").GetComponent().text = RemoveColorTags( + confirmMenu.transform.Find("window/text").GetComponent().text + ); + + var confirmButton = confirmMenu.transform.Find("Image").GetComponent(); + _ = confirmMenu.transform.Find("Image2").GetComponent(); + + confirmButton.clickEvent = new(); + confirmButton.clickEvent.AddListener(new Action(SwapLocalData)); + confirmButton.clickEvent.AddListener(new Action(CursorChange.SetDefaultCursor)); + confirmButton.clickEvent.AddListener(new Action(() => GameAPP.UIManager.Pop())); + } + + public static void SwapLocalData() + { + Core.Instance.ConfigUseLocal.Value = !Core.Instance.ConfigUseLocal.Value; + ChangeLanguage(Language.ToString()); + var sourceMsg = $"Translation Source:\n{(Core.Instance.ConfigUseLocal.Value ? "Local" : "Online")}"; + OptLanguageBtn_Patch.FlashMessage(OptLanguageBtn_Patch.ToggleSlots[2], sourceMsg, 0.1f, false); + CursorChange.SetDefaultCursor(); + } + + public static async Task GetDataFromWeb(string url, bool isLog = true) + { + if (isLog) + Log.LogInfo($"Attempting to read {url}"); + + try + { + var dataRequest = await s_client.GetAsync(url); + + if (dataRequest.StatusCode == System.Net.HttpStatusCode.OK) + { + if (isLog) + Log.LogInfo($"Successfully loaded data from {url}!"); + + var content = await dataRequest.Content.ReadAsStringAsync(); + return content; + } + + if (isLog) + { + Log.LogError($"Failed to load data from {url}! Falling back..."); + Log.LogError($"Status code: {dataRequest.StatusCode}"); + } + + new CancellationTokenSource().Cancel(); + return null; + } + catch (Exception ex) + { + Log.LogError($"Failed to load data from {url}! Falling back..."); + Log.LogError(ex); + new CancellationTokenSource().Cancel(); + return null; + } + } + + public static async Task GetByteDataFromWeb(string url, bool isLog = true) + { + if (isLog) + Log.LogInfo($"Attempting to read {url}"); + + try + { + var dataRequest = await s_client.GetAsync(url); + + if (dataRequest.StatusCode == System.Net.HttpStatusCode.OK) + { + if (isLog) + Log.LogInfo($"Successfully loaded data from {url}!"); + + var content = await dataRequest.Content.ReadAsByteArrayAsync(); + return content; + } + + if (isLog) + { + Log.LogError($"Failed to load data from {url}! Falling back..."); + Log.LogError($"Status code: {dataRequest.StatusCode}"); + } + + new CancellationTokenSource().Cancel(); + return null; + } + catch (Exception ex) + { + Log.LogError($"Failed to load data from {url}! Falling back..."); + Log.LogError(ex); + new CancellationTokenSource().Cancel(); + return null; + } + } + + public static async Task GetDataFromWebWithInput(string url, bool isLog = true) + { + if (isLog) + Log.LogInfo($"Attempting to read {url}"); + + using var request = new HttpRequestMessage(); + request.Method = HttpMethod.Get; + request.RequestUri = new(url); + + request.Headers.Add("Accept", "*/*"); + request.Headers.Add("Accept-Encoding", "gzip, deflate, br"); + request.Headers.Add("User-Agent", "TranslatorMod"); + + var dataRequest = await s_client.SendAsync(request); + + if (dataRequest.StatusCode == System.Net.HttpStatusCode.OK) + { + if (isLog) + Log.LogInfo($"Successfully loaded data from {url}!"); + + var content = await dataRequest.Content.ReadAsStringAsync(); + return content; + } + + if (isLog) + { + Log.LogError($"Failed to load data from {url}! Falling back..."); + Log.LogError($"Status code: {dataRequest.StatusCode}"); + } + + new CancellationTokenSource().Cancel(); + return null; + } + + public static int CalculateGameVersion(string gameVersion) + { + var res = 0; + var gameVersionParts = gameVersion.Split('.'); + + var startingPower = Math.Max(gameVersionParts.Length, 3); + + for (var i = 0; i < startingPower; i++) + { + var factor = 0; + + if (i < gameVersionParts.Length) + factor = int.Parse(gameVersionParts[i]); + + var power = startingPower - i; + res += factor * (int)Math.Pow(10, power - 1); + } + + return res; + } + + internal static void ChangeLanguage(string language) + { + UnityEngine.Debug.Assert(ModFeatures.IsMultiLanguage, nameof(ModFeatures.IsMultiLanguage)); + OldLanguage = Language; + + if (Enum.TryParse(language, out LanguageEnum lang)) + Language = lang; + else + // Handle invalid language string + Log.LogError($"Invalid language string: {language}"); + + //WarningStore.isWarningMessageLoaded = false; + FontStore.Reload(); + StringStore.Reload(); + TextureStore.Reload(); + FileLoader.SaveLanguage(); + RegisterPlantIndices(); + Zombie_Patch.LoadHpStrings(); + } +#pragma warning disable CA2211 // ReSharper disable once NotAccessedField.Global + public static LanguageEnum OldLanguage; + public static LanguageEnum Language; + + public enum LanguageEnum + { + // first column + English, + ChineseCn, + French, + + //Italian, + German, + Spanish, + + // second column + //Portuguese, + //Javanese, + //Filipino, + Vietnamese, + Indonesian, + + //Russian, //NOTE: legacy language + Japanese, + + // third column + Korean, + Ukrainian, + + // Slovak, + //Polish, + //Turkish, + Arabic, + Romanian, + + LangEnd, + } + + public static Dictionary LanguageNames = new() + { + { LanguageEnum.English, "English" }, + { LanguageEnum.ChineseCn, "简体中文" }, + { LanguageEnum.French, "Français" }, + { LanguageEnum.German, "Deutsch" }, + { LanguageEnum.Spanish, "Español" }, + { LanguageEnum.Vietnamese, "Tiếng Việt" }, + { LanguageEnum.Indonesian, "Bahasa Indonesia" }, + { LanguageEnum.Japanese, "日本語" }, + { LanguageEnum.Korean, "한국어" }, + { LanguageEnum.Ukrainian, "українська" }, + { LanguageEnum.Arabic, "ﺔﻴﺑﺮﻌﻟا" }, + { LanguageEnum.Romanian, "Română" }, + }; + + public static Dictionary ToggleNames = new() + { + { ToggleEnum.Textures, "Change Texture\nSource" }, + { ToggleEnum.Audio, "Change Audio\nSource" }, + { ToggleEnum.SwapLocal, "Change Translation\nSource" }, + }; + + private static readonly HttpClient s_client = new(); +#pragma warning restore CA2211 + public enum ToggleEnum + { + Textures, + Audio, + SwapLocal, + ToggleEnd, + } +}