Files
AquaDX/AquaMai/AquaMai.Mods/UX/QuickEndPlay.cs
Menci 37044dae01 [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.
2024-11-25 01:25:19 +08:00

71 lines
2.1 KiB
C#

using AquaMai.Config.Attributes;
using AquaMai.Core.Helpers;
using AquaMai.Core.Resources;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Monitor;
using Process;
using UnityEngine;
namespace AquaMai.Mods.UX;
[ConfigSection(
en: "Show a \"skip\" button like AstroDX after the notes end.",
zh: "音符结束之后显示像 AstroDX 一样的「跳过」按钮")]
public class QuickEndPlay
{
private static int _timer;
[HarmonyPatch(typeof(GameProcess), "OnStart")]
[HarmonyPostfix]
public static void GameProcessPostStart(GameMonitor[] ____monitors)
{
_timer = 0;
____monitors[0].gameObject.AddComponent<Ui>();
}
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
[HarmonyPostfix]
public static void GameProcessPostUpdate(GameProcess __instance, Message[] ____message, ProcessDataContainer ___container, byte ____sequence)
{
switch (____sequence)
{
case 9:
_timer = 0;
break;
case > 4:
_timer++;
break;
default:
_timer = 0;
break;
}
if (_timer > 60 && (InputManager.GetTouchPanelAreaDown(InputManager.TouchPanelArea.B4) || InputManager.GetTouchPanelAreaDown(InputManager.TouchPanelArea.E4)))
{
var traverse = Traverse.Create(__instance);
___container.processManager.SendMessage(____message[0]);
Singleton<GamePlayManager>.Instance.SetSyncResult(0);
traverse.Method("SetRelease").GetValue();
}
}
private class Ui : MonoBehaviour
{
public void OnGUI()
{
if (_timer < 60) return;
// 这里重新 setup 一下 style 也可以
var x = GuiSizes.PlayerCenter;
var y = Screen.height - GuiSizes.PlayerWidth * .37f;
var width = GuiSizes.PlayerWidth * .25f;
var height = GuiSizes.PlayerWidth * .13f;
GUI.Box(new Rect(x, y, width, height), "");
GUI.Button(new Rect(x, y, width, height), Locale.Skip);
}
}
}