Merge branch 'master' into tc21/skip-to-music

pull/7/head
Tianyi Cao 2024-02-07 02:20:39 -08:00
commit abe1d3ad29
7 changed files with 106 additions and 14 deletions

View File

@ -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" />

View File

@ -1,4 +1,10 @@
# ===================================
# Cheat: You control the buttons you press
[Cheat]
# Unlock normally event-only tickets
TicketUnlock=true
# ===================================
# UX: User Experience Improvements
[UX]

View File

@ -0,0 +1,40 @@
using Manager.MaiStudio;
using HarmonyLib;
namespace AquaMai.Cheat
{
/**
* Unlock tickets that are typically locked unless a specific event is open.
*/
public class TicketUnlock
{
// For any ticket, return the event ID 1 to unlock it
[HarmonyPrefix]
[HarmonyPatch(typeof(TicketData), "get_ticketEvent")]
public static bool get_ticketEvent(ref StringID __result)
{
var id = new Manager.MaiStudio.Serialize.StringID
{
id = 1,
str = "無期限常時解放"
};
var sid = new StringID();
sid.Init(id);
__result = sid;
return false;
}
// Modify the maxTicketNum to 0
// this is because TicketManager.GetTicketData adds the ticket to the list if either
// the player owns at least one ticket or the maxTicketNum = 0
[HarmonyPrefix]
[HarmonyPatch(typeof(TicketData), "get_maxCount")]
public static bool get_maxCount(ref int __result)
{
__result = 0;
return false;
}
}
}

View File

@ -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
{

View File

@ -0,0 +1,28 @@
using HarmonyLib;
using Process;
using Util;
namespace AquaMai.Fix
{
/**
* Fix character selection crashing because get map color returns null
*/
public class FixCharaCrash
{
// Check if the return is null. If it is, make up a color
[HarmonyPostfix]
[HarmonyPatch(typeof(CharacterSelectProces), "GetMapColorData")]
public static void GetMapColorData(ref CharacterSelectProces __instance, ref CharacterMapColorData __result)
{
if (__result != null) return;
// 1 is a color that definitely exists
if (MapMaster.GetSlotData(1) == null)
{
MapMaster.GetSlotData(1).Load();
}
__result = MapMaster.GetSlotData(1);
}
}
}

View File

@ -1,4 +1,7 @@
using AquaMai.UX;
using System;
using AquaMai.Cheat;
using AquaMai.Fix;
using AquaMai.UX;
using MelonLoader;
using Tomlet;
@ -18,6 +21,12 @@ namespace AquaMai
{
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...");
@ -33,23 +42,24 @@ namespace AquaMai
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));
if (AppConfig.UX.SkipToMusicSelection)
{
MelonLogger.Msg($"> Patching {nameof(SkipToMusicSelection)}");
HarmonyLib.Harmony.CreateAndPatchAll(typeof(SkipToMusicSelection));
Patch(typeof(SkipToMusicSelection));
}
// Fixes that does not have side effects
// These don't need to be configurable
Patch(typeof(FixCharaCrash));
MelonLogger.Msg("Loaded!");
}
}

View File

@ -2,15 +2,15 @@ using System;
using HarmonyLib;
using UnityEngine;
namespace AquaMai.UX
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;