diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 3c3c3754..82d53ee0 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -290,6 +290,8 @@ DEBUG + + @@ -299,6 +301,7 @@ DEBUG + @@ -321,6 +324,7 @@ DEBUG + diff --git a/AquaMai/AquaMai.toml b/AquaMai/AquaMai.toml index 26cd6916..7199a172 100644 --- a/AquaMai/AquaMai.toml +++ b/AquaMai/AquaMai.toml @@ -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 @@ -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 diff --git a/AquaMai/AquaMai.zh.toml b/AquaMai/AquaMai.zh.toml index f01f8065..30264f27 100644 --- a/AquaMai/AquaMai.zh.toml +++ b/AquaMai/AquaMai.zh.toml @@ -76,6 +76,8 @@ ForceFreePlay=true ForcePaidPlay=false # 增加更多待命的音符贴图,防止奇怪的自制谱用完音符贴图池 ExtendNotesPool=128 +# 强制设置帧率上限为 60 帧并关闭垂直同步。如果你的游戏没有问题,请不要使用 +FrameRateLock=false [Utils] # 登录时将 UserID 输出到日志 @@ -96,6 +98,8 @@ Height=0 SelectionDetail=true # 出现灰网时显示原因 ShowNetErrorDetail=true +# 显示帧率 +FrameRateDisplay=false # =================================== # 节省一些不知道有用没用的时间 diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 2116b145..f8f9445f 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -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 @@ -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 @@ -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]; + } } } diff --git a/AquaMai/CustomKeyMap/Enable.cs b/AquaMai/CustomKeyMap/Enable.cs new file mode 100644 index 00000000..f9d6cc6e --- /dev/null +++ b/AquaMai/CustomKeyMap/Enable.cs @@ -0,0 +1,6 @@ +namespace AquaMai.CustomKeyMap; + +public class Enable +{ + +} \ No newline at end of file diff --git a/AquaMai/CustomKeyMap/KeyCodeID.cs b/AquaMai/CustomKeyMap/KeyCodeID.cs new file mode 100644 index 00000000..b4b9dc8f --- /dev/null +++ b/AquaMai/CustomKeyMap/KeyCodeID.cs @@ -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, +} diff --git a/AquaMai/Fix/FrameRateLock.cs b/AquaMai/Fix/FrameRateLock.cs new file mode 100644 index 00000000..0375aba4 --- /dev/null +++ b/AquaMai/Fix/FrameRateLock.cs @@ -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; + } +} diff --git a/AquaMai/Utils/FrameRateDisplay.cs b/AquaMai/Utils/FrameRateDisplay.cs new file mode 100644 index 00000000..e5c108c5 --- /dev/null +++ b/AquaMai/Utils/FrameRateDisplay.cs @@ -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(); + } + + 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"); + } + } +}