mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
Snake: Remember if game was paused when picking color
If we were paused before, don't start the game after closing the dialog.
This commit is contained in:
parent
4f496e97fe
commit
3ce87ea5f9
2 changed files with 6 additions and 1 deletions
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
virtual ~Game() override = default;
|
||||
|
||||
bool is_paused() const { return !has_timer(); }
|
||||
void start();
|
||||
void pause();
|
||||
void reset();
|
||||
|
|
|
@ -94,10 +94,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Change snake color", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/color-chooser.png"sv)), [&](auto&) {
|
||||
game.pause();
|
||||
auto was_paused = game.is_paused();
|
||||
if (!was_paused)
|
||||
game.pause();
|
||||
auto dialog = GUI::ColorPicker::construct(Gfx::Color::White, window);
|
||||
if (dialog->exec() == GUI::Dialog::ExecResult::OK)
|
||||
game.set_snake_base_color(dialog->color());
|
||||
game.start();
|
||||
if (!was_paused)
|
||||
game.start();
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
|
|
Loading…
Add table
Reference in a new issue