From 08ae1a42c694ec409921225daa59ab42fac75d58 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 9 Aug 2020 16:29:26 +0300 Subject: Allow options in dialogue --- scripts/Game.gd | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'scripts/Game.gd') diff --git a/scripts/Game.gd b/scripts/Game.gd index 25edde0..d5f3bb5 100644 --- a/scripts/Game.gd +++ b/scripts/Game.gd @@ -52,20 +52,24 @@ func change_level(num: int): func _on_PlayerCharacter_initiate_dialogue(other: Node): in_dialogue_with = other - var dialogues = other.get_dialogue() + var dialogues: Dictionary = other.get_dialogue() $CanvasLayer/GUI/BottomRow/DialogueBox.set_visible(true) emit_signal("dialogue_begin") - for i in range(dialogues.size()): - var d = dialogues[i] + var id = "1" + while id != null: + var d: Dictionary = dialogues[String(id)] var name = d["name"] var body = d["body"] - $CanvasLayer/GUI/BottomRow/DialogueBox/Name.set_text(name) - $CanvasLayer/GUI/BottomRow/DialogueBox/Text.set_text(body) - print("[%s] %s" % [name, body]) - yield($CanvasLayer/GUI, "dialogue_next") + var options = d.get("options", [[">>", null]]) + $CanvasLayer/GUI/BottomRow/DialogueBox.set_dialogue(name, body, options) + print("[%s] \"%s\"" % [name, body]) + var next_target = yield($CanvasLayer/GUI, "dialogue_next") + id = next_target emit_signal("dialogue_next") in_dialogue_with = null $CanvasLayer/GUI/BottomRow/DialogueBox.set_visible(false) + $CanvasLayer/GUI/BottomRow/DialogueBox.free_buttons() emit_signal("dialogue_end") + -- cgit v1.3