mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 00:53:39 +08:00
try to remember window position across multiple display monitors
This commit is contained in:
@@ -128,6 +128,9 @@ public static class WinApi
|
|||||||
[DllImport("user32", ExactSpelling = true)]
|
[DllImport("user32", ExactSpelling = true)]
|
||||||
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint);
|
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)]
|
[DllImport("kernel32", ExactSpelling = true, SetLastError = true)]
|
||||||
public static extern bool GetProcessAffinityMask(IntPtr hProcess, out ulong lpProcessAffinityMask, out ulong lpSystemAffinityMask);
|
public static extern bool GetProcessAffinityMask(IntPtr hProcess, out ulong lpProcessAffinityMask, out ulong lpSystemAffinityMask);
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
var wnd = WindowFunctions.FindGameWindow();
|
var wnd = WindowFunctions.FindGameWindow();
|
||||||
if (wnd == IntPtr.Zero) return;
|
if (wnd == IntPtr.Zero) return;
|
||||||
WinApi.GetWindowRect(wnd, out var rect);
|
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<EnableWindowResize>
|
private class EnableWindowResize : PatchImpl<EnableWindowResize>
|
||||||
@@ -245,32 +245,15 @@ public class GamePatch : PatchImpl<GamePatch>
|
|||||||
needFix = true;
|
needFix = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sw = Screen.currentResolution.width;
|
var rc = new WinApi.Rect {Left = x, Top = y, Right = x + w, Bottom = y + h};
|
||||||
var sh = Screen.currentResolution.height;
|
if (WinApi.MonitorFromRect(ref rc, 0) == IntPtr.Zero)
|
||||||
if (x + w > sw)
|
|
||||||
{
|
|
||||||
x = sw - w;
|
|
||||||
needFix = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y + h > sh)
|
|
||||||
{
|
|
||||||
y = sh - h;
|
|
||||||
needFix = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (x < 0)
|
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
needFix = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (y < 0)
|
|
||||||
{
|
|
||||||
y = 0;
|
y = 0;
|
||||||
|
w = 1280;
|
||||||
|
h = 720;
|
||||||
needFix = true;
|
needFix = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needFix)
|
if (needFix)
|
||||||
{
|
{
|
||||||
LastWindowRect.Value = new Vector4(x, y, w, h);
|
LastWindowRect.Value = new Vector4(x, y, w, h);
|
||||||
|
|||||||
Reference in New Issue
Block a user