summaryrefslogtreecommitdiff
path: root/addons/escoria-dialog-simple/states/dialog_choices.gd
diff options
context:
space:
mode:
authorRadio <radiohotline@disroot.org>2026-06-04 15:15:11 +0300
committerRadio <radiohotline@disroot.org>2026-06-04 15:15:11 +0300
commit9d74b49ab62908d4acf53dde444413886b8b28e5 (patch)
tree0cb785267ea7e239b19d88684c0d64b9bd5d52f0 /addons/escoria-dialog-simple/states/dialog_choices.gd
parent2c85d452ad02a5f89cd43bad7f9de31d0e4fa0c1 (diff)
escoria setup and old branch archives
Diffstat (limited to 'addons/escoria-dialog-simple/states/dialog_choices.gd')
-rw-r--r--addons/escoria-dialog-simple/states/dialog_choices.gd44
1 files changed, 44 insertions, 0 deletions
diff --git a/addons/escoria-dialog-simple/states/dialog_choices.gd b/addons/escoria-dialog-simple/states/dialog_choices.gd
new file mode 100644
index 0000000..3779a6d
--- /dev/null
+++ b/addons/escoria-dialog-simple/states/dialog_choices.gd
@@ -0,0 +1,44 @@
+extends State
+
+
+# The owning dialog player.
+var _dialog_player
+
+# The dialog to start.
+var _dialog: ESCDialog
+var _type: String = "simple"
+
+var _dialog_chooser_ui: ESCDialogManager = null
+
+var _ready_to_choose: bool
+
+
+func initialize(dialog_player, dialog_chooser_ui: ESCDialogManager, dialog: ESCDialog, type: String) -> void:
+ _dialog_player = dialog_player
+ _dialog_chooser_ui = dialog_chooser_ui
+ _dialog = dialog
+ _type = type
+
+
+func enter():
+ escoria.logger.trace(self, "Dialog State Machine: Entered 'choices'.")
+
+ if _dialog.options.is_empty():
+ escoria.logger.error(
+ self,
+ "Received dialog options array was empty."
+ )
+
+ _ready_to_choose = true
+
+
+func update(_delta):
+ if _ready_to_choose:
+ _ready_to_choose = false
+ _dialog_chooser_ui.do_choose(_dialog_player, _dialog, _type)
+ var option = await _dialog_chooser_ui.option_chosen
+
+ escoria.logger.trace(self, "Dialog State Machine: 'choices' -> 'idle'")
+
+ finished.emit("idle")
+ _dialog_player.option_chosen.emit(option)