Snake: Show status tips in Statusbar

This commit is contained in:
Sam Atkins 2023-06-17 17:02:41 +01:00 committed by Andreas Kling
parent 46f365df5c
commit b264d29515
Notes: sideshowbarker 2024-07-17 07:31:31 +09:00

View file

@ -64,6 +64,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& statusbar = *widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar"sv);
statusbar.set_text(0, TRY("Score: 0"_string));
statusbar.set_text(1, TRY(String::formatted("High Score: {}", high_score)));
GUI::Application::the()->on_action_enter = [&statusbar](GUI::Action& action) {
statusbar.set_override_text(action.status_tip());
};
GUI::Application::the()->on_action_leave = [&statusbar](GUI::Action&) {
statusbar.set_override_text({});
};
game.on_score_update = [&](auto score) {
statusbar.set_text(0, String::formatted("Score: {}", score).release_value_but_fixme_should_propagate_errors());