diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-05-18 09:04:24 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-18 16:48:39 +0200 |
commit | 8afaa7f30e64ad5cdf840df36044de714d2d1cbc (patch) | |
tree | c576aecd2b249b3f30112fb9ea3704b07f785540 /Userland | |
parent | 97cee35471e9c58860d3157e9a895f25933304b4 (diff) | |
download | serenity-8afaa7f30e64ad5cdf840df36044de714d2d1cbc.zip |
2048: Display action status tips in status bar
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Games/2048/main.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index adcf0db70c..9ba195712b 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -18,6 +18,7 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Statusbar.h> #include <LibGUI/Window.h> +#include <LibGfx/Painter.h> #include <stdio.h> #include <time.h> #include <unistd.h> @@ -87,6 +88,17 @@ int main(int argc, char** argv) board_view.set_focus(true); auto& statusbar = main_widget.add<GUI::Statusbar>(); + 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(); |