texture particle fix
This commit is contained in:
parent
1f6ef36728
commit
524d8994e3
3 changed files with 51 additions and 6 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)
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
if (spriteRenderer.sprite != null)
|
if (spriteRenderer.sprite != null)
|
||||||
{
|
{
|
||||||
if (TextureStore.spriteDict.ContainsKey(spriteRenderer.sprite.name) && spriteRenderer.drawMode != SpriteDrawMode.Sliced)
|
if (TextureStore.spriteDict.ContainsKey(spriteRenderer.sprite.name))
|
||||||
{
|
{
|
||||||
spriteRenderer.drawMode = SpriteDrawMode.Sliced;
|
spriteRenderer.drawMode = SpriteDrawMode.Sliced;
|
||||||
|
spriteRenderer.sprite.name = "replaced_" + spriteRenderer.sprite.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue