mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
GameOfLife: Propagate errors while loading bmp
This commit is contained in:
parent
21e8099e42
commit
2e1f7c5ac8
Notes:
sideshowbarker
2024-07-17 02:53:32 +09:00
Author: https://github.com/ericLemanissier
Commit: 2e1f7c5ac8
Pull-request: https://github.com/SerenityOS/serenity/pull/16614
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 7 additions and 6 deletions
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "BoardWidget.h"
|
||||
#include <AK/Try.h>
|
||||
#include <AK/URL.h>
|
||||
#include <Games/GameOfLife/GameOfLifeGML.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -90,8 +91,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
interval_spinbox.set_value(150);
|
||||
|
||||
auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
auto paused_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
auto play_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv));
|
||||
|
||||
auto toggle_running_action = GUI::Action::create("&Toggle Running", { Mod_None, Key_Return }, *play_icon, [&](GUI::Action&) {
|
||||
board_widget->set_running(!board_widget->is_running());
|
||||
|
@ -100,27 +101,27 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
toggle_running_action->set_checkable(true);
|
||||
auto toggle_running_toolbar_button = TRY(main_toolbar.try_add_action(toggle_running_action));
|
||||
|
||||
auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
|
||||
auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](const GUI::Action&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->run_generation();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(run_one_generation_action));
|
||||
|
||||
auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv)), [&](auto&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->clear_cells();
|
||||
board_widget->update();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(clear_board_action));
|
||||
|
||||
auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
statusbar.set_text(click_tip);
|
||||
board_widget->randomize_cells();
|
||||
board_widget->update();
|
||||
});
|
||||
(void)TRY(main_toolbar.try_add_action(randomize_cells_action));
|
||||
|
||||
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
|
||||
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"sv)), [&](auto&) {
|
||||
board_widget->selected_pattern()->rotate_clockwise();
|
||||
});
|
||||
rotate_pattern_action->set_enabled(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue