mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
Spider: Make double-click skip the new-game animation
This commit is contained in:
parent
8744e8b561
commit
ced59fb3a0
2 changed files with 52 additions and 34 deletions
|
@ -368,13 +368,19 @@ void Game::mousemove_event(GUI::MouseEvent& event)
|
||||||
m_mouse_down_location = click_location;
|
m_mouse_down_location = click_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::timer_event(Core::TimerEvent&)
|
void Game::doubleclick_event(GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
|
GUI::Frame::doubleclick_event(event);
|
||||||
|
|
||||||
if (m_state == State::NewGameAnimation) {
|
if (m_state == State::NewGameAnimation) {
|
||||||
if (m_new_game_animation_delay < new_game_animation_delay) {
|
while (m_state == State::NewGameAnimation)
|
||||||
++m_new_game_animation_delay;
|
deal_next_card();
|
||||||
} else {
|
return;
|
||||||
m_new_game_animation_delay = 0;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::deal_next_card()
|
||||||
|
{
|
||||||
auto& current_pile = stack_at_location(piles.at(m_new_game_animation_pile));
|
auto& current_pile = stack_at_location(piles.at(m_new_game_animation_pile));
|
||||||
|
|
||||||
// for first 4 piles, draw 6 cards
|
// for first 4 piles, draw 6 cards
|
||||||
|
@ -404,6 +410,16 @@ void Game::timer_event(Core::TimerEvent&)
|
||||||
m_state = State::WaitingForNewGame;
|
m_state = State::WaitingForNewGame;
|
||||||
stop_timer();
|
stop_timer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Game::timer_event(Core::TimerEvent&)
|
||||||
|
{
|
||||||
|
if (m_state == State::NewGameAnimation) {
|
||||||
|
if (m_new_game_animation_delay < new_game_animation_delay) {
|
||||||
|
++m_new_game_animation_delay;
|
||||||
|
} else {
|
||||||
|
m_new_game_animation_delay = 0;
|
||||||
|
deal_next_card();
|
||||||
}
|
}
|
||||||
} else if (m_state == State::DrawAnimation) {
|
} else if (m_state == State::DrawAnimation) {
|
||||||
if (m_draw_animation_delay < draw_animation_delay) {
|
if (m_draw_animation_delay < draw_animation_delay) {
|
||||||
|
|
|
@ -92,12 +92,14 @@ private:
|
||||||
void detect_victory();
|
void detect_victory();
|
||||||
void move_focused_cards(CardStack& stack);
|
void move_focused_cards(CardStack& stack);
|
||||||
void clear_hovered_stack();
|
void clear_hovered_stack();
|
||||||
|
void deal_next_card();
|
||||||
|
|
||||||
void paint_event(GUI::PaintEvent&) override;
|
virtual void paint_event(GUI::PaintEvent&) override;
|
||||||
void mousedown_event(GUI::MouseEvent&) override;
|
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||||
void mouseup_event(GUI::MouseEvent&) override;
|
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||||
void mousemove_event(GUI::MouseEvent&) override;
|
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||||
void timer_event(Core::TimerEvent&) override;
|
virtual void doubleclick_event(GUI::MouseEvent&) override;
|
||||||
|
virtual void timer_event(Core::TimerEvent&) override;
|
||||||
|
|
||||||
Mode m_mode { Mode::SingleSuit };
|
Mode m_mode { Mode::SingleSuit };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue