From 483a64c7e31fb7525069aacd61c41844f4bdecaa Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 6 Nov 2021 17:11:23 +0100 Subject: [PATCH 01/47] change default settings and rename ddraw.ini for high res pach tests --- src/config.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 2112bcc..c2cf65b 100644 --- a/src/config.c +++ b/src/config.c @@ -10,6 +10,8 @@ #include "hook.h" #include "debug.h" +#define FILE_EXISTS(a) (GetFileAttributes(a) != INVALID_FILE_ATTRIBUTES) + static void cfg_init(); static void cfg_create_ini(); @@ -27,7 +29,11 @@ void cfg_load() g_ddraw->border = cfg_get_bool("border", TRUE); g_ddraw->boxing = cfg_get_bool("boxing", FALSE); g_ddraw->maintas = cfg_get_bool("maintas", FALSE); - g_ddraw->adjmouse = cfg_get_bool("adjmouse", TRUE) || !cfg_get_bool("handlemouse", TRUE); + g_ddraw->adjmouse = + cfg_get_bool("adjmouse", TRUE) || + !cfg_get_bool("handlemouse", TRUE) || + FILE_EXISTS(".\\plugin\\HardwareCursor.w2p"); + g_ddraw->devmode = cfg_get_bool("devmode", FALSE); g_ddraw->vsync = cfg_get_bool("vsync", FALSE); g_ddraw->noactivateapp = cfg_get_bool("noactivateapp", FALSE); @@ -240,7 +246,7 @@ static void cfg_create_ini() "windowed=false\n" "\n" "; Maintain aspect ratio\n" - "maintas=false\n" + "maintas=true\n" "\n" "; Windowboxing / Integer Scaling\n" "boxing=false\n" @@ -255,7 +261,7 @@ static void cfg_create_ini() "\n" "; Automatic mouse sensitivity scaling\n" "; Note: Only works if stretching is enabled. Sensitivity will be adjusted according to the size of the window\n" - "adjmouse=true\n" + "adjmouse=false\n" "\n" "; Preliminary libretro shader support - (Requires 'renderer=opengl') https://github.com/libretro/glsl-shaders\n" "; 2x scaling example: https://imgur.com/a/kxsM1oY - 4x scaling example: https://imgur.com/a/wjrhpFV\n" @@ -983,7 +989,7 @@ static void cfg_init() } /* set up settings ini */ - strncpy(g_config.ini_path, ".\\ddraw.ini", sizeof(g_config.ini_path) - 1); + strncpy(g_config.ini_path, ".\\dd-hd.ini", sizeof(g_config.ini_path) - 1); if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES) cfg_create_ini(); From 2e23e4309c0508a056a77f7cfa6d80a444e4a021 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 6 Nov 2021 17:12:02 +0100 Subject: [PATCH 02/47] run lobby in fullscreen with opengl/gdi renderer --- inc/dd.h | 1 + src/config.c | 24 ++---------------------- src/winapi_hooks.c | 25 ++++++++++++++----------- src/wndproc.c | 8 ++------ 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/inc/dd.h b/inc/dd.h index 4afc477..5fc29c0 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -155,6 +155,7 @@ typedef struct CNCDDRAW BOOL bnet_was_fullscreen; BOOL bnet_was_upscaled; RECT bnet_win_rect; + DEVMODE bnet_mode; POINT bnet_pos; void* last_freed_palette; /* Dungeon Keeper hack */ BOOL child_window_exists; diff --git a/src/config.c b/src/config.c index c2cf65b..3d8946d 100644 --- a/src/config.c +++ b/src/config.c @@ -40,7 +40,7 @@ void cfg_load() g_ddraw->vhack = cfg_get_bool("vhack", FALSE); g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE); g_ddraw->resizable = cfg_get_bool("resizable", TRUE); - g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); + g_ddraw->nonexclusive = TRUE;// cfg_get_bool("nonexclusive", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT); g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE); @@ -149,11 +149,7 @@ void cfg_load() { g_ddraw->renderer = gdi_render_main; } - else if (tolower(tmp[0]) == 'd') /* direct3d9 */ - { - g_ddraw->renderer = d3d9_render_main; - } - else if (tolower(tmp[0]) == 'o') /* opengl */ + else /* opengl */ { if (oglu_load_dll()) { @@ -165,22 +161,6 @@ void cfg_load() g_ddraw->renderer = gdi_render_main; } } - else /* auto */ - { - if (!g_ddraw->wine && d3d9_is_available()) - { - g_ddraw->renderer = d3d9_render_main; - } - else if (oglu_load_dll()) - { - g_ddraw->renderer = ogl_render_main; - } - else - { - g_ddraw->show_driver_warning = TRUE; - g_ddraw->renderer = gdi_render_main; - } - } } void cfg_save() diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 55fd09a..b26365b 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -617,13 +617,13 @@ BOOL WINAPI fake_DestroyWindow(HWND hWnd) dst_height, flags); } - - g_ddraw->fullscreen = g_ddraw->bnet_was_upscaled; - - SetTimer(g_ddraw->hwnd, IDT_TIMER_LEAVE_BNET, 1000, (TIMERPROC)NULL); - - g_ddraw->resizable = TRUE; } + + g_ddraw->fullscreen = g_ddraw->bnet_was_upscaled; + + SetTimer(g_ddraw->hwnd, IDT_TIMER_LEAVE_BNET, 1000, (TIMERPROC)NULL); + + g_ddraw->resizable = TRUE; } } @@ -649,9 +649,12 @@ HWND WINAPI fake_CreateWindowExA( if (!g_ddraw->windowed && !g_ddraw->bnet_was_fullscreen) { - int ws = g_config.window_state; - util_toggle_fullscreen(); - g_config.window_state = ws; + memcpy(&g_ddraw->bnet_mode, &g_ddraw->render.mode, sizeof(DEVMODE)); + + g_ddraw->render.mode.dmPelsWidth = 640; + g_ddraw->render.mode.dmPelsHeight = 480; + ChangeDisplaySettings(&g_ddraw->render.mode, CDS_FULLSCREEN); + g_ddraw->bnet_was_fullscreen = TRUE; } @@ -684,8 +687,8 @@ HWND WINAPI fake_CreateWindowExA( 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; + X += pt.x;// +align_x; + Y += pt.y;// +align_y; dwStyle |= WS_CLIPCHILDREN; } diff --git a/src/wndproc.c b/src/wndproc.c index 230d050..e001662 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -145,16 +145,12 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam { KillTimer(g_ddraw->hwnd, IDT_TIMER_LEAVE_BNET); - if (!g_ddraw->windowed) - g_ddraw->bnet_was_fullscreen = FALSE; - if (!g_ddraw->bnet_active) { if (g_ddraw->bnet_was_fullscreen) { - int ws = g_config.window_state; - util_toggle_fullscreen(); - g_config.window_state = ws; + memcpy(&g_ddraw->render.mode, &g_ddraw->bnet_mode, sizeof(DEVMODE)); + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); g_ddraw->bnet_was_fullscreen = FALSE; } else if (g_ddraw->bnet_was_upscaled) From f7d5d6a46e3a6563d5e95bdd58ce4e04d0f92629 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 6 Nov 2021 18:51:07 +0100 Subject: [PATCH 03/47] don't change display settings for original war2 --- src/winapi_hooks.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index b26365b..3f96827 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -649,13 +649,17 @@ HWND WINAPI fake_CreateWindowExA( if (!g_ddraw->windowed && !g_ddraw->bnet_was_fullscreen) { - memcpy(&g_ddraw->bnet_mode, &g_ddraw->render.mode, sizeof(DEVMODE)); + if (g_ddraw->render.mode.dmPelsWidth != 640 || + g_ddraw->render.mode.dmPelsHeight != 480) + { + memcpy(&g_ddraw->bnet_mode, &g_ddraw->render.mode, sizeof(DEVMODE)); - g_ddraw->render.mode.dmPelsWidth = 640; - g_ddraw->render.mode.dmPelsHeight = 480; - ChangeDisplaySettings(&g_ddraw->render.mode, CDS_FULLSCREEN); - - g_ddraw->bnet_was_fullscreen = TRUE; + g_ddraw->render.mode.dmPelsWidth = 640; + g_ddraw->render.mode.dmPelsHeight = 480; + ChangeDisplaySettings(&g_ddraw->render.mode, CDS_FULLSCREEN); + + g_ddraw->bnet_was_fullscreen = TRUE; + } } real_GetClientRect(g_ddraw->hwnd, &g_ddraw->bnet_win_rect); From b4cb502f6a112426c943d71e390333881e015133 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 6 Nov 2021 20:12:15 +0100 Subject: [PATCH 04/47] don't enable nonexclusive --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 3d8946d..67f2a9e 100644 --- a/src/config.c +++ b/src/config.c @@ -40,7 +40,7 @@ void cfg_load() g_ddraw->vhack = cfg_get_bool("vhack", FALSE); g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE); g_ddraw->resizable = cfg_get_bool("resizable", TRUE); - g_ddraw->nonexclusive = TRUE;// cfg_get_bool("nonexclusive", FALSE); + g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT); g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE); From 6a241ca0aefe02959c1dfdd083746bfda6039952 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 7 Nov 2021 22:42:55 +0100 Subject: [PATCH 05/47] add OBS game capture support for bnet lobby --- inc/IDirectDrawSurface.h | 4 ++ inc/ddsurface.h | 2 +- inc/wndproc.h | 1 + src/IDirectDraw/IDirectDrawSurface.c | 12 +++++ src/ddsurface.c | 78 ++++++++++++++++++++++++++-- src/render_d3d9.c | 26 ++++++++-- src/render_gdi.c | 16 +++++- src/render_ogl.c | 25 +++++++-- src/winapi_hooks.c | 2 + src/wndproc.c | 8 +++ 10 files changed, 160 insertions(+), 14 deletions(-) diff --git a/inc/IDirectDrawSurface.h b/inc/IDirectDrawSurface.h index 97aa39f..1cb624d 100644 --- a/inc/IDirectDrawSurface.h +++ b/inc/IDirectDrawSurface.h @@ -30,6 +30,10 @@ typedef struct IDirectDrawSurfaceImpl DWORD l_pitch; DWORD lx_pitch; + void* bnet_surface; + HDC bnet_dc; + HBITMAP bnet_bitmap; + PBITMAPINFO bmi; HBITMAP bitmap; HDC hdc; diff --git a/inc/ddsurface.h b/inc/ddsurface.h index f641118..b069885 100644 --- a/inc/ddsurface.h +++ b/inc/ddsurface.h @@ -33,6 +33,6 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect); HRESULT dds_GetDDInterface(IDirectDrawSurfaceImpl* This, LPVOID* lplpDD); void* dds_GetBuffer(IDirectDrawSurfaceImpl* This); HRESULT dd_CreateSurface(IDirectDrawImpl* This, LPDDSURFACEDESC lpDDSurfaceDesc, IDirectDrawSurfaceImpl** lpDDSurface, IUnknown FAR* unkOuter); - +void dds_RedrawBnet(IDirectDrawSurfaceImpl* This); #endif diff --git a/inc/wndproc.h b/inc/wndproc.h index 6d2a199..d74dff7 100644 --- a/inc/wndproc.h +++ b/inc/wndproc.h @@ -9,6 +9,7 @@ #define WM_DISPLAYCHANGE_DDRAW WM_APP+116 #define IDT_TIMER_LEAVE_BNET 541287654 +#define IDT_TIMER_REDRAW_BNET 541287655 LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/src/IDirectDraw/IDirectDrawSurface.c b/src/IDirectDraw/IDirectDrawSurface.c index de4b209..b86f2c4 100644 --- a/src/IDirectDraw/IDirectDrawSurface.c +++ b/src/IDirectDraw/IDirectDrawSurface.c @@ -90,9 +90,21 @@ ULONG __stdcall IDirectDrawSurface__Release(IDirectDrawSurfaceImpl* This) HeapFree(GetProcessHeap(), 0, This->surface); } + if (This->bnet_bitmap) + { + DeleteObject(This->bnet_bitmap); + } + else if (This->bnet_surface) + { + HeapFree(GetProcessHeap(), 0, This->bnet_surface); + } + if (This->hdc) DeleteDC(This->hdc); + if (This->bnet_dc) + DeleteDC(This->bnet_dc); + if (This->bmi) HeapFree(GetProcessHeap(), 0, This->bmi); diff --git a/src/ddsurface.c b/src/ddsurface.c index 8a8ceef..bb75231 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -1190,28 +1190,39 @@ HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpD return DD_OK; } -HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) +void dds_RedrawBnet(IDirectDrawSurfaceImpl* This) { /* Hack for Warcraft II BNE and Diablo */ HWND hwnd = g_ddraw->bnet_active ? FindWindowEx(HWND_DESKTOP, NULL, "SDlgDialog", NULL) : NULL; - if (hwnd && (This->caps & DDSCAPS_PRIMARYSURFACE)) + if (hwnd) { HDC primary_dc; dds_GetDC(This, &primary_dc); + if (g_ddraw->primary->palette) + { + SetDIBColorTable(g_ddraw->primary->bnet_dc, 0, 256, g_ddraw->primary->palette->data_rgb); + } + /* GdiTransparentBlt idea taken from Aqrit's war2 ddraw */ RGBQUAD quad; GetDIBColorTable(primary_dc, 0xFE, 1, &quad); COLORREF color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue); BOOL erase = FALSE; + HWND hwnd_bnet[20]; + int i = 0; + + memset(&hwnd_bnet[0], 0, sizeof(hwnd_bnet)); do { RECT rc; if (fake_GetWindowRect(hwnd, &rc)) { + hwnd_bnet[i++] = hwnd; + if (rc.bottom - rc.top == 479) erase = TRUE; @@ -1236,6 +1247,36 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) } while ((hwnd = FindWindowEx(HWND_DESKTOP, hwnd, "SDlgDialog", NULL))); + /* hack for windows 8/10 fullscreen exclusive mode */ + EnterCriticalSection(&g_ddraw->cs); + + for (i = sizeof(hwnd_bnet) / sizeof(hwnd_bnet[0]); i--; ) + { + if (hwnd_bnet[i]) + { + RECT rc; + if (fake_GetWindowRect(hwnd_bnet[i], &rc)) + { + HDC dc = GetDC(hwnd_bnet[i]); + + BitBlt( + g_ddraw->primary->bnet_dc, + rc.left, + rc.top, + rc.right - rc.left, + rc.bottom - rc.top, + dc, + 0, + 0, + SRCCOPY); + + ReleaseDC(hwnd_bnet[i], dc); + } + } + } + + LeaveCriticalSection(&g_ddraw->cs); + if (erase) { BOOL x = g_ddraw->ticks_limiter.use_blt_or_flip; @@ -1245,10 +1286,21 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) g_ddraw->ticks_limiter.use_blt_or_flip = x; } + + if (g_ddraw->render.run) + ReleaseSemaphore(g_ddraw->render.sem, 1, NULL); + } +} + +HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) +{ + if ((This->caps & DDSCAPS_PRIMARYSURFACE)) + { + dds_RedrawBnet(This); } /* Hack for Star Trek Armada */ - hwnd = g_ddraw->armadahack ? FindWindowEx(HWND_DESKTOP, NULL, "#32770", NULL) : NULL; + HWND hwnd = g_ddraw->armadahack ? FindWindowEx(HWND_DESKTOP, NULL, "#32770", NULL) : NULL; if (hwnd && (This->caps & DDSCAPS_PRIMARYSURFACE)) { @@ -1471,6 +1523,26 @@ HRESULT dd_CreateSurface( { g_ddraw->primary = dst_surface; FakePrimarySurface = dst_surface->surface; + + dst_surface->bnet_dc = CreateCompatibleDC(g_ddraw->render.hdc); + + dst_surface->bnet_bitmap = + CreateDIBSection( + dst_surface->bnet_dc, + dst_surface->bmi, + DIB_RGB_COLORS, + (void**)&dst_surface->bnet_surface, NULL, 0); + + if (!dst_surface->bnet_bitmap) + { + dst_surface->bnet_surface = + HeapAlloc( + GetProcessHeap(), + HEAP_ZERO_MEMORY, + dst_surface->l_pitch * (dst_surface->height + 200) * dst_surface->lx_pitch); + } + + SelectObject(dst_surface->bnet_dc, dst_surface->bnet_bitmap); } SelectObject(dst_surface->hdc, dst_surface->bitmap); diff --git a/src/render_d3d9.c b/src/render_d3d9.c index f640fb0..c6e3b95 100644 --- a/src/render_d3d9.c +++ b/src/render_d3d9.c @@ -442,6 +442,27 @@ DWORD WINAPI d3d9_render_main(void) } } } + + if (g_ddraw->bnet_active) + { + RECT rc = { 0,0,g_ddraw->width,g_ddraw->height }; + + if (SUCCEEDED(IDirect3DTexture9_LockRect(g_d3d9.surface_tex[tex_index], 0, &lock_rc, &rc, 0))) + { + unsigned char* src = (unsigned char*)g_ddraw->primary->bnet_surface; + unsigned char* dst = (unsigned char*)lock_rc.pBits; + + for (int i = 0; i < g_ddraw->height; i++) + { + memcpy(dst, src, g_ddraw->primary->l_pitch); + + src += g_ddraw->primary->l_pitch; + dst += lock_rc.Pitch; + } + + IDirect3DTexture9_UnlockRect(g_d3d9.surface_tex[tex_index], 0); + } + } } LeaveCriticalSection(&g_ddraw->cs); @@ -456,11 +477,6 @@ DWORD WINAPI d3d9_render_main(void) IDirect3DDevice9_DrawPrimitive(g_d3d9.device, D3DPT_TRIANGLESTRIP, 0, 2); IDirect3DDevice9_EndScene(g_d3d9.device); - if (g_ddraw->bnet_active) - { - IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); - } - if (FAILED(IDirect3DDevice9_Present(g_d3d9.device, NULL, NULL, NULL, NULL))) { DWORD_PTR result; diff --git a/src/render_gdi.c b/src/render_gdi.c index 74528f3..e2e8ef0 100644 --- a/src/render_gdi.c +++ b/src/render_gdi.c @@ -97,8 +97,20 @@ DWORD WINAPI gdi_render_main(void) if (g_ddraw->bnet_active) { - RECT rc = { 0, 0, g_ddraw->render.width, g_ddraw->render.height }; - FillRect(g_ddraw->render.hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + StretchDIBits( + g_ddraw->render.hdc, + g_ddraw->render.viewport.x, + g_ddraw->render.viewport.y, + g_ddraw->render.viewport.width, + g_ddraw->render.viewport.height, + 0, + 0, + g_ddraw->width, + g_ddraw->height, + g_ddraw->primary->bnet_surface, + g_ddraw->primary->bmi, + DIB_RGB_COLORS, + SRCCOPY); } else if (upscale_hack) { diff --git a/src/render_ogl.c b/src/render_ogl.c index 87c6b1e..1c5336c 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -701,6 +701,28 @@ static void ogl_render() } } } + + if (g_ddraw->bnet_active) + { + glBindTexture(GL_TEXTURE_2D, g_ogl.surface_tex_ids[tex_index]); + + if (g_ogl.adjust_alignment) + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + g_ddraw->width, + g_ddraw->height, + g_ogl.surface_format, + g_ogl.surface_type, + g_ddraw->primary->bnet_surface); + + if (g_ogl.adjust_alignment) + glPixelStorei(GL_UNPACK_ALIGNMENT, 4); + } } LeaveCriticalSection(&g_ddraw->cs); @@ -823,9 +845,6 @@ static void ogl_render() glEnd(); } - if (g_ddraw->bnet_active) - glClear(GL_COLOR_BUFFER_BIT); - SwapBuffers(g_ddraw->render.hdc); #if _DEBUG diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 3f96827..8f3c9c0 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -591,6 +591,7 @@ BOOL WINAPI fake_DestroyWindow(HWND hWnd) if (!FindWindowEx(HWND_DESKTOP, NULL, "SDlgDialog", NULL)) { + KillTimer(g_ddraw->hwnd, IDT_TIMER_REDRAW_BNET); g_ddraw->bnet_active = FALSE; SetFocus(g_ddraw->hwnd); mouse_lock(); @@ -680,6 +681,7 @@ HWND WINAPI fake_CreateWindowExA( g_ddraw->resizable = FALSE; g_ddraw->bnet_active = TRUE; + SetTimer(g_ddraw->hwnd, IDT_TIMER_REDRAW_BNET, 200, (TIMERPROC)NULL); mouse_unlock(); } diff --git a/src/wndproc.c b/src/wndproc.c index e001662..d69cbb5 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -4,6 +4,7 @@ #include "dllmain.h" #include "dd.h" #include "hook.h" +#include "ddsurface.h" #include "mouse.h" #include "render_d3d9.h" #include "config.h" @@ -162,6 +163,13 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam return 0; } + case IDT_TIMER_REDRAW_BNET: + { + if (g_ddraw->primary) + dds_RedrawBnet(g_ddraw->primary); + + return 0; + } } break; } From 8c6b2814a90cbbc5ff9840a4408c70e902e1c1f3 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 7 Nov 2021 23:22:46 +0100 Subject: [PATCH 06/47] redraw only top window for better performance --- inc/ddsurface.h | 3 +- src/ddsurface.c | 101 +++++++++++++++++++++++------------------------- src/wndproc.c | 2 +- 3 files changed, 52 insertions(+), 54 deletions(-) diff --git a/inc/ddsurface.h b/inc/ddsurface.h index b069885..eae85f7 100644 --- a/inc/ddsurface.h +++ b/inc/ddsurface.h @@ -33,6 +33,7 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect); HRESULT dds_GetDDInterface(IDirectDrawSurfaceImpl* This, LPVOID* lplpDD); void* dds_GetBuffer(IDirectDrawSurfaceImpl* This); HRESULT dd_CreateSurface(IDirectDrawImpl* This, LPDDSURFACEDESC lpDDSurfaceDesc, IDirectDrawSurfaceImpl** lpDDSurface, IUnknown FAR* unkOuter); -void dds_RedrawBnet(IDirectDrawSurfaceImpl* This); +void dds_RedrawBnet(IDirectDrawSurfaceImpl* This, BOOL obs_hack); +void dds_RedrawArmada(IDirectDrawSurfaceImpl* This); #endif diff --git a/src/ddsurface.c b/src/ddsurface.c index bb75231..3237122 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -1190,39 +1190,66 @@ HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpD return DD_OK; } -void dds_RedrawBnet(IDirectDrawSurfaceImpl* This) +void dds_RedrawBnet(IDirectDrawSurfaceImpl* This, BOOL obs_hack) { /* Hack for Warcraft II BNE and Diablo */ HWND hwnd = g_ddraw->bnet_active ? FindWindowEx(HWND_DESKTOP, NULL, "SDlgDialog", NULL) : NULL; if (hwnd) { + if (obs_hack) + { + /* hack for windows 8/10 fullscreen exclusive mode */ + + if (g_ddraw->primary->palette) + { + SetDIBColorTable(g_ddraw->primary->bnet_dc, 0, 256, g_ddraw->primary->palette->data_rgb); + } + + EnterCriticalSection(&g_ddraw->cs); + + RECT rc; + if (fake_GetWindowRect(hwnd, &rc)) + { + HDC dc = GetDC(hwnd); + + BitBlt( + g_ddraw->primary->bnet_dc, + rc.left, + rc.top, + rc.right - rc.left, + rc.bottom - rc.top, + dc, + 0, + 0, + SRCCOPY); + + ReleaseDC(hwnd, dc); + } + + LeaveCriticalSection(&g_ddraw->cs); + + if (g_ddraw->render.run) + ReleaseSemaphore(g_ddraw->render.sem, 1, NULL); + + return; + } + HDC primary_dc; dds_GetDC(This, &primary_dc); - if (g_ddraw->primary->palette) - { - SetDIBColorTable(g_ddraw->primary->bnet_dc, 0, 256, g_ddraw->primary->palette->data_rgb); - } - /* GdiTransparentBlt idea taken from Aqrit's war2 ddraw */ RGBQUAD quad; GetDIBColorTable(primary_dc, 0xFE, 1, &quad); COLORREF color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue); BOOL erase = FALSE; - HWND hwnd_bnet[20]; - int i = 0; - - memset(&hwnd_bnet[0], 0, sizeof(hwnd_bnet)); do { RECT rc; if (fake_GetWindowRect(hwnd, &rc)) { - hwnd_bnet[i++] = hwnd; - if (rc.bottom - rc.top == 479) erase = TRUE; @@ -1247,36 +1274,6 @@ void dds_RedrawBnet(IDirectDrawSurfaceImpl* This) } while ((hwnd = FindWindowEx(HWND_DESKTOP, hwnd, "SDlgDialog", NULL))); - /* hack for windows 8/10 fullscreen exclusive mode */ - EnterCriticalSection(&g_ddraw->cs); - - for (i = sizeof(hwnd_bnet) / sizeof(hwnd_bnet[0]); i--; ) - { - if (hwnd_bnet[i]) - { - RECT rc; - if (fake_GetWindowRect(hwnd_bnet[i], &rc)) - { - HDC dc = GetDC(hwnd_bnet[i]); - - BitBlt( - g_ddraw->primary->bnet_dc, - rc.left, - rc.top, - rc.right - rc.left, - rc.bottom - rc.top, - dc, - 0, - 0, - SRCCOPY); - - ReleaseDC(hwnd_bnet[i], dc); - } - } - } - - LeaveCriticalSection(&g_ddraw->cs); - if (erase) { BOOL x = g_ddraw->ticks_limiter.use_blt_or_flip; @@ -1286,23 +1283,15 @@ void dds_RedrawBnet(IDirectDrawSurfaceImpl* This) g_ddraw->ticks_limiter.use_blt_or_flip = x; } - - if (g_ddraw->render.run) - ReleaseSemaphore(g_ddraw->render.sem, 1, NULL); } } -HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) +void dds_RedrawArmada(IDirectDrawSurfaceImpl* This) { - if ((This->caps & DDSCAPS_PRIMARYSURFACE)) - { - dds_RedrawBnet(This); - } - /* Hack for Star Trek Armada */ HWND hwnd = g_ddraw->armadahack ? FindWindowEx(HWND_DESKTOP, NULL, "#32770", NULL) : NULL; - if (hwnd && (This->caps & DDSCAPS_PRIMARYSURFACE)) + if (hwnd) { HDC primary_dc; dds_GetDC(This, &primary_dc); @@ -1336,7 +1325,15 @@ HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) g_ddraw->ticks_limiter.use_blt_or_flip = x; } +} +HRESULT dds_Unlock(IDirectDrawSurfaceImpl* This, LPRECT lpRect) +{ + if ((This->caps & DDSCAPS_PRIMARYSURFACE)) + { + dds_RedrawBnet(This, FALSE); + dds_RedrawArmada(This); + } if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw->render.run) { diff --git a/src/wndproc.c b/src/wndproc.c index d69cbb5..d38deff 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -166,7 +166,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam case IDT_TIMER_REDRAW_BNET: { if (g_ddraw->primary) - dds_RedrawBnet(g_ddraw->primary); + dds_RedrawBnet(g_ddraw->primary, TRUE); return 0; } From 87d3fb169adebdaf2a3365ae7ec887d832e1da8b Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 8 Nov 2021 02:36:28 +0100 Subject: [PATCH 07/47] center in windowed mode + clear --- src/render_d3d9.c | 2 ++ src/render_ogl.c | 2 ++ src/winapi_hooks.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/render_d3d9.c b/src/render_d3d9.c index c6e3b95..cd8c9e7 100644 --- a/src/render_d3d9.c +++ b/src/render_d3d9.c @@ -445,6 +445,8 @@ DWORD WINAPI d3d9_render_main(void) if (g_ddraw->bnet_active) { + IDirect3DDevice9_Clear(g_d3d9.device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0); + RECT rc = { 0,0,g_ddraw->width,g_ddraw->height }; if (SUCCEEDED(IDirect3DTexture9_LockRect(g_d3d9.surface_tex[tex_index], 0, &lock_rc, &rc, 0))) diff --git a/src/render_ogl.c b/src/render_ogl.c index 1c5336c..f267a97 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -704,6 +704,8 @@ static void ogl_render() if (g_ddraw->bnet_active) { + glClear(GL_COLOR_BUFFER_BIT); + glBindTexture(GL_TEXTURE_2D, g_ogl.surface_tex_ids[tex_index]); if (g_ogl.adjust_alignment) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 8f3c9c0..01c3ef6 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -693,8 +693,14 @@ HWND WINAPI fake_CreateWindowExA( 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; + if (g_ddraw->windowed) + { + X += align_x; + Y += align_y; + } + + X += pt.x; + Y += pt.y; dwStyle |= WS_CLIPCHILDREN; } From fce63191375c476cf0b1dc5cf31e261113dd812b Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 8 Nov 2021 03:18:28 +0100 Subject: [PATCH 08/47] re-enable d3d9 but only for windowed/borderless - default to opengl --- src/config.c | 38 ++++++++++++++++++++++++++++++++++++-- src/wndproc.c | 3 ++- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 67f2a9e..ccdf8b1 100644 --- a/src/config.c +++ b/src/config.c @@ -149,7 +149,18 @@ void cfg_load() { g_ddraw->renderer = gdi_render_main; } - else /* opengl */ + else if (tolower(tmp[0]) == 'd') /* direct3d9 */ + { + g_ddraw->renderer = d3d9_render_main; + + if (!g_ddraw->windowed) + { + g_ddraw->fullscreen = TRUE; + g_ddraw->windowed = TRUE; + g_config.window_rect.left = g_config.window_rect.top = -32000; + } + } + else if (tolower(tmp[0]) == 'o') /* opengl */ { if (oglu_load_dll()) { @@ -161,6 +172,29 @@ void cfg_load() g_ddraw->renderer = gdi_render_main; } } + else /* auto */ + { + if (!g_ddraw->wine && d3d9_is_available()) + { + g_ddraw->renderer = d3d9_render_main; + + if (!g_ddraw->windowed) + { + g_ddraw->fullscreen = TRUE; + g_ddraw->windowed = TRUE; + g_config.window_rect.left = g_config.window_rect.top = -32000; + } + } + else if (oglu_load_dll()) + { + g_ddraw->renderer = ogl_render_main; + } + else + { + g_ddraw->show_driver_warning = TRUE; + g_ddraw->renderer = gdi_render_main; + } + } } void cfg_save() @@ -252,7 +286,7 @@ static void cfg_create_ini() "posY=-32000\n" "\n" "; Renderer, possible values: auto, opengl, gdi, direct3d9 (auto = try direct3d9/opengl, fallback = gdi)\n" - "renderer=auto\n" + "renderer=opengl\n" "\n" "; Developer mode (don't lock the cursor)\n" "devmode=false\n" diff --git a/src/wndproc.c b/src/wndproc.c index d38deff..a8c085c 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -587,7 +587,8 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam wParam == g_ddraw->hotkeys.toggle_fullscreen && !g_ddraw->fullscreen && context_code && - !key_state) + !key_state && + g_ddraw->renderer != d3d9_render_main) { util_toggle_fullscreen(); return 0; From a4725e7b2d867cae144c1a4cc31043499d653cb6 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 11 Nov 2021 23:19:26 +0100 Subject: [PATCH 09/47] leave fullscreen exclusive on bnet --- src/winapi_hooks.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 01c3ef6..438eb04 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -661,6 +661,17 @@ HWND WINAPI fake_CreateWindowExA( g_ddraw->bnet_was_fullscreen = TRUE; } + else + { + real_SetWindowPos( + g_ddraw->hwnd, + 0, + 0, + 0, + g_ddraw->render.width, + g_ddraw->render.height + 1, + SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSENDCHANGING); + } } real_GetClientRect(g_ddraw->hwnd, &g_ddraw->bnet_win_rect); From e38222053bed5edc0ed4c1e2086bffb8c9db531d Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 12 Nov 2021 02:00:40 +0100 Subject: [PATCH 10/47] clear bnet surface on alt+enter --- src/utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils.c b/src/utils.c index db2dd5d..2f957ce 100644 --- a/src/utils.c +++ b/src/utils.c @@ -279,6 +279,8 @@ void util_toggle_fullscreen() if (g_ddraw->bnet_active) return; + memset(g_ddraw->primary->bnet_surface, 0, g_ddraw->width * g_ddraw->height); + if (g_ddraw->windowed) { mouse_unlock(); From aa1ba9f6eccf333a77babca8a6b357f3af5b7e6e Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 12 Nov 2021 02:05:39 +0100 Subject: [PATCH 11/47] make lowest resolutio check less strict --- src/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.c b/src/utils.c index 2f957ce..8958fb1 100644 --- a/src/utils.c +++ b/src/utils.c @@ -158,7 +158,7 @@ BOOL util_get_lowest_resolution( DWORD max_height) { BOOL result = FALSE; - int org_ratio = (int)((ratio + 0.005f) * 100); + int org_ratio = (int)((ratio + 0.005f) * 10); SIZE lowest = { .cx = max_width + 1, .cy = max_height + 1 }; DWORD i = 0; DEVMODE m; @@ -174,7 +174,7 @@ BOOL util_get_lowest_resolution( m.dmPelsWidth < lowest.cx && m.dmPelsHeight < lowest.cy) { - int res_ratio = (int)((((float)m.dmPelsWidth / m.dmPelsHeight) + 0.005f) * 100); + int res_ratio = (int)((((float)m.dmPelsWidth / m.dmPelsHeight) + 0.005f) * 10); if (res_ratio == org_ratio) { From bf3d21c835793558475c2f6e83ef04250457a5c0 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 20 Nov 2021 03:45:05 +0100 Subject: [PATCH 12/47] add exports for game patching --- ddraw.def | 8 ++++++++ src/dllmain.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/ddraw.def b/ddraw.def index c1b0b64..3b4b6bb 100644 --- a/ddraw.def +++ b/ddraw.def @@ -18,5 +18,13 @@ EXPORTS DirectInputCreateW = fake_DirectInputCreateW DirectInputCreateEx = fake_DirectInputCreateEx DirectInput8Create = fake_DirectInput8Create + DDmemcpy + DDmemmove + DDmemset + DDZeroMemory + DDmemcpyStd + DDmemmoveStd + DDmemsetStd + DDZeroMemoryStd GameHandlesClose DATA pvBmpBits = FakePrimarySurface DATA diff --git a/src/dllmain.c b/src/dllmain.c index e33135a..86f1439 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -232,3 +232,45 @@ DWORD WINAPI DDInternalUnlock(DWORD a) TRACE("NOT_IMPLEMENTED <- %s\n", __FUNCTION__); return ret; } + +/* Exports for game patching */ + +void* __cdecl DDmemcpy(void* _Dst, void const* _Src, size_t _Size) +{ + return memcpy(_Dst, _Src, _Size); +} + +void* __cdecl DDmemmove(void* _Dst, void const* _Src, size_t _Size) +{ + return memmove(_Dst, _Src, _Size); +} + +void* __cdecl DDmemset(void* _Dst, int _Val, size_t _Size) +{ + return memset(_Dst, _Val, _Size); +} + +void __cdecl DDZeroMemory(PVOID Destination, SIZE_T Length) +{ + memset(Destination, 0, Length); +} + +void* __stdcall DDmemcpyStd(void* _Dst, void const* _Src, size_t _Size) +{ + return memcpy(_Dst, _Src, _Size); +} + +void* __stdcall DDmemmoveStd(void* _Dst, void const* _Src, size_t _Size) +{ + return memmove(_Dst, _Src, _Size); +} + +void* __stdcall DDmemsetStd(void* _Dst, int _Val, size_t _Size) +{ + return memset(_Dst, _Val, _Size); +} + +void __stdcall DDZeroMemoryStd(PVOID Destination, SIZE_T Length) +{ + memset(Destination, 0, Length); +} From a71528f35f18faacdb1a53235d9ce696f3b0427c Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 27 Nov 2021 12:51:35 +0100 Subject: [PATCH 13/47] add workaround for multi-monitor setups --- src/render_gdi.c | 49 ++++++++++++++++++++++++++++++++-------------- src/render_ogl.c | 2 +- src/winapi_hooks.c | 10 ++++++++-- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/render_gdi.c b/src/render_gdi.c index e2e8ef0..fd78f80 100644 --- a/src/render_gdi.c +++ b/src/render_gdi.c @@ -74,7 +74,7 @@ DWORD WINAPI gdi_render_main(void) if (g_ddraw->fixchilds) { - g_ddraw->child_window_exists = FALSE; + g_ddraw->child_window_exists = g_ddraw->bnet_active && GetSystemMetrics(SM_CMONITORS) > 1; EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary); } @@ -97,20 +97,39 @@ DWORD WINAPI gdi_render_main(void) if (g_ddraw->bnet_active) { - StretchDIBits( - g_ddraw->render.hdc, - g_ddraw->render.viewport.x, - g_ddraw->render.viewport.y, - g_ddraw->render.viewport.width, - g_ddraw->render.viewport.height, - 0, - 0, - g_ddraw->width, - g_ddraw->height, - g_ddraw->primary->bnet_surface, - g_ddraw->primary->bmi, - DIB_RGB_COLORS, - SRCCOPY); + if (GetSystemMetrics(SM_CMONITORS) == 1) + { + StretchDIBits( + g_ddraw->render.hdc, + g_ddraw->render.viewport.x, + g_ddraw->render.viewport.y, + g_ddraw->render.viewport.width, + g_ddraw->render.viewport.height, + 0, + 0, + g_ddraw->width, + g_ddraw->height, + g_ddraw->primary->bnet_surface, + g_ddraw->primary->bmi, + DIB_RGB_COLORS, + SRCCOPY); + } + else + { + SetDIBitsToDevice( + g_ddraw->render.hdc, + 0, + 0, + g_ddraw->width, + g_ddraw->height, + 0, + 0, + 0, + g_ddraw->height, + g_ddraw->primary->bnet_surface, + g_ddraw->primary->bmi, + DIB_RGB_COLORS); + } } else if (upscale_hack) { diff --git a/src/render_ogl.c b/src/render_ogl.c index f267a97..60d87cd 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -676,7 +676,7 @@ static void ogl_render() if (g_ddraw->fixchilds) { - g_ddraw->child_window_exists = FALSE; + g_ddraw->child_window_exists = g_ddraw->bnet_active && GetSystemMetrics(SM_CMONITORS) > 1; EnumChildWindows(g_ddraw->hwnd, util_enum_child_proc, (LPARAM)g_ddraw->primary); if (g_ddraw->render.width != g_ddraw->width || g_ddraw->render.height != g_ddraw->height) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 438eb04..5c7a91e 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -650,8 +650,9 @@ HWND WINAPI fake_CreateWindowExA( if (!g_ddraw->windowed && !g_ddraw->bnet_was_fullscreen) { - if (g_ddraw->render.mode.dmPelsWidth != 640 || - g_ddraw->render.mode.dmPelsHeight != 480) + if ((g_ddraw->render.mode.dmPelsWidth != 640 || + g_ddraw->render.mode.dmPelsHeight != 480) && + GetSystemMetrics(SM_CMONITORS) == 1) { memcpy(&g_ddraw->bnet_mode, &g_ddraw->render.mode, sizeof(DEVMODE)); @@ -709,6 +710,11 @@ HWND WINAPI fake_CreateWindowExA( X += align_x; Y += align_y; } + else if (GetSystemMetrics(SM_CMONITORS) > 1) + { + X += min(g_ddraw->render.width / 2 - 640 / 2, added_width); + Y += min(g_ddraw->render.height / 2 - 480 / 2, added_height); + } X += pt.x; Y += pt.y; From 6a38496bf76fea3a84087a9a3fd66d2911900fa1 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 27 Nov 2021 17:38:22 +0100 Subject: [PATCH 14/47] fix cursor lock on alt+tab --- src/mouse.c | 2 +- src/wndproc.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mouse.c b/src/mouse.c index 34ab4f9..9b43aa7 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -13,7 +13,7 @@ void mouse_lock() if (g_ddraw->devmode || g_ddraw->bnet_active) return; - if (g_hook_active && !g_ddraw->locked) + if (g_hook_active && !g_ddraw->locked && !IsIconic(g_ddraw->hwnd)) { int game_count = InterlockedExchangeAdd((LONG*)&g_ddraw->show_cursor_count, 0); int cur_count = real_ShowCursor(TRUE) - 1; diff --git a/src/wndproc.c b/src/wndproc.c index a8c085c..736c626 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -504,6 +504,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam if (g_ddraw->renderer != d3d9_render_main) { ChangeDisplaySettings(&g_ddraw->render.mode, CDS_FULLSCREEN); + real_ShowWindow(g_ddraw->hwnd, SW_RESTORE); mouse_lock(); } } From 6e9307a422984d0ccf7776fb4053878b19a9d1ce Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 28 Nov 2021 12:49:13 +0100 Subject: [PATCH 15/47] give bnet lobby a name to make OBS auto scene switcher working with the game --- src/winapi_hooks.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 5c7a91e..1a73cd6 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -720,6 +720,11 @@ HWND WINAPI fake_CreateWindowExA( Y += pt.y; dwStyle |= WS_CLIPCHILDREN; + + if (lpWindowName && !lpWindowName[0]) + { + lpWindowName = "Bnet Lobby"; + } } return real_CreateWindowExA( From 8643372afe35b45f0b3fa58e4145cf6938e09a00 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 9 Apr 2023 19:32:24 +0200 Subject: [PATCH 16/47] fix for non working links in profile --- src/winapi_hooks.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 1a73cd6..a37181c 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -107,6 +107,16 @@ BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint) return TRUE; } + else if (lpPoint && g_ddraw->bnet_active && real_ScreenToClient(g_ddraw->hwnd, &pt)) + { + if (pt.x > 0 && pt.x < g_ddraw->width && pt.y > 0 && pt.y < g_ddraw->height) + { + lpPoint->x = pt.x; + lpPoint->y = pt.y; + + return TRUE; + } + } if (lpPoint) { From 50d4c0aa81ffc697094593fa9bc9fb303e64a162 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 9 Apr 2023 20:06:51 +0200 Subject: [PATCH 17/47] hook SetForegroundWindow for profile links --- inc/hook.h | 4 +++- inc/winapi_hooks.h | 1 + src/hook.c | 2 ++ src/winapi_hooks.c | 5 +++++ src/wndproc.c | 4 ++-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/inc/hook.h b/inc/hook.h index 0623c07..95ba179 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -9,7 +9,7 @@ #define SKIP_HOOK3 0x00000002l typedef struct HOOKLISTDATA { char function_name[32]; PROC new_function; PROC* function; DWORD flags; } HOOKLISTDATA; -typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[24]; } HOOKLIST; +typedef struct HOOKLIST { char module_name[32]; HOOKLISTDATA data[25]; } HOOKLIST; typedef BOOL(WINAPI* GETCURSORPOSPROC)(LPPOINT); typedef BOOL(WINAPI* CLIPCURSORPROC)(const RECT*); @@ -34,6 +34,7 @@ typedef HWND(WINAPI* CREATEWINDOWEXAPROC)(DWORD, LPCSTR, LPCSTR, DWORD, int, int typedef BOOL(WINAPI* DESTROYWINDOWPROC)(HWND); typedef int (WINAPI* MAPWINDOWPOINTSPROC)(HWND, HWND, LPPOINT, UINT); typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int); +typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd); typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD); typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int); typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR); @@ -65,6 +66,7 @@ extern CREATEWINDOWEXAPROC real_CreateWindowExA; extern DESTROYWINDOWPROC real_DestroyWindow; extern MAPWINDOWPOINTSPROC real_MapWindowPoints; extern SHOWWINDOWPROC real_ShowWindow; +extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow; extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA; extern GETDEVICECAPSPROC real_GetDeviceCaps; extern LOADLIBRARYAPROC real_LoadLibraryA; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index 3b4ca4c..c112ec3 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -27,6 +27,7 @@ BOOL WINAPI fake_EnableWindow(HWND hWnd, BOOL bEnable); BOOL WINAPI fake_DestroyWindow(HWND hWnd); int WINAPI fake_MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints); BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow); +BOOL WINAPI fake_SetForegroundWindow(HWND hWnd); HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId); int WINAPI fake_GetDeviceCaps(HDC hdc, int index); HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName); diff --git a/src/hook.c b/src/hook.c index a6fb2a5..3a3406a 100644 --- a/src/hook.c +++ b/src/hook.c @@ -40,6 +40,7 @@ CREATEWINDOWEXAPROC real_CreateWindowExA = CreateWindowExA; DESTROYWINDOWPROC real_DestroyWindow = DestroyWindow; MAPWINDOWPOINTSPROC real_MapWindowPoints = MapWindowPoints; SHOWWINDOWPROC real_ShowWindow = ShowWindow; +SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow; SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA; GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps; LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA; @@ -76,6 +77,7 @@ static HOOKLIST g_hooks[] = { "DestroyWindow", (PROC)fake_DestroyWindow, (PROC*)&real_DestroyWindow, 0 }, { "MapWindowPoints", (PROC)fake_MapWindowPoints, (PROC*)&real_MapWindowPoints, 0 }, { "ShowWindow", (PROC)fake_ShowWindow, (PROC*)&real_ShowWindow, 0 }, + { "SetForegroundWindow", (PROC)fake_SetForegroundWindow, (PROC*)&real_SetForegroundWindow, 0 }, { "", NULL, NULL, 0 } } }, diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index a37181c..2ffeab5 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -526,6 +526,11 @@ BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow) return real_ShowWindow(hWnd, nCmdShow); } +BOOL WINAPI fake_SetForegroundWindow(HWND hWnd) +{ + return TRUE; +} + HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId) { if (idHook == WH_KEYBOARD_LL && hmod && GetModuleHandle("AcGenral") == hmod) diff --git a/src/wndproc.c b/src/wndproc.c index 736c626..eee69fa 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -17,7 +17,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - /* + /**/ TRACE( " uMsg = %s (%d), wParam = %08X (%d), lParam = %08X (%d)\n", dbg_mes_to_str(uMsg), @@ -26,7 +26,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam wParam, lParam, lParam); - */ + static BOOL in_size_move = FALSE; static int redraw_count = 0; From 9b028e63763d8060a251e6dd1e46bb11d1075b93 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 9 Apr 2023 20:07:43 +0200 Subject: [PATCH 18/47] disable debug code --- src/wndproc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wndproc.c b/src/wndproc.c index eee69fa..736c626 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -17,7 +17,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - /**/ + /* TRACE( " uMsg = %s (%d), wParam = %08X (%d), lParam = %08X (%d)\n", dbg_mes_to_str(uMsg), @@ -26,7 +26,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam wParam, lParam, lParam); - + */ static BOOL in_size_move = FALSE; static int redraw_count = 0; From b50f9fff7b2183f2f809b39d7c331111081f5c62 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 16 Aug 2023 14:21:26 +0200 Subject: [PATCH 19/47] add hooks to fix blurry fonts --- inc/hook.h | 4 ++++ inc/winapi_hooks.h | 6 ++++++ src/hook.c | 27 +++++++++++++++++++++++++++ src/winapi_hooks.c | 24 ++++++++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/inc/hook.h b/inc/hook.h index 95ba179..5a08f6b 100644 --- a/inc/hook.h +++ b/inc/hook.h @@ -37,6 +37,8 @@ typedef BOOL (WINAPI* SHOWWINDOWPROC)(HWND, int); typedef BOOL (WINAPI* SETFOREGROUNDWINDOWPROC)(HWND hWnd); typedef HHOOK(WINAPI* SETWINDOWSHOOKEXAPROC)(int, HOOKPROC, HINSTANCE, DWORD); typedef int (WINAPI* GETDEVICECAPSPROC)(HDC, int); +typedef HFONT(WINAPI* CREATEFONTINDIRECTAPROC)(CONST LOGFONT*); +typedef HFONT(WINAPI* CREATEFONTAPROC)(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR); typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR); typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR); typedef HMODULE(WINAPI* LOADLIBRARYEXAPROC)(LPCSTR, HANDLE, DWORD); @@ -69,6 +71,8 @@ extern SHOWWINDOWPROC real_ShowWindow; extern SETFOREGROUNDWINDOWPROC real_SetForegroundWindow; extern SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA; extern GETDEVICECAPSPROC real_GetDeviceCaps; +extern CREATEFONTINDIRECTAPROC real_CreateFontIndirectA; +extern CREATEFONTAPROC real_CreateFontA; extern LOADLIBRARYAPROC real_LoadLibraryA; extern LOADLIBRARYWPROC real_LoadLibraryW; extern LOADLIBRARYEXAPROC real_LoadLibraryExA; diff --git a/inc/winapi_hooks.h b/inc/winapi_hooks.h index c112ec3..9c0a5b4 100644 --- a/inc/winapi_hooks.h +++ b/inc/winapi_hooks.h @@ -30,6 +30,12 @@ BOOL WINAPI fake_ShowWindow(HWND hWnd, int nCmdShow); BOOL WINAPI fake_SetForegroundWindow(HWND hWnd); HHOOK WINAPI fake_SetWindowsHookExA(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId); int WINAPI fake_GetDeviceCaps(HDC hdc, int index); +HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA* lplf); +HFONT WINAPI fake_CreateFontA(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight, + DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet, + DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality, DWORD fdwPitchAndFamily, + LPCTSTR lpszFace); + HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName); HMODULE WINAPI fake_LoadLibraryW(LPCWSTR lpLibFileName); HMODULE WINAPI fake_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags); diff --git a/src/hook.c b/src/hook.c index 3a3406a..66af624 100644 --- a/src/hook.c +++ b/src/hook.c @@ -43,12 +43,15 @@ SHOWWINDOWPROC real_ShowWindow = ShowWindow; SETFOREGROUNDWINDOWPROC real_SetForegroundWindow = SetForegroundWindow; SETWINDOWSHOOKEXAPROC real_SetWindowsHookExA = SetWindowsHookExA; GETDEVICECAPSPROC real_GetDeviceCaps = GetDeviceCaps; +CREATEFONTINDIRECTAPROC real_CreateFontIndirectA = CreateFontIndirectA; +CREATEFONTAPROC real_CreateFontA = CreateFontA; LOADLIBRARYAPROC real_LoadLibraryA = LoadLibraryA; LOADLIBRARYWPROC real_LoadLibraryW = LoadLibraryW; LOADLIBRARYEXAPROC real_LoadLibraryExA = LoadLibraryExA; LOADLIBRARYEXWPROC real_LoadLibraryExW = LoadLibraryExW; COCREATEINSTANCEPROC real_CoCreateInstance = CoCreateInstance; + static HOOKLIST g_hooks[] = { { @@ -497,6 +500,20 @@ void hook_init() { BOOL initial_hook = !g_hook_active; + if (initial_hook) + { + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach((PVOID*)&real_CreateFontIndirectA, (PVOID)fake_CreateFontIndirectA); + DetourTransactionCommit(); + + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach((PVOID*)&real_CreateFontA, (PVOID)fake_CreateFontA); + DetourTransactionCommit(); + } + + #ifdef _MSC_VER if (initial_hook && g_hook_dinput) { @@ -577,6 +594,16 @@ void hook_exit() { g_hook_active = FALSE; + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourDetach((PVOID*)&real_CreateFontIndirectA, (PVOID)fake_CreateFontIndirectA); + DetourTransactionCommit(); + + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourDetach((PVOID*)&real_CreateFontA, (PVOID)fake_CreateFontA); + DetourTransactionCommit(); + #ifdef _MSC_VER if (g_hook_dinput) { diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 2ffeab5..7ab3324 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -560,6 +560,30 @@ int WINAPI fake_GetDeviceCaps(HDC hdc, int index) return real_GetDeviceCaps(hdc, index); } +HFONT WINAPI fake_CreateFontIndirectA(CONST LOGFONTA* lplf) +{ + LOGFONTA lf; + memcpy(&lf, lplf, sizeof(lf)); + lf.lfQuality = NONANTIALIASED_QUALITY; + + return real_CreateFontIndirectA(&lf); +} + +HFONT WINAPI fake_CreateFontA(int nHeight, int nWidth, int nEscapement, int nOrientation, int fnWeight, + DWORD fdwItalic, DWORD fdwUnderline, DWORD fdwStrikeOut, DWORD fdwCharSet, + DWORD fdwOutputPrecision, DWORD fdwClipPrecision, DWORD fdwQuality, DWORD fdwPitchAndFamily, + LPCTSTR lpszFace) +{ + fdwQuality = NONANTIALIASED_QUALITY; + + return + real_CreateFontA( + nHeight, nWidth, nEscapement, nOrientation, fnWeight, + fdwItalic, fdwUnderline, fdwStrikeOut, fdwCharSet, + fdwOutputPrecision, fdwClipPrecision, fdwQuality, fdwPitchAndFamily, + lpszFace); +} + HMODULE WINAPI fake_LoadLibraryA(LPCSTR lpLibFileName) { HMODULE hmod = real_LoadLibraryA(lpLibFileName); From 971bcb39851d7c9507abfb02c33fdd5bd7283d66 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 2 Sep 2023 23:11:51 +0200 Subject: [PATCH 20/47] update config to latest version --- config/ConfigFormUnit.cpp | 594 +++++++++++++++-- config/ConfigFormUnit.dfm | 955 ++++++++++++++++++--------- config/ConfigFormUnit.h | 44 +- config/Resources/IT.png | Bin 0 -> 420 bytes config/cnc-ddraw config.cbproj | 836 ++++++++++++----------- config/cnc-ddraw config.cpp | 26 +- config/cnc-ddraw config.manifest | 34 + config/cnc-ddraw config_resources.rc | 1 + 8 files changed, 1682 insertions(+), 808 deletions(-) create mode 100644 config/Resources/IT.png create mode 100644 config/cnc-ddraw config.manifest diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 82f9920..3c704e2 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "ConfigFormUnit.h" //--------------------------------------------------------------------------- #pragma package(smart_init) @@ -18,7 +20,7 @@ bool IsEnglish; /* Save previous settings so we don't override custom settings */ int Maxfps; int Savesettings; -int Hook; +int Resolutions; int Minfps; //--------------------------------------------------------------------------- @@ -27,9 +29,18 @@ __fastcall TConfigForm::TConfigForm(TComponent* Owner) { } +void __fastcall TConfigForm::CreateParams(TCreateParams & Params) +{ + TForm::CreateParams(Params); + + StrCopy( + Params.WinClassName, + THashSHA1::GetHashString(Application->ExeName).w_str()); +} + void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) { - auto *ini = new TIniFile(".\\ddraw.ini"); + auto *ini = new TIniFile(".\\dd-hd.ini"); ini->WriteString("ddraw", "configlang", IsEnglish ? "auto" : "english"); delete ini; @@ -37,7 +48,51 @@ void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) NULL, L"open", Application->ExeName.w_str(), + L"-restart", NULL, + SW_SHOWNORMAL); + + Application->Terminate(); +} + +void __fastcall TConfigForm::ThemePnlClick(TObject *Sender) +{ + auto *ini = new TIniFile(".\\dd-hd.ini"); + auto theme = + ThemePnl->Color == (TColor)RGB(31, 31, 31) ? "Cobalt XEMedia" : "Windows10"; + + ini->WriteString("ddraw", "configtheme", theme); + + delete ini; + + ShellExecute( + NULL, + L"open", + Application->ExeName.w_str(), + L"-restart", + NULL, + SW_SHOWNORMAL); + + Application->Terminate(); +} + +void __fastcall TConfigForm::RestoreDefaultsBtnClick(TObject *Sender) +{ + if (Application->MessageBox( + (RestoreDefaultsBtn->Caption + "?").w_str(), + L"cnc-ddraw", + MB_YESNO) == IDNO) { + + return; + } + + DeleteFile(".\\dd-hd.ini"); + + ShellExecute( + NULL, + L"open", + Application->ExeName.w_str(), + L"-restart", NULL, SW_SHOWNORMAL); @@ -57,7 +112,9 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"cnc-ddraw 配置"; DisplayBtn->Caption = L"显示设置"; AdvancedBtn->Caption = L"高级设置"; + HotkeyBtn->Caption = L"热键设置"; CompatibilityBtn->Caption = L"兼容性设置"; + RestoreDefaultsBtn->Caption = L"恢复默认设置"; PresentationLbl->Caption = L"显示方式"; MaintasLbl->Caption = L"保持纵横比"; VsyncLbl->Caption = L"打开垂直同步"; @@ -69,11 +126,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"OpenGL着色器"; MaxfpsLbl->Caption = L"限制帧率"; BoxingLbl->Caption = L"打开窗盒显示/整数缩放"; + ToggleWindowedLbl->Caption = L"切换窗口模式"; + MaximizeWindowLbl->Caption = L"最大化窗口"; + UnlockCursor1Lbl->Caption = L"解锁光标 1"; + UnlockCursor2Lbl->Caption = L"解锁光标 2"; + ScreenshotLbl->Caption = L"截屏"; MaxgameticksLbl->Caption = L"限制游戏速率"; NoactivateappLbl->Caption = L"修复损坏的Alt+Tab功能"; - HookLbl->Caption = L"修复损坏的窗口模式或拉伸"; + ResolutionsLbl->Caption = L"解锁其他屏幕分辨率"; MinfpsLbl->Caption = L"强制高FPS / 修复使用Freesync/G-Sync的卡顿问题"; - FixpitchLbl->Caption = L"修复倾斜撕裂显示的问题"; + SinglecpuLbl->Caption = L"修复性能不佳和声音问题"; NonexclusiveLbl->Caption = L"修复不显示的视频/UI元素"; RendererCbx->Items->Clear(); @@ -94,6 +156,8 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"模拟60hz刷新率显示器", NULL); MaxgameticksCbx->AddItem(L"1000tick每秒", NULL); MaxgameticksCbx->AddItem(L"500tick每秒", NULL); + MaxgameticksCbx->AddItem(L"250tick每秒", NULL); + MaxgameticksCbx->AddItem(L"125tick每秒", NULL); MaxgameticksCbx->AddItem(L"60tick每秒", NULL); MaxgameticksCbx->AddItem(L"30tick每秒", NULL); MaxgameticksCbx->AddItem(L"25tick每秒", NULL); @@ -107,7 +171,9 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"Ajustes de cnc-ddraw"; DisplayBtn->Caption = L"Ajustes de pantalla"; AdvancedBtn->Caption = L"Ajustes avanzados"; + HotkeyBtn->Caption = L"Teclas de acceso rápido"; CompatibilityBtn->Caption = L"Ajustes de compatibilidad"; + RestoreDefaultsBtn->Caption = L"Restaurar la configuración predeterminada"; PresentationLbl->Caption = L"Presentación"; MaintasLbl->Caption = L"Mantener la relación de aspecto"; VsyncLbl->Caption = L"Activar VSync"; @@ -119,11 +185,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"Sombreador OpenGL"; MaxfpsLbl->Caption = L"Limitar velocidad de fotogramas"; BoxingLbl->Caption = L"Activar encajado de ventanas / escalado de enteros"; + ToggleWindowedLbl->Caption = L"Alternar modo de ventana"; + MaximizeWindowLbl->Caption = L"Maximizar ventana"; + UnlockCursor1Lbl->Caption = L"Desbloquear cursor 1"; + UnlockCursor2Lbl->Caption = L"Desbloquear cursor 2"; + ScreenshotLbl->Caption = L"Captura de pantalla"; MaxgameticksLbl->Caption = L"Limitar velocidad de juego"; NoactivateappLbl->Caption = L"Corregir Alt+Tab roto"; - HookLbl->Caption = L"Corregir modo ventana o ampliación de escala"; + ResolutionsLbl->Caption = L"Desbloquear resoluciones de pantalla adicionales"; MinfpsLbl->Caption = L"Forzar un alto FPS / Corregir retrasos en Freesync/G-Sync"; - FixpitchLbl->Caption = L"Corregir problemas de visualización de dibujos en diagonal"; + SinglecpuLbl->Caption = L"Solucione el mal rendimiento y los problemas de sonido"; NonexclusiveLbl->Caption = L"Corregir vídeos / elementos de interfaz invisibles"; RendererCbx->Items->Clear(); @@ -144,6 +215,8 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"Emular monitor con tasa de refresco de 60hz", NULL); MaxgameticksCbx->AddItem(L"1000 tics por segundo", NULL); MaxgameticksCbx->AddItem(L"500 tics por segundo", NULL); + MaxgameticksCbx->AddItem(L"250 tics por segundo", NULL); + MaxgameticksCbx->AddItem(L"125 tics por segundo", NULL); MaxgameticksCbx->AddItem(L"60 tics por segundo", NULL); MaxgameticksCbx->AddItem(L"30 tics por segundo", NULL); MaxgameticksCbx->AddItem(L"25 tics por segundo", NULL); @@ -157,23 +230,30 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"cnc-ddraw Konfiguration"; DisplayBtn->Caption = L"Anzeigeeinstellungen"; AdvancedBtn->Caption = L"Erweiterte Einstellungen"; + HotkeyBtn->Caption = L"Tastenkürzel-Einstellungen"; CompatibilityBtn->Caption = L"Kompatibilitätseinstellungen"; - PresentationLbl->Caption = L"Presentation"; - MaintasLbl->Caption = L"Erhalte Seitenverhältnis"; + RestoreDefaultsBtn->Caption = L"Standardeinstellungen wiederherstellen"; + PresentationLbl->Caption = L"Darstellung"; + MaintasLbl->Caption = L"Seitenverhältnis beibehalten"; VsyncLbl->Caption = L"VSync aktiveren"; AdjmouseLbl->Caption = L"Mausempfindlichkeit anpassen"; DevmodeLbl->Caption = L"Sperre Cursor zu Fenster / Bildschirm"; //Not 100% sure, if not a better translation exists RendererLbl->Caption = L"Renderer"; BorderLbl->Caption = L"Zeige Fensterränder in Fenstermodus"; SavesettingsLbl->Caption = L"Fensterposition und Größe merken"; - ShaderLbl->Caption = L"OpenGL shader"; + ShaderLbl->Caption = L"OpenGL Shader"; MaxfpsLbl->Caption = L"Limitiere Aktualisierungsrate"; BoxingLbl->Caption = L"Fensterboxing / Integer Skalierung aktivieren"; //Not 100% sure if "windowboxing" can be translated better. + ToggleWindowedLbl->Caption = L"Fenstermodus umschalten"; + MaximizeWindowLbl->Caption = L"Fenster maximieren"; + UnlockCursor1Lbl->Caption = L"Cursor entsperren 1"; + UnlockCursor2Lbl->Caption = L"Cursor entsperren 2"; + ScreenshotLbl->Caption = L"Bildschirmfoto"; MaxgameticksLbl->Caption = L"Spielgeschwindigkeit limitieren"; NoactivateappLbl->Caption = L"Fehlerhaftes Alt+Tab reparieren"; //The first word can be ignored if its to long (eng word "Fix" - HookLbl->Caption = L"Fehlerhafter Fenstermodus oder Hochskalierung reparieren"; //The first word can be ignored if its to long (eng word "Fix") + ResolutionsLbl->Caption = L"Zusätzliche Bildschirmauflösungen freischalten"; MinfpsLbl->Caption = L"Erzwinge Hohe FPS / Repariere Stottern bei Freesync/G-Sync"; - FixpitchLbl->Caption = L"Diagonal dargestellte Zeichnungsfehler reparieren"; + SinglecpuLbl->Caption = L"Schlechte Leistung und Soundprobleme reparieren"; NonexclusiveLbl->Caption = L"Unsichtbare Videos / UI Elemente reparieren"; RendererCbx->Items->Clear(); @@ -186,7 +266,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) PresentationCbx->AddItem(L"Vollbild", NULL); PresentationCbx->AddItem(L"Hochskaliertes Vollbild", NULL); PresentationCbx->AddItem(L"Ränderfreies Fenster", NULL); - PresentationCbx->AddItem(L"Fenster", NULL); + PresentationCbx->AddItem(L"Fenstermodus", NULL); MaxgameticksCbx->Items->Clear(); MaxgameticksCbx->AddItem(L"Unlimitiert", NULL); @@ -194,6 +274,8 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"Emuliere 60hz Bildschirmaktualisierungsrate", NULL); MaxgameticksCbx->AddItem(L"1000 Ticks pro Sekunde", NULL); MaxgameticksCbx->AddItem(L"500 Ticks pro Sekunde", NULL); + MaxgameticksCbx->AddItem(L"250 Ticks pro Sekunde", NULL); + MaxgameticksCbx->AddItem(L"125 Ticks pro Sekunde", NULL); MaxgameticksCbx->AddItem(L"60 Ticks pro Sekunde", NULL); MaxgameticksCbx->AddItem(L"30 Ticks pro Sekunde", NULL); MaxgameticksCbx->AddItem(L"25 Ticks pro Sekunde", NULL); @@ -202,16 +284,15 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) else if (lang == "russian" || (lang == "auto" && priID == LANG_RUSSIAN)) { LanguageImg->Visible = true; ClientWidth *= 1.13; - DisplayPnl->Width *= 1.184; - AdvancedPnl->Width *= 1.184; - CompatibilityPnl->Width *= 1.184; /* -Russian- made by shikulja @ github */ ConfigForm->Caption = L"Настройки cnc-ddraw"; DisplayBtn->Caption = L"Настройки отображения"; AdvancedBtn->Caption = L"Расширенные настройки"; + HotkeyBtn->Caption = L"Настройки горячих клавиш"; CompatibilityBtn->Caption = L"Настройки совместимости"; + RestoreDefaultsBtn->Caption = L"Восстановить настройки по умолчанию"; PresentationLbl->Caption = L"Отображение"; MaintasLbl->Caption = L"Сохранять соотношение сторон"; VsyncLbl->Caption = L"Включить VSync"; @@ -223,11 +304,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"Шейдер OpenGL"; MaxfpsLbl->Caption = L"Ограничить частоту кадров"; BoxingLbl->Caption = L"Включить windowboxing / целочисленное масштабирование"; + ToggleWindowedLbl->Caption = L"Переключить оконный режим"; + MaximizeWindowLbl->Caption = L"Развернуть окно"; + UnlockCursor1Lbl->Caption = L"Разблокировать курсор 1"; + UnlockCursor2Lbl->Caption = L"Разблокировать курсор 2"; + ScreenshotLbl->Caption = L"Скриншот"; MaxgameticksLbl->Caption = L"Ограничить скорость игры"; NoactivateappLbl->Caption = L"Исправить сломанный Alt+Tab"; - HookLbl->Caption = L"Исправить сломанный оконный режим или масштабированние"; + ResolutionsLbl->Caption = L"Разблокировать дополнительные разрешения экрана"; MinfpsLbl->Caption = L"Принудительно высокий FPS / Исправить заикание при Freesync/G-Sync"; - FixpitchLbl->Caption = L"Исправить проблемы с отображением отрисовки по диагонали"; + SinglecpuLbl->Caption = L"Исправление проблем с производительностью и звуком"; NonexclusiveLbl->Caption = L"Исправить невидимые видео / элементы пользовательского интерфейса"; RendererCbx->Items->Clear(); @@ -248,6 +334,8 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"Эмуляция частоты обновления монитора 60 Гц", NULL); MaxgameticksCbx->AddItem(L"1000 тиков в секунду", NULL); MaxgameticksCbx->AddItem(L"500 тиков в секунду", NULL); + MaxgameticksCbx->AddItem(L"250 тиков в секунду", NULL); + MaxgameticksCbx->AddItem(L"125 тиков в секунду", NULL); MaxgameticksCbx->AddItem(L"60 тиков в секунду", NULL); MaxgameticksCbx->AddItem(L"30 тиков в секунду", NULL); MaxgameticksCbx->AddItem(L"25 тиков в секунду", NULL); @@ -261,7 +349,9 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"cnc-ddraw Beállító"; DisplayBtn->Caption = L"Képbeállítások"; AdvancedBtn->Caption = L"Haladó Beállítások"; + HotkeyBtn->Caption = L"Gyorsbillentyűk beállításai"; CompatibilityBtn->Caption = L"Kompatibilitás Beállítások"; + RestoreDefaultsBtn->Caption = L"Visszaállítja az alapértelmezett beállításokat"; PresentationLbl->Caption = L"Bemutató"; MaintasLbl->Caption = L"Képarány megtartása"; VsyncLbl->Caption = L"VSync bekapcsolása"; @@ -273,11 +363,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"OpenGL árnyaló"; MaxfpsLbl->Caption = L"Képkockaszám korlátozás"; BoxingLbl->Caption = L"Ablakos mód / felskálázás bekapcsolása"; + ToggleWindowedLbl->Caption = L"Az ablakos mód váltása"; + MaximizeWindowLbl->Caption = L"Az ablak maximalizálása"; + UnlockCursor1Lbl->Caption = L"A kurzor feloldása 1"; + UnlockCursor2Lbl->Caption = L"A kurzor feloldása 2"; + ScreenshotLbl->Caption = L"Képernyőkép"; MaxgameticksLbl->Caption = L"Játéksebesség korlátozás"; NoactivateappLbl->Caption = L"Alt+Tab hiba kiküszöbölése"; - HookLbl->Caption = L"Hibás ablakos mód, vagy felskálázás javítása"; + ResolutionsLbl->Caption = L"További képernyőfelbontások feloldása"; MinfpsLbl->Caption = L"Magas FPS kényszerítés / Akadozásjavítás Freesync/G-Sync esetén"; - FixpitchLbl->Caption = L"Átlós rajzolási gondok kiküszöbölése"; + SinglecpuLbl->Caption = L"Javítsa ki a rossz teljesítmény- és hangproblémákat"; NonexclusiveLbl->Caption = L"Láthatatlan videók / kezelőfelületi elemek javítása"; RendererCbx->Items->Clear(); @@ -298,6 +393,8 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"60hz képfrissítésű kijelző emulálása", NULL); MaxgameticksCbx->AddItem(L"1000 tick másodpercenként", NULL); MaxgameticksCbx->AddItem(L"500 tick másodpercenként", NULL); + MaxgameticksCbx->AddItem(L"250 tick másodpercenként", NULL); + MaxgameticksCbx->AddItem(L"125 tick másodpercenként", NULL); MaxgameticksCbx->AddItem(L"60 tick másodpercenként", NULL); MaxgameticksCbx->AddItem(L"30 tick másodpercenként", NULL); MaxgameticksCbx->AddItem(L"25 tick másodpercenként", NULL); @@ -311,7 +408,9 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"Configuration cnc-ddraw"; DisplayBtn->Caption = L"Paramètres d'Affichage"; AdvancedBtn->Caption = L"Paramètres Avancés"; + HotkeyBtn->Caption = L"Paramètres de raccourci"; CompatibilityBtn->Caption = L"Paramètres de Compatibilité"; + RestoreDefaultsBtn->Caption = L"Restaurer les paramètres par défaut"; PresentationLbl->Caption = L"Présentation"; MaintasLbl->Caption = L"Conserver les proportions de l'image"; VsyncLbl->Caption = L"Activer la synchro verticale (VSync)"; @@ -323,11 +422,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"Shader OpenGL"; MaxfpsLbl->Caption = L"Limiter les images par seconde (FPS)"; BoxingLbl->Caption = L"Activer windowboxing / mise à l'échelle par nombres entiers"; + ToggleWindowedLbl->Caption = L"Basculer en mode fenêtré"; + MaximizeWindowLbl->Caption = L"Agrandir la fenêtre"; + UnlockCursor1Lbl->Caption = L"Déverrouiller le curseur 1"; + UnlockCursor2Lbl->Caption = L"Déverrouiller le curseur 2"; + ScreenshotLbl->Caption = L"Capture d'écran"; MaxgameticksLbl->Caption = L"Limiter la vitesse du jeu"; NoactivateappLbl->Caption = L"Corriger Alt+Tab défaillant"; - HookLbl->Caption = L"Corriger mode fenêtré ou mise à l'échelle défaillant"; + ResolutionsLbl->Caption = L"Déverrouiller des résolutions d'écran supplémentaires"; MinfpsLbl->Caption = L"Forcer FPS élevé / Corriger saccades en Freesync/G-Sync"; - FixpitchLbl->Caption = L"Corriger défauts d'affichage diagonaux"; + SinglecpuLbl->Caption = L"Résoudre les problèmes de mauvaise performance et de son"; NonexclusiveLbl->Caption = L"Corriger vidéos et éléments d'interface invisibles"; RendererCbx->Items->Clear(); @@ -348,11 +452,72 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"Émuler un écran à 60Hz", NULL); MaxgameticksCbx->AddItem(L"1000 tics par seconde", NULL); MaxgameticksCbx->AddItem(L"500 tics par seconde", NULL); + MaxgameticksCbx->AddItem(L"250 tics par seconde", NULL); + MaxgameticksCbx->AddItem(L"125 tics par seconde", NULL); MaxgameticksCbx->AddItem(L"60 tics par seconde", NULL); MaxgameticksCbx->AddItem(L"30 tics par seconde", NULL); MaxgameticksCbx->AddItem(L"25 tics par seconde", NULL); MaxgameticksCbx->AddItem(L"15 tics par seconde", NULL); } + else if (lang == "italian" || (lang == "auto" && priID == LANG_ITALIAN)) { + LanguageImg->Visible = true; + + /* -Italian - made by Kappa971 @ github */ + + ConfigForm->Caption = L"Configurazione di cnc-ddraw"; + DisplayBtn->Caption = L"Impostazioni dello schermo"; + AdvancedBtn->Caption = L"Impostazioni avanzate"; + HotkeyBtn->Caption = L"Tasti di scelta rapida"; + CompatibilityBtn->Caption = L"Impostazioni di compatibilità"; + RestoreDefaultsBtn->Caption = L"Ripristina le impostazioni predefinite"; + PresentationLbl->Caption = L"Presentazione"; + MaintasLbl->Caption = L"Mantieni il rapporto d'aspetto"; + VsyncLbl->Caption = L"Abilita la sincronizzazione verticale (VSync)"; + AdjmouseLbl->Caption = L"Regola la sensibilità del mouse"; + DevmodeLbl->Caption = L"Cattura il cursore nella finestra / schermo"; + RendererLbl->Caption = L"Renderer"; + BorderLbl->Caption = L"Mostra i bordi della finestra in modalità finestra"; + SavesettingsLbl->Caption = L"Ricorda la posizione e le dimensioni della finestra"; + ShaderLbl->Caption = L"Shader OpenGL"; + MaxfpsLbl->Caption = L"Limita la frequenza dei fotogrammi (FPS)"; + BoxingLbl->Caption = L"Abilita il ridimensionamento dei numeri interi"; + ToggleWindowedLbl->Caption = L"Attiva/disattiva la modalità finestra"; + MaximizeWindowLbl->Caption = L"Ingrandisci finestra"; + UnlockCursor1Lbl->Caption = L"Sblocca cursore 1"; + UnlockCursor2Lbl->Caption = L"Sblocca cursore 2"; + ScreenshotLbl->Caption = L"Istantanea dello schermo"; + MaxgameticksLbl->Caption = L"Limita la velocità di gioco"; + NoactivateappLbl->Caption = L"Correggi il funzionamento di Alt+Tab"; + ResolutionsLbl->Caption = L"Sblocca ulteriori risoluzioni dello schermo"; + MinfpsLbl->Caption = L"Forza FPS elevati / Correggi balbuzie su Freesync/G-Sync"; + SinglecpuLbl->Caption = L"Risolvi problemi di prestazioni e audio scadenti"; + NonexclusiveLbl->Caption = L"Correggi video / elementi dell'interfaccia utente invisibili"; + + RendererCbx->Items->Clear(); + RendererCbx->AddItem(L"Automatico", NULL); + RendererCbx->AddItem(L"Direct3D 9", NULL); + RendererCbx->AddItem(L"OpenGL", NULL); + RendererCbx->AddItem(L"GDI", NULL); + + PresentationCbx->Items->Clear(); + PresentationCbx->AddItem(L"Schermo Intero", NULL); + PresentationCbx->AddItem(L"Schermo Intero Ridimensionato", NULL); + PresentationCbx->AddItem(L"Senza Bordi", NULL); + PresentationCbx->AddItem(L"In Finestra", NULL); + + MaxgameticksCbx->Items->Clear(); + MaxgameticksCbx->AddItem(L"Senza Limiti", NULL); + MaxgameticksCbx->AddItem(L"Sincronizza con la frequenza dello schermo", NULL); + MaxgameticksCbx->AddItem(L"Emula uno schermo a 60Hz", NULL); + MaxgameticksCbx->AddItem(L"1000 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"500 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"250 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"125 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"60 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"30 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"25 tick al secondo", NULL); + MaxgameticksCbx->AddItem(L"15 tick al secondo", NULL); + } else { IsEnglish = true; @@ -393,6 +558,12 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) LanguageImg->Picture->Graphic = png; LanguageImg->Visible = true; } + else if (priID == LANG_ITALIAN) { + TPngImage *png = new TPngImage(); + png->LoadFromResourceName((int)HInstance, "PngImage_IT"); + LanguageImg->Picture->Graphic = png; + LanguageImg->Visible = true; + } } catch (...) { } @@ -400,7 +571,9 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ConfigForm->Caption = L"cnc-ddraw config"; DisplayBtn->Caption = L"Display Settings"; AdvancedBtn->Caption = L"Advanced Settings"; + HotkeyBtn->Caption = L"Hotkey Settings"; CompatibilityBtn->Caption = L"Compatibility Settings"; + RestoreDefaultsBtn->Caption = L"Restore default settings"; PresentationLbl->Caption = L"Presentation"; MaintasLbl->Caption = L"Maintain aspect ratio"; VsyncLbl->Caption = L"Enable VSync"; @@ -412,11 +585,16 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) ShaderLbl->Caption = L"OpenGL shader"; MaxfpsLbl->Caption = L"Limit frame rate"; BoxingLbl->Caption = L"Enable windowboxing / integer scaling"; + ToggleWindowedLbl->Caption = L"Toggle windowed mode"; + MaximizeWindowLbl->Caption = L"Maximize window"; + UnlockCursor1Lbl->Caption = L"Unlock cursor 1"; + UnlockCursor2Lbl->Caption = L"Unlock cursor 2"; + ScreenshotLbl->Caption = L"Screenshot"; MaxgameticksLbl->Caption = L"Limit game speed"; NoactivateappLbl->Caption = L"Fix broken Alt+Tab"; - HookLbl->Caption = L"Fix broken windowed mode or upscaling"; + ResolutionsLbl->Caption = L"Unlock additional screen resolutions"; MinfpsLbl->Caption = L"Force high FPS / Fix stuttering on Freesync/G-Sync"; - FixpitchLbl->Caption = L"Fix diagonally displayed drawing issues"; + SinglecpuLbl->Caption = L"Fix bad performance and sound issues"; NonexclusiveLbl->Caption = L"Fix invisible videos / UI elements"; RendererCbx->Items->Clear(); @@ -437,18 +615,30 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) MaxgameticksCbx->AddItem(L"Emulate 60hz refresh rate monitor", NULL); MaxgameticksCbx->AddItem(L"1000 ticks per second", NULL); MaxgameticksCbx->AddItem(L"500 ticks per second", NULL); + MaxgameticksCbx->AddItem(L"250 ticks per second", NULL); + MaxgameticksCbx->AddItem(L"125 ticks per second", NULL); MaxgameticksCbx->AddItem(L"60 ticks per second", NULL); MaxgameticksCbx->AddItem(L"30 ticks per second", NULL); MaxgameticksCbx->AddItem(L"25 ticks per second", NULL); MaxgameticksCbx->AddItem(L"15 ticks per second", NULL); */ } + + ToggleWindowedKeyLbl->Caption = GetKeyText(VK_MENU) + L" +"; + MaximizeWindowKeyLbl->Caption = GetKeyText(VK_MENU) + L" +"; + UnlockCursor1KeyLbl->Caption = GetKeyText(VK_CONTROL) + L" +"; + UnlockCursor2KeyLbl->Caption = "R " + GetKeyText(VK_MENU) + L" +"; + + ConfigForm->Caption += + " (" + TPath::GetFileName( + TPath::GetDirectoryName(Application->ExeName)) + ")"; } void __fastcall TConfigForm::DisplayBtnClick(TObject *Sender) { DisplayPnl->Visible = true; AdvancedPnl->Visible = false; + HotkeyPnl->Visible = false; CompatibilityPnl->Visible = false; } @@ -456,6 +646,15 @@ void __fastcall TConfigForm::AdvancedBtnClick(TObject *Sender) { AdvancedPnl->Visible = true; DisplayPnl->Visible = false; + HotkeyPnl->Visible = false; + CompatibilityPnl->Visible = false; +} + +void __fastcall TConfigForm::HotkeyBtnClick(TObject *Sender) +{ + HotkeyPnl->Visible = true; + AdvancedPnl->Visible = false; + DisplayPnl->Visible = false; CompatibilityPnl->Visible = false; } @@ -464,11 +663,49 @@ void __fastcall TConfigForm::CompatibilityBtnClick(TObject *Sender) CompatibilityPnl->Visible = true; AdvancedPnl->Visible = false; DisplayPnl->Visible = false; + HotkeyPnl->Visible = false; } void __fastcall TConfigForm::FormCreate(TObject *Sender) { - auto *ini = new TIniFile(".\\ddraw.ini"); + /* Let cnc-ddraw create a new dd-hd.ini if it doesn't exist */ + if (FileExists(".\\ddraw.dll") && !FileExists(".\\dd-hd.ini")) { + + SetEnvironmentVariableW(L"cnc_ddraw_config_init", L"1"); + + HMODULE ddraw = LoadLibraryW(L".\\ddraw.dll"); + + if (ddraw) { + + void (WINAPI* dd_create)(void*, void**, void*); + + dd_create = + (void (WINAPI*)(void*, void**, void*)) + GetProcAddress(ddraw, "DirectDrawCreate"); + + if (dd_create && GetProcAddress(ddraw, "GameHandlesClose")) { + + void *buf; + dd_create(NULL, &buf, NULL); + } + + FreeLibrary(ddraw); + } + } + + auto *ini = new TIniFile(".\\dd-hd.ini"); + + if (ini->ReadString("ddraw", "configtheme", "Windows10") == "Cobalt XEMedia") { + + ThemePnl->Color = (TColor)RGB(243, 243, 243); + DisplayPnl->StyleElements = TStyleElements(seFont + seClient + seBorder); + AdvancedPnl->StyleElements = TStyleElements(seFont + seClient + seBorder); + HotkeyPnl->StyleElements = TStyleElements(seFont + seClient + seBorder); + CompatibilityPnl->StyleElements = TStyleElements(seFont + seClient + seBorder); + + MenuPnl->StyleElements = TStyleElements(seFont); + MenuPnl->Color = (TColor)RGB(31, 31, 31); + } ApplyTranslation(ini); @@ -499,8 +736,28 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) auto renderer = LowerCase(ini->ReadString("ddraw", "renderer", "auto")); - if (StartsStr("d", renderer)) { + if (renderer == "direct3d9on12") { + RendererCbx->AddItem(L"Direct3D 12 (9On12)", NULL); + RendererCbx->ItemIndex = 4; + + ShaderLbl->Caption = + ReplaceStr(ShaderLbl->Caption, "OpenGL", "Direct3D"); + + ShaderD3DCbx->Visible = true; + ShaderCbx->Visible = false; + } + else if (renderer == "openglcore") { + RendererCbx->AddItem(L"OpenGL Core", NULL); + RendererCbx->ItemIndex = 4; + } + else if (StartsStr("d", renderer)) { RendererCbx->ItemIndex = 1; + + ShaderLbl->Caption = + ReplaceStr(ShaderLbl->Caption, "OpenGL", "Direct3D"); + + ShaderD3DCbx->Visible = true; + ShaderCbx->Visible = false; } else if (StartsStr("o", renderer)) { RendererCbx->ItemIndex = 2; @@ -521,14 +778,45 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) for (int i = 0; i < list.Length; i++) ShaderCbx->AddItem(list[i], NULL); - - auto shader = ini->ReadString("ddraw", "shader", ""); - ShaderCbx->ItemIndex = ShaderCbx->Items->IndexOf(shader); } catch (...) { } + if (ShaderCbx->Items->Count == 0) { + ShaderCbx->AddItem("Nearest neighbor", NULL); + ShaderCbx->AddItem("Bilinear", NULL); + ShaderCbx->AddItem("Bicubic", NULL); + ShaderCbx->AddItem("Lanczos", NULL); + ShaderCbx->AddItem("xBR-lv2", NULL); + } + + auto shader = ini->ReadString("ddraw", "shader", "Bicubic"); + ShaderCbx->ItemIndex = ShaderCbx->Items->IndexOf(shader); + + if (ShaderCbx->ItemIndex == -1) { + ShaderCbx->AddItem(shader, NULL); + ShaderCbx->ItemIndex = ShaderCbx->Items->Count - 1; + } + + int d3d9_filter = ini->ReadInteger("ddraw", "d3d9_filter", 2); + + switch (d3d9_filter) { + case 0: + ShaderD3DCbx->ItemIndex = 0; + break; + case 1: + ShaderD3DCbx->ItemIndex = 1; + break; + case 2: + default: + ShaderD3DCbx->ItemIndex = 2; + break; + case 3: + ShaderD3DCbx->ItemIndex = 3; + break; + } + Maxfps = ini->ReadInteger("ddraw", "maxfps", -1); MaxfpsChk->State = Maxfps != 0 ? tssOn : tssOff; @@ -538,6 +826,23 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) Savesettings = ini->ReadInteger("ddraw", "savesettings", 1); SavesettingsChk->State = Savesettings != 0 ? tssOn : tssOff; + /* Hotkey Settings */ + + ToggleWindowedEdt->Text = + GetKeyText(Byte(ini->ReadInteger("ddraw", "keytogglefullscreen", 0x0D))); + + MaximizeWindowEdt->Text = + GetKeyText(Byte(ini->ReadInteger("ddraw", "keytogglemaximize", 0x22))); + + UnlockCursor1Edt->Text = + GetKeyText(Byte(ini->ReadInteger("ddraw", "keyunlockcursor1", 0x09))); + + UnlockCursor2Edt->Text = + GetKeyText(Byte(ini->ReadInteger("ddraw", "keyunlockcursor2", 0xA3))); + + ScreenshotEdt->Text = + GetKeyText(Byte(ini->ReadInteger("ddraw", "keyscreenshot", 0x2C))); + /* Compatibility Settings */ int maxgameticks = ini->ReadInteger("ddraw", "maxgameticks", 0); @@ -558,35 +863,48 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) case 500: MaxgameticksCbx->ItemIndex = 4; break; - case 60: + case 250: MaxgameticksCbx->ItemIndex = 5; break; - case 30: + case 125: MaxgameticksCbx->ItemIndex = 6; break; - case 25: + case 60: MaxgameticksCbx->ItemIndex = 7; break; - case 15: + case 30: MaxgameticksCbx->ItemIndex = 8; break; + case 25: + MaxgameticksCbx->ItemIndex = 9; + break; + case 15: + MaxgameticksCbx->ItemIndex = 10; + break; default: MaxgameticksCbx->AddItem(IntToStr(maxgameticks), NULL); - MaxgameticksCbx->ItemIndex = 9; + MaxgameticksCbx->ItemIndex = 11; break; } NoactivateappChk->State = GetBool(ini, "noactivateapp", false) ? tssOn : tssOff; - Hook = ini->ReadInteger("ddraw", "hook", 4); - HookChk->State = Hook == 2 ? tssOn : tssOff; + Resolutions = ini->ReadInteger("ddraw", "resolutions", 0); + ResolutionsChk->State = Resolutions == 2 ? tssOn : tssOff; Minfps = ini->ReadInteger("ddraw", "minfps", 0); MinfpsChk->State = Minfps != 0 ? tssOn : tssOff; - FixpitchChk->State = GetBool(ini, "fixpitch", false) ? tssOn : tssOff; + SinglecpuChk->State = GetBool(ini, "singlecpu", true) ? tssOff : tssOn; NonexclusiveChk->State = GetBool(ini, "nonexclusive", false) ? tssOn : tssOff; + CompatibilityBtn->Visible = !GetBool(ini, "hide_compat_tab", false); + + RestoreDefaultsBtn->Visible = + FileExists(".\\ddraw.dll") && + FileExists(".\\dd-hd.ini") && + GetBool(ini, "allow_reset", true); + delete ini; Initialized = true; @@ -597,7 +915,7 @@ void TConfigForm::SaveSettings() if (!Initialized) return; - auto *ini = new TIniFile(".\\ddraw.ini"); + auto *ini = new TIniFile(".\\dd-hd.ini"); /* Display Settings */ @@ -605,6 +923,7 @@ void TConfigForm::SaveSettings() case 0: ini->WriteString("ddraw", "windowed", "false"); ini->WriteString("ddraw", "fullscreen", "false"); + ini->WriteString("ddraw", "toggle_borderless", "false"); break; case 1: ini->WriteString("ddraw", "windowed", "false"); @@ -613,6 +932,7 @@ void TConfigForm::SaveSettings() case 2: ini->WriteString("ddraw", "windowed", "true"); ini->WriteString("ddraw", "fullscreen", "true"); + ini->WriteString("ddraw", "toggle_borderless", "true"); break; case 3: ini->WriteString("ddraw", "windowed", "true"); @@ -657,12 +977,22 @@ void TConfigForm::SaveSettings() case 3: ini->WriteString("ddraw", "renderer", "gdi"); break; + case 4: + if (RendererCbx->Text == "OpenGL Core") { + ini->WriteString("ddraw", "renderer", "openglcore"); + } + else { + ini->WriteString("ddraw", "renderer", "direct3d9on12"); + } + break; default: break; } ini->WriteString("ddraw", "shader", ShaderCbx->Text); + ini->WriteInteger("ddraw", "d3d9_filter", ShaderD3DCbx->ItemIndex); + int maxfps = Maxfps == 0 ? -1 : Maxfps; ini->WriteInteger( @@ -694,6 +1024,33 @@ void TConfigForm::SaveSettings() ini->WriteInteger("ddraw", "posY", -32000); } + /* Hotkey Settings */ + + ini->WriteString( + "ddraw", + "keytogglefullscreen", + "0x" + IntToHex(Byte(GetKeyCode(ToggleWindowedEdt->Text)))); + + ini->WriteString( + "ddraw", + "keytogglemaximize", + "0x" + IntToHex(Byte(GetKeyCode(MaximizeWindowEdt->Text)))); + + ini->WriteString( + "ddraw", + "keyunlockcursor1", + "0x" + IntToHex(Byte(GetKeyCode(UnlockCursor1Edt->Text)))); + + ini->WriteString( + "ddraw", + "keyunlockcursor2", + "0x" + IntToHex(Byte(GetKeyCode(UnlockCursor2Edt->Text)))); + + ini->WriteString( + "ddraw", + "keyscreenshot", + "0x" + IntToHex(Byte(GetKeyCode(ScreenshotEdt->Text)))); + /* Compatibility Settings */ switch(MaxgameticksCbx->ItemIndex) { @@ -713,18 +1070,24 @@ void TConfigForm::SaveSettings() ini->WriteInteger("ddraw", "maxgameticks", 500); break; case 5: - ini->WriteInteger("ddraw", "maxgameticks", 60); + ini->WriteInteger("ddraw", "maxgameticks", 250); break; case 6: - ini->WriteInteger("ddraw", "maxgameticks", 30); + ini->WriteInteger("ddraw", "maxgameticks", 125); break; case 7: - ini->WriteInteger("ddraw", "maxgameticks", 25); + ini->WriteInteger("ddraw", "maxgameticks", 60); break; case 8: - ini->WriteInteger("ddraw", "maxgameticks", 15); + ini->WriteInteger("ddraw", "maxgameticks", 30); break; case 9: + ini->WriteInteger("ddraw", "maxgameticks", 25); + break; + case 10: + ini->WriteInteger("ddraw", "maxgameticks", 15); + break; + case 11: ini->WriteString("ddraw", "maxgameticks", MaxgameticksCbx->Text); break; default: @@ -736,15 +1099,12 @@ void TConfigForm::SaveSettings() "noactivateapp", NoactivateappChk->State == tssOn ? "true" : "false"); - int hook = Hook != 2 ? Hook : 4; + int resolutions = Resolutions != 2 ? Resolutions : 0; ini->WriteInteger( "ddraw", - "hook", - HookChk->State == tssOn ? 2 : hook); - - if (HookChk->State == tssOn && Hook != 2) - ini->WriteString("ddraw", "renderer", "gdi"); + "resolutions", + ResolutionsChk->State == tssOn ? 2 : resolutions); int minfps = Minfps == 0 ? -1 : Minfps; @@ -755,8 +1115,8 @@ void TConfigForm::SaveSettings() ini->WriteString( "ddraw", - "fixpitch", - FixpitchChk->State == tssOn ? "true" : "false"); + "singlecpu", + SinglecpuChk->State == tssOn ? "false" : "true"); ini->WriteString( "ddraw", @@ -766,6 +1126,110 @@ void TConfigForm::SaveSettings() delete ini; } +void __fastcall TConfigForm::FormActivate(TObject *Sender) +{ + /* Detect wine (Linux/macOS) and create the needed dll override */ + if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version")) + return; + + TRegistry* reg = new TRegistry(KEY_READ); + reg->RootKey = HKEY_CURRENT_USER; + + if (reg->OpenKey("Software\\Wine\\DllOverrides\\", true)) { + + if (!reg->ValueExists("ddraw")) { + + reg->CloseKey(); + + if (Application->MessageBox( + L"cnc-ddraw requires a dll override in winecfg, " + "would you like to add it now?", + L"cnc-ddraw", + MB_YESNO) == IDNO) { + + reg->Free(); + return; + } + + reg->Access = KEY_WRITE; + + if (reg->OpenKey("Software\\Wine\\DllOverrides\\", true)) { + + reg->WriteString("ddraw", "native,builtin"); + reg->CloseKey(); + } + } + else + reg->CloseKey(); + } + + reg->Free(); +} + +void __fastcall TConfigForm::HotkeyEdtKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) +{ + TEdit *edit = static_cast(Sender); + + if (Key == VK_DELETE || Key == VK_BACK) { + edit->Text = L""; + } + else if (GetAsyncKeyState(VK_RCONTROL) & 0x8000) { + edit->Text = GetKeyText(VK_RCONTROL); + } + else { + edit->Text = GetKeyText(Key); + } +} + +void __fastcall TConfigForm::HotkeyEdtKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) +{ + TEdit *edit = static_cast(Sender); + + if (Key == VK_SNAPSHOT || Key == VK_TAB) { + edit->Text = GetKeyText(Key); + } + + SaveSettings(); +} + +WORD TConfigForm::GetKeyCode(System::UnicodeString key) +{ + if (key == L"PrtScn") { + return VK_SNAPSHOT; + } + + if (key == L"Pause_") { + return VK_PAUSE; + } + + if (key == L"R " + ShortCutToText(VK_CONTROL)) { + return VK_RCONTROL; + } + + return TextToShortCut(key); +} + +System::UnicodeString TConfigForm::GetKeyText(WORD key) +{ + if (key == VK_SNAPSHOT) { + return L"PrtScn"; + } + + if (key == VK_PAUSE) { + return L"Pause_"; + } + + if (key == VK_RCONTROL) { + return L"R " + ShortCutToText(VK_CONTROL); + } + + if (key == VK_RSHIFT) { + return ShortCutToText(VK_SHIFT); + } + + return ShortCutToText(key); +} + bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValue) { auto s = LowerCase(ini->ReadString("ddraw", key, defValue ? "true" : "false")); @@ -799,12 +1263,36 @@ void __fastcall TConfigForm::DevmodeChkClick(TObject *Sender) void __fastcall TConfigForm::RendererCbxChange(TObject *Sender) { + if (ContainsStr(RendererCbx->Text, "Direct3D")) { + + ShaderLbl->Caption = + ReplaceStr(ShaderLbl->Caption, "OpenGL", "Direct3D"); + + ShaderD3DCbx->Visible = true; + ShaderCbx->Visible = false; + } + else { + ShaderLbl->Caption = + ReplaceStr(ShaderLbl->Caption, "Direct3D", "OpenGL"); + + ShaderCbx->Visible = true; + ShaderD3DCbx->Visible = false; + } + SaveSettings(); } void __fastcall TConfigForm::ShaderCbxChange(TObject *Sender) { - RendererCbx->ItemIndex = 2; + if (RendererCbx->Text != "OpenGL Core") { + RendererCbx->ItemIndex = 2; + } + + SaveSettings(); +} + +void __fastcall TConfigForm::ShaderD3DCbxChange(TObject *Sender) +{ SaveSettings(); } @@ -838,7 +1326,7 @@ void __fastcall TConfigForm::NoactivateappChkClick(TObject *Sender) SaveSettings(); } -void __fastcall TConfigForm::HookChkClick(TObject *Sender) +void __fastcall TConfigForm::ResolutionsChkClick(TObject *Sender) { SaveSettings(); } @@ -848,7 +1336,7 @@ void __fastcall TConfigForm::MinfpsChkClick(TObject *Sender) SaveSettings(); } -void __fastcall TConfigForm::FixpitchChkClick(TObject *Sender) +void __fastcall TConfigForm::SinglecpuChkClick(TObject *Sender) { SaveSettings(); } @@ -861,6 +1349,6 @@ void __fastcall TConfigForm::NonexclusiveChkClick(TObject *Sender) void __fastcall TConfigForm::PboxPaint(TObject *Sender) { TPaintBox *pbox = static_cast(Sender); - pbox->Canvas->Rectangle(pbox->ClientRect); + //pbox->Canvas->Rectangle(pbox->ClientRect); } diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 0e04389..a69b94f 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -4,9 +4,9 @@ object ConfigForm: TConfigForm BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'cnc-ddraw config' - ClientHeight = 475 - ClientWidth = 708 - Color = clBlack + ClientHeight = 476 + ClientWidth = 741 + Color = clMenu Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 @@ -2677,16 +2677,397 @@ object ConfigForm: TConfigForm 61C0650530766087F0B9DE67A1EF3B173173597F3B695CC608E0B202F8FC22D7 BBBF4CD8CBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCBB88CCB B88CB18EFF1FA2974C1C31AF16A40000000049454E44AE426082} - OldCreateOrder = False Position = poDesktopCenter + OnActivate = FormActivate OnCreate = FormCreate - PixelsPerInch = 96 + DesignSize = ( + 741 + 476) TextHeight = 13 - object AdvancedPnl: TPanel - Left = 201 + object DisplayPnl: TPanel + Left = 233 Top = 8 Width = 499 Height = 465 + Anchors = [akLeft, akTop, akRight, akBottom] + BevelOuter = bvNone + Color = clWhite + ParentBackground = False + ShowCaption = False + TabOrder = 1 + StyleElements = [seFont, seBorder] + ExplicitWidth = 495 + ExplicitHeight = 464 + DesignSize = ( + 499 + 465) + object PresentationLbl: TLabel + Left = 40 + Top = 28 + Width = 87 + Height = 21 + Caption = 'Presentation' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object MaintasLbl: TLabel + Left = 40 + Top = 105 + Width = 145 + Height = 21 + Margins.Top = 18 + Caption = 'Maintain aspect ratio' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object VsyncLbl: TLabel + Left = 40 + Top = 173 + Width = 93 + Height = 21 + Margins.Top = 18 + Caption = 'Enable VSync' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object AdjmouseLbl: TLabel + Left = 40 + Top = 241 + Width = 168 + Height = 21 + Margins.Top = 18 + Caption = 'Adjust mouse sensitivity' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object DevmodeLbl: TLabel + Left = 40 + Top = 309 + Width = 216 + Height = 21 + Margins.Top = 18 + Caption = 'Lock cursor to window / screen' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object PresentationPbox: TPaintBox + Left = 40 + Top = 54 + Width = 282 + Height = 31 + OnPaint = PboxPaint + end + object LanguageImg: TImage + Left = 453 + Top = 8 + Width = 16 + Height = 11 + Anchors = [akTop, akRight] + Picture.Data = { + 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000100000 + 000B0802000000F9809A6E0000000467414D410000AFC837058AE90000001974 + 455874536F6674776172650041646F626520496D616765526561647971C9653C + 000001B34944415478DA4D51DF4B5451109EB3B95010813E583ED8D28B7F8356 + 6A1A2BD5530F81AE108837E9414390681F841235FF00115C0A5A82AD1E7C1172 + B7A050597C102C05E5C2222CE5A2D8522CABBBDD7BEEF935CE5DF1E2F031F30D + C37C67660EB39EAE4160C68051000200C9BF897C47E7FFBFBF7F283735508D51 + C3DBF9B65416639DE6E34AA8BF1DDF67D9E3DB2AB95A37D8A51101D12005F049 + 26B3E03774C65A3F658D3640100A35FA842BFC09E3502AC3F111542BE038ACFF + 7EEEC71A35AC74F4B6F7DDD23DAF59262EA3D375E917CE9DE94B3683D24B61CE + ACBE7ED475E76D7B8B5943D98ED8CDE432BDE06B2B091EA20D9E7236D4E11C09 + 43B58A9C8310A1C187EBF626B3ACAF89C4DDEE576629CEA35317D3F1E36B33E2 + F798691ED92E25DB4EE56907F2E5AB8D797F07EB4B6B5FF4DD374DC246C20E16 + B597833D0D05ADAECCF8DA9E4720121AEEFD9CCFB14221DFD4745D4A19289D27 + 01775DF74618E616534C4F3E63F71E617A198B45289769621F9C234D2F040644 + CA0BCF073EECFF62BBBB3B91484B251CBE2C7870F5F3A694E4BC01605F6BD330 + 3BC10E9E3CA0E3041F0967840354009C1A642D3DAD9E00C53A4C480864283400 + 00000049454E44AE426082} + Stretch = True + Visible = False + OnClick = LanguageImgClick + end + object PresentationCbx: TComboBox + Left = 41 + Top = 55 + Width = 280 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 1 + OnChange = PresentationCbxChange + Items.Strings = ( + 'Fullscreen' + 'Fullscreen Upscaled' + 'Borderless' + 'Windowed') + end + object MaintasChk: TToggleSwitch + Left = 40 + Top = 132 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 0 + OnClick = MaintasChkClick + end + object VsyncChk: TToggleSwitch + Left = 40 + Top = 200 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 2 + OnClick = VsyncChkClick + end + object AdjmouseChk: TToggleSwitch + Left = 40 + Top = 268 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 3 + OnClick = AdjmouseChkClick + end + object DevmodeChk: TToggleSwitch + Left = 40 + Top = 336 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 4 + OnClick = DevmodeChkClick + end + object ThemePnl: TPanel + Left = 475 + Top = 8 + Width = 16 + Height = 11 + Anchors = [akTop, akRight] + BevelOuter = bvNone + Color = 2039583 + ParentBackground = False + TabOrder = 5 + StyleElements = [seFont, seBorder] + OnClick = ThemePnlClick + ExplicitLeft = 471 + end + end + object CompatibilityPnl: TPanel + Left = 233 + Top = 8 + Width = 499 + Height = 465 + Anchors = [akLeft, akTop, akRight, akBottom] + BevelOuter = bvNone + Color = clWhite + ParentBackground = False + ShowCaption = False + TabOrder = 3 + Visible = False + StyleElements = [seFont, seBorder] + ExplicitWidth = 495 + ExplicitHeight = 464 + object MaxgameticksLbl: TLabel + Left = 40 + Top = 28 + Width = 123 + Height = 21 + Caption = 'Limit game speed' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object NoactivateappLbl: TLabel + Left = 40 + Top = 105 + Width = 129 + Height = 21 + Margins.Top = 18 + Caption = 'Fix broken Alt+Tab' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object ResolutionsLbl: TLabel + Left = 40 + Top = 173 + Width = 251 + Height = 21 + Margins.Top = 18 + Caption = 'Unlock additional screen resolutions' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object MinfpsLbl: TLabel + Left = 40 + Top = 241 + Width = 350 + Height = 21 + Margins.Top = 18 + Caption = 'Force high FPS / Fix stuttering on Freesync/G-Sync' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object SinglecpuLbl: TLabel + Left = 40 + Top = 309 + Width = 265 + Height = 21 + Margins.Top = 18 + Caption = 'Fix bad performance and sound issues' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object NonexclusiveLbl: TLabel + Left = 40 + Top = 377 + Width = 225 + Height = 21 + Margins.Top = 18 + Caption = 'Fix invisible videos / UI elements' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object MaxgameticksPbox: TPaintBox + Left = 40 + Top = 54 + Width = 394 + Height = 31 + OnPaint = PboxPaint + end + object MaxgameticksCbx: TComboBox + Left = 41 + Top = 55 + Width = 392 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + DropDownCount = 12 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 0 + OnChange = MaxgameticksCbxChange + Items.Strings = ( + 'No limit' + 'Sync with monitor refresh rate' + 'Emulate 60hz refresh rate monitor' + '1000 ticks per second' + '500 ticks per second' + '250 ticks per second' + '125 ticks per second' + '60 ticks per second' + '30 ticks per second' + '25 ticks per second' + '15 ticks per second') + end + object NoactivateappChk: TToggleSwitch + Left = 40 + Top = 132 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 1 + OnClick = NoactivateappChkClick + end + object ResolutionsChk: TToggleSwitch + Left = 40 + Top = 200 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 2 + OnClick = ResolutionsChkClick + end + object MinfpsChk: TToggleSwitch + Left = 40 + Top = 268 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 3 + OnClick = MinfpsChkClick + end + object SinglecpuChk: TToggleSwitch + Left = 40 + Top = 336 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 4 + OnClick = SinglecpuChkClick + end + object NonexclusiveChk: TToggleSwitch + Left = 40 + Top = 404 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 5 + OnClick = NonexclusiveChkClick + end + end + object AdvancedPnl: TPanel + Left = 233 + Top = 8 + Width = 499 + Height = 465 + Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite ParentBackground = False @@ -2694,6 +3075,8 @@ object ConfigForm: TConfigForm TabOrder = 2 Visible = False StyleElements = [seFont, seBorder] + ExplicitWidth = 495 + ExplicitHeight = 464 object RendererLbl: TLabel Left = 40 Top = 28 @@ -2706,7 +3089,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object SavesettingsLbl: TLabel Left = 40 @@ -2721,7 +3103,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object ShaderLbl: TLabel Left = 40 @@ -2736,7 +3117,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object MaxfpsLbl: TLabel Left = 40 @@ -2751,7 +3131,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object BorderLbl: TLabel Left = 40 @@ -2766,7 +3145,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object BoxingLbl: TLabel Left = 40 @@ -2781,7 +3159,6 @@ object ConfigForm: TConfigForm Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end object RendererPbox: TPaintBox Left = 40 @@ -2797,6 +3174,31 @@ object ConfigForm: TConfigForm Height = 31 OnPaint = PboxPaint end + object ShaderD3DCbx: TComboBox + Left = 41 + Top = 132 + Width = 425 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + DropDownCount = 10 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 6 + Visible = False + OnChange = ShaderD3DCbxChange + Items.Strings = ( + 'Nearest neighbor' + 'Bilinear' + 'Bicubic (Catmull-Rom)' + 'Lanczos') + end object RendererCbx: TComboBox Left = 41 Top = 55 @@ -2876,434 +3278,331 @@ object ConfigForm: TConfigForm OnClick = BoxingChkClick end end - object DisplayPnl: TPanel - Left = 201 + object HotkeyPnl: TPanel + Left = 233 Top = 8 Width = 499 Height = 465 + Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite ParentBackground = False ShowCaption = False - TabOrder = 1 - StyleElements = [seFont, seBorder] - DesignSize = ( - 499 - 465) - object PresentationLbl: TLabel - Left = 40 - Top = 28 - Width = 87 - Height = 21 - Caption = 'Presentation' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object MaintasLbl: TLabel - Left = 40 - Top = 105 - Width = 145 - Height = 21 - Margins.Top = 18 - Caption = 'Maintain aspect ratio' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object VsyncLbl: TLabel - Left = 40 - Top = 173 - Width = 93 - Height = 21 - Margins.Top = 18 - Caption = 'Enable VSync' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object AdjmouseLbl: TLabel - Left = 40 - Top = 241 - Width = 168 - Height = 21 - Margins.Top = 18 - Caption = 'Adjust mouse sensitivity' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object DevmodeLbl: TLabel - Left = 40 - Top = 309 - Width = 216 - Height = 21 - Margins.Top = 18 - Caption = 'Lock cursor to window / screen' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object PresentationPbox: TPaintBox - Left = 40 - Top = 54 - Width = 282 - Height = 31 - OnPaint = PboxPaint - end - object LanguageImg: TImage - Left = 477 - Top = 8 - Width = 16 - Height = 11 - Anchors = [akTop, akRight] - Picture.Data = { - 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000100000 - 000B0802000000F9809A6E0000000467414D410000AFC837058AE90000001974 - 455874536F6674776172650041646F626520496D616765526561647971C9653C - 000001B34944415478DA4D51DF4B5451109EB3B95010813E583ED8D28B7F8356 - 6A1A2BD5530F81AE108837E9414390681F841235FF00115C0A5A82AD1E7C1172 - B7A050597C102C05E5C2222CE5A2D8522CABBBDD7BEEF935CE5DF1E2F031F30D - C37C67660EB39EAE4160C68051000200C9BF897C47E7FFBFBF7F283735508D51 - C3DBF9B65416639DE6E34AA8BF1DDF67D9E3DB2AB95A37D8A51101D12005F049 - 26B3E03774C65A3F658D3640100A35FA842BFC09E3502AC3F111542BE038ACFF - 7EEEC71A35AC74F4B6F7DDD23DAF59262EA3D375E917CE9DE94B3683D24B61CE - ACBE7ED475E76D7B8B5943D98ED8CDE432BDE06B2B091EA20D9E7236D4E11C09 - 43B58A9C8310A1C187EBF626B3ACAF89C4DDEE576629CEA35317D3F1E36B33E2 - F798691ED92E25DB4EE56907F2E5AB8D797F07EB4B6B5FF4DD374DC246C20E16 - B597833D0D05ADAECCF8DA9E4720121AEEFD9CCFB14221DFD4745D4A19289D27 - 01775DF74618E616534C4F3E63F71E617A198B45289769621F9C234D2F040644 - CA0BCF073EECFF62BBBB3B91484B251CBE2C7870F5F3A694E4BC01605F6BD330 - 3BC10E9E3CA0E3041F0967840354009C1A642D3DAD9E00C53A4C480864283400 - 00000049454E44AE426082} - Stretch = True - Visible = False - OnClick = LanguageImgClick - ExplicitLeft = 569 - end - object PresentationCbx: TComboBox - Left = 41 - Top = 55 - Width = 280 - Height = 29 - BevelEdges = [] - BevelInner = bvNone - BevelOuter = bvSpace - Style = csDropDownList - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - TabOrder = 1 - OnChange = PresentationCbxChange - Items.Strings = ( - 'Fullscreen' - 'Fullscreen Upscaled' - 'Borderless' - 'Windowed') - end - object MaintasChk: TToggleSwitch - Left = 40 - Top = 132 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 0 - OnClick = MaintasChkClick - end - object VsyncChk: TToggleSwitch - Left = 40 - Top = 200 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 2 - OnClick = VsyncChkClick - end - object AdjmouseChk: TToggleSwitch - Left = 40 - Top = 268 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 3 - OnClick = AdjmouseChkClick - end - object DevmodeChk: TToggleSwitch - Left = 40 - Top = 336 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 4 - OnClick = DevmodeChkClick - end - end - object CompatibilityPnl: TPanel - Left = 201 - Top = 8 - Width = 499 - Height = 465 - BevelOuter = bvNone - Color = clWhite - ParentBackground = False - ShowCaption = False - TabOrder = 3 + TabOrder = 4 Visible = False StyleElements = [seFont, seBorder] - object MaxgameticksLbl: TLabel + ExplicitWidth = 495 + ExplicitHeight = 464 + object ToggleWindowedLbl: TLabel Left = 40 - Top = 28 - Width = 123 - Height = 21 - Caption = 'Limit game speed' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - StyleElements = [seClient, seBorder] - end - object NoactivateappLbl: TLabel - Left = 40 - Top = 105 - Width = 129 + Top = 27 + Width = 165 Height = 21 Margins.Top = 18 - Caption = 'Fix broken Alt+Tab' + Caption = 'Toggle windowed mode' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end - object HookLbl: TLabel + object ToggleWindowedKeyLbl: TLabel + Left = 50 + Top = 60 + Width = 34 + Height = 21 + Margins.Top = 8 + Caption = 'Alt +' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object MaximizeWindowLbl: TLabel Left = 40 - Top = 173 - Width = 281 + Top = 107 + Width = 125 Height = 21 Margins.Top = 18 - Caption = 'Fix broken windowed mode or upscaling' + Caption = 'Maximize window' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end - object MinfpsLbl: TLabel + object MaximizeWindowKeyLbl: TLabel + Left = 50 + Top = 139 + Width = 34 + Height = 21 + Margins.Top = 8 + Caption = 'Alt +' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object UnlockCursor1Lbl: TLabel Left = 40 - Top = 241 - Width = 350 + Top = 186 + Width = 109 Height = 21 Margins.Top = 18 - Caption = 'Force high FPS / Fix stuttering on Freesync/G-Sync' + Caption = 'Unlock cursor 1' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end - object FixpitchLbl: TLabel + object UnlockCursor1KeyLbl: TLabel + Left = 50 + Top = 218 + Width = 40 + Height = 21 + Margins.Top = 8 + Caption = 'Ctrl +' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object UnlockCursor2Lbl: TLabel Left = 40 - Top = 309 - Width = 272 + Top = 265 + Width = 109 Height = 21 Margins.Top = 18 - Caption = 'Fix diagonally displayed drawing issues' + Caption = 'Unlock cursor 2' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end - object NonexclusiveLbl: TLabel - Left = 40 - Top = 377 - Width = 225 + object UnlockCursor2KeyLbl: TLabel + Left = 50 + Top = 297 + Width = 48 Height = 21 - Margins.Top = 18 - Caption = 'Fix invisible videos / UI elements' + Margins.Top = 8 + Caption = 'R Alt +' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False - StyleElements = [seClient, seBorder] end - object MaxgameticksPbox: TPaintBox - Left = 40 - Top = 54 - Width = 394 - Height = 31 - OnPaint = PboxPaint - end - object MaxgameticksCbx: TComboBox + object ScreenshotLbl: TLabel Left = 41 - Top = 55 - Width = 392 - Height = 29 - BevelEdges = [] - BevelInner = bvNone - BevelOuter = bvSpace - Style = csDropDownList - DropDownCount = 10 + Top = 344 + Width = 77 + Height = 21 + Margins.Top = 18 + Caption = 'Screenshot' Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 Font.Name = 'Segoe UI' Font.Style = [] ParentFont = False + end + object ToggleWindowedEdt: TEdit + Left = 137 + Top = 57 + Width = 217 + Height = 29 + Margins.Top = 5 + TabStop = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + ReadOnly = True TabOrder = 0 - OnChange = MaxgameticksCbxChange - Items.Strings = ( - 'No limit' - 'Sync with monitor refresh rate' - 'Emulate 60hz refresh rate monitor' - '1000 ticks per second' - '500 ticks per second' - '60 ticks per second' - '30 ticks per second' - '25 ticks per second' - '15 ticks per second') + OnKeyDown = HotkeyEdtKeyDown + OnKeyUp = HotkeyEdtKeyUp end - object NoactivateappChk: TToggleSwitch - Left = 40 - Top = 132 - Width = 50 - Height = 20 - ShowStateCaption = False + object MaximizeWindowEdt: TEdit + Left = 137 + Top = 136 + Width = 217 + Height = 29 + Margins.Top = 5 + TabStop = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + ReadOnly = True TabOrder = 1 - OnClick = NoactivateappChkClick + OnKeyDown = HotkeyEdtKeyDown + OnKeyUp = HotkeyEdtKeyUp end - object HookChk: TToggleSwitch - Left = 40 - Top = 200 - Width = 50 - Height = 20 - ShowStateCaption = False + object UnlockCursor1Edt: TEdit + Left = 137 + Top = 215 + Width = 217 + Height = 29 + Margins.Top = 5 + TabStop = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + ReadOnly = True TabOrder = 2 - OnClick = HookChkClick + OnKeyDown = HotkeyEdtKeyDown + OnKeyUp = HotkeyEdtKeyUp end - object MinfpsChk: TToggleSwitch - Left = 40 - Top = 268 - Width = 50 - Height = 20 - ShowStateCaption = False + object UnlockCursor2Edt: TEdit + Left = 137 + Top = 294 + Width = 217 + Height = 29 + Margins.Top = 5 + TabStop = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + ReadOnly = True TabOrder = 3 - OnClick = MinfpsChkClick + OnKeyDown = HotkeyEdtKeyDown + OnKeyUp = HotkeyEdtKeyUp end - object FixpitchChk: TToggleSwitch - Left = 40 - Top = 336 - Width = 50 - Height = 20 - ShowStateCaption = False + object ScreenshotEdt: TEdit + Left = 137 + Top = 373 + Width = 217 + Height = 29 + Margins.Top = 5 + TabStop = False + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + ReadOnly = True TabOrder = 4 - OnClick = FixpitchChkClick - end - object NonexclusiveChk: TToggleSwitch - Left = 40 - Top = 404 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 5 - OnClick = NonexclusiveChkClick + OnKeyDown = HotkeyEdtKeyDown + OnKeyUp = HotkeyEdtKeyUp end end object MenuPnl: TPanel Left = 0 Top = 8 - Width = 201 - Height = 465 + Width = 233 + Height = 468 + Anchors = [akLeft, akTop, akBottom] BevelOuter = bvNone - Color = clBlack + Color = clMenu ParentBackground = False TabOrder = 0 + ExplicitHeight = 467 DesignSize = ( - 201 - 465) + 233 + 468) object DisplayBtn: TSpeedButton - Left = 5 + Left = 0 Top = 8 - Width = 187 + Width = 227 Height = 41 Anchors = [akLeft, akTop, akRight] Caption = 'Display Settings' Flat = True Font.Charset = DEFAULT_CHARSET - Font.Color = clWhite - Font.Height = -13 + Font.Color = clBlack + Font.Height = -16 Font.Name = 'Segoe UI' - Font.Style = [fsBold] + Font.Style = [] ParentFont = False - StyleElements = [seFont, seBorder] OnClick = DisplayBtnClick end object AdvancedBtn: TSpeedButton - Left = 5 + Left = 0 Top = 55 - Width = 187 + Width = 227 Height = 41 Anchors = [akLeft, akTop, akRight] Caption = 'Advanced Settings' Flat = True Font.Charset = DEFAULT_CHARSET - Font.Color = clWhite - Font.Height = -13 + Font.Color = clBlack + Font.Height = -16 Font.Name = 'Segoe UI' - Font.Style = [fsBold] + Font.Style = [] ParentFont = False OnClick = AdvancedBtnClick end object CompatibilityBtn: TSpeedButton - Left = 5 - Top = 102 - Width = 187 + Left = 0 + Top = 149 + Width = 227 Height = 41 Anchors = [akLeft, akTop, akRight] Caption = 'Compatibility Settings' Flat = True Font.Charset = DEFAULT_CHARSET - Font.Color = clWhite - Font.Height = -13 + Font.Color = clBlack + Font.Height = -16 Font.Name = 'Segoe UI' - Font.Style = [fsBold] + Font.Style = [] ParentFont = False OnClick = CompatibilityBtnClick end + object HotkeyBtn: TSpeedButton + Left = 0 + Top = 102 + Width = 227 + Height = 41 + Anchors = [akLeft, akTop, akRight] + Caption = 'Hotkey Settings' + Flat = True + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + OnClick = HotkeyBtnClick + end + object RestoreDefaultsBtn: TSpeedButton + Left = 0 + Top = 440 + Width = 227 + Height = 22 + Anchors = [akLeft, akRight, akBottom] + Caption = 'Restore default settings' + Flat = True + Font.Charset = DEFAULT_CHARSET + Font.Color = clBlack + Font.Height = -12 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + OnClick = RestoreDefaultsBtnClick + end end end diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 689f83f..2e16295 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -49,12 +49,12 @@ __published: // Von der IDE verwaltete Komponenten TLabel *MaxgameticksLbl; TLabel *NoactivateappLbl; TToggleSwitch *NoactivateappChk; - TLabel *HookLbl; - TToggleSwitch *HookChk; + TLabel *ResolutionsLbl; + TToggleSwitch *ResolutionsChk; TLabel *MinfpsLbl; TToggleSwitch *MinfpsChk; - TToggleSwitch *FixpitchChk; - TLabel *FixpitchLbl; + TToggleSwitch *SinglecpuChk; + TLabel *SinglecpuLbl; TLabel *NonexclusiveLbl; TToggleSwitch *NonexclusiveChk; TPaintBox *PresentationPbox; @@ -62,6 +62,25 @@ __published: // Von der IDE verwaltete Komponenten TPaintBox *ShaderPbox; TPaintBox *MaxgameticksPbox; TImage *LanguageImg; + TPanel *HotkeyPnl; + TLabel *ToggleWindowedLbl; + TSpeedButton *HotkeyBtn; + TEdit *ToggleWindowedEdt; + TLabel *ToggleWindowedKeyLbl; + TLabel *MaximizeWindowLbl; + TEdit *MaximizeWindowEdt; + TLabel *MaximizeWindowKeyLbl; + TLabel *UnlockCursor1Lbl; + TEdit *UnlockCursor1Edt; + TLabel *UnlockCursor1KeyLbl; + TLabel *UnlockCursor2Lbl; + TEdit *UnlockCursor2Edt; + TLabel *UnlockCursor2KeyLbl; + TLabel *ScreenshotLbl; + TEdit *ScreenshotEdt; + TComboBox *ShaderD3DCbx; + TSpeedButton *RestoreDefaultsBtn; + TPanel *ThemePnl; void __fastcall DisplayBtnClick(TObject *Sender); void __fastcall AdvancedBtnClick(TObject *Sender); void __fastcall CompatibilityBtnClick(TObject *Sender); @@ -79,16 +98,29 @@ __published: // Von der IDE verwaltete Komponenten void __fastcall SavesettingsChkClick(TObject *Sender); void __fastcall MaxgameticksCbxChange(TObject *Sender); void __fastcall NoactivateappChkClick(TObject *Sender); - void __fastcall HookChkClick(TObject *Sender); + void __fastcall ResolutionsChkClick(TObject *Sender); void __fastcall MinfpsChkClick(TObject *Sender); - void __fastcall FixpitchChkClick(TObject *Sender); + void __fastcall SinglecpuChkClick(TObject *Sender); void __fastcall NonexclusiveChkClick(TObject *Sender); void __fastcall PboxPaint(TObject *Sender); void __fastcall LanguageImgClick(TObject *Sender); + void __fastcall FormActivate(TObject *Sender); + void __fastcall HotkeyBtnClick(TObject *Sender); + void __fastcall HotkeyEdtKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); + void __fastcall HotkeyEdtKeyUp(TObject *Sender, WORD &Key, TShiftState Shift); + void __fastcall ShaderD3DCbxChange(TObject *Sender); + void __fastcall RestoreDefaultsBtnClick(TObject *Sender); + void __fastcall ThemePnlClick(TObject *Sender); + + + private: // Benutzer-Deklarationen + virtual void __fastcall CreateParams(TCreateParams & Params); void SaveSettings(); bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue); void ApplyTranslation(TIniFile *ini); + System::UnicodeString GetKeyText(WORD key); + WORD GetKeyCode(System::UnicodeString key); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner); }; diff --git a/config/Resources/IT.png b/config/Resources/IT.png new file mode 100644 index 0000000000000000000000000000000000000000..89692f74f051cd43503744c3dab65c8ba773b7e2 GIT binary patch literal 420 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~o!2~3KHq6QcQY`6?zK#qG>ra@ocD)4hB}-f* zN`mv#O3D+9QW+dm@{>{(JaZG%Q-e|yQz{EjrrIztFq(O~IEGZ*N=lh=;=qSyMwWku z27eMOW_|f0uQeek^e_9g7KH|eq{JVG0^UaP2Jy4}|L^JL_3uCblfVD@mnS9t`~UCn z|MT(+KT|KOfz%~1cG~~^_2vEk{SFNQ?Cjg~|NsBWy<%2im{vp^YdeS=hk-Cyo6U`Hgs{l4FR(w#{P`G0;a3G2@YSmzI~fu(ZE1> L{an^LB{Ts58L6#6 literal 0 HcmV?d00001 diff --git a/config/cnc-ddraw config.cbproj b/config/cnc-ddraw config.cbproj index 3ac67c6..dbd448c 100644 --- a/config/cnc-ddraw config.cbproj +++ b/config/cnc-ddraw config.cbproj @@ -1,7 +1,7 @@  {E020D5C7-AE07-4DB9-9688-6D289E9FFF1A} - 18.8 + 19.5 VCL Application cnc-ddraw config.cpp @@ -9,6 +9,7 @@ Release Win32 1 + c true @@ -18,6 +19,11 @@ Base true + + true + Base + true + true Base @@ -29,6 +35,12 @@ true true + + true + Cfg_1 + true + true + true Base @@ -40,6 +52,12 @@ true true + + true + Cfg_2 + true + true + JPHNE true @@ -52,7 +70,7 @@ $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) CppVCLApplication System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) - rtl.lib;vcl.lib;vclwinx.lib;vclimg.lib + rtl.lib;vcl.lib;vclwinx.lib;vclimg.lib;bindengine.lib <_TCHARMapping>wchar_t true $(BDS)\bin\cbuilder_PROJECTICON.ico @@ -61,7 +79,7 @@ cnc-ddraw\config\;$(IncludePath) cnc-ddraw\config\;$(ILINK_LibraryPath) cnc-ddraw_config - "Windows10 Blue|VCLSTYLE|$(BDSCOMMONDIR)\Styles\Windows10Blue.vsf" + Windows10|VCLSTYLE|$(BDSCOMMONDIR)\Styles\Windows10.vsf;"Cobalt XEMedia|VCLSTYLE|$(BDSCOMMONDIR)\Styles\CobaltXEMedia.vsf" adortl;appanalytics;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindengine;CloudService;CustomIPTransport;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXInterBaseDriver;DBXMySQLDriver;DBXSqliteDriver;dsnap;dsnapcon;dsnapxml;FireDAC;FireDACADSDriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACIBDriver;FireDACMSAccDriver;FireDACMySQLDriver;FireDACPgDriver;FireDACSqliteDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;RESTBackendComponents;RESTComponents;rtl;soapmidas;soaprtl;soapserver;svn;tethering;vcl;vclactnband;vcldb;vcldsnap;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclx;xmlrtl;$(PackageImports) @@ -71,6 +89,16 @@ true CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= 1033 + cnc-ddraw config.manifest + 5.0 + 5.0 + + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 $(BDS)\bin\default_app.manifest @@ -105,21 +133,33 @@ false false rtl.lib;vcl.lib;vclwinx.lib;vclimg.lib + $(BDSLIB)\$(PLATFORM)$(CC_SUFFIX)\debug;$(ILINK_LibraryPath) + 5.0 + 5.0 + cnc-ddraw config.manifest + + + PerMonitorV2 NDEBUG;$(Defines) None - true PerMonitorV2 false false false true - rtl.lib;vcl.lib;vclwinx.lib;vclimg.lib + rtl.lib;vcl.lib;vclwinx.lib;vclimg.lib;bindengine.lib 1033 cnc-ddraw.ico + 5.0 + 5.0 + cnc-ddraw config.manifest + + + PerMonitorV2 @@ -151,6 +191,10 @@ RCDATA PngImage_HU + + RCDATA + PngImage_IT + RCDATA PngImage_RU @@ -160,10 +204,6 @@ PngImage_US - - Cfg_2 - Base - Base @@ -171,6 +211,10 @@ Cfg_1 Base + + Cfg_2 + Base + CPlusPlusBuilder.Personality.12 @@ -187,125 +231,79 @@ cnc-ddraw config.cpp - Embarcadero C++Builder-Package für Office 2000-Server - Embarcadero C++Builder-Package für Office XP-Server + Embarcadero C++Builder-Package für Office 2000-Server + Embarcadero C++Builder-Package für Office XP-Server - - - - true - - + true - - - true - - - - - true - - - - - true - - true - - - true - - + + true - + + + true - - - cnc-ddraw_config.exe - true - - - - - .\ - true - - - - - .\ - true - - - - - .\ - true - - - - - .\ - true - - - - - cnc-ddraw_config.exe - true - - - - - .\ - true - - - + true - + true - + + + - .\ true - - - true - - - + - .\ true + + + + + true + + + + + true + + + + + + + + + + + + 1 @@ -318,14 +316,14 @@ 0 - + classes - 1 + 64 classes - 1 + 64 @@ -446,6 +444,16 @@ 1 + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + res\drawable-ldpi @@ -609,6 +617,11 @@ 1 .framework + + Contents\MacOS + 1 + .framework + 0 @@ -622,7 +635,7 @@ 1 .dylib - + 1 .dylib @@ -636,6 +649,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -650,7 +668,7 @@ 1 .dylib - + 1 .dylib @@ -664,6 +682,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -682,7 +705,7 @@ 0 - + 0 @@ -693,272 +716,12 @@ Contents\Resources\StartUp\ 0 - + + Contents\Resources\StartUp\ 0 - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 + + 0 @@ -969,61 +732,15 @@ 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF - 1 - - - - - 1 - - - 1 - - - - - ..\ - 1 - - - ..\ - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + @@ -1034,6 +751,10 @@ ..\ 1 + + ..\ + 1 + @@ -1044,6 +765,10 @@ Contents 1 + + Contents + 1 + @@ -1054,6 +779,10 @@ Contents\Resources 1 + + Contents\Resources + 1 + @@ -1070,7 +799,7 @@ 1 - + 1 @@ -1084,6 +813,10 @@ Contents\MacOS 1 + + Contents\MacOS + 1 + 0 @@ -1102,6 +835,66 @@ 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + + + 1 + + + 1 + + + 1 + + Assets @@ -1122,19 +915,222 @@ 1 - - - - - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + - - + + + + + + + + + + True + False 12 diff --git a/config/cnc-ddraw config.cpp b/config/cnc-ddraw config.cpp index e98fba6..f88df0c 100644 --- a/config/cnc-ddraw config.cpp +++ b/config/cnc-ddraw config.cpp @@ -2,6 +2,8 @@ #include #pragma hdrstop +#include +#include #include //--------------------------------------------------------------------------- #include @@ -14,7 +16,29 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { Application->Initialize(); Application->MainFormOnTaskBar = true; - TStyleManager::TrySetStyle("Windows10 Blue"); + + HWND hwnd = + FindWindow( + THashSHA1::GetHashString(Application->ExeName).w_str(), NULL); + + if (hwnd && ParamStr(1) != L"-restart") { + + if (IsIconic(hwnd)) { + ShowWindow(hwnd, SW_RESTORE); + } + + SetForegroundWindow(hwnd); + return 0; + } + + auto *ini = new TIniFile(".\\dd-hd.ini"); + auto theme = ini->ReadString("ddraw", "configtheme", "Windows10"); + + TStyleManager::TrySetStyle( + theme == "Cobalt XEMedia" ? "Cobalt XEMedia" : "Windows10"); + + delete ini; + Application->CreateForm(__classid(TConfigForm), &ConfigForm); Application->Run(); } diff --git a/config/cnc-ddraw config.manifest b/config/cnc-ddraw config.manifest new file mode 100644 index 0000000..35c0fea --- /dev/null +++ b/config/cnc-ddraw config.manifest @@ -0,0 +1,34 @@ + + + + + true/pm + PerMonitorV2 + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/cnc-ddraw config_resources.rc b/config/cnc-ddraw config_resources.rc index 15a55fd..a2ed1e5 100644 --- a/config/cnc-ddraw config_resources.rc +++ b/config/cnc-ddraw config_resources.rc @@ -3,5 +3,6 @@ PngImage_DE RCDATA "Resources\\DE.png" PngImage_ES RCDATA "Resources\\ES.png" PngImage_FR RCDATA "Resources\\fr.png" PngImage_HU RCDATA "Resources\\hu.png" +PngImage_IT RCDATA "Resources\\IT.png" PngImage_RU RCDATA "Resources\\RU.png" PngImage_US RCDATA "Resources\\US.png" From c9d5e1015cb564f7599c55516bd16979c7108728 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 2 Sep 2023 23:22:04 +0200 Subject: [PATCH 21/47] remove new filter settings to keep config compatible with old cnc-ddraw build --- config/ConfigFormUnit.cpp | 40 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 3c704e2..db2464d 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -781,15 +781,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) } catch (...) { - } - - if (ShaderCbx->Items->Count == 0) { - ShaderCbx->AddItem("Nearest neighbor", NULL); - ShaderCbx->AddItem("Bilinear", NULL); - ShaderCbx->AddItem("Bicubic", NULL); - ShaderCbx->AddItem("Lanczos", NULL); - ShaderCbx->AddItem("xBR-lv2", NULL); - } + } auto shader = ini->ReadString("ddraw", "shader", "Bicubic"); ShaderCbx->ItemIndex = ShaderCbx->Items->IndexOf(shader); @@ -799,24 +791,15 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) ShaderCbx->ItemIndex = ShaderCbx->Items->Count - 1; } - int d3d9_filter = ini->ReadInteger("ddraw", "d3d9_filter", 2); + bool d3d9_filter = GetBool(ini, "d3d9linear", true); - switch (d3d9_filter) { - case 0: - ShaderD3DCbx->ItemIndex = 0; - break; - case 1: + if (d3d9_filter) { ShaderD3DCbx->ItemIndex = 1; - break; - case 2: - default: - ShaderD3DCbx->ItemIndex = 2; - break; - case 3: - ShaderD3DCbx->ItemIndex = 3; - break; } - + else { + ShaderD3DCbx->ItemIndex = 0; + } + Maxfps = ini->ReadInteger("ddraw", "maxfps", -1); MaxfpsChk->State = Maxfps != 0 ? tssOn : tssOff; @@ -991,8 +974,13 @@ void TConfigForm::SaveSettings() ini->WriteString("ddraw", "shader", ShaderCbx->Text); - ini->WriteInteger("ddraw", "d3d9_filter", ShaderD3DCbx->ItemIndex); - + if (ShaderD3DCbx->ItemIndex == 0) { + ini->WriteString("ddraw", "d3d9linear", "false"); + } + else { + ini->WriteString("ddraw", "d3d9linear", "true"); + } + int maxfps = Maxfps == 0 ? -1 : Maxfps; ini->WriteInteger( From 19ed60642ff7546475852016f5bb0a370def7dec Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 3 Sep 2023 00:08:14 +0200 Subject: [PATCH 22/47] add Resolution setting --- config/ConfigFormUnit.cpp | 37 +++++++++++++++++++++++ config/ConfigFormUnit.dfm | 63 ++++++++++++++++++++++++++++++++------- config/ConfigFormUnit.h | 3 ++ 3 files changed, 93 insertions(+), 10 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index db2464d..e64166b 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -116,6 +116,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"兼容性设置"; RestoreDefaultsBtn->Caption = L"恢复默认设置"; PresentationLbl->Caption = L"显示方式"; + ResolutionLbl->Caption = L"解决"; MaintasLbl->Caption = L"保持纵横比"; VsyncLbl->Caption = L"打开垂直同步"; AdjmouseLbl->Caption = L"调整鼠标灵敏度"; @@ -175,6 +176,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Ajustes de compatibilidad"; RestoreDefaultsBtn->Caption = L"Restaurar la configuración predeterminada"; PresentationLbl->Caption = L"Presentación"; + ResolutionLbl->Caption = L"Resolución"; MaintasLbl->Caption = L"Mantener la relación de aspecto"; VsyncLbl->Caption = L"Activar VSync"; AdjmouseLbl->Caption = L"Ajustar sensibilidad de ratón"; @@ -234,6 +236,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Kompatibilitätseinstellungen"; RestoreDefaultsBtn->Caption = L"Standardeinstellungen wiederherstellen"; PresentationLbl->Caption = L"Darstellung"; + ResolutionLbl->Caption = L"Auflösung"; MaintasLbl->Caption = L"Seitenverhältnis beibehalten"; VsyncLbl->Caption = L"VSync aktiveren"; AdjmouseLbl->Caption = L"Mausempfindlichkeit anpassen"; @@ -294,6 +297,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Настройки совместимости"; RestoreDefaultsBtn->Caption = L"Восстановить настройки по умолчанию"; PresentationLbl->Caption = L"Отображение"; + ResolutionLbl->Caption = L"Разрешение"; MaintasLbl->Caption = L"Сохранять соотношение сторон"; VsyncLbl->Caption = L"Включить VSync"; AdjmouseLbl->Caption = L"Регулировка чувствительности мыши"; @@ -353,6 +357,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Kompatibilitás Beállítások"; RestoreDefaultsBtn->Caption = L"Visszaállítja az alapértelmezett beállításokat"; PresentationLbl->Caption = L"Bemutató"; + ResolutionLbl->Caption = L"Felbontás"; MaintasLbl->Caption = L"Képarány megtartása"; VsyncLbl->Caption = L"VSync bekapcsolása"; AdjmouseLbl->Caption = L"Egérérzékenység beállítás"; @@ -412,6 +417,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Paramètres de Compatibilité"; RestoreDefaultsBtn->Caption = L"Restaurer les paramètres par défaut"; PresentationLbl->Caption = L"Présentation"; + ResolutionLbl->Caption = L"Résolution"; MaintasLbl->Caption = L"Conserver les proportions de l'image"; VsyncLbl->Caption = L"Activer la synchro verticale (VSync)"; AdjmouseLbl->Caption = L"Ajuster la sensibilité souris"; @@ -471,6 +477,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Impostazioni di compatibilità"; RestoreDefaultsBtn->Caption = L"Ripristina le impostazioni predefinite"; PresentationLbl->Caption = L"Presentazione"; + ResolutionLbl->Caption = L"Risoluzione"; MaintasLbl->Caption = L"Mantieni il rapporto d'aspetto"; VsyncLbl->Caption = L"Abilita la sincronizzazione verticale (VSync)"; AdjmouseLbl->Caption = L"Regola la sensibilità del mouse"; @@ -575,6 +582,7 @@ void TConfigForm::ApplyTranslation(TIniFile *ini) CompatibilityBtn->Caption = L"Compatibility Settings"; RestoreDefaultsBtn->Caption = L"Restore default settings"; PresentationLbl->Caption = L"Presentation"; + ResolutionLbl->Caption = L"Resolution"; MaintasLbl->Caption = L"Maintain aspect ratio"; VsyncLbl->Caption = L"Enable VSync"; AdjmouseLbl->Caption = L"Adjust mouse sensitivity"; @@ -694,6 +702,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) } auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *hd_ini = new TIniFile(".\\Warcraft_II_HD.ini"); if (ini->ReadString("ddraw", "configtheme", "Windows10") == "Cobalt XEMedia") { @@ -727,6 +736,18 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) PresentationCbx->ItemIndex = 0; } + int cwidth = hd_ini->ReadInteger("Warcraft_II_HD", "Width", 0); + int cheight = hd_ini->ReadInteger("Warcraft_II_HD", "Height", 0); + int reso = hd_ini->ReadInteger("Warcraft_II_HD", "Resolution", 3); + + if (!cwidth || !cheight) { + ResolutionCbx->ItemIndex = reso <= 5 ? reso : 3; + } + else { + ResolutionCbx->AddItem(IntToStr(cwidth) + "x" + IntToStr(cheight), NULL); + ResolutionCbx->ItemIndex = ResolutionCbx->Items->Count - 1; + } + MaintasChk->State = GetBool(ini, "maintas", false) ? tssOn : tssOff; VsyncChk->State = GetBool(ini, "vsync", false) ? tssOn : tssOff; AdjmouseChk->State = GetBool(ini, "adjmouse", true) ? tssOn : tssOff; @@ -889,6 +910,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) GetBool(ini, "allow_reset", true); delete ini; + delete hd_ini; Initialized = true; } @@ -899,6 +921,7 @@ void TConfigForm::SaveSettings() return; auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *hd_ini = new TIniFile(".\\Warcraft_II_HD.ini"); /* Display Settings */ @@ -925,6 +948,18 @@ void TConfigForm::SaveSettings() break; } + if (ResolutionCbx->ItemIndex <= 5) { + hd_ini->WriteInteger( + "Warcraft_II_HD", "Resolution", ResolutionCbx->ItemIndex); + + hd_ini->WriteInteger("Warcraft_II_HD", "Width", 0); + hd_ini->WriteInteger("Warcraft_II_HD", "Height", 0); + + if (ResolutionCbx->Items->Count == 7) { + ResolutionCbx->Items->Delete(6); + } + } + ini->WriteString( "ddraw", "maintas", @@ -1112,6 +1147,7 @@ void TConfigForm::SaveSettings() NonexclusiveChk->State == tssOn ? "true" : "false"); delete ini; + delete hd_ini; } void __fastcall TConfigForm::FormActivate(TObject *Sender) @@ -1340,3 +1376,4 @@ void __fastcall TConfigForm::PboxPaint(TObject *Sender) //pbox->Canvas->Rectangle(pbox->ClientRect); } + diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index a69b94f..29b86ff 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -2696,8 +2696,6 @@ object ConfigForm: TConfigForm ShowCaption = False TabOrder = 1 StyleElements = [seFont, seBorder] - ExplicitWidth = 495 - ExplicitHeight = 464 DesignSize = ( 499 465) @@ -2716,7 +2714,7 @@ object ConfigForm: TConfigForm end object MaintasLbl: TLabel Left = 40 - Top = 105 + Top = 182 Width = 145 Height = 21 Margins.Top = 18 @@ -2730,7 +2728,7 @@ object ConfigForm: TConfigForm end object VsyncLbl: TLabel Left = 40 - Top = 173 + Top = 250 Width = 93 Height = 21 Margins.Top = 18 @@ -2744,7 +2742,7 @@ object ConfigForm: TConfigForm end object AdjmouseLbl: TLabel Left = 40 - Top = 241 + Top = 318 Width = 168 Height = 21 Margins.Top = 18 @@ -2758,7 +2756,7 @@ object ConfigForm: TConfigForm end object DevmodeLbl: TLabel Left = 40 - Top = 309 + Top = 386 Width = 216 Height = 21 Margins.Top = 18 @@ -2806,6 +2804,26 @@ object ConfigForm: TConfigForm Visible = False OnClick = LanguageImgClick end + object ResolutionLbl: TLabel + Left = 40 + Top = 105 + Width = 74 + Height = 21 + Caption = 'Resolution' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object ResolutionPbox: TPaintBox + Left = 40 + Top = 131 + Width = 282 + Height = 31 + OnPaint = PboxPaint + end object PresentationCbx: TComboBox Left = 41 Top = 55 @@ -2831,7 +2849,7 @@ object ConfigForm: TConfigForm end object MaintasChk: TToggleSwitch Left = 40 - Top = 132 + Top = 209 Width = 50 Height = 20 ShowStateCaption = False @@ -2840,7 +2858,7 @@ object ConfigForm: TConfigForm end object VsyncChk: TToggleSwitch Left = 40 - Top = 200 + Top = 277 Width = 50 Height = 20 ShowStateCaption = False @@ -2849,7 +2867,7 @@ object ConfigForm: TConfigForm end object AdjmouseChk: TToggleSwitch Left = 40 - Top = 268 + Top = 345 Width = 50 Height = 20 ShowStateCaption = False @@ -2858,7 +2876,7 @@ object ConfigForm: TConfigForm end object DevmodeChk: TToggleSwitch Left = 40 - Top = 336 + Top = 413 Width = 50 Height = 20 ShowStateCaption = False @@ -2879,6 +2897,31 @@ object ConfigForm: TConfigForm OnClick = ThemePnlClick ExplicitLeft = 471 end + object ResolutionCbx: TComboBox + Left = 41 + Top = 132 + Width = 280 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 6 + OnChange = PresentationCbxChange + Items.Strings = ( + '640x480 (4:3)' + '800x608 (4:3)' + '832x480 (16:9)' + '960x544 (16:9)' + '1280x704 (16:9)' + '1280x544 (21:9)') + end end object CompatibilityPnl: TPanel Left = 233 diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 2e16295..cb81a60 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -81,6 +81,9 @@ __published: // Von der IDE verwaltete Komponenten TComboBox *ShaderD3DCbx; TSpeedButton *RestoreDefaultsBtn; TPanel *ThemePnl; + TComboBox *ResolutionCbx; + TLabel *ResolutionLbl; + TPaintBox *ResolutionPbox; void __fastcall DisplayBtnClick(TObject *Sender); void __fastcall AdvancedBtnClick(TObject *Sender); void __fastcall CompatibilityBtnClick(TObject *Sender); From 02d300c5193a90a8c18fd149d30e450a10d6ea25 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 3 Sep 2023 00:18:32 +0200 Subject: [PATCH 23/47] change default settings --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index ccdf8b1..1ddacc1 100644 --- a/src/config.c +++ b/src/config.c @@ -279,7 +279,7 @@ static void cfg_create_ini() "\n" "; Preliminary libretro shader support - (Requires 'renderer=opengl') https://github.com/libretro/glsl-shaders\n" "; 2x scaling example: https://imgur.com/a/kxsM1oY - 4x scaling example: https://imgur.com/a/wjrhpFV\n" - "shader=Shaders\\interpolation\\bilinear.glsl\n" + "shader=Shaders\\interpolation\\catmull-rom-bilinear.glsl\n" "\n" "; Window position, -32000 = center to screen\n" "posX=-32000\n" From 88e9566ccff9cab2847d8d606b9e77cc69cd2951 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 17 Jan 2024 23:00:08 +0100 Subject: [PATCH 24/47] adjust ini file name and settings --- config/ConfigFormUnit.cpp | 17 +++++++------- config/ConfigFormUnit.dfm | 48 +++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index e64166b..499c337 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -702,7 +702,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) } auto *ini = new TIniFile(".\\dd-hd.ini"); - auto *hd_ini = new TIniFile(".\\Warcraft_II_HD.ini"); + auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); if (ini->ReadString("ddraw", "configtheme", "Windows10") == "Cobalt XEMedia") { @@ -736,9 +736,9 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) PresentationCbx->ItemIndex = 0; } - int cwidth = hd_ini->ReadInteger("Warcraft_II_HD", "Width", 0); - int cheight = hd_ini->ReadInteger("Warcraft_II_HD", "Height", 0); - int reso = hd_ini->ReadInteger("Warcraft_II_HD", "Resolution", 3); + int cwidth = hd_ini->ReadInteger("Game", "Width", 0); + int cheight = hd_ini->ReadInteger("Game", "Height", 0); + int reso = hd_ini->ReadInteger("Game", "Resolution", 3); if (!cwidth || !cheight) { ResolutionCbx->ItemIndex = reso <= 5 ? reso : 3; @@ -921,7 +921,7 @@ void TConfigForm::SaveSettings() return; auto *ini = new TIniFile(".\\dd-hd.ini"); - auto *hd_ini = new TIniFile(".\\Warcraft_II_HD.ini"); + auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); /* Display Settings */ @@ -949,11 +949,10 @@ void TConfigForm::SaveSettings() } if (ResolutionCbx->ItemIndex <= 5) { - hd_ini->WriteInteger( - "Warcraft_II_HD", "Resolution", ResolutionCbx->ItemIndex); + hd_ini->WriteInteger("Game", "Resolution", ResolutionCbx->ItemIndex); - hd_ini->WriteInteger("Warcraft_II_HD", "Width", 0); - hd_ini->WriteInteger("Warcraft_II_HD", "Height", 0); + hd_ini->WriteInteger("Game", "Width", 0); + hd_ini->WriteInteger("Game", "Height", 0); if (ResolutionCbx->Items->Count == 7) { ResolutionCbx->Items->Delete(6); diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 29b86ff..1c96d00 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -4,8 +4,8 @@ object ConfigForm: TConfigForm BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = 'cnc-ddraw config' - ClientHeight = 476 - ClientWidth = 741 + ClientHeight = 475 + ClientWidth = 737 Color = clMenu Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText @@ -2681,14 +2681,14 @@ object ConfigForm: TConfigForm OnActivate = FormActivate OnCreate = FormCreate DesignSize = ( - 741 - 476) + 737 + 475) TextHeight = 13 object DisplayPnl: TPanel Left = 233 Top = 8 - Width = 499 - Height = 465 + Width = 495 + Height = 464 Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite @@ -2697,8 +2697,8 @@ object ConfigForm: TConfigForm TabOrder = 1 StyleElements = [seFont, seBorder] DesignSize = ( - 499 - 465) + 495 + 464) object PresentationLbl: TLabel Left = 40 Top = 28 @@ -2776,7 +2776,7 @@ object ConfigForm: TConfigForm OnPaint = PboxPaint end object LanguageImg: TImage - Left = 453 + Left = 449 Top = 8 Width = 16 Height = 11 @@ -2803,6 +2803,7 @@ object ConfigForm: TConfigForm Stretch = True Visible = False OnClick = LanguageImgClick + ExplicitLeft = 453 end object ResolutionLbl: TLabel Left = 40 @@ -2884,7 +2885,7 @@ object ConfigForm: TConfigForm OnClick = DevmodeChkClick end object ThemePnl: TPanel - Left = 475 + Left = 471 Top = 8 Width = 16 Height = 11 @@ -2895,7 +2896,6 @@ object ConfigForm: TConfigForm TabOrder = 5 StyleElements = [seFont, seBorder] OnClick = ThemePnlClick - ExplicitLeft = 471 end object ResolutionCbx: TComboBox Left = 41 @@ -2926,8 +2926,8 @@ object ConfigForm: TConfigForm object CompatibilityPnl: TPanel Left = 233 Top = 8 - Width = 499 - Height = 465 + Width = 495 + Height = 464 Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite @@ -2936,8 +2936,6 @@ object ConfigForm: TConfigForm TabOrder = 3 Visible = False StyleElements = [seFont, seBorder] - ExplicitWidth = 495 - ExplicitHeight = 464 object MaxgameticksLbl: TLabel Left = 40 Top = 28 @@ -3108,8 +3106,8 @@ object ConfigForm: TConfigForm object AdvancedPnl: TPanel Left = 233 Top = 8 - Width = 499 - Height = 465 + Width = 495 + Height = 464 Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite @@ -3118,8 +3116,6 @@ object ConfigForm: TConfigForm TabOrder = 2 Visible = False StyleElements = [seFont, seBorder] - ExplicitWidth = 495 - ExplicitHeight = 464 object RendererLbl: TLabel Left = 40 Top = 28 @@ -3324,8 +3320,8 @@ object ConfigForm: TConfigForm object HotkeyPnl: TPanel Left = 233 Top = 8 - Width = 499 - Height = 465 + Width = 495 + Height = 464 Anchors = [akLeft, akTop, akRight, akBottom] BevelOuter = bvNone Color = clWhite @@ -3334,8 +3330,6 @@ object ConfigForm: TConfigForm TabOrder = 4 Visible = False StyleElements = [seFont, seBorder] - ExplicitWidth = 495 - ExplicitHeight = 464 object ToggleWindowedLbl: TLabel Left = 40 Top = 27 @@ -3557,16 +3551,15 @@ object ConfigForm: TConfigForm Left = 0 Top = 8 Width = 233 - Height = 468 + Height = 467 Anchors = [akLeft, akTop, akBottom] BevelOuter = bvNone Color = clMenu ParentBackground = False TabOrder = 0 - ExplicitHeight = 467 DesignSize = ( 233 - 468) + 467) object DisplayBtn: TSpeedButton Left = 0 Top = 8 @@ -3633,7 +3626,7 @@ object ConfigForm: TConfigForm end object RestoreDefaultsBtn: TSpeedButton Left = 0 - Top = 440 + Top = 439 Width = 227 Height = 22 Anchors = [akLeft, akRight, akBottom] @@ -3646,6 +3639,7 @@ object ConfigForm: TConfigForm Font.Style = [] ParentFont = False OnClick = RestoreDefaultsBtnClick + ExplicitTop = 440 end end end From 3997c03d70c8991b41b023ff7f938b3c429e7c59 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 17 Jan 2024 23:17:21 +0100 Subject: [PATCH 25/47] add 16:10 resolutions --- config/ConfigFormUnit.cpp | 8 +- config/ConfigFormUnit.dfm | 490 +++++++++++++++++++------------------- 2 files changed, 255 insertions(+), 243 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 499c337..4cc22a1 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -741,7 +741,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) int reso = hd_ini->ReadInteger("Game", "Resolution", 3); if (!cwidth || !cheight) { - ResolutionCbx->ItemIndex = reso <= 5 ? reso : 3; + ResolutionCbx->ItemIndex = reso <= 7 ? reso : 3; } else { ResolutionCbx->AddItem(IntToStr(cwidth) + "x" + IntToStr(cheight), NULL); @@ -948,14 +948,14 @@ void TConfigForm::SaveSettings() break; } - if (ResolutionCbx->ItemIndex <= 5) { + if (ResolutionCbx->ItemIndex <= 7) { hd_ini->WriteInteger("Game", "Resolution", ResolutionCbx->ItemIndex); hd_ini->WriteInteger("Game", "Width", 0); hd_ini->WriteInteger("Game", "Height", 0); - if (ResolutionCbx->Items->Count == 7) { - ResolutionCbx->Items->Delete(6); + if (ResolutionCbx->Items->Count == 9) { + ResolutionCbx->Items->Delete(8); } } diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 1c96d00..533b68b 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -2684,245 +2684,6 @@ object ConfigForm: TConfigForm 737 475) TextHeight = 13 - object DisplayPnl: TPanel - Left = 233 - Top = 8 - Width = 495 - Height = 464 - Anchors = [akLeft, akTop, akRight, akBottom] - BevelOuter = bvNone - Color = clWhite - ParentBackground = False - ShowCaption = False - TabOrder = 1 - StyleElements = [seFont, seBorder] - DesignSize = ( - 495 - 464) - object PresentationLbl: TLabel - Left = 40 - Top = 28 - Width = 87 - Height = 21 - Caption = 'Presentation' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object MaintasLbl: TLabel - Left = 40 - Top = 182 - Width = 145 - Height = 21 - Margins.Top = 18 - Caption = 'Maintain aspect ratio' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object VsyncLbl: TLabel - Left = 40 - Top = 250 - Width = 93 - Height = 21 - Margins.Top = 18 - Caption = 'Enable VSync' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object AdjmouseLbl: TLabel - Left = 40 - Top = 318 - Width = 168 - Height = 21 - Margins.Top = 18 - Caption = 'Adjust mouse sensitivity' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object DevmodeLbl: TLabel - Left = 40 - Top = 386 - Width = 216 - Height = 21 - Margins.Top = 18 - Caption = 'Lock cursor to window / screen' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object PresentationPbox: TPaintBox - Left = 40 - Top = 54 - Width = 282 - Height = 31 - OnPaint = PboxPaint - end - object LanguageImg: TImage - Left = 449 - Top = 8 - Width = 16 - Height = 11 - Anchors = [akTop, akRight] - Picture.Data = { - 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000100000 - 000B0802000000F9809A6E0000000467414D410000AFC837058AE90000001974 - 455874536F6674776172650041646F626520496D616765526561647971C9653C - 000001B34944415478DA4D51DF4B5451109EB3B95010813E583ED8D28B7F8356 - 6A1A2BD5530F81AE108837E9414390681F841235FF00115C0A5A82AD1E7C1172 - B7A050597C102C05E5C2222CE5A2D8522CABBBDD7BEEF935CE5DF1E2F031F30D - C37C67660EB39EAE4160C68051000200C9BF897C47E7FFBFBF7F283735508D51 - C3DBF9B65416639DE6E34AA8BF1DDF67D9E3DB2AB95A37D8A51101D12005F049 - 26B3E03774C65A3F658D3640100A35FA842BFC09E3502AC3F111542BE038ACFF - 7EEEC71A35AC74F4B6F7DDD23DAF59262EA3D375E917CE9DE94B3683D24B61CE - ACBE7ED475E76D7B8B5943D98ED8CDE432BDE06B2B091EA20D9E7236D4E11C09 - 43B58A9C8310A1C187EBF626B3ACAF89C4DDEE576629CEA35317D3F1E36B33E2 - F798691ED92E25DB4EE56907F2E5AB8D797F07EB4B6B5FF4DD374DC246C20E16 - B597833D0D05ADAECCF8DA9E4720121AEEFD9CCFB14221DFD4745D4A19289D27 - 01775DF74618E616534C4F3E63F71E617A198B45289769621F9C234D2F040644 - CA0BCF073EECFF62BBBB3B91484B251CBE2C7870F5F3A694E4BC01605F6BD330 - 3BC10E9E3CA0E3041F0967840354009C1A642D3DAD9E00C53A4C480864283400 - 00000049454E44AE426082} - Stretch = True - Visible = False - OnClick = LanguageImgClick - ExplicitLeft = 453 - end - object ResolutionLbl: TLabel - Left = 40 - Top = 105 - Width = 74 - Height = 21 - Caption = 'Resolution' - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - end - object ResolutionPbox: TPaintBox - Left = 40 - Top = 131 - Width = 282 - Height = 31 - OnPaint = PboxPaint - end - object PresentationCbx: TComboBox - Left = 41 - Top = 55 - Width = 280 - Height = 29 - BevelEdges = [] - BevelInner = bvNone - BevelOuter = bvSpace - Style = csDropDownList - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - TabOrder = 1 - OnChange = PresentationCbxChange - Items.Strings = ( - 'Fullscreen' - 'Fullscreen Upscaled' - 'Borderless' - 'Windowed') - end - object MaintasChk: TToggleSwitch - Left = 40 - Top = 209 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 0 - OnClick = MaintasChkClick - end - object VsyncChk: TToggleSwitch - Left = 40 - Top = 277 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 2 - OnClick = VsyncChkClick - end - object AdjmouseChk: TToggleSwitch - Left = 40 - Top = 345 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 3 - OnClick = AdjmouseChkClick - end - object DevmodeChk: TToggleSwitch - Left = 40 - Top = 413 - Width = 50 - Height = 20 - ShowStateCaption = False - TabOrder = 4 - OnClick = DevmodeChkClick - end - object ThemePnl: TPanel - Left = 471 - Top = 8 - Width = 16 - Height = 11 - Anchors = [akTop, akRight] - BevelOuter = bvNone - Color = 2039583 - ParentBackground = False - TabOrder = 5 - StyleElements = [seFont, seBorder] - OnClick = ThemePnlClick - end - object ResolutionCbx: TComboBox - Left = 41 - Top = 132 - Width = 280 - Height = 29 - BevelEdges = [] - BevelInner = bvNone - BevelOuter = bvSpace - Style = csDropDownList - Font.Charset = DEFAULT_CHARSET - Font.Color = clWindowText - Font.Height = -16 - Font.Name = 'Segoe UI' - Font.Style = [] - ParentFont = False - TabOrder = 6 - OnChange = PresentationCbxChange - Items.Strings = ( - '640x480 (4:3)' - '800x608 (4:3)' - '832x480 (16:9)' - '960x544 (16:9)' - '1280x704 (16:9)' - '1280x544 (21:9)') - end - end object CompatibilityPnl: TPanel Left = 233 Top = 8 @@ -2936,6 +2697,8 @@ object ConfigForm: TConfigForm TabOrder = 3 Visible = False StyleElements = [seFont, seBorder] + ExplicitWidth = 491 + ExplicitHeight = 463 object MaxgameticksLbl: TLabel Left = 40 Top = 28 @@ -3116,6 +2879,8 @@ object ConfigForm: TConfigForm TabOrder = 2 Visible = False StyleElements = [seFont, seBorder] + ExplicitWidth = 491 + ExplicitHeight = 463 object RendererLbl: TLabel Left = 40 Top = 28 @@ -3330,6 +3095,8 @@ object ConfigForm: TConfigForm TabOrder = 4 Visible = False StyleElements = [seFont, seBorder] + ExplicitWidth = 491 + ExplicitHeight = 463 object ToggleWindowedLbl: TLabel Left = 40 Top = 27 @@ -3547,6 +3314,250 @@ object ConfigForm: TConfigForm OnKeyUp = HotkeyEdtKeyUp end end + object DisplayPnl: TPanel + Left = 233 + Top = 8 + Width = 495 + Height = 464 + Anchors = [akLeft, akTop, akRight, akBottom] + BevelOuter = bvNone + Color = clWhite + ParentBackground = False + ShowCaption = False + TabOrder = 1 + StyleElements = [seFont, seBorder] + ExplicitWidth = 491 + ExplicitHeight = 463 + DesignSize = ( + 495 + 464) + object PresentationLbl: TLabel + Left = 40 + Top = 28 + Width = 87 + Height = 21 + Caption = 'Presentation' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object MaintasLbl: TLabel + Left = 40 + Top = 182 + Width = 145 + Height = 21 + Margins.Top = 18 + Caption = 'Maintain aspect ratio' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object VsyncLbl: TLabel + Left = 40 + Top = 250 + Width = 93 + Height = 21 + Margins.Top = 18 + Caption = 'Enable VSync' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object AdjmouseLbl: TLabel + Left = 40 + Top = 318 + Width = 168 + Height = 21 + Margins.Top = 18 + Caption = 'Adjust mouse sensitivity' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object DevmodeLbl: TLabel + Left = 40 + Top = 386 + Width = 216 + Height = 21 + Margins.Top = 18 + Caption = 'Lock cursor to window / screen' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object PresentationPbox: TPaintBox + Left = 40 + Top = 54 + Width = 282 + Height = 31 + OnPaint = PboxPaint + end + object LanguageImg: TImage + Left = 449 + Top = 8 + Width = 16 + Height = 11 + Anchors = [akTop, akRight] + Picture.Data = { + 0954506E67496D61676589504E470D0A1A0A0000000D49484452000000100000 + 000B0802000000F9809A6E0000000467414D410000AFC837058AE90000001974 + 455874536F6674776172650041646F626520496D616765526561647971C9653C + 000001B34944415478DA4D51DF4B5451109EB3B95010813E583ED8D28B7F8356 + 6A1A2BD5530F81AE108837E9414390681F841235FF00115C0A5A82AD1E7C1172 + B7A050597C102C05E5C2222CE5A2D8522CABBBDD7BEEF935CE5DF1E2F031F30D + C37C67660EB39EAE4160C68051000200C9BF897C47E7FFBFBF7F283735508D51 + C3DBF9B65416639DE6E34AA8BF1DDF67D9E3DB2AB95A37D8A51101D12005F049 + 26B3E03774C65A3F658D3640100A35FA842BFC09E3502AC3F111542BE038ACFF + 7EEEC71A35AC74F4B6F7DDD23DAF59262EA3D375E917CE9DE94B3683D24B61CE + ACBE7ED475E76D7B8B5943D98ED8CDE432BDE06B2B091EA20D9E7236D4E11C09 + 43B58A9C8310A1C187EBF626B3ACAF89C4DDEE576629CEA35317D3F1E36B33E2 + F798691ED92E25DB4EE56907F2E5AB8D797F07EB4B6B5FF4DD374DC246C20E16 + B597833D0D05ADAECCF8DA9E4720121AEEFD9CCFB14221DFD4745D4A19289D27 + 01775DF74618E616534C4F3E63F71E617A198B45289769621F9C234D2F040644 + CA0BCF073EECFF62BBBB3B91484B251CBE2C7870F5F3A694E4BC01605F6BD330 + 3BC10E9E3CA0E3041F0967840354009C1A642D3DAD9E00C53A4C480864283400 + 00000049454E44AE426082} + Stretch = True + Visible = False + OnClick = LanguageImgClick + ExplicitLeft = 453 + end + object ResolutionLbl: TLabel + Left = 40 + Top = 105 + Width = 74 + Height = 21 + Caption = 'Resolution' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + end + object ResolutionPbox: TPaintBox + Left = 40 + Top = 131 + Width = 282 + Height = 31 + OnPaint = PboxPaint + end + object PresentationCbx: TComboBox + Left = 41 + Top = 55 + Width = 280 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 1 + OnChange = PresentationCbxChange + Items.Strings = ( + 'Fullscreen' + 'Fullscreen Upscaled' + 'Borderless' + 'Windowed') + end + object MaintasChk: TToggleSwitch + Left = 40 + Top = 209 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 0 + OnClick = MaintasChkClick + end + object VsyncChk: TToggleSwitch + Left = 40 + Top = 277 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 2 + OnClick = VsyncChkClick + end + object AdjmouseChk: TToggleSwitch + Left = 40 + Top = 345 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 3 + OnClick = AdjmouseChkClick + end + object DevmodeChk: TToggleSwitch + Left = 40 + Top = 413 + Width = 50 + Height = 20 + ShowStateCaption = False + TabOrder = 4 + OnClick = DevmodeChkClick + end + object ThemePnl: TPanel + Left = 471 + Top = 8 + Width = 16 + Height = 11 + Anchors = [akTop, akRight] + BevelOuter = bvNone + Color = 2039583 + ParentBackground = False + TabOrder = 5 + StyleElements = [seFont, seBorder] + OnClick = ThemePnlClick + ExplicitLeft = 467 + end + object ResolutionCbx: TComboBox + Left = 41 + Top = 132 + Width = 280 + Height = 29 + BevelEdges = [] + BevelInner = bvNone + BevelOuter = bvSpace + Style = csDropDownList + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -16 + Font.Name = 'Segoe UI' + Font.Style = [] + ParentFont = False + TabOrder = 6 + OnChange = PresentationCbxChange + Items.Strings = ( + '640x480 (4:3)' + '800x608 (4:3)' + '832x480 (16:9)' + '960x544 (16:9)' + '1280x704 (16:9)' + '1280x544 (21:9)' + '768x480 (16:10)' + '960x608 (16:10)') + end + end object MenuPnl: TPanel Left = 0 Top = 8 @@ -3557,6 +3568,7 @@ object ConfigForm: TConfigForm Color = clMenu ParentBackground = False TabOrder = 0 + ExplicitHeight = 466 DesignSize = ( 233 467) From 93c6e120b61359e24424665b26e91f558bfa798c Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 3 Feb 2024 21:06:24 +0100 Subject: [PATCH 26/47] restore original .ini file name --- config/ConfigFormUnit.cpp | 16 ++++++++-------- config/cnc-ddraw config.cpp | 2 +- src/config.c | 10 +++++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 4cc22a1..64d0014 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -40,7 +40,7 @@ void __fastcall TConfigForm::CreateParams(TCreateParams & Params) void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) { - auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *ini = new TIniFile(".\\ddraw.ini"); ini->WriteString("ddraw", "configlang", IsEnglish ? "auto" : "english"); delete ini; @@ -57,7 +57,7 @@ void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) void __fastcall TConfigForm::ThemePnlClick(TObject *Sender) { - auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *ini = new TIniFile(".\\ddraw.ini"); auto theme = ThemePnl->Color == (TColor)RGB(31, 31, 31) ? "Cobalt XEMedia" : "Windows10"; @@ -86,7 +86,7 @@ void __fastcall TConfigForm::RestoreDefaultsBtnClick(TObject *Sender) return; } - DeleteFile(".\\dd-hd.ini"); + DeleteFile(".\\ddraw.ini"); ShellExecute( NULL, @@ -676,8 +676,8 @@ void __fastcall TConfigForm::CompatibilityBtnClick(TObject *Sender) void __fastcall TConfigForm::FormCreate(TObject *Sender) { - /* Let cnc-ddraw create a new dd-hd.ini if it doesn't exist */ - if (FileExists(".\\ddraw.dll") && !FileExists(".\\dd-hd.ini")) { + /* Let cnc-ddraw create a new ddraw.ini if it doesn't exist */ + if (FileExists(".\\ddraw.dll") && !FileExists(".\\ddraw.ini")) { SetEnvironmentVariableW(L"cnc_ddraw_config_init", L"1"); @@ -701,7 +701,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) } } - auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *ini = new TIniFile(".\\ddraw.ini"); auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); if (ini->ReadString("ddraw", "configtheme", "Windows10") == "Cobalt XEMedia") { @@ -906,7 +906,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) RestoreDefaultsBtn->Visible = FileExists(".\\ddraw.dll") && - FileExists(".\\dd-hd.ini") && + FileExists(".\\ddraw.ini") && GetBool(ini, "allow_reset", true); delete ini; @@ -920,7 +920,7 @@ void TConfigForm::SaveSettings() if (!Initialized) return; - auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *ini = new TIniFile(".\\ddraw.ini"); auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); /* Display Settings */ diff --git a/config/cnc-ddraw config.cpp b/config/cnc-ddraw config.cpp index f88df0c..7cb64d5 100644 --- a/config/cnc-ddraw config.cpp +++ b/config/cnc-ddraw config.cpp @@ -31,7 +31,7 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) return 0; } - auto *ini = new TIniFile(".\\dd-hd.ini"); + auto *ini = new TIniFile(".\\ddraw.ini"); auto theme = ini->ReadString("ddraw", "configtheme", "Windows10"); TStyleManager::TrySetStyle( diff --git a/src/config.c b/src/config.c index 1ddacc1..eaca4d7 100644 --- a/src/config.c +++ b/src/config.c @@ -685,6 +685,14 @@ static void cfg_create_ini() "maintas=false\n" "boxing=false\n" "\n" + "; Diablo\n" + "[Diablo]\n" + "devmode=true\n" + "\n" + "; Diablo: Hellfire\n" + "[hellfire]\n" + "devmode=true\n" + "\n" "; Eggsucker\n" "[eggsucker]\n" "fixpitch=true\n" @@ -1003,7 +1011,7 @@ static void cfg_init() } /* set up settings ini */ - strncpy(g_config.ini_path, ".\\dd-hd.ini", sizeof(g_config.ini_path) - 1); + strncpy(g_config.ini_path, ".\\ddraw.ini", sizeof(g_config.ini_path) - 1); if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES) cfg_create_ini(); From de2e3bb26631709ad314c923382f6d1db05bc2ef Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 16 Feb 2024 01:45:41 +0100 Subject: [PATCH 27/47] add new resolution settings --- config/ConfigFormUnit.cpp | 10 +++++----- config/ConfigFormUnit.dfm | 16 ++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 64d0014..cae9037 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -738,10 +738,10 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) int cwidth = hd_ini->ReadInteger("Game", "Width", 0); int cheight = hd_ini->ReadInteger("Game", "Height", 0); - int reso = hd_ini->ReadInteger("Game", "Resolution", 3); + int reso = hd_ini->ReadInteger("Game", "Resolution", 4); if (!cwidth || !cheight) { - ResolutionCbx->ItemIndex = reso <= 7 ? reso : 3; + ResolutionCbx->ItemIndex = reso <= 10 ? reso : 4; } else { ResolutionCbx->AddItem(IntToStr(cwidth) + "x" + IntToStr(cheight), NULL); @@ -948,14 +948,14 @@ void TConfigForm::SaveSettings() break; } - if (ResolutionCbx->ItemIndex <= 7) { + if (ResolutionCbx->ItemIndex <= 10) { hd_ini->WriteInteger("Game", "Resolution", ResolutionCbx->ItemIndex); hd_ini->WriteInteger("Game", "Width", 0); hd_ini->WriteInteger("Game", "Height", 0); - if (ResolutionCbx->Items->Count == 9) { - ResolutionCbx->Items->Delete(8); + if (ResolutionCbx->Items->Count == 12) { + ResolutionCbx->Items->Delete(11); } } diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 533b68b..7bcdc25 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -3539,6 +3539,7 @@ object ConfigForm: TConfigForm BevelInner = bvNone BevelOuter = bvSpace Style = csDropDownList + DropDownCount = 11 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 @@ -3548,14 +3549,17 @@ object ConfigForm: TConfigForm TabOrder = 6 OnChange = PresentationCbxChange Items.Strings = ( - '640x480 (4:3)' - '800x608 (4:3)' - '832x480 (16:9)' - '960x544 (16:9)' + '640x480 (4:3)' + '800x608 (4:3)' + '1024x768 (4:3)' + '832x480 (16:9)' + '960x544 (16:9)' '1280x704 (16:9)' + '1120x480 (21:9)' '1280x544 (21:9)' - '768x480 (16:10)' - '960x608 (16:10)') + '768x480 (16:10)' + '960x608 (16:10)' + '1280x800 (16:10)') end end object MenuPnl: TPanel From 6aae09eea9466b07a4d5c19ca8b293c572735601 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 16 Feb 2024 01:46:54 +0100 Subject: [PATCH 28/47] increase dropdowncount --- config/ConfigFormUnit.dfm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 7bcdc25..786a72b 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -3539,7 +3539,7 @@ object ConfigForm: TConfigForm BevelInner = bvNone BevelOuter = bvSpace Style = csDropDownList - DropDownCount = 11 + DropDownCount = 12 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 @@ -3549,17 +3549,17 @@ object ConfigForm: TConfigForm TabOrder = 6 OnChange = PresentationCbxChange Items.Strings = ( - '640x480 (4:3)' - '800x608 (4:3)' - '1024x768 (4:3)' - '832x480 (16:9)' - '960x544 (16:9)' - '1280x704 (16:9)' - '1120x480 (21:9)' - '1280x544 (21:9)' - '768x480 (16:10)' - '960x608 (16:10)' - '1280x800 (16:10)') + '640x480 (4:3)' + '800x608 (4:3)' + '1024x768 (4:3)' + '832x480 (16:9)' + '960x544 (16:9)' + '1280x704 (16:9)' + '1120x480 (21:9)' + '1280x544 (21:9)' + '768x480 (16:10)' + '960x608 (16:10)' + '1280x800 (16:10)') end end object MenuPnl: TPanel From 0a88e48e60a136139e8c7b10a981c7ecf28886f4 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 16 Feb 2024 04:21:13 +0100 Subject: [PATCH 29/47] reset resolution to default --- config/ConfigFormUnit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index cae9037..11cec77 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -86,6 +86,14 @@ void __fastcall TConfigForm::RestoreDefaultsBtnClick(TObject *Sender) return; } + auto *ini = new TIniFile(".\\Warcraft II BNE.ini"); + + ini->WriteString("Game", "Resolution", "4"); + ini->WriteString("Game", "Width", "0"); + ini->WriteString("Game", "Height", "0"); + + delete ini; + DeleteFile(".\\ddraw.ini"); ShellExecute( From b9eead19477bf6890ab9dd36e4dc5aa880a217c3 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Fri, 16 Feb 2024 04:22:53 +0100 Subject: [PATCH 30/47] fix url --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index eaca4d7..5d48d41 100644 --- a/src/config.c +++ b/src/config.c @@ -241,7 +241,7 @@ static void cfg_create_ini() if (fh) { fputs( - "; cnc-ddraw - https://github.com/CnCNet/cnc-ddraw - https://cncnet.org\n" + "; cnc-ddraw - https://github.com/FunkyFr3sh/cnc-ddraw\n" "\n" "[ddraw]\n" "; ### Optional settings ###\n" From 608cb6fa684e045572f13b0063c473436e4e5824 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 17 Feb 2024 03:49:32 +0100 Subject: [PATCH 31/47] add 1024x576 to config --- config/ConfigFormUnit.cpp | 8 ++++---- config/ConfigFormUnit.dfm | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 11cec77..6a00eb9 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -749,7 +749,7 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) int reso = hd_ini->ReadInteger("Game", "Resolution", 4); if (!cwidth || !cheight) { - ResolutionCbx->ItemIndex = reso <= 10 ? reso : 4; + ResolutionCbx->ItemIndex = reso <= 11 ? reso : 4; } else { ResolutionCbx->AddItem(IntToStr(cwidth) + "x" + IntToStr(cheight), NULL); @@ -956,14 +956,14 @@ void TConfigForm::SaveSettings() break; } - if (ResolutionCbx->ItemIndex <= 10) { + if (ResolutionCbx->ItemIndex <= 11) { hd_ini->WriteInteger("Game", "Resolution", ResolutionCbx->ItemIndex); hd_ini->WriteInteger("Game", "Width", 0); hd_ini->WriteInteger("Game", "Height", 0); - if (ResolutionCbx->Items->Count == 12) { - ResolutionCbx->Items->Delete(11); + if (ResolutionCbx->Items->Count == 13) { + ResolutionCbx->Items->Delete(12); } } diff --git a/config/ConfigFormUnit.dfm b/config/ConfigFormUnit.dfm index 786a72b..62c57de 100644 --- a/config/ConfigFormUnit.dfm +++ b/config/ConfigFormUnit.dfm @@ -3539,7 +3539,7 @@ object ConfigForm: TConfigForm BevelInner = bvNone BevelOuter = bvSpace Style = csDropDownList - DropDownCount = 12 + DropDownCount = 13 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -16 @@ -3554,6 +3554,7 @@ object ConfigForm: TConfigForm '1024x768 (4:3)' '832x480 (16:9)' '960x544 (16:9)' + '1024x576 (16:9)' '1280x704 (16:9)' '1120x480 (21:9)' '1280x544 (21:9)' From 6ead8985be1f35a2e2f0cde8e9c3d57a834cb530 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 7 Mar 2024 17:42:36 +0100 Subject: [PATCH 32/47] fix screenshot names --- src/screenshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screenshot.c b/src/screenshot.c index 02e3d22..0720f03 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -132,7 +132,7 @@ BOOL ss_take_screenshot(IDirectDrawSurfaceImpl* src) } } - strftime(str_time, sizeof(str_time), "%Y-%m-%d-%H_%M_%S", localtime(&t)); + strftime(str_time, sizeof(str_time), "%Y-%m-%d_%H-%M-%S", localtime(&t)); _snprintf(filename, sizeof(filename), "%s-%s.png", title, str_time); if (src->bpp == 8 && src->palette) From bf7a3d021a8ae1318f87e2b2c912145550100c69 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Thu, 7 Mar 2024 17:44:34 +0100 Subject: [PATCH 33/47] fix screenshot names --- src/screenshot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/screenshot.c b/src/screenshot.c index 0720f03..76a7480 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -133,7 +133,7 @@ BOOL ss_take_screenshot(IDirectDrawSurfaceImpl* src) } strftime(str_time, sizeof(str_time), "%Y-%m-%d_%H-%M-%S", localtime(&t)); - _snprintf(filename, sizeof(filename), "%s-%s.png", title, str_time); + _snprintf(filename, sizeof(filename), "%s_%s.png", title, str_time); if (src->bpp == 8 && src->palette) { From 51d9ef58d9582581ce466090b426990f67efc9d5 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 3 Apr 2024 00:37:24 +0200 Subject: [PATCH 34/47] always use full path to avoid issues with working directories in wine --- config/ConfigFormUnit.cpp | 26 ++++++++++++++------------ config/cnc-ddraw config.cpp | 6 +++++- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 6a00eb9..790336a 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -23,6 +23,8 @@ int Savesettings; int Resolutions; int Minfps; +#define GAME_PATH (TPath::GetDirectoryName(Application->ExeName) + "\\") + //--------------------------------------------------------------------------- __fastcall TConfigForm::TConfigForm(TComponent* Owner) : TForm(Owner) @@ -40,7 +42,7 @@ void __fastcall TConfigForm::CreateParams(TCreateParams & Params) void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) { - auto *ini = new TIniFile(".\\ddraw.ini"); + auto *ini = new TIniFile(GAME_PATH + "ddraw.ini"); ini->WriteString("ddraw", "configlang", IsEnglish ? "auto" : "english"); delete ini; @@ -57,7 +59,7 @@ void __fastcall TConfigForm::LanguageImgClick(TObject *Sender) void __fastcall TConfigForm::ThemePnlClick(TObject *Sender) { - auto *ini = new TIniFile(".\\ddraw.ini"); + auto *ini = new TIniFile(GAME_PATH + "ddraw.ini"); auto theme = ThemePnl->Color == (TColor)RGB(31, 31, 31) ? "Cobalt XEMedia" : "Windows10"; @@ -86,7 +88,7 @@ void __fastcall TConfigForm::RestoreDefaultsBtnClick(TObject *Sender) return; } - auto *ini = new TIniFile(".\\Warcraft II BNE.ini"); + auto *ini = new TIniFile(GAME_PATH + "Warcraft II BNE.ini"); ini->WriteString("Game", "Resolution", "4"); ini->WriteString("Game", "Width", "0"); @@ -94,7 +96,7 @@ void __fastcall TConfigForm::RestoreDefaultsBtnClick(TObject *Sender) delete ini; - DeleteFile(".\\ddraw.ini"); + DeleteFile(GAME_PATH + "ddraw.ini"); ShellExecute( NULL, @@ -685,11 +687,11 @@ void __fastcall TConfigForm::CompatibilityBtnClick(TObject *Sender) void __fastcall TConfigForm::FormCreate(TObject *Sender) { /* Let cnc-ddraw create a new ddraw.ini if it doesn't exist */ - if (FileExists(".\\ddraw.dll") && !FileExists(".\\ddraw.ini")) { + if (FileExists(GAME_PATH + "ddraw.dll") && !FileExists(GAME_PATH + "ddraw.ini")) { SetEnvironmentVariableW(L"cnc_ddraw_config_init", L"1"); - HMODULE ddraw = LoadLibraryW(L".\\ddraw.dll"); + HMODULE ddraw = LoadLibraryW((GAME_PATH + "ddraw.dll").w_str()); if (ddraw) { @@ -709,8 +711,8 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) } } - auto *ini = new TIniFile(".\\ddraw.ini"); - auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); + auto *ini = new TIniFile(GAME_PATH + "ddraw.ini"); + auto *hd_ini = new TIniFile(GAME_PATH + "Warcraft II BNE.ini"); if (ini->ReadString("ddraw", "configtheme", "Windows10") == "Cobalt XEMedia") { @@ -913,8 +915,8 @@ void __fastcall TConfigForm::FormCreate(TObject *Sender) CompatibilityBtn->Visible = !GetBool(ini, "hide_compat_tab", false); RestoreDefaultsBtn->Visible = - FileExists(".\\ddraw.dll") && - FileExists(".\\ddraw.ini") && + FileExists(GAME_PATH + "ddraw.dll") && + FileExists(GAME_PATH + "ddraw.ini") && GetBool(ini, "allow_reset", true); delete ini; @@ -928,8 +930,8 @@ void TConfigForm::SaveSettings() if (!Initialized) return; - auto *ini = new TIniFile(".\\ddraw.ini"); - auto *hd_ini = new TIniFile(".\\Warcraft II BNE.ini"); + auto *ini = new TIniFile(GAME_PATH + "ddraw.ini"); + auto *hd_ini = new TIniFile(GAME_PATH + "Warcraft II BNE.ini"); /* Display Settings */ diff --git a/config/cnc-ddraw config.cpp b/config/cnc-ddraw config.cpp index 7cb64d5..0760b13 100644 --- a/config/cnc-ddraw config.cpp +++ b/config/cnc-ddraw config.cpp @@ -3,6 +3,7 @@ #include #pragma hdrstop #include +#include #include #include //--------------------------------------------------------------------------- @@ -10,6 +11,9 @@ #include USEFORM("ConfigFormUnit.cpp", ConfigForm); //--------------------------------------------------------------------------- + +#define GAME_PATH (TPath::GetDirectoryName(Application->ExeName) + "\\") + int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { try @@ -31,7 +35,7 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) return 0; } - auto *ini = new TIniFile(".\\ddraw.ini"); + auto *ini = new TIniFile(GAME_PATH + "ddraw.ini"); auto theme = ini->ReadString("ddraw", "configtheme", "Windows10"); TStyleManager::TrySetStyle( From 418df164469da393a424deb34ecf94438bb5fd22 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 22 May 2024 04:55:27 +0200 Subject: [PATCH 35/47] fix mousei input issues in diablo 1 --- src/winapi_hooks.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index 7ab3324..faf6514 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -734,6 +734,7 @@ HWND WINAPI fake_CreateWindowExA( g_ddraw->bnet_active = TRUE; SetTimer(g_ddraw->hwnd, IDT_TIMER_REDRAW_BNET, 200, (TIMERPROC)NULL); mouse_unlock(); + ReleaseCapture(); } POINT pt = { 0, 0 }; From 02aa3bc0d9302e27fb3c51bda8c594c28318f9ff Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 31 Jul 2023 07:33:57 +0200 Subject: [PATCH 36/47] remove fixwndprochook setting --- inc/dd.h | 1 - src/config.c | 5 ----- src/winapi_hooks.c | 24 ++++++------------------ 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/inc/dd.h b/inc/dd.h index 5fc29c0..c164705 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -140,7 +140,6 @@ typedef struct CNCDDRAW BOOL nonexclusive; BOOL fixpitch; int fixchilds; - BOOL fixwndprochook; BOOL fixnotresponding; BOOL locktopleft; BOOL d3d9linear; diff --git a/src/config.c b/src/config.c index 5d48d41..206cf8b 100644 --- a/src/config.c +++ b/src/config.c @@ -43,7 +43,6 @@ void cfg_load() g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT); - g_ddraw->fixwndprochook = cfg_get_bool("fixwndprochook", FALSE); g_ddraw->fixnotresponding = cfg_get_bool("fixnotresponding", FALSE); g_ddraw->locktopleft = cfg_get_bool("locktopleft", FALSE); g_ddraw->releasealt = cfg_get_bool("releasealt", FALSE); @@ -719,17 +718,14 @@ static void cfg_create_ini() "\n" "; Grand Theft Auto\n" "[Grand Theft Auto]\n" - "fixwndprochook=true\n" "singlecpu=false\n" "\n" "; Grand Theft Auto: London 1969\n" "[gta_uk]\n" - "fixwndprochook=true\n" "singlecpu=false\n" "\n" "; Grand Theft Auto: London 1961\n" "[Gta_61]\n" - "fixwndprochook=true\n" "singlecpu=false\n" "\n" "; Heroes of Might and Magic II: The Succession Wars\n" @@ -745,7 +741,6 @@ static void cfg_create_ini() "; Invictus\n" "[Invictus]\n" "adjmouse=true\n" - "fixwndprochook=true\n" "renderer=opengl\n" "\n" "; Interstate 76\n" diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index faf6514..c6ffd2d 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -428,24 +428,12 @@ LONG WINAPI fake_SetWindowLongA(HWND hWnd, int nIndex, LONG dwNewLong) if (nIndex == GWL_STYLE) return 0; - if (nIndex == GWL_WNDPROC && g_ddraw->fixwndprochook) + if (nIndex == GWL_WNDPROC) { - if (dwNewLong == (LONG)compat_WndProc) - { - WNDPROC old = g_ddraw->wndproc = g_compat_wndproc; - //g_compat_wndproc = NULL; - return (LONG)old; - } - else - { - if (dwNewLong != (LONG)g_ddraw->wndproc) - { - g_compat_wndproc = g_ddraw->wndproc; - g_ddraw->wndproc = (WNDPROC)dwNewLong; - } + WNDPROC old = g_ddraw->wndproc; + g_ddraw->wndproc = (WNDPROC)dwNewLong; - return (LONG)compat_WndProc; - } + return (LONG)old; } } @@ -456,9 +444,9 @@ LONG WINAPI fake_GetWindowLongA(HWND hWnd, int nIndex) { if (g_ddraw && g_ddraw->hwnd == hWnd) { - if (nIndex == GWL_WNDPROC && g_ddraw->fixwndprochook) + if (nIndex == GWL_WNDPROC) { - return (LONG)compat_WndProc; + return (LONG)g_ddraw->wndproc; } } From f0816d26a6d059d860d93f1f1bb3c4fc5a3d53de Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 25 Sep 2023 00:42:45 +0200 Subject: [PATCH 37/47] use english key names for now --- config/ConfigFormUnit.cpp | 51 +++++++++++++++++++++++++++++++++++---- config/ConfigFormUnit.h | 1 + 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 790336a..acd2b4b 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -1235,11 +1235,11 @@ WORD TConfigForm::GetKeyCode(System::UnicodeString key) return VK_PAUSE; } - if (key == L"R " + ShortCutToText(VK_CONTROL)) { + if (key == L"R " + TranslateShortCut(ShortCutToText(VK_CONTROL))) { return VK_RCONTROL; } - return TextToShortCut(key); + return TextToShortCut(TranslateShortCut(key)); } System::UnicodeString TConfigForm::GetKeyText(WORD key) @@ -1253,14 +1253,55 @@ System::UnicodeString TConfigForm::GetKeyText(WORD key) } if (key == VK_RCONTROL) { - return L"R " + ShortCutToText(VK_CONTROL); + return L"R " + TranslateShortCut(ShortCutToText(VK_CONTROL)); } if (key == VK_RSHIFT) { - return ShortCutToText(VK_SHIFT); + return TranslateShortCut(ShortCutToText(VK_SHIFT)); } - return ShortCutToText(key); + return TranslateShortCut(ShortCutToText(key)); +} + +System::UnicodeString TConfigForm::TranslateShortCut(System::UnicodeString text) +{ + /* Hack: Allows building the config tool on a german OS */ + if (text == "Eingabe") return "Enter"; + if (text == "Enter") return "Eingabe"; + if (text == "Leer") return "Space"; + if (text == "Space") return "Leer"; + if (text == "BildAuf") return "PgUp"; + if (text == "PgUp") return "BildAuf"; + if (text == "BildAb") return "PgDn"; + if (text == "PgDn") return "BildAb"; + if (text == "Ende") return "End"; + if (text == "End") return "Ende"; + if (text == "Pos1") return "Home"; + if (text == "Home") return "Pos1"; + if (text == "Links") return "Left"; + if (text == "Left") return "Links"; + if (text == "Auf") return "Up"; + if (text == "Up") return "Auf"; + if (text == "Rechts") return "Right"; + if (text == "Right") return "Rechts"; + if (text == "Ab") return "Down"; + if (text == "Down") return "Ab"; + if (text == "Einfg") return "Ins"; + if (text == "Ins") return "Einfg"; + if (text == "UMSCHALT") return "Shift"; + if (text == "Shift") return "UMSCHALT"; + if (text == "STRG") return "Ctrl"; + if (text == "Ctrl") return "STRG"; + if (text == "ALT") return "Alt"; + if (text == "Alt") return "ALT"; + if (text == "CTRL") return "Ctrl"; + if (text == "Ctrl") return "CTRL"; + if (text == "ROLLEN-FESTSTELL") return "Scroll Lock"; + if (text == "Scroll Lock") return "ROLLEN-FESTSTELL"; + if (text == "FESTSTELL") return "Caps Lock"; + if (text == "Caps Lock") return "FESTSTELL"; + + return text; } bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValue) diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index cb81a60..f521d0f 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -124,6 +124,7 @@ private: // Benutzer-Deklarationen void ApplyTranslation(TIniFile *ini); System::UnicodeString GetKeyText(WORD key); WORD GetKeyCode(System::UnicodeString key); + System::UnicodeString TranslateShortCut(System::UnicodeString text); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner); }; From da0ccd99e830bbe77f97096df72d5a78f6459d5f Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 25 Sep 2023 02:30:35 +0200 Subject: [PATCH 38/47] try to use translated key names --- config/ConfigFormUnit.cpp | 87 ++++++++++++++++++++------------------- config/ConfigFormUnit.h | 3 +- 2 files changed, 47 insertions(+), 43 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index acd2b4b..1a9e4f7 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -16,6 +16,7 @@ TConfigForm *ConfigForm; bool Initialized; bool IsEnglish; +System::UnicodeString KeyNames[256]; /* Save previous settings so we don't override custom settings */ int Maxfps; @@ -1235,11 +1236,11 @@ WORD TConfigForm::GetKeyCode(System::UnicodeString key) return VK_PAUSE; } - if (key == L"R " + TranslateShortCut(ShortCutToText(VK_CONTROL))) { + if (key == L"R " + KeyToText(VK_CONTROL)) { return VK_RCONTROL; } - return TextToShortCut(TranslateShortCut(key)); + return TextToKey(key); } System::UnicodeString TConfigForm::GetKeyText(WORD key) @@ -1253,55 +1254,57 @@ System::UnicodeString TConfigForm::GetKeyText(WORD key) } if (key == VK_RCONTROL) { - return L"R " + TranslateShortCut(ShortCutToText(VK_CONTROL)); + return L"R " + KeyToText(VK_CONTROL); } if (key == VK_RSHIFT) { - return TranslateShortCut(ShortCutToText(VK_SHIFT)); + return KeyToText(VK_SHIFT); } - return TranslateShortCut(ShortCutToText(key)); + return KeyToText(key); } -System::UnicodeString TConfigForm::TranslateShortCut(System::UnicodeString text) +WORD TConfigForm::TextToKey(System::UnicodeString Text) { - /* Hack: Allows building the config tool on a german OS */ - if (text == "Eingabe") return "Enter"; - if (text == "Enter") return "Eingabe"; - if (text == "Leer") return "Space"; - if (text == "Space") return "Leer"; - if (text == "BildAuf") return "PgUp"; - if (text == "PgUp") return "BildAuf"; - if (text == "BildAb") return "PgDn"; - if (text == "PgDn") return "BildAb"; - if (text == "Ende") return "End"; - if (text == "End") return "Ende"; - if (text == "Pos1") return "Home"; - if (text == "Home") return "Pos1"; - if (text == "Links") return "Left"; - if (text == "Left") return "Links"; - if (text == "Auf") return "Up"; - if (text == "Up") return "Auf"; - if (text == "Rechts") return "Right"; - if (text == "Right") return "Rechts"; - if (text == "Ab") return "Down"; - if (text == "Down") return "Ab"; - if (text == "Einfg") return "Ins"; - if (text == "Ins") return "Einfg"; - if (text == "UMSCHALT") return "Shift"; - if (text == "Shift") return "UMSCHALT"; - if (text == "STRG") return "Ctrl"; - if (text == "Ctrl") return "STRG"; - if (text == "ALT") return "Alt"; - if (text == "Alt") return "ALT"; - if (text == "CTRL") return "Ctrl"; - if (text == "Ctrl") return "CTRL"; - if (text == "ROLLEN-FESTSTELL") return "Scroll Lock"; - if (text == "Scroll Lock") return "ROLLEN-FESTSTELL"; - if (text == "FESTSTELL") return "Caps Lock"; - if (text == "Caps Lock") return "FESTSTELL"; + for (WORD i = 0; i < 256; i++) { + if (KeyNames[i] == Text) { + return i; + } + } - return text; + return 0; +} + +System::UnicodeString TConfigForm::KeyToText(WORD key) +{ + WCHAR keyName[256] = {}; + + UINT scanCode = MapVirtualKeyW(key, MAPVK_VK_TO_VSC); + + switch (key) { + case VK_LEFT: + case VK_UP: + case VK_RIGHT: + case VK_DOWN: + case VK_PRIOR: + case VK_NEXT: + case VK_END: + case VK_HOME: + case VK_INSERT: + case VK_DELETE: + case VK_DIVIDE: + case VK_NUMLOCK: + { + scanCode |= 0x100; + break; + } + } + + GetKeyNameTextW(scanCode << 16, keyName, sizeof(keyName) / sizeof(WCHAR)); + + KeyNames[(BYTE)key] = keyName; + + return KeyNames[(BYTE)key]; } bool TConfigForm::GetBool(TIniFile *ini, System::UnicodeString key, bool defValue) diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index f521d0f..83ed66a 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -124,7 +124,8 @@ private: // Benutzer-Deklarationen void ApplyTranslation(TIniFile *ini); System::UnicodeString GetKeyText(WORD key); WORD GetKeyCode(System::UnicodeString key); - System::UnicodeString TranslateShortCut(System::UnicodeString text); + WORD TextToKey(System::UnicodeString Text); + System::UnicodeString KeyToText(WORD key); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner); }; From 6987d1a773181b5ae981389a91db5d32303e4461 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 25 Sep 2023 02:57:59 +0200 Subject: [PATCH 39/47] remove unneeded function --- config/ConfigFormUnit.cpp | 30 ++++++++++++------------------ config/ConfigFormUnit.h | 3 +-- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 1a9e4f7..66d8be5 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -1226,21 +1226,27 @@ void __fastcall TConfigForm::HotkeyEdtKeyUp(TObject *Sender, WORD &Key, TShiftSt SaveSettings(); } -WORD TConfigForm::GetKeyCode(System::UnicodeString key) +WORD TConfigForm::GetKeyCode(System::UnicodeString text) { - if (key == L"PrtScn") { + if (text == L"PrtScn") { return VK_SNAPSHOT; } - if (key == L"Pause_") { + if (text == L"Pause_") { return VK_PAUSE; } - if (key == L"R " + KeyToText(VK_CONTROL)) { + if (text == L"R " + KeyToText(VK_CONTROL)) { return VK_RCONTROL; } - return TextToKey(key); + for (WORD i = 0; i < 256; i++) { + if (KeyNames[i] == text) { + return i; + } + } + + return 0; } System::UnicodeString TConfigForm::GetKeyText(WORD key) @@ -1264,21 +1270,8 @@ System::UnicodeString TConfigForm::GetKeyText(WORD key) return KeyToText(key); } -WORD TConfigForm::TextToKey(System::UnicodeString Text) -{ - for (WORD i = 0; i < 256; i++) { - if (KeyNames[i] == Text) { - return i; - } - } - - return 0; -} - System::UnicodeString TConfigForm::KeyToText(WORD key) { - WCHAR keyName[256] = {}; - UINT scanCode = MapVirtualKeyW(key, MAPVK_VK_TO_VSC); switch (key) { @@ -1300,6 +1293,7 @@ System::UnicodeString TConfigForm::KeyToText(WORD key) } } + WCHAR keyName[256] = {}; GetKeyNameTextW(scanCode << 16, keyName, sizeof(keyName) / sizeof(WCHAR)); KeyNames[(BYTE)key] = keyName; diff --git a/config/ConfigFormUnit.h b/config/ConfigFormUnit.h index 83ed66a..3a77681 100644 --- a/config/ConfigFormUnit.h +++ b/config/ConfigFormUnit.h @@ -123,8 +123,7 @@ private: // Benutzer-Deklarationen bool GetBool(TIniFile *ini, System::UnicodeString key, bool defValue); void ApplyTranslation(TIniFile *ini); System::UnicodeString GetKeyText(WORD key); - WORD GetKeyCode(System::UnicodeString key); - WORD TextToKey(System::UnicodeString Text); + WORD GetKeyCode(System::UnicodeString text); System::UnicodeString KeyToText(WORD key); public: // Benutzer-Deklarationen __fastcall TConfigForm(TComponent* Owner); From a4e95ac6a0714bd6d02930f8e392b9acf3781287 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 3 Jul 2023 02:59:04 +0200 Subject: [PATCH 40/47] force pos 0,0 in borderless mode --- src/config.c | 5 ----- src/dd.c | 11 ++++++++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/config.c b/src/config.c index 206cf8b..483843f 100644 --- a/src/config.c +++ b/src/config.c @@ -112,11 +112,6 @@ void cfg_load() g_ddraw->flip_limiter.tick_length = (DWORD)(flip_len + 0.5f); } - if ((g_ddraw->fullscreen = cfg_get_bool("fullscreen", FALSE))) - { - g_config.window_rect.left = g_config.window_rect.top = -32000; - } - if (cfg_get_bool("singlecpu", TRUE)) { SetProcessAffinityMask(GetCurrentProcess(), 1); diff --git a/src/dd.c b/src/dd.c index 73773f3..c3cc184 100644 --- a/src/dd.c +++ b/src/dd.c @@ -450,9 +450,6 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl { border = FALSE; - g_config.window_rect.left = -32000; - g_config.window_rect.top = -32000; - /* prevent OpenGL from going automatically into fullscreen exclusive mode */ if (g_ddraw->renderer == ogl_render_main) nonexclusive = TRUE; @@ -672,6 +669,14 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl int x = (g_config.window_rect.left != -32000) ? g_config.window_rect.left : (cy / 2) - (g_ddraw->render.width / 2); int y = (g_config.window_rect.top != -32000) ? g_config.window_rect.top : (cx / 2) - (g_ddraw->render.height / 2); + if (nonexclusive) + { + x = y = 0; + } + + if (IsIconic(g_ddraw->hwnd)) + real_ShowWindow(g_ddraw->hwnd, SW_RESTORE); + RECT dst = { x, y, g_ddraw->render.width + x, g_ddraw->render.height + y }; AdjustWindowRect(&dst, GetWindowLong(g_ddraw->hwnd, GWL_STYLE), FALSE); From f2a613ff2aadbd09cefe71769031d5731c17df76 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Mon, 3 Jul 2023 05:13:47 +0200 Subject: [PATCH 41/47] new .ini setting #toggle_borderless --- inc/config.h | 1 + inc/dd.h | 1 + src/config.c | 13 +++++++++- src/utils.c | 71 +++++++++++++++++++++++++++++++-------------------- src/wndproc.c | 2 +- 5 files changed, 59 insertions(+), 29 deletions(-) diff --git a/inc/config.h b/inc/config.h index f70523c..89598eb 100644 --- a/inc/config.h +++ b/inc/config.h @@ -9,6 +9,7 @@ typedef struct CNCDDRAWCONFIG { RECT window_rect; int window_state; + int borderless_state; char ini_path[MAX_PATH]; char game_path[MAX_PATH]; char process_file_name[MAX_PATH]; diff --git a/inc/dd.h b/inc/dd.h index c164705..a60f8bf 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -137,6 +137,7 @@ typedef struct CNCDDRAW int show_cursor_count; BOOL accurate_timers; BOOL resizable; + BOOL toggle_borderless; BOOL nonexclusive; BOOL fixpitch; int fixchilds; diff --git a/src/config.c b/src/config.c index 483843f..8c2c82d 100644 --- a/src/config.c +++ b/src/config.c @@ -16,7 +16,7 @@ static void cfg_init(); static void cfg_create_ini(); CNCDDRAWCONFIG g_config = - { .window_rect = {.left = -32000, .top = -32000, .right = 0, .bottom = 0 }, .window_state = -1 }; + { .window_rect = {.left = -32000, .top = -32000, .right = 0, .bottom = 0 }, .window_state = -1, .borderless_state = -1 }; void cfg_load() { @@ -40,6 +40,7 @@ void cfg_load() g_ddraw->vhack = cfg_get_bool("vhack", FALSE); g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE); g_ddraw->resizable = cfg_get_bool("resizable", TRUE); + g_ddraw->toggle_borderless = cfg_get_bool("toggle_borderless", FALSE); g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT); @@ -112,6 +113,8 @@ void cfg_load() g_ddraw->flip_limiter.tick_length = (DWORD)(flip_len + 0.5f); } + g_ddraw->fullscreen = cfg_get_bool("fullscreen", FALSE); + if (cfg_get_bool("singlecpu", TRUE)) { SetProcessAffinityMask(GetCurrentProcess(), 1); @@ -227,6 +230,11 @@ void cfg_save() { WritePrivateProfileString(section, "windowed", g_config.window_state ? "true" : "false", g_config.ini_path); } + + if (g_config.borderless_state != -1) + { + WritePrivateProfileString(section, "fullscreen", g_config.borderless_state ? "true" : "false", g_config.ini_path); + } } static void cfg_create_ini() @@ -304,6 +312,9 @@ static void cfg_create_ini() "; cnc-ddraw config program language, possible values: auto, english, chinese, german, spanish, russian, hungarian, french\n" "configlang=auto\n" "\n" + "; Switch between windowed/borderless modes with alt+enter rather than windowed/fullscreen modes\n" + "toggle_borderless=false\n" + "\n" "\n" "\n" "; ### Compatibility settings ###\n" diff --git a/src/utils.c b/src/utils.c index 8958fb1..9d528ee 100644 --- a/src/utils.c +++ b/src/utils.c @@ -281,39 +281,56 @@ void util_toggle_fullscreen() memset(g_ddraw->primary->bnet_surface, 0, g_ddraw->width * g_ddraw->height); - if (g_ddraw->windowed) + if (g_ddraw->toggle_borderless) { - mouse_unlock(); - - g_config.window_state = g_ddraw->windowed = FALSE; - LONG style = GetWindowLong(g_ddraw->hwnd, GWL_STYLE); - - real_SetWindowLongA( - g_ddraw->hwnd, - GWL_STYLE, - style & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)); - - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_WINDOWED); - util_update_bnet_pos(0, 0); - - mouse_lock(); - } - else - { - mouse_unlock(); - g_config.window_state = g_ddraw->windowed = TRUE; - - if (g_ddraw->renderer == d3d9_render_main) + if (!g_ddraw->fullscreen) { - d3d9_reset(); + mouse_unlock(); + + g_config.borderless_state = g_ddraw->fullscreen = TRUE; + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); + + mouse_lock(); } else { - ChangeDisplaySettings(NULL, g_ddraw->bnet_active ? CDS_FULLSCREEN : 0); - } + mouse_unlock(); - dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_FULLSCREEN); - //mouse_lock(); + g_config.borderless_state = g_ddraw->fullscreen = FALSE; + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); + + //mouse_lock(); + } + } + else + { + if (g_ddraw->windowed) + { + mouse_unlock(); + + g_config.window_state = g_ddraw->windowed = FALSE; + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_WINDOWED); + util_update_bnet_pos(0, 0); + + mouse_lock(); + } + else + { + mouse_unlock(); + g_config.window_state = g_ddraw->windowed = TRUE; + + if (g_ddraw->renderer == d3d9_render_main) + { + d3d9_reset(); + } + else + { + ChangeDisplaySettings(NULL, g_ddraw->bnet_active ? CDS_FULLSCREEN : 0); + } + + dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_FULLSCREEN); + //mouse_lock(); + } } } diff --git a/src/wndproc.c b/src/wndproc.c index 736c626..3ac0677 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -586,7 +586,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam if (g_ddraw->hotkeys.toggle_fullscreen && wParam == g_ddraw->hotkeys.toggle_fullscreen && - !g_ddraw->fullscreen && + (!g_ddraw->fullscreen || (g_ddraw->windowed && g_ddraw->toggle_borderless)) && context_code && !key_state && g_ddraw->renderer != d3d9_render_main) From eeefbb9b717e80fdf77de1a306752aa1132b778b Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 14 Nov 2023 17:16:23 +0100 Subject: [PATCH 42/47] add support for alt+enter in fullscreen upscaled mode --- src/utils.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/utils.c b/src/utils.c index 9d528ee..1ff93a7 100644 --- a/src/utils.c +++ b/src/utils.c @@ -287,7 +287,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.borderless_state = g_ddraw->fullscreen = TRUE; + g_config.upscaled_state = g_config.fullscreen = TRUE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); mouse_lock(); @@ -296,7 +296,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.borderless_state = g_ddraw->fullscreen = FALSE; + g_config.upscaled_state = g_config.fullscreen = FALSE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); //mouse_lock(); @@ -308,7 +308,12 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.window_state = g_ddraw->windowed = FALSE; + 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); @@ -317,7 +322,13 @@ void util_toggle_fullscreen() else { mouse_unlock(); - g_config.window_state = g_ddraw->windowed = TRUE; + + 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) { From 952fe4fe1a005505852befea2a6903de05e569be Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 4 Dec 2024 21:57:52 +0100 Subject: [PATCH 43/47] add support for alt+enter in fullscreen upscaled mode --- inc/config.h | 2 +- inc/dd.h | 1 + src/config.c | 10 +++++++--- src/utils.c | 16 ++++++++-------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/inc/config.h b/inc/config.h index 89598eb..2937e26 100644 --- a/inc/config.h +++ b/inc/config.h @@ -9,7 +9,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]; diff --git a/inc/dd.h b/inc/dd.h index a60f8bf..fb4af12 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -138,6 +138,7 @@ typedef struct CNCDDRAW BOOL accurate_timers; BOOL resizable; BOOL toggle_borderless; + BOOL toggle_upscaled; BOOL nonexclusive; BOOL fixpitch; int fixchilds; diff --git a/src/config.c b/src/config.c index 8c2c82d..2bbfa04 100644 --- a/src/config.c +++ b/src/config.c @@ -16,7 +16,7 @@ static void cfg_init(); static void cfg_create_ini(); 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() { @@ -41,6 +41,7 @@ void cfg_load() g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE); g_ddraw->resizable = cfg_get_bool("resizable", TRUE); g_ddraw->toggle_borderless = cfg_get_bool("toggle_borderless", FALSE); + g_ddraw->toggle_upscaled = cfg_get_bool("toggle_upscaled", FALSE); g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE); g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE); g_ddraw->fixchilds = cfg_get_int("fixchilds", FIX_CHILDS_DETECT_PAINT); @@ -231,9 +232,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); } } @@ -315,6 +316,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 1ff93a7..3b18210 100644 --- a/src/utils.c +++ b/src/utils.c @@ -287,7 +287,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.upscaled_state = g_config.fullscreen = TRUE; + g_config.upscaled_state = g_ddraw->fullscreen = TRUE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); mouse_lock(); @@ -296,7 +296,7 @@ void util_toggle_fullscreen() { mouse_unlock(); - g_config.upscaled_state = g_config.fullscreen = FALSE; + g_config.upscaled_state = g_ddraw->fullscreen = FALSE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, 0); //mouse_lock(); @@ -308,12 +308,12 @@ void util_toggle_fullscreen() { mouse_unlock(); - if (g_config.toggle_upscaled) + if (g_ddraw->toggle_upscaled) { - g_config.upscaled_state = g_config.fullscreen = TRUE; + g_config.upscaled_state = g_ddraw->fullscreen = TRUE; } - g_config.window_state = g_config.windowed = FALSE; + g_config.window_state = g_ddraw->windowed = FALSE; dd_SetDisplayMode(g_ddraw->width, g_ddraw->height, g_ddraw->bpp, SDM_LEAVE_WINDOWED); util_update_bnet_pos(0, 0); @@ -323,12 +323,12 @@ void util_toggle_fullscreen() { mouse_unlock(); - if (g_config.toggle_upscaled) + if (g_ddraw->toggle_upscaled) { - g_config.upscaled_state = g_config.fullscreen = FALSE; + g_config.upscaled_state = g_ddraw->fullscreen = FALSE; } - g_config.window_state = g_config.windowed = TRUE; + g_config.window_state = g_ddraw->windowed = TRUE; if (g_ddraw->renderer == d3d9_render_main) { From 292af455b67a90c86f713cc716fcd845b6035e43 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Tue, 14 Nov 2023 17:24:41 +0100 Subject: [PATCH 44/47] set new toggle_fullscreen bool --- config/ConfigFormUnit.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/ConfigFormUnit.cpp b/config/ConfigFormUnit.cpp index 66d8be5..35c99f4 100644 --- a/config/ConfigFormUnit.cpp +++ b/config/ConfigFormUnit.cpp @@ -941,15 +941,19 @@ void TConfigForm::SaveSettings() ini->WriteString("ddraw", "windowed", "false"); ini->WriteString("ddraw", "fullscreen", "false"); ini->WriteString("ddraw", "toggle_borderless", "false"); + ini->WriteString("ddraw", "toggle_upscaled", "false"); break; case 1: ini->WriteString("ddraw", "windowed", "false"); ini->WriteString("ddraw", "fullscreen", "true"); + ini->WriteString("ddraw", "toggle_borderless", "false"); + ini->WriteString("ddraw", "toggle_upscaled", "true"); break; case 2: ini->WriteString("ddraw", "windowed", "true"); ini->WriteString("ddraw", "fullscreen", "true"); ini->WriteString("ddraw", "toggle_borderless", "true"); + ini->WriteString("ddraw", "toggle_upscaled", "false"); break; case 3: ini->WriteString("ddraw", "windowed", "true"); From 2ec028e87a1353f7cc8cf45cad9e1c0be1967bdd Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Wed, 4 Dec 2024 22:05:38 +0100 Subject: [PATCH 45/47] allow alt+enter with fullscreen upscaled mode --- src/wndproc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wndproc.c b/src/wndproc.c index 3ac0677..ef88b6b 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -586,7 +586,6 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam if (g_ddraw->hotkeys.toggle_fullscreen && wParam == g_ddraw->hotkeys.toggle_fullscreen && - (!g_ddraw->fullscreen || (g_ddraw->windowed && g_ddraw->toggle_borderless)) && context_code && !key_state && g_ddraw->renderer != d3d9_render_main) From 6d44a0b122a2e5df4945d30d9ac11d2a2fc6d21d Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 7 Dec 2024 05:01:22 +0100 Subject: [PATCH 46/47] fix issue where game is shifted towards the bottom right after joining the lobby twice --- src/dd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dd.c b/src/dd.c index c3cc184..eed4a76 100644 --- a/src/dd.c +++ b/src/dd.c @@ -669,7 +669,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl int x = (g_config.window_rect.left != -32000) ? g_config.window_rect.left : (cy / 2) - (g_ddraw->render.width / 2); int y = (g_config.window_rect.top != -32000) ? g_config.window_rect.top : (cx / 2) - (g_ddraw->render.height / 2); - if (nonexclusive) + if (g_ddraw->fullscreen) { x = y = 0; } From 666a3ad0e32e5d6690d6072b694e52529b473ddc Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 7 Dec 2024 05:29:10 +0100 Subject: [PATCH 47/47] only use shader if upscaling is enabled --- src/render_ogl.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/render_ogl.c b/src/render_ogl.c index 60d87cd..80f34b7 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -150,7 +150,21 @@ static void ogl_build_programs() _snprintf(shader_path, sizeof(shader_path) - 1, "%s%s", g_config.game_path, g_ddraw->shader); } - g_ogl.scale_program = oglu_build_program_from_file(shader_path, wglCreateContextAttribsARB != NULL); + BOOL is_upscaler = + strstr(g_ddraw->shader, "fsr.glsl") != NULL || + strstr(g_ddraw->shader, "catmull-rom-bilinear.glsl") != NULL || + strstr(g_ddraw->shader, "lanczos2-sharp.glsl") != NULL || + strstr(g_ddraw->shader, "xbr-lv2-noblend.glsl") != NULL || + strstr(g_ddraw->shader, "xbrz-freescale-multipass.glsl") != NULL || + strstr(g_ddraw->shader, "xbrz-freescale.glsl") != NULL; + + if (!is_upscaler || + g_ddraw->render.viewport.width != g_ddraw->width || + g_ddraw->render.viewport.height != g_ddraw->height || + g_ddraw->vhack) + { + g_ogl.scale_program = oglu_build_program_from_file(shader_path, wglCreateContextAttribsARB != NULL); + } } else {