1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15: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:
Timothy Flynn 2021-05-05 12:36:18 -04:00 committed by Andreas Kling
parent 4fc9c1d710
commit 59193dd6b3

View file

@ -74,6 +74,8 @@ void Game::start_game_over_animation()
create_new_animation_card(); create_new_animation_card();
m_game_over_animation = true; m_game_over_animation = true;
start_timer(s_timer_interval_ms);
} }
void Game::stop_game_over_animation() void Game::stop_game_over_animation()
@ -83,12 +85,13 @@ void Game::stop_game_over_animation()
m_game_over_animation = false; m_game_over_animation = false;
update(); update();
stop_timer();
} }
void Game::setup() void Game::setup()
{ {
stop_game_over_animation(); stop_game_over_animation();
stop_timer();
for (auto& stack : m_stacks) for (auto& stack : m_stacks)
stack.clear(); stack.clear();
@ -366,6 +369,7 @@ void Game::paint_event(GUI::PaintEvent& event)
while (!m_new_deck.is_empty()) while (!m_new_deck.is_empty())
stack(Stock).push(m_new_deck.take_last()); stack(Stock).push(m_new_deck.take_last());
m_new_game_animation = false; m_new_game_animation = false;
stop_timer();
} }
} }
} }