Skip to content

Commit b9a9311

Browse files
committed
Quest Separator: Add Play button
1 parent 4b28def commit b9a9311

2 files changed

Lines changed: 48 additions & 9 deletions

File tree

scenes/menus/quest_separator/components/quest_separator.gd

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ extends Control
55
@onready var title: Label = %Title
66
@onready var animated_texture_rect: AnimatedTextureRect = %AnimatedTextureRect
77
@onready var rich_text_label: RichTextLabel = %RichTextLabel
8+
@onready var play_button: Button = %PlayButton
9+
@onready var auto_play_progress_bar: ProgressBar = %AutoPlayProgressBar
10+
@onready var auto_play_timer: Timer = %AutoPlayTimer
811

912

1013
func _ready() -> void:
@@ -15,14 +18,20 @@ func _ready() -> void:
1518
animated_texture_rect.animation_name = quest.animation_name
1619
rich_text_label.text = quest.description
1720

18-
await get_tree().create_timer(3).timeout
21+
play_button.grab_focus()
22+
play_button.pressed.connect(play)
1923

20-
(
21-
SceneSwitcher
22-
. change_to_file_with_transition(
23-
quest.first_scene,
24-
^"",
25-
Transition.Effect.RADIAL,
26-
Transition.Effect.FADE,
27-
)
24+
auto_play_progress_bar.max_value = auto_play_timer.wait_time
25+
auto_play_timer.timeout.connect(play)
26+
27+
28+
func _process(_delta: float) -> void:
29+
auto_play_progress_bar.value = auto_play_timer.wait_time - auto_play_timer.time_left
30+
31+
32+
func play() -> void:
33+
auto_play_timer.stop()
34+
var quest := GameState.quest.quest
35+
SceneSwitcher.change_to_file_with_transition(
36+
quest.first_scene, ^"", Transition.Effect.RADIAL, Transition.Effect.FADE
2837
)

scenes/menus/quest_separator/quest_separator.tscn

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ anchor_right = 1.0
4848
anchor_bottom = 1.0
4949
grow_horizontal = 2
5050
grow_vertical = 2
51+
theme_override_constants/margin_left = 192
52+
theme_override_constants/margin_top = 64
53+
theme_override_constants/margin_right = 192
54+
theme_override_constants/margin_bottom = 64
5155

5256
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer" unique_id=1354617346]
5357
layout_mode = 2
@@ -82,6 +86,26 @@ layout_mode = 2
8286
text = "StoryWeaver runs away from a growing emptiness that spreads across the land, smothering and swallowing everything it covers."
8387
fit_content = true
8488

89+
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer" unique_id=175954450]
90+
layout_mode = 2
91+
alignment = 2
92+
93+
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/HBoxContainer" unique_id=1564039556]
94+
layout_mode = 2
95+
theme_override_constants/separation = 0
96+
97+
[node name="PlayButton" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer" unique_id=327046167]
98+
unique_name_in_owner = true
99+
layout_mode = 2
100+
theme_type_variation = &"FlatButton"
101+
text = "Play"
102+
flat = true
103+
104+
[node name="AutoPlayProgressBar" type="ProgressBar" parent="MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer" unique_id=1528838248]
105+
unique_name_in_owner = true
106+
layout_mode = 2
107+
show_percentage = false
108+
85109
[node name="TextureRect" type="TextureRect" parent="." unique_id=279230856]
86110
material = SubResource("CanvasItemMaterial_wq0a1")
87111
layout_mode = 1
@@ -91,3 +115,9 @@ anchor_bottom = 1.0
91115
grow_horizontal = 2
92116
grow_vertical = 2
93117
texture = ExtResource("6_wq0a1")
118+
119+
[node name="AutoPlayTimer" type="Timer" parent="." unique_id=229639968]
120+
unique_name_in_owner = true
121+
wait_time = 3.0
122+
one_shot = true
123+
autostart = true

0 commit comments

Comments
 (0)