[+] able to switch off WindowState

This commit is contained in:
Clansty
2024-10-01 15:50:00 +08:00
parent 07817b04fb
commit 9ead7a413e
5 changed files with 22 additions and 15 deletions

View File

@@ -328,7 +328,6 @@ DEBUG</DefineConstants>
<Compile Include="Utils\PractiseModeUI.cs" /> <Compile Include="Utils\PractiseModeUI.cs" />
<Compile Include="Utils\SelectionDetail.cs" /> <Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\ShowNetErrorDetail.cs" /> <Compile Include="Utils\ShowNetErrorDetail.cs" />
<Compile Include="Utils\WindowState.cs" />
<Compile Include="UX\CustomPlaceName.cs" /> <Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" /> <Compile Include="UX\CustomVersionString.cs" />
<Compile Include="UX\DemoMaster.cs" /> <Compile Include="UX\DemoMaster.cs" />
@@ -343,6 +342,7 @@ DEBUG</DefineConstants>
<Compile Include="UX\RunCommandOnEvents.cs" /> <Compile Include="UX\RunCommandOnEvents.cs" />
<Compile Include="UX\SinglePlayer.cs" /> <Compile Include="UX\SinglePlayer.cs" />
<Compile Include="UX\TestProof.cs" /> <Compile Include="UX\TestProof.cs" />
<Compile Include="WindowState\Enable.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />

View File

@@ -11,6 +11,7 @@ namespace AquaMai
public FixConfig Fix { get; set; } = new(); public FixConfig Fix { get; set; } = new();
public UtilsConfig Utils { get; set; } = new(); public UtilsConfig Utils { get; set; } = new();
public TimeSavingConfig TimeSaving { get; set; } = new(); public TimeSavingConfig TimeSaving { get; set; } = new();
public WindowStateConfig WindowState { get; set; } = new();
public TouchSensitivityConfig TouchSensitivity { get; set; } = new(); public TouchSensitivityConfig TouchSensitivity { get; set; } = new();
public class CheatConfig public class CheatConfig
@@ -57,9 +58,6 @@ namespace AquaMai
public float JudgeAdjustA { get; set; } public float JudgeAdjustA { get; set; }
public float JudgeAdjustB { get; set; } public float JudgeAdjustB { get; set; }
public int TouchDelay { 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 PractiseMode { get; set; }
public bool SelectionDetail { get; set; } public bool SelectionDetail { get; set; }
public bool ShowNetErrorDetail { get; set; } public bool ShowNetErrorDetail { get; set; }
@@ -76,6 +74,14 @@ namespace AquaMai
public bool SkipTrackStart { get; set; } 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 class TouchSensitivityConfig
{ {
public bool Enable { get; set; } public bool Enable { get; set; }

View File

@@ -147,7 +147,6 @@ namespace AquaMai
// Fixes that does not have side effects // Fixes that does not have side effects
// These don't need to be configurable // These don't need to be configurable
WindowState.Execute();
// Helpers // Helpers
Patch(typeof(MessageHelper)); Patch(typeof(MessageHelper));
Patch(typeof(MusicDirHelper)); Patch(typeof(MusicDirHelper));

View File

@@ -92,6 +92,7 @@ public class PractiseMode
SetSpeed(); SetSpeed();
} }
# if DEBUG
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(GenericProcess), "OnUpdate")] [HarmonyPatch(typeof(GenericProcess), "OnUpdate")]
public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors) public static void OnGenericProcessUpdate(GenericMonitor[] ____monitors)
@@ -101,6 +102,7 @@ public class PractiseMode
____monitors[0].gameObject.AddComponent<PractiseModeUI>(); ____monitors[0].gameObject.AddComponent<PractiseModeUI>();
} }
} }
# endif
[HarmonyPatch(typeof(GameProcess), "OnUpdate")] [HarmonyPatch(typeof(GameProcess), "OnUpdate")]
[HarmonyPostfix] [HarmonyPostfix]

View File

@@ -3,32 +3,32 @@ using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
namespace AquaMai.Utils; namespace AquaMai.WindowState;
public class WindowState public class Enable
{ {
private const int GWL_STYLE = -16; private const int GWL_STYLE = -16;
private const int WS_WHATEVER = 0x14CF0000; private const int WS_WHATEVER = 0x14CF0000;
private static IntPtr hwnd = IntPtr.Zero; 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; 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; Screen.fullScreenMode = FullScreenMode.Windowed;
} }
else else
{ {
alreadyWindowed = false; 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(); hwnd = GetWindowHandle();
if(alreadyWindowed) if (alreadyWindowed)
{ {
SetResizeable(); SetResizeable();
} }
@@ -44,8 +44,8 @@ public class WindowState
} }
else else
{ {
var width = AquaMai.AppConfig.Utils.Width == 0 ? Display.main.systemWidth : AquaMai.AppConfig.Utils.Width; var width = AquaMai.AppConfig.WindowState.Width == 0 ? Display.main.systemWidth : AquaMai.AppConfig.WindowState.Width;
var height = AquaMai.AppConfig.Utils.Height == 0 ? Display.main.systemHeight : AquaMai.AppConfig.Utils.Height; var height = AquaMai.AppConfig.WindowState.Height == 0 ? Display.main.systemHeight : AquaMai.AppConfig.WindowState.Height;
Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow); Screen.SetResolution(width, height, FullScreenMode.FullScreenWindow);
} }
} }