Skip to content

Commit 8461a60

Browse files
committed
quest_004: Fix intro book not starting and reuse the shared storybook art
1 parent 8e8bc65 commit 8461a60

3 files changed

Lines changed: 95 additions & 51 deletions

File tree

scenes/quests/lore_quests/quest_004/01_dream_threshold/intro_storybook.gd

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
11
# SPDX-FileCopyrightText: The Threadbare Authors
22
# SPDX-License-Identifier: MPL-2.0
33
extends CanvasLayer
4-
## Libro de historia: pantalla en NEGRO, se abre un libro que cuenta la historia
5-
## página a página, y al terminar (o saltar con Esc) se desvanece y devuelve el
6-
## control. Pausa el juego mientras se muestra.
7-
##
8-
## Sirve para el INTRO (auto_start = true: se abre al cargar la escena) y para el
9-
## FINAL (auto_start = false: queda oculto hasta que algo llame [method start_book],
10-
## p. ej. un Area2D conectada a [method on_player_entered]).
11-
12-
## Títulos (página izquierda del libro). Uno por entrada de [member pages].
13-
## Si falta el título de una página, la página izquierda queda en blanco.
14-
@export var titles: PackedStringArray = []
15-
## Cuerpo de cada página (página derecha del libro). Se permite BBCode ([i], etc.).
16-
@export var pages: PackedStringArray = []
17-
## Duración de los fundidos de apertura/cierre (s).
4+
5+
@export var titles: PackedStringArray = [
6+
"The Last Petal", "The Weaver Wakes", "Before the Petal Falls"
7+
]
8+
9+
@export var pages: PackedStringArray = [
10+
(
11+
"Long ago, every dream was woven on a single Loom, and at its heart grew a flower — the [i]Stellaria[/i] — whose petals held all we remember, imagine and feel."
12+
),
13+
"You are the [i]Storyweaver[/i], called from sleep to gather what was lost.",
14+
"Through golden meadows, a keeper's garden, a forgetting forest and a fleeing night...",
15+
]
16+
17+
@export var pages_right: PackedStringArray = [
18+
(
19+
"Then the Void crept in, thread by thread, and the petals fell, one by one, until the meadow itself grew quiet and grey.\n\nOnly the last petal still clings — trembling, waiting for someone to answer its call."
20+
),
21+
(
22+
"Three threads remain — [i]Memory[/i], [i]Imagination[/i] and [i]Spirit[/i] — scattered across the dreaming meadow.\n\nHum to the old stones and they will rise to carry you; pull each thread back toward the Loom before it unravels for good."
23+
),
24+
(
25+
"Find the three threads. Bring them to Noria's Loom.\n\nMake the Stellaria bloom — before the last petal lets go, and the dream forgets itself forever."
26+
),
27+
]
1828
@export var fade_time: float = 0.7
19-
## Si está activo, el libro se abre solo al cargar la escena (modo intro).
20-
## Si no, queda oculto hasta llamar start_book() (modo final por trigger).
2129
@export var auto_start: bool = true
22-
## (Opcional, modo no-auto) Área que, al entrar el jugador, abre el libro.
2330
@export var trigger_area: Area2D
2431

2532
@onready var black: ColorRect = $Black
2633
@onready var book: Control = $Book
27-
@onready var left_title: Label = $Book/LeftTitle
34+
@onready var book_art: AnimatedTextureRect = $Book
35+
@onready var left_title: Label = $Book/TitleBox/LeftTitle
36+
@onready var left_body: RichTextLabel = $Book/LeftBody
2837
@onready var right_body: RichTextLabel = $Book/RightBody
2938
@onready var hint: Label = $Hint
3039

@@ -43,7 +52,6 @@ func _ready() -> void:
4352
trigger_area.body_entered.connect(on_player_entered)
4453

4554

46-
## Abre el libro: pausa, muestra la primera página y lo desvanece hacia adentro.
4755
func start_book() -> void:
4856
if _started:
4957
return
@@ -67,7 +75,6 @@ func start_book() -> void:
6775
t.chain().tween_callback(_unlock)
6876

6977

70-
## Conéctalo al body_entered de un Area2D para abrir el libro al pasar el jugador.
7178
func on_player_entered(body: Node2D) -> void:
7279
if not _started and body.is_in_group(&"player"):
7380
start_book()
@@ -80,7 +87,8 @@ func _unlock() -> void:
8087
func _show_page(i: int) -> void:
8188
_index = i
8289
left_title.text = titles[i] if i < titles.size() else ""
83-
right_body.text = pages[i]
90+
left_body.text = pages[i]
91+
right_body.text = pages_right[i] if i < pages_right.size() else ""
8492
if i < pages.size() - 1:
8593
hint.text = "▶ clic / Enter · Esc para saltar"
8694
else:
@@ -113,11 +121,14 @@ func _next() -> void:
113121
_finish()
114122
return
115123
_busy = true
124+
_play_page_flip()
116125
var t := create_tween().set_parallel(true)
117126
t.tween_property(left_title, "modulate:a", 0.0, 0.12)
127+
t.tween_property(left_body, "modulate:a", 0.0, 0.12)
118128
t.tween_property(right_body, "modulate:a", 0.0, 0.12)
119129
t.chain().tween_callback(_advance_page)
120130
t.tween_property(left_title, "modulate:a", 1.0, 0.14)
131+
t.tween_property(left_body, "modulate:a", 1.0, 0.14)
121132
t.tween_property(right_body, "modulate:a", 1.0, 0.14)
122133
t.chain().tween_callback(_unlock)
123134

@@ -126,6 +137,18 @@ func _advance_page() -> void:
126137
_show_page(_index + 1)
127138

128139

140+
## Reuses the shared storybook page-turn art (see scenes/menus/storybook/).
141+
func _play_page_flip() -> void:
142+
book_art.animation_name = &"book_right"
143+
var frames := book_art.sprite_frames
144+
var duration := frames.get_frame_count(&"book_right") / frames.get_animation_speed(&"book_right")
145+
get_tree().create_timer(duration).timeout.connect(_on_page_flip_finished)
146+
147+
148+
func _on_page_flip_finished() -> void:
149+
book_art.animation_name = &"idle"
150+
151+
129152
func _finish() -> void:
130153
_busy = true
131154
var t := create_tween().set_parallel(true)

scenes/quests/lore_quests/quest_004/01_dream_threshold/intro_storybook.tscn

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
[gd_scene format=3 uid="uid://c728g77vt54pq"]
22

33
[ext_resource type="Script" uid="uid://b8h45uimhuhl2" path="res://scenes/quests/lore_quests/quest_004/01_dream_threshold/intro_storybook.gd" id="1_i"]
4-
[ext_resource type="Texture2D" uid="uid://dakvpilaqdm3b" path="res://scenes/menus/storybook/Textures/book_turn_left.png" id="2_b"]
54
[ext_resource type="Theme" uid="uid://cvitou84ni7qe" path="res://scenes/ui_elements/components/theme.tres" id="3_theme"]
6-
7-
[sub_resource type="AtlasTexture" id="AtlasTexture_b"]
8-
atlas = ExtResource("2_b")
9-
region = Rect2(0, 0, 999, 720)
5+
[ext_resource type="Script" uid="uid://dfx8s2ybd11mt" path="res://scenes/menus/storybook/components/animated_texture_rect.gd" id="4_anim"]
6+
[ext_resource type="SpriteFrames" uid="uid://dne3cxrhbjuno" path="res://scenes/menus/storybook/components/storybook_animation.tres" id="5_sf"]
107

118
[node name="IntroStorybook" type="CanvasLayer" unique_id=1507766693]
129
process_mode = 3
1310
layer = 60
1411
script = ExtResource("1_i")
15-
titles = PackedStringArray("The Last Petal", "The Weaver Wakes", "Before the Petal Falls")
16-
pages = PackedStringArray("Long ago, every dream was woven on a single Loom, and at its heart grew a flower — the [i]Stellaria[/i] — whose petals held all we remember, imagine and feel.\n\nThen the Void crept in, thread by thread, and the petals fell.\n\nOnly the last petal still clings.", "You are the [i]Storyweaver[/i], called from sleep to gather what was lost.\n\nThree threads remain — [i]Memory[/i], [i]Imagination[/i] and [i]Spirit[/i].\n\nHum to the old stones and they will rise to carry you; pull each thread back toward the Loom.", "Through golden meadows, a keeper's garden, a forgetting forest and a fleeing night...\n\nFind the three threads. Bring them to Noria's Loom.\n\nMake the Stellaria bloom — before the last petal lets go.")
1712

1813
[node name="Black" type="ColorRect" parent="." unique_id=82491225]
1914
anchors_preset = 15
@@ -22,11 +17,11 @@ anchor_bottom = 1.0
2217
grow_horizontal = 2
2318
grow_vertical = 2
2419
mouse_filter = 2
25-
color = Color(0.03, 0.03, 0.06, 1)
20+
color = Color(0.03, 0.03, 0.06, 0.75)
2621

2722
[node name="Book" type="TextureRect" parent="." unique_id=1445237289]
28-
theme = ExtResource("3_theme")
2923
unique_name_in_owner = true
24+
anchors_preset = 8
3025
anchor_left = 0.5
3126
anchor_top = 0.5
3227
anchor_right = 0.5
@@ -37,48 +32,76 @@ offset_right = 380.0
3732
offset_bottom = 274.0
3833
pivot_offset = Vector2(380, 274)
3934
mouse_filter = 2
40-
texture = SubResource("AtlasTexture_b")
35+
theme = ExtResource("3_theme")
4136
expand_mode = 1
4237
stretch_mode = 5
38+
script = ExtResource("4_anim")
39+
sprite_frames = ExtResource("5_sf")
4340

44-
[node name="LeftTitle" type="Label" parent="Book" unique_id=1084628526]
45-
unique_name_in_owner = true
41+
[node name="TitleBox" type="PanelContainer" parent="Book" unique_id=1084628525]
42+
layout_mode = 1
43+
anchors_preset = 10
4644
anchor_right = 1.0
47-
anchor_bottom = 1.0
48-
offset_left = 70.0
49-
offset_top = 120.0
50-
offset_right = -412.0
51-
offset_bottom = -120.0
45+
offset_left = 91.0
46+
offset_top = 85.0
47+
offset_right = -390.0
48+
offset_bottom = 148.0
5249
grow_horizontal = 2
53-
grow_vertical = 2
5450
mouse_filter = 2
51+
theme_type_variation = &"PlayerRibbon"
52+
53+
[node name="LeftTitle" type="Label" parent="Book/TitleBox" unique_id=1084628526]
54+
unique_name_in_owner = true
55+
layout_mode = 2
5556
theme_override_colors/font_color = Color(0.22, 0.16, 0.11, 1)
56-
theme_override_font_sizes/font_size = 38
57+
theme_override_font_sizes/font_size = 22
5758
text = "The Last Petal"
5859
horizontal_alignment = 1
5960
vertical_alignment = 1
60-
autowrap_mode = 3
61+
clip_text = true
62+
63+
[node name="LeftBody" type="RichTextLabel" parent="Book" unique_id=448118183]
64+
unique_name_in_owner = true
65+
layout_mode = 1
66+
anchors_preset = 15
67+
anchor_right = 1.0
68+
anchor_bottom = 1.0
69+
offset_left = 101.0
70+
offset_top = 175.0
71+
offset_right = -386.0
72+
offset_bottom = -101.0
73+
grow_horizontal = 2
74+
grow_vertical = 2
75+
mouse_filter = 2
76+
theme_override_colors/default_color = Color(0.22, 0.16, 0.11, 1)
77+
theme_override_constants/line_separation = 7
78+
theme_override_font_sizes/normal_font_size = 21
79+
theme_override_font_sizes/italics_font_size = 21
80+
bbcode_enabled = true
81+
scroll_active = false
6182

6283
[node name="RightBody" type="RichTextLabel" parent="Book" unique_id=448118184]
6384
unique_name_in_owner = true
85+
layout_mode = 1
86+
anchors_preset = 15
6487
anchor_right = 1.0
6588
anchor_bottom = 1.0
66-
offset_left = 400.0
89+
offset_left = 410.0
6790
offset_top = 96.0
68-
offset_right = -66.0
91+
offset_right = -77.0
6992
offset_bottom = -104.0
7093
grow_horizontal = 2
7194
grow_vertical = 2
7295
mouse_filter = 2
73-
bbcode_enabled = true
74-
scroll_active = false
7596
theme_override_colors/default_color = Color(0.22, 0.16, 0.11, 1)
7697
theme_override_constants/line_separation = 7
77-
theme_override_font_sizes/normal_font_size = 23
78-
theme_override_font_sizes/italics_font_size = 23
98+
theme_override_font_sizes/normal_font_size = 21
99+
theme_override_font_sizes/italics_font_size = 21
100+
bbcode_enabled = true
101+
scroll_active = false
79102

80103
[node name="Hint" type="Label" parent="." unique_id=2084880253]
81-
theme = ExtResource("3_theme")
104+
anchors_preset = 7
82105
anchor_left = 0.5
83106
anchor_top = 1.0
84107
anchor_right = 0.5
@@ -89,7 +112,7 @@ offset_right = 220.0
89112
offset_bottom = -14.0
90113
grow_horizontal = 2
91114
grow_vertical = 0
92-
mouse_filter = 2
115+
theme = ExtResource("3_theme")
93116
theme_override_colors/font_color = Color(0.85, 0.85, 0.9, 0.8)
94117
theme_override_font_sizes/font_size = 18
95118
text = "▶ clic / Enter"

scenes/quests/lore_quests/quest_004/01_dream_threshold/mythical_meadows.tscn

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ animations = [{
9595
[node name="MythicalMeadows" type="Node2D" unique_id=78806229]
9696

9797
[node name="IntroStorybook" parent="." unique_id=2065889873 instance=ExtResource("80_intro")]
98-
titles = []
99-
pages = []
10098

10199
[node name="HUD" parent="." unique_id=965472728 instance=ExtResource("98_hud")]
102100

0 commit comments

Comments
 (0)