feat: adds additional options to dialog manager, including a left-click action option and a text skipping option
This commit is contained in:
committed by
Julian Murgia
parent
d955e2ef1b
commit
d676e50284
@@ -56,11 +56,16 @@ func choose(dialog_player: Node, dialog: ESCDialog):
|
||||
pass
|
||||
|
||||
|
||||
# Trigger running the dialog faster
|
||||
# Trigger running the dialogue faster
|
||||
func speedup():
|
||||
pass
|
||||
|
||||
|
||||
# Trigger an instant finish of the current dialog
|
||||
func finish():
|
||||
pass
|
||||
|
||||
|
||||
# The say command has been interrupted, cancel the dialog display
|
||||
func interrupt():
|
||||
pass
|
||||
|
||||
@@ -42,6 +42,7 @@ func _create_states() -> void:
|
||||
"idle": DialogIdle.new(),
|
||||
"say": DialogSay.new(),
|
||||
"say_fast": DialogSayFast.new(),
|
||||
"say_finish": DialogSayFinish.new(),
|
||||
"visible": DialogVisible.new(),
|
||||
"finish": DialogFinish.new(),
|
||||
"interrupt": DialogInterrupt.new(),
|
||||
@@ -70,11 +71,16 @@ func say(character: String, type: String, text: String) -> void:
|
||||
_change_state("say")
|
||||
|
||||
|
||||
# Called when a dialog line is to be sped up.
|
||||
# Called when a dialogue line is to be sped up.
|
||||
func speedup() -> void:
|
||||
_change_state("say_fast")
|
||||
|
||||
|
||||
# Called when a dialogue line is to be finished immediately.
|
||||
func finish() -> void:
|
||||
_change_state("say_finish")
|
||||
|
||||
|
||||
# Display a list of choices
|
||||
#
|
||||
# #### Parameters
|
||||
@@ -96,5 +102,6 @@ func interrupt() -> void:
|
||||
func _on_dialog_manager_set(dialog_manager: ESCDialogManager) -> void:
|
||||
_dialog_manager = dialog_manager
|
||||
states_map["say_fast"].initialize(dialog_manager)
|
||||
states_map["say_finish"].initialize(dialog_manager)
|
||||
states_map["visible"].initialize(dialog_manager)
|
||||
states_map["interrupt"].initialize(dialog_manager)
|
||||
|
||||
@@ -13,10 +13,10 @@ func initialize(dialog_manager: ESCDialogManager) -> void:
|
||||
func enter():
|
||||
escoria.logger.trace(self, "Dialog State Machine: Entered 'interrupt'.")
|
||||
|
||||
if not _dialog_manager.is_connected("say_finished", self, "_on_say_finished"):
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
|
||||
if _dialog_manager != null:
|
||||
if not _dialog_manager.is_connected("say_finished", self, "_on_say_finished"):
|
||||
_dialog_manager.connect("say_finished", self, "_on_say_finished", [], CONNECT_ONESHOT)
|
||||
|
||||
_dialog_manager.interrupt()
|
||||
|
||||
|
||||
|
||||
@@ -44,13 +44,27 @@ func handle_input(_event):
|
||||
escoria.inputs_manager.INPUT_NONE and \
|
||||
_dialog_manager != null:
|
||||
|
||||
var left_click_action = ESCProjectSettingsManager.get_setting(SimpleDialogPlugin.LEFT_CLICK_ACTION)
|
||||
|
||||
_handle_left_click_action(left_click_action)
|
||||
|
||||
|
||||
func _handle_left_click_action(left_click_action: String) -> void:
|
||||
match left_click_action:
|
||||
SimpleDialogPlugin.LEFT_CLICK_ACTION_SPEED_UP:
|
||||
if _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.disconnect("say_visible", self, "_on_say_visible")
|
||||
|
||||
escoria.logger.trace(self, "Dialog State Machine: 'say' -> 'say_fast'")
|
||||
|
||||
emit_signal("finished", "say_fast")
|
||||
get_tree().set_input_as_handled()
|
||||
SimpleDialogPlugin.LEFT_CLICK_ACTION_INSTANT_FINISH:
|
||||
if _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.disconnect("say_visible", self, "_on_say_visible")
|
||||
|
||||
escoria.logger.trace(self, "Dialog State Machine: 'say' -> 'say_finish'")
|
||||
emit_signal("finished", "say_finish")
|
||||
|
||||
get_tree().set_input_as_handled()
|
||||
|
||||
|
||||
func enter():
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
extends State
|
||||
class_name DialogSayFinish
|
||||
|
||||
|
||||
# Reference to the currently playing dialog manager
|
||||
var _dialog_manager: ESCDialogManager = null
|
||||
|
||||
|
||||
func initialize(dialog_manager: ESCDialogManager) -> void:
|
||||
_dialog_manager = dialog_manager
|
||||
|
||||
|
||||
func enter():
|
||||
escoria.logger.trace(self, "Dialog State Machine: Entered 'say_finish'.")
|
||||
|
||||
if escoria.inputs_manager.input_mode != \
|
||||
escoria.inputs_manager.INPUT_NONE and \
|
||||
_dialog_manager != null:
|
||||
|
||||
if not _dialog_manager.is_connected("say_visible", self, "_on_say_visible"):
|
||||
_dialog_manager.connect("say_visible", self, "_on_say_visible", [], CONNECT_ONESHOT)
|
||||
|
||||
_dialog_manager.finish()
|
||||
else:
|
||||
escoria.logger.error(self, "Illegal state.")
|
||||
|
||||
|
||||
func _on_say_visible() -> void:
|
||||
escoria.logger.trace(self, "Dialog State Machine: 'say_finish' -> 'visible'")
|
||||
emit_signal("finished", "visible")
|
||||
Reference in New Issue
Block a user