Description:
Add News Items from file.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r115:00a5a1dc06d4 -

@@ -0,0 +1,5
1 - hed: deserialized
2 contents: 'This is a #test#.'
3 source: Wire
4 variables:
5 test: albatross
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,1 +1,1
1 8ee6b95dcd628b76a0d5ee914132625645a90707
1 d7f0e37253a74f9e09b0aa45e63a243a5e7640d5
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,1 +1,1
1 0d126f771b88f01f6a28944a5ac1d8a59fabfd62
1 4365fd40af26f6a84e18b3f7cc9703f84189efab
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,14 +1,15
1 1 {
2 2 "format": 1,
3 3 "restore": {
4 "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj": {}
4 "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj": {}
5 5 },
6 6 "projects": {
7 "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
7 "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
8 "version": "1.0.0",
8 9 "restore": {
9 "projectUniqueName": "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj",
10 "projectUniqueName": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj",
10 11 "projectName": "FNA",
11 "projectPath": "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj",
12 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj",
12 13 "frameworks": {
13 14 "net48": {
14 15 "projectReferences": {}
@@ -19,20 +20,17
19 20 "net48": {}
20 21 }
21 22 },
22 "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj": {
23 "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj": {
23 24 "version": "1.0.0",
24 25 "restore": {
25 "projectUniqueName": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
26 "projectUniqueName": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
26 27 "projectName": "SpriteFontPlus",
27 "projectPath": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
28 "packagesPath": "/home/alys/.nuget/packages/",
29 "outputPath": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/obj/",
28 "projectPath": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
29 "packagesPath": "/Users/alys/.nuget/packages/",
30 "outputPath": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/obj/",
30 31 "projectStyle": "PackageReference",
31 "fallbackFolders": [
32 "/usr/share/dotnet/sdk/NuGetFallbackFolder"
33 ],
34 32 "configFilePaths": [
35 "/home/alys/.config/NuGet/NuGet.Config"
33 "/Users/alys/.config/NuGet/NuGet.Config"
36 34 ],
37 35 "originalTargetFrameworks": [
38 36 "net45"
@@ -43,8 +41,8
43 41 "frameworks": {
44 42 "net45": {
45 43 "projectReferences": {
46 "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
47 "projectPath": "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj"
44 "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
45 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj"
48 46 }
49 47 }
50 48 }
@@ -4,10 +4,10
4 4 <RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5 5 <RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6 6 <ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7 <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/alys/.nuget/packages/</NuGetPackageRoot>
8 <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/alys/.nuget/packages/;/usr/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
7 <NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageRoot>
8 <NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/alys/.nuget/packages/</NuGetPackageFolders>
9 9 <NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10 <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.6.0</NuGetToolVersion>
10 <NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.1.0</NuGetToolVersion>
11 11 </PropertyGroup>
12 12 <PropertyGroup>
13 13 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
@@ -26,23 +26,19
26 26 ]
27 27 },
28 28 "packageFolders": {
29 "/home/alys/.nuget/packages/": {},
30 "/usr/share/dotnet/sdk/NuGetFallbackFolder": {}
29 "/Users/alys/.nuget/packages/": {}
31 30 },
32 31 "project": {
33 32 "version": "1.0.0",
34 33 "restore": {
35 "projectUniqueName": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
34 "projectUniqueName": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
36 35 "projectName": "SpriteFontPlus",
37 "projectPath": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
38 "packagesPath": "/home/alys/.nuget/packages/",
39 "outputPath": "/home/alys/repos/isometric-park-fna/SpriteFontPlus/src/obj/",
36 "projectPath": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/SpriteFontPlus.FNA.csproj",
37 "packagesPath": "/Users/alys/.nuget/packages/",
38 "outputPath": "/Users/alys/repos/isometric-park-fna/SpriteFontPlus/src/obj/",
40 39 "projectStyle": "PackageReference",
41 "fallbackFolders": [
42 "/usr/share/dotnet/sdk/NuGetFallbackFolder"
43 ],
44 40 "configFilePaths": [
45 "/home/alys/.config/NuGet/NuGet.Config"
41 "/Users/alys/.config/NuGet/NuGet.Config"
46 42 ],
47 43 "originalTargetFrameworks": [
48 44 "net45"
@@ -53,8 +49,8
53 49 "frameworks": {
54 50 "net45": {
55 51 "projectReferences": {
56 "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
57 "projectPath": "/home/alys/repos/isometric-park-fna/FNA/FNA.csproj"
52 "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj": {
53 "projectPath": "/Users/alys/repos/isometric-park-fna/FNA/FNA.csproj"
58 54 }
59 55 }
60 56 }
@@ -31,6 +31,8
31 31 "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas",
32 32 "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe",
33 33 "New York City"],
34 "vars": "assistantName = #assistantName# \n whatever = #whatever#"
34 "vars": "assistantName = #assistantName# \n whatever = #whatever#",
35 "test": "test",
36 "empty": ""
35 37
36 38 }
@@ -203,16 +203,17
203 203
204 204 grammar.AddModifier("toUpper", toUpper);
205 205
206 var newItems = new[] {new NewsItem{hed="test", contents="#city.toUpper# - This is where the lede would go.", source="Wire"},
206 var newItems = new[] {new NewsItem{hed="Test", contents="#city.toUpper# - This is where the lede would go. #whatever#", source="Wire"},
207 207 new NewsItem{hed="Politicians Debate Stimulus Package", contents="WASHINGTON - Poliicians 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"},
208 new NewsItem{hed="The Rare Subspecies of Spruce Making a Comeback", contents="Maeve Redding didn't think the test would ever be seen in Red Harbor again.", source="Arborist"},
209 209 };
210 210
211 211 this.newsItems = newItems.ToList();
212 this.newsItems.AddRange(NewsItem.FromYaml(@"
213 - hed: deserialized
214 contents: abc
215 source: Wire"));
212
213 using (var sr = new StreamReader(@"Content/news_items.yaml"))
214 {
215 this.newsItems.AddRange(NewsItem.FromYaml(sr.ReadToEnd()));
216 }
216 217 this.newsItems = this.newsItems.Select(s => s.Flatten(this.grammar)).ToList();
217 218
218 219 this.remainingDialog = new Queue<Node<DialogOption>>();
@@ -2,6 +2,7
2 2 using ImGuiNET;
3 3
4 4 using Num = System.Numerics;
5 using System;
5 6 using System.Linq;
6 7 using System.IO;
7 8 using System.Collections.Generic;
@@ -14,11 +15,28
14 15 public string hed;
15 16 public string contents;
16 17 public string source;
18 public Dictionary<string, string> variables;
17 19
18 20 public NewsItem Flatten(TraceryNet.Grammar grammar) {
21
22 var variableString = "#";
23
24 if (this.variables != null) {
25 foreach (var variable in this.variables) {
26 variableString += String.Format("[{0}:{1}]", variable.Key, variable.Value);
27 }
28 }
29
30 variableString += "vars# ";
31
32 var result = grammar.Flatten(variableString);
33 #if DEBUG
34 System.Console.Write(variableString);
35 #endif
36
19 37 return new NewsItem {
20 38 hed = grammar.Flatten(this.hed),
21 contents = grammar.Flatten(this.contents),
39 contents = grammar.Flatten(contents),
22 40 source = grammar.Flatten(this.source)
23 41 };
24 42 }
@@ -94,7 +112,7
94 112 ImGui.EndTabItem();
95 113 }
96 114 if (ImGui.BeginTabItem("All True News")) {
97 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) )) {
115 foreach (NewsItem story in content.Where( s => (s.source == "True" ) )) {
98 116 if (ImGui.TreeNode(story.hed)) {
99 117 ImGui.TextWrapped(story.contents);
100 118 ImGui.TreePop();
@@ -117,6 +117,9
117 117 <None Include="Content\grammar.json">
118 118 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
119 119 </None>
120 <None Include="Content\news_items.yaml">
121 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
122 </None>
120 123 </ItemGroup>
121 124 <ItemGroup>
122 125 <Reference Include="System" />
You need to be logged in to leave comments. Login now