From d8fc14e71bcccca7087099d65e24f30bea878f91 Mon Sep 17 00:00:00 2001 From: Clansty Date: Mon, 8 Apr 2024 14:59:54 +0800 Subject: [PATCH 1/4] [+] Custom version string feature --- AquaMai/AquaMai.csproj | 1 + AquaMai/AquaMai.toml | 4 +++- AquaMai/Config.cs | 1 + AquaMai/Main.cs | 2 ++ AquaMai/UX/CustomVersionString.cs | 24 ++++++++++++++++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 AquaMai/UX/CustomVersionString.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 815e02d6..5dc03c43 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -268,6 +268,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index bdbe445e..331473a6 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -13,4 +13,6 @@ SkipWarningScreen=true # Single player: Show 1P only, at the center of the screen SinglePlayer=true # !!EXPERIMENTAL!! Skip from the card-scanning screen directly to music selection screen -SkipToMusicSelection=false \ No newline at end of file +SkipToMusicSelection=false +# Set the version string displayed at the top-right corner of the screen +CustomVersionString="" \ No newline at end of file diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index a9b8fb56..f1a97d58 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -18,6 +18,7 @@ namespace AquaMai public bool SkipWarningScreen { get; set; } public bool SinglePlayer { get; set; } public bool SkipToMusicSelection { get; set; } + public string CustomVersionString { get; set; } } } } diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index a69e69aa..6a35b971 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -1,5 +1,6 @@ using System; using AquaMai.Fix; +using AquaMai.UX; using MelonLoader; using Tomlet; @@ -77,6 +78,7 @@ namespace AquaMai // Fixes that does not have side effects // These don't need to be configurable Patch(typeof(FixCharaCrash)); + Patch(typeof(CustomVersionString)); MelonLogger.Msg("Loaded!"); } diff --git a/AquaMai/UX/CustomVersionString.cs b/AquaMai/UX/CustomVersionString.cs new file mode 100644 index 00000000..78282ea9 --- /dev/null +++ b/AquaMai/UX/CustomVersionString.cs @@ -0,0 +1,24 @@ +using HarmonyLib; + +namespace AquaMai.UX +{ + public class CustomVersionString + { + /* + * Patch displayVersionString Property Getter + */ + [HarmonyPrefix] + [HarmonyPatch(typeof(MAI2System.Config), "displayVersionString", MethodType.Getter)] + public static bool GetDisplayVersionString(ref string __result) + { + if (string.IsNullOrEmpty(AquaMai.AppConfig.UX.CustomVersionString)) + { + return true; + } + + __result = AquaMai.AppConfig.UX.CustomVersionString; + // Return false to block the original method + return false; + } + } +} \ No newline at end of file From 442ec7682892a84d72a78fd8b999d7a4976841ed Mon Sep 17 00:00:00 2001 From: Clansty Date: Mon, 8 Apr 2024 17:02:14 +0800 Subject: [PATCH 2/4] [+] Option to disable some useless checks and delays to speedup the game boot process --- AquaMai/AquaMai.csproj | 1 + AquaMai/AquaMai.toml | 6 ++- AquaMai/Config.cs | 6 +++ AquaMai/Performance/ImproveLoadSpeed.cs | 57 +++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 AquaMai/Performance/ImproveLoadSpeed.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 815e02d6..b7f6d42b 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -266,6 +266,7 @@ + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index bdbe445e..47e7c6ef 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -13,4 +13,8 @@ SkipWarningScreen=true # Single player: Show 1P only, at the center of the screen SinglePlayer=true # !!EXPERIMENTAL!! Skip from the card-scanning screen directly to music selection screen -SkipToMusicSelection=false \ No newline at end of file +SkipToMusicSelection=false + +[Performance] +# Disable some useless checks and delays to speedup the game boot process +ImproveLoadSpeed=false \ No newline at end of file diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index a9b8fb56..07c1b14b 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -7,6 +7,7 @@ namespace AquaMai { public UXConfig UX { get; set; } public CheatConfig Cheat { get; set; } + public PerformanceConfig Performance { get; set; } public class CheatConfig { @@ -19,5 +20,10 @@ namespace AquaMai public bool SinglePlayer { get; set; } public bool SkipToMusicSelection { get; set; } } + + public class PerformanceConfig + { + public bool ImproveLoadSpeed { get; set; } + } } } diff --git a/AquaMai/Performance/ImproveLoadSpeed.cs b/AquaMai/Performance/ImproveLoadSpeed.cs new file mode 100644 index 00000000..1e659adc --- /dev/null +++ b/AquaMai/Performance/ImproveLoadSpeed.cs @@ -0,0 +1,57 @@ +using System.Diagnostics; +using HarmonyLib; +using MelonLoader; +using Process; + +namespace AquaMai.Performance +{ + public class ImproveLoadSpeed + { + [HarmonyPrefix] + [HarmonyPatch(typeof(PowerOnProcess), "OnUpdate")] + public static bool PrePowerOnUpdate(PowerOnProcess __instance) + { + var traverse = Traverse.Create(__instance); + var state = traverse.Field("_state").GetValue(); + switch (state) + { + case 3: + traverse.Field("_state").SetValue((byte)4); + break; + case 5: + traverse.Field("_state").SetValue((byte)8); + break; + case 9: + traverse.Field("_state").SetValue((byte)10); + break; + } + + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(StartupProcess), "OnUpdate")] + public static bool PreStartupUpdate(StartupProcess __instance) + { + var traverse = Traverse.Create(__instance); + var state = traverse.Field("_state").GetValue(); + switch (state) + { + case 0: + case 1: + case 2: + traverse.Field("_state").SetValue((byte)3); + break; + case 4: + traverse.Field("_state").SetValue((byte)5); + break; + case 8: + var timer = traverse.Field("timer").GetValue(); + Traverse.Create(timer).Field("elapsed").SetValue(2 * 10000000L); + break; + } + + return true; + } + } +} \ No newline at end of file From 0aff0330e7b24f7377795707b0bc6c1de4269b39 Mon Sep 17 00:00:00 2001 From: Azalea Date: Wed, 10 Apr 2024 07:13:54 -0700 Subject: [PATCH 3/4] [U] Update config description --- AquaMai/AquaMai.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 47e7c6ef..c82559c4 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -12,9 +12,10 @@ TicketUnlock=true SkipWarningScreen=true # Single player: Show 1P only, at the center of the screen SinglePlayer=true -# !!EXPERIMENTAL!! Skip from the card-scanning screen directly to music selection screen +# !!EXPERIMENTAL!! Skip from the card-scanning screen directly to the music selection screen SkipToMusicSelection=false [Performance] -# Disable some useless checks and delays to speedup the game boot process -ImproveLoadSpeed=false \ No newline at end of file +# Disable some useless checks and delays to speed up the game boot process +# !! Known issue: The game may crash if DX Pass scanning is enabled +ImproveLoadSpeed=false From c83e0f8cff64ed7bfb8f8ca90fab1a110878d9b9 Mon Sep 17 00:00:00 2001 From: Clansty Date: Fri, 12 Apr 2024 00:40:29 +0800 Subject: [PATCH 4/4] [F] Fix Chime scanning and (maybe) DX Pass crash --- AquaMai/Performance/ImproveLoadSpeed.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/AquaMai/Performance/ImproveLoadSpeed.cs b/AquaMai/Performance/ImproveLoadSpeed.cs index 1e659adc..006ac44a 100644 --- a/AquaMai/Performance/ImproveLoadSpeed.cs +++ b/AquaMai/Performance/ImproveLoadSpeed.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using HarmonyLib; -using MelonLoader; +using MAI2.Util; +using Manager; using Process; namespace AquaMai.Performance @@ -19,6 +20,8 @@ namespace AquaMai.Performance traverse.Field("_state").SetValue((byte)4); break; case 5: + case 6: + case 7: traverse.Field("_state").SetValue((byte)8); break; case 9: @@ -38,9 +41,12 @@ namespace AquaMai.Performance switch (state) { case 0: - case 1: + traverse.Field("_state").SetValue((byte)1); + break; case 2: - traverse.Field("_state").SetValue((byte)3); + // AimeReader maybe typeof AimeReaderManager or ChimeReaderManager, must build with correct Assembly-CSharp.dll in Libs folder + if(SingletonStateMachine.Instance.AimeReader.GetType().FullName == "Manager.AimeReaderManager") + traverse.Field("_state").SetValue((byte)3); break; case 4: traverse.Field("_state").SetValue((byte)5);