mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
Solitaire: Reduce overdraw when drawing initial cards
This commit is contained in:
parent
882b4dc848
commit
0150ae4bbd
1 changed files with 29 additions and 27 deletions
|
@ -61,7 +61,35 @@ void Game::timer_event(Core::TimerEvent&)
|
||||||
if (m_animation.tick())
|
if (m_animation.tick())
|
||||||
update(m_animation.card()->rect());
|
update(m_animation.card()->rect());
|
||||||
} else if (m_new_game_animation) {
|
} else if (m_new_game_animation) {
|
||||||
update();
|
if (m_new_game_animation_delay < new_game_animation_delay) {
|
||||||
|
++m_new_game_animation_delay;
|
||||||
|
} else {
|
||||||
|
m_new_game_animation_delay = 0;
|
||||||
|
auto& current_pile = stack(piles.at(m_new_game_animation_pile));
|
||||||
|
|
||||||
|
if (current_pile.count() < m_new_game_animation_pile) {
|
||||||
|
auto card = m_new_deck.take_last();
|
||||||
|
card->set_upside_down(true);
|
||||||
|
current_pile.push(card);
|
||||||
|
} else {
|
||||||
|
current_pile.push(m_new_deck.take_last());
|
||||||
|
++m_new_game_animation_pile;
|
||||||
|
}
|
||||||
|
|
||||||
|
update(current_pile.bounding_box());
|
||||||
|
|
||||||
|
if (m_new_game_animation_pile == piles.size()) {
|
||||||
|
auto& stock_pile = stack(Stock);
|
||||||
|
while (!m_new_deck.is_empty())
|
||||||
|
stock_pile.push(m_new_deck.take_last());
|
||||||
|
|
||||||
|
update(stock_pile.bounding_box());
|
||||||
|
|
||||||
|
m_new_game_animation = false;
|
||||||
|
m_waiting_for_new_game = true;
|
||||||
|
stop_timer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -523,32 +551,6 @@ void Game::paint_event(GUI::PaintEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_new_game_animation) {
|
|
||||||
if (m_new_game_animation_delay < new_game_animation_delay) {
|
|
||||||
++m_new_game_animation_delay;
|
|
||||||
} else {
|
|
||||||
m_new_game_animation_delay = 0;
|
|
||||||
auto& current_pile = stack(piles.at(m_new_game_animation_pile));
|
|
||||||
|
|
||||||
if (current_pile.count() < m_new_game_animation_pile) {
|
|
||||||
auto card = m_new_deck.take_last();
|
|
||||||
card->set_upside_down(true);
|
|
||||||
current_pile.push(card);
|
|
||||||
} else {
|
|
||||||
current_pile.push(m_new_deck.take_last());
|
|
||||||
++m_new_game_animation_pile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_new_game_animation_pile == piles.size()) {
|
|
||||||
while (!m_new_deck.is_empty())
|
|
||||||
stack(Stock).push(m_new_deck.take_last());
|
|
||||||
m_new_game_animation = false;
|
|
||||||
m_waiting_for_new_game = true;
|
|
||||||
stop_timer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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.clear(painter, s_background_color);
|
focused_card.clear(painter, s_background_color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue