Skip to content

Commit

Permalink
Merge pull request #2439 from salianifo/skippable-waits
Browse files Browse the repository at this point in the history
Add skippable option to Wait event
  • Loading branch information
zaknafean authored Oct 16, 2024
2 parents df7dee7 + c6e46d1 commit c4227bd
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion addons/dialogic/Modules/Wait/event_wait.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ extends DialogicEvent
var time: float = 1.0
## If true the text box will be hidden while the event waits.
var hide_text := true
## If true the wait can be skipped with user input
var skippable := false

var _tween: Tween

################################################################################
## EXECUTE
Expand All @@ -30,7 +33,22 @@ func _execute() -> void:
dialogic.Text.update_dialog_text('', true)
dialogic.Text.hide_textbox()

await dialogic.get_tree().create_timer(final_wait_time, false, DialogicUtil.is_physics_timer()).timeout
_tween = dialogic.get_tree().create_tween()
if DialogicUtil.is_physics_timer():
_tween.set_process_mode(Tween.TWEEN_PROCESS_PHYSICS)
_tween.tween_callback(_on_finish).set_delay(final_wait_time)

if skippable:
dialogic.Inputs.dialogic_action.connect(_on_finish)


func _on_finish() -> void:
if is_instance_valid(_tween):
_tween.kill()

if skippable:
dialogic.Inputs.dialogic_action.disconnect(_on_finish)

if dialogic.Animations.is_animating():
dialogic.Animations.stop_animation()
dialogic.current_state = dialogic.States.IDLE
Expand Down Expand Up @@ -62,6 +80,7 @@ func get_shortcode_parameters() -> Dictionary:
#param_name : property_info
"time" : {"property": "time", "default": 1},
"hide_text" : {"property": "hide_text", "default": true},
"skippable" : {"property": "skippable", "default": false},
}


Expand All @@ -74,3 +93,4 @@ func build_event_editor() -> void:
add_header_label('seconds', 'time != 1')
add_header_label('second', 'time == 1')
add_body_edit('hide_text', ValueType.BOOL, {'left_text':'Hide text box:'})
add_body_edit('skippable', ValueType.BOOL, {'left_text':'Skippable:'})

0 comments on commit c4227bd

Please sign in to comment.