Removed confirmation for exit done from the menu.

Issue #173.
This commit is contained in:
Muzychenko Andrey 2023-03-10 09:28:28 +03:00
parent 4b86fe2aa7
commit f521a03322
3 changed files with 10 additions and 6 deletions

View File

@ -562,7 +562,7 @@ void pb::InputDown(GameInput input)
const auto bindings = options::MapGameInput(input); const auto bindings = options::MapGameInput(input);
for (const auto binding : bindings) for (const auto binding : bindings)
{ {
winmain::HandleGameBinding(binding); winmain::HandleGameBinding(binding, true);
} }
if (game_mode != GameModes::InGame || winmain::single_step || demo_mode) if (game_mode != GameModes::InGame || winmain::single_step || demo_mode)

View File

@ -1131,7 +1131,7 @@ void winmain::UpdateFrameRate()
TargetFrameTime = DurationMs(1000.0 / ups); TargetFrameTime = DurationMs(1000.0 / ups);
} }
void winmain::HandleGameBinding(GameBindings binding) void winmain::HandleGameBinding(GameBindings binding, bool shortcut)
{ {
switch (binding) switch (binding)
{ {
@ -1158,10 +1158,14 @@ void winmain::HandleGameBinding(GameBindings binding)
options::toggle(Menu1::Show_Menu); options::toggle(Menu1::Show_Menu);
break; break;
case GameBindings::Exit: case GameBindings::Exit:
if (!shortcut)
{ {
SDL_Event event{SDL_QUIT};
SDL_PushEvent(&event);
}
else
ShowExitPopup = true; ShowExitPopup = true;
break; break;
}
default: default:
break; break;
} }
@ -1236,6 +1240,6 @@ void winmain::ImGuiMenuItemWShortcut(GameBindings binding, bool selected)
const auto& keyDef = Options.Key[~binding]; const auto& keyDef = Options.Key[~binding];
if (ImGui::MenuItem(pb::get_rc_string(keyDef.Description), keyDef.GetShortcutDescription().c_str(), selected)) if (ImGui::MenuItem(pb::get_rc_string(keyDef.Description), keyDef.GetShortcutDescription().c_str(), selected))
{ {
HandleGameBinding(binding); HandleGameBinding(binding, false);
} }
} }

View File

@ -86,7 +86,7 @@ public:
static void pause(bool toggle = true); static void pause(bool toggle = true);
static void Restart(); static void Restart();
static void UpdateFrameRate(); static void UpdateFrameRate();
static void HandleGameBinding(GameBindings binding); static void HandleGameBinding(GameBindings binding, bool shortcut);
private: private:
static int return_value; static int return_value;
static int mouse_down, last_mouse_x, last_mouse_y; static int mouse_down, last_mouse_x, last_mouse_y;