Description:
Add multiple sources.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r112:1f8c9ec57473 -

@@ -882,8 +882,10
882 if (this.showNews)
882 if (this.showNews)
883 {
883 {
884 NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation,
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."},
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."}});
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 });
887 }
889 }
888
890
889 bool quit = false;
891 bool quit = false;
@@ -2,6 +2,7
2 using ImGuiNET;
2 using ImGuiNET;
3
3
4 using Num = System.Numerics;
4 using Num = System.Numerics;
5 using System.Linq;
5
6
6 namespace isometricparkfna.UI
7 namespace isometricparkfna.UI
7 {
8 {
@@ -9,10 +10,12
9 public struct NewsItem {
10 public struct NewsItem {
10 public string hed;
11 public string hed;
11 public string contents;
12 public string contents;
13 public string source;
12 }
14 }
13
15
14 public static class NewsWindow
16 public static class NewsWindow
15 {
17 {
18
16 public static void Render(ref bool show, ImFontPtr font, Simulation sim, NewsItem[] content)
19 public static void Render(ref bool show, ImFontPtr font, Simulation sim, NewsItem[] content)
17 {
20 {
18 if (show)
21 if (show)
@@ -25,6 +28,10
25 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
28 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
26 ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
29 ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f);
27 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
30 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
31 ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
32 ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
33 ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
34 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
28
35
29 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
36 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
30 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
37 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
@@ -38,16 +45,37
38
45
39 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
46 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
40 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
47 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
41 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
48 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
49
42
50
43 if (ImGui.BeginTabBar("Sources", 0)) {
51 if (ImGui.BeginTabBar("Sources", 0)) {
44 if (ImGui.BeginTabItem("Wire")) {
52 if (ImGui.BeginTabItem("Wire")) {
45
53 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) )) {
46 foreach (NewsItem story in content) {
54 if (ImGui.TreeNode(story.hed)) {
47 if (ImGui.CollapsingHeader(story.hed, ImGuiTreeNodeFlags.DefaultOpen)) {
55 ImGui.TextWrapped(story.contents);
48 ImGui.TextWrapped(story.contents);
56 ImGui.TreePop();
57 }
49 }
58 }
59 ImGui.EndTabItem();
60 }
61 ImGui.EndTabItem();
62 if (ImGui.BeginTabItem("Arborist")) {
63 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 }
50 }
68 }
69 ImGui.EndTabItem();
70 }
71 if (ImGui.BeginTabItem("All True News")) {
72 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 }
77 }
78 ImGui.EndTabItem();
51 }
79 }
52 }
80 }
53
81
@@ -62,7 +90,7
62 ImGui.End();
90 ImGui.End();
63 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
91 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
64 ImGui.PopStyleVar(4);
92 ImGui.PopStyleVar(4);
65 ImGui.PopStyleColor(8);
93 ImGui.PopStyleColor(12);
66 ImGui.PopFont();
94 ImGui.PopFont();
67 }
95 }
68 }
96 }
You need to be logged in to leave comments. Login now