mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
fix tiberian sun menus
This commit is contained in:
parent
b04dc01104
commit
5e4de793d4
@ -35,6 +35,7 @@ BOOL detect_cutscene();
|
||||
void LimitGameTicks(BOOL isBltOrFlip);
|
||||
DWORD WINAPI render_main(void);
|
||||
DWORD WINAPI render_soft_main(void);
|
||||
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam);
|
||||
|
||||
struct IDirectDrawImpl;
|
||||
struct IDirectDrawImplVtbl;
|
||||
|
57
src/main.c
57
src/main.c
@ -103,6 +103,27 @@ BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
|
||||
{
|
||||
IDirectDrawSurfaceImpl *this = (IDirectDrawSurfaceImpl *)lParam;
|
||||
|
||||
HDC hDC = GetDC(hWnd);
|
||||
|
||||
RECT size;
|
||||
GetClientRect(hWnd, &size);
|
||||
|
||||
RECT pos;
|
||||
GetWindowRect(hWnd, &pos);
|
||||
|
||||
MapWindowPoints(HWND_DESKTOP, ddraw->hWnd, (LPPOINT)&pos, 2);
|
||||
|
||||
BitBlt(hDC, 0, 0, size.right, size.bottom, this->hDC, pos.left, pos.top, SRCCOPY);
|
||||
|
||||
ReleaseDC(hWnd, hDC);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static unsigned char getPixel(int x, int y)
|
||||
{
|
||||
return ((unsigned char *)ddraw->primary->surface)[y*ddraw->primary->lPitch + x*ddraw->primary->lXPitch];
|
||||
@ -709,6 +730,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
RECT rc = { 0, 0, ddraw->render.width, ddraw->render.height };
|
||||
static BOOL inSizeMove = FALSE;
|
||||
static int redrawCount = 0;
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
@ -920,6 +942,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
|
||||
if (!ddraw->hidemouse)
|
||||
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
|
||||
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam); /* Carmageddon fix */
|
||||
}
|
||||
|
||||
@ -954,6 +979,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
InterlockedExchange(&ddraw->minimized, FALSE);
|
||||
}
|
||||
|
||||
if (!ddraw->hidemouse)
|
||||
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
|
||||
}
|
||||
else if (wParam == WA_INACTIVE)
|
||||
{
|
||||
@ -1109,19 +1137,34 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
|
||||
/* make sure we redraw when WM_PAINT is requested */
|
||||
//Workaround for invisible menu on Load/Save/Delete in Tiberian Sun
|
||||
case WM_PARENTNOTIFY:
|
||||
{
|
||||
if (!ddraw->hidemouse && LOWORD(wParam) == WM_DESTROY)
|
||||
redrawCount = 2;
|
||||
break;
|
||||
}
|
||||
case WM_PAINT:
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
break;
|
||||
{
|
||||
if (!ddraw->hidemouse && redrawCount > 0)
|
||||
{
|
||||
redrawCount--;
|
||||
RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
|
||||
}
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
FillRect(ddraw->render.hDC, &rc, (HBRUSH) GetStockObject(BLACK_BRUSH));
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND:
|
||||
{
|
||||
EnterCriticalSection(&ddraw->cs);
|
||||
FillRect(ddraw->render.hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
|
||||
ReleaseSemaphore(ddraw->render.sem, 1, NULL);
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ddraw->WndProc(hWnd, uMsg, wParam, lParam);
|
||||
|
19
src/mouse.c
19
src/mouse.c
@ -311,14 +311,21 @@ void mouse_unlock()
|
||||
|
||||
BOOL WINAPI fake_GetWindowRect(HWND hWnd, LPRECT lpRect)
|
||||
{
|
||||
if (lpRect && ddraw && ddraw->hWnd == hWnd)
|
||||
if (lpRect && ddraw)
|
||||
{
|
||||
lpRect->bottom = ddraw->height;
|
||||
lpRect->left = 0;
|
||||
lpRect->right = ddraw->width;
|
||||
lpRect->top = 0;
|
||||
if (ddraw->hWnd == hWnd)
|
||||
{
|
||||
lpRect->bottom = ddraw->height;
|
||||
lpRect->left = 0;
|
||||
lpRect->right = ddraw->width;
|
||||
lpRect->top = 0;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetWindowRect(hWnd, lpRect) && MapWindowPoints(HWND_DESKTOP, ddraw->hWnd, (LPPOINT)lpRect, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return GetWindowRect(hWnd, lpRect);
|
||||
|
@ -644,6 +644,9 @@ static void Render()
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
UseOpenGL = FALSE;
|
||||
}
|
||||
|
||||
if (!ddraw->hidemouse)
|
||||
EnumChildWindows(ddraw->hWnd, EnumChildProc, (LPARAM)ddraw->primary);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
@ -375,6 +375,9 @@ DWORD WINAPI render_d3d9_main(void)
|
||||
IDirect3DTexture9_UnlockRect(PaletteTex[palIndex], 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ddraw->hidemouse)
|
||||
EnumChildWindows(ddraw->hWnd, EnumChildProc, (LPARAM)ddraw->primary);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
@ -116,6 +116,9 @@ DWORD WINAPI render_soft_main(void)
|
||||
ddraw->primary->bmi,
|
||||
DIB_RGB_COLORS);
|
||||
}
|
||||
|
||||
if (!ddraw->hidemouse)
|
||||
EnumChildWindows(ddraw->hWnd, EnumChildProc, (LPARAM)ddraw->primary);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&ddraw->cs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user