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

r145:16a78cafe246 -

@@ -19,9 +19,9
19 - Write a small number of testing @done(2021-03-15)
19 - Write a small number of testing @done(2021-03-15)
20 - Write five stories for each source
20 - Write five stories for each source
21 - Arborist
21 - Arborist
22 - Wire
22 - Wire @done(2021-03-22)
23 - True
23 - True
24 - Figure out update interval
24 - Figure out update interval @done(2021-03-22)
25 - Better NEWS tab
25 - Better NEWS tab
26 - Images for some stories
26 - Images for some stories
27 - More stories—a dozen for each source?
27 - More stories—a dozen for each source?
@@ -208,15 +208,17
208
208
209 this.newsItems = newItems.ToList();
209 this.newsItems = newItems.ToList();
210
210
211 using (var sr = new StreamReader(@"Content/news_items.yaml"))
211 using (var sr = new StreamReader(@"Content/news_items.yaml"))
212 {
212 {
213 this.newsItems.AddRange(NewsItem.FromYaml(sr.ReadToEnd()));
213 this.newsItems.AddRange(NewsItem.FromYaml(sr.ReadToEnd()));
214 }
214 }
215 using (var sr_pregenerated = new StreamReader(@"Content/news_items_pregenerated.yaml"))
215 using (var sr_pregenerated = new StreamReader(@"Content/news_items_pregenerated.yaml"))
216 {
216 {
217 this.newsItems.AddRange(NewsItem.FromYaml(sr_pregenerated.ReadToEnd()));
217 this.newsItems.AddRange(NewsItem.FromYaml(sr_pregenerated.ReadToEnd()));
218 }
218 }
219 this.newsItems = this.newsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle();
219 this.simulation.LoadContent(this.newsItems, this.grammar);
220 // this.newsItems = this.newsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle();
221
220
222
221 this.remainingDialog = new Queue<Node<DialogOption>>();
223 this.remainingDialog = new Queue<Node<DialogOption>>();
222
224
@@ -905,7 +907,7
905
907
906 if (this.showNews)
908 if (this.showNews)
907 {
909 {
908 NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation, this.newsItems);
910 NewsWindow.Render(ref this.showNews, debugWindow.monoFont, this.simulation);
909 }
911 }
910
912
911 bool quit = false;
913 bool quit = false;
@@ -3,6 +3,10
3 using static isometricparkfna.CellMap;
3 using static isometricparkfna.CellMap;
4 using System.Linq;
4 using System.Linq;
5
5
6 using isometricparkfna.UI; //purely for news item
7
8 using TraceryNet;
9
6 namespace isometricparkfna
10 namespace isometricparkfna
7 {
11 {
8 public struct Budget
12 public struct Budget
@@ -109,18 +113,23
109 }
113 }
110 }
114 }
111
115
116
117 private Grammar grammar;
118 private List<NewsItem> sourceNewsItems;
119 public List<NewsItem> latestNewsItems;
120
112 public float[] millisecondsPerAdvance { get; private set; }
121 public float[] millisecondsPerAdvance { get; private set; }
113 public String Season { get
122 public String Season { get
114 {
123 {
115 if (MathUtils.Between(this.DateTime.Month, 3, 5))
124 if (MathUtils.BetweenInclusive(this.DateTime.Month, 3, 5))
116 {
125 {
117 return "Spring";
126 return "Spring";
118 }
127 }
119 else if (MathUtils.Between(this.DateTime.Month, 6, 8))
128 else if (MathUtils.BetweenInclusive(this.DateTime.Month, 6, 8))
120 {
129 {
121 return "Summer";
130 return "Summer";
122 }
131 }
123 else if (MathUtils.Between(this.DateTime.Month, 9, 11))
132 else if (MathUtils.BetweenInclusive(this.DateTime.Month, 9, 11))
124 {
133 {
125 return "Fall";
134 return "Fall";
126 }
135 }
@@ -213,7 +222,12
213 private void advanceSimulation()
222 private void advanceSimulation()
214 {
223 {
215
224
225 var oldSeason = this.Season;
216 this.DateTime = this.DateTime.AddMonths(1);
226 this.DateTime = this.DateTime.AddMonths(1);
227 var newSeason = this.Season;
228 var seasonChanged = oldSeason != newSeason;
229
230
217
231
218
232
219 foreach (Cell cell in this.map.iterate_cells())
233 foreach (Cell cell in this.map.iterate_cells())
@@ -281,6 +295,10
281
295
282 newBudget = this.applyBudget(newBudget); ;
296 newBudget = this.applyBudget(newBudget); ;
283 this.budgets.Add(newBudget);
297 this.budgets.Add(newBudget);
298
299 if (seasonChanged) {
300 this.updateNews();
301 }
284 }
302 }
285
303
286 public Budget applyBudget(Budget budget)
304 public Budget applyBudget(Budget budget)
@@ -302,6 +320,19
302 this.currentRate = newRate;
320 this.currentRate = newRate;
303 }
321 }
304 }
322 }
323
324 public void updateNews() {
325 this.latestNewsItems = this.sourceNewsItems.Select(s => s.Flatten(this.grammar)).ToList().Shuffle();
326 }
327
328 public void LoadContent(List<NewsItem> sourceNewsItems, Grammar grammar) {
329 this.sourceNewsItems = sourceNewsItems;
330 this.grammar = grammar;
331
332 this.updateNews();
333
334
335 }
305
336
306 public void update(TimeSpan deltaTime)
337 public void update(TimeSpan deltaTime)
307 {
338 {
@@ -59,7 +59,7
59 public static class NewsWindow
59 public static class NewsWindow
60 {
60 {
61
61
62 public static void Render(ref bool show, ImFontPtr font, Simulation sim, List<NewsItem> content)
62 public static void Render(ref bool show, ImFontPtr font, Simulation sim)
63 {
63 {
64 if (show)
64 if (show)
65 {
65 {
@@ -90,6 +90,8
90 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
90 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
91 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
91 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
92 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
92 ImGui.Begin("NEWS", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
93
94 var content = sim.latestNewsItems;
93
95
94
96
95 if (ImGui.BeginTabBar("Sources", 0)) {
97 if (ImGui.BeginTabBar("Sources", 0)) {
@@ -13,11 +13,23
13
13
14 }
14 }
15
15
16 public static bool Between(int val, int x, int y)
16 public static bool Between(int val, int x, int y)
17 {
17 {
18 return ((x < val && val < y) || (y < val && val < x));
18 return ((x < val && val < y) || (y < val && val < x));
19
20 }
19
21
20 }
22 public static bool BetweenInclusive(float val, float x, float y)
23 {
24 return ((x <= val && val <= y) || (y <= val && val <= x));
25
26 }
27
28 public static bool BetweenInclusive(int val, int x, int y)
29 {
30 return ((x <= val && val <= y) || (y <= val && val <= x));
31
32 }
21
33
22 public static int Clamp(int val, int min, int max)
34 public static int Clamp(int val, int min, int max)
23 {
35 {
You need to be logged in to leave comments. Login now