From b83005118da29ee3e13d2d6a794a3c73968547ef Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 10 Aug 2021 16:45:40 +0200 Subject: [PATCH] add new .ini setting for hiding child windows --- inc/dd.h | 1 + src/config.c | 6 +++--- src/utils.c | 41 +++++++++++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/inc/dd.h b/inc/dd.h index 4d67447..8949cb5 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -25,6 +25,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute #define FIX_CHILDS_DISABLED 0 #define FIX_CHILDS_DETECT 1 #define FIX_CHILDS_DETECT_PAINT 2 +#define FIX_CHILDS_DETECT_HIDE 3 #define RESLIST_NORMAL 0 #define RESLIST_MINI 1 diff --git a/src/config.c b/src/config.c index fa96347..5efe93f 100644 --- a/src/config.c +++ b/src/config.c @@ -329,7 +329,7 @@ static void cfg_create_ini() "; Note: Set this to 2 if your chosen resolution is not working, set to 1 if the game is crashing\n" "resolutions=0\n" "\n" - "; Child window handling, possible values: 0 = Disabled, 1 = Display top left, 2 = Display top left + repaint\n" + "; Child window handling, possible values: 0 = Disabled, 1 = Display top left, 2 = Display top left + repaint, 3 = Hide\n" "; Note: Disables upscaling if a child window was detected\n" "fixchilds=2\n" "\n" @@ -417,8 +417,8 @@ static void cfg_create_ini() "\n" "; Blade & Sword\n" "[comeon]\n" - "renderer=opengl\n" - "nonexclusive=true\n" + "fixchilds=3\n" + "hook=3\n" "fixpitch=true\n" "\n" "; Blood II - The Chosen / Shogo - Mobile Armor Division\n" diff --git a/src/utils.c b/src/utils.c index d136f67..db2dd5d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,5 +1,6 @@ #include #include "ddraw.h" +#include "debug.h" #include "dd.h" #include "ddsurface.h" #include "hook.h" @@ -372,20 +373,44 @@ BOOL CALLBACK util_enum_child_proc(HWND hwnd, LPARAM lparam) if (real_GetClientRect(hwnd, &size) && real_GetWindowRect(hwnd, &pos) && size.right > 1 && size.bottom > 1) { - g_ddraw->got_child_windows = g_ddraw->child_window_exists = TRUE; + //TRACE(" util_enum_child_proc right=%u, bottom=%u\n", size.right, size.bottom); - if (g_ddraw->fixchilds == FIX_CHILDS_DETECT_PAINT) + if (g_ddraw->fixchilds == FIX_CHILDS_DETECT_HIDE) { - HDC dst_dc = GetDC(hwnd); - HDC src_dc; + LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); - dds_GetDC(this, &src_dc); + if (!(style & WS_EX_TRANSPARENT)) + { + real_SetWindowLongA(hwnd, GWL_EXSTYLE, style | WS_EX_TRANSPARENT); - real_MapWindowPoints(HWND_DESKTOP, g_ddraw->hwnd, (LPPOINT)&pos, 2); + real_SetWindowPos( + hwnd, + 0, + 0, + 0, + 0, + 0, + SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER + ); + } + } + else + { + g_ddraw->got_child_windows = g_ddraw->child_window_exists = TRUE; - BitBlt(dst_dc, 0, 0, size.right, size.bottom, src_dc, pos.left, pos.top, SRCCOPY); + if (g_ddraw->fixchilds == FIX_CHILDS_DETECT_PAINT) + { + HDC dst_dc = GetDC(hwnd); + HDC src_dc; - ReleaseDC(hwnd, dst_dc); + dds_GetDC(this, &src_dc); + + real_MapWindowPoints(HWND_DESKTOP, g_ddraw->hwnd, (LPPOINT)&pos, 2); + + BitBlt(dst_dc, 0, 0, size.right, size.bottom, src_dc, pos.left, pos.top, SRCCOPY); + + ReleaseDC(hwnd, dst_dc); + } } }