From a992ef476dcf10a6dbc9a0b955c6cce377339e89 Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Sun, 18 Jan 2026 16:49:40 +0100 Subject: [PATCH] wip: drag and drop fixes --- src/logic-scenes/board/card-board.gd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 06d63c3..8a31d09 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -321,10 +321,15 @@ func give_lore_feedback(): complete = true # Mark area that was hovered over as currently selected -func handle_hover(draggable: Draggable) -> void: - +func handle_hover(_draggable: Draggable) -> void: # If we're hovering with the mouse without clicking, that updates our selection if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return + + var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes)) + if not candidate: + candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards)) + selection = candidate + func _sort_by_proximity_and_depth(draggables: Array) -> Array[Draggable]: @@ -334,7 +339,7 @@ func _sort_by_proximity_and_depth(draggables: Array) -> Array[Draggable]: var depth := len(result) * 2 for item in result: depth -= 1 - item.z_index = depth + item.z_index = depth if item.mouse_over else 0 # only care about the ones we are currently touching return result @@ -382,7 +387,7 @@ func _input(event) -> void: get_viewport().set_input_as_handled() - if event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"): + if selection and event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"): var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes)) if not candidate: candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards))