From b4cbb1fd141fa51db7ad64905142225b9834c3d1 Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 23 Apr 2024 18:51:49 +0800 Subject: [PATCH] [+] Load AssetBundle without manifest --- AquaMai/AquaMai.csproj | 1 + AquaMai/AquaMai.toml | 2 ++ AquaMai/Config.cs | 1 + AquaMai/UX/LoadAssetBundleWithoutManifest.cs | 32 ++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 AquaMai/UX/LoadAssetBundleWithoutManifest.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 428fd711..800ac623 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -271,6 +271,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 6df4b43f..34e73eb7 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -20,6 +20,8 @@ CustomVersionString="" LoadJacketPng=true # Press key "7" for 1 second to skip to next step or restart current song QuickSkip=true +# Add ".ab" image resources without the need of rebuilding a manifest +LoadAssetBundleWithoutManifest=true [Performance] # Disable some useless checks and delays to speed up the game boot process diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 203b92eb..876366b9 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -20,6 +20,7 @@ namespace AquaMai public bool SinglePlayer { get; set; } public bool SkipToMusicSelection { get; set; } public bool LoadJacketPng { get; set; } + public bool LoadAssetBundleWithoutManifest { get; set; } public bool QuickSkip { get; set; } public string CustomVersionString { get; set; } } diff --git a/AquaMai/UX/LoadAssetBundleWithoutManifest.cs b/AquaMai/UX/LoadAssetBundleWithoutManifest.cs new file mode 100644 index 00000000..90dcb2b4 --- /dev/null +++ b/AquaMai/UX/LoadAssetBundleWithoutManifest.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; +using System.Linq; +using HarmonyLib; +using UnityEngine; +using Manager; +using Util; + +namespace AquaMai.UX +{ + public class LoadAssetBundleWithoutManifest + { + private static HashSet abFiles = new HashSet(); + + [HarmonyPostfix] + [HarmonyPatch(typeof(OptionDataManager), "CheckAssetBundle")] + public static void PostCheckAssetBundle(ref Safe.ReadonlySortedDictionary abs) + { + foreach (var ab in abs) + { + abFiles.Add(ab.Key); + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(AssetBundleManifest), "GetAllAssetBundles")] + public static bool PreGetAllAssetBundles(AssetBundleManifest __instance, ref string[] __result) + { + __result = abFiles.ToArray(); + return false; + } + } +} \ No newline at end of file