From 6a52d487c7522584be902a7ef7e7c465d96bead8 Mon Sep 17 00:00:00 2001 From: vaporvee Date: Sat, 17 Dec 2022 22:50:23 +0100 Subject: [PATCH] minor changes and added rewritten version of dialog json will be implemented later --- dialog/npcs/rewrite_villager_normal.json | 51 ++++++++++++++++++++++++ dialog/npcs/villager_normal.json | 2 +- src/scene-scripts/gui/dialog_bubble.cs | 15 +++---- 3 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 dialog/npcs/rewrite_villager_normal.json diff --git a/dialog/npcs/rewrite_villager_normal.json b/dialog/npcs/rewrite_villager_normal.json new file mode 100644 index 0000000..9d49dca --- /dev/null +++ b/dialog/npcs/rewrite_villager_normal.json @@ -0,0 +1,51 @@ +{ + "dialogTitle": "Debug Character", + "dialogType": "villager", + + "random": + { + "welcome": + [ + "Oh hello, {0}... You look great! What do you want from me?", + "Hey, {0}! Hope you have fun today!", + "Hi! What's up {0}?" + ], + "goodbye": + [ + "Was nice talking to you goodbye!", + "Have a great day, {0}!" + ] + }, + "multi": + { + "tipp": + { + "0": + [ + "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." + ], + "1": + [ + "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." + ], + "2": + [ + "test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1", + "test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2", + "test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3", + "So do you want to do xy for me?", + { + "Okay I'm doing that": + [ + "Good nice thank you!" + ] + } + ] + } + } +} \ No newline at end of file diff --git a/dialog/npcs/villager_normal.json b/dialog/npcs/villager_normal.json index ea116b2..2eb375a 100644 --- a/dialog/npcs/villager_normal.json +++ b/dialog/npcs/villager_normal.json @@ -26,7 +26,7 @@ ] } ], - "multiDebugTipp2":[ + "multiTipp2":[ "test1test1test1test1test1test1test1test1test1test1test1test1test1test1test1", "test2test2test2test2test2test2test2test2test2test2test2test2test2test2test2", "test3test3test3test3test3test3test3test3test3test3test3test3test3test3test3", diff --git a/src/scene-scripts/gui/dialog_bubble.cs b/src/scene-scripts/gui/dialog_bubble.cs index 41e7e19..d6fd170 100644 --- a/src/scene-scripts/gui/dialog_bubble.cs +++ b/src/scene-scripts/gui/dialog_bubble.cs @@ -16,7 +16,7 @@ public partial class dialog_bubble : CanvasLayer { userName = playerName; GetNode("/root/main/player").Call("ChangeProcess", false); - currentKey = "multiTipp0";//2 is a selection menu needs to be planned before coding + currentKey = "multiTipp2";//2 is a selection menu needs to be planned before coding using var file = FileAccess.Open(dialogFile, FileAccess.ModeFlags.Read); string text = file.GetAsText(); allDialog = (Dictionary)JSON.ParseString(text); @@ -24,7 +24,7 @@ public partial class dialog_bubble : CanvasLayer addText(); - //Todo: add multiline text and actual running dialog. And go through string for other dictionaries wich always will be playeranswers + //Todo: Implement the better json file structure. } public void EndDialog() @@ -36,16 +36,11 @@ public partial class dialog_bubble : CanvasLayer } public void addText() { + var dialogWithKey = allDialog[currentKey].AsStringArray(); if (currentKey.StartsWith("random")) - { - string[] dialogRand = allDialog[currentKey].AsStringArray(); - currentDialogList.Add(dialogRand[GD.Randi() % dialogRand.Length]); - } + currentDialogList.Add(dialogWithKey[GD.Randi() % dialogWithKey.Length]); if (currentKey.StartsWith("multi")) - { - string[] dialogMulti = allDialog[currentKey].AsStringArray(); - currentDialogList.AddRange(dialogMulti); - } + currentDialogList.AddRange(dialogWithKey); } public override void _Process(double delta) {