From 279fe5dcb8a67d3d43319a4cd1782039bbccf2cc Mon Sep 17 00:00:00 2001 From: Tianyi Cao Date: Wed, 7 Feb 2024 02:16:24 -0800 Subject: [PATCH] Add ability to skip a bunch of stuff directly to music selection --- AquaMai/AquaMai.csproj | 3 ++- AquaMai/Config.cs | 1 + AquaMai/Main.cs | 22 ++++++++++++++-------- AquaMai/UX/SinglePlayer.cs | 6 ++++-- AquaMai/UX/SkipToMusicSelection.cs | 26 ++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 AquaMai/UX/SkipToMusicSelection.cs diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 70752762..2314b799 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -268,6 +268,7 @@ + @@ -276,4 +277,4 @@ - + \ No newline at end of file diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 8f20891e..88dd5702 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -11,6 +11,7 @@ namespace AquaMai { public bool SkipWarningScreen { get; set; } public bool SinglePlayer { get; set; } + public bool SkipToMusicSelection { get; set; } } } } \ No newline at end of file diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index e7e62e9a..ebf5c336 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -17,34 +17,40 @@ namespace AquaMai public class AquaMai : MelonMod { public static Config AppConfig { get; private set; } - - public override void OnInitializeMelon() + + public override void OnInitializeMelon() { MelonLogger.Msg("Loading mod settings..."); - + // Check if AquaMai.toml exists if (!System.IO.File.Exists("AquaMai.toml")) { MelonLogger.Error("AquaMai.toml not found! Please create it."); return; } - + // Read AquaMai.toml to load settings AppConfig = TomletMain.To(System.IO.File.ReadAllText("AquaMai.toml")); - + if (AppConfig.UX.SkipWarningScreen) { MelonLogger.Msg("> Patching SkipWarningScreen"); HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipWarningScreen)); } - + if (AppConfig.UX.SinglePlayer) { MelonLogger.Msg("> Patching SinglePlayer"); HarmonyLib.Harmony.CreateAndPatchAll(typeof(SinglePlayer)); } - + + if (AppConfig.UX.SkipToMusicSelection) + { + MelonLogger.Msg($"> Patching {nameof(SkipToMusicSelection)}"); + HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipToMusicSelection)); + } + MelonLogger.Msg("Loaded!"); } } -} \ No newline at end of file +} diff --git a/AquaMai/UX/SinglePlayer.cs b/AquaMai/UX/SinglePlayer.cs index e62018cc..17e222a8 100644 --- a/AquaMai/UX/SinglePlayer.cs +++ b/AquaMai/UX/SinglePlayer.cs @@ -2,10 +2,12 @@ using System; using HarmonyLib; using UnityEngine; -namespace AquaMai { +namespace AquaMai.UX +{ // Hides the 2p (right hand side) UI. // Note: this is not my original work. I simply interpreted the code and rewrote it as a mod. - public class SinglePlayer { + public class SinglePlayer + { [HarmonyPrefix] [HarmonyPatch(typeof(Main.GameMain), "LateInitialize", new Type[] { typeof(MonoBehaviour), typeof(Transform), typeof(Transform) })] public static bool LateInitialize(MonoBehaviour gameMainObject, ref Transform left, ref Transform right) diff --git a/AquaMai/UX/SkipToMusicSelection.cs b/AquaMai/UX/SkipToMusicSelection.cs new file mode 100644 index 00000000..0b63f268 --- /dev/null +++ b/AquaMai/UX/SkipToMusicSelection.cs @@ -0,0 +1,26 @@ +using HarmonyLib; +using Manager; +using Process; +using Process.Information; + +namespace AquaMai.UX +{ + public class SkipToMusicSelection + { + /* + * Highly experimental, may well break some stuff + * Works by overriding the info screen (where it shows new events and stuff) + * to directly exit to the music selection screen, skipping character and + * event selection, among others + */ + [HarmonyPrefix] + [HarmonyPatch(typeof(InformationProcess), "OnUpdate")] + public static bool OnUpdate(InformationProcess __instance, ProcessDataContainer ___container) + { + GameManager.SetMaxTrack(); + ___container.processManager.AddProcess(new MusicSelectProcess(___container), 50); + ___container.processManager.ReleaseProcess(__instance); + return false; + } + } +}