Skip to content

Commit

Permalink
[+] able to switch off WindowState
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Oct 1, 2024
1 parent 07817b0 commit 9ead7a4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion AquaMai/AquaMai.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ DEBUG</DefineConstants>
<Compile Include="Utils\PractiseModeUI.cs" />
<Compile Include="Utils\SelectionDetail.cs" />
<Compile Include="Utils\ShowNetErrorDetail.cs" />
<Compile Include="Utils\WindowState.cs" />
<Compile Include="UX\CustomPlaceName.cs" />
<Compile Include="UX\CustomVersionString.cs" />
<Compile Include="UX\DemoMaster.cs" />
Expand All @@ -343,6 +342,7 @@ DEBUG</DefineConstants>
<Compile Include="UX\RunCommandOnEvents.cs" />
<Compile Include="UX\SinglePlayer.cs" />
<Compile Include="UX\TestProof.cs" />
<Compile Include="WindowState\Enable.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
12 changes: 9 additions & 3 deletions AquaMai/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Config
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
Expand Down Expand Up @@ -57,9 +58,6 @@ public class UtilsConfig
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; }
Expand All @@ -76,6 +74,14 @@ public class TimeSavingConfig
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; }
Expand Down
1 change: 0 additions & 1 deletion AquaMai/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public override void OnInitializeMelon()
// Fixes that does not have side effects
// These don't need to be configurable

WindowState.Execute();
// Helpers
Patch(typeof(MessageHelper));
Patch(typeof(MusicDirHelper));
Expand Down
2 changes: 2 additions & 0 deletions AquaMai/Utils/PractiseMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static void GameProcessPostStart()
SetSpeed();
}

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

[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
[HarmonyPostfix]
Expand Down
20 changes: 10 additions & 10 deletions AquaMai/Utils/WindowState.cs → AquaMai/WindowState/Enable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
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();
}
Expand All @@ -44,8 +44,8 @@ public static void Execute()
}
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);
}
}
Expand Down

0 comments on commit 9ead7a4

Please sign in to comment.