From 434fb4de9969672499007bb82a76f09c3abd7d54 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 14 Nov 2023 17:16:23 +0100 Subject: [PATCH] add support for alt+enter in fullscreen upscaled mode --- inc/config.h | 3 ++- inc/version.h | 2 +- src/config.c | 10 +++++++--- src/utils.c | 15 +++++++++++++-- src/wndproc.c | 4 ++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/inc/config.h b/inc/config.h index 2b2435e..34c8c66 100644 --- a/inc/config.h +++ b/inc/config.h @@ -10,7 +10,7 @@ typedef struct CNCDDRAWCONFIG { RECT window_rect; int window_state; - int borderless_state; + int upscaled_state; char ini_path[MAX_PATH]; char game_path[MAX_PATH]; char process_file_name[MAX_PATH]; @@ -37,6 +37,7 @@ typedef struct CNCDDRAWCONFIG BOOL vhack; char screenshot_dir[MAX_PATH]; BOOL toggle_borderless; + BOOL toggle_upscaled; /* Compatibility settings */ diff --git a/inc/version.h b/inc/version.h index 0c15ac6..70d7cff 100644 --- a/inc/version.h +++ b/inc/version.h @@ -7,7 +7,7 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 #define VERSION_BUILD 0 -#define VERSION_REVISION 2 +#define VERSION_REVISION 3 #define VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION #define VERSION_STRING ver_str(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD, VERSION_REVISION) diff --git a/src/config.c b/src/config.c index 1f36d97..5cf7718 100644 --- a/src/config.c +++ b/src/config.c @@ -23,7 +23,7 @@ static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, #define GET_STRING(a,b,c,d) cfg_get_string(a, b, c, d); TRACE("%s=%s\n", a, c) CNCDDRAWCONFIG g_config = - { .window_rect = {.left = -32000, .top = -32000, .right = 0, .bottom = 0 }, .window_state = -1, .borderless_state = -1 }; + { .window_rect = {.left = -32000, .top = -32000, .right = 0, .bottom = 0 }, .window_state = -1, .upscaled_state = -1 }; void cfg_load() { @@ -52,6 +52,7 @@ void cfg_load() GET_BOOL(g_config.vhack, "vhack", FALSE); GET_STRING("screenshotdir", ".\\Screenshots\\", g_config.screenshot_dir, sizeof(g_config.screenshot_dir)); GET_BOOL(g_config.toggle_borderless, "toggle_borderless", FALSE); + GET_BOOL(g_config.toggle_upscaled, "toggle_upscaled", FALSE); /* Compatibility settings */ @@ -148,9 +149,9 @@ void cfg_save() WritePrivateProfileString(section, "windowed", g_config.window_state ? "true" : "false", g_config.ini_path); } - if (g_config.borderless_state != -1) + if (g_config.upscaled_state != -1) { - WritePrivateProfileString(section, "fullscreen", g_config.borderless_state ? "true" : "false", g_config.ini_path); + WritePrivateProfileString(section, "fullscreen", g_config.upscaled_state ? "true" : "false", g_config.ini_path); } } @@ -235,6 +236,9 @@ static void cfg_create_ini() "; Switch between windowed/borderless modes with alt+enter rather than windowed/fullscreen modes\n" "toggle_borderless=false\n" "\n" + "; Switch between windowed/fullscreen upscaled modes with alt+enter rather than windowed/fullscreen modes\n" + "toggle_upscaled=false\n" + "\n" "\n" "\n" "; ### Compatibility settings ###\n" diff --git a/src/utils.c b/src/utils.c index 8e62c26..763f271 100644 --- a/src/utils.c +++ b/src/utils.c @@ -421,7 +421,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.borderless_state = g_config.fullscreen = TRUE; + g_config.upscaled_state = g_config.fullscreen = TRUE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); mouse_lock(); @@ -430,7 +430,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.borderless_state = g_config.fullscreen = FALSE; + g_config.upscaled_state = g_config.fullscreen = FALSE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); //mouse_lock(); @@ -442,6 +442,11 @@ void util_toggle_fullscreen() { mouse_unlock(); + if (g_config.toggle_upscaled) + { + g_config.upscaled_state = g_config.fullscreen = TRUE; + } + g_config.window_state = g_config.windowed = FALSE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_WINDOWED); util_update_bnet_pos(0, 0); @@ -451,6 +456,12 @@ void util_toggle_fullscreen() else { mouse_unlock(); + + if (g_config.toggle_upscaled) + { + g_config.upscaled_state = g_config.fullscreen = FALSE; + } + g_config.window_state = g_config.windowed = TRUE; if (g_ddraw->renderer == d3d9_render_main && !g_config.nonexclusive) diff --git a/src/wndproc.c b/src/wndproc.c index 445d271..70c70d6 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -691,7 +691,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam } case WM_TOGGLE_FULLSCREEN: { - if (!g_config.fullscreen || (g_config.windowed && g_config.toggle_borderless)) + if (!g_config.fullscreen || g_config.toggle_upscaled || (g_config.windowed && g_config.toggle_borderless)) { /* Check if we are fullscreen/borderless already */ if (wParam == CNC_DDRAW_SET_FULLSCREEN && (!g_config.windowed || g_config.fullscreen)) @@ -731,7 +731,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam if (g_config.hotkeys.toggle_fullscreen && wParam == g_config.hotkeys.toggle_fullscreen && - (!g_config.fullscreen || (g_config.windowed && g_config.toggle_borderless)) && + (!g_config.fullscreen || g_config.toggle_upscaled || (g_config.windowed && g_config.toggle_borderless)) && context_code && !key_state) {