diff options
author | Dylan Katz <dykatz@uw.edu> | 2022-01-09 20:45:12 -0800 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-01-10 00:58:40 -0800 |
commit | fe3bd062b782c10ce0043a0d6a4b8e54ac7abcf8 (patch) | |
tree | 207cd4cb3baa99d0ab123363eaef35adce982fe7 | |
parent | 0fda98dfb3d2212d865c9b1b41a122eb1bd07a4c (diff) | |
download | serenity-fe3bd062b782c10ce0043a0d6a4b8e54ac7abcf8.zip |
2048: Simplify dialog box when target reached
Previously, upon reaching the target, the player is presented with
potentially two dialog boxes: one asking if the user wants to
continue endlessly and another showing the player's statistics,
which would only be shown if the user does not want to continue.
This commit consolidates these into a single dialog box that shows
the relevant statistics and asks the user if they want to continue
endlessly.
-rw-r--r-- | Userland/Games/2048/main.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 429e7bbe5d..3af1a99245 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -141,19 +141,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) break; case Game::MoveOutcome::Won: { update(); - auto message_box = GUI::MessageBox::construct(window, "Congratulations! You won the game, Do you still want to continue?", - "Want to continue?", + auto want_to_continue = GUI::MessageBox::show(window, + String::formatted("You won the game in {} turns with a score of {}. Would you like to continue?", game.turns(), game.score()), + "Congratulations!", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); - if (message_box->exec() == GUI::MessageBox::ExecYes) + if (want_to_continue == GUI::MessageBox::ExecYes) game.set_want_to_continue(); - else { - GUI::MessageBox::show(window, - String::formatted("You reached {} in {} turns with a score of {}", game.largest_tile(), game.turns(), game.score()), - "You won!", - GUI::MessageBox::Type::Information); + else start_a_new_game(); - } break; } case Game::MoveOutcome::GameOver: |