chore: hook up new direct interactable system

This commit is contained in:
tiger tiger tiger 2026-01-05 16:19:21 +01:00
parent 465b00cbd4
commit 8dfbf4ef23
3 changed files with 45 additions and 7 deletions

View File

@ -31,6 +31,17 @@ var has_mouse: bool = false
# 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():
mouse_entered.connect(_on_mouse_entered) mouse_entered.connect(_on_mouse_entered)
# Wire up the CollectableUi with the CanvasLayer for story playback
var canvas = get_node_or_null("%CanvasLayer")
if canvas and ui:
ui.canvas_layer = canvas
# Find and wire the StoryPlayable if not already set
if ui.story_playable == null:
for child in canvas.get_children():
if child is StoryPlayable:
ui.story_playable = child
break
func _on_mouse_entered(): func _on_mouse_entered():
if not State.focus_locked: if not State.focus_locked:

View File

@ -2,9 +2,13 @@ extends CenterContainer
class_name CollectableUi class_name CollectableUi
## The StoryPlayable to play when this memento is collected. ## The StoryPlayable to play when this memento is collected.
## Should be a child node (typically inside a CanvasLayer for full-screen display). ## Auto-discovered from the owner's %CanvasLayer, or can be set manually.
@export var story_playable: StoryPlayable @export var story_playable: StoryPlayable
## Reference to the CanvasLayer containing the story_playable.
## Auto-discovered in _ready() if not set.
var canvas_layer: CanvasLayer
@export var has_stage: bool = false: @export var has_stage: bool = false:
set(focused): set(focused):
if has_stage == focused: return if has_stage == focused: return
@ -165,9 +169,22 @@ func _ready() -> void:
State.settings_changed.connect(_on_context_updated) State.settings_changed.connect(_on_context_updated)
%CollectButton.pressed.connect(collect_memento) %CollectButton.pressed.connect(collect_memento)
##TODO: add functions for remaining buttons ##TODO: add functions for remaining buttons
# Auto-discover story_playable and canvas_layer from scene hierarchy
_discover_story_playable()
update_state() update_state()
## Ensure canvas_layer is set if story_playable was set via export.
## InteractiveSprite._ready() handles the main wiring for inherited scenes.
func _discover_story_playable() -> void:
if story_playable != null and canvas_layer == null:
# story_playable set via export, find its parent CanvasLayer
var parent = story_playable.get_parent()
if parent is CanvasLayer:
canvas_layer = parent
func _on_context_updated() -> void: func _on_context_updated() -> void:
%SkipButton.visible = State.allow_skipping %SkipButton.visible = State.allow_skipping
%SummaryButton.visible = State.provide_summaries %SummaryButton.visible = State.provide_summaries
@ -242,22 +259,28 @@ func collect_memento() -> void:
is_collected = true is_collected = true
return return
# Take stage and mark sequence as starting # Signal that a scene is starting (for music, etc.)
State.take_stage(self)
Scenes.begin_sequence(scene) Scenes.begin_sequence(scene)
# Hide mouse and collapse other interactables # Hide mouse and collapse other interactables BEFORE showing canvas
get_tree().call_group("interactables", "collapse") get_tree().call_group("interactables", "collapse")
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
# Play the story (StoryPlayable handles its own visibility via animations) # Show the CanvasLayer so the story is visible full-screen
if canvas_layer:
canvas_layer.show()
# Play the story
await story_playable.play() await story_playable.play()
# Hide the CanvasLayer when done
if canvas_layer:
canvas_layer.hide()
# Restore mouse # Restore mouse
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
# Leave stage and mark sequence as finished # Signal that the scene is finished
State.leave_stage(self)
Scenes.end_sequence(scene) Scenes.end_sequence(scene)
if was_skipped: if was_skipped:

View File

@ -8,6 +8,10 @@ var enabled_sequences: int = 255:
set(stuff): pass set(stuff): pass
var current_sequence: int = -1 var current_sequence: int = -1
## Returns true if a scene is currently playing.
var is_playing: bool:
get: return current_sequence != -1
enum id { enum id {
YOUTH_DRAEVEN, YOUTH_DRAEVEN,
YOUTH_CHILDHOOD, YOUTH_CHILDHOOD,