1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-26 10:29:23 +01:00

make sure mhack is always enabled when required

This commit is contained in:
FunkyFr3sh 2017-11-20 01:26:53 +01:00
parent 8b34ec65ad
commit bde38c9b0b
2 changed files with 26 additions and 5 deletions

View File

@ -29,7 +29,7 @@
/* from mouse.c */ /* from mouse.c */
BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint); BOOL WINAPI fake_GetCursorPos(LPPOINT lpPoint);
void mouse_init(HWND); void mouse_init();
void mouse_lock(); void mouse_lock();
void mouse_unlock(); void mouse_unlock();
@ -290,6 +290,12 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
if (This->render.width > This->mode.dmPelsWidth || This->render.height > This->mode.dmPelsHeight) if (This->render.width > This->mode.dmPelsWidth || This->render.height > This->mode.dmPelsHeight)
{ {
// chosen game resolution higher than current resolution, use window mode for this case // chosen game resolution higher than current resolution, use window mode for this case
if (!This->mhack)
{
This->mhack = TRUE;
mouse_init();
}
This->windowed = TRUE; This->windowed = TRUE;
} }
else else
@ -319,6 +325,12 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
This->render.mode.dmPelsWidth = This->render.width; This->render.mode.dmPelsWidth = This->render.width;
This->render.mode.dmPelsHeight = This->render.height; This->render.mode.dmPelsHeight = This->render.height;
if (!This->mhack)
{
This->mhack = TRUE;
mouse_init();
}
This->windowed = TRUE; This->windowed = TRUE;
} }
} }
@ -425,6 +437,12 @@ void ToggleFullscreen()
{ {
if(ChangeDisplaySettings(&ddraw->mode, 0) == DISP_CHANGE_SUCCESSFUL) if(ChangeDisplaySettings(&ddraw->mode, 0) == DISP_CHANGE_SUCCESSFUL)
{ {
if (!ddraw->devmode && !ddraw->mhack)
{
ddraw->mhack = TRUE;
mouse_init();
}
if (!ddraw->border) if (!ddraw->border)
{ {
SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU)); SetWindowLong(ddraw->hWnd, GWL_STYLE, GetWindowLong(ddraw->hWnd, GWL_STYLE) & ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU));
@ -635,7 +653,7 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW
This->hWnd = hWnd; This->hWnd = hWnd;
} }
mouse_init(hWnd); mouse_init();
This->WndProc = (LRESULT CALLBACK (*)(HWND, UINT, WPARAM, LPARAM))GetWindowLong(hWnd, GWL_WNDPROC); This->WndProc = (LRESULT CALLBACK (*)(HWND, UINT, WPARAM, LPARAM))GetWindowLong(hWnd, GWL_WNDPROC);
@ -978,6 +996,9 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
This->mhack = FALSE; This->mhack = FALSE;
} }
if (This->windowed)
This->mhack = TRUE;
GetPrivateProfileStringA("ddraw", "devmode", "FALSE", tmp, sizeof(tmp), SettingsIniPath); GetPrivateProfileStringA("ddraw", "devmode", "FALSE", tmp, sizeof(tmp), SettingsIniPath);
if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1') if (tolower(tmp[0]) == 'y' || tolower(tmp[0]) == 't' || tolower(tmp[0]) == 'e' || tmp[0] == '1')
{ {

View File

@ -246,7 +246,7 @@ void mouse_unlock()
} }
} }
void mouse_init(HWND hWnd) void mouse_init()
{ {
if(ddraw->mhack || ddraw->devmode) if(ddraw->mhack || ddraw->devmode)
{ {