diff --git a/AquaMai/UX/LoadAssetsPng.cs b/AquaMai/UX/LoadAssetsPng.cs index 2c78e707..5a3f5a9d 100644 --- a/AquaMai/UX/LoadAssetsPng.cs +++ b/AquaMai/UX/LoadAssetsPng.cs @@ -17,14 +17,16 @@ namespace AquaMai.UX; public class LoadAssetsPng { private static string[] imageExts = [".jpg", ".png", ".jpeg"]; - private static Dictionary jacketPaths = new(); - private static Dictionary framePaths = new(); - private static Dictionary platePaths = new(); - private static Dictionary framemaskPaths = new(); - private static Dictionary framepatternPaths = new(); - private static Dictionary iconPaths = new(); - private static Dictionary charaPaths = new(); - private static Dictionary partnerPaths = new(); + private static Dictionary jacketPaths = new(); + private static Dictionary framePaths = new(); + private static Dictionary platePaths = new(); + private static Dictionary framemaskPaths = new(); + private static Dictionary framepatternPaths = new(); + private static Dictionary iconPaths = new(); + private static Dictionary charaPaths = new(); + + private static Dictionary partnerPaths = new(); + //private static Dictionary navicharaPaths = new(); private static Dictionary tabTitlePaths = new(); private static Dictionary localAssetsContents = new(); @@ -41,24 +43,24 @@ public static void LoadMusicPostfix(List ____targetDirs) if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; var idStr = Path.GetFileName(file).Substring("ui_jacket_".Length, 6); jacketPaths[idStr] = file; - } - + } + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\frame"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\frame"))) { if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; var idStr = Path.GetFileName(file).Substring("ui_frame_".Length, 6); framePaths[idStr] = file; - } - + } + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\nameplate"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\nameplate"))) { if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; var idStr = Path.GetFileName(file).Substring("ui_plate_".Length, 6); platePaths[idStr] = file; - } - + } + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framemask"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framemask"))) { @@ -66,7 +68,7 @@ public static void LoadMusicPostfix(List ____targetDirs) var idStr = Path.GetFileName(file).Substring("ui_framemask_".Length, 6); framemaskPaths[idStr] = file; } - + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\framepattern"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\framepattern"))) { @@ -74,7 +76,7 @@ public static void LoadMusicPostfix(List ____targetDirs) var idStr = Path.GetFileName(file).Substring("ui_framepattern_".Length, 6); framepatternPaths[idStr] = file; } - + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\icon"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\icon"))) { @@ -82,30 +84,30 @@ public static void LoadMusicPostfix(List ____targetDirs) var idStr = Path.GetFileName(file).Substring("ui_icon_".Length, 6); iconPaths[idStr] = file; } - + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\chara"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\chara"))) { if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; var idStr = Path.GetFileName(file).Substring("ui_chara_".Length, 6); charaPaths[idStr] = file; - } - + } + if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\partner"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\partner"))) { if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; var idStr = Path.GetFileName(file).Substring("ui_Partner_".Length, 6); partnerPaths[idStr] = file; - } - //if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_21"))) - // foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_", charaid))) - //{ - // if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; - //var idStr = Path.GetFileName(file).Substring("ui_navichara_".Length, 6); - // navicharaPaths[idStr] = file; - // } - + } + //if (Directory.Exists(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_21"))) + // foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"AssetBundleImages\navichara\sprite\parts\ui_navichara_", charaid))) + //{ + // if (!imageExts.Contains(Path.GetExtension(file).ToLowerInvariant())) continue; + //var idStr = Path.GetFileName(file).Substring("ui_navichara_".Length, 6); + // navicharaPaths[idStr] = file; + // } + if (Directory.Exists(Path.Combine(aDir, @"Common\Sprites\Tab\Title"))) foreach (var file in Directory.GetFiles(Path.Combine(aDir, @"Common\Sprites\Tab\Title"))) { @@ -147,8 +149,8 @@ public static Texture2D GetJacketTexture2D(string id) public static Texture2D GetJacketTexture2D(int id) { return GetJacketTexture2D($"{id:000000}"); - } - + } + private static string GetFramePath(string id) { return framePaths.GetValueOrDefault(id); @@ -165,7 +167,8 @@ public static Texture2D GetFrameTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } + } + private static string GetPlatePath(string id) { return platePaths.GetValueOrDefault(id); @@ -182,8 +185,8 @@ public static Texture2D GetPlateTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } - + } + private static string GetFrameMaskPath(string id) { return framemaskPaths.GetValueOrDefault(id); @@ -200,8 +203,8 @@ public static Texture2D GetFrameMaskTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } - + } + private static string GetFramePatternPath(string id) { return framepatternPaths.GetValueOrDefault(id); @@ -218,7 +221,8 @@ public static Texture2D GetFramePatternTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } + } + private static string GetIconPath(string id) { return iconPaths.GetValueOrDefault(id); @@ -235,7 +239,8 @@ public static Texture2D GetIconTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } + } + private static string GetCharaPath(string id) { return charaPaths.GetValueOrDefault(id); @@ -252,12 +257,13 @@ public static Texture2D GetCharaTexture2D(string id) var texture = new Texture2D(1, 1, TextureFormat.RGBA32, false); texture.LoadImage(File.ReadAllBytes(path)); return texture; - } + } + private static string GetPartnerPath(string id) { return partnerPaths.GetValueOrDefault(id); } - + public static Texture2D GetPartnerTexture2D(string id) { var path = GetPartnerPath(id); @@ -360,8 +366,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - + } + [HarmonyPatch] public static class FrameLoader { @@ -386,8 +392,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - + } + [HarmonyPatch] public static class PlateLoader { @@ -412,8 +418,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - + } + [HarmonyPatch] public static class FrameMaskLoader { @@ -438,8 +444,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - + } + [HarmonyPatch] public static class FramePatternLoader { @@ -464,38 +470,28 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - - [HarmonyPatch] - public static class IconLoader + } + + // Private | Instance + [HarmonyPrefix] + [HarmonyPatch(typeof(AssetManager), "GetIconTexture2D", typeof(string))] + public static bool IconLoader(string filename, ref Texture2D __result, AssetManager __instance) { - public static IEnumerable TargetMethods() + var matches = Regex.Matches(filename, @"UI_Icon_(\d+)\.png"); + if (matches.Count < 1) { - var AM = typeof(AssetManager); - var method = AM.GetMethod("GetIconTexture2D", new[] { typeof(string) }); - if (method != null) - { - yield return method; - } + return true; } - public static bool Prefix(string filename, ref Texture2D __result, AssetManager __instance) - { - var matches = Regex.Matches(filename, @"UI_Icon_(\d+)\.png"); - if (matches.Count < 1) - { - return true; - } - MelonLogger.Msg(filename); - var id = matches[0].Groups[1].Value; + MelonLogger.Msg(filename); + var id = matches[0].Groups[1].Value; - var texture = GetIconTexture2D(id); - __result = texture ?? __instance.LoadAsset($"Icon/UI_Icon_{id}.png"); + var texture = GetIconTexture2D(id); + __result = texture ?? __instance.LoadAsset($"Icon/UI_Icon_{id}.png"); + + return false; + } - return false; - } - } - [HarmonyPatch] public static class CharaLoader { @@ -520,8 +516,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - + } + [HarmonyPatch] public static class PartnerLoader { @@ -546,8 +542,8 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager return false; } - } - /* + } + /* [HarmonyPatch] public static class FrameLoader { @@ -574,4 +570,4 @@ public static bool Prefix(string filename, ref Texture2D __result, AssetManager } } */ -} +} \ No newline at end of file