@@ -9,9 +9,6 @@ class_name DialogueLabel extends RichTextLabel
9
9
## Emitted for each letter typed out.
10
10
signal spoke (letter : String , letter_index : int , speed : float )
11
11
12
- ## Emitted when typing paused for a `[wait]`
13
- signal paused_typing (duration : float )
14
-
15
12
## Emitted when the player skips the typing of dialogue.
16
13
signal skipped_typing ()
17
14
@@ -21,6 +18,9 @@ signal started_typing()
21
18
## Emitted when typing finishes.
22
19
signal finished_typing ()
23
20
21
+ ## [Deprecated] No longer emitted.
22
+ signal paused_typing (duration : float )
23
+
24
24
25
25
## The action to press to skip typing.
26
26
@export var skip_action : StringName = & "ui_cancel"
@@ -57,12 +57,13 @@ var dialogue_line:
57
57
## Whether the label is currently typing itself out.
58
58
var is_typing : bool = false :
59
59
set (value ):
60
- var is_finished : bool = is_typing != value and value == false
61
- is_typing = value
60
+ var is_finished : bool = _is_typing != value and value == false and visible_characters == get_total_character_count ()
61
+ _is_typing = value
62
62
if is_finished :
63
63
finished_typing .emit ()
64
64
get :
65
- return is_typing
65
+ return _is_typing and not _is_awaiting_mutation
66
+ var _is_typing : bool = false
66
67
67
68
var _last_wait_index : int = - 1
68
69
var _last_mutation_index : int = - 1
@@ -71,7 +72,7 @@ var _is_awaiting_mutation: bool = false
71
72
72
73
73
74
func _process (delta : float ) -> void :
74
- if self . is_typing :
75
+ if _is_typing :
75
76
# Type out text
76
77
if visible_ratio < 1 :
77
78
# See if we are waiting
@@ -83,7 +84,7 @@ func _process(delta: float) -> void:
83
84
else :
84
85
# Make sure any mutations at the end of the line get run
85
86
_mutate_inline_mutations (get_total_character_count ())
86
- self . is_typing = false
87
+ is_typing = false
87
88
88
89
89
90
## Sets the label's text from the current dialogue line. Override if you want
@@ -102,25 +103,25 @@ func type_out() -> void:
102
103
_last_mutation_index = - 1
103
104
_already_mutated_indices .clear ()
104
105
105
- self . is_typing = true
106
+ is_typing = true
106
107
started_typing .emit ()
107
108
108
109
# Allow typing listeners a chance to connect
109
110
await get_tree ().process_frame
110
111
111
112
if get_total_character_count () == 0 :
112
- self . is_typing = false
113
+ is_typing = false
113
114
elif seconds_per_step == 0 :
114
115
_mutate_remaining_mutations ()
115
116
visible_characters = get_total_character_count ()
116
- self . is_typing = false
117
+ is_typing = false
117
118
118
119
119
120
## Stop typing out the text and jump right to the end
120
121
func skip_typing () -> void :
121
122
_mutate_remaining_mutations ()
122
123
visible_characters = get_total_character_count ()
123
- self . is_typing = false
124
+ is_typing = false
124
125
skipped_typing .emit ()
125
126
126
127
@@ -136,17 +137,11 @@ func _type_next(delta: float, seconds_needed: float) -> void:
136
137
_mutate_inline_mutations (visible_characters )
137
138
if _is_awaiting_mutation : return
138
139
139
- var additional_waiting_seconds : float = _get_pause (visible_characters )
140
-
141
140
# Pause on characters like "."
142
- if _should_auto_pause ():
143
- additional_waiting_seconds += seconds_per_pause_step
144
-
145
- # Pause at literal [wait] directives
146
- if _last_wait_index != visible_characters and additional_waiting_seconds > 0 :
141
+ var waiting_seconds : float = seconds_per_pause_step if _should_auto_pause () else 0
142
+ if _last_wait_index != visible_characters and waiting_seconds > 0 :
147
143
_last_wait_index = visible_characters
148
- _waiting_seconds += additional_waiting_seconds
149
- paused_typing .emit (_get_pause (visible_characters ))
144
+ _waiting_seconds += waiting_seconds
150
145
else :
151
146
visible_characters += 1
152
147
if visible_characters <= get_total_character_count ():
@@ -159,11 +154,6 @@ func _type_next(delta: float, seconds_needed: float) -> void:
159
154
_type_next (delta , seconds_needed )
160
155
161
156
162
- # Get the pause for the current typing position if there is one
163
- func _get_pause (at_index : int ) -> float :
164
- return dialogue_line .pauses .get (at_index , 0 )
165
-
166
-
167
157
# Get the speed for the current typing position
168
158
func _get_speed (at_index : int ) -> float :
169
159
var speed : float = 1
0 commit comments