Makes ESCDialog and ESCDialogOption instantiable without an ESC string
and other dialog optimizations Co-authored-by: Dennis Ploeger <develop@dieploegers.de>
This commit is contained in:
@@ -160,7 +160,8 @@ func _compile(lines: Array) -> Array:
|
||||
group.statements = self._compile(group_lines)
|
||||
returned.append(group)
|
||||
elif dialog_regex.search(line):
|
||||
var dialog = ESCDialog.new(line)
|
||||
var dialog = ESCDialog.new()
|
||||
dialog.load_string(line)
|
||||
escoria.logger.trace("Line is a dialog")
|
||||
var dialog_lines = []
|
||||
while lines.size() > 0:
|
||||
@@ -187,7 +188,8 @@ func _compile(lines: Array) -> Array:
|
||||
lines.pop_front()
|
||||
returned.append(dialog)
|
||||
elif dialog_option_regex.search(line):
|
||||
var dialog_option = ESCDialogOption.new(line)
|
||||
var dialog_option = ESCDialogOption.new()
|
||||
dialog_option.load_string(line)
|
||||
escoria.logger.trace(
|
||||
"Line is the dialog option %s" % \
|
||||
dialog_option.option
|
||||
|
||||
@@ -27,8 +27,11 @@ var timeout_option: int = 0
|
||||
var options: Array
|
||||
|
||||
|
||||
# Construct a dialog from a dialog string
|
||||
func _init(dialog_string: String):
|
||||
# Construct a dialog from an ESC dialog string
|
||||
#
|
||||
# #### Parameters
|
||||
# - dialog_string: ESC dialog string
|
||||
func load_string(dialog_string: String):
|
||||
var dialog_regex = RegEx.new()
|
||||
dialog_regex.compile(REGEX)
|
||||
|
||||
|
||||
@@ -16,8 +16,11 @@ var option: String setget ,get_option
|
||||
var conditions: Array = []
|
||||
|
||||
|
||||
# Create a dialog option from a string
|
||||
func _init(option_string: String):
|
||||
# Create a dialog option from an ESC string
|
||||
#
|
||||
# #### Parameter
|
||||
# - option_string: ESC string for the dialog option
|
||||
func load_string(option_string: String):
|
||||
var option_regex = RegEx.new()
|
||||
option_regex.compile(REGEX)
|
||||
|
||||
|
||||
@@ -438,16 +438,22 @@ func turn_to(object: Node, wait: float = 0.0):
|
||||
|
||||
# Play the talking animation
|
||||
func start_talking():
|
||||
if get_animation_player().is_playing():
|
||||
get_animation_player().stop()
|
||||
get_animation_player().play(animations.speaks[_movable.last_dir].animation)
|
||||
if get_animation_player():
|
||||
if get_animation_player().is_playing():
|
||||
get_animation_player().stop()
|
||||
get_animation_player().play(
|
||||
animations.speaks[_movable.last_dir].animation
|
||||
)
|
||||
|
||||
|
||||
# Stop playing the talking animation
|
||||
func stop_talking():
|
||||
if get_animation_player().is_playing():
|
||||
get_animation_player().stop()
|
||||
get_animation_player().play(animations.idles[_movable.last_dir].animation)
|
||||
if get_animation_player():
|
||||
if get_animation_player().is_playing():
|
||||
get_animation_player().stop()
|
||||
get_animation_player().play(
|
||||
animations.idles[_movable.last_dir].animation
|
||||
)
|
||||
|
||||
|
||||
# Detect the child nodes and set respective references
|
||||
|
||||
@@ -64,12 +64,6 @@ func say(character: String, line: String) :
|
||||
|
||||
# Position the RichTextLabel on the character's dialog position, if any.
|
||||
_current_character = escoria.object_manager.get_object(character).node
|
||||
rect_position = _current_character.get_node("dialog_position") \
|
||||
.get_global_transform_with_canvas().origin
|
||||
rect_position.x -= rect_size.x / 2
|
||||
|
||||
# Start talking animation
|
||||
_current_character.start_talking()
|
||||
|
||||
# Set text color to color set in the actor
|
||||
var text_color = _current_character.dialog_color
|
||||
@@ -78,6 +72,18 @@ func say(character: String, line: String) :
|
||||
text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \
|
||||
.format([text_color_html]) + tr(line) + "[/color][center]"
|
||||
|
||||
if _current_character.is_inside_tree() and \
|
||||
_current_character.has_node("dialog_position"):
|
||||
rect_position = _current_character.get_node(
|
||||
"dialog_position"
|
||||
).get_global_transform_with_canvas().origin
|
||||
rect_position.x -= rect_size.x / 2
|
||||
else:
|
||||
rect_position.x = 0
|
||||
rect_size.x = ProjectSettings.get_setting("display/window/size/width")
|
||||
|
||||
_current_character.start_talking()
|
||||
|
||||
text_node.percent_visible = 0.0
|
||||
var time_show_full_text = _text_speed_per_character * len(line)
|
||||
|
||||
|
||||
@@ -365,11 +365,6 @@ _global_script_classes=[ {
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd"
|
||||
}, {
|
||||
"base": "ESCBaseCommand",
|
||||
"class": "HideMenuCommand",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd"
|
||||
}, {
|
||||
"base": "ESCBaseCommand",
|
||||
"class": "IncGlobalCommand",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd"
|
||||
@@ -464,11 +459,6 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd"
|
||||
}, {
|
||||
"base": "ESCBaseCommand",
|
||||
"class": "ShowMenuCommand",
|
||||
"language": "GDScript",
|
||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/show_menu.gd"
|
||||
}, {
|
||||
"base": "SlideCommand",
|
||||
"class": "SlideBlockCommand",
|
||||
"language": "GDScript",
|
||||
@@ -606,7 +596,6 @@ _global_script_class_icons={
|
||||
"ESCUtils": "",
|
||||
"ESCWalkContext": "",
|
||||
"EnableTerrainCommand": "",
|
||||
"HideMenuCommand": "",
|
||||
"IncGlobalCommand": "",
|
||||
"InventoryAddCommand": "",
|
||||
"InventoryRemoveCommand": "",
|
||||
@@ -626,7 +615,6 @@ _global_script_class_icons={
|
||||
"SetSoundStateCommand": "",
|
||||
"SetSpeedCommand": "",
|
||||
"SetStateCommand": "",
|
||||
"ShowMenuCommand": "",
|
||||
"SlideBlockCommand": "",
|
||||
"SlideCommand": "",
|
||||
"SpawnCommand": "",
|
||||
@@ -683,7 +671,6 @@ debug/terminate_on_warnings=false
|
||||
debug/terminate_on_errors=true
|
||||
debug/development_lang="en"
|
||||
ui/tooltip_follows_mouse=false
|
||||
ui/default_dialog_scene="res://addons/escoria-core/ui_library/dialogs/floating_dialog_player.tscn"
|
||||
main/text_lang="fr_FR"
|
||||
main/voice_lang="fr_FR"
|
||||
sound/music_volume=1
|
||||
@@ -709,8 +696,8 @@ ui/transition_paths=[ "res://addons/escoria-core/game/scenes/transitions/shaders
|
||||
ui/inventory_item_size=Vector2( 72, 72 )
|
||||
debug/enable_room_selector=true
|
||||
debug/room_selector_room_dir="res://game/rooms"
|
||||
ui/default_dialog_type="floating"
|
||||
ui/dialog_managers=[ "res://addons/escoria-dialog-simple/esc_dialog_simple.gd" ]
|
||||
ui/default_dialog_type="avatar"
|
||||
dialog_simple/avatars_path="res://game/dialog_avatars"
|
||||
dialog_simple/text_speed_per_character=0.1
|
||||
dialog_simple/fast_text_speed_per_character=0.25
|
||||
@@ -720,7 +707,7 @@ dialog_simple/max_time_to_disappear=1.0
|
||||
|
||||
esc_show_debug_prompt={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777245,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
switch_action_verb={
|
||||
|
||||
Reference in New Issue
Block a user