forked from Cookies_Github_mirror/AquaDX
[RF] AquaMai configuration refactor (#82)
更新了配置文件格式,原有的配置文件将被自动无缝迁移,详情请见新的配置文件中的注释(例外:`SlideJudgeTweak` 不再默认启用) 旧配置文件将被重命名备份,如果更新到此版本遇到 Bug 请联系我们 Updated configuration file schema. The old config file will be migrated automatically and seamlessly. See the comments in the new configuration file for details. (Except for `SlideJudgeTweak` is no longer enabled by default) Your old configuration file will be renamed as a backup. If you encounter any bug with this version, please contact us.
This commit is contained in:
69
AquaMai/AquaMai.Mods/GameSystem/TestProof.cs
Normal file
69
AquaMai/AquaMai.Mods/GameSystem/TestProof.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using AquaMai.Config.Attributes;
|
||||
using AquaMai.Config.Types;
|
||||
using AquaMai.Core;
|
||||
using AquaMai.Core.Attributes;
|
||||
using AquaMai.Core.Helpers;
|
||||
using AquaMai.Mods.UX;
|
||||
using AquaMai.Mods.UX.PracticeMode;
|
||||
using HarmonyLib;
|
||||
using Manager;
|
||||
|
||||
namespace AquaMai.Mods.GameSystem;
|
||||
|
||||
[ConfigSection(
|
||||
en: """
|
||||
When enabled, test button must be long pressed to enter game test mode.
|
||||
When test button is bound to other features, this option is enabled automatically.
|
||||
""",
|
||||
zh: """
|
||||
启用后,测试键必须长按才能进入游戏测试模式
|
||||
当测试键被绑定到其它功能时,此选项自动开启
|
||||
""")]
|
||||
[EnableImplicitlyIf(nameof(ShouldEnableImplicitly))]
|
||||
public class TestProof
|
||||
{
|
||||
public static bool ShouldEnableImplicitly
|
||||
{
|
||||
get
|
||||
{
|
||||
(System.Type section, KeyCodeOrName key)[] featureKeys =
|
||||
[
|
||||
(typeof(OneKeyEntryEnd), OneKeyEntryEnd.key),
|
||||
(typeof(OneKeyRetrySkip), OneKeyRetrySkip.retryKey),
|
||||
(typeof(OneKeyRetrySkip), OneKeyRetrySkip.skipKey),
|
||||
(typeof(HideSelfMadeCharts), HideSelfMadeCharts.key),
|
||||
(typeof(PracticeMode), PracticeMode.key),
|
||||
];
|
||||
var keyMapEnabled = ConfigLoader.Config.GetSectionState(typeof(KeyMap)).Enabled;
|
||||
return featureKeys.Any(it =>
|
||||
// The feature is enabled and...
|
||||
ConfigLoader.Config.GetSectionState(it.section).Enabled &&
|
||||
(
|
||||
// and the key is test, or...
|
||||
it.key == KeyCodeOrName.Test ||
|
||||
// or the key have been mapped to the same key as test.
|
||||
(keyMapEnabled && it.key.ToString() == KeyMap.Test.ToString())));
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(InputManager), "GetSystemInputDown")]
|
||||
public static bool GetSystemInputDown(ref bool __result, InputManager.SystemButtonSetting button, bool[] ___SystemButtonDown)
|
||||
{
|
||||
__result = ___SystemButtonDown[(int)button];
|
||||
if (button != InputManager.SystemButtonSetting.ButtonTest)
|
||||
return false;
|
||||
|
||||
var stackTrace = new StackTrace(); // get call stack
|
||||
var stackFrames = stackTrace.GetFrames(); // get method calls (frames)
|
||||
|
||||
if (stackFrames.Any(it => it.GetMethod().Name == "DMD<Main.GameMainObject::Update>"))
|
||||
{
|
||||
__result = KeyListener.GetKeyDownOrLongPress(KeyCodeOrName.Test, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user