diff --git a/UXAssist/Common/WinApi.cs b/UXAssist/Common/WinApi.cs index 5ecb5ca..1b344e4 100644 --- a/UXAssist/Common/WinApi.cs +++ b/UXAssist/Common/WinApi.cs @@ -127,6 +127,9 @@ public static class WinApi [DllImport("user32", ExactSpelling = true)] public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint); + + [DllImport("user32", ExactSpelling = true)] + public static extern IntPtr MonitorFromRect([In] ref Rect lpRect, uint dwFlags); [DllImport("kernel32", ExactSpelling = true, SetLastError = true)] public static extern bool GetProcessAffinityMask(IntPtr hProcess, out ulong lpProcessAffinityMask, out ulong lpSystemAffinityMask); diff --git a/UXAssist/Patches/GamePatch.cs b/UXAssist/Patches/GamePatch.cs index 0453d63..202ff9c 100644 --- a/UXAssist/Patches/GamePatch.cs +++ b/UXAssist/Patches/GamePatch.cs @@ -171,7 +171,7 @@ public class GamePatch : PatchImpl var wnd = WindowFunctions.FindGameWindow(); if (wnd == IntPtr.Zero) return; WinApi.GetWindowRect(wnd, out var rect); - LastWindowRect.Value = new Vector4(rect.Left < 20 - Screen.width ? 0 : rect.Left, rect.Top < 20 - Screen.height ? 0 : rect.Top, Screen.width, Screen.height); + LastWindowRect.Value = new Vector4(rect.Left, rect.Top, Screen.width, Screen.height); } private class EnableWindowResize : PatchImpl @@ -245,32 +245,15 @@ public class GamePatch : PatchImpl needFix = true; } - var sw = Screen.currentResolution.width; - var sh = Screen.currentResolution.height; - if (x + w > sw) - { - x = sw - w; - needFix = true; - } - - if (y + h > sh) - { - y = sh - h; - needFix = true; - } - - if (x < 0) + var rc = new WinApi.Rect {Left = x, Top = y, Right = x + w, Bottom = y + h}; + if (WinApi.MonitorFromRect(ref rc, 0) == IntPtr.Zero) { x = 0; - needFix = true; - } - - if (y < 0) - { y = 0; + w = 1280; + h = 720; needFix = true; } - if (needFix) { LastWindowRect.Value = new Vector4(x, y, w, h);