feat: adds additional options to dialog manager, including a left-click action option and a text skipping option

This commit is contained in:
Duncan Brown
2022-12-01 22:57:16 -05:00
committed by Julian Murgia
parent d955e2ef1b
commit d676e50284
9 changed files with 141 additions and 35 deletions

View File

@@ -90,12 +90,18 @@ func choose(dialog_player: Node, dialog: ESCDialog):
emit_signal("option_chosen", option)
# Trigger running the dialog faster
# Trigger running the dialogue faster
func speedup():
if _type_player != null:
_type_player.speedup()
# Trigger an instant finish of the current dialog
func finish():
if _type_player != null:
_type_player.finish()
# The say command has been interrupted, cancel the dialog display
func interrupt():
if _dialog_player.get_children().has(_type_player):

View File

@@ -1,6 +1,8 @@
# A simple dialog manager for Escoria
tool
extends EditorPlugin
class_name SimpleDialogPlugin
const MANAGER_CLASS="res://addons/escoria-dialog-simple/esc_dialog_simple.gd"
const SETTINGS_ROOT="escoria/dialog_simple"
@@ -8,9 +10,21 @@ const SETTINGS_ROOT="escoria/dialog_simple"
const AVATARS_PATH = "%s/avatars_path" % SETTINGS_ROOT
const TEXT_SPEED_PER_CHARACTER = "%s/text_speed_per_character" % SETTINGS_ROOT
const FAST_TEXT_SPEED_PER_CHARACTER = "%s/fast_text_speed_per_character" % SETTINGS_ROOT
const MAX_TIME_TO_DISAPPEAR = "%s/max_time_to_disappear" % SETTINGS_ROOT
const SKIP_DIALOGS = "%s/skip_dialogs" % SETTINGS_ROOT
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
const CLEAR_TEXT_BY_CLICK_ONLY = "%s/clear_text_by_click_only" % SETTINGS_ROOT
const LEFT_CLICK_ACTION = "%s/left_click_action" % SETTINGS_ROOT
const LEFT_CLICK_ACTION_SPEED_UP = "Speed up"
const LEFT_CLICK_ACTION_INSTANT_FINISH = "Instant finish"
const LEFT_CLICK_ACTION_NOTHING = "None"
var leftClickActions: Array = [
LEFT_CLICK_ACTION_SPEED_UP,
LEFT_CLICK_ACTION_INSTANT_FINISH,
LEFT_CLICK_ACTION_NOTHING
]
# Override function to return the plugin name.
func get_plugin_name():
@@ -36,12 +50,16 @@ func disable_plugin():
FAST_TEXT_SPEED_PER_CHARACTER
)
ESCProjectSettingsManager.remove_setting(
CLEAR_TEXT_BY_CLICK_ONLY
)
ESCProjectSettingsManager.remove_setting(
READING_SPEED_IN_WPM
)
ESCProjectSettingsManager.remove_setting(
MAX_TIME_TO_DISAPPEAR
LEFT_CLICK_ACTION
)
EscoriaPlugin.deregister_dialog_manager(MANAGER_CLASS)
@@ -85,6 +103,14 @@ func enable_plugin():
}
)
ESCProjectSettingsManager.register_setting(
CLEAR_TEXT_BY_CLICK_ONLY,
false,
{
"type": TYPE_BOOL
}
)
ESCProjectSettingsManager.register_setting(
READING_SPEED_IN_WPM,
200,
@@ -93,22 +119,18 @@ func enable_plugin():
}
)
var leftClickActionsString: String = ",".join(leftClickActions)
ESCProjectSettingsManager.register_setting(
MAX_TIME_TO_DISAPPEAR,
1.0,
LEFT_CLICK_ACTION,
"Speed up",
{
"type": TYPE_INT
"type": TYPE_STRING,
"hint": PROPERTY_HINT_ENUM,
"hint_string": leftClickActionsString
}
)
ESCProjectSettingsManager.register_setting(
SKIP_DIALOGS,
true,
{
"type": TYPE_BOOL
}
)
#escoria.settings_manager.custom_settings[SKIP_DIALOGS] = true
else:
get_editor_interface().set_plugin_enabled(
get_plugin_name(),

View File

@@ -44,13 +44,13 @@ onready var is_paused: bool = true
# Build up the UI
func _ready():
_text_speed_per_character = ProjectSettings.get_setting(
"escoria/dialog_simple/text_speed_per_character"
SimpleDialogPlugin.TEXT_SPEED_PER_CHARACTER
)
_fast_text_speed_per_character = ProjectSettings.get_setting(
"escoria/dialog_simple/fast_text_speed_per_character"
SimpleDialogPlugin.FAST_TEXT_SPEED_PER_CHARACTER
)
_reading_speed_in_wpm = ProjectSettings.get_setting(
"escoria/dialog_simple/reading_speed_in_wpm"
SimpleDialogPlugin.READING_SPEED_IN_WPM
)
_word_regex.compile("\\S+")
@@ -118,13 +118,24 @@ func speedup():
tween.start()
# Called by the dialog player when user wants to finish dialogue immediately.
func finish():
tween.remove_all()
tween.interpolate_property(text_node, "percent_visible",
text_node.percent_visible, 1.0, 0.0)
tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
var time_to_disappear: float = _calculate_time_to_disappear()
text_node.visible_characters = -1
$Timer.start(time_to_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
var time_to_disappear: float = _calculate_time_to_disappear()
$Timer.start(time_to_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
emit_signal("say_visible")

View File

@@ -43,13 +43,13 @@ onready var is_paused: bool = true
# Enable bbcode and catch the signal when a tween completed
func _ready():
_text_speed_per_character = ProjectSettings.get_setting(
"escoria/dialog_simple/text_speed_per_character"
SimpleDialogPlugin.TEXT_SPEED_PER_CHARACTER
)
_fast_text_speed_per_character = ProjectSettings.get_setting(
"escoria/dialog_simple/fast_text_speed_per_character"
SimpleDialogPlugin.FAST_TEXT_SPEED_PER_CHARACTER
)
_reading_speed_in_wpm = ProjectSettings.get_setting(
"escoria/dialog_simple/reading_speed_in_wpm"
SimpleDialogPlugin.READING_SPEED_IN_WPM
)
_word_regex.compile("\\S+")
@@ -132,7 +132,7 @@ func say(character: String, line: String) :
set_process(true)
# Called by the dialog player when user wants to finish dialog fast.
# Called by the dialog player when user wants to finish dialogue fast.
func speedup():
if not _is_speeding_up:
_is_speeding_up = true
@@ -143,13 +143,24 @@ func speedup():
tween.start()
# Called by the dialog player when user wants to finish dialogue immediately.
func finish():
tween.remove_all()
tween.interpolate_property(text_node, "percent_visible",
text_node.percent_visible, 1.0, 0.0)
tween.start()
# The dialog line was printed, start the waiting time and then finish
# the dialog
func _on_dialog_line_typed(object, key):
var time_to_disappear: float = _calculate_time_to_disappear()
text_node.visible_characters = -1
$Timer.start(time_to_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
if not ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.CLEAR_TEXT_BY_CLICK_ONLY):
var time_to_disappear: float = _calculate_time_to_disappear()
$Timer.start(time_to_disappear)
$Timer.connect("timeout", self, "_on_dialog_finished")
emit_signal("say_visible")