mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
resize window on bnet
This commit is contained in:
parent
43224a0f65
commit
8f28bfad9c
@ -41,6 +41,7 @@ extern BOOL ChildWindowExists;
|
|||||||
BOOL detect_cutscene();
|
BOOL detect_cutscene();
|
||||||
void LimitGameTicks();
|
void LimitGameTicks();
|
||||||
void ToggleFullscreen();
|
void ToggleFullscreen();
|
||||||
|
void SetWindowRect(int x, int y, int width, int height, UINT flags);
|
||||||
DWORD WINAPI render_main(void);
|
DWORD WINAPI render_main(void);
|
||||||
DWORD WINAPI render_soft_main(void);
|
DWORD WINAPI render_soft_main(void);
|
||||||
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
|
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
|
||||||
@ -131,6 +132,8 @@ typedef struct IDirectDrawImpl
|
|||||||
BOOL resizable;
|
BOOL resizable;
|
||||||
BOOL bnetActive;
|
BOOL bnetActive;
|
||||||
BOOL bnetWasFullscreen;
|
BOOL bnetWasFullscreen;
|
||||||
|
RECT bnetWinRect;
|
||||||
|
POINT bnetPos;
|
||||||
SpeedLimiter ticksLimiter;
|
SpeedLimiter ticksLimiter;
|
||||||
SpeedLimiter flipLimiter;
|
SpeedLimiter flipLimiter;
|
||||||
SpeedLimiter fpsLimiter;
|
SpeedLimiter fpsLimiter;
|
||||||
|
31
src/main.c
31
src/main.c
@ -1002,6 +1002,37 @@ BOOL UnadjustWindowRectEx(LPRECT prc, DWORD dwStyle, BOOL fMenu, DWORD dwExStyle
|
|||||||
return fRc;
|
return fRc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetWindowRect(int x, int y, int width, int height, UINT flags)
|
||||||
|
{
|
||||||
|
if (ddraw->windowed)
|
||||||
|
{
|
||||||
|
if (ddraw->render.thread)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&ddraw->cs);
|
||||||
|
ddraw->render.run = FALSE;
|
||||||
|
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||||
|
LeaveCriticalSection(&ddraw->cs);
|
||||||
|
|
||||||
|
WaitForSingleObject(ddraw->render.thread, INFINITE);
|
||||||
|
ddraw->render.thread = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & SWP_NOMOVE) == 0)
|
||||||
|
{
|
||||||
|
WindowRect.left = x;
|
||||||
|
WindowRect.top = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & SWP_NOSIZE) == 0)
|
||||||
|
{
|
||||||
|
WindowRect.bottom = height;
|
||||||
|
WindowRect.right = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
ddraw_SetDisplayMode(ddraw, ddraw->width, ddraw->height, ddraw->bpp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
RECT rc = { 0, 0, ddraw->render.width, ddraw->render.height };
|
RECT rc = { 0, 0, ddraw->render.width, ddraw->render.height };
|
||||||
|
36
src/mouse.c
36
src/mouse.c
@ -435,9 +435,26 @@ BOOL WINAPI fake_DestroyWindow(HWND hWnd)
|
|||||||
ddraw->bnetActive = FALSE;
|
ddraw->bnetActive = FALSE;
|
||||||
mouse_lock();
|
mouse_lock();
|
||||||
|
|
||||||
if (ddraw->windowed && ddraw->bnetWasFullscreen)
|
if (ddraw->windowed)
|
||||||
{
|
{
|
||||||
SetTimer(ddraw->hWnd, IDT_TIMER_LEAVE_BNET, 1000, (TIMERPROC)NULL);
|
if (!ddraw->fullscreen)
|
||||||
|
{
|
||||||
|
ddraw->bnetPos.x = ddraw->bnetPos.y = 0;
|
||||||
|
ClientToScreen(ddraw->hWnd, &ddraw->bnetPos);
|
||||||
|
|
||||||
|
int width = ddraw->bnetWinRect.right - ddraw->bnetWinRect.left;
|
||||||
|
int height = ddraw->bnetWinRect.bottom - ddraw->bnetWinRect.top;
|
||||||
|
UINT flags = width != ddraw->width || height != ddraw->height ? 0 : SWP_NOMOVE;
|
||||||
|
|
||||||
|
SetWindowRect(ddraw->bnetWinRect.left, ddraw->bnetWinRect.top, width, height, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ddraw->bnetWasFullscreen)
|
||||||
|
{
|
||||||
|
SetTimer(ddraw->hWnd, IDT_TIMER_LEAVE_BNET, 1000, (TIMERPROC)NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ddraw->resizable = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,6 +478,21 @@ HWND WINAPI fake_CreateWindowExA(
|
|||||||
ddraw->bnetWasFullscreen = TRUE;
|
ddraw->bnetWasFullscreen = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ddraw->fullscreen)
|
||||||
|
{
|
||||||
|
GetClientRect(ddraw->hWnd, &ddraw->bnetWinRect);
|
||||||
|
MapWindowPoints(ddraw->hWnd, HWND_DESKTOP, (LPPOINT)&ddraw->bnetWinRect, 2);
|
||||||
|
|
||||||
|
int width = ddraw->bnetWinRect.right - ddraw->bnetWinRect.left;
|
||||||
|
int height = ddraw->bnetWinRect.bottom - ddraw->bnetWinRect.top;
|
||||||
|
int x = ddraw->bnetPos.x || ddraw->bnetPos.y ? ddraw->bnetPos.x : -32000;
|
||||||
|
int y = ddraw->bnetPos.x || ddraw->bnetPos.y ? ddraw->bnetPos.y : -32000;
|
||||||
|
UINT flags = width != ddraw->width || height != ddraw->height ? 0 : SWP_NOMOVE;
|
||||||
|
|
||||||
|
SetWindowRect(x, y, ddraw->width, ddraw->height, flags);
|
||||||
|
ddraw->resizable = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
ddraw->bnetActive = TRUE;
|
ddraw->bnetActive = TRUE;
|
||||||
mouse_unlock();
|
mouse_unlock();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user