even more dialogue system improvements

This commit is contained in:
Yannik
2023-04-11 16:32:16 +02:00
parent 15b938e0a0
commit 4c58781fb6
3 changed files with 40 additions and 35 deletions

View File

@@ -1,3 +1,3 @@
{
"message": "This is a cool debug test!"
"<message>": "This is a cool debug test!"
}

View File

@@ -1,58 +1,60 @@
{
"dialogType": "villager",
"intro": [
"<dialogType>": "villager",
"<intro>": [
[
"Hello i'm {title}. Your name must be {player}!",
0
]
],
"welcome": [
"<welcome>": [
[
"Oh hello, {player}... You look great!",
"<goto:>begindialog"
"<goto:0:begindialog>"
],
[
"Hey, {player}! Hope you have fun today!",
"<goto:>begindialog"
"<goto:0:begindialog>"
],
[
"Hi! What's up {player}?",
"<goto:>begindialog"
"<goto:0:begindialog>"
]
],
"begindialog": [
"<begindialog>": [
[
"What can I do for you?",
{
"I just wanna talk": "<goto:>tipp",
"Nevermind!": "<goto:>goodbye"
"<eventBeginAnswers>": true,
"I just wanna talk": "<goto:0:tipp>",
"Nevermind!": "<goto:0:goodbye>"
}
],
[
"So what do you want?",
{
"What's up": "<goto:>tipp",
"Nothing": "<goto:>goodbye"
"<eventBeginAnswers>": true,
"What's up": "<goto:0:tipp>",
"Nothing": "<goto:0:goodbye>"
}
]
],
"else": [
"<else>": [
[
"Do you need something else?",
{
"Can you tell me more?": "<goto:>tipp",
"No, thanks!": "<goto:>goodbye"
"Can you tell me more?": "<goto:0:tipp>",
"No, thanks!": "<goto:0:goodbye>"
}
],
[
"So can i help you with something else?",
{
"Tell me a bit more": "<goto:>tipp",
"I'm good, thank you!": "<goto:>goodbye"
"Tell me a bit more": "<goto:0:tipp>",
"I'm good, thank you!": "<goto:0:goodbye>"
}
]
],
"goodbye": [
"<goodbye>": [
[
"Was nice talking to you goodbye!"
],
@@ -60,20 +62,20 @@
"Have a great day, {player}!"
]
],
"tipp": [
"<tipp>": [
[
"[font s=6]░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░░\n░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░\n░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░\n░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░\n░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░\n█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█\n█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█\n░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░\n░░█░░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█░░\n░░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█░░░\n░░░░█░░░░▀▀▄░█░░░█░█▀██████░█░░\n░░░░░▀▄░░░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█░░\n░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░▒░░░█░\n░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░░░░█░\n░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░░░░█░░[/font]",
"<goto:>else"
"<goto:0:else>"
],
[
"[center][font s=80][wave amp=50 freq=15][rainbow]This is cool test text[/rainbow][/wave][/font][/center]",
"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.",
"<goto:>else"
"<goto:0:else>"
]
],
"story": [
"<story>": [
[
"test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1",
"test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2",

View File

@@ -1,8 +1,10 @@
using Godot;
using Godot.Collections;
using System.Text.RegularExpressions;
public partial class dialog_bubble : CanvasLayer
{
[Export] Dictionary eventBeginAnswers;
Variant parsedDlg;
Variant dlgLines;
int dlgPointer = 0;
@@ -18,7 +20,8 @@ public partial class dialog_bubble : CanvasLayer
- add tree support (example: "story" key)
- ability to add dialogue begin answers on the fly (special ones are colored)
they will be in a dictionary with event IDs or Dictionary keys it also needs an array wich ones are active
-answers should work more like gatherdialogue for tree support*/
-answers should work more like gatherdialogue for tree support
- the int in <goto:0 <- should represent the parsedDlgPointer*/
public override void _Ready()
{
richText = GetNode<RichTextLabel>("box/rich_text_label");
@@ -37,14 +40,14 @@ public partial class dialog_bubble : CanvasLayer
GetNode<Label>("box/name_label").Text = title;
player.allowMovement = false;
//Get first key
if (introducedVillager && parsedDlg.AsGodotDictionary().ContainsKey("welcome"))
GatherDialog("welcome");
else if (parsedDlg.AsGodotDictionary().ContainsKey("intro"))
GatherDialog("intro");
else if (parsedDlg.AsGodotDictionary().ContainsKey("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");
GatherDialog("<message>");
}
Visible = true;
@@ -97,11 +100,11 @@ public partial class dialog_bubble : CanvasLayer
//read and write the dialogue
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float)
InDialogEvents((int)dlgLines.AsGodotArray()[dlgPointer]);
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && !dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:>"))
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && !dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:"))
UpdateDialog();
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:>"))
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:"))
{
GatherDialog(dlgLines.AsGodotArray()[dlgPointer].AsString().Replace("<goto:>", ""));
GatherDialog(dlgLines.AsGodotArray()[dlgPointer].AsString().Replace("goto:0:", ""));
UpdateDialog();
}
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
@@ -150,9 +153,9 @@ public partial class dialog_bubble : CanvasLayer
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container")
.GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
GetNode<PanelContainer>("box/panel_container").Visible = false;
if (answer.VariantType == Variant.Type.String && answer.AsString().StartsWith("<goto:>"))
if (answer.VariantType == Variant.Type.String && answer.AsString().StartsWith("<goto:"))
{
GatherDialog(answer.AsString().Replace("<goto:>", ""));
GatherDialog(answer.AsString().Replace("goto:0:", ""));
UpdateDialog();
}
dlgPointer++;
@@ -165,7 +168,7 @@ public partial class dialog_bubble : CanvasLayer
case 0:
GetNode<Label>("box/name_label").Text = title;
triggerArea.Set("introducedVillager", true);
GatherDialog("begindialog");
GatherDialog("<begindialog>");
UpdateDialog();
break;
}