mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:28:11 +00:00
Spider: Highlight valid target stack when hovering over it
This is largely copied and pasted from Solitaire. Moving this into LibCards somehow would be nice but I can't think of a nice way to do so right now.
This commit is contained in:
parent
e193679352
commit
80c7ac0d0e
2 changed files with 27 additions and 0 deletions
|
@ -299,6 +299,7 @@ void Game::move_focused_cards(CardStack& stack)
|
|||
void Game::mouseup_event(GUI::MouseEvent& event)
|
||||
{
|
||||
GUI::Frame::mouseup_event(event);
|
||||
clear_hovered_stack();
|
||||
|
||||
if (!is_moving_cards() || m_new_game_animation || m_draw_animation)
|
||||
return;
|
||||
|
@ -346,6 +347,18 @@ void Game::mousemove_event(GUI::MouseEvent& event)
|
|||
int dx = click_location.dx_relative_to(m_mouse_down_location);
|
||||
int dy = click_location.dy_relative_to(m_mouse_down_location);
|
||||
|
||||
if (auto target_stack = find_stack_to_drop_on(Cards::CardStack::MovementRule::Any)) {
|
||||
if (target_stack != m_hovered_stack) {
|
||||
clear_hovered_stack();
|
||||
|
||||
m_hovered_stack = move(target_stack);
|
||||
m_hovered_stack->set_highlighted(true);
|
||||
update(m_hovered_stack->bounding_box());
|
||||
}
|
||||
} else {
|
||||
clear_hovered_stack();
|
||||
}
|
||||
|
||||
for (auto& to_intersect : moving_cards()) {
|
||||
mark_intersecting_stacks_dirty(to_intersect);
|
||||
to_intersect.rect().translate_by(dx, dy);
|
||||
|
@ -417,4 +430,15 @@ void Game::timer_event(Core::TimerEvent&)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Game::clear_hovered_stack()
|
||||
{
|
||||
if (!m_hovered_stack)
|
||||
return;
|
||||
|
||||
m_hovered_stack->set_highlighted(false);
|
||||
update(m_hovered_stack->bounding_box());
|
||||
m_hovered_stack = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue