Skip to content

Commit

Permalink
[+] QuickEndPlay button when notes play end
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 15, 2024
1 parent f716ab0 commit 1810bbe
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ SkipGameOverScreen=true
SkipTrackStart=true
# Show reason when net icon is gray
ShowNetErrorDetail=true
# Show a "skip" button like AstroDX after the notes end
ShowQuickEndPlay=true

[WindowState]
# If not enabled, no operations will be performed on the game window
Expand Down
2 changes: 2 additions & 0 deletions AquaMai/AquaMai.zh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ IWontTapOrSlideVigorously=true
SkipGameOverScreen=true
# 跳过乐曲开始界面
SkipTrackStart=true
# 音符结束之后显示像 AstroDX 一样的“跳过”按钮
ShowQuickEndPlay=true

[WindowState]
# 不启用的话,不会对游戏窗口做任何操作
Expand Down
1 change: 1 addition & 0 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public class TimeSavingConfig
public bool IWontTapOrSlideVigorously { get; set; }
public bool SkipGameOverScreen { get; set; }
public bool SkipTrackStart { get; set; }
public bool ShowQuickEndPlay { get; set; }
}

public class WindowStateConfig
Expand Down
9 changes: 9 additions & 0 deletions AquaMai/Resources/Locale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions AquaMai/Resources/Locale.resx
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@
<data name="RatingUpWhenSSSp" xml:space="preserve">
<value>SSS+ =&gt; DXRating += {0}</value>
</data>
<data name="Skip" xml:space="preserve">
<value>Skip</value>
</data>
</root>
3 changes: 3 additions & 0 deletions AquaMai/Resources/Locale.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@
<data name="RatingUpWhenSSSp" xml:space="preserve">
<value>推到鸟加可上 {0} 分</value>
</data>
<data name="Skip" xml:space="preserve">
<value>跳过</value>
</data>
</root>
59 changes: 59 additions & 0 deletions AquaMai/TimeSaving/ShowQuickEndPlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Collections.Generic;
using AquaMai.Helpers;
using AquaMai.Resources;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Monitor;
using Process;
using UnityEngine;

namespace AquaMai.TimeSaving;

public class ShowQuickEndPlay
{
private static bool _showUi;

[HarmonyPatch(typeof(GameProcess), "OnStart")]
[HarmonyPostfix]
public static void GameProcessPostStart(GameMonitor[] ____monitors)
{
_showUi = false;
____monitors[0].gameObject.AddComponent<Ui>();
}

[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
[HarmonyPostfix]
public static void GameProcessPostUpdate(GameProcess __instance, Message[] ____message, ProcessDataContainer ___container, byte ____sequence)
{
if (____sequence > 4)
{
_showUi = true;
}

if (_showUi && (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 (!_showUi) return;
var style = GUI.skin.GetStyle("button");
style.fontSize = GuiSizes.FontSize;

var x = GuiSizes.PlayerCenter;
var y = Screen.height - GuiSizes.PlayerWidth * .37f;
var width = GuiSizes.PlayerWidth * .25f;
var height = GuiSizes.PlayerWidth * .13f;

GUI.Button(new Rect(x, y, width, height), Locale.Skip);
}
}
}

0 comments on commit 1810bbe

Please sign in to comment.