1
0
mirror of https://github.com/k4zmu2a/SpaceCadetPinball.git synced 2024-11-12 22:02:40 +01:00

Don't resume game when paused manually (#118)

You get an annoying behavior when:
- press F3 to pause
- minimize the window
- (keep it in the background, do other stuff)
- bring the window back to focus, accidentally (Alt+Tab)
- game resumes even if I explicitly paused it with F3

This commit makes F3 (and Pause in the menu) require an explicit
resume via F3 (or Pause), other pauses like moving the window still
get resumed automatically.
This commit is contained in:
Gábor Dobra 2022-01-05 06:25:39 +01:00 committed by GitHub
parent ed0ef9044d
commit bd90b9d712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -32,6 +32,7 @@ int winmain::no_time_loss;
UINT winmain::iFrostUniqueMsg;
bool winmain::restart = false;
bool winmain::explicitPaused = false;
gdrv_bitmap8 winmain::gfr_display{};
char winmain::DatFileName[300]{};
@ -522,7 +523,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
new_game();
break;
case VK_F3:
pause();
pause(false);
break;
case VK_F4:
options::toggle(0x193u);
@ -602,14 +603,14 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
switch (wParam)
{
case Menu1_Launch_Ball:
end_pause();
end_pause(true);
pb::launch_ball();
break;
case Menu1_Pause_Resume_Game:
pause();
pause(false);
break;
case Menu1_Demo:
end_pause();
end_pause(true);
pb::toggle_demo();
break;
case Menu1_Select_Table:
@ -844,10 +845,14 @@ int winmain::a_dialog(HINSTANCE hInstance, HWND hWnd)
return ShellAboutW(hWnd, appName, szOtherStuff, icon);
}
void winmain::end_pause()
void winmain::end_pause(bool explicitResume)
{
if (single_step)
{
if (explicitPaused && !explicitResume)
return;
explicitPaused = false;
if (fullscrn::screen_mode)
fullscrn::set_menu_mode(0);
pb::pause_continue();
@ -857,14 +862,17 @@ void winmain::end_pause()
void winmain::new_game()
{
end_pause();
end_pause(true);
HCURSOR prevCursor = SetCursor(LoadCursorA(nullptr, IDC_WAIT));
pb::replay_level(0);
SetCursor(prevCursor);
}
void winmain::pause()
void winmain::pause(bool autoResume)
{
if (!autoResume)
winmain::explicitPaused = true;
if (fullscrn::screen_mode)
{
if (single_step)

View File

@ -18,9 +18,9 @@ public:
static int check_expiration_date();
static HDC _GetDC(HWND hWnd);
static int a_dialog(HINSTANCE hInstance, HWND hWnd);
static void end_pause();
static void end_pause(bool explicitResume = false);
static void new_game();
static void pause();
static void pause(bool autoResume = true);
static void help_introduction(HINSTANCE a1, HWND a2);
static void Restart();
private:
@ -30,6 +30,7 @@ private:
static gdrv_bitmap8 gfr_display;
static HCURSOR mouse_hsave;
static bool restart;
static bool explicitPaused;
static HDC _BeginPaint(HWND hWnd, LPPAINTSTRUCT lpPaint);
static void ResetTimer()