mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 05:07:35 +00:00
LibGfx: Remove try_
prefix from bitmap creation functions
Those don't have any non-try counterpart, so we might as well just omit it.
This commit is contained in:
parent
1971bff314
commit
82a152b696
186 changed files with 598 additions and 598 deletions
|
@ -171,7 +171,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
start_a_new_game();
|
||||
})));
|
||||
|
||||
|
@ -192,7 +192,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
})));
|
||||
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game->reset();
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
|
|
@ -381,7 +381,7 @@ static RefPtr<Gfx::Bitmap> get_piece(StringView set, StringView image)
|
|||
builder.append(set);
|
||||
builder.append('/');
|
||||
builder.append(image);
|
||||
return Gfx::Bitmap::try_load_from_file(builder.build()).release_value_but_fixme_should_propagate_errors();
|
||||
return Gfx::Bitmap::load_from_file(builder.build()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
void ChessWidget::set_piece_set(StringView set)
|
||||
|
|
|
@ -91,7 +91,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (widget->board().game_result() == Chess::Board::Result::NotFinished) {
|
||||
if (widget->resign() < 0)
|
||||
return;
|
||||
|
@ -127,7 +127,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
GUI::ActionGroup board_theme_action_group;
|
||||
board_theme_action_group.set_exclusive(true);
|
||||
auto board_theme_menu = TRY(style_menu->try_add_submenu("Board Theme"));
|
||||
board_theme_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
board_theme_menu->set_icon(Gfx::Bitmap::load_from_file("/res/icons/chess/mini-board.png"sv).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
for (auto const& theme : { "Beige", "Green", "Blue" }) {
|
||||
auto action = GUI::Action::create_checkable(theme, [&](auto& action) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
ColorLines::BitmapArray ColorLines::build_marble_color_bitmaps()
|
||||
{
|
||||
auto marble_bitmap = MUST(Gfx::Bitmap::try_load_from_file("/res/icons/colorlines/colorlines.png"sv));
|
||||
auto marble_bitmap = MUST(Gfx::Bitmap::load_from_file("/res/icons/colorlines/colorlines.png"sv));
|
||||
float constexpr hue_degrees[Marble::number_of_colors] = {
|
||||
0, // Red
|
||||
45, // Brown/Yellow
|
||||
|
|
|
@ -52,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game->reset();
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
|
|
@ -59,8 +59,8 @@ public:
|
|||
public:
|
||||
static ErrorOr<Bug> construct()
|
||||
{
|
||||
NonnullRefPtr<Gfx::Bitmap> falling_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png"sv));
|
||||
NonnullRefPtr<Gfx::Bitmap> flapping_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png"sv));
|
||||
NonnullRefPtr<Gfx::Bitmap> falling_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/flappybug/falling.png"sv));
|
||||
NonnullRefPtr<Gfx::Bitmap> flapping_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/flappybug/flapping.png"sv));
|
||||
return Bug(move(falling_bitmap), move(flapping_bitmap));
|
||||
}
|
||||
|
||||
|
@ -139,9 +139,9 @@ public:
|
|||
static ErrorOr<Cloud> construct()
|
||||
{
|
||||
Vector<NonnullRefPtr<Gfx::Bitmap>> const cloud_bitmaps {
|
||||
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png"sv)),
|
||||
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png"sv)),
|
||||
TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png"sv)),
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_0.png"sv)),
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_1.png"sv)),
|
||||
TRY(Gfx::Bitmap::load_from_file("/res/icons/flappybug/cloud_2.png"sv)),
|
||||
};
|
||||
return Cloud(move(cloud_bitmaps));
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ private:
|
|||
float m_last_score {};
|
||||
float m_difficulty {};
|
||||
float m_restart_cooldown {};
|
||||
NonnullRefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png"sv).release_value_but_fixme_should_propagate_errors() };
|
||||
NonnullRefPtr<Gfx::Bitmap> m_background_bitmap { Gfx::Bitmap::load_from_file("/res/icons/flappybug/background.png"sv).release_value_but_fixme_should_propagate_errors() };
|
||||
const Gfx::IntRect m_score_rect { 10, 10, 20, 20 };
|
||||
const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 };
|
||||
|
||||
|
|
|
@ -169,12 +169,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
start_a_new_game();
|
||||
})));
|
||||
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
|
||||
|
|
|
@ -91,8 +91,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
interval_spinbox.set_value(150);
|
||||
|
||||
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 paused_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
auto play_icon = TRY(Gfx::Bitmap::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());
|
||||
|
@ -101,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 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](const GUI::Action&) {
|
||||
auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, TRY(Gfx::Bitmap::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 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv)), [&](auto&) {
|
||||
auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::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 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, TRY(Gfx::Bitmap::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 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"sv)), [&](auto&) {
|
||||
auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/redo.png"sv)), [&](auto&) {
|
||||
board_widget->selected_pattern()->rotate_clockwise();
|
||||
});
|
||||
rotate_pattern_action->set_enabled(false);
|
||||
|
|
|
@ -90,12 +90,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game.setup(player_name);
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(TRY(Cards::make_cards_settings_action(window))));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("Hearts &Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("Hearts &Settings", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) {
|
||||
change_settings();
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
|
|
@ -111,15 +111,15 @@ private:
|
|||
ErrorOr<NonnullRefPtr<Field>> Field::create(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::IntSize)> on_size_changed)
|
||||
{
|
||||
auto field = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Field(flag_label, time_label, face_button, move(on_size_changed))));
|
||||
field->m_mine_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png"sv));
|
||||
field->m_flag_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"sv));
|
||||
field->m_badflag_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png"sv));
|
||||
field->m_consider_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png"sv));
|
||||
field->m_default_face_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png"sv));
|
||||
field->m_good_face_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"sv));
|
||||
field->m_bad_face_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"sv));
|
||||
field->m_mine_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/mine.png"sv));
|
||||
field->m_flag_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png"sv));
|
||||
field->m_badflag_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/badflag.png"sv));
|
||||
field->m_consider_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/consider.png"sv));
|
||||
field->m_default_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-default.png"sv));
|
||||
field->m_good_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-good.png"sv));
|
||||
field->m_bad_face_bitmap = TRY(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/face-bad.png"sv));
|
||||
for (int i = 0; i < 8; ++i)
|
||||
field->m_number_bitmap[i] = TRY(Gfx::Bitmap::try_load_from_file(DeprecatedString::formatted("/res/icons/minesweeper/{}.png", i + 1)));
|
||||
field->m_number_bitmap[i] = TRY(Gfx::Bitmap::load_from_file(DeprecatedString::formatted("/res/icons/minesweeper/{}.png", i + 1)));
|
||||
field->initialize();
|
||||
return field;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
field->reset();
|
||||
})));
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ ErrorOr<NonnullRefPtr<Game>> Game::try_create()
|
|||
TRY(food_bitmaps.try_ensure_capacity(food_bitmaps_files.size()));
|
||||
|
||||
for (auto file : food_bitmaps_files) {
|
||||
auto bitmap = Gfx::Bitmap::try_load_from_file(file);
|
||||
auto bitmap = Gfx::Bitmap::load_from_file(file);
|
||||
if (bitmap.is_error()) {
|
||||
dbgln("\033[31;1mCould not load bitmap file\033[0m '{}': {}", file, bitmap.error());
|
||||
return bitmap.release_error();
|
||||
|
|
|
@ -74,13 +74,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
game.reset();
|
||||
})));
|
||||
static DeprecatedString const pause_text = "&Pause Game"sv;
|
||||
auto const pause_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
auto const pause_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/pause.png"sv));
|
||||
static DeprecatedString const continue_text = "&Continue Game"sv;
|
||||
auto const continue_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv));
|
||||
auto const continue_icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/play.png"sv));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create(pause_text, { Mod_None, Key_Space }, pause_icon, [&](auto& action) {
|
||||
if (game.has_timer()) {
|
||||
game.pause();
|
||||
|
@ -92,7 +92,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
action.set_icon(pause_icon);
|
||||
}
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Change snake color", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&Change snake color", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/color-chooser.png"sv)), [&](auto&) {
|
||||
game.pause();
|
||||
auto dialog = GUI::ColorPicker::construct(Gfx::Color::White, window);
|
||||
if (dialog->exec() == GUI::Dialog::ExecResult::OK)
|
||||
|
|
|
@ -206,7 +206,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (!confirm_end_current_game())
|
||||
return;
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
suit_actions.add_action(two_suit_action);
|
||||
|
||||
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"sv)), [&](auto&) {
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) {
|
||||
if (!confirm_end_current_game())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue