more weird dialogue code

This commit is contained in:
2023-02-05 10:56:31 +01:00
parent 271084a94d
commit cec3a13a66
4 changed files with 131 additions and 127 deletions

View File

@@ -66,6 +66,7 @@ theme_override_font_sizes/font_size = 36
text = "???"
[node name="panel_container" type="PanelContainer" parent="box"]
visible = false
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0

View File

@@ -8,4 +8,4 @@
[node name="first_world" parent="." instance=ExtResource("2_x8nyb")]
[node name="player" parent="." instance=ExtResource("1_p5d84")]
playerName = "[rainbow]Yannik[/rainbow]"
playerName = "Yannik"

View File

@@ -9,7 +9,7 @@ public partial class dialog_bubble : CanvasLayer
public ArrayList dlgLines = new ArrayList();
public int dlgPointer = 0;
public RichTextLabel richText;
public int dialogOptionsLength;
public int dialogOptionsLength = 1;
public override void _Ready()
{
@@ -51,7 +51,7 @@ public partial class dialog_bubble : CanvasLayer
GetNode<Timer>("typewriter_timer").Start();
}
if (Input.IsActionJustPressed("ui_cancel") && Visible) richText.VisibleCharacters = richText.Text.Length;
if (Input.IsActionJustPressed("ui_accept") && Visible && richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length <= richText.VisibleCharacters)
if (Input.IsActionJustPressed("ui_accept") && GetNode<PanelContainer>("box/panel_container").Visible == false && Visible && richText.VisibleCharacters == -1 | Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length <= richText.VisibleCharacters)
{
if (dlgPointer < dlgLines.Count && dlgLines[dlgPointer] is string)
{
@@ -78,8 +78,6 @@ public partial class dialog_bubble : CanvasLayer
}
for (int i = 0; i < dialogOptions.Length; i++)
parent.GetChild<Button>(i).Text = dialogOptions[i];
//parent.GetChild<Button>(0).focus
dialogOptionsLength = dialogOptions.Length;
}
}

View File

@@ -1,5 +1,6 @@
using Godot;
using System;
using System.Text.RegularExpressions;
public partial class player : CharacterBody2D
{
@@ -14,6 +15,10 @@ public partial class player : CharacterBody2D
public override void _Ready()
{
playerName = Regex.Replace(playerName, @"\[[^]]+\]", "");
if (playerName.Length > 12)
playerName = playerName.Substring(0, 12);
animatedSprite = GetNode<AnimatedSprite2D>("animated_sprite_2d");
rotCenter = GetNode<Marker2D>("rotation_center");
dialogRayCast = GetNode<RayCast2D>("rotation_center/ray_cast_2d");