mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Solitaire: Reduce overdraw when drawing initial cards
This commit is contained in:
parent
882b4dc848
commit
0150ae4bbd
Notes:
sideshowbarker
2024-07-18 08:58:27 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/SerenityOS/serenity/commit/0150ae4bbdb Pull-request: https://github.com/SerenityOS/serenity/pull/8778
1 changed files with 29 additions and 27 deletions
|
@ -61,7 +61,35 @@ void Game::timer_event(Core::TimerEvent&)
|
|||
if (m_animation.tick())
|
||||
update(m_animation.card()->rect());
|
||||
} 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;
|
||||
}
|
||||
|
||||
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()) {
|
||||
for (auto& focused_card : m_focused_cards)
|
||||
focused_card.clear(painter, s_background_color);
|
||||
|
|
Loading…
Reference in a new issue