better one line dialogue string support
This commit is contained in:
3
assets/lang/en/dialogue/npcs/message_one.json
Normal file
3
assets/lang/en/dialogue/npcs/message_one.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"message": "This is a cool debug test!"
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bkm7365u1mm3o"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://cqfthyrbb8k6v"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/dialogue-system/dialog_bubble.cs" id="1_xtj1q"]
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/dialog_bubble.cs" id="1_xtj1q"]
|
||||
[ext_resource type="FontFile" uid="uid://cx6bvqk0ghmjv" path="res://assets/fonts/urbane-rounded-medium.otf" id="2_qrihj"]
|
||||
[ext_resource type="AudioStream" uid="uid://cg6grs5k5m33n" path="res://assets/audios/typewrite/default_tw.wav" id="2_wg62u"]
|
||||
[ext_resource type="Texture2D" uid="uid://04pdpdvkg2s" path="res://assets/textures/dialogue/dialogue_answer_ninepatch.png" id="3_n3y1v"]
|
||||
|
@@ -55,6 +55,9 @@ editor_draw_limits = true
|
||||
position = Vector2(-224, 206)
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="dialog_trigger_area" parent="base_npc" index="2"]
|
||||
file = "res://assets/lang/en/dialogue/npcs/message_one.json"
|
||||
|
||||
[node name="base_npc_2" parent="." instance=ExtResource("3_dxdug")]
|
||||
position = Vector2(-319, 178)
|
||||
metadata/_edit_lock_ = true
|
||||
@@ -85,3 +88,5 @@ shape = SubResource("SegmentShape2D_f7wta")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[editable path="player"]
|
||||
[editable path="base_npc"]
|
||||
[editable path="base_npc/dialog_trigger_area"]
|
||||
|
@@ -6,6 +6,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
Variant parsedDlg;
|
||||
Variant dlgLines;
|
||||
int dlgPointer = 0;
|
||||
int parsedDlgPointer = 0;
|
||||
RichTextLabel richText;
|
||||
Timer typewriterTimer;
|
||||
string title;
|
||||
@@ -33,21 +34,19 @@ public partial class dialog_bubble : CanvasLayer
|
||||
|
||||
parsedDlg = Json.ParseString(FileAccess.Open(file, FileAccess.ModeFlags.Read).GetAsText()
|
||||
.Replace("{player}", "[color=cyan]" + player_variables.PlayerName + "[/color]").Replace("{title}", "[color=purple]" + title + "[/color]"));
|
||||
|
||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
|
||||
if (introducedVillager)
|
||||
GetNode<Label>("box/name_label").Text = title;
|
||||
|
||||
player.allowMovement = false;
|
||||
|
||||
//Get first key
|
||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
||||
if (introducedVillager)
|
||||
GatherDialog("welcome");
|
||||
else
|
||||
GatherDialog("intro");
|
||||
|
||||
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
|
||||
if (introducedVillager && parsedDlg.AsGodotDictionary().ContainsKey("welcome"))
|
||||
GatherDialog("welcome");
|
||||
else if (parsedDlg.AsGodotDictionary().ContainsKey("intro"))
|
||||
GatherDialog("intro");
|
||||
else if (parsedDlg.AsGodotDictionary().ContainsKey("message"))
|
||||
{
|
||||
GetNode<Label>("box/name_label").Text = title;
|
||||
GatherDialog("message");
|
||||
}
|
||||
|
||||
Visible = true;
|
||||
isTalking = true;
|
||||
@@ -55,6 +54,11 @@ public partial class dialog_bubble : CanvasLayer
|
||||
void GatherDialog(string key)
|
||||
{
|
||||
dlgPointer = 0;
|
||||
if (parsedDlg.AsGodotDictionary()[key].VariantType == Variant.Type.String)
|
||||
{
|
||||
string[] oneline = { parsedDlg.AsGodotDictionary()[key].AsString() };
|
||||
dlgLines = oneline;
|
||||
}
|
||||
if (parsedDlg.AsGodotDictionary()[key].VariantType == Variant.Type.Array)
|
||||
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
|
||||
if (dlgLines.AsGodotArray()[0].VariantType == Variant.Type.Array)
|
Reference in New Issue
Block a user