1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:47:35 +00:00

LibCards+Games: Remove concept of a CardStack being focused

This was only used for asking the stack if it is the one we are moving
cards from. We now have a better way to do that, by comparing against
`CardGame::moving_cards_source_stack()`, which doesn't require manually
telling a stack that it is/isn't focused.
This commit is contained in:
Sam Atkins 2022-09-28 17:47:19 +01:00 committed by Sam Atkins
parent ef8b1e25aa
commit 5186e617bd
3 changed files with 2 additions and 10 deletions

View file

@ -45,10 +45,7 @@ Gfx::IntRect CardGame::moving_cards_bounds() const
void CardGame::pick_up_cards_from_stack(Cards::CardStack& stack, Gfx::IntPoint click_location, CardStack::MovementRule movement_rule)
{
if (m_moving_cards_source_stack)
m_moving_cards_source_stack->set_focused(false);
stack.add_all_grabbed_cards(click_location, m_moving_cards, movement_rule);
stack.set_focused(true);
m_moving_cards_source_stack = stack;
}
@ -60,7 +57,7 @@ RefPtr<CardStack> CardGame::find_stack_to_drop_on(CardStack::MovementRule moveme
float closest_distance = FLT_MAX;
for (auto const& stack : stacks()) {
if (stack.is_focused())
if (stack == moving_cards_source_stack())
continue;
if (stack.bounding_box().intersects(bounds_to_check)
@ -92,8 +89,6 @@ void CardGame::drop_cards_on_stack(Cards::CardStack& stack, CardStack::MovementR
void CardGame::clear_moving_cards()
{
if (!m_moving_cards_source_stack.is_null())
m_moving_cards_source_stack->set_focused(false);
m_moving_cards_source_stack.clear();
m_moving_cards.clear();
}