1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 00:50:47 +00:00

LibCards: Stop calling the card back image a "background" image

It's not a background, past me!
This commit is contained in:
Sam Atkins 2023-10-03 17:14:43 +01:00 committed by Sam Atkins
parent d8e8b300c8
commit eff25f9116
4 changed files with 10 additions and 10 deletions

View File

@ -122,7 +122,7 @@ ErrorOr<void> CardSettingsWidget::initialize()
return;
m_last_selected_card_back = card_back_selection.first();
set_modified(true);
Cards::CardPainter::the().set_background_image_path(card_back_image_path());
Cards::CardPainter::the().set_back_image_path(card_back_image_path());
m_preview_frame->update();
};
@ -154,7 +154,7 @@ bool CardSettingsWidget::set_card_back_image_path(StringView path)
auto index = static_cast<GUI::FileSystemModel*>(m_card_back_image_view->model())->index(path.to_deprecated_string(), m_card_back_image_view->model_column());
if (index.is_valid()) {
m_card_back_image_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set);
Cards::CardPainter::the().set_background_image_path(path);
Cards::CardPainter::the().set_back_image_path(path);
m_preview_frame->update();
return true;
}

View File

@ -121,7 +121,7 @@ void CardGame::config_string_did_change(StringView domain, StringView group, Str
return;
}
if (key == "CardBackImage") {
CardPainter::the().set_background_image_path(String::from_utf8(value).release_value_but_fixme_should_propagate_errors());
CardPainter::the().set_back_image_path(String::from_utf8(value).release_value_but_fixme_should_propagate_errors());
update();
return;
}

View File

@ -23,7 +23,7 @@ CardPainter& CardPainter::the()
CardPainter::CardPainter()
{
m_background_image_path = MUST(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv, "/res/graphics/cards/backs/buggie-deck.png"sv)));
m_back_image_path = MUST(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardBackImage"sv, "/res/graphics/cards/backs/buggie-deck.png"sv)));
set_front_images_set_name(MUST(String::from_deprecated_string(Config::read_string("Games"sv, "Cards"sv, "CardFrontImages"sv, "Classic"sv))));
}
@ -146,12 +146,12 @@ NonnullRefPtr<Gfx::Bitmap> CardPainter::card_back_inverted()
return *m_card_back_inverted;
}
void CardPainter::set_background_image_path(StringView path)
void CardPainter::set_back_image_path(StringView path)
{
if (m_background_image_path == path)
if (m_back_image_path == path)
return;
m_background_image_path = MUST(String::from_utf8(path));
m_back_image_path = MUST(String::from_utf8(path));
if (!m_card_back.is_null())
paint_card_back(*m_card_back);
if (!m_card_back_inverted.is_null())
@ -440,7 +440,7 @@ void CardPainter::paint_card_back(Gfx::Bitmap& bitmap)
auto inner_paint_rect = paint_rect.shrunken(2, 2);
painter.fill_rect_with_rounded_corners(inner_paint_rect, Color::White, Card::card_radius - 1);
auto image = Gfx::Bitmap::load_from_file(m_background_image_path).release_value_but_fixme_should_propagate_errors();
auto image = Gfx::Bitmap::load_from_file(m_back_image_path).release_value_but_fixme_should_propagate_errors();
painter.blit({ (bitmap.width() - image->width()) / 2, (bitmap.height() - image->height()) / 2 }, image, image->rect());
}

View File

@ -24,7 +24,7 @@ public:
NonnullRefPtr<Gfx::Bitmap> card_back_inverted();
NonnullRefPtr<Gfx::Bitmap> card_front_highlighted(Suit, Rank);
void set_background_image_path(StringView path);
void set_back_image_path(StringView path);
void set_front_images_set_name(StringView path);
void set_background_color(Color);
@ -45,7 +45,7 @@ private:
RefPtr<Gfx::Bitmap> m_card_back;
RefPtr<Gfx::Bitmap> m_card_back_inverted;
String m_background_image_path;
String m_back_image_path;
String m_front_images_set_name;
Color m_background_color;
};