Merge branch 'cassidy'

This commit is contained in:
SillyStar-Github 2025-07-28 01:30:00 -04:00
commit ae707d7b06
4 changed files with 78 additions and 5 deletions

View file

@ -7,8 +7,9 @@ namespace PvZ_Fusion_Translator.AssetStore
public static class TextureStore
{
internal static Dictionary<string, string> textureDict = [];
internal static Dictionary<string, string> spriteDict = [];
internal static void Init() => FileLoader.LoadTextures();
internal static void Init() => FileLoader.LoadTextures();
internal static void Reload()
{

View file

@ -17,6 +17,7 @@ namespace PvZ_Fusion_Translator
Strings,
Dumps,
Almanac,
Sprites
}
public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null)
@ -115,11 +116,12 @@ namespace PvZ_Fusion_Translator
LoadLocalizedTextures(Utils.LanguageEnum.English);
}
LoadLocalizedTextures(Utils.Language);
#else
LoadLocalizedSprites(Utils.Language);
#else
LoadLocalizedTextures();
#endif
#endif
Log.LogInfo("Textures loaded successfully.");
Log.LogInfo("Textures loaded successfully.");
}
internal static void LoadLocalizedTextures(Utils.LanguageEnum? language = null)
@ -163,7 +165,48 @@ namespace PvZ_Fusion_Translator
}
}
internal static void LoadDefaultTextures()
internal static void LoadLocalizedSprites(Utils.LanguageEnum? language = null)
{
string textureDir = GetAssetDir(AssetType.Sprites, 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) && loadDefaultTextures)
{
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
Texture2D texture2D = Utils.LoadImage(filepath);
TextureStore.spriteDict[Path.GetFileNameWithoutExtension(filepath)] = filepath;
}
}
catch (Exception e)
{
Log.LogError("Error loading Texture.");
Log.LogError(e.GetType() + " " + e.Message);
}
}
internal static void LoadDefaultTextures()
{
if(Utils.customTextures == false)
{

View file

@ -0,0 +1,28 @@
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<SpriteRenderer>())
{
if (spriteRenderer.sprite != null)
{
if (TextureStore.spriteDict.ContainsKey(spriteRenderer.sprite.name) && spriteRenderer.drawMode != SpriteDrawMode.Sliced)
{
spriteRenderer.drawMode = SpriteDrawMode.Sliced;
}
}
}
}
}
}

View file

@ -400,6 +400,7 @@
<Compile Include="Log.cs" />
<Compile Include="ModFeatures.cs" />
<Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />