1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 06:14:58 +00:00

Solitaire: Hide solve button when game ends

`on_game_start` is not called until the player makes a move, so waiting
until then means that the solve button would still be visible when
starting a new game after completing one. By hiding the button in
`on_game_end`, this happens when the game-over animation starts playing
instead.
This commit is contained in:
Sam Atkins 2024-01-11 12:23:23 +00:00 committed by Andrew Kaster
parent 8b3fd16da8
commit 4ed5287792

View file

@ -100,6 +100,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
game.start_solving();
solve_button.set_enabled(false);
};
solve_button.set_enabled(false);
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
statusbar.set_text(0, "Score: 0"_string);
@ -126,8 +127,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}));
game.on_game_start = [&]() {
solve_button.set_enabled(false);
action_bar.set_visible(false);
seconds_elapsed = 0;
timer->start();
statusbar.set_text(2, "Time: 00:00"_string);
@ -141,6 +140,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
timer->stop();
solve_button.set_enabled(false);
action_bar.set_visible(false);
if (reason == Solitaire::GameOverReason::Victory) {
if (seconds_elapsed >= 30) {