mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibCards+Games: Rename "draw" methods to "paint" for clarity
"Draw" is already a card-game term so using it for graphics was confusing me a lot!
This commit is contained in:
parent
6ef0504a42
commit
bfa9ae809f
8 changed files with 17 additions and 17 deletions
|
@ -896,21 +896,21 @@ void Game::paint_event(GUI::PaintEvent& event)
|
||||||
if (!game_ended()) {
|
if (!game_ended()) {
|
||||||
for (auto& card : player.hand)
|
for (auto& card : player.hand)
|
||||||
if (!card.is_null())
|
if (!card.is_null())
|
||||||
card->draw(painter);
|
card->paint(painter);
|
||||||
} else {
|
} else {
|
||||||
// FIXME: reposition cards in advance_game() maybe
|
// FIXME: reposition cards in advance_game() maybe
|
||||||
auto card_position = player.first_card_position;
|
auto card_position = player.first_card_position;
|
||||||
for (auto& card : player.cards_taken) {
|
for (auto& card : player.cards_taken) {
|
||||||
card->set_upside_down(false);
|
card->set_upside_down(false);
|
||||||
card->set_position(card_position);
|
card->set_position(card_position);
|
||||||
card->draw(painter);
|
card->paint(painter);
|
||||||
card_position.translate_by(player.card_offset);
|
card_position.translate_by(player.card_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < m_trick.size(); i++)
|
for (size_t i = 0; i < m_trick.size(); i++)
|
||||||
m_trick[i].draw(painter);
|
m_trick[i].paint(painter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::dump_state() const
|
void Game::dump_state() const
|
||||||
|
|
|
@ -552,12 +552,12 @@ void Game::paint_event(GUI::PaintEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& stack : stacks()) {
|
for (auto& stack : stacks()) {
|
||||||
stack.draw(painter, background_color);
|
stack.paint(painter, background_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_focused_cards.is_empty()) {
|
if (!m_focused_cards.is_empty()) {
|
||||||
for (auto& focused_card : m_focused_cards) {
|
for (auto& focused_card : m_focused_cards) {
|
||||||
focused_card.draw(painter);
|
focused_card.paint(painter);
|
||||||
focused_card.save_old_position();
|
focused_card.save_old_position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ private:
|
||||||
void draw(GUI::Painter& painter)
|
void draw(GUI::Painter& painter)
|
||||||
{
|
{
|
||||||
VERIFY(!m_animation_card.is_null());
|
VERIFY(!m_animation_card.is_null());
|
||||||
m_animation_card->draw(painter);
|
m_animation_card->paint(painter);
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,12 +201,12 @@ void Game::paint_event(GUI::PaintEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& stack : stacks()) {
|
for (auto& stack : stacks()) {
|
||||||
stack.draw(painter, background_color);
|
stack.paint(painter, background_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_focused_cards.is_empty()) {
|
if (!m_focused_cards.is_empty()) {
|
||||||
for (auto& focused_card : m_focused_cards) {
|
for (auto& focused_card : m_focused_cards) {
|
||||||
focused_card.draw(painter);
|
focused_card.paint(painter);
|
||||||
focused_card.save_old_position();
|
focused_card.save_old_position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ Card::Card(Suit suit, Rank rank)
|
||||||
VERIFY(to_underlying(rank) < card_count);
|
VERIFY(to_underlying(rank) < card_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Card::draw(GUI::Painter& painter) const
|
void Card::paint(GUI::Painter& painter) const
|
||||||
{
|
{
|
||||||
auto& card_painter = CardPainter::the();
|
auto& card_painter = CardPainter::the();
|
||||||
auto bitmap = [&]() {
|
auto bitmap = [&]() {
|
||||||
|
@ -43,12 +43,12 @@ void Card::save_old_position()
|
||||||
m_old_position_valid = true;
|
m_old_position_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Card::clear_and_draw(GUI::Painter& painter, Color const& background_color)
|
void Card::clear_and_paint(GUI::Painter& painter, Color const& background_color)
|
||||||
{
|
{
|
||||||
if (is_old_position_valid())
|
if (is_old_position_valid())
|
||||||
clear(painter, background_color);
|
clear(painter, background_color);
|
||||||
|
|
||||||
draw(painter);
|
paint(painter);
|
||||||
save_old_position();
|
save_old_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,9 +106,9 @@ public:
|
||||||
|
|
||||||
void save_old_position();
|
void save_old_position();
|
||||||
|
|
||||||
void draw(GUI::Painter&) const;
|
void paint(GUI::Painter&) const;
|
||||||
void clear(GUI::Painter&, Color const& background_color) const;
|
void clear(GUI::Painter&, Color const& background_color) const;
|
||||||
void clear_and_draw(GUI::Painter&, Color const& background_color);
|
void clear_and_paint(GUI::Painter& painter, Color const& background_color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Card(Suit, Rank);
|
Card(Suit, Rank);
|
||||||
|
|
|
@ -42,7 +42,7 @@ void CardStack::clear()
|
||||||
m_stack_positions.clear();
|
m_stack_positions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardStack::draw(GUI::Painter& painter, Gfx::Color const& background_color)
|
void CardStack::paint(GUI::Painter& painter, Gfx::Color const& background_color)
|
||||||
{
|
{
|
||||||
auto draw_background_if_empty = [&]() {
|
auto draw_background_if_empty = [&]() {
|
||||||
size_t number_of_moving_cards = 0;
|
size_t number_of_moving_cards = 0;
|
||||||
|
@ -89,13 +89,13 @@ void CardStack::draw(GUI::Painter& painter, Gfx::Color const& background_color)
|
||||||
|
|
||||||
if (m_rules.shift_x == 0 && m_rules.shift_y == 0) {
|
if (m_rules.shift_x == 0 && m_rules.shift_y == 0) {
|
||||||
auto& card = peek();
|
auto& card = peek();
|
||||||
card.draw(painter);
|
card.paint(painter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& card : m_stack) {
|
for (auto& card : m_stack) {
|
||||||
if (!card.is_moving())
|
if (!card.is_moving())
|
||||||
card.clear_and_draw(painter, Gfx::Color::Transparent);
|
card.clear_and_paint(painter, Gfx::Color::Transparent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public:
|
||||||
|
|
||||||
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
|
bool is_allowed_to_push(Card const&, size_t stack_size = 1, MovementRule movement_rule = MovementRule::Alternating) const;
|
||||||
void add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
|
void add_all_grabbed_cards(Gfx::IntPoint const& click_location, NonnullRefPtrVector<Card>& grabbed, MovementRule movement_rule = MovementRule::Alternating);
|
||||||
void draw(GUI::Painter&, Gfx::Color const& background_color);
|
void paint(GUI::Painter&, Gfx::Color const& background_color);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue