|
|
|
|
@ -2,9 +2,13 @@ extends CenterContainer
|
|
|
|
|
class_name CollectableUi
|
|
|
|
|
|
|
|
|
|
## 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
|
|
|
|
|
|
|
|
|
|
## 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:
|
|
|
|
|
set(focused):
|
|
|
|
|
if has_stage == focused: return
|
|
|
|
|
@ -166,8 +170,21 @@ func _ready() -> void:
|
|
|
|
|
%CollectButton.pressed.connect(collect_memento)
|
|
|
|
|
##TODO: add functions for remaining buttons
|
|
|
|
|
|
|
|
|
|
# Auto-discover story_playable and canvas_layer from scene hierarchy
|
|
|
|
|
_discover_story_playable()
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
%SkipButton.visible = State.allow_skipping
|
|
|
|
|
%SummaryButton.visible = State.provide_summaries
|
|
|
|
|
@ -242,22 +259,28 @@ func collect_memento() -> void:
|
|
|
|
|
is_collected = true
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
# Take stage and mark sequence as starting
|
|
|
|
|
State.take_stage(self)
|
|
|
|
|
# Signal that a scene is starting (for music, etc.)
|
|
|
|
|
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")
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
# Hide the CanvasLayer when done
|
|
|
|
|
if canvas_layer:
|
|
|
|
|
canvas_layer.hide()
|
|
|
|
|
|
|
|
|
|
# Restore mouse
|
|
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
|
|
|
|
|
|
|
|
|
# Leave stage and mark sequence as finished
|
|
|
|
|
State.leave_stage(self)
|
|
|
|
|
# Signal that the scene is finished
|
|
|
|
|
Scenes.end_sequence(scene)
|
|
|
|
|
|
|
|
|
|
if was_skipped:
|
|
|
|
|
|