1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

LibCards: Make the card back image configurable

`CardPainter::set_background_image_path()` immediately repaints the card
back and inverted card back bitmaps if they exist, so users just need
to `update()` that part of the screen. This is handled automatically by
`CardGame`, but other users will have to do this manually.
This commit is contained in:
Sam Atkins 2022-08-21 15:47:06 +01:00 committed by Andreas Kling
parent 7f46d31849
commit 40b1428194
3 changed files with 35 additions and 4 deletions

View file

@ -5,6 +5,7 @@
*/
#include "CardGame.h"
#include <LibCards/CardPainter.h>
#include <LibConfig/Client.h>
#include <LibGfx/Palette.h>
@ -18,9 +19,16 @@ CardGame::CardGame()
void CardGame::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
{
if (domain == "Games" && group == "Cards" && key == "BackgroundColor") {
if (auto maybe_color = Gfx::Color::from_string(value); maybe_color.has_value()) {
set_background_color(maybe_color.value());
if (domain == "Games" && group == "Cards") {
if (key == "BackgroundColor") {
if (auto maybe_color = Gfx::Color::from_string(value); maybe_color.has_value())
set_background_color(maybe_color.value());
return;
}
if (key == "CardBackImage") {
CardPainter::the().set_background_image_path(value);
update();
return;
}
}
}