From 8afaa7f30e64ad5cdf840df36044de714d2d1cbc Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 18 May 2021 09:04:24 -0400 Subject: [PATCH] 2048: Display action status tips in status bar --- Userland/Games/2048/main.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index adcf0db70cc..9ba195712b7 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -87,6 +88,17 @@ int main(int argc, char** argv) board_view.set_focus(true); auto& statusbar = main_widget.add(); + app->on_action_enter = [&](GUI::Action& action) { + auto text = action.status_tip(); + if (text.is_empty()) + text = Gfx::parse_ampersand_string(action.text()); + statusbar.set_override_text(move(text)); + }; + + app->on_action_leave = [&](GUI::Action&) { + statusbar.set_override_text({}); + }; + auto update = [&]() { board_view.set_board(&game.board()); board_view.update();