From 9ead7a413edcf16a7bf408809998b880ee3d820a Mon Sep 17 00:00:00 2001 From: Clansty Date: Tue, 1 Oct 2024 15:50:00 +0800 Subject: [PATCH] [+] able to switch off WindowState --- AquaMai/AquaMai.csproj | 2 +- AquaMai/Config.cs | 12 ++++++++--- AquaMai/Main.cs | 1 - AquaMai/Utils/PractiseMode.cs | 2 ++ .../WindowState.cs => WindowState/Enable.cs} | 20 +++++++++---------- 5 files changed, 22 insertions(+), 15 deletions(-) rename AquaMai/{Utils/WindowState.cs => WindowState/Enable.cs} (71%) diff --git a/AquaMai/AquaMai.csproj b/AquaMai/AquaMai.csproj index 0ec5818a..3c3c3754 100644 --- a/AquaMai/AquaMai.csproj +++ b/AquaMai/AquaMai.csproj @@ -328,7 +328,6 @@ DEBUG - @@ -343,6 +342,7 @@ DEBUG + diff --git a/AquaMai/Config.cs b/AquaMai/Config.cs index 88981f7c..2116b145 100644 --- a/AquaMai/Config.cs +++ b/AquaMai/Config.cs @@ -11,6 +11,7 @@ namespace AquaMai public FixConfig Fix { get; set; } = new(); public UtilsConfig Utils { get; set; } = new(); public TimeSavingConfig TimeSaving { get; set; } = new(); + public WindowStateConfig WindowState { get; set; } = new(); public TouchSensitivityConfig TouchSensitivity { get; set; } = new(); public class CheatConfig @@ -57,9 +58,6 @@ namespace AquaMai public float JudgeAdjustA { get; set; } public float JudgeAdjustB { get; set; } public int TouchDelay { get; set; } - public bool Windowed { get; set; } - public int Width { get; set; } - public int Height { get; set; } public bool PractiseMode { get; set; } public bool SelectionDetail { get; set; } public bool ShowNetErrorDetail { get; set; } @@ -76,6 +74,14 @@ namespace AquaMai public bool SkipTrackStart { get; set; } } + public class WindowStateConfig + { + public bool Enable { get; set; } + public bool Windowed { get; set; } + public int Width { get; set; } + public int Height { get; set; } + } + public class TouchSensitivityConfig { public bool Enable { get; set; } diff --git a/AquaMai/Main.cs b/AquaMai/Main.cs index 5bce860e..7d8619b9 100644 --- a/AquaMai/Main.cs +++ b/AquaMai/Main.cs @@ -147,7 +147,6 @@ namespace AquaMai // Fixes that does not have side effects // These don't need to be configurable - WindowState.Execute(); // Helpers Patch(typeof(MessageHelper)); Patch(typeof(MusicDirHelper)); diff --git a/AquaMai/Utils/PractiseMode.cs b/AquaMai/Utils/PractiseMode.cs index fd8498bb..35df7592 100644 --- a/AquaMai/Utils/PractiseMode.cs +++ b/AquaMai/Utils/PractiseMode.cs @@ -92,6 +92,7 @@ public class PractiseMode SetSpeed(); } +# if DEBUG [HarmonyPrefix] [HarmonyPatch(typeof(GenericProcess), "OnUpdate")] public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors) @@ -101,6 +102,7 @@ public class PractiseMode ____monitors[0].gameObject.AddComponent(); } } +# endif [HarmonyPatch(typeof(GameProcess), "OnUpdate")] [HarmonyPostfix] diff --git a/AquaMai/Utils/WindowState.cs b/AquaMai/WindowState/Enable.cs similarity index 71% rename from AquaMai/Utils/WindowState.cs rename to AquaMai/WindowState/Enable.cs index f6b91028..43c9db0c 100644 --- a/AquaMai/Utils/WindowState.cs +++ b/AquaMai/WindowState/Enable.cs @@ -3,32 +3,32 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; using UnityEngine; -namespace AquaMai.Utils; +namespace AquaMai.WindowState; -public class WindowState +public class Enable { private const int GWL_STYLE = -16; - private const int WS_WHATEVER = 0x14CF0000; + private const int WS_WHATEVER = 0x14CF0000; private static IntPtr hwnd = IntPtr.Zero; - public static void Execute() + public static void DoCustomPatch(HarmonyLib.Harmony h) { - if (AquaMai.AppConfig.Utils.Windowed) + if (AquaMai.AppConfig.WindowState.Windowed) { var alreadyWindowed = Screen.fullScreenMode == FullScreenMode.Windowed; - if (AquaMai.AppConfig.Utils.Width == 0 || AquaMai.AppConfig.Utils.Height == 0) + if (AquaMai.AppConfig.WindowState.Width == 0 || AquaMai.AppConfig.WindowState.Height == 0) { Screen.fullScreenMode = FullScreenMode.Windowed; } else { alreadyWindowed = false; - Screen.SetResolution(AquaMai.AppConfig.Utils.Width, AquaMai.AppConfig.Utils.Height, FullScreenMode.Windowed); + Screen.SetResolution(AquaMai.AppConfig.WindowState.Width, AquaMai.AppConfig.WindowState.Height, FullScreenMode.Windowed); } hwnd = GetWindowHandle(); - if(alreadyWindowed) + if (alreadyWindowed) { SetResizeable(); } @@ -44,8 +44,8 @@ public class WindowState } else { - var width = AquaMai.AppConfig.Utils.Width == 0 ? Display.main.systemWidth : AquaMai.AppConfig.Utils.Width; - var height = AquaMai.AppConfig.Utils.Height == 0 ? Display.main.systemHeight : AquaMai.AppConfig.Utils.Height; + var width = AquaMai.AppConfig.WindowState.Width == 0 ? Display.main.systemWidth : AquaMai.AppConfig.WindowState.Width; + var height = AquaMai.AppConfig.WindowState.Height == 0 ? Display.main.systemHeight : AquaMai.AppConfig.WindowState.Height; Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow); } }