Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
<Compile Include="Main.cs" />
<Compile Include="UX\SinglePlayer.cs" />
<Compile Include="UX\SkipWarningScreen.cs" />
<Compile Include="UX\SkipToMusicSelection.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
7 changes: 4 additions & 3 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ public class Config
{
public UXConfig UX { get; set; }
public CheatConfig Cheat { get; set; }

public class CheatConfig
{
public bool TicketUnlock { get; set; }
}

public class UXConfig
{
public bool SkipWarningScreen { get; set; }
public bool SinglePlayer { get; set; }
public bool SkipToMusicSelection { get; set; }
}
}
}
}
25 changes: 15 additions & 10 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,46 @@ public static class BuildInfo
public class AquaMai : MelonMod
{
public static Config AppConfig { get; private set; }

private void Patch(Type type)
{
MelonLogger.Msg($"> Patching {type}");
HarmonyLib.Harmony.CreateAndPatchAll(type);
}
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<Config>(System.IO.File.ReadAllText("AquaMai.toml"));

if (AppConfig.UX.SkipWarningScreen)
Patch(typeof(SkipWarningScreen));

if (AppConfig.UX.SinglePlayer)
Patch(typeof(SinglePlayer));

if (AppConfig.Cheat.TicketUnlock)
Patch(typeof(TicketUnlock));


if (AppConfig.UX.SkipToMusicSelection)
{
Patch(typeof(SkipToMusicSelection));
}
Comment on lines +53 to +56
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我对没有curly brackets的if statement有点偏见 所以你改掉我不介意但是实在是不愿意自己写qaq

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

呜呜 没关系,之后想优化成反射,然后就不需要手动注册要 patch 哪些了(不过我还要学学 C# 反射怎么用xx


// Fixes that does not have side effects
// These don't need to be configurable
Patch(typeof(FixCharaCrash));

MelonLogger.Msg("Loaded!");
}
}
}
}
4 changes: 2 additions & 2 deletions AquaMai/UX/SinglePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ 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)
public static bool LateInitialize(MonoBehaviour gameMainObject, ref Transform left, ref Transform right)
{
left.transform.position = Vector3.zero;
right.localScale = Vector3.zero;
Expand Down
26 changes: 26 additions & 0 deletions AquaMai/UX/SkipToMusicSelection.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Loading