summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-05-27 14:27:20 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-27 22:55:37 +0200
commitf7667901edac2c1fc41fc7bba9518ebf3ca82caa (patch)
tree1629f67150058df0a68bac99cf706d85a36918b6
parentbacb2dea70d1cc5b46755dc591a50de3499c54d5 (diff)
downloadserenity-f7667901edac2c1fc41fc7bba9518ebf3ca82caa.zip
Solitaire: Start timer when first card is moved
Starts the game timer when the first card is clicked or moved instead of when a new game is started. Fixes #7489
-rw-r--r--Userland/Games/Solitaire/Game.cpp9
-rw-r--r--Userland/Games/Solitaire/Game.h2
-rw-r--r--Userland/Games/Solitaire/main.cpp1
3 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp
index e794e98806..b9ae0914dc 100644
--- a/Userland/Games/Solitaire/Game.cpp
+++ b/Userland/Games/Solitaire/Game.cpp
@@ -155,6 +155,11 @@ void Game::mousedown_event(GUI::MouseEvent& event)
if (m_new_game_animation || m_game_over_animation)
return;
+ if (on_game_start && m_waiting_for_new_game) {
+ on_game_start();
+ m_waiting_for_new_game = false;
+ }
+
auto click_location = event.position();
for (auto& to_check : m_stacks) {
if (to_check.type() == CardStack::Type::Waste)
@@ -440,10 +445,8 @@ 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;
+ m_waiting_for_new_game = true;
stop_timer();
-
- if (on_game_start)
- on_game_start();
}
}
}
diff --git a/Userland/Games/Solitaire/Game.h b/Userland/Games/Solitaire/Game.h
index b9164610ba..a77c9d943c 100644
--- a/Userland/Games/Solitaire/Game.h
+++ b/Userland/Games/Solitaire/Game.h
@@ -173,7 +173,7 @@ private:
Animation m_animation;
bool m_game_over_animation { false };
-
+ bool m_waiting_for_new_game { true };
bool m_new_game_animation { false };
uint8_t m_new_game_animation_pile { 0 };
uint8_t m_new_game_animation_delay { 0 };
diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp
index cb6c6dd9fd..3cdcddb2f0 100644
--- a/Userland/Games/Solitaire/main.cpp
+++ b/Userland/Games/Solitaire/main.cpp
@@ -146,6 +146,7 @@ int main(int argc, char** argv)
statusbar.set_text(1, String::formatted("High Score: {}", score));
}
}
+ statusbar.set_text(2, "Timer starts after your first move");
};
GUI::ActionGroup draw_setting_actions;