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)
|
group.statements = self._compile(group_lines)
|
||||||
returned.append(group)
|
returned.append(group)
|
||||||
elif dialog_regex.search(line):
|
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")
|
escoria.logger.trace("Line is a dialog")
|
||||||
var dialog_lines = []
|
var dialog_lines = []
|
||||||
while lines.size() > 0:
|
while lines.size() > 0:
|
||||||
@@ -187,7 +188,8 @@ func _compile(lines: Array) -> Array:
|
|||||||
lines.pop_front()
|
lines.pop_front()
|
||||||
returned.append(dialog)
|
returned.append(dialog)
|
||||||
elif dialog_option_regex.search(line):
|
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(
|
escoria.logger.trace(
|
||||||
"Line is the dialog option %s" % \
|
"Line is the dialog option %s" % \
|
||||||
dialog_option.option
|
dialog_option.option
|
||||||
|
|||||||
@@ -27,8 +27,11 @@ var timeout_option: int = 0
|
|||||||
var options: Array
|
var options: Array
|
||||||
|
|
||||||
|
|
||||||
# Construct a dialog from a dialog string
|
# Construct a dialog from an ESC dialog string
|
||||||
func _init(dialog_string: String):
|
#
|
||||||
|
# #### Parameters
|
||||||
|
# - dialog_string: ESC dialog string
|
||||||
|
func load_string(dialog_string: String):
|
||||||
var dialog_regex = RegEx.new()
|
var dialog_regex = RegEx.new()
|
||||||
dialog_regex.compile(REGEX)
|
dialog_regex.compile(REGEX)
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ var option: String setget ,get_option
|
|||||||
var conditions: Array = []
|
var conditions: Array = []
|
||||||
|
|
||||||
|
|
||||||
# Create a dialog option from a string
|
# Create a dialog option from an ESC string
|
||||||
func _init(option_string: String):
|
#
|
||||||
|
# #### Parameter
|
||||||
|
# - option_string: ESC string for the dialog option
|
||||||
|
func load_string(option_string: String):
|
||||||
var option_regex = RegEx.new()
|
var option_regex = RegEx.new()
|
||||||
option_regex.compile(REGEX)
|
option_regex.compile(REGEX)
|
||||||
|
|
||||||
|
|||||||
@@ -438,16 +438,22 @@ func turn_to(object: Node, wait: float = 0.0):
|
|||||||
|
|
||||||
# Play the talking animation
|
# Play the talking animation
|
||||||
func start_talking():
|
func start_talking():
|
||||||
if get_animation_player().is_playing():
|
if get_animation_player():
|
||||||
get_animation_player().stop()
|
if get_animation_player().is_playing():
|
||||||
get_animation_player().play(animations.speaks[_movable.last_dir].animation)
|
get_animation_player().stop()
|
||||||
|
get_animation_player().play(
|
||||||
|
animations.speaks[_movable.last_dir].animation
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Stop playing the talking animation
|
# Stop playing the talking animation
|
||||||
func stop_talking():
|
func stop_talking():
|
||||||
if get_animation_player().is_playing():
|
if get_animation_player():
|
||||||
get_animation_player().stop()
|
if get_animation_player().is_playing():
|
||||||
get_animation_player().play(animations.idles[_movable.last_dir].animation)
|
get_animation_player().stop()
|
||||||
|
get_animation_player().play(
|
||||||
|
animations.idles[_movable.last_dir].animation
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# Detect the child nodes and set respective references
|
# 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.
|
# Position the RichTextLabel on the character's dialog position, if any.
|
||||||
_current_character = escoria.object_manager.get_object(character).node
|
_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
|
# Set text color to color set in the actor
|
||||||
var text_color = _current_character.dialog_color
|
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 + "]" \
|
text_node.bbcode_text = "[center][color=#" + text_color_html + "]" \
|
||||||
.format([text_color_html]) + tr(line) + "[/color][center]"
|
.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
|
text_node.percent_visible = 0.0
|
||||||
var time_show_full_text = _text_speed_per_character * len(line)
|
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"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/enable_terrain.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "ESCBaseCommand",
|
"base": "ESCBaseCommand",
|
||||||
"class": "HideMenuCommand",
|
|
||||||
"language": "GDScript",
|
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/hide_menu.gd"
|
|
||||||
}, {
|
|
||||||
"base": "ESCBaseCommand",
|
|
||||||
"class": "IncGlobalCommand",
|
"class": "IncGlobalCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd"
|
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/inc_global.gd"
|
||||||
@@ -464,11 +459,6 @@ _global_script_classes=[ {
|
|||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://addons/escoria-core/game/core-scripts/esc/commands/set_state.gd"
|
"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",
|
"base": "SlideCommand",
|
||||||
"class": "SlideBlockCommand",
|
"class": "SlideBlockCommand",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
@@ -606,7 +596,6 @@ _global_script_class_icons={
|
|||||||
"ESCUtils": "",
|
"ESCUtils": "",
|
||||||
"ESCWalkContext": "",
|
"ESCWalkContext": "",
|
||||||
"EnableTerrainCommand": "",
|
"EnableTerrainCommand": "",
|
||||||
"HideMenuCommand": "",
|
|
||||||
"IncGlobalCommand": "",
|
"IncGlobalCommand": "",
|
||||||
"InventoryAddCommand": "",
|
"InventoryAddCommand": "",
|
||||||
"InventoryRemoveCommand": "",
|
"InventoryRemoveCommand": "",
|
||||||
@@ -626,7 +615,6 @@ _global_script_class_icons={
|
|||||||
"SetSoundStateCommand": "",
|
"SetSoundStateCommand": "",
|
||||||
"SetSpeedCommand": "",
|
"SetSpeedCommand": "",
|
||||||
"SetStateCommand": "",
|
"SetStateCommand": "",
|
||||||
"ShowMenuCommand": "",
|
|
||||||
"SlideBlockCommand": "",
|
"SlideBlockCommand": "",
|
||||||
"SlideCommand": "",
|
"SlideCommand": "",
|
||||||
"SpawnCommand": "",
|
"SpawnCommand": "",
|
||||||
@@ -683,7 +671,6 @@ debug/terminate_on_warnings=false
|
|||||||
debug/terminate_on_errors=true
|
debug/terminate_on_errors=true
|
||||||
debug/development_lang="en"
|
debug/development_lang="en"
|
||||||
ui/tooltip_follows_mouse=false
|
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/text_lang="fr_FR"
|
||||||
main/voice_lang="fr_FR"
|
main/voice_lang="fr_FR"
|
||||||
sound/music_volume=1
|
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 )
|
ui/inventory_item_size=Vector2( 72, 72 )
|
||||||
debug/enable_room_selector=true
|
debug/enable_room_selector=true
|
||||||
debug/room_selector_room_dir="res://game/rooms"
|
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/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/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
|
||||||
@@ -720,7 +707,7 @@ dialog_simple/max_time_to_disappear=1.0
|
|||||||
|
|
||||||
esc_show_debug_prompt={
|
esc_show_debug_prompt={
|
||||||
"deadzone": 0.5,
|
"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={
|
switch_action_verb={
|
||||||
|
|||||||
Reference in New Issue
Block a user