From 4a0d74001a2ae96c920d63249b1613b3a0b3f410 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 5 Nov 2021 21:04:12 +0100 Subject: [PATCH] center war2 high res patch windows --- src/utils.c | 6 +++--- src/winapi_hooks.c | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/utils.c b/src/utils.c index a85f6b7..db2dd5d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -71,7 +71,7 @@ void util_update_bnet_pos(int new_x, int new_y) real_ClientToScreen(g_ddraw->hwnd, &pt); RECT mainrc; - SetRect(&mainrc, pt.x, pt.y, pt.x + 640, pt.y + 480); + SetRect(&mainrc, pt.x, pt.y, pt.x + g_ddraw->width, pt.y + g_ddraw->height); int adj_y = 0; int adj_x = 0; @@ -94,7 +94,7 @@ void util_update_bnet_pos(int new_x, int new_y) 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - if (rc.bottom - rc.top <= 480) + if (rc.bottom - rc.top <= g_ddraw->height) { if (rc.bottom > mainrc.bottom && abs(mainrc.bottom - rc.bottom) > abs(adj_y)) { @@ -106,7 +106,7 @@ void util_update_bnet_pos(int new_x, int new_y) } } - if (rc.right - rc.left <= 640) + if (rc.right - rc.left <= g_ddraw->width) { if (rc.right > mainrc.right && abs(mainrc.right - rc.right) > abs(adj_x)) { diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 8caa3ba..55fd09a 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -679,8 +679,13 @@ HWND WINAPI fake_CreateWindowExA( POINT pt = { 0, 0 }; real_ClientToScreen(g_ddraw->hwnd, &pt); - X += pt.x; - Y += pt.y; + int added_height = g_ddraw->height - 480; + int added_width = g_ddraw->width - 640; + int align_y = added_height > 0 ? added_height / 2 : 0; + int align_x = added_width > 0 ? added_width / 2 : 0; + + X += pt.x + align_x; + Y += pt.y + align_y; dwStyle |= WS_CLIPCHILDREN; }