mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:27:35 +00:00
Solitaire: Only start timer when the timer event is needed
The timer is no longer used to trigger a paint event for all updates; it is only used to paint the new-game and game-over animations. So only run the timer during those events.
This commit is contained in:
parent
4fc9c1d710
commit
59193dd6b3
1 changed files with 5 additions and 1 deletions
|
@ -74,6 +74,8 @@ void Game::start_game_over_animation()
|
|||
|
||||
create_new_animation_card();
|
||||
m_game_over_animation = true;
|
||||
|
||||
start_timer(s_timer_interval_ms);
|
||||
}
|
||||
|
||||
void Game::stop_game_over_animation()
|
||||
|
@ -83,12 +85,13 @@ void Game::stop_game_over_animation()
|
|||
|
||||
m_game_over_animation = false;
|
||||
update();
|
||||
|
||||
stop_timer();
|
||||
}
|
||||
|
||||
void Game::setup()
|
||||
{
|
||||
stop_game_over_animation();
|
||||
stop_timer();
|
||||
|
||||
for (auto& stack : m_stacks)
|
||||
stack.clear();
|
||||
|
@ -366,6 +369,7 @@ void Game::paint_event(GUI::PaintEvent& event)
|
|||
while (!m_new_deck.is_empty())
|
||||
stack(Stock).push(m_new_deck.take_last());
|
||||
m_new_game_animation = false;
|
||||
stop_timer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue