mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
try to get at least some windowed games working with zero config
This commit is contained in:
parent
aa357c044d
commit
33666bbd19
1
inc/dd.h
1
inc/dd.h
@ -166,7 +166,6 @@ typedef struct CNCDDRAW
|
|||||||
int y;
|
int y;
|
||||||
} textbox; /* Age Of Empires 2 textbox align */
|
} textbox; /* Age Of Empires 2 textbox align */
|
||||||
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
BOOL enabled;
|
BOOL enabled;
|
||||||
|
31
src/dd.c
31
src/dd.c
@ -1427,6 +1427,13 @@ HRESULT dd_SetCooperativeLevel(HWND hwnd, DWORD dwFlags)
|
|||||||
|
|
||||||
dd_SetDisplayMode(width, height, bpp, 0);
|
dd_SetDisplayMode(width, height, bpp, 0);
|
||||||
}
|
}
|
||||||
|
else if (!g_ddraw.width)
|
||||||
|
{
|
||||||
|
RECT rc = { 0 };
|
||||||
|
real_GetClientRect(hwnd, &rc);
|
||||||
|
|
||||||
|
dd_SetDisplayMode(rc.right, rc.bottom, 16, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
@ -1579,10 +1586,30 @@ ULONG dd_Release()
|
|||||||
|
|
||||||
DeleteCriticalSection(&g_ddraw.cs);
|
DeleteCriticalSection(&g_ddraw.cs);
|
||||||
|
|
||||||
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
|
if (g_ddraw.hwnd && IsWindow(g_ddraw.hwnd))
|
||||||
if (g_ddraw.hwnd)
|
|
||||||
{
|
{
|
||||||
|
/* restore old wndproc, subsequent ddraw creation will otherwise fail */
|
||||||
real_SetWindowLongA(g_ddraw.hwnd, GWL_WNDPROC, (LONG)g_ddraw.wndproc);
|
real_SetWindowLongA(g_ddraw.hwnd, GWL_WNDPROC, (LONG)g_ddraw.wndproc);
|
||||||
|
|
||||||
|
/* restore old window size, required for games that can switch between windowed and fullscreen during runtime */
|
||||||
|
if (g_ddraw.width)
|
||||||
|
{
|
||||||
|
RECT rc = { 0, 0, g_ddraw.width, g_ddraw.height };
|
||||||
|
|
||||||
|
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
||||||
|
LONG exstyle = real_GetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE);
|
||||||
|
|
||||||
|
AdjustWindowRectEx(&rc, style, GetMenu(g_ddraw.hwnd) != NULL, exstyle);
|
||||||
|
|
||||||
|
real_SetWindowPos(
|
||||||
|
g_ddraw.hwnd,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
(rc.right - rc.left),
|
||||||
|
(rc.bottom - rc.top),
|
||||||
|
SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&g_ddraw, 0, sizeof(g_ddraw));
|
memset(&g_ddraw, 0, sizeof(g_ddraw));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user