Skip to content

Commit

Permalink
[+] Add cheat config
Browse files Browse the repository at this point in the history
  • Loading branch information
hykilpikonna committed Feb 7, 2024
1 parent de12ec6 commit ccb3f7e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Cheat\TicketUnlock.cs" />
<Compile Include="Config.cs" />
<Compile Include="Fix\FixCharaCrash.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Main.cs" />
<Compile Include="UX\SinglePlayer.cs" />
Expand Down
6 changes: 6 additions & 0 deletions AquaMai/AquaMai.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

# ===================================
# Cheat: You control the buttons you press
[Cheat]
# Unlock normally event-only tickets
TicketUnlock=true

# ===================================
# UX: User Experience Improvements
[UX]
Expand Down
6 changes: 6 additions & 0 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ namespace AquaMai
public class Config
{
public UXConfig UX { get; set; }
public CheatConfig Cheat { get; set; }

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

public class UXConfig
{
Expand Down
28 changes: 19 additions & 9 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using AquaMai.UX;
using System;
using AquaMai.Cheat;
using AquaMai.Fix;
using AquaMai.UX;
using MelonLoader;
using Tomlet;

Expand All @@ -18,6 +21,12 @@ 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()
{
MelonLogger.Msg("Loading mod settings...");
Expand All @@ -33,16 +42,17 @@ public override void OnInitializeMelon()
AppConfig = TomletMain.To<Config>(System.IO.File.ReadAllText("AquaMai.toml"));

if (AppConfig.UX.SkipWarningScreen)
{
MelonLogger.Msg("> Patching SkipWarningScreen");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipWarningScreen));
}
Patch(typeof(SkipWarningScreen));

if (AppConfig.UX.SinglePlayer)
{
MelonLogger.Msg("> Patching SinglePlayer");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SinglePlayer));
}
Patch(typeof(SinglePlayer));

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

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

MelonLogger.Msg("Loaded!");
}
Expand Down
6 changes: 4 additions & 2 deletions AquaMai/UX/SinglePlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
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)
Expand Down

0 comments on commit ccb3f7e

Please sign in to comment.