diff --git a/isometric-park-fna/Content/grammar.json b/isometric-park-fna/Content/grammar.json --- a/isometric-park-fna/Content/grammar.json +++ b/isometric-park-fna/Content/grammar.json @@ -28,6 +28,9 @@ "greeting": [ "Hi", "Hello", "Greetings" ], "addressGreeting": "#greeting#, #name#", "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ], + "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas", + "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe", + "New York City"], "vars": "assistantName = #assistantName# \n whatever = #whatever#" } diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Input; @@ -70,6 +71,7 @@ private Node currentNode; private Queue> remainingDialog; + private NewsItem[] newsItems; private bool showGrid; @@ -194,6 +196,19 @@ this.output = grammar.Flatten("#greeting#"); var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#"); + Func toUpper = delegate (string i) + { + return i.ToUpper(); + }; + + grammar.AddModifier("toUpper", toUpper); + + this.newsItems = new[] {new NewsItem{hed="test", contents="#city.toUpper# - This is where the lede would go.", source="Wire"}, + 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"}, + new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think", source="Arborist"}, + }; + this.newsItems = this.newsItems.Select(s => s.Flatten(this.grammar)).ToArray(); + this.remainingDialog = new Queue>(); #if DEBUG @@ -881,11 +896,10 @@ if (this.showNews) { - NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, - new[] {new NewsItem{hed="test", contents="MILWAUKEE - This is where the lede would go.", source="Wire"}, - 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"}, - new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think", source="Arborist"}, - }); + + + + NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, this.newsItems); } bool quit = false; diff --git a/isometric-park-fna/UI/NewsWindow.cs b/isometric-park-fna/UI/NewsWindow.cs --- a/isometric-park-fna/UI/NewsWindow.cs +++ b/isometric-park-fna/UI/NewsWindow.cs @@ -11,6 +11,14 @@ public string hed; public string contents; public string source; + + public NewsItem Flatten(TraceryNet.Grammar grammar) { + return new NewsItem { + hed = grammar.Flatten(this.hed), + contents = grammar.Flatten(this.contents), + source = grammar.Flatten(this.source) + }; + } } public static class NewsWindow @@ -46,36 +54,36 @@ ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f)); ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); - + if (ImGui.BeginTabBar("Sources", 0)) { if (ImGui.BeginTabItem("Wire")) { foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) )) { - if (ImGui.TreeNode(story.hed)) { - ImGui.TextWrapped(story.contents); - ImGui.TreePop(); - } + if (ImGui.TreeNode(story.hed)) { + ImGui.TextWrapped(story.contents); + ImGui.TreePop(); + } } - ImGui.EndTabItem(); + ImGui.EndTabItem(); } - ImGui.EndTabItem(); + ImGui.EndTabItem(); if (ImGui.BeginTabItem("Arborist")) { foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) { - if (ImGui.TreeNode(story.hed)) { - ImGui.TextWrapped(story.contents); - ImGui.TreePop(); - } + if (ImGui.TreeNode(story.hed)) { + ImGui.TextWrapped(story.contents); + ImGui.TreePop(); + } } - ImGui.EndTabItem(); + ImGui.EndTabItem(); } if (ImGui.BeginTabItem("All True News")) { foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) { - if (ImGui.TreeNode(story.hed)) { - ImGui.TextWrapped(story.contents); - ImGui.TreePop(); - } + if (ImGui.TreeNode(story.hed)) { + ImGui.TextWrapped(story.contents); + ImGui.TreePop(); + } } - ImGui.EndTabItem(); + ImGui.EndTabItem(); } }