Description:
Hook Tracery into the News feature.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -28,6 +28,9 | |||
|
28 | 28 | "greeting": [ "Hi", "Hello", "Greetings" ], |
|
29 | 29 | "addressGreeting": "#greeting#, #name#", |
|
30 | 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 | 34 | "vars": "assistantName = #assistantName# \n whatever = #whatever#" |
|
32 | 35 | |
|
33 | 36 | } |
@@ -1,4 +1,5 | |||
|
1 | 1 | using System.Collections.Generic; |
|
2 | using System.Linq; | |
|
2 | 3 | using Microsoft.Xna.Framework; |
|
3 | 4 | using Microsoft.Xna.Framework.Audio; |
|
4 | 5 | using Microsoft.Xna.Framework.Input; |
@@ -70,6 +71,7 | |||
|
70 | 71 | |
|
71 | 72 | private Node<DialogOption> currentNode; |
|
72 | 73 | private Queue<Node<DialogOption>> remainingDialog; |
|
74 | private NewsItem[] newsItems; | |
|
73 | 75 | |
|
74 | 76 | |
|
75 | 77 | private bool showGrid; |
@@ -194,6 +196,19 | |||
|
194 | 196 | this.output = grammar.Flatten("#greeting#"); |
|
195 | 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 | 212 | this.remainingDialog = new Queue<Node<DialogOption>>(); |
|
198 | 213 | |
|
199 | 214 | #if DEBUG |
@@ -881,11 +896,10 | |||
|
881 | 896 | |
|
882 | 897 | if (this.showNews) |
|
883 | 898 | { |
|
884 | NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, | |
|
885 | new[] {new NewsItem{hed="test", contents="MILWAUKEE - This is where the lede would go.", source="Wire"}, | |
|
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"}, | |
|
887 | new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think", source="Arborist"}, | |
|
888 | }); | |
|
899 | ||
|
900 | ||
|
901 | ||
|
902 | NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, this.newsItems); | |
|
889 | 903 | } |
|
890 | 904 | |
|
891 | 905 | bool quit = false; |
@@ -11,6 +11,14 | |||
|
11 | 11 | public string hed; |
|
12 | 12 | public string contents; |
|
13 | 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 | 24 | public static class NewsWindow |
@@ -46,36 +54,36 | |||
|
46 | 54 | ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); |
|
47 | 55 | ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f)); |
|
48 | 56 | ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); |
|
49 | ||
|
57 | ||
|
50 | 58 | |
|
51 | 59 | if (ImGui.BeginTabBar("Sources", 0)) { |
|
52 | 60 | if (ImGui.BeginTabItem("Wire")) { |
|
53 | 61 | foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) )) { |
|
54 | if (ImGui.TreeNode(story.hed)) { | |
|
55 | ImGui.TextWrapped(story.contents); | |
|
56 | ImGui.TreePop(); | |
|
57 | } | |
|
62 | if (ImGui.TreeNode(story.hed)) { | |
|
63 | ImGui.TextWrapped(story.contents); | |
|
64 | ImGui.TreePop(); | |
|
65 | } | |
|
58 | 66 | } |
|
59 | ImGui.EndTabItem(); | |
|
67 | ImGui.EndTabItem(); | |
|
60 | 68 | } |
|
61 | ImGui.EndTabItem(); | |
|
69 | ImGui.EndTabItem(); | |
|
62 | 70 | if (ImGui.BeginTabItem("Arborist")) { |
|
63 | 71 | foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) { |
|
64 | if (ImGui.TreeNode(story.hed)) { | |
|
65 | ImGui.TextWrapped(story.contents); | |
|
66 | ImGui.TreePop(); | |
|
67 | } | |
|
72 | if (ImGui.TreeNode(story.hed)) { | |
|
73 | ImGui.TextWrapped(story.contents); | |
|
74 | ImGui.TreePop(); | |
|
75 | } | |
|
68 | 76 | } |
|
69 | ImGui.EndTabItem(); | |
|
77 | ImGui.EndTabItem(); | |
|
70 | 78 | } |
|
71 | 79 | if (ImGui.BeginTabItem("All True News")) { |
|
72 | 80 | foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) { |
|
73 | if (ImGui.TreeNode(story.hed)) { | |
|
74 | ImGui.TextWrapped(story.contents); | |
|
75 | ImGui.TreePop(); | |
|
76 | } | |
|
81 | if (ImGui.TreeNode(story.hed)) { | |
|
82 | ImGui.TextWrapped(story.contents); | |
|
83 | ImGui.TreePop(); | |
|
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