Merge pull request #65 from twolife/pause

Pause the game when the window is minimized
This commit is contained in:
ptitSeb 2023-05-04 16:48:33 +02:00 committed by GitHub
commit 3e36706d26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -85,6 +85,11 @@ BOOL PeekMessage(MSG *msg, void *hwnd, UINT wMsgFilterMin,
msg->message = WM_PAINT;
return TRUE;
}
if (sdlevent.window.event == SDL_WINDOWEVENT_MINIMIZED)
{
msg->wParam = sdlevent.window.event;
return TRUE;
}
break;
// These all map to WM_* things without any drama.

View File

@ -1028,7 +1028,21 @@ int SubMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
}
}
#else
STUBBED("SDL2 can handle these events");
if( msg.message==SDL_WINDOWEVENT)
{
switch( msg.wParam) {
case SDL_WINDOWEVENT_MINIMIZED:
if( _bWindowChanging) break;
_bWindowChanging = TRUE;
_bReconsiderInput = TRUE;
// if allowed, not already paused and only in single player game mode
if( sam_bPauseOnMinimize && !_pNetwork->IsPaused() && _gmRunningGameMode==GM_SINGLE_PLAYER) {
// pause game
_pNetwork->TogglePause();
}
break;
}
}
#endif
// toggle full-screen on alt-enter