From 8b722147800a9998a34edd2f5c86fb6f86fa3cc2 Mon Sep 17 00:00:00 2001 From: Clansty Date: Wed, 19 Jun 2024 21:12:29 +0800 Subject: [PATCH] [+] Load jacket with higher resolution --- AquaMai/UX/LoadJacketPng.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/AquaMai/UX/LoadJacketPng.cs b/AquaMai/UX/LoadJacketPng.cs index cc9603d4..4f728380 100644 --- a/AquaMai/UX/LoadJacketPng.cs +++ b/AquaMai/UX/LoadJacketPng.cs @@ -15,10 +15,10 @@ namespace AquaMai.UX public static IEnumerable TargetMethods() { var AM = typeof(AssetManager); - return new[] { AM.GetMethod("GetJacketThumbTexture2D", new []{typeof(string)}), AM.GetMethod("GetJacketTexture2D", new []{typeof(string)}) }; + return new[] { AM.GetMethod("GetJacketThumbTexture2D", new[] { typeof(string) }), AM.GetMethod("GetJacketTexture2D", new[] { typeof(string) }) }; } - - public static bool Prefix(string filename, ref Texture2D __result) + + public static bool Prefix(string filename, ref Texture2D __result, AssetManager __instance) { var matches = Regex.Matches(filename, @"UI_Jacket_(\d+)(_s)?\.png"); if (matches.Count < 1) @@ -27,21 +27,26 @@ namespace AquaMai.UX } var id = matches[0].Groups[1].Value; - foreach (var ext in new []{".jpg",".png",".webp",".bmp",".gif"}) + foreach (var ext in new[] { ".jpg", ".png", ".webp", ".bmp", ".gif" }) { if (File.Exists(Path.Combine(Environment.CurrentDirectory, "LocalAssets", id + ext))) { filename = id + ext; } } - + var localPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", filename); - if (!File.Exists(localPath)) return true; - - __result = new Texture2D(1, 1); - ImageConversion.LoadImage(__result, File.ReadAllBytes(localPath)); + if (File.Exists(localPath)) + { + __result = new Texture2D(1, 1); + ImageConversion.LoadImage(__result, File.ReadAllBytes(localPath)); + } + else + { + __result = __instance.LoadAsset($"Jacket/UI_Jacket_{id}.png"); + } + return false; } - } } \ No newline at end of file