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
|
||||
|
||||
Reference in New Issue
Block a user