diff --git a/scenes/gui/dialog_bubble.tscn b/scenes/gui/dialog_bubble.tscn index be9775e..17f455c 100644 --- a/scenes/gui/dialog_bubble.tscn +++ b/scenes/gui/dialog_bubble.tscn @@ -1,17 +1,18 @@ [gd_scene load_steps=4 format=3 uid="uid://bkm7365u1mm3o"] -[ext_resource type="Script" path="res://src/scene-scripts/dialogue-system/dialog_bubble.cs" id="1_5xn2c"] +[ext_resource type="Script" path="res://src/scene-scripts/dialogue-system/dialog_bubble.cs" id="1_xtj1q"] [ext_resource type="FontFile" uid="uid://cx6bvqk0ghmjv" path="res://assets/fonts/urbane-rounded-medium.otf" id="2_qrihj"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5w2xu"] [node name="dialog_bubble" type="CanvasLayer"] -script = ExtResource("1_5xn2c") +script = ExtResource("1_xtj1q") metadata/_edit_use_anchors_ = true [node name="typewriter_timer" type="Timer" parent="."] wait_time = 0.05 one_shot = true +metadata/charsAtOnce = 60 [node name="box" type="ColorRect" parent="."] anchors_preset = -1 diff --git a/src/scene-scripts/dialogue-system/dialog_bubble.cs b/src/scene-scripts/dialogue-system/dialog_bubble.cs index 176881b..3b00a59 100644 --- a/src/scene-scripts/dialogue-system/dialog_bubble.cs +++ b/src/scene-scripts/dialogue-system/dialog_bubble.cs @@ -1,6 +1,7 @@ using Godot; -using System.Collections; using System; +using System.Collections; +using System.Text.RegularExpressions; public partial class dialog_bubble : CanvasLayer { @@ -12,8 +13,8 @@ public partial class dialog_bubble : CanvasLayer public override void _Ready() { richText = GetNode("box/rich_text_label"); - dlgLines.Add("Hello! I'm a debug character and..."); - dlgLines.Add("[center][b][wave amp=50 freq=15][rainbow]This is cool test text"); //bbcode gets counted to so typewrite effect takes decades //make a seperate variable without bbcode and count that instead + dlgLines.Add("Hello! I'm a [color=purple]debug character[/color] and..."); + dlgLines.Add("[center][b][wave amp=50 freq=15][rainbow]This is cool test text[/rainbow][/wave][/b][/center]"); //bbcode gets counted to so typewrite effect takes decades //make a seperate variable without bbcode and count that instead } public void GetDialog(string file, string title, Variant actor) { @@ -34,12 +35,12 @@ public partial class dialog_bubble : CanvasLayer } public override void _Process(double delta) { - if (richText.VisibleCharacters < richText.Text.Length && GetNode("typewriter_timer").IsStopped()) + if (richText.VisibleCharacters < Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length && GetNode("typewriter_timer").IsStopped()) { richText.VisibleCharacters++; GetNode("typewriter_timer").Start(); } - if (Input.IsActionJustPressed("ui_accept") && richText.VisibleCharacters == -1 | richText.Text.Length == richText.VisibleCharacters) + if (Input.IsActionJustPressed("ui_accept") && Visible == true && richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length == richText.VisibleCharacters) { if (dlgPointer < dlgLines.Count && dlgLines[dlgPointer] is string) {