fix(rtmi-dialog-simple): say command was blocking game state
This commit is contained in:
@@ -6,10 +6,6 @@ extends EditorPlugin
|
|||||||
const MANAGER_CLASS="res://addons/escoria-ui-return-monkey-island-dialog-simple/rtmi_dialog_simple.gd"
|
const MANAGER_CLASS="res://addons/escoria-ui-return-monkey-island-dialog-simple/rtmi_dialog_simple.gd"
|
||||||
const SETTINGS_ROOT="escoria/rtmi_dialog_simple"
|
const SETTINGS_ROOT="escoria/rtmi_dialog_simple"
|
||||||
|
|
||||||
const READING_SPEED_IN_WPM_DEFAULT_VALUE = 200
|
|
||||||
const TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE = 100
|
|
||||||
const TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE = 25
|
|
||||||
|
|
||||||
var left_click_actions: PackedStringArray = [
|
var left_click_actions: PackedStringArray = [
|
||||||
RTMISimpleDialogSettings.LEFT_CLICK_ACTION_SPEED_UP,
|
RTMISimpleDialogSettings.LEFT_CLICK_ACTION_SPEED_UP,
|
||||||
RTMISimpleDialogSettings.LEFT_CLICK_ACTION_INSTANT_FINISH,
|
RTMISimpleDialogSettings.LEFT_CLICK_ACTION_INSTANT_FINISH,
|
||||||
@@ -87,7 +83,7 @@ func _enable_plugin():
|
|||||||
|
|
||||||
ESCProjectSettingsManager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
|
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS,
|
||||||
TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE,
|
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE,
|
||||||
{
|
{
|
||||||
"type": TYPE_FLOAT
|
"type": TYPE_FLOAT
|
||||||
}
|
}
|
||||||
@@ -95,7 +91,7 @@ func _enable_plugin():
|
|||||||
|
|
||||||
ESCProjectSettingsManager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
|
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST,
|
||||||
TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE,
|
RTMISimpleDialogSettings.TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE,
|
||||||
{
|
{
|
||||||
"type": TYPE_FLOAT
|
"type": TYPE_FLOAT
|
||||||
}
|
}
|
||||||
@@ -111,7 +107,7 @@ func _enable_plugin():
|
|||||||
|
|
||||||
ESCProjectSettingsManager.register_setting(
|
ESCProjectSettingsManager.register_setting(
|
||||||
RTMISimpleDialogSettings.READING_SPEED_IN_WPM,
|
RTMISimpleDialogSettings.READING_SPEED_IN_WPM,
|
||||||
READING_SPEED_IN_WPM_DEFAULT_VALUE,
|
RTMISimpleDialogSettings.READING_SPEED_IN_WPM_DEFAULT_VALUE,
|
||||||
{
|
{
|
||||||
"type": TYPE_INT
|
"type": TYPE_INT
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,26 @@ func has_type(type: String) -> bool:
|
|||||||
return true if type in ["floating"] else false
|
return true if type in ["floating"] else false
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether a specific chooser type is supported by the
|
||||||
|
# dialog plugin
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - type: required chooser type
|
||||||
|
# *Returns* Whether the type is supported or not
|
||||||
|
func has_chooser_type(type: String) -> bool:
|
||||||
|
return true if type == "simple" else false
|
||||||
|
|
||||||
|
|
||||||
|
# Instructs the dialog manager to preserve the next dialog box used by a `say`
|
||||||
|
# command until a call to `disable_preserve_dialog_box` is made.
|
||||||
|
#
|
||||||
|
# This method should be idempotent, i.e. if called after the first time and
|
||||||
|
# prior to `disable_preserve_dialog_box` being called, the result should be the
|
||||||
|
# same.
|
||||||
|
func enable_preserve_dialog_box() -> void:
|
||||||
|
_should_preserve_dialog_box = true
|
||||||
|
|
||||||
|
|
||||||
# Instructs the dialog manager to no longer preserve the currently-preserved
|
# Instructs the dialog manager to no longer preserve the currently-preserved
|
||||||
# dialog box or to not preserve the next dialog box used by a `say` command
|
# dialog box or to not preserve the next dialog box used by a `say` command
|
||||||
# (this is the default state).
|
# (this is the default state).
|
||||||
@@ -52,7 +72,38 @@ func disable_preserve_dialog_box() -> void:
|
|||||||
if is_instance_valid(_dialog_player) and _dialog_player.get_children().has(_type_player):
|
if is_instance_valid(_dialog_player) and _dialog_player.get_children().has(_type_player):
|
||||||
_dialog_player.remove_child(_type_player)
|
_dialog_player.remove_child(_type_player)
|
||||||
_preserved_type_player_type = ""
|
_preserved_type_player_type = ""
|
||||||
_dialog_player.remove_child(_dialog_tip)
|
|
||||||
|
|
||||||
|
# Output a text said by the item specified by the global id. Emit
|
||||||
|
# `say_finished` after finishing displaying the text.
|
||||||
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - dialog_player: Node of the dialog player in the UI
|
||||||
|
# - global_id: Global id of the item that is speaking
|
||||||
|
# - text: Text to say, optional prefixed by a translation key separated
|
||||||
|
# by a ":"
|
||||||
|
# - type: Type of dialog box to use
|
||||||
|
# - *key*: Translation key
|
||||||
|
func say(dialog_player: Node, global_id: String, text: String, type: String, key: String):
|
||||||
|
_dialog_player = dialog_player
|
||||||
|
|
||||||
|
_initialize_say_states(global_id, text, type, key)
|
||||||
|
|
||||||
|
if _should_preserve_dialog_box:
|
||||||
|
# If the dialog box type doesn't match what's currently being reused (if anything),
|
||||||
|
# we want to remove the old one (if it exists) and then initialize and add the new dialog
|
||||||
|
# box type to the dialog player
|
||||||
|
if type != _preserved_type_player_type:
|
||||||
|
if _dialog_player.get_children().has(_type_player):
|
||||||
|
_dialog_player.remove_child(_type_player)
|
||||||
|
|
||||||
|
_init_type_player(type)
|
||||||
|
|
||||||
|
_preserved_type_player_type = type
|
||||||
|
else:
|
||||||
|
_init_type_player(type)
|
||||||
|
|
||||||
|
state_machine._change_state("say")
|
||||||
|
|
||||||
|
|
||||||
func do_say(global_id: String, text: String) -> void:
|
func do_say(global_id: String, text: String) -> void:
|
||||||
@@ -83,6 +134,15 @@ func _init_type_player(type: String) -> void:
|
|||||||
_type_player.say_visible.connect(_on_say_visible)
|
_type_player.say_visible.connect(_on_say_visible)
|
||||||
|
|
||||||
|
|
||||||
|
func _initialize_say_states(global_id: String, text: String, type: String, key: String) -> void:
|
||||||
|
state_machine.states_map["say"].initialize(self, global_id, text, type, key)
|
||||||
|
state_machine.states_map["finish"].initialize(_dialog_player)
|
||||||
|
state_machine.states_map["say_fast"].initialize(self)
|
||||||
|
state_machine.states_map["say_finish"].initialize(self)
|
||||||
|
state_machine.states_map["visible"].initialize(self)
|
||||||
|
state_machine.states_map["interrupt"].initialize(self)
|
||||||
|
|
||||||
|
|
||||||
func _on_say_finished():
|
func _on_say_finished():
|
||||||
if not _should_preserve_dialog_box and _dialog_player.get_children().has(_type_player):
|
if not _should_preserve_dialog_box and _dialog_player.get_children().has(_type_player):
|
||||||
_dialog_player.remove_child(_type_player)
|
_dialog_player.remove_child(_type_player)
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ const SETTINGS_ROOT = "escoria/rtmi_dialog_simple"
|
|||||||
|
|
||||||
const AVATARS_PATH = "%s/avatars_path" % SETTINGS_ROOT
|
const AVATARS_PATH = "%s/avatars_path" % SETTINGS_ROOT
|
||||||
const TEXT_TIME_PER_LETTER_MS = "%s/text_time_per_letter_ms" % SETTINGS_ROOT
|
const TEXT_TIME_PER_LETTER_MS = "%s/text_time_per_letter_ms" % SETTINGS_ROOT
|
||||||
|
const TEXT_TIME_PER_LETTER_MS_DEFAULT_VALUE = 100
|
||||||
const TEXT_TIME_PER_LETTER_MS_FAST = "%s/text_time_per_fast_letter_ms" % SETTINGS_ROOT
|
const TEXT_TIME_PER_LETTER_MS_FAST = "%s/text_time_per_fast_letter_ms" % SETTINGS_ROOT
|
||||||
|
const TEXT_TIME_PER_LETTER_MS_FAST_DEFAULT_VALUE = 25
|
||||||
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
|
const READING_SPEED_IN_WPM = "%s/reading_speed_in_wpm" % SETTINGS_ROOT
|
||||||
|
const READING_SPEED_IN_WPM_DEFAULT_VALUE = 200
|
||||||
const CLEAR_TEXT_BY_CLICK_ONLY = "%s/clear_text_by_click_only" % 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 = "%s/left_click_action" % SETTINGS_ROOT
|
||||||
|
|
||||||
|
|||||||
@@ -272,7 +272,8 @@ func element_focused(element_id: String) -> void:
|
|||||||
if is_instance_valid(last_target):
|
if is_instance_valid(last_target):
|
||||||
last_target.get_component('outline').highlight(false)
|
last_target.get_component('outline').highlight(false)
|
||||||
|
|
||||||
if(escoria.action_manager.has_actions(target_obj)):
|
if escoria.action_manager.has_actions(target_obj):
|
||||||
|
if target_obj is ESCItemWithTooltip:
|
||||||
target_obj.get_component('outline').highlight(true)
|
target_obj.get_component('outline').highlight(true)
|
||||||
last_target = target_obj
|
last_target = target_obj
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ var texture: Texture2D = null
|
|||||||
func _init(p_item: ESCItem) -> void:
|
func _init(p_item: ESCItem) -> void:
|
||||||
global_id = p_item.global_id
|
global_id = p_item.global_id
|
||||||
texture = p_item._get_inventory_texture()
|
texture = p_item._get_inventory_texture()
|
||||||
|
if p_item is ESCItemWithTooltip:
|
||||||
p_item.register_components()
|
p_item.register_components()
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
:action2
|
:action2
|
||||||
say($player, "Cartón pa la saca!", "TODO_I18N")
|
say($player, "Cartón pa la saca!", "TODO_I18N")
|
||||||
set_active(turno_cocina_carton, false)
|
set_active($turno_cocina_carton, false)
|
||||||
inventory_add(turno_cocina_carton)
|
inventory_add($turno_cocina_carton)
|
||||||
|
|
||||||
:action3
|
:action3
|
||||||
say($player, "Es una caja de cartón vacía.", "TODO_I18N")
|
say($player, "Es una caja de cartón vacía.", "TODO_I18N")
|
||||||
|
|||||||
Reference in New Issue
Block a user