Description:
Add procgen dialog.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r44:e939e083808e -

1 NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,33
1 {
2 "origin": "#sentence#",
3 "assistantNames": [ "Alfred", "Maximillian", "Elena", "#femaleCodedName#" ],
4 "femaleCodedName": ["Ozma", "Alaina", "Josephine", "Ash",
5 "April", "Jessica", "Tina",
6 "Violet", "Steph", "Tabitha", "Chrissy",
7 "Amy", "Jo", "May", "Ada", "Celine",
8 "Nona", "Mia", "Felica", "Persephone",
9 "Priscilla", "Zelda", "Chyrsanthemum",
10 "Viola", "Alyssa", "Eva", "Matilda",
11 "Josie", "Monique", "Maria", "Ella",
12 "Margaret", "Brianna", "Marilyn",
13 "Kitty", "Janet", "Zoë"],
14 "maleCodedName": [ "Tom", "Jack", "Mark",
15 "Phil", "Aaron", "Stephen", "Marcus",
16 "George", "Tim", "Ian", "Max",
17 "Ryne", "Hans", "Isaiah", "Nate",
18 "Christopher", "Brutus", "Cato",
19 "Francis", "Frederick", "Wallace",
20 "Jackson", "Jay", "Cecil", "Marty",
21 "Shane", "Reid", "Tyrone",
22 "Roberto", "Aiden" ],
23 "androgynousName": [ "Ash", "Sam", "Mal",
24 "Mel", "Ren", "Maurice",
25 "Alex", "Isa", "Ky",
26 "Mattie", "Ev", "Sky",
27 "Grey" ],
28 "greeting": [ "Hi", "Hello", "Greetings" ],
29 "addressGreeting": "#greeting#, #name#",
30 "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ],
31 "vars": "assistantName = #assistantName# \n whatever = #whatever#"
32
33 }
@@ -1,7 +1,8
1 1 using System;
2 using System.Collections.Generic;
2 3 using ImGuiNET;
3 4 using isometricparkfna.Utils;
4
5 using TraceryNet;
5 6 using Num = System.Numerics;
6 7
7 8
@@ -14,6 +15,7
14 15 {
15 16 public String? choice;
16 17 public String response;
18 public String speaker;
17 19 }
18 20
19 21
@@ -22,13 +24,16
22 24
23 25 public static Node<DialogOption> introTree = new Node<DialogOption>(
24 26 new DialogOption{response = "Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.",
27 speaker = "The Governor"
25 28 },
26 29 new Node<DialogOption>(new DialogOption { choice = "Okay",
27 response = "Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!" },
30 response = "Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!",
31 speaker = "The Governor"
32 },
28 33 new Node<DialogOption>[]{
29 new Node<DialogOption>(new DialogOption {choice="And I need to keep the forest healthy, too, right?", response="Uhh yeah." },
30 new Node<DialogOption>(new DialogOption {choice="..." })),
31 new Node<DialogOption>(new DialogOption {choice="Sounds good!", response="I'll check in soon." })
34 new Node<DialogOption>(new DialogOption {choice="And I need to keep the forest healthy, too, right?", response="Uhh yeah.", speaker = "The Governor" },
35 new Node<DialogOption>(new DialogOption {choice="...", speaker = "The Governor"})),
36 new Node<DialogOption>(new DialogOption {choice="Sounds good!", response="I'll check in soon.", speaker = "The Governor" })
32 37
33 38 })
34 39 );
@@ -36,16 +41,64
36 41 public static Node<DialogOption> testTree = new Node<DialogOption>(
37 42 new DialogOption
38 43 {
39 response = "Hi.",
44 response = "#[name:player]addressGreeting# #addressGreeting#",
45 speaker = "#assistantName#"
40 46 },
41 47
42 48 new Node<DialogOption>[]{
43 new Node<DialogOption>(new DialogOption {choice="Hi.", response="*walks away*" }),
44 new Node<DialogOption>(new DialogOption {choice="What's up?", response="Not much!" })
49 new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!",
50 speaker = "#assistantName#" }),
51 new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#",
52 speaker = "#assistantName#" })
53
54 }
55 );
56
57 public static Node<DialogOption> testTree2 = new Node<DialogOption>(
58 new DialogOption
59 {
60 response = "#whatever#",
61 speaker = "#assistantName#"
62 },
63
64 new Node<DialogOption>[]{
65 new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!",
66 speaker = "#assistantName#" }),
67 new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#",
68 speaker = "#assistantName#" })
45 69
46 70 }
47 71 );
48 72
73
74 public static Node<DialogOption> flatten (Node<DialogOption> node, Grammar grammar) {
75
76 DialogOption new_data = new DialogOption
77 {
78 choice = node.data.choice != null ? grammar.Flatten(node.data.choice) : node.data.choice,
79 response = node.data.response != null ? grammar.Flatten(node.data.response) : node.data.response,
80 speaker = grammar.Flatten(node.data.speaker)
81 };
82
83
84 if (node.children != null) {
85 List<Node<DialogOption>> new_children = new List<Node<DialogOption>>();
86 foreach (Node<DialogOption> child in node.children)
87 {
88 new_children.Add(flatten(child, grammar));
89 }
90
91 return new Node<DialogOption>(new_data, new_children.ToArray());
92 }
93 else
94 {
95 return new Node<DialogOption>(new_data);
96
97 }
98
99
100 }
101
49 102 }
50 103
51 104 public static class DialogInterface
@@ -73,15 +126,21
73 126
74 127 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
75 128 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
76 ImGui.Begin("The Governor", ref show);
129 ImGui.Begin(currentNode.data.speaker, ref show);
77 130
78 131
79 ImGui.TextWrapped(currentNode.data.response);
132 if (currentNode.data.response != null)
133 {
134 string messageText = currentNode.data.response;
135 ImGui.TextWrapped(messageText);
136 }
137
80 138 if ((currentNode.children != null) && currentNode.children.Length > 0)
81 139 {
82 140 foreach (Node<DialogOption> child in currentNode.children)
83 141 {
84 if (ImGui.Button(child.data.choice))
142 string buttonText = child.data.choice;
143 if (ImGui.Button(buttonText))
85 144 {
86 145 return child;
87 146 }
@@ -20,6 +20,7
20 20
21 21 using ImGuiNET.SampleProgram.XNA;
22 22 using ImGuiNET;
23 using TraceryNet;
23 24
24 25 class FNAGame : Game
25 26 {
@@ -73,6 +74,7
73 74
74 75
75 76 private bool showGrid = true;
77 private Grammar grammar;
76 78 private string output;
77 79 private bool showSecond = true;
78 80
@@ -129,20 +131,6
129 131
130 132 currentNode = DialogTrees.introTree;
131 133
132 this.remainingDialog = new Queue<Node<DialogOption>>();
133
134 this.remainingDialog.Enqueue(DialogTrees.testTree);
135
136
137 var json = "{" +
138 " 'origin': '#sentence#'," +
139 " 'sentence': 'hello cat'" +
140 "}";
141
142 var grammar = new TraceryNet.Grammar(json);
143
144 this.output = grammar.Flatten("#origin#");
145
146 134
147 135
148 136 }
@@ -189,6 +177,18
189 177
190 178
191 179 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice);
180
181 var json2 = new FileInfo(@"Content/grammar.json");
182
183 this.grammar = new TraceryNet.Grammar(json2);
184
185 this.output = grammar.Flatten("#greeting#");
186 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
187
188 this.remainingDialog = new Queue<Node<DialogOption>>();
189
190 this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
191
192 192
193 193 //font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
194 194 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
@@ -793,7 +793,7
793 793 if (this.currentNode != null)
794 794 {
795 795 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
796 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
796 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
797 797 }
798 798
799 799
@@ -32,7 +32,9
32 32 <NoWarn></NoWarn>
33 33 </PropertyGroup>
34 34 <ItemGroup>
35 <Compile Include="FNAGame.cs" />
35 <Compile Include="FNAGame.cs">
36 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37 </Compile>
36 38 <Compile Include="Tile.cs" />
37 39 <Compile Include="TileMap.cs" />
38 40 <Compile Include="Line.cs" />
@@ -106,6 +108,9
106 108 <None Include="Content\iosevka-term-medium.ttf">
107 109 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
108 110 </None>
111 <None Include="Content\grammar.json">
112 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
113 </None>
109 114 </ItemGroup>
110 115 <ItemGroup>
111 116 <Reference Include="System" />
You need to be logged in to leave comments. Login now