From 59193dd6b3c5c065790f03a8e1154af2b45139ab Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 5 May 2021 12:36:18 -0400 Subject: [PATCH] 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. --- Userland/Games/Solitaire/Game.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp index 1aac81557c..152935a50b 100644 --- a/Userland/Games/Solitaire/Game.cpp +++ b/Userland/Games/Solitaire/Game.cpp @@ -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(); } } }