mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 15:57:36 +00:00
Userland: Make Window::set_main_widget()
non-fallible
This commit is contained in:
parent
c9297126db
commit
3aa49f268c
120 changed files with 144 additions and 133 deletions
|
@ -25,7 +25,7 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent, size_t board_size, size_t ta
|
|||
set_icon(parent->icon());
|
||||
set_resizable(false);
|
||||
|
||||
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
auto main_widget = set_main_widget<GUI::Widget>();
|
||||
main_widget->load_from_gml(game_size_dialog_gml).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto board_size_spinbox = main_widget->find_descendant_of_type_named<GUI::SpinBox>("board_size_spinbox");
|
||||
|
|
|
@ -65,7 +65,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("2048");
|
||||
window->resize(315, 336);
|
||||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto main_widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(main_widget->load_from_gml(game_window_gml));
|
||||
|
||||
Game game { board_size, target_tile, evil_ai };
|
||||
|
|
|
@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->resize(360, 462);
|
||||
window->set_resizable(false);
|
||||
|
||||
auto game = TRY(window->set_main_widget<BrickGame>(app_name));
|
||||
auto game = window->set_main_widget<BrickGame>(app_name);
|
||||
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ PromotionDialog::PromotionDialog(ChessWidget& chess_widget)
|
|||
set_icon(chess_widget.window()->icon());
|
||||
resize(70 * 4, 70);
|
||||
|
||||
auto main_widget = set_main_widget<GUI::Frame>().release_value_but_fixme_should_propagate_errors();
|
||||
auto main_widget = set_main_widget<GUI::Frame>();
|
||||
main_widget->set_frame_style(Gfx::FrameStyle::SunkenContainer);
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
main_widget->set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
|
|
@ -63,7 +63,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"sv));
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
auto widget = TRY(window->set_main_widget<ChessWidget>());
|
||||
auto widget = TRY(ChessWidget::try_create());
|
||||
window->set_main_widget(widget);
|
||||
|
||||
auto engines = TRY(available_engines());
|
||||
for (auto const& engine : engines)
|
||||
|
|
|
@ -48,7 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->resize(436, 481);
|
||||
window->set_resizable(false);
|
||||
|
||||
auto game = TRY(window->set_main_widget<ColorLines>(app_name));
|
||||
auto game = window->set_main_widget<ColorLines>(app_name);
|
||||
|
||||
auto game_menu = window->add_menu("&Game"_string);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Flappy Bug");
|
||||
window->set_double_buffering_enabled(false);
|
||||
window->set_resizable(false);
|
||||
auto widget = TRY(window->set_main_widget<FlappyBug::Game>(TRY(FlappyBug::Game::Bug::construct()), TRY(FlappyBug::Game::Cloud::construct())));
|
||||
auto widget = window->set_main_widget<FlappyBug::Game>(TRY(FlappyBug::Game::Bug::construct()), TRY(FlappyBug::Game::Cloud::construct()));
|
||||
|
||||
widget->on_game_end = [&](u32 score) {
|
||||
if (score <= high_score)
|
||||
|
|
|
@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_double_buffering_enabled(false);
|
||||
window->set_title("Game of Life");
|
||||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto main_widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(main_widget->load_from_gml(game_of_life_gml));
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ void Game::show_score_card(bool game_over)
|
|||
score_dialog->set_resizable(false);
|
||||
score_dialog->set_icon(window()->icon());
|
||||
|
||||
auto score_widget = score_dialog->set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
auto score_widget = score_dialog->set_main_widget<GUI::Widget>();
|
||||
score_widget->set_fill_with_background_color(true);
|
||||
score_widget->set_layout<GUI::HorizontalBoxLayout>(10, 15);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ SettingsDialog::SettingsDialog(GUI::Window* parent, DeprecatedString player_name
|
|||
set_icon(parent->icon());
|
||||
set_resizable(false);
|
||||
|
||||
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
auto main_widget = set_main_widget<GUI::Widget>();
|
||||
main_widget->set_fill_with_background_color(true);
|
||||
|
||||
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
|
||||
|
|
|
@ -50,7 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto window = GUI::Window::construct();
|
||||
window->set_title("Hearts");
|
||||
|
||||
auto widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(widget->load_from_gml(hearts_gml));
|
||||
|
||||
auto& game = *widget->find_descendant_of_type_named<Hearts::Game>("game");
|
||||
|
|
|
@ -47,7 +47,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_resizable(false);
|
||||
window->set_auto_shrink(true);
|
||||
|
||||
auto main_widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto main_widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(main_widget->load_from_gml(master_word_gml));
|
||||
auto& game = *main_widget->find_descendant_of_type_named<MasterWord::WordGame>("word_game");
|
||||
auto& statusbar = *main_widget->find_descendant_of_type_named<GUI::Statusbar>("statusbar");
|
||||
|
|
|
@ -45,7 +45,7 @@ CustomGameDialog::CustomGameDialog(Window* parent_window)
|
|||
set_resizable(false);
|
||||
set_title("Custom Game");
|
||||
|
||||
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
|
||||
auto main_widget = set_main_widget<GUI::Widget>();
|
||||
main_widget->load_from_gml(minesweeper_custom_game_window_gml).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
m_columns_spinbox = *main_widget->find_descendant_of_type_named<GUI::SpinBox>("columns_spinbox");
|
||||
|
|
|
@ -49,7 +49,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Minesweeper");
|
||||
window->set_auto_shrink(true);
|
||||
|
||||
auto widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(widget->load_from_gml(minesweeper_window_gml));
|
||||
|
||||
auto& flag_label = *widget->find_descendant_of_type_named<GUI::Label>("flag_label");
|
||||
|
|
|
@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_title("Snake");
|
||||
window->resize(324, 345);
|
||||
|
||||
auto widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(widget->load_from_gml(snake_gml));
|
||||
|
||||
auto& game = *widget->find_descendant_of_type_named<Snake::Game>("game");
|
||||
|
|
|
@ -84,7 +84,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (mode >= Solitaire::Mode::__Count)
|
||||
update_mode(Solitaire::Mode::SingleCardDraw);
|
||||
|
||||
auto widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(widget->load_from_gml(solitaire_gml));
|
||||
|
||||
auto& game = *widget->find_descendant_of_type_named<Solitaire::Game>("game");
|
||||
|
|
|
@ -109,7 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (statistic_display >= StatisticDisplay::__Count)
|
||||
update_statistic_display(StatisticDisplay::HighScore);
|
||||
|
||||
auto widget = TRY(window->set_main_widget<GUI::Widget>());
|
||||
auto widget = window->set_main_widget<GUI::Widget>();
|
||||
TRY(widget->load_from_gml(spider_gml));
|
||||
|
||||
auto& game = *widget->find_descendant_of_type_named<Spider::Game>("game");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue