even more dialog code changes

This commit is contained in:
2022-12-07 23:00:56 +01:00
parent 0b4abc2365
commit f62e44a4f2
3 changed files with 30 additions and 11 deletions

View File

@@ -4,9 +4,26 @@
"Hey, {0}! Hope you have fun today!", "Hey, {0}! Hope you have fun today!",
"Hi! What's up {0}?" "Hi! What's up {0}?"
], ],
"debugAnswer": "This is a debug answer!",
"randomGoodbyeText":[ "randomGoodbyeText":[
"Was nice talking to you goodbye!", "Was nice talking to you goodbye!",
"Have a great day, {0}!" "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."
]
}
] ]
} }

View File

@@ -9,7 +9,7 @@
[node name="first_world" parent="." instance=ExtResource("2_x8nyb")] [node name="first_world" parent="." instance=ExtResource("2_x8nyb")]
[node name="player" parent="." instance=ExtResource("1_p5d84")] [node name="player" parent="." instance=ExtResource("1_p5d84")]
playerName = "vaporvee" playerName = "PlayerName"
[node name="dialog_bubble" parent="." instance=ExtResource("3_ohogx")] [node name="dialog_bubble" parent="." instance=ExtResource("3_ohogx")]
visible = false visible = false

View File

@@ -4,7 +4,7 @@ using System;
public partial class dialog_bubble : CanvasLayer public partial class dialog_bubble : CanvasLayer
{ {
public string printedDialog; public string currentDialogLine;
public int debugCounter; public int debugCounter;
public void ImportString(string dialogTitle, string dialogFile, string playerName) public void ImportString(string dialogTitle, string dialogFile, string playerName)
{ {
@@ -14,17 +14,19 @@ public partial class dialog_bubble : CanvasLayer
string currentKey = "randomWelcomeText"; string currentKey = "randomWelcomeText";
using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read);
string text = file.GetAsText(); string text = file.GetAsText();
var jsonFile = JSON.ParseString(text); var jsonFile = JSON.ParseString(text);
Dictionary allDialog = (Dictionary)jsonFile; 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(); string[] dialogRand = allDialog[currentKey].AsStringArray();
printedDialog = dialogPart[GD.Randi() % dialogPart.Length]; currentDialogLine = dialogRand[GD.Randi() % dialogRand.Length];
} }
else printedDialog = allDialog[currentKey].AsString(); else currentDialogLine = allDialog[currentKey].AsString();
printedDialog = String.Format(printedDialog, playerName); currentDialogLine = String.Format(currentDialogLine, playerName);
GetNode<Label>("TextLabel").Text = printedDialog; GetNode<Label>("TextLabel").Text = currentDialogLine;
GetNode<Label>("NameLabel").Text = dialogTitle; GetNode<Label>("NameLabel").Text = dialogTitle;
} }
public void EndDialog() public void EndDialog()
@@ -38,7 +40,7 @@ public partial class dialog_bubble : CanvasLayer
{ {
debugCounter++; debugCounter++;
} }
if(debugCounter == 2) if(debugCounter > 1)
{ {
EndDialog(); EndDialog();
debugCounter = 0; debugCounter = 0;