Show More
Commit Description:
Show a random selection of three stories, rather than one of each.
Commit Description:
Show a random selection of three stories, rather than one of each.
File last commit:
Show/Diff file:
Action:
isometric-park-fna/UI/NewsWindow.cs
141 lines | 6.3 KiB | text/x-csharp | CSharpLexer
Initial version of News window.
r110
using ImGuiNET;
using Num = System.Numerics;
Add News Items from file.
r115 using System;
Add multiple sources.
r112 using System.Linq;
Add support for reading in news stories from YAML.
r114 using System.IO;
using System.Collections.Generic;
using YamlDotNet.Serialization;
Initial version of News window.
r110
namespace isometricparkfna.UI
{
Add NewsItem struct.
r111 public struct NewsItem {
Add support for reading in news stories from YAML.
r114 public string hed;
public string contents;
Add multiple sources.
r112 public string source;
Add News Items from file.
r115 public Dictionary<string, string> variables;
Hook Tracery into the News feature.
r113
public NewsItem Flatten(TraceryNet.Grammar grammar) {
Add News Items from file.
r115
var variableString = "#";
if (this.variables != null) {
foreach (var variable in this.variables) {
variableString += String.Format("[{0}:{1}]", variable.Key, variable.Value);
}
}
variableString += "vars# ";
var result = grammar.Flatten(variableString);
#if DEBUG
System.Console.Write(variableString);
#endif
Hook Tracery into the News feature.
r113 return new NewsItem {
hed = grammar.Flatten(this.hed),
Add News Items from file.
r115 contents = grammar.Flatten(contents),
Hook Tracery into the News feature.
r113 source = grammar.Flatten(this.source)
};
}
Add support for reading in news stories from YAML.
r114
public static List<NewsItem> FromYaml(string yamlString) {
var input = new StringReader(yamlString);
var deserializer = new DeserializerBuilder()
.Build();
//Dictionary<string, string>
var items = deserializer.Deserialize<List<NewsItem>>(input);
return items;
}
Add NewsItem struct.
r111 }
public static class NewsWindow
Initial version of News window.
r110 {
Add multiple sources.
r112
Add support for reading in news stories from YAML.
r114 public static void Render(ref bool show, ImFontPtr font, Simulation sim, List<NewsItem> content)
Initial version of News window.
r110 {
if (show)
{
ImGui.PushFont(font);
ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
Add multiple sources.
r112 ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
Initial version of News window.
r110
var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar);
ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar);
ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
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));
Add multiple sources.
r112 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
Hook Tracery into the News feature.
r113
Initial version of News window.
r110
Add NewsItem struct.
r111 if (ImGui.BeginTabBar("Sources", 0)) {
Initial version of News window.
r110 if (ImGui.BeginTabItem("Wire")) {
Show a random selection of three stories, rather than one of each.
r127 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) ).Take(3)) {
Hook Tracery into the News feature.
r113 if (ImGui.TreeNode(story.hed)) {
ImGui.TextWrapped(story.contents);
ImGui.TreePop();
}
Add NewsItem struct.
r111 }
Hook Tracery into the News feature.
r113 ImGui.EndTabItem();
Add multiple sources.
r112 }
Hook Tracery into the News feature.
r113 ImGui.EndTabItem();
Add support for reading in news stories from YAML.
r114 if (ImGui.BeginTabItem("The Naturalist")) {
Show a random selection of three stories, rather than one of each.
r127 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) ).Take(3)) {
Hook Tracery into the News feature.
r113 if (ImGui.TreeNode(story.hed)) {
ImGui.TextWrapped(story.contents);
ImGui.TreePop();
}
Initial version of News window.
r110 }
Hook Tracery into the News feature.
r113 ImGui.EndTabItem();
Add multiple sources.
r112 }
if (ImGui.BeginTabItem("All True News")) {
Show a random selection of three stories, rather than one of each.
r127 foreach (NewsItem story in content.Where( s => (s.source == "True" ) ).Take(3)) {
Hook Tracery into the News feature.
r113 if (ImGui.TreeNode(story.hed)) {
ImGui.TextWrapped(story.contents);
ImGui.TreePop();
}
Add multiple sources.
r112 }
Hook Tracery into the News feature.
r113 ImGui.EndTabItem();
Initial version of News window.
r110 }
}
ImGui.EndTabBar();
if (ImGui.Button("Okay"))
{
show = false;
}
ImGui.End();
ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
ImGui.PopStyleVar(4);
Add multiple sources.
r112 ImGui.PopStyleColor(12);
Initial version of News window.
r110 ImGui.PopFont();
}
}
}
}