feat: adds adjustable reading speed/display time
This commit is contained in:
committed by
Julian Murgia
parent
42e22f579b
commit
a3da01e4cc
@@ -67,7 +67,8 @@ const _SIMPLE_DIALOG_ROOT = "dialog_simple"
|
|||||||
const AVATARS_PATH = "%s/%s/avatars_path" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
const AVATARS_PATH = "%s/%s/avatars_path" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
||||||
const TEXT_SPEED_PER_CHARACTER = "%s/%s/text_speed_per_character" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
const TEXT_SPEED_PER_CHARACTER = "%s/%s/text_speed_per_character" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
||||||
const FAST_TEXT_SPEED_PER_CHARACTER = "%s/%s/fast_text_speed_per_character" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
const FAST_TEXT_SPEED_PER_CHARACTER = "%s/%s/fast_text_speed_per_character" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
||||||
const MAX_TIME_TO_DISAPPEAR = "%s/%s/max_time_to_disappear" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
const READING_SPEED_IN_WPM = "%s/%s/reading_speed_in_wpm" % [_ESCORIA_SETTINGS_ROOT, _SIMPLE_DIALOG_ROOT]
|
||||||
|
|
||||||
|
|
||||||
# Godot Windows project settings
|
# Godot Windows project settings
|
||||||
const DISPLAY = "display"
|
const DISPLAY = "display"
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func disable_plugin():
|
|||||||
)
|
)
|
||||||
|
|
||||||
ESCProjectSettingsManager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
ESCProjectSettingsManager.MAX_TIME_TO_DISAPPEAR,
|
ESCProjectSettingsManager.READING_SPEED_IN_WPM,
|
||||||
null,
|
null,
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
@@ -83,10 +83,10 @@ func enable_plugin():
|
|||||||
)
|
)
|
||||||
|
|
||||||
ESCProjectSettingsManager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
ESCProjectSettingsManager.MAX_TIME_TO_DISAPPEAR,
|
ESCProjectSettingsManager.READING_SPEED_IN_WPM,
|
||||||
1.0,
|
200,
|
||||||
{
|
{
|
||||||
"type": TYPE_REAL
|
"type": TYPE_INT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ var _text_speed_per_character
|
|||||||
# The text speed per character if the dialog line is skipped
|
# The text speed per character if the dialog line is skipped
|
||||||
var _fast_text_speed_per_character
|
var _fast_text_speed_per_character
|
||||||
|
|
||||||
# The time to wait before the dialog is finished
|
# The reading speed to be used in determining the length of time text remains
|
||||||
var _max_time_to_text_disappear
|
# on the screen.
|
||||||
|
var _reading_speed_in_wpm: int
|
||||||
|
|
||||||
|
# Used to extract words from lines of text.
|
||||||
|
var _word_regex: RegEx = RegEx.new()
|
||||||
|
|
||||||
# Whether the current dialog is speeding up
|
# Whether the current dialog is speeding up
|
||||||
var _is_speeding_up: bool = false
|
var _is_speeding_up: bool = false
|
||||||
@@ -42,9 +46,12 @@ func _ready():
|
|||||||
_fast_text_speed_per_character = ProjectSettings.get_setting(
|
_fast_text_speed_per_character = ProjectSettings.get_setting(
|
||||||
"escoria/dialog_simple/fast_text_speed_per_character"
|
"escoria/dialog_simple/fast_text_speed_per_character"
|
||||||
)
|
)
|
||||||
_max_time_to_text_disappear = ProjectSettings.get_setting(
|
_reading_speed_in_wpm = ProjectSettings.get_setting(
|
||||||
"escoria/dialog_simple/max_time_to_disappear"
|
"escoria/dialog_simple/reading_speed_in_wpm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_word_regex.compile("\\S+")
|
||||||
|
|
||||||
text_node.bbcode_enabled = true
|
text_node.bbcode_enabled = true
|
||||||
tween.connect(
|
tween.connect(
|
||||||
"tween_completed",
|
"tween_completed",
|
||||||
@@ -111,11 +118,20 @@ func speedup():
|
|||||||
# The dialog line was printed, start the waiting time and then finish
|
# The dialog line was printed, start the waiting time and then finish
|
||||||
# the dialog
|
# the dialog
|
||||||
func _on_dialog_line_typed(object, key):
|
func _on_dialog_line_typed(object, key):
|
||||||
|
var time_to_disappear: float = _calculate_time_to_disappear()
|
||||||
text_node.visible_characters = -1
|
text_node.visible_characters = -1
|
||||||
$Timer.start(_max_time_to_text_disappear)
|
$Timer.start(time_to_disappear)
|
||||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||||
|
|
||||||
|
|
||||||
|
func _calculate_time_to_disappear() -> float:
|
||||||
|
return (_get_number_of_words() / _reading_speed_in_wpm as float) * 60
|
||||||
|
|
||||||
|
|
||||||
|
func _get_number_of_words() -> int:
|
||||||
|
return _word_regex.search_all(text_node.get_text()).size()
|
||||||
|
|
||||||
|
|
||||||
# Ending the dialog
|
# Ending the dialog
|
||||||
func _on_dialog_finished():
|
func _on_dialog_finished():
|
||||||
emit_signal("say_finished")
|
emit_signal("say_finished")
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ var _text_speed_per_character
|
|||||||
# The text speed per character if the dialog line is skipped
|
# The text speed per character if the dialog line is skipped
|
||||||
var _fast_text_speed_per_character
|
var _fast_text_speed_per_character
|
||||||
|
|
||||||
# The time to wait before the dialog is finished
|
# The reading speed to be used in determining the length of time text remains
|
||||||
var _max_time_to_text_disappear
|
# on the screen.
|
||||||
|
var _reading_speed_in_wpm: int
|
||||||
|
|
||||||
|
# Used to extract words from lines of text.
|
||||||
|
var _word_regex: RegEx = RegEx.new()
|
||||||
|
|
||||||
|
|
||||||
# Current character speaking, to keep track of reference for animation purposes
|
# Current character speaking, to keep track of reference for animation purposes
|
||||||
@@ -41,9 +45,12 @@ func _ready():
|
|||||||
_fast_text_speed_per_character = ProjectSettings.get_setting(
|
_fast_text_speed_per_character = ProjectSettings.get_setting(
|
||||||
"escoria/dialog_simple/fast_text_speed_per_character"
|
"escoria/dialog_simple/fast_text_speed_per_character"
|
||||||
)
|
)
|
||||||
_max_time_to_text_disappear = ProjectSettings.get_setting(
|
_reading_speed_in_wpm = ProjectSettings.get_setting(
|
||||||
"escoria/dialog_simple/max_time_to_disappear"
|
"escoria/dialog_simple/reading_speed_in_wpm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_word_regex.compile("\\S+")
|
||||||
|
|
||||||
bbcode_enabled = true
|
bbcode_enabled = true
|
||||||
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
|
$Tween.connect("tween_completed", self, "_on_dialog_line_typed")
|
||||||
|
|
||||||
@@ -134,11 +141,20 @@ func speedup():
|
|||||||
# The dialog line was printed, start the waiting time and then finish
|
# The dialog line was printed, start the waiting time and then finish
|
||||||
# the dialog
|
# the dialog
|
||||||
func _on_dialog_line_typed(object, key):
|
func _on_dialog_line_typed(object, key):
|
||||||
|
var time_to_disappear: float = _calculate_time_to_disappear()
|
||||||
text_node.visible_characters = -1
|
text_node.visible_characters = -1
|
||||||
$Timer.start(_max_time_to_text_disappear)
|
$Timer.start(time_to_disappear)
|
||||||
$Timer.connect("timeout", self, "_on_dialog_finished")
|
$Timer.connect("timeout", self, "_on_dialog_finished")
|
||||||
|
|
||||||
|
|
||||||
|
func _calculate_time_to_disappear() -> float:
|
||||||
|
return (_get_number_of_words() / _reading_speed_in_wpm as float) * 60
|
||||||
|
|
||||||
|
|
||||||
|
func _get_number_of_words() -> int:
|
||||||
|
return _word_regex.search_all(text_node.get_text()).size()
|
||||||
|
|
||||||
|
|
||||||
# Ending the dialog
|
# Ending the dialog
|
||||||
func _on_dialog_finished():
|
func _on_dialog_finished():
|
||||||
# Make the speaking item animation stop talking, if it is still alive
|
# Make the speaking item animation stop talking, if it is still alive
|
||||||
|
|||||||
@@ -24,27 +24,27 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/anim.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/anim.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraPushCommand",
|
"class": "CameraPushCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_push.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraSetLimitsCommand",
|
"class": "CameraSetLimitsCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_limits.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraSetPosCommand",
|
"class": "CameraSetPosCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_pos.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraSetTargetCommand",
|
"class": "CameraSetTargetCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_target.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraSetZoomCommand",
|
"class": "CameraSetZoomCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom.gd"
|
||||||
@@ -54,7 +54,7 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_set_zoom_height.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCCameraBaseCommand",
|
||||||
"class": "CameraShiftCommand",
|
"class": "CameraShiftCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/camera_shift.gd"
|
||||||
@@ -109,6 +109,11 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/scenes/camera_player/esc_camera.gd"
|
"path": "res://addons/escoria-core/game/scenes/camera_player/esc_camera.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "ESCBaseCommand",
|
||||||
|
"class": "ESCCameraBaseCommand",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://addons/escoria-core/game/core-scripts/esc/types/esc_camera_base_command.gd"
|
||||||
|
}, {
|
||||||
"base": "Reference",
|
"base": "Reference",
|
||||||
"class": "ESCCameraLimits",
|
"class": "ESCCameraLimits",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@@ -615,6 +620,7 @@ _global_script_class_icons={
|
|||||||
"ESCBackground": "res://addons/escoria-core/design/esc_background.svg",
|
"ESCBackground": "res://addons/escoria-core/design/esc_background.svg",
|
||||||
"ESCBaseCommand": "",
|
"ESCBaseCommand": "",
|
||||||
"ESCCamera": "",
|
"ESCCamera": "",
|
||||||
|
"ESCCameraBaseCommand": "",
|
||||||
"ESCCameraLimits": "",
|
"ESCCameraLimits": "",
|
||||||
"ESCCommand": "",
|
"ESCCommand": "",
|
||||||
"ESCCommandArgumentDescriptor": "",
|
"ESCCommandArgumentDescriptor": "",
|
||||||
@@ -745,7 +751,7 @@ search_in_file_extensions=PoolStringArray( "gd", "shader", "esc" )
|
|||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
enabled=PoolStringArray( "res://addons/escoria-core/plugin.cfg", "res://addons/escoria-dialog-simple/plugin.cfg", "res://addons/escoria-ui-9verbs/plugin.cfg", "res://addons/escoria-wizard/plugin.cfg", "res://addons/godot-plugin-refresher/plugin.cfg" )
|
enabled=PoolStringArray( "res://addons/escoria-core/plugin.cfg", "res://addons/escoria-dialog-simple/plugin.cfg", "res://addons/escoria-ui-9verbs/plugin.cfg", "res://addons/escoria-wizard/plugin.cfg" )
|
||||||
|
|
||||||
[escoria]
|
[escoria]
|
||||||
|
|
||||||
@@ -788,11 +794,11 @@ ui/tooltip_follows_mouse=false
|
|||||||
main/escoria_version=""
|
main/escoria_version=""
|
||||||
ui/dialogs_chooser="res://addons/escoria-core/ui_library/dialogs/text_dialog_chooser.tscn"
|
ui/dialogs_chooser="res://addons/escoria-core/ui_library/dialogs/text_dialog_chooser.tscn"
|
||||||
ui/default_dialog_scene="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.tscn"
|
ui/default_dialog_scene="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.tscn"
|
||||||
|
main/action_default_script="res://action_defaults.esc"
|
||||||
dialog_simple/avatars_path="res://game/dialog_avatars/"
|
dialog_simple/avatars_path="res://game/dialog_avatars/"
|
||||||
dialog_simple/text_speed_per_character=0.1
|
dialog_simple/text_speed_per_character=0.1
|
||||||
dialog_simple/fast_text_speed_per_character=0.25
|
dialog_simple/fast_text_speed_per_character=0.25
|
||||||
dialog_simple/max_time_to_disappear=1.0
|
dialog_simple/reading_speed_in_wpm=200
|
||||||
main/action_default_script="res://action_defaults.esc"
|
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user