fix: returns an appropriate RC code when no more options are left at a particular dialog level; this has the somewhat beneficial side effect of moving up a level in dialog if there is one, although this requires a 'stop' command to be present in at least one of the top-most dialog options.
This commit is contained in:
committed by
Julian Murgia
parent
9b27bc4b24
commit
328e5efdd9
@@ -90,9 +90,17 @@ func run():
|
|||||||
escoria.dialog_player,
|
escoria.dialog_player,
|
||||||
"option_chosen"
|
"option_chosen"
|
||||||
) as ESCDialogOption
|
) as ESCDialogOption
|
||||||
var rc = option.run()
|
|
||||||
|
var rc = ESCExecution.RC_OK
|
||||||
|
|
||||||
|
# If no valid option was returned, it means this level of dialog is done.
|
||||||
|
# If this is the case and the current level of dialog has a parent, it means
|
||||||
|
# it is still yielding and so will be shown again.
|
||||||
|
if option:
|
||||||
|
rc = option.run()
|
||||||
if rc is GDScriptFunctionState:
|
if rc is GDScriptFunctionState:
|
||||||
rc = yield(rc, "completed")
|
rc = yield(rc, "completed")
|
||||||
if rc != ESCExecution.RC_CANCEL:
|
if rc != ESCExecution.RC_CANCEL:
|
||||||
return self.run()
|
return self.run()
|
||||||
|
|
||||||
return rc
|
return rc
|
||||||
|
|||||||
@@ -2,10 +2,14 @@
|
|||||||
# Supports timeout and avatar display
|
# Supports timeout and avatar display
|
||||||
extends ESCDialogOptionsChooser
|
extends ESCDialogOptionsChooser
|
||||||
|
|
||||||
|
|
||||||
export(Color, RGB) var color_normal = Color(1.0,1.0,1.0,1.0)
|
export(Color, RGB) var color_normal = Color(1.0,1.0,1.0,1.0)
|
||||||
export(Color, RGB) var color_hover = Color(165.0,42.0,42.0, 1.0)
|
export(Color, RGB) var color_hover = Color(165.0,42.0,42.0, 1.0)
|
||||||
|
|
||||||
|
|
||||||
|
var _no_more_options: bool = false
|
||||||
|
|
||||||
|
|
||||||
# Hide the chooser at the start just to be safe
|
# Hide the chooser at the start just to be safe
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
hide_chooser()
|
hide_chooser()
|
||||||
@@ -40,6 +44,15 @@ func show_chooser():
|
|||||||
option
|
option
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# If we've no options left, signify as much and start the timer with a
|
||||||
|
# very short interval so the appropriate signal can be fired. Note that
|
||||||
|
# we have to fire the signal AFTER this method returns as the caller
|
||||||
|
# is almost certainly yielding after this method returns.
|
||||||
|
if _vbox.get_child_count() == 0:
|
||||||
|
_no_more_options = true
|
||||||
|
$Timer.start(0.05)
|
||||||
|
return
|
||||||
|
|
||||||
if self.dialog.avatar != "-":
|
if self.dialog.avatar != "-":
|
||||||
$AvatarContainer.add_child(
|
$AvatarContainer.add_child(
|
||||||
ResourceLoader.load(self.dialog.avatar).instance()
|
ResourceLoader.load(self.dialog.avatar).instance()
|
||||||
@@ -76,7 +89,9 @@ func _on_answer_selected(option: ESCDialogOption):
|
|||||||
|
|
||||||
# The timeout came and a option was selected
|
# The timeout came and a option was selected
|
||||||
func _on_Timer_timeout() -> void:
|
func _on_Timer_timeout() -> void:
|
||||||
_option_chosen(self.dialog.options[self.dialog.timeout_option - 1])
|
var option_chosen = null if _no_more_options else self.dialog.options[self.dialog.timeout_option - 1]
|
||||||
|
_no_more_options = false
|
||||||
|
_option_chosen(option_chosen)
|
||||||
|
|
||||||
|
|
||||||
# Remove the avatar
|
# Remove the avatar
|
||||||
|
|||||||
Reference in New Issue
Block a user