fix: cards now properly talk to the right handler.

This commit is contained in:
tiger tiger tiger 2026-01-22 17:58:56 +01:00
parent 9990a80845
commit 03f427b76a
5 changed files with 14 additions and 6 deletions

View File

@ -278,4 +278,4 @@ func handle_drop(draggable: StickyNote) -> int:
## Cards always drop back to board dropzone ## Cards always drop back to board dropzone
func find_drop_target() -> Node: func find_drop_target() -> Node:
return _get_board() return _get_button_handler()

View File

@ -56,11 +56,11 @@ func _get_hover_handler() -> Node:
## Walks up the scene tree to find the CardBoard ## Walks up the scene tree to find the CardBoard
func _get_board() -> CardBoard: func _get_button_handler() -> Node:
var node := get_parent() var node := get_parent()
while node: while node:
if node.has_method("handle_mouse_button"): if node.has_method("handle_mouse_button"):
return node as CardBoard return node
node = node.get_parent() node = node.get_parent()
return null return null
@ -94,13 +94,15 @@ func _input(event: InputEvent) -> void:
if is_dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_released(): if is_dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_released():
is_dragged = false is_dragged = false
# Trigger the drop logic # Trigger the drop logic
_get_board().handle_mouse_button(event, self) var handler := _get_button_handler()
if handler: handler.handle_mouse_button(event, self)
## Handles input events on this Area2D (used to start drag) ## Handles input events on this Area2D (used to start drag)
func _on_input_event(_viewport, event, _shape_idx): func _on_input_event(_viewport, event, _shape_idx):
if highlighted and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: if highlighted and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
_get_board().handle_mouse_button(event, self) var handler := _get_button_handler()
if handler: handler.handle_mouse_button(event, self)
## Starts a drag operation ## Starts a drag operation

View File

@ -100,7 +100,7 @@ var random_player: AnimationPlayer
var card_anim_skipped:bool = false var card_anim_skipped:bool = false
func _input(event : InputEvent): func _input(event : InputEvent) -> void:
if _input_locked: return if _input_locked: return
# Navigation # Navigation

View File

@ -113,9 +113,11 @@ func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_pause"): if event.is_action_pressed("ui_pause"):
state = AppState.PAUSE state = AppState.PAUSE
get_viewport().set_input_as_handled()
if not Engine.is_editor_hint(): if not Engine.is_editor_hint():
if event.is_action_pressed("toggle_fullscreen"): if event.is_action_pressed("toggle_fullscreen"):
get_viewport().set_input_as_handled()
# I have no idea why I wrote thit as convoluted, # I have no idea why I wrote thit as convoluted,
# but it works(TM) so I am not gonna change it :D # but it works(TM) so I am not gonna change it :D
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN: if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:

View File

@ -22,3 +22,7 @@ func _on_help_pressed():
func appear(): func appear():
show() show()
%ResumeButton.grab_focus.call_deferred() %ResumeButton.grab_focus.call_deferred()
func _unhandled_input(_event: InputEvent) -> void:
if not visible: return
get_viewport().set_input_as_handled()