even more dialog code changes
This commit is contained in:
@@ -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."
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@@ -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
|
||||
|
@@ -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<Label>("TextLabel").Text = printedDialog;
|
||||
else currentDialogLine = allDialog[currentKey].AsString();
|
||||
currentDialogLine = String.Format(currentDialogLine, playerName);
|
||||
GetNode<Label>("TextLabel").Text = currentDialogLine;
|
||||
GetNode<Label>("NameLabel").Text = dialogTitle;
|
||||
}
|
||||
public void EndDialog()
|
||||
@@ -38,7 +40,7 @@ public partial class dialog_bubble : CanvasLayer
|
||||
{
|
||||
debugCounter++;
|
||||
}
|
||||
if(debugCounter == 2)
|
||||
if(debugCounter > 1)
|
||||
{
|
||||
EndDialog();
|
||||
debugCounter = 0;
|
||||
|
Reference in New Issue
Block a user