Description:
Hook Tracery into the News feature.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r113:93647912d2ba -

@@ -28,6 +28,9
28 "greeting": [ "Hi", "Hello", "Greetings" ],
28 "greeting": [ "Hi", "Hello", "Greetings" ],
29 "addressGreeting": "#greeting#, #name#",
29 "addressGreeting": "#greeting#, #name#",
30 "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ],
30 "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ],
31 "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas",
32 "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe",
33 "New York City"],
31 "vars": "assistantName = #assistantName# \n whatever = #whatever#"
34 "vars": "assistantName = #assistantName# \n whatever = #whatever#"
32
35
33 }
36 }
@@ -1,4 +1,5
1 using System.Collections.Generic;
1 using System.Collections.Generic;
2 using System.Linq;
2 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework;
3 using Microsoft.Xna.Framework.Audio;
4 using Microsoft.Xna.Framework.Audio;
4 using Microsoft.Xna.Framework.Input;
5 using Microsoft.Xna.Framework.Input;
@@ -70,6 +71,7
70
71
71 private Node<DialogOption> currentNode;
72 private Node<DialogOption> currentNode;
72 private Queue<Node<DialogOption>> remainingDialog;
73 private Queue<Node<DialogOption>> remainingDialog;
74 private NewsItem[] newsItems;
73
75
74
76
75 private bool showGrid;
77 private bool showGrid;
@@ -194,6 +196,19
194 this.output = grammar.Flatten("#greeting#");
196 this.output = grammar.Flatten("#greeting#");
195 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
197 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
196
198
199 Func<string, string> toUpper = delegate (string i)
200 {
201 return i.ToUpper();
202 };
203
204 grammar.AddModifier("toUpper", toUpper);
205
206 this.newsItems = new[] {new NewsItem{hed="test", contents="#city.toUpper# - This is where the lede would go.", source="Wire"},
207 new NewsItem{hed="Politicians Debate Stimulus Package", contents="WASHINGTON - Politicians debate the latest stimulus package, which opponents argue might help some people who don't deserve it. So it's impossible to say whether it's good or bad.", source="Wire"},
208 new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think", source="Arborist"},
209 };
210 this.newsItems = this.newsItems.Select(s => s.Flatten(this.grammar)).ToArray();
211
197 this.remainingDialog = new Queue<Node<DialogOption>>();
212 this.remainingDialog = new Queue<Node<DialogOption>>();
198
213
199 #if DEBUG
214 #if DEBUG
@@ -881,11 +896,10
881
896
882 if (this.showNews)
897 if (this.showNews)
883 {
898 {
884 NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation,
899
885 new[] {new NewsItem{hed="test", contents="MILWAUKEE - This is where the lede would go.", source="Wire"},
900
886 new NewsItem{hed="Politicians Debate Stimulus Package", contents="WASHINGTON - Politicians debate the latest stimulus package, which opponents argue might help some people who don't deserve it. So it's impossible to say whether it's good or bad.", source="Wire"},
901
887 new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think", source="Arborist"},
902 NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, this.newsItems);
888 });
889 }
903 }
890
904
891 bool quit = false;
905 bool quit = false;
@@ -11,6 +11,14
11 public string hed;
11 public string hed;
12 public string contents;
12 public string contents;
13 public string source;
13 public string source;
14
15 public NewsItem Flatten(TraceryNet.Grammar grammar) {
16 return new NewsItem {
17 hed = grammar.Flatten(this.hed),
18 contents = grammar.Flatten(this.contents),
19 source = grammar.Flatten(this.source)
20 };
21 }
14 }
22 }
15
23
16 public static class NewsWindow
24 public static class NewsWindow
@@ -46,36 +54,36
46 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
54 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
47 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
55 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
48 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
56 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
49
57
50
58
51 if (ImGui.BeginTabBar("Sources", 0)) {
59 if (ImGui.BeginTabBar("Sources", 0)) {
52 if (ImGui.BeginTabItem("Wire")) {
60 if (ImGui.BeginTabItem("Wire")) {
53 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) )) {
61 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) )) {
54 if (ImGui.TreeNode(story.hed)) {
62 if (ImGui.TreeNode(story.hed)) {
55 ImGui.TextWrapped(story.contents);
63 ImGui.TextWrapped(story.contents);
56 ImGui.TreePop();
64 ImGui.TreePop();
57 }
65 }
58 }
66 }
59 ImGui.EndTabItem();
67 ImGui.EndTabItem();
60 }
68 }
61 ImGui.EndTabItem();
69 ImGui.EndTabItem();
62 if (ImGui.BeginTabItem("Arborist")) {
70 if (ImGui.BeginTabItem("Arborist")) {
63 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) {
71 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) {
64 if (ImGui.TreeNode(story.hed)) {
72 if (ImGui.TreeNode(story.hed)) {
65 ImGui.TextWrapped(story.contents);
73 ImGui.TextWrapped(story.contents);
66 ImGui.TreePop();
74 ImGui.TreePop();
67 }
75 }
68 }
76 }
69 ImGui.EndTabItem();
77 ImGui.EndTabItem();
70 }
78 }
71 if (ImGui.BeginTabItem("All True News")) {
79 if (ImGui.BeginTabItem("All True News")) {
72 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) {
80 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) {
73 if (ImGui.TreeNode(story.hed)) {
81 if (ImGui.TreeNode(story.hed)) {
74 ImGui.TextWrapped(story.contents);
82 ImGui.TextWrapped(story.contents);
75 ImGui.TreePop();
83 ImGui.TreePop();
76 }
84 }
77 }
85 }
78 ImGui.EndTabItem();
86 ImGui.EndTabItem();
79 }
87 }
80 }
88 }
81
89
You need to be logged in to leave comments. Login now