[O] Auto detect if DebugFeature is need to be patched

pull/55/head
Clansty 2024-09-27 20:18:53 +08:00
parent a2db465825
commit c1c7788cd3
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134
6 changed files with 28 additions and 12 deletions

View File

@ -284,12 +284,12 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Cheat\DebugFeature.cs" />
<Compile Include="Cheat\MapUnlock.cs" /> <Compile Include="Cheat\MapUnlock.cs" />
<Compile Include="Cheat\TicketUnlock.cs" /> <Compile Include="Cheat\TicketUnlock.cs" />
<Compile Include="Cheat\UnlockUtage.cs" /> <Compile Include="Cheat\UnlockUtage.cs" />
<Compile Include="Config.cs" /> <Compile Include="Config.cs" />
<Compile Include="Fix\BasicFix.cs" /> <Compile Include="Fix\BasicFix.cs" />
<Compile Include="Fix\DebugFeature.cs" />
<Compile Include="Fix\DisableReboot.cs" /> <Compile Include="Fix\DisableReboot.cs" />
<Compile Include="Fix\ExtendNotesPool.cs" /> <Compile Include="Fix\ExtendNotesPool.cs" />
<Compile Include="Fix\FixCharaCrash.cs" /> <Compile Include="Fix\FixCharaCrash.cs" />

View File

@ -8,8 +8,6 @@ TicketUnlock=true
MapUnlock=true MapUnlock=true
# Unlock Utage without the need of DXRating 10000 # Unlock Utage without the need of DXRating 10000
UnlockUtage=true UnlockUtage=true
# Restore AutoPlay(Home) and Pause(Enter) for SDGA
DebugFeature=true
# =================================== # ===================================
# UX: User Experience Improvements # UX: User Experience Improvements

View File

@ -11,8 +11,6 @@ TicketUnlock=true
MapUnlock=true MapUnlock=true
# 不需要万分也可以进宴会场 # 不需要万分也可以进宴会场
UnlockUtage=true UnlockUtage=true
# 恢复 SDGA 的自动播放Home和暂停Enter按键
DebugFeature=true
# =================================== # ===================================
# 用户体验改进 # 用户体验改进

View File

@ -18,7 +18,6 @@ namespace AquaMai
public bool TicketUnlock { get; set; } public bool TicketUnlock { get; set; }
public bool MapUnlock { get; set; } public bool MapUnlock { get; set; }
public bool UnlockUtage { get; set; } public bool UnlockUtage { get; set; }
public bool DebugFeature { get; set; }
} }
public class UXConfig public class UXConfig

View File

@ -1,22 +1,37 @@
using System; using System;
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib; using HarmonyLib;
using MAI2.Util; using MAI2.Util;
using Manager; using Manager;
using MelonLoader;
using Monitor; using Monitor;
using Process; using Process;
using UnityEngine; using UnityEngine;
namespace AquaMai.Cheat; namespace AquaMai.Fix;
[HarmonyPatch]
public class DebugFeature public class DebugFeature
{ {
# if SDGA145 public static bool IsPatchingSkipped { get; private set; }
private static bool isPause; private static bool isPause;
private static double timer; private static double timer;
[HarmonyPostfix] public static IEnumerable<MethodBase> TargetMethods()
[HarmonyPatch(typeof(GameProcess), "OnUpdate")] {
public static void PostGameProcessUpdate(GameProcess __instance, byte ____sequence, MovieController ____gameMovie, GameMonitor[] ____monitors) var original = typeof(GameProcess).GetField("debugFeature", BindingFlags.NonPublic | BindingFlags.Instance);
if (original is not null)
{
MelonLogger.Msg("[DebugFeature] Skipped because already included");
IsPatchingSkipped = true;
return [];
}
return [AccessTools.Method(typeof(GameProcess), "OnUpdate")];
}
public static void Postfix(GameProcess __instance, byte ____sequence, MovieController ____gameMovie, GameMonitor[] ____monitors)
{ {
if (____sequence != 4) return; if (____sequence != 4) return;
// GameSequence.Play // GameSequence.Play
@ -24,6 +39,7 @@ public class DebugFeature
{ {
timer += GameManager.GetGameMSecAddD(); timer += GameManager.GetGameMSecAddD();
} }
if (Input.GetKeyDown(KeyCode.Home)) if (Input.GetKeyDown(KeyCode.Home))
{ {
GameManager.AutoPlay = (GameManager.AutoPlayMode)((int)(GameManager.AutoPlay + 1) % Enum.GetNames(typeof(GameManager.AutoPlayMode)).Length); GameManager.AutoPlay = (GameManager.AutoPlayMode)((int)(GameManager.AutoPlay + 1) % Enum.GetNames(typeof(GameManager.AutoPlayMode)).Length);
@ -42,10 +58,12 @@ public class DebugFeature
{ {
num23 = -1000; num23 = -1000;
} }
if (DebugInput.GetKeyDown(KeyCode.RightArrow)) if (DebugInput.GetKeyDown(KeyCode.RightArrow))
{ {
num23 = 1000; num23 = 1000;
} }
int addMsec = ((!DebugInput.GetKey(KeyCode.LeftShift) && !DebugInput.GetKey(KeyCode.RightShift)) ? ((!DebugInput.GetKey(KeyCode.LeftControl) && !DebugInput.GetKey(KeyCode.RightControl)) ? num23 : (num23 * 10)) : (num23 * 5)); int addMsec = ((!DebugInput.GetKey(KeyCode.LeftShift) && !DebugInput.GetKey(KeyCode.RightShift)) ? ((!DebugInput.GetKey(KeyCode.LeftControl) && !DebugInput.GetKey(KeyCode.RightControl)) ? num23 : (num23 * 10)) : (num23 * 5));
Singleton<GamePlayManager>.Instance.Initialize(); Singleton<GamePlayManager>.Instance.Initialize();
DebugTimeSkip(addMsec); DebugTimeSkip(addMsec);
@ -66,12 +84,14 @@ public class DebugFeature
{ {
timer = timer + addMsec >= 0.0 ? timer + addMsec : 0.0; timer = timer + addMsec >= 0.0 ? timer + addMsec : 0.0;
} }
____gameMovie.SetSeekFrame(timer); ____gameMovie.SetSeekFrame(timer);
SoundManager.SeekMusic((int)timer); SoundManager.SeekMusic((int)timer);
for (int i = 0; i < ____monitors.Length; i++) for (int i = 0; i < ____monitors.Length; i++)
{ {
____monitors[i].Seek((int)timer); ____monitors[i].Seek((int)timer);
} }
// magic number, dont know why // magic number, dont know why
NotesManager.StartPlay((int)timer + 91); NotesManager.StartPlay((int)timer + 91);
NotesManager.Pause(isPause); NotesManager.Pause(isPause);
@ -84,8 +104,8 @@ public class DebugFeature
{ {
____gameMovie.Pause(pauseFlag: true); ____gameMovie.Pause(pauseFlag: true);
} }
__instance.UpdateNotes(); __instance.UpdateNotes();
} }
} }
# endif
} }

View File

@ -129,6 +129,7 @@ namespace AquaMai
Patch(typeof(DisableReboot)); Patch(typeof(DisableReboot));
Patch(typeof(ExtendNotesPool)); Patch(typeof(ExtendNotesPool));
Patch(typeof(FixCheckAuth)); Patch(typeof(FixCheckAuth));
Patch(typeof(DebugFeature));
// UX // UX
Patch(typeof(CustomVersionString)); Patch(typeof(CustomVersionString));
Patch(typeof(CustomPlaceName)); Patch(typeof(CustomPlaceName));