Skip to content

Commit

Permalink
[+] Splash+ support
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 23, 2024
1 parent 1b47bfa commit e844164
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 91 deletions.
25 changes: 17 additions & 8 deletions AquaMai/Fix/BasicFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ private static bool GetMouseButtonDown(ref bool __result, int button)
return false;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(GameManager), "CalcSpecialNum")]
private static bool CalcSpecialNum(ref int __result)
{
__result = 1024;
return false;
}

[HarmonyPostfix]
[HarmonyPatch(typeof(NetHttpClient), MethodType.Constructor)]
private static void OnNetHttpClientConstructor(NetHttpClient __instance)
Expand All @@ -75,4 +67,21 @@ private static void OnNetHttpClientCreate()
// Unset the certificate validation callback (SSL pinning) to restore the default behavior
ServicePointManager.ServerCertificateValidationCallback = null;
}

public static void DoCustomPatch(HarmonyLib.Harmony h)
{
if (typeof(GameManager).GetMethod("CalcSpecialNum") is null) return;
h.PatchAll(typeof(CalcSpecialNumPatch));
}

private class CalcSpecialNumPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(GameManager), "CalcSpecialNum")]
private static bool CalcSpecialNum(ref int __result)
{
__result = 1024;
return false;
}
}
}
21 changes: 21 additions & 0 deletions AquaMai/Helpers/GameInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Reflection;
using MAI2System;

namespace AquaMai.Helpers;

public class GameInfo
{
public static uint GameVersion { get; } = GetGameVersion();

private static uint GetGameVersion()
{
return (uint)typeof(ConstParameter).GetField("NowGameVersion", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null);
}

public static string GameId { get; } = GetGameId();

private static string GetGameId()
{
return typeof(ConstParameter).GetField("GameIDStr", BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy).GetValue(null) as string;
}
}
9 changes: 6 additions & 3 deletions AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,15 @@ public override void OnInitializeMelon()
Patch(typeof(FixCharaCrash));
Patch(typeof(BasicFix));
Patch(typeof(DisableReboot));
Patch(typeof(ExtendNotesPool));
if (GameInfo.GameVersion >= 23000)
Patch(typeof(ExtendNotesPool));
Patch(typeof(FixCheckAuth));
Patch(typeof(DebugFeature));
Patch(typeof(FixConnSlide));
if (GameInfo.GameVersion >= 23000)
Patch(typeof(FixConnSlide));
Patch(typeof(SlideAutoPlayTweak));
Patch(typeof(FixLevelDisplay));
if (GameInfo.GameVersion >= 24000)
Patch(typeof(FixLevelDisplay));
// UX
Patch(typeof(CustomVersionString));
Patch(typeof(CustomPlaceName));
Expand Down
1 change: 0 additions & 1 deletion AquaMai/Resources/Locale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion AquaMai/Resources/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
</data>
<data name="LoadError" xml:space="preserve">
<value>Errors detected while loading!
- Check if you have installed the wrong version of AquaMai, such as using SDEZ version on SDGA
- Are you using a modified Assembly-CSharp.dll, which will cause inconsistent functions and cannot find the functions that need to be modified
- Check for conflicting mods, or enabled incompatible options</value>
</data>
Expand Down
1 change: 0 additions & 1 deletion AquaMai/Resources/Locale.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
</data>
<data name="LoadError" xml:space="preserve">
<value>加载过程中检测到错误!
- 请检查你是否安装了错误的 AquaMai 版本,比如在 SDGA 上使用了 SDEZ 的版本
- 你是否正在使用魔改的 Assembly-CSharp.dll,这会导致函数不一致而无法找到需要修改的函数
- 请检查是否有冲突的 Mod,或者开启了不兼容的选项</value>
</data>
Expand Down
124 changes: 66 additions & 58 deletions AquaMai/UX/QuickSkip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,82 +10,90 @@
using Process;
using UnityEngine;

namespace AquaMai.UX
namespace AquaMai.UX;

public class QuickSkip
{
public class QuickSkip
private static int _keyPressFrames;

[HarmonyPrefix]
[HarmonyPatch(typeof(GameMainObject), "Update")]
public static void OnGameMainObjectUpdate()
{
private static int _keyPressFrames;
// The button between [1p] and [2p] button on ADX
if (Input.GetKey(KeyCode.Alpha7) || InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService)) _keyPressFrames++;

[HarmonyPrefix]
[HarmonyPatch(typeof(GameMainObject), "Update")]
public static void OnGameMainObjectUpdate()
if (_keyPressFrames > 0 && !Input.GetKey(KeyCode.Alpha7) && !InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService))
{
// The button between [1p] and [2p] button on ADX
if (Input.GetKey(KeyCode.Alpha7) || InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService)) _keyPressFrames++;

if (_keyPressFrames > 0 && !Input.GetKey(KeyCode.Alpha7) && !InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService))
{
_keyPressFrames = 0;
MelonLogger.Msg(SharedInstances.ProcessDataContainer.processManager.Dump());
return;
}
_keyPressFrames = 0;
MelonLogger.Msg(SharedInstances.ProcessDataContainer.processManager.Dump());
return;
}

if (_keyPressFrames != 60) return;
MelonLogger.Msg("[QuickSkip] Activated");
if (_keyPressFrames != 60) return;
MelonLogger.Msg("[QuickSkip] Activated");

var traverse = Traverse.Create(SharedInstances.ProcessDataContainer.processManager);
var processList = traverse.Field("_processList").GetValue<LinkedList<ProcessManager.ProcessControle>>();
var traverse = Traverse.Create(SharedInstances.ProcessDataContainer.processManager);
var processList = traverse.Field("_processList").GetValue<LinkedList<ProcessManager.ProcessControle>>();

ProcessBase processToRelease = null;
ProcessBase processToRelease = null;

foreach (ProcessManager.ProcessControle process in processList)
foreach (ProcessManager.ProcessControle process in processList)
{
switch (process.Process.ToString())
{
switch (process.Process.ToString())
{
// After login
case "Process.ModeSelect.ModeSelectProcess":
case "Process.LoginBonus.LoginBonusProcess":
case "Process.RegionalSelectProcess":
case "Process.CharacterSelectProcess":
case "Process.TicketSelect.TicketSelectProcess":
processToRelease = process.Process;
break;
// After login
case "Process.ModeSelect.ModeSelectProcess":
case "Process.LoginBonus.LoginBonusProcess":
case "Process.RegionalSelectProcess":
case "Process.CharacterSelectProcess":
case "Process.TicketSelect.TicketSelectProcess":
processToRelease = process.Process;
break;

case "Process.MusicSelectProcess":
// Skip to save
SoundManager.PreviewEnd();
SoundManager.PlayBGM(Cue.BGM_COLLECTION, 2);
SharedInstances.ProcessDataContainer.processManager.AddProcess(new FadeProcess(SharedInstances.ProcessDataContainer, process.Process, new UnlockMusicProcess(SharedInstances.ProcessDataContainer)));
break;
}
case "Process.MusicSelectProcess":
// Skip to save
SoundManager.PreviewEnd();
SoundManager.PlayBGM(Cue.BGM_COLLECTION, 2);
SharedInstances.ProcessDataContainer.processManager.AddProcess(new FadeProcess(SharedInstances.ProcessDataContainer, process.Process, new UnlockMusicProcess(SharedInstances.ProcessDataContainer)));
break;
}
}

if (processToRelease != null)
{
GameManager.SetMaxTrack();
SharedInstances.ProcessDataContainer.processManager.AddProcess(new FadeProcess(SharedInstances.ProcessDataContainer, processToRelease, new MusicSelectProcess(SharedInstances.ProcessDataContainer)));
}
if (processToRelease != null)
{
GameManager.SetMaxTrack();
SharedInstances.ProcessDataContainer.processManager.AddProcess(new FadeProcess(SharedInstances.ProcessDataContainer, processToRelease, new MusicSelectProcess(SharedInstances.ProcessDataContainer)));
}
}

[HarmonyPostfix]
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
public static void PostGameProcessUpdate(GameProcess __instance, Message[] ____message, ProcessDataContainer ___container)
[HarmonyPostfix]
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
public static void PostGameProcessUpdate(GameProcess __instance, Message[] ____message, ProcessDataContainer ___container)
{
if (InputManager.GetButtonDown(0, InputManager.ButtonSetting.Select))
{
if (InputManager.GetButtonDown(0, InputManager.ButtonSetting.Select))
{
var traverse = Traverse.Create(__instance);
___container.processManager.SendMessage(____message[0]);
Singleton<GamePlayManager>.Instance.SetSyncResult(0);
traverse.Method("SetRelease").GetValue();
}
var traverse = Traverse.Create(__instance);
___container.processManager.SendMessage(____message[0]);
Singleton<GamePlayManager>.Instance.SetSyncResult(0);
traverse.Method("SetRelease").GetValue();
}

if (Input.GetKey(KeyCode.Alpha7) || InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService))
{
// This is original typo in Assembly-CSharp
Singleton<GamePlayManager>.Instance.SetQuickRetryFrag(flag: true);
}
if (Input.GetKey(KeyCode.Alpha7) || InputManager.GetSystemInputPush(InputManager.SystemButtonSetting.ButtonService) && GameInfo.GameVersion >= 23000)
{
// This is original typo in Assembly-CSharp
Singleton<GamePlayManager>.Instance.SetQuickRetryFrag(flag: true);
}
}

public static void DoCustomPatch(HarmonyLib.Harmony h)
{
if (GameInfo.GameVersion < 23000) return;
h.PatchAll(typeof(FestivalAndLaterQuickRetryPatch));
}

private class FestivalAndLaterQuickRetryPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(QuickRetry), "IsQuickRetryEnable")]
public static bool OnQuickRetryIsQuickRetryEnable(ref bool __result)
Expand Down
19 changes: 0 additions & 19 deletions AquaMai/Utils/GameInfo.cs

This file was deleted.

0 comments on commit e844164

Please sign in to comment.