[O] ResetTouchAfterTrack -> ResetTouch, add press key to reset (#93)

* [O] ResetTouchAfterTrack -> ResetTouch, add press key to reset

* fix

* update

* fix: Remove not work

---------

Co-authored-by: Menci <mencici@msn.com>
This commit is contained in:
凌莞~(=^▽^=)
2024-11-30 05:29:30 +08:00
committed by GitHub
parent bed1b85319
commit d5a9c98ff9
12 changed files with 161 additions and 24 deletions

View File

@@ -5,6 +5,7 @@ using AquaMai.Config.Types;
using AquaMai.Core;
using AquaMai.Core.Attributes;
using AquaMai.Core.Helpers;
using AquaMai.Mods.Tweaks;
using AquaMai.Mods.UX;
using AquaMai.Mods.UX.PracticeMode;
using HarmonyLib;
@@ -35,6 +36,7 @@ public class TestProof
(typeof(OneKeyRetrySkip), OneKeyRetrySkip.skipKey),
(typeof(HideSelfMadeCharts), HideSelfMadeCharts.key),
(typeof(PracticeMode), PracticeMode.key),
(typeof(ResetTouch), ResetTouch.key),
];
var keyMapEnabled = ConfigLoader.Config.GetSectionState(typeof(KeyMap)).Enabled;
return featureKeys.Any(it =>

View File

@@ -0,0 +1,43 @@
using AquaMai.Config.Attributes;
using AquaMai.Config.Types;
using AquaMai.Core.Helpers;
using AquaMai.Core.Resources;
using HarmonyLib;
using MAI2.Util;
using Main;
using Manager;
using Process;
namespace AquaMai.Mods.Tweaks;
[ConfigSection(
en: "Reset touch panel manually or after playing track.",
zh: "重置触摸面板")]
public class ResetTouch
{
[ConfigEntry(en: "Reset touch panel after playing track.", zh: "玩完一首歌自动重置")]
private static bool afterTrack = false;
[ConfigEntry(en: "Reset manually.", zh: "按键重置")]
public static readonly KeyCodeOrName key = KeyCodeOrName.None;
[ConfigEntry] private static readonly bool longPress = false;
[HarmonyPostfix]
[HarmonyPatch(typeof(ResultProcess), "OnStart")]
public static void ResultProcessOnStart()
{
if (!afterTrack) return;
SingletonStateMachine<AmManager, AmManager.EState>.Instance.StartTouchPanel();
MelonLoader.MelonLogger.Msg("[TouchResetAfterTrack] Touch panel reset");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameMainObject), "Update")]
public static void OnGameMainObjectUpdate()
{
if (!KeyListener.GetKeyDownOrLongPress(key, longPress)) return;
SingletonStateMachine<AmManager, AmManager.EState>.Instance.StartTouchPanel();
MessageHelper.ShowMessage(Locale.TouchPanelReset);
}
}

View File

@@ -1,21 +0,0 @@
using AquaMai.Config.Attributes;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Process;
namespace AquaMai.Mods.Tweaks;
[ConfigSection(
en: "Reset touch panel after playing track.",
zh: "在游玩一首曲目后重置触摸面板")]
public class ResetTouchAfterTrack
{
[HarmonyPostfix]
[HarmonyPatch(typeof(ResultProcess), "OnStart")]
public static void ResultProcessOnStart()
{
SingletonStateMachine<AmManager, AmManager.EState>.Instance.StartTouchPanel();
MelonLoader.MelonLogger.Msg("[TouchResetAfterTrack] Touch panel reset");
}
}