From f521a03322b062b8a83fafcdb8f3da6a72c5d101 Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Fri, 10 Mar 2023 09:28:28 +0300 Subject: [PATCH] Removed confirmation for exit done from the menu. Issue #173. --- SpaceCadetPinball/pb.cpp | 2 +- SpaceCadetPinball/winmain.cpp | 12 ++++++++---- SpaceCadetPinball/winmain.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SpaceCadetPinball/pb.cpp b/SpaceCadetPinball/pb.cpp index 7288e12..4da44b2 100644 --- a/SpaceCadetPinball/pb.cpp +++ b/SpaceCadetPinball/pb.cpp @@ -562,7 +562,7 @@ void pb::InputDown(GameInput input) const auto bindings = options::MapGameInput(input); for (const auto binding : bindings) { - winmain::HandleGameBinding(binding); + winmain::HandleGameBinding(binding, true); } if (game_mode != GameModes::InGame || winmain::single_step || demo_mode) diff --git a/SpaceCadetPinball/winmain.cpp b/SpaceCadetPinball/winmain.cpp index 5113065..b5408d7 100644 --- a/SpaceCadetPinball/winmain.cpp +++ b/SpaceCadetPinball/winmain.cpp @@ -1131,7 +1131,7 @@ void winmain::UpdateFrameRate() TargetFrameTime = DurationMs(1000.0 / ups); } -void winmain::HandleGameBinding(GameBindings binding) +void winmain::HandleGameBinding(GameBindings binding, bool shortcut) { switch (binding) { @@ -1158,10 +1158,14 @@ void winmain::HandleGameBinding(GameBindings binding) options::toggle(Menu1::Show_Menu); break; case GameBindings::Exit: + if (!shortcut) { - ShowExitPopup = true; - break; + SDL_Event event{SDL_QUIT}; + SDL_PushEvent(&event); } + else + ShowExitPopup = true; + break; default: break; } @@ -1236,6 +1240,6 @@ void winmain::ImGuiMenuItemWShortcut(GameBindings binding, bool selected) const auto& keyDef = Options.Key[~binding]; if (ImGui::MenuItem(pb::get_rc_string(keyDef.Description), keyDef.GetShortcutDescription().c_str(), selected)) { - HandleGameBinding(binding); + HandleGameBinding(binding, false); } } diff --git a/SpaceCadetPinball/winmain.h b/SpaceCadetPinball/winmain.h index a78c222..a58f8ff 100644 --- a/SpaceCadetPinball/winmain.h +++ b/SpaceCadetPinball/winmain.h @@ -86,7 +86,7 @@ public: static void pause(bool toggle = true); static void Restart(); static void UpdateFrameRate(); - static void HandleGameBinding(GameBindings binding); + static void HandleGameBinding(GameBindings binding, bool shortcut); private: static int return_value; static int mouse_down, last_mouse_x, last_mouse_y;