Merge branch 'cassidy'
This commit is contained in:
commit
ae707d7b06
4 changed files with 78 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
public static class TextureStore
|
public static class TextureStore
|
||||||
{
|
{
|
||||||
internal static Dictionary<string, string> textureDict = [];
|
internal static Dictionary<string, string> textureDict = [];
|
||||||
|
internal static Dictionary<string, string> spriteDict = [];
|
||||||
|
|
||||||
internal static void Init() => FileLoader.LoadTextures();
|
internal static void Init() => FileLoader.LoadTextures();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace PvZ_Fusion_Translator
|
||||||
Strings,
|
Strings,
|
||||||
Dumps,
|
Dumps,
|
||||||
Almanac,
|
Almanac,
|
||||||
|
Sprites
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null)
|
public static string GetAssetDir(AssetType assetType, Utils.LanguageEnum? language = null)
|
||||||
|
|
@ -115,9 +116,10 @@ namespace PvZ_Fusion_Translator
|
||||||
LoadLocalizedTextures(Utils.LanguageEnum.English);
|
LoadLocalizedTextures(Utils.LanguageEnum.English);
|
||||||
}
|
}
|
||||||
LoadLocalizedTextures(Utils.Language);
|
LoadLocalizedTextures(Utils.Language);
|
||||||
|
LoadLocalizedSprites(Utils.Language);
|
||||||
#else
|
#else
|
||||||
LoadLocalizedTextures();
|
LoadLocalizedTextures();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Log.LogInfo("Textures loaded successfully.");
|
Log.LogInfo("Textures loaded successfully.");
|
||||||
}
|
}
|
||||||
|
|
@ -163,6 +165,47 @@ namespace PvZ_Fusion_Translator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
internal static void LoadDefaultTextures()
|
||||||
{
|
{
|
||||||
if(Utils.customTextures == false)
|
if(Utils.customTextures == false)
|
||||||
|
|
|
||||||
28
MelonLoader/Patches/GameObjects/Board_Patch.cs
Normal file
28
MelonLoader/Patches/GameObjects/Board_Patch.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -400,6 +400,7 @@
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue