PopochiuDialog - carenalgas/popochiu GitHub Wiki

Description
Inherits Resource.
Branching dialogs that show options for players to select and trigger actions.
Properties
Constants
- PopochiuDialogOption Resource. Default
preload('PopochiuDialogOption.gd'). Used to cast variables as PopochiuDialogOption.
Export
- options Array. Default
[]. Array of PopochiuDialogOption. This are the options that are shown on screen when the dialog is running. - script_name String. Default
''. The identifier of the dialog used in scripts.
Methods
Virtual
🍑 For a detailed and exemplified description of all the virtual methods of this class, go to the Your scripts > Dialog page.
-
on_start() void
Use it to define custom behaviors before the dialog starts. ⚠️ You have to use a yield in this method in order to make the dialog to work properly.
-
option_selected( PopochiuDialogOption
opt) voidCalled when a dialog option is clicked. The
idproperty inoptcan be used to check which was the option selected.
Public
-
get_option( String
opt_id) PopochiuDialogOptionReturns the PopochiuDialogOption which
idis equal toopt_id. -
start() void
Starts this dialog by calling
show_dialogin IDialog passing as argument its ownscript_name. -
stop() void
Finishes the dialog (which makes the menu with the options to disappear) by triggering the
dialog_finishedsignal from IDialog. -
turn_off_options( Array
ids) voidDisables each PopochiuDialogOption which
idproperty matches each of the values in theidsarray. -
turn_off_forever_options( Array
ids) voidDisables forever each PopochiuDialogOption which
idproperty matches each of the values in theidsarray. This means that each of those options cannot be enabled by code again. -
turn_on_options( Array
ids) voidEnables each PopochiuDialogOption which
idproperty matches each of the values in theidsarray.
Set and get
-
set_options( Array
value) voidCreates a PopochiuDialogOption each time an element is added to
optionsusing Godot´s Inspector.
Private
-
_on_option_selected( PopochiuDialogOption
opt) voidThis makes an option to be selected when clicked. It marks
optasusedand adds 1 to itsused_timesproperty, then makesoptto be the value of theselected_optionproperty in IDialog, and finally sendsopttooption_selected(). -
_show_options() void
Emits the signal that will make this dialog options to appear on screen and connects to the
option_selectedsignal on each of those PopochiuDialogOption. -
_start() void
Starts the dialog by showing the list of options in a menu that is rendered on the bottom of the screen. Then it yields until the
dialog_finishedsignal from IDialog is triggered.