fixed and improved code, added disabled answers
This commit is contained in:
@@ -3,29 +3,29 @@
|
|||||||
"intro": [
|
"intro": [
|
||||||
[
|
[
|
||||||
"Hello i'm {title}. Your name must be {player}! So...",
|
"Hello i'm {title}. Your name must be {player}! So...",
|
||||||
1
|
0
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"welcome": [
|
"welcome": [
|
||||||
[
|
[
|
||||||
"Oh hello, {player}... You look great! What can I do for you?",
|
"Oh hello, {player}... You look great! What can I do for you?",
|
||||||
{
|
{
|
||||||
"I just wanna talk": "tipp",
|
"I just wanna talk": "<goto:>tipp",
|
||||||
"Nevermind!": "goodbye"
|
"Nevermind!": "<goto:>goodbye"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Hey, {player}! Hope you have fun today! So what do you want?",
|
"Hey, {player}! Hope you have fun today! So what do you want?",
|
||||||
{
|
{
|
||||||
"What's up": "tipp",
|
"What's up": "<goto:>tipp",
|
||||||
"Nothing": "goodbye"
|
"Nothing": "<goto:>goodbye"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Hi! What's up {player}?",
|
"Hi! What's up {player}?",
|
||||||
{
|
{
|
||||||
"Can we talk?": "tipp",
|
"Can we talk?": "<goto:>tipp",
|
||||||
"Have a great day!": "goodbye"
|
"Have a great day!": "<goto:>goodbye"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@@ -33,39 +33,39 @@
|
|||||||
[
|
[
|
||||||
"Do you need something else?",
|
"Do you need something else?",
|
||||||
{
|
{
|
||||||
"Can you tell me something else?": "tipp",
|
"Can you tell me something else?": "<goto:>tipp",
|
||||||
"No, thanks!": "goodbye"
|
"No, thanks!": "<goto:>goodbye"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"So can i help you with something else?",
|
"So can i help you with something else?",
|
||||||
{
|
{
|
||||||
"Tell me a bit more maybe": "tipp",
|
"Tell me a bit more maybe": "<goto:>tipp",
|
||||||
"I'm good, thank you!": "goodbye"
|
"I'm good, thank you!": "<goto:>goodbye"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"goodbye": [
|
"goodbye": [
|
||||||
[
|
[
|
||||||
"Was nice talking to you goodbye!",
|
"Was nice talking to you goodbye!"
|
||||||
0
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Have a great day, {player}!",
|
"Have a great day, {player}!"
|
||||||
0
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"tipp": [
|
"tipp": [
|
||||||
[
|
[
|
||||||
"You can walk arround with WASD on PC.",
|
"You can walk arround with WASD on PC.",
|
||||||
"You can also use your joystick and D-Pad, if you have a controller.",
|
"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."
|
"You can interact with cupcakes and use the buggy placeholder clouds as a football.",
|
||||||
|
"<goto:>else"
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"[center][font s=80][wave amp=50 freq=15][rainbow]This is cool test text[/rainbow][/wave][/font][/center]",
|
"[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 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.",
|
"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."
|
"Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
|
||||||
|
"<goto:>else"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"story": [
|
"story": [
|
||||||
|
@@ -25,7 +25,7 @@ theme_override_colors/icon_pressed_color = Color(1, 1, 1, 1)
|
|||||||
theme_override_colors/icon_hover_color = Color(1, 1, 1, 1)
|
theme_override_colors/icon_hover_color = Color(1, 1, 1, 1)
|
||||||
theme_override_colors/icon_hover_pressed_color = Color(1, 1, 1, 1)
|
theme_override_colors/icon_hover_pressed_color = Color(1, 1, 1, 1)
|
||||||
theme_override_colors/icon_focus_color = Color(1, 1, 1, 1)
|
theme_override_colors/icon_focus_color = Color(1, 1, 1, 1)
|
||||||
theme_override_colors/icon_disabled_color = Color(0, 0, 0, 0)
|
theme_override_colors/icon_disabled_color = Color(1, 1, 1, 0)
|
||||||
theme_override_fonts/font = ExtResource("1_2bkol")
|
theme_override_fonts/font = ExtResource("1_2bkol")
|
||||||
theme_override_font_sizes/font_size = 28
|
theme_override_font_sizes/font_size = 28
|
||||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_mvyo0")
|
theme_override_styles/normal = SubResource("StyleBoxEmpty_mvyo0")
|
||||||
|
@@ -12,7 +12,6 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
|
|
||||||
/*TODO:
|
/*TODO:
|
||||||
- Dont repeat the same randomized dialogue after you get asked do you need something "else"
|
- Dont repeat the same randomized dialogue after you get asked do you need something "else"
|
||||||
- add controller support for answerboxes
|
|
||||||
- add tree support (example: "story" key)
|
- add tree support (example: "story" key)
|
||||||
- ability to add dialogue begin answers on the fly (special ones are colored)
|
- 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*/
|
they will be in a dictionary with event IDs or Dictionary keys it also needs an array wich ones are active*/
|
||||||
@@ -24,12 +23,15 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
triggerArea = actor;
|
triggerArea = actor;
|
||||||
name = title;
|
name = title;
|
||||||
|
|
||||||
parsedDlg = Json.ParseString(FileAccess.Open(file, FileAccess.ModeFlags.Read).GetAsText()
|
parsedDlg = Json.ParseString(FileAccess.Open(file, FileAccess.ModeFlags.Read).GetAsText()
|
||||||
.Replace("{player}", "[color=cyan]" + playerName + "[/color]").Replace("{title}", "[color=purple]" + title + "[/color]"));
|
.Replace("{player}", "[color=cyan]" + playerName + "[/color]").Replace("{title}", "[color=purple]" + title + "[/color]"));
|
||||||
|
|
||||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
|
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() != "villager" || introducedVillager)
|
||||||
GetNode<Label>("box/name_label").Text = title;
|
GetNode<Label>("box/name_label").Text = title;
|
||||||
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
|
if (GetParent().Name == "player") GetParent<player>().allowMovement = false;
|
||||||
|
|
||||||
|
//Get first key
|
||||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
||||||
if (introducedVillager)
|
if (introducedVillager)
|
||||||
GatherDialog("welcome");
|
GatherDialog("welcome");
|
||||||
@@ -38,6 +40,7 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
|
|
||||||
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
|
else if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "message")
|
||||||
GatherDialog("message");
|
GatherDialog("message");
|
||||||
|
|
||||||
Visible = true;
|
Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +48,6 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
dlgPointer = 0;
|
dlgPointer = 0;
|
||||||
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
|
dlgLines = parsedDlg.AsGodotDictionary()[key].AsGodotArray();
|
||||||
if (dlgLines.VariantType == Variant.Type.Array)
|
|
||||||
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)];
|
dlgLines = dlgLines.AsGodotArray()[GD.RandRange(0, dlgLines.AsGodotArray().Count - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,40 +69,41 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
{
|
{
|
||||||
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
if (dlgPointer < dlgLines.AsGodotArray().Count)
|
||||||
{
|
{
|
||||||
|
//read and write the dialogue
|
||||||
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float)
|
if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Float)
|
||||||
InDialogEvents((int)dlgLines.AsGodotArray()[dlgPointer]);
|
InDialogEvents((int)dlgLines.AsGodotArray()[dlgPointer]);
|
||||||
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String)
|
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && !dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:>"))
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
|
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.String && dlgLines.AsGodotArray()[dlgPointer].AsString().StartsWith("<goto:>"))
|
||||||
|
{
|
||||||
|
GatherDialog(dlgLines.AsGodotArray()[dlgPointer].AsString().Replace("<goto:>", ""));
|
||||||
|
UpdateDialog();
|
||||||
|
}
|
||||||
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
|
else if (dlgLines.AsGodotArray()[dlgPointer].VariantType == Variant.Type.Dictionary)
|
||||||
MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray());
|
MakeAnswerBox(Json.ParseString(dlgLines.AsGodotArray()[dlgPointer].AsGodotDictionary().Keys.ToString()).AsStringArray());
|
||||||
}
|
}
|
||||||
dlgPointer++;
|
dlgPointer++;
|
||||||
}
|
}
|
||||||
|
//Typewrite effect
|
||||||
if (richText.VisibleCharacters < Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length && GetNode<Timer>("typewriter_timer").IsStopped())
|
if (richText.VisibleCharacters < Regex.Replace(richText.Text, @"\[[^]]+\]", "").Length && GetNode<Timer>("typewriter_timer").IsStopped())
|
||||||
{
|
{
|
||||||
richText.VisibleCharacters++;
|
richText.VisibleCharacters++;
|
||||||
GetNode<Timer>("typewriter_timer").Start();
|
GetNode<Timer>("typewriter_timer").Start();
|
||||||
}
|
}
|
||||||
if (dlgPointer > dlgLines.AsGodotArray().Count)
|
|
||||||
{
|
|
||||||
if (parsedDlg.AsGodotDictionary()["dialogType"].AsString() == "villager")
|
|
||||||
{
|
|
||||||
GatherDialog("else");
|
|
||||||
UpdateDialog();
|
|
||||||
dlgPointer++;
|
|
||||||
}
|
|
||||||
else CloseDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (dlgPointer > dlgLines.AsGodotArray().Count)
|
||||||
|
CloseDialog();
|
||||||
|
|
||||||
|
//AnswerBox answer "logic"
|
||||||
if (GetNode<PanelContainer>("box/panel_container").Visible == true
|
if (GetNode<PanelContainer>("box/panel_container").Visible == true
|
||||||
&& GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton() != null)
|
&& GetNode("box/panel_container/margin_container").GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton() != null)
|
||||||
{
|
{
|
||||||
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container")
|
var answer = dlgLines.AsGodotArray()[dlgPointer - 1].AsGodotDictionary()[GetNode<Button>(GetNode("box/panel_container/margin_container")
|
||||||
.GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
|
.GetChild(0).GetChild<Button>(0).ButtonGroup.GetPressedButton().GetPath()).Text];
|
||||||
GetNode<PanelContainer>("box/panel_container").Visible = false;
|
GetNode<PanelContainer>("box/panel_container").Visible = false;
|
||||||
if (answer.VariantType == Variant.Type.String)
|
if (answer.VariantType == Variant.Type.String && answer.AsString().StartsWith("<goto:>"))
|
||||||
{
|
{
|
||||||
GatherDialog(answer.AsString());
|
GatherDialog(answer.AsString().Replace("<goto:>", ""));
|
||||||
UpdateDialog();
|
UpdateDialog();
|
||||||
}
|
}
|
||||||
dlgPointer++;
|
dlgPointer++;
|
||||||
@@ -121,7 +124,8 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
for (int i = 0; parent.GetChildCount() < dialogOptions.Length; i++)
|
for (int i = 0; parent.GetChildCount() < dialogOptions.Length; i++)
|
||||||
{
|
{
|
||||||
parent.AddChild(GD.Load<PackedScene>("res://scenes/gui/dlg_answer_button.tscn").Instantiate());
|
parent.AddChild(GD.Load<PackedScene>("res://scenes/gui/dlg_answer_button.tscn").Instantiate());
|
||||||
parent.GetChild<Button>(i).Text = dialogOptions[i];
|
if (dialogOptions[i].StartsWith("<!>")) parent.GetChild<Button>(i).Disabled = true;
|
||||||
|
parent.GetChild<Button>(i).Text = dialogOptions[i].Replace("<!>", "");
|
||||||
}
|
}
|
||||||
GetNode<PanelContainer>("box/panel_container").Visible = true;
|
GetNode<PanelContainer>("box/panel_container").Visible = true;
|
||||||
parent.GetChild<Button>(0).GrabFocus();
|
parent.GetChild<Button>(0).GrabFocus();
|
||||||
@@ -131,9 +135,6 @@ public partial class dialog_bubble : CanvasLayer
|
|||||||
switch (eventID)
|
switch (eventID)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
CloseDialog();
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
GetNode<Label>("box/name_label").Text = name;
|
GetNode<Label>("box/name_label").Text = name;
|
||||||
triggerArea.Set("introducedVillager", true);
|
triggerArea.Set("introducedVillager", true);
|
||||||
GatherDialog("welcome"); //not that logical conversation maybe split "welcome" and "what do you want"
|
GatherDialog("welcome"); //not that logical conversation maybe split "welcome" and "what do you want"
|
||||||
|
Reference in New Issue
Block a user