fix: cardboard can now be opened.

This commit is contained in:
tiger tiger tiger 2026-01-12 22:50:49 +01:00
parent cc04eea1a8
commit 11994f7f27
2 changed files with 14 additions and 2 deletions

View File

@ -27,6 +27,7 @@ var focus_stickies:bool = true:
var focused := false: var focused := false:
set(focus): set(focus):
var was_focused := focused
if focus: if focus:
focused = true focused = true
get_tree().call_group("interactables", "collapse") get_tree().call_group("interactables", "collapse")
@ -44,6 +45,9 @@ var focused := false:
if sticky is StickyNote: if sticky is StickyNote:
sticky.is_dragged = false sticky.is_dragged = false
visible = focused visible = focused
# Emit closed signal when transitioning from focused to unfocused
if was_focused and not focused:
closed.emit()
@onready var dropzone := $HBoxContainer/dropzone @onready var dropzone := $HBoxContainer/dropzone
@ -131,6 +135,7 @@ var last_save_dict: Dictionary
var text_recovery: Dictionary var text_recovery: Dictionary
signal board_completed signal board_completed
signal closed
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
@ -576,6 +581,13 @@ func on_scene_skipped(i: int):
func claim_focus(): func claim_focus():
focused = true focused = true
## Awaitable function to show the board and wait until user closes it
func play() -> void:
focused = true
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
await closed
func find_first_free_card() -> int: func find_first_free_card() -> int:
for i in range(dropzone.get_child_count()): for i in range(dropzone.get_child_count()):
# start searching at the current location, use modulo to avoid getting out of array bounds # start searching at the current location, use modulo to avoid getting out of array bounds

View File

@ -230,7 +230,7 @@ func _move_card():
position += (get_viewport().get_mouse_position() - position) - mouse_offset position += (get_viewport().get_mouse_position() - position) - mouse_offset
func has_sticky_note_attached() -> bool: func has_sticky_note_attached() -> bool:
return get_child_count(false) > 0 return get_attached_sticky_note() != null
func get_attached_sticky_note() -> StickyNote: func get_attached_sticky_note() -> StickyNote:
for child in get_children(false): for child in get_children(false):