[PR] #7 from tc21: skip-to-music

Add ability to skip a bunch of stuff directly to music selection
This commit is contained in:
Azalea 2024-02-07 05:26:17 -05:00 committed by GitHub
commit fb58f08e44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 48 additions and 15 deletions

View File

@ -270,6 +270,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" />

View File

@ -7,16 +7,17 @@ namespace AquaMai
{ {
public UXConfig UX { get; set; } public UXConfig UX { get; set; }
public CheatConfig Cheat { get; set; } public CheatConfig Cheat { get; set; }
public class CheatConfig public class CheatConfig
{ {
public bool TicketUnlock { get; set; } public bool TicketUnlock { get; set; }
} }
public class UXConfig public class UXConfig
{ {
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

@ -20,41 +20,46 @@ namespace AquaMai
public class AquaMai : MelonMod public class AquaMai : MelonMod
{ {
public static Config AppConfig { get; private set; } public static Config AppConfig { get; private set; }
private void Patch(Type type) private void Patch(Type type)
{ {
MelonLogger.Msg($"> Patching {type}"); MelonLogger.Msg($"> Patching {type}");
HarmonyLib.Harmony.CreateAndPatchAll(type); HarmonyLib.Harmony.CreateAndPatchAll(type);
} }
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)
Patch(typeof(SkipWarningScreen)); Patch(typeof(SkipWarningScreen));
if (AppConfig.UX.SinglePlayer) if (AppConfig.UX.SinglePlayer)
Patch(typeof(SinglePlayer)); Patch(typeof(SinglePlayer));
if (AppConfig.Cheat.TicketUnlock) if (AppConfig.Cheat.TicketUnlock)
Patch(typeof(TicketUnlock)); Patch(typeof(TicketUnlock));
if (AppConfig.UX.SkipToMusicSelection)
{
Patch(typeof(SkipToMusicSelection));
}
// Fixes that does not have side effects // Fixes that does not have side effects
// These don't need to be configurable // These don't need to be configurable
Patch(typeof(FixCharaCrash)); Patch(typeof(FixCharaCrash));
MelonLogger.Msg("Loaded!"); MelonLogger.Msg("Loaded!");
} }
} }
} }

View File

@ -6,11 +6,11 @@ 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)
{ {
left.transform.position = Vector3.zero; left.transform.position = Vector3.zero;
right.localScale = Vector3.zero; right.localScale = Vector3.zero;

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