From f62e44a4f2ea370736bd1f6afc3aa3987d97b276 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Wed, 7 Dec 2022 23:00:56 +0100 Subject: [PATCH] even more dialog code changes --- dialog/npcs/villager_normal.json | 19 ++++++++++++++++++- scenes/main.tscn | 2 +- src/scene-scripts/gui/dialog_bubble.cs | 20 +++++++++++--------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/dialog/npcs/villager_normal.json b/dialog/npcs/villager_normal.json index d8fb1ad..a144481 100644 --- a/dialog/npcs/villager_normal.json +++ b/dialog/npcs/villager_normal.json @@ -4,9 +4,26 @@ "Hey, {0}! Hope you have fun today!", "Hi! What's up {0}?" ], - "debugAnswer": "This is a debug answer!", "randomGoodbyeText":[ "Was nice talking to you goodbye!", "Have a great day, {0}!" + ], + "multiDebugTipp00":[ + "You can walk arround with WASD on PC.", + "You can also use your joystick and D-Pad, if", + "you have a controller.", + "You can interact with cupcakes and", + "use the buggy placeholder clouds as a football." + ], + "multiDebugTipp01":[ + "Lorem ipsum dolor sit amet, consetetur sadipscing elitr,", + "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,", + "sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.", + "Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", + { + "Okay I'm doing that":[ + "Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." + ] + } ] } \ No newline at end of file diff --git a/scenes/main.tscn b/scenes/main.tscn index 964216e..dea557a 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -9,7 +9,7 @@ [node name="first_world" parent="." instance=ExtResource("2_x8nyb")] [node name="player" parent="." instance=ExtResource("1_p5d84")] -playerName = "vaporvee" +playerName = "PlayerName" [node name="dialog_bubble" parent="." instance=ExtResource("3_ohogx")] visible = false diff --git a/src/scene-scripts/gui/dialog_bubble.cs b/src/scene-scripts/gui/dialog_bubble.cs index 7c2fd6f..ba796b5 100644 --- a/src/scene-scripts/gui/dialog_bubble.cs +++ b/src/scene-scripts/gui/dialog_bubble.cs @@ -4,7 +4,7 @@ using System; public partial class dialog_bubble : CanvasLayer { - public string printedDialog; + public string currentDialogLine; public int debugCounter; public void ImportString(string dialogTitle, string dialogFile, string playerName) { @@ -14,17 +14,19 @@ public partial class dialog_bubble : CanvasLayer string currentKey = "randomWelcomeText"; using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); string text = file.GetAsText(); - var jsonFile = JSON.ParseString(text); Dictionary allDialog = (Dictionary)jsonFile; - if (currentKey.BeginsWith("random")) + + //Todo: add multiline text and actual running dialog. And go through string for other dictionaries wich always will be playeranswers + + if (currentKey.StartsWith("random")) { - string[] dialogPart = allDialog[currentKey].AsStringArray(); - printedDialog = dialogPart[GD.Randi() % dialogPart.Length]; + string[] dialogRand = allDialog[currentKey].AsStringArray(); + currentDialogLine = dialogRand[GD.Randi() % dialogRand.Length]; } - else printedDialog = allDialog[currentKey].AsString(); - printedDialog = String.Format(printedDialog, playerName); - GetNode