summaryrefslogtreecommitdiff
path: root/Userland/Games
diff options
context:
space:
mode:
authorJamie Mansfield <jmansfield@cadixdev.org>2021-07-27 12:18:29 +0100
committerAndreas Kling <kling@serenityos.org>2021-07-27 16:53:56 +0200
commitf7eb6772ce0e6502f54cccf5a38379ca30110254 (patch)
tree4d8f34bc2291bace7f88c9955cfa4d6609e56223 /Userland/Games
parent4df9d05f91f3fc33d690f9c570459dfac2dce4f8 (diff)
downloadserenity-f7eb6772ce0e6502f54cccf5a38379ca30110254.zip
Spider: Get user confirmation to close when there is a active game
Diffstat (limited to 'Userland/Games')
-rw-r--r--Userland/Games/Spider/main.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp
index 5bb08011c6..ed39f1d73b 100644
--- a/Userland/Games/Spider/main.cpp
+++ b/Userland/Games/Spider/main.cpp
@@ -155,6 +155,24 @@ int main(int argc, char** argv)
statusbar.set_text(2, "Timer starts after your first move");
};
+ window->on_close_request = [&]() {
+ auto game_in_progress = timer->is_active();
+ if (game_in_progress) {
+ auto result = GUI::MessageBox::show(window,
+ "A game is still in progress, are you sure you would like to quit?",
+ "Game in progress",
+ GUI::MessageBox::Type::Warning,
+ GUI::MessageBox::InputType::YesNoCancel);
+
+ if (result == GUI::MessageBox::ExecYes)
+ return GUI::Window::CloseRequestDecision::Close;
+ else
+ return GUI::Window::CloseRequestDecision::StayOpen;
+ }
+
+ return GUI::Window::CloseRequestDecision::Close;
+ };
+
GUI::ActionGroup suit_actions;
suit_actions.set_exclusive(true);