2022-08-21 12:53:20 +01:00
|
|
|
/*
|
2023-10-03 16:09:38 +01:00
|
|
|
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
|
2022-08-21 12:53:20 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Array.h>
|
2023-06-26 20:49:32 +02:00
|
|
|
#include <AK/String.h>
|
2022-08-21 12:53:20 +01:00
|
|
|
#include <LibCards/Card.h>
|
|
|
|
#include <LibGfx/Bitmap.h>
|
2023-01-04 18:25:23 -05:00
|
|
|
#include <LibGfx/Color.h>
|
2022-08-21 12:53:20 +01:00
|
|
|
|
|
|
|
namespace Cards {
|
|
|
|
|
|
|
|
class CardPainter {
|
|
|
|
public:
|
|
|
|
static CardPainter& the();
|
|
|
|
|
|
|
|
NonnullRefPtr<Gfx::Bitmap> card_front(Suit, Rank);
|
|
|
|
NonnullRefPtr<Gfx::Bitmap> card_back();
|
|
|
|
NonnullRefPtr<Gfx::Bitmap> card_front_inverted(Suit, Rank);
|
|
|
|
NonnullRefPtr<Gfx::Bitmap> card_back_inverted();
|
2023-01-04 18:25:23 -05:00
|
|
|
NonnullRefPtr<Gfx::Bitmap> card_front_highlighted(Suit, Rank);
|
2022-08-21 12:53:20 +01:00
|
|
|
|
2023-10-03 17:14:43 +01:00
|
|
|
void set_back_image_path(StringView path);
|
2023-10-03 16:09:38 +01:00
|
|
|
void set_front_images_set_name(StringView path);
|
2023-01-04 18:25:23 -05:00
|
|
|
void set_background_color(Color);
|
2022-08-21 15:47:06 +01:00
|
|
|
|
2022-08-21 12:53:20 +01:00
|
|
|
private:
|
2022-08-21 15:47:06 +01:00
|
|
|
CardPainter();
|
2022-08-21 12:53:20 +01:00
|
|
|
NonnullRefPtr<Gfx::Bitmap> create_card_bitmap();
|
|
|
|
void paint_card_front(Gfx::Bitmap&, Suit, Rank);
|
2023-10-03 16:09:38 +01:00
|
|
|
void paint_card_front_pips(Gfx::Bitmap&, Suit, Rank);
|
2022-08-21 12:53:20 +01:00
|
|
|
void paint_card_back(Gfx::Bitmap&);
|
|
|
|
void paint_inverted_card(Gfx::Bitmap& bitmap, Gfx::Bitmap const& source_to_invert);
|
2023-01-04 18:25:23 -05:00
|
|
|
void paint_highlighted_card(Gfx::Bitmap& bitmap, Gfx::Bitmap const& source_to_highlight);
|
2022-08-21 12:53:20 +01:00
|
|
|
|
2023-10-03 16:09:38 +01:00
|
|
|
Array<RefPtr<Gfx::Bitmap>, to_underlying(Suit::__Count)> m_suit_pips;
|
|
|
|
Array<RefPtr<Gfx::Bitmap>, to_underlying(Suit::__Count)> m_suit_pips_flipped_vertically;
|
2022-08-21 12:53:20 +01:00
|
|
|
Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards;
|
|
|
|
Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards_inverted;
|
2023-01-04 18:25:23 -05:00
|
|
|
Array<Array<RefPtr<Gfx::Bitmap>, to_underlying(Rank::__Count)>, to_underlying(Suit::__Count)> m_cards_highlighted;
|
2022-08-21 12:53:20 +01:00
|
|
|
RefPtr<Gfx::Bitmap> m_card_back;
|
|
|
|
RefPtr<Gfx::Bitmap> m_card_back_inverted;
|
2022-08-21 15:47:06 +01:00
|
|
|
|
2023-10-03 17:14:43 +01:00
|
|
|
String m_back_image_path;
|
2023-10-03 16:09:38 +01:00
|
|
|
String m_front_images_set_name;
|
2023-01-04 18:25:23 -05:00
|
|
|
Color m_background_color;
|
2022-08-21 12:53:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|