2048: Display action status tips in status bar

This commit is contained in:
Timothy Flynn 2021-05-18 09:04:24 -04:00 committed by Andreas Kling
parent 97cee35471
commit 8afaa7f30e
Notes: sideshowbarker 2024-07-18 17:50:22 +09:00

View file

@ -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();