Add ability to skip a bunch of stuff directly to music selection

pull/7/head
Tianyi Cao 2024-02-07 02:16:24 -08:00
parent 8152b9ab0d
commit 279fe5dcb8
5 changed files with 47 additions and 11 deletions

View File

@ -268,6 +268,7 @@
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="UX\SinglePlayer.cs" /> <Compile Include="UX\SinglePlayer.cs" />
<Compile Include="UX\SkipWarningScreen.cs" /> <Compile Include="UX\SkipWarningScreen.cs" />
<Compile Include="UX\SkipToMusicSelection.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
@ -276,4 +277,4 @@
<Content Include="AquaMai.toml" /> <Content Include="AquaMai.toml" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@ -11,6 +11,7 @@ namespace AquaMai
{ {
public bool SkipWarningScreen { get; set; } public bool SkipWarningScreen { get; set; }
public bool SinglePlayer { get; set; } public bool SinglePlayer { get; set; }
public bool SkipToMusicSelection { get; set; }
} }
} }
} }

View File

@ -17,34 +17,40 @@ namespace AquaMai
public class AquaMai : MelonMod public class AquaMai : MelonMod
{ {
public static Config AppConfig { get; private set; } public static Config AppConfig { get; private set; }
public override void OnInitializeMelon() public override void OnInitializeMelon()
{ {
MelonLogger.Msg("Loading mod settings..."); MelonLogger.Msg("Loading mod settings...");
// Check if AquaMai.toml exists // Check if AquaMai.toml exists
if (!System.IO.File.Exists("AquaMai.toml")) if (!System.IO.File.Exists("AquaMai.toml"))
{ {
MelonLogger.Error("AquaMai.toml not found! Please create it."); MelonLogger.Error("AquaMai.toml not found! Please create it.");
return; return;
} }
// Read AquaMai.toml to load settings // Read AquaMai.toml to load settings
AppConfig = TomletMain.To<Config>(System.IO.File.ReadAllText("AquaMai.toml")); AppConfig = TomletMain.To<Config>(System.IO.File.ReadAllText("AquaMai.toml"));
if (AppConfig.UX.SkipWarningScreen) if (AppConfig.UX.SkipWarningScreen)
{ {
MelonLogger.Msg("> Patching SkipWarningScreen"); MelonLogger.Msg("> Patching SkipWarningScreen");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipWarningScreen)); HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipWarningScreen));
} }
if (AppConfig.UX.SinglePlayer) if (AppConfig.UX.SinglePlayer)
{ {
MelonLogger.Msg("> Patching SinglePlayer"); MelonLogger.Msg("> Patching SinglePlayer");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SinglePlayer)); HarmonyLib.Harmony.CreateAndPatchAll(typeof(SinglePlayer));
} }
if (AppConfig.UX.SkipToMusicSelection)
{
MelonLogger.Msg($"> Patching {nameof(SkipToMusicSelection)}");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipToMusicSelection));
}
MelonLogger.Msg("Loaded!"); MelonLogger.Msg("Loaded!");
} }
} }
} }

View File

@ -2,10 +2,12 @@ using System;
using HarmonyLib; using HarmonyLib;
using UnityEngine; using UnityEngine;
namespace AquaMai { namespace AquaMai.UX
{
// Hides the 2p (right hand side) UI. // 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. // 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] [HarmonyPrefix]
[HarmonyPatch(typeof(Main.GameMain), "LateInitialize", new Type[] { typeof(MonoBehaviour), typeof(Transform), typeof(Transform) })] [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) public static bool LateInitialize(MonoBehaviour gameMainObject, ref Transform left, ref Transform right)

View File

@ -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;
}
}
}