From fe1c63c3bf7e322f335ce4628460007516436677 Mon Sep 17 00:00:00 2001 From: cmod31 Date: Tue, 7 Feb 2023 22:28:02 +0100 Subject: [PATCH] answerbox now updates correctly --- scenes/gui/dialog_bubble.tscn | 3 --- src/scene-scripts/dialogue-system/dialog_bubble.cs | 13 ++++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scenes/gui/dialog_bubble.tscn b/scenes/gui/dialog_bubble.tscn index 8dd853e..c619ff2 100644 --- a/scenes/gui/dialog_bubble.tscn +++ b/scenes/gui/dialog_bubble.tscn @@ -97,6 +97,3 @@ theme_override_constants/margin_left = 40 theme_override_constants/margin_top = 30 theme_override_constants/margin_right = 60 theme_override_constants/margin_bottom = 30 - -[node name="v_box_container" type="VBoxContainer" parent="box/panel_container/margin_container"] -layout_mode = 2 diff --git a/src/scene-scripts/dialogue-system/dialog_bubble.cs b/src/scene-scripts/dialogue-system/dialog_bubble.cs index 18ec166..7510746 100644 --- a/src/scene-scripts/dialogue-system/dialog_bubble.cs +++ b/src/scene-scripts/dialogue-system/dialog_bubble.cs @@ -43,7 +43,7 @@ public partial class dialog_bubble : CanvasLayer { if (Input.IsActionJustPressed("ui_cancel") && Visible) richText.VisibleCharacters = richText.Text.Length; - if (Input.IsActionJustPressed("ui_accept") && GetNode("box/panel_container").Visible == false && Visible + if (Input.IsActionJustPressed("ui_accept") && Visible && richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length <= richText.VisibleCharacters) { if (dlgPointer < dlgLines.AsGodotArray().Count) @@ -57,7 +57,6 @@ public partial class dialog_bubble : CanvasLayer else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary) { MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray()); - GetNode("box/panel_container").Visible = true; } } dlgPointer++; @@ -73,12 +72,16 @@ public partial class dialog_bubble : CanvasLayer } public void MakeAnswerBox(string[] dialogOptions) { - var parent = GetNode("box/panel_container/margin_container/v_box_container"); + var parent = GetNode("box/panel_container/margin_container"); + if (parent.GetChildCount() == 1) + parent.GetChild(0).Free(); + parent.AddChild(new VBoxContainer()); + parent = parent.GetChild(0); for (int i = 0; parent.GetChildCount() < dialogOptions.Length; i++) { parent.AddChild(GD.Load("res://scenes/gui/dlg_answer_button.tscn").Instantiate()); - } - for (int i = 0; i < dialogOptions.Length; i++) parent.GetChild