Skip to content

Commit

Permalink
[+] FrameRate lock + display
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 1, 2024
1 parent 9ead7a4 commit c15dcf6
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ DEBUG</DefineConstants>
<Compile Include="Cheat\TicketUnlock.cs" />
<Compile Include="Cheat\UnlockUtage.cs" />
<Compile Include="Config.cs" />
<Compile Include="CustomKeyMap\Enable.cs" />
<Compile Include="CustomKeyMap\KeyCodeID.cs" />
<Compile Include="Fix\BasicFix.cs" />
<Compile Include="Fix\DebugFeature.cs" />
<Compile Include="Fix\DisableReboot.cs" />
Expand All @@ -299,6 +301,7 @@ DEBUG</DefineConstants>
<Compile Include="Fix\ForceAsServer.cs" />
<Compile Include="Fix\ForceFreePlay.cs" />
<Compile Include="Fix\ForcePaidPlay.cs" />
<Compile Include="Fix\FrameRateLock.cs" />
<Compile Include="Fix\I18nSingleAssemblyHook.cs" />
<Compile Include="Fix\RemoveEncryption.cs" />
<Compile Include="Fix\SkipVersionCheck.cs" />
Expand All @@ -321,6 +324,7 @@ DEBUG</DefineConstants>
<Compile Include="TimeSaving\SkipTrackStart.cs" />
<Compile Include="TimeSaving\SkipWarningScreen.cs" />
<Compile Include="TouchSensitivity\Enable.cs" />
<Compile Include="Utils\FrameRateDisplay.cs" />
<Compile Include="Utils\JudgeAdjust.cs" />
<Compile Include="Utils\LogNetworkErrors.cs" />
<Compile Include="Utils\LogUserId.cs" />
Expand Down
4 changes: 4 additions & 0 deletions AquaMai/AquaMai.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ ForceFreePlay=true
ForcePaidPlay=false
# Add notes sprite to the pool to prevent use up
ExtendNotesPool=128
# Force the frame rate limit to 60 FPS and disable vSync. Do not use if your game has no issues
FrameRateLock=false

[Utils]
# Log user ID on login
Expand All @@ -78,6 +80,8 @@ Width=0
Height=0
# Show detail of selected song in music selection screen
SelectionDetail=true
# Display framerate
FrameRateDisplay=false

# ===================================
# Save some potentially unnecessary time
Expand Down
4 changes: 4 additions & 0 deletions AquaMai/AquaMai.zh.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ ForceFreePlay=true
ForcePaidPlay=false
# 增加更多待命的音符贴图,防止奇怪的自制谱用完音符贴图池
ExtendNotesPool=128
# 强制设置帧率上限为 60 帧并关闭垂直同步。如果你的游戏没有问题,请不要使用
FrameRateLock=false

[Utils]
# 登录时将 UserID 输出到日志
Expand All @@ -96,6 +98,8 @@ Height=0
SelectionDetail=true
# 出现灰网时显示原因
ShowNetErrorDetail=true
# 显示帧率
FrameRateDisplay=false

# ===================================
# 节省一些不知道有用没用的时间
Expand Down
8 changes: 8 additions & 0 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class FixConfig
public bool ForceFreePlay { get; set; } = true;
public bool ForcePaidPlay { get; set; }
public int ExtendNotesPool { get; set; }
public bool FrameRateLock { get; set; }
}

public class UtilsConfig
Expand All @@ -61,6 +62,7 @@ public class UtilsConfig
public bool PractiseMode { get; set; }
public bool SelectionDetail { get; set; }
public bool ShowNetErrorDetail { get; set; }
public bool FrameRateDisplay { get; set; }
}

public class TimeSavingConfig
Expand Down Expand Up @@ -120,5 +122,11 @@ public class TouchSensitivityConfig
public byte E7 { get; set; } = 20;
public byte E8 { get; set; } = 20;
}

public class CustomKeyMapConfig
{
public bool Enable { get; set; }
public string[] KeyMap { get; set; } = new string[0];
}
}
}
6 changes: 6 additions & 0 deletions AquaMai/CustomKeyMap/Enable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace AquaMai.CustomKeyMap;

public class Enable
{

}
146 changes: 146 additions & 0 deletions AquaMai/CustomKeyMap/KeyCodeID.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
namespace AquaMai.CustomKeyMap;

public enum KeyCodeID
{
None,
Backspace,
Tab,
Clear,
Return,
Pause,
Escape,
Space,
Exclaim,
DoubleQuote,
Hash,
Dollar,
Ampersand,
Quote,
LeftParen,
RightParen,
Asterisk,
Plus,
Comma,
Minus,
Period,
Slash,
Alpha0,
Alpha1,
Alpha2,
Alpha3,
Alpha4,
Alpha5,
Alpha6,
Alpha7,
Alpha8,
Alpha9,
Colon,
Semicolon,
Less,
Equals,
Greater,
Question,
At,
LeftBracket,
Backslash,
RightBracket,
Caret,
Underscore,
BackQuote,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
Delete,
Keypad0,
Keypad1,
Keypad2,
Keypad3,
Keypad4,
Keypad5,
Keypad6,
Keypad7,
Keypad8,
Keypad9,
KeypadPeriod,
KeypadDivide,
KeypadMultiply,
KeypadMinus,
KeypadPlus,
KeypadEnter,
KeypadEquals,
UpArrow,
DownArrow,
RightArrow,
LeftArrow,
Insert,
Home,
End,
PageUp,
PageDown,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
Numlock,
CapsLock,
ScrollLock,
RightShift,
LeftShift,
RightControl,
LeftControl,
RightAlt,
LeftAlt,
RightCommand,
RightApple,
LeftCommand,
LeftApple,
LeftWindows,
RightWindows,
AltGr,
Help,
Print,
SysReq,
Break,
Menu,
Mouse0,
Mouse1,
Mouse2,
Mouse3,
Mouse4,
Mouse5,
Mouse6,
}
12 changes: 12 additions & 0 deletions AquaMai/Fix/FrameRateLock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;

namespace AquaMai.Fix;

public class FrameRateLock
{
public static void DoCustomPatch(HarmonyLib.Harmony h)
{
Application.targetFrameRate = 60;
QualitySettings.vSyncCount = 0;
}
}
49 changes: 49 additions & 0 deletions AquaMai/Utils/FrameRateDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using AquaMai.Helpers;
using HarmonyLib;
using Main;
using UnityEngine;

namespace AquaMai.Utils;

public class FrameRateDisplay
{
[HarmonyPatch(typeof(GameMainObject), "Awake")]
[HarmonyPostfix]
public static void ShowUi(GameMainObject __instance)
{
__instance.gameObject.AddComponent<Ui>();
}

private class Ui : MonoBehaviour
{
private static float sampleTime = 1f;
private static int frame;
private static float time;
private static float fps;

public void OnGUI()
{
var labelStyle = GUI.skin.GetStyle("label");
labelStyle.fontSize = GuiSizes.FontSize;
labelStyle.alignment = TextAnchor.MiddleCenter;

const float x = 10f;
const float y = 10f;
var width = GuiSizes.FontSize * 7f;
var height = GuiSizes.LabelHeight * 1.5f;

frame += 1;
time += Time.deltaTime;

if (time >= sampleTime)
{
fps = frame / time;
frame = 0;
time = 0;
}

GUI.Box(new Rect(x, y, width, height), "");
GUI.Label(new Rect(x, y, width, height), $"{fps:0.0} FPS");
}
}
}

0 comments on commit c15dcf6

Please sign in to comment.