feat: sticky exchange

This commit is contained in:
tiger tiger tiger 2026-01-18 17:52:04 +01:00
parent 2164c2e1fc
commit 65e818aa80
3 changed files with 7 additions and 24 deletions

View File

@ -265,17 +265,12 @@ func _end_drag(draggable: Draggable) -> void:
if sticky.get_parent() != self: if sticky.get_parent() != self:
sticky.reparent(self) sticky.reparent(self)
# Ensure it's in the notes array
if not sticky in notes:
notes.append(sticky)
# Check win condition after any sticky movement # Check win condition after any sticky movement
check_board_completion() check_board_completion()
func reclaim_sticky(note: StickyNote): func reclaim_sticky(note: StickyNote):
note.reparent(self) note.reparent(self)
notes.append(note)
func check_board_completion(): func check_board_completion():
@ -288,12 +283,7 @@ func check_board_completion():
give_lore_feedback() give_lore_feedback()
func is_board_complete() -> bool: func is_board_complete() -> bool:
if mementos_collected < 4: return false return mementos_collected == 4 and notes.all(func (n : StickyNote): return n.is_attached)
for sticky : StickyNote in notes:
if not sticky.is_attached: return false
return true
var unfitting: bool = false var unfitting: bool = false
var incomplete: bool = false var incomplete: bool = false
@ -337,7 +327,7 @@ func give_lore_feedback():
# Mark area that was hovered over as currently selected # 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 we're hovering with the mouse without clicking, that updates our selection
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): return if selection and selection.is_dragged: return
var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes)) var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
if not candidate: if not candidate:
@ -400,8 +390,7 @@ func _input(event) -> void:
closed.emit() closed.emit()
get_viewport().set_input_as_handled() get_viewport().set_input_as_handled()
if selection and not selection.is_dragged and 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)) var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
if not candidate: if not candidate:
candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards)) candidate = _nearest_hovered(_sort_by_proximity_and_depth(cards))

View File

@ -95,7 +95,6 @@ func _input(event: InputEvent) -> void:
func _on_input_event(_viewport, event, _shape_idx): func _on_input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if highlighted: if highlighted:
var mouse_offset := get_viewport().get_mouse_position() - position
var board := _get_board() var board := _get_board()
if board and board.has_method("handle_mouse_button"): if board and board.has_method("handle_mouse_button"):
board.handle_mouse_button(event, self) board.handle_mouse_button(event, self)

View File

@ -153,12 +153,7 @@ func _find_drop_target() -> Node:
if (not closest) or ((area.position - position).length() < (closest.position - position).length()): if (not closest) or ((area.position - position).length() < (closest.position - position).length()):
closest = area closest = area
# Return the closest card if found return closest
if closest:
return closest
# Priority 2: Default to board (stay loose in dropzone)
return null
## Find the nearest panel that can accept this sticky ## Find the nearest panel that can accept this sticky
func _find_nearest_panel() -> StickyNotePanel: func _find_nearest_panel() -> StickyNotePanel: