mirror of https://github.com/hykilpikonna/AquaDX
[+] PractiseMode Debugging
parent
24ecaab570
commit
27b8e6bd21
|
@ -37,6 +37,11 @@
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>SDGA145
|
||||||
|
DEBUG</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>Libs\0Harmony.dll</HintPath>
|
<HintPath>Libs\0Harmony.dll</HintPath>
|
||||||
|
@ -314,6 +319,7 @@
|
||||||
<Compile Include="TouchSensitivity\Enable.cs" />
|
<Compile Include="TouchSensitivity\Enable.cs" />
|
||||||
<Compile Include="Utils\JudgeAdjust.cs" />
|
<Compile Include="Utils\JudgeAdjust.cs" />
|
||||||
<Compile Include="Utils\LogUserId.cs" />
|
<Compile Include="Utils\LogUserId.cs" />
|
||||||
|
<Compile Include="Utils\PractiseMode.cs" />
|
||||||
<Compile Include="Utils\WindowState.cs" />
|
<Compile Include="Utils\WindowState.cs" />
|
||||||
<Compile Include="UX\CustomPlaceName.cs" />
|
<Compile Include="UX\CustomPlaceName.cs" />
|
||||||
<Compile Include="UX\CustomVersionString.cs" />
|
<Compile Include="UX\CustomVersionString.cs" />
|
||||||
|
|
|
@ -9,12 +9,15 @@ Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
SDGA145|Any CPU = SDGA145|Any CPU
|
SDGA145|Any CPU = SDGA145|Any CPU
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{788BC472-59F7-46F6-B760-65C18BA74389}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{788BC472-59F7-46F6-B760-65C18BA74389}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{788BC472-59F7-46F6-B760-65C18BA74389}.Release|Any CPU.Build.0 = Release|Any CPU
|
{788BC472-59F7-46F6-B760-65C18BA74389}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{788BC472-59F7-46F6-B760-65C18BA74389}.SDGA145|Any CPU.ActiveCfg = SDGA145|Any CPU
|
{788BC472-59F7-46F6-B760-65C18BA74389}.SDGA145|Any CPU.ActiveCfg = SDGA145|Any CPU
|
||||||
{788BC472-59F7-46F6-B760-65C18BA74389}.SDGA145|Any CPU.Build.0 = SDGA145|Any CPU
|
{788BC472-59F7-46F6-B760-65C18BA74389}.SDGA145|Any CPU.Build.0 = SDGA145|Any CPU
|
||||||
|
{788BC472-59F7-46F6-B760-65C18BA74389}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{788BC472-59F7-46F6-B760-65C18BA74389}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -60,6 +60,7 @@ namespace AquaMai
|
||||||
public bool Windowed { get; set; }
|
public bool Windowed { get; set; }
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
public bool PractiseMode { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TimeSavingConfig
|
public class TimeSavingConfig
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class DebugFeature
|
||||||
private static MovieController _gameMovie;
|
private static MovieController _gameMovie;
|
||||||
private static GameMonitor[] _monitors;
|
private static GameMonitor[] _monitors;
|
||||||
private static object _debugFeatureOriginal;
|
private static object _debugFeatureOriginal;
|
||||||
|
private static System.Type _debugFeatureType;
|
||||||
|
|
||||||
[HarmonyPatch(typeof(GameProcess), "OnStart")]
|
[HarmonyPatch(typeof(GameProcess), "OnStart")]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
@ -39,28 +40,79 @@ public class DebugFeature
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MelonLogger.Msg(" > [DebugFeature] Already included");
|
MelonLogger.Msg(" > [DebugFeature] Already included");
|
||||||
|
_debugFeatureType = typeof(GameProcess).GetNestedType("DebugFeature", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||||
h.PatchAll(typeof(GetOriginal));
|
h.PatchAll(typeof(GetOriginal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetPause(bool pause)
|
public static bool Pause
|
||||||
|
{
|
||||||
|
get
|
||||||
{
|
{
|
||||||
if (IsPolyfill)
|
if (IsPolyfill)
|
||||||
{
|
{
|
||||||
PolyFill.isPause = pause;
|
return PolyFill.isPause;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (bool)_debugFeatureType.GetField("_debugPause", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_debugFeatureOriginal);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (IsPolyfill)
|
||||||
|
{
|
||||||
|
PolyFill.isPause = value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var debugFeatureClass = typeof(GameProcess).GetNestedType("DebugFeature", BindingFlags.Instance | BindingFlags.NonPublic);
|
_debugFeatureType.GetField("_debugPause", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_debugFeatureOriginal, value);
|
||||||
debugFeatureClass?.GetField("_debugPause", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_debugFeatureOriginal, pause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager.PauseMusic(pause);
|
SoundManager.PauseMusic(value);
|
||||||
_gameMovie.Pause(pause);
|
_gameMovie.Pause(value);
|
||||||
NotesManager.Pause(pause);
|
NotesManager.Pause(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Seek(int msec)
|
||||||
|
{
|
||||||
|
Singleton<GamePlayManager>.Instance.Initialize();
|
||||||
|
if (IsPolyfill)
|
||||||
|
{
|
||||||
|
PolyFill.DebugTimeSkip(msec);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_debugFeatureType.GetMethod("DebugTimeSkip", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(_debugFeatureOriginal, new object[] { msec });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double CurrentPlayMsec
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsPolyfill)
|
||||||
|
{
|
||||||
|
return PolyFill.timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (double)_debugFeatureType.GetField("_debugTimer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(_debugFeatureOriginal);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (IsPolyfill)
|
||||||
|
{
|
||||||
|
PolyFill.timer = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_debugFeatureType.GetField("_debugTimer", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(_debugFeatureOriginal, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Seek(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
private static class GetOriginal
|
private static class GetOriginal
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(GameProcess), "OnStart")]
|
[HarmonyPatch(typeof(GameProcess), "OnStart")]
|
||||||
|
@ -71,7 +123,6 @@ public class DebugFeature
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
private static class PolyFill
|
private static class PolyFill
|
||||||
{
|
{
|
||||||
public static bool isPause;
|
public static bool isPause;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class MessageHelper
|
||||||
replaceText = true,
|
replaceText = true,
|
||||||
text = message,
|
text = message,
|
||||||
changeSize = true,
|
changeSize = true,
|
||||||
sizeID = size
|
sizeID = size,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
using AquaMai.Fix;
|
||||||
|
using AquaMai.Helpers;
|
||||||
|
using HarmonyLib;
|
||||||
|
using MelonLoader;
|
||||||
|
using Monitor;
|
||||||
|
using Process;
|
||||||
|
using UnityEngine;
|
||||||
|
using UrGUI.GUIWindow;
|
||||||
|
|
||||||
|
namespace AquaMai.Utils;
|
||||||
|
|
||||||
|
public class PractiseMode
|
||||||
|
{
|
||||||
|
private static double repeatStart = -1;
|
||||||
|
private static double repeatEnd = -1;
|
||||||
|
|
||||||
|
private static void SetRepeatEnd(double time)
|
||||||
|
{
|
||||||
|
if (repeatStart == -1)
|
||||||
|
{
|
||||||
|
MessageHelper.ShowMessage("Please set repeat start time first");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time < repeatStart)
|
||||||
|
{
|
||||||
|
MessageHelper.ShowMessage("Repeat end time cannot be less than repeat start time");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
repeatEnd = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ClearRepeat()
|
||||||
|
{
|
||||||
|
repeatStart = -1;
|
||||||
|
repeatEnd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DebugWindow : MonoBehaviour
|
||||||
|
{
|
||||||
|
private GUIWindow window;
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
window = GUIWindow.Begin("练习模式 测试");
|
||||||
|
window.Button("暂停", () => DebugFeature.Pause = !DebugFeature.Pause);
|
||||||
|
window.SameLine();
|
||||||
|
window.Button("向前", () => DebugFeature.Seek(-1000));
|
||||||
|
window.Button("向后", () => DebugFeature.Seek(1000));
|
||||||
|
window.SameLine(1, 1, 1);
|
||||||
|
window.Button("循环开始", () => repeatStart = DebugFeature.CurrentPlayMsec);
|
||||||
|
window.Button("循环结束", () => SetRepeatEnd(DebugFeature.CurrentPlayMsec));
|
||||||
|
window.Button("循环解除", ClearRepeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
window?.Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DebugWindow debugWin;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void GameProcessPostUpdate(GameProcess __instance, GameMonitor[] ____monitors)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.F12))
|
||||||
|
{
|
||||||
|
if (debugWin is null)
|
||||||
|
{
|
||||||
|
debugWin = ____monitors[0].gameObject.AddComponent<DebugWindow>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MelonLogger.Msg("[PractiseMode] 调试窗口作用中");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (repeatStart >= 0 && repeatEnd >= 0)
|
||||||
|
{
|
||||||
|
if (DebugFeature.CurrentPlayMsec >= repeatEnd)
|
||||||
|
{
|
||||||
|
DebugFeature.CurrentPlayMsec = repeatStart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue