diff options
author | Martin Frederic <juni@fat.fm> | 2022-04-02 16:52:58 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-15 00:13:09 +0200 |
commit | 740beea5ce3b23b46472b3d2dd00686f72922545 (patch) | |
tree | faf4d473f241b6840e89902d6d9cc935dc8d1394 /Userland/Games/Pong/main.cpp | |
parent | a4639fced91d74a9532e68fe9014a876ff0bfef1 (diff) | |
download | serenity-740beea5ce3b23b46472b3d2dd00686f72922545.zip |
Pong: Add 'New Game' action
This declares Game::reset() public and lets the menu action invoke it.
Diffstat (limited to 'Userland/Games/Pong/main.cpp')
-rw-r--r-- | Userland/Games/Pong/main.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Games/Pong/main.cpp b/Userland/Games/Pong/main.cpp index fb3accfc3f..fc9fd1c8e4 100644 --- a/Userland/Games/Pong/main.cpp +++ b/Userland/Games/Pong/main.cpp @@ -37,10 +37,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) window->set_icon(app_icon.bitmap_for_size(16)); window->set_title("Pong"); window->set_double_buffering_enabled(false); - (void)TRY(window->try_set_main_widget<Pong::Game>()); + auto game = TRY(window->try_set_main_widget<Pong::Game>()); window->set_resizable(false); auto game_menu = TRY(window->try_add_menu("&Game")); + + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + game->reset(); + }))); + + TRY(game_menu->try_add_separator()); + TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) { GUI::Application::the()->quit(); }))); |