#166 fix skip control
This commit is contained in:
parent
57e11162ef
commit
57ded43713
|
|
@ -54,7 +54,7 @@ var all_text_revealed: bool = false:
|
||||||
if revealed and not all_text_revealed:
|
if revealed and not all_text_revealed:
|
||||||
var tween: Tween = get_tree().create_tween()
|
var tween: Tween = get_tree().create_tween()
|
||||||
tween.set_ease(Tween.EASE_OUT)
|
tween.set_ease(Tween.EASE_OUT)
|
||||||
tween.tween_property(label, "visible_ratio", 1, 1.5)
|
tween.tween_property(label, "visible_ratio", 1, 0.5)
|
||||||
elif not revealed and all_text_revealed:
|
elif not revealed and all_text_revealed:
|
||||||
reset_progress = true
|
reset_progress = true
|
||||||
all_text_revealed = revealed
|
all_text_revealed = revealed
|
||||||
|
|
@ -174,7 +174,9 @@ func trigger_intro():
|
||||||
|
|
||||||
var was_skipped = false
|
var was_skipped = false
|
||||||
func skip_text():
|
func skip_text():
|
||||||
if not animation_complete:
|
if not all_text_revealed:
|
||||||
|
all_text_revealed = true
|
||||||
|
elif not animation_complete:
|
||||||
animation_player.stop(true)
|
animation_player.stop(true)
|
||||||
was_skipped = true
|
was_skipped = true
|
||||||
text_finished.emit()
|
text_finished.emit()
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,14 @@ var time_pressed: float = 0
|
||||||
|
|
||||||
@onready var button: Button = %SkipButton
|
@onready var button: Button = %SkipButton
|
||||||
@onready var progress: ProgressBar = %ProgressBar
|
@onready var progress: ProgressBar = %ProgressBar
|
||||||
|
@onready var action_prompt: ActionPrompt = %ActionPrompt
|
||||||
|
|
||||||
# control is hidden when there is no input.
|
## control is hidden when there is no input.
|
||||||
var unrevealed: bool = true
|
var unrevealed: bool = true
|
||||||
# as this can be pressed for multiple reasons, this variable is keeping track of all of them.
|
## as this can be pressed for multiple reasons, this variable is keeping track of all of them.
|
||||||
var pressed: bool = false
|
var pressed: bool = false
|
||||||
# determines wheather or not the scene is waiting for a proceed or listening for a skip.
|
## determines if the scene is waiting for a proceed or listening for a skip.
|
||||||
var proceeding: bool = false:
|
var text_revealed: bool = false:
|
||||||
set(value):
|
set(value):
|
||||||
if value and is_node_ready():
|
if value and is_node_ready():
|
||||||
if unrevealed:
|
if unrevealed:
|
||||||
|
|
@ -24,12 +25,14 @@ var proceeding: bool = false:
|
||||||
else:
|
else:
|
||||||
$AnimationPlayer.play("replace_text")
|
$AnimationPlayer.play("replace_text")
|
||||||
await _transition_text
|
await _transition_text
|
||||||
button.text = "continuing ..."
|
button.text = "skip scene"
|
||||||
elif is_node_ready():
|
elif is_node_ready():
|
||||||
button.text = "skip reading (hold)"
|
button.text = "reveal full text (hold)"
|
||||||
proceeding = value
|
action_prompt.action = "ui_next"
|
||||||
# while this is true, a counter counts up to automatically proceed.
|
text_revealed = value
|
||||||
var is_auto_proceeding: bool = true:
|
## while this is true, a counter counts up to automatically proceed.
|
||||||
|
var aborted
|
||||||
|
var is_auto_proceeding: bool = false:
|
||||||
set(value):
|
set(value):
|
||||||
if is_auto_proceeding and not value:
|
if is_auto_proceeding and not value:
|
||||||
var tween = get_tree().create_tween()
|
var tween = get_tree().create_tween()
|
||||||
|
|
@ -41,24 +44,34 @@ var is_auto_proceeding: bool = true:
|
||||||
# use this to disable the updates during progress.
|
# use this to disable the updates during progress.
|
||||||
is_auto_proceeding = false
|
is_auto_proceeding = false
|
||||||
await _transition_text
|
await _transition_text
|
||||||
button.text = "continue (press)"
|
action_prompt.action = "skip"
|
||||||
|
button.text = "continue"
|
||||||
|
elif not is_auto_proceeding and value:
|
||||||
|
$AnimationPlayer.play("replace_text")
|
||||||
|
# use this to disable the updates during progress.
|
||||||
|
await _transition_text
|
||||||
|
is_auto_proceeding = true
|
||||||
|
action_prompt.action = "ui_cancel"
|
||||||
|
button.text = "keep reading"
|
||||||
is_auto_proceeding = value
|
is_auto_proceeding = value
|
||||||
|
|
||||||
#resets progress bar on button
|
#resets progress bar on button
|
||||||
time_pressed = 0
|
time_pressed = 0
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if pressed and is_visible_in_tree():
|
if pressed and is_visible_in_tree():
|
||||||
time_pressed += delta
|
time_pressed += delta
|
||||||
progress.value = time_pressed / skip_delay
|
progress.value = time_pressed / skip_delay
|
||||||
if time_pressed >= skip_delay:
|
if time_pressed >= skip_delay:
|
||||||
skip.emit()
|
skip.emit()
|
||||||
print("emmitted skip!")
|
|
||||||
pressed = false
|
pressed = false
|
||||||
time_pressed = 0
|
time_pressed = 0
|
||||||
|
if not text_revealed:
|
||||||
|
text_revealed = true
|
||||||
|
else:
|
||||||
|
is_auto_proceeding = true
|
||||||
|
|
||||||
elif is_auto_proceeding and proceeding:
|
elif is_auto_proceeding and text_revealed:
|
||||||
time_pressed += delta
|
time_pressed += delta
|
||||||
progress.value = time_pressed / auto_continue_delay
|
progress.value = time_pressed / auto_continue_delay
|
||||||
if time_pressed >= auto_continue_delay:
|
if time_pressed >= auto_continue_delay:
|
||||||
|
|
@ -68,30 +81,35 @@ func _process(delta):
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if is_visible_in_tree():
|
if is_visible_in_tree():
|
||||||
if not event is InputEventMouseMotion and unrevealed:
|
if unrevealed:
|
||||||
$AnimationPlayer.play("reveal_skip")
|
$AnimationPlayer.play("reveal_skip")
|
||||||
unrevealed = false
|
unrevealed = false
|
||||||
|
|
||||||
if event.is_action_pressed("skip"):
|
if event.is_action_pressed("skip"):
|
||||||
if not proceeding:
|
if not (is_auto_proceeding or aborted):
|
||||||
pressed = true
|
pressed = true
|
||||||
else:
|
else:
|
||||||
proceed.emit()
|
proceed.emit()
|
||||||
|
is_auto_proceeding = false
|
||||||
|
$AnimationPlayer.play("vanish_skip")
|
||||||
|
await $AnimationPlayer.animation_finished
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
elif event.is_action_released("skip"):
|
elif event.is_action_released("skip"):
|
||||||
if not proceeding:
|
if not is_auto_proceeding:
|
||||||
pressed = false
|
pressed = false
|
||||||
time_pressed = 0
|
time_pressed = 0
|
||||||
progress.value = 0
|
progress.value = 0
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
elif Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("ui_focus_next") or Input.is_action_just_pressed("skip") and proceeding:
|
elif Input.is_action_just_pressed("ui_accept") or Input.is_action_just_pressed("ui_focus_next") or Input.is_action_just_pressed("skip") and is_auto_proceeding:
|
||||||
proceed.emit()
|
proceed.emit()
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
reset()
|
reset()
|
||||||
elif event.is_action_pressed("ui_cancel"):
|
elif event.is_action_pressed("ui_cancel"):
|
||||||
# FIXME this right now would be consumed by the pause menu.
|
# FIXME this right now would be consumed by the pause menu.
|
||||||
is_auto_proceeding = false
|
is_auto_proceeding = false
|
||||||
|
aborted = true
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
|
|
||||||
func _on_skip_button_toggled(button_pressed):
|
func _on_skip_button_toggled(button_pressed):
|
||||||
|
|
@ -102,7 +120,8 @@ func _on_skip_button_toggled(button_pressed):
|
||||||
time_pressed = 0
|
time_pressed = 0
|
||||||
|
|
||||||
func start_proceed_countdown():
|
func start_proceed_countdown():
|
||||||
proceeding = true
|
text_revealed = true
|
||||||
|
is_auto_proceeding = true
|
||||||
|
|
||||||
func transition_text():
|
func transition_text():
|
||||||
_transition_text.emit()
|
_transition_text.emit()
|
||||||
|
|
@ -112,4 +131,6 @@ func reset():
|
||||||
await(get_tree().create_timer(1).timeout)
|
await(get_tree().create_timer(1).timeout)
|
||||||
unrevealed = true
|
unrevealed = true
|
||||||
pressed = false
|
pressed = false
|
||||||
proceeding = false
|
text_revealed = false
|
||||||
|
aborted = false
|
||||||
|
is_auto_proceeding = false
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=13 format=3 uid="uid://dvwuhobhka78d"]
|
[gd_scene load_steps=14 format=3 uid="uid://dvwuhobhka78d"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dw07pldd135f1" path="res://logic-scenes/misc/skip_control.gd" id="1_s6riu"]
|
[ext_resource type="Script" uid="uid://dw07pldd135f1" path="res://logic-scenes/misc/skip_control.gd" id="1_s6riu"]
|
||||||
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="2_ev8gx"]
|
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="2_ev8gx"]
|
||||||
|
|
@ -199,12 +199,41 @@ tracks/2/keys = {
|
||||||
"values": [Vector2(0.8, 0.8), Vector2(1.1, 1.1), Vector2(1, 1)]
|
"values": [Vector2(0.8, 0.8), Vector2(1.1, 1.1), Vector2(1, 1)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_7em4l"]
|
||||||
|
resource_name = "vanish_skip"
|
||||||
|
length = 0.5
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("SkipButton:self_modulate")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0.0333333, 0.5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||||
|
}
|
||||||
|
tracks/1/type = "value"
|
||||||
|
tracks/1/imported = false
|
||||||
|
tracks/1/enabled = true
|
||||||
|
tracks/1/path = NodePath("SkipButton/ActionPrompt:modulate")
|
||||||
|
tracks/1/interp = 1
|
||||||
|
tracks/1/loop_wrap = true
|
||||||
|
tracks/1/keys = {
|
||||||
|
"times": PackedFloat32Array(0.133333, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Color(1, 1, 1, 1), Color(1, 1, 1, 0)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_f8gbl"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_f8gbl"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_24cc4"),
|
&"RESET": SubResource("Animation_24cc4"),
|
||||||
&"replace_text": SubResource("Animation_7t2h7"),
|
&"replace_text": SubResource("Animation_7t2h7"),
|
||||||
&"reveal_skip": SubResource("Animation_wpc0s"),
|
&"reveal_skip": SubResource("Animation_wpc0s"),
|
||||||
&"skip_pressed": SubResource("Animation_5y7a2")
|
&"skip_pressed": SubResource("Animation_5y7a2"),
|
||||||
|
&"vanish_skip": SubResource("Animation_7em4l")
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="SkipControl" type="Control"]
|
[node name="SkipControl" type="Control"]
|
||||||
|
|
@ -233,7 +262,7 @@ offset_right = 108.0
|
||||||
offset_bottom = 21.5
|
offset_bottom = 21.5
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
text = "skip reading (hold)"
|
text = "reveal full text (hold)"
|
||||||
|
|
||||||
[node name="ProgressBar" type="ProgressBar" parent="SkipButton"]
|
[node name="ProgressBar" type="ProgressBar" parent="SkipButton"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
@ -249,6 +278,7 @@ max_value = 1.0
|
||||||
show_percentage = false
|
show_percentage = false
|
||||||
|
|
||||||
[node name="ActionPrompt" type="TextureRect" parent="SkipButton"]
|
[node name="ActionPrompt" type="TextureRect" parent="SkipButton"]
|
||||||
|
unique_name_in_owner = true
|
||||||
modulate = Color(1, 1, 1, 0)
|
modulate = Color(1, 1, 1, 0)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
anchors_preset = 4
|
anchors_preset = 4
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue