mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibCards+Games: Move mark_intersecting_stacks_dirty()
to CardGame
As part of this, made a const overload for `Card::rect()`. We need the non-const one too as it's used for modifying the position of a card that's being dragged. I plan on changing that soon but we'll see.
This commit is contained in:
parent
12612703f9
commit
5960c0556f
7 changed files with 12 additions and 22 deletions
|
@ -521,16 +521,6 @@ void Game::auto_move_eligible_cards_to_foundations()
|
||||||
auto_move_eligible_cards_to_foundations();
|
auto_move_eligible_cards_to_foundations();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mark_intersecting_stacks_dirty(Card& intersecting_card)
|
|
||||||
{
|
|
||||||
for (auto& stack : stacks()) {
|
|
||||||
if (intersecting_card.rect().intersects(stack.bounding_box()))
|
|
||||||
update(stack.bounding_box());
|
|
||||||
}
|
|
||||||
|
|
||||||
update(intersecting_card.rect());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::paint_event(GUI::PaintEvent& event)
|
void Game::paint_event(GUI::PaintEvent& event)
|
||||||
{
|
{
|
||||||
Gfx::Color background_color = this->background_color();
|
Gfx::Color background_color = this->background_color();
|
||||||
|
|
|
@ -159,7 +159,6 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mark_intersecting_stacks_dirty(Card& intersecting_card);
|
|
||||||
void score_move(CardStack& from, CardStack& to, bool inverse = false);
|
void score_move(CardStack& from, CardStack& to, bool inverse = false);
|
||||||
void score_flip(bool inverse = false);
|
void score_flip(bool inverse = false);
|
||||||
void remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards);
|
void remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards);
|
||||||
|
|
|
@ -105,16 +105,6 @@ void Game::draw_cards()
|
||||||
start_timer(s_timer_interval_ms);
|
start_timer(s_timer_interval_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::mark_intersecting_stacks_dirty(Card& intersecting_card)
|
|
||||||
{
|
|
||||||
for (auto& stack : stacks()) {
|
|
||||||
if (intersecting_card.rect().intersects(stack.bounding_box()))
|
|
||||||
update(stack.bounding_box());
|
|
||||||
}
|
|
||||||
|
|
||||||
update(intersecting_card.rect());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Game::detect_full_stacks()
|
void Game::detect_full_stacks()
|
||||||
{
|
{
|
||||||
auto& completed_stack = stack_at_location(Completed);
|
auto& completed_stack = stack_at_location(Completed);
|
||||||
|
|
|
@ -70,7 +70,6 @@ private:
|
||||||
void start_timer_if_necessary();
|
void start_timer_if_necessary();
|
||||||
void update_score(int delta);
|
void update_score(int delta);
|
||||||
void draw_cards();
|
void draw_cards();
|
||||||
void mark_intersecting_stacks_dirty(Card& intersecting_card);
|
|
||||||
void detect_full_stacks();
|
void detect_full_stacks();
|
||||||
void detect_victory();
|
void detect_victory();
|
||||||
void move_focused_cards(CardStack& stack);
|
void move_focused_cards(CardStack& stack);
|
||||||
|
|
|
@ -88,6 +88,7 @@ public:
|
||||||
virtual ~Card() override = default;
|
virtual ~Card() override = default;
|
||||||
|
|
||||||
Gfx::IntRect& rect() { return m_rect; }
|
Gfx::IntRect& rect() { return m_rect; }
|
||||||
|
Gfx::IntRect const& rect() const { return m_rect; }
|
||||||
Gfx::IntPoint position() const { return m_rect.location(); }
|
Gfx::IntPoint position() const { return m_rect.location(); }
|
||||||
Gfx::IntPoint const& old_position() const { return m_old_position; }
|
Gfx::IntPoint const& old_position() const { return m_old_position; }
|
||||||
Rank rank() const { return m_rank; };
|
Rank rank() const { return m_rank; };
|
||||||
|
|
|
@ -22,6 +22,16 @@ void CardGame::add_stack(NonnullRefPtr<CardStack> stack)
|
||||||
m_stacks.append(move(stack));
|
m_stacks.append(move(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CardGame::mark_intersecting_stacks_dirty(Cards::Card const& intersecting_card)
|
||||||
|
{
|
||||||
|
for (auto& stack : stacks()) {
|
||||||
|
if (intersecting_card.rect().intersects(stack.bounding_box()))
|
||||||
|
update(stack.bounding_box());
|
||||||
|
}
|
||||||
|
|
||||||
|
update(intersecting_card.rect());
|
||||||
|
}
|
||||||
|
|
||||||
void CardGame::dump_layout() const
|
void CardGame::dump_layout() const
|
||||||
{
|
{
|
||||||
dbgln("------------------------------");
|
dbgln("------------------------------");
|
||||||
|
|
|
@ -25,6 +25,7 @@ public:
|
||||||
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
|
NonnullRefPtrVector<CardStack> const& stacks() const { return m_stacks; }
|
||||||
CardStack& stack_at_location(int location) { return m_stacks[location]; }
|
CardStack& stack_at_location(int location) { return m_stacks[location]; }
|
||||||
void add_stack(NonnullRefPtr<CardStack>);
|
void add_stack(NonnullRefPtr<CardStack>);
|
||||||
|
void mark_intersecting_stacks_dirty(Card const& intersecting_card);
|
||||||
|
|
||||||
void dump_layout() const;
|
void dump_layout() const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue