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

r534:83d9621d56f6 -

@@ -13,7 +13,7
13
13
14 public int ZoneWidth = 10;
14 public int ZoneWidth = 10;
15 public int ZoneHeight = 10;
15 public int ZoneHeight = 10;
16
16
17
17
18 public int MapMultiplier; //Adjusts for larger maps.
18 public int MapMultiplier; //Adjusts for larger maps.
19
19
@@ -46,7 +46,6
46 }
46 }
47 }
47 }
48
48
49
50 public CellMap()
49 public CellMap()
51 {
50 {
52 //TileMap(MapWidth, MapHeight);
51 //TileMap(MapWidth, MapHeight);
@@ -61,7 +60,6
61
60
62 this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2);
61 this.MapMultiplier = (int)(((this.MapWidth / 50) + (this.MapHeight / 50)) / 2);
63
62
64
65 for (int i = 0; i < height; i++)
63 for (int i = 0; i < height; i++)
66 {
64 {
67 List<Cell> newRow = new List<Cell>();
65 List<Cell> newRow = new List<Cell>();
@@ -210,7 +208,6
210 GenericEvergreen,
208 GenericEvergreen,
211 GenericDeciduous,
209 GenericDeciduous,
212 GenericShrub
210 GenericShrub
213
214 }
211 }
215
212
216 public class Cell
213 public class Cell
@@ -172,7 +172,7
172 }
172 }
173 else if (delta.deltaTrees.Value > 0)
173 else if (delta.deltaTrees.Value > 0)
174 {
174 {
175 var random_type = random_generator.Next(0, 3);
175 var random_type = random_generator.Next(0, 3);
176 cell.AddTree(this.simulation.DateTime, (CellMap.TreeType)random_type);
176 cell.AddTree(this.simulation.DateTime, (CellMap.TreeType)random_type);
177 added++;
177 added++;
178 }
178 }
@@ -24,7 +24,6
24 private Random random_generator;
24 private Random random_generator;
25
25
26 public const int DEFAULT_MIN_SQUARES = 75;
26 public const int DEFAULT_MIN_SQUARES = 75;
27 // public const int DEFAULT_SQUARES = 25;
28 public const int DEFAULT_SQUARES = 100;
27 public const int DEFAULT_SQUARES = 100;
29 public const int CONTRACT_MINIMUM = 50;
28 public const int CONTRACT_MINIMUM = 50;
30 public const int CONTRACT_MAXIMUM = 400;
29 public const int CONTRACT_MAXIMUM = 400;
@@ -32,7 +31,7
32 private int MapWidth;
31 private int MapWidth;
33 private int MapHeight;
32 private int MapHeight;
34
33
35 private int MapMultiplier; //Adjustment factor for larger maps
34 private int MapMultiplier; //Adjustment factor for larger maps
36
35
37 private Simulation simulation;
36 private Simulation simulation;
38 private Grammar grammar;
37 private Grammar grammar;
@@ -48,7 +47,8
48 this.simulation = simulation;
47 this.simulation = simulation;
49 this.grammar = grammar;
48 this.grammar = grammar;
50
49
51 this.MapMultiplier = this.simulation.map.MapMultiplier; }
50 this.MapMultiplier = this.simulation.map.MapMultiplier;
51 }
52 private Vector2 FindStart(HashSet<Vector2> occupied_squares)
52 private Vector2 FindStart(HashSet<Vector2> occupied_squares)
53 {
53 {
54
54
@@ -63,7 +63,6
63 return new_square;
63 return new_square;
64 }
64 }
65 }
65 }
66 // return null;
67 return Vector2.Zero;
66 return Vector2.Zero;
68 }
67 }
69
68
@@ -116,8 +115,6
116
115
117 protected override void Spawn(in SpawnContractMessage message)
116 protected override void Spawn(in SpawnContractMessage message)
118 {
117 {
119
120
121 //for now:
118 //for now:
122 var occupied = new List<Vector2>();
119 var occupied = new List<Vector2>();
123
120
@@ -146,10 +143,6
146
143
147 var image_index = random_generator.Next(1, 7);
144 var image_index = random_generator.Next(1, 7);
148
145
149 // int max_squares = (message.max_squares == 0) ? DEFAULT_SQUARES : message.max_squares;
150 // int min_squares = (message.min_squares == null) ? DEFAULT_MIN_SQUARES : (int)message.min_squares;
151
152
153 int max_squares = (organization_type, message.min_squares) switch {
146 int max_squares = (organization_type, message.min_squares) switch {
154 (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier),
147 (OrganizationType.Family, null) => random_generator.Next(50, 100 * this.MapMultiplier),
155 (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier),
148 (OrganizationType.LargeCorporation, null) => random_generator.Next(90, 250 * this.MapMultiplier),
@@ -53,7 +53,7
53 int random_month = random_generator.Next(1, 13);
53 int random_month = random_generator.Next(1, 13);
54 DateTime random_date = new DateTime(random_year, random_month, 1);
54 DateTime random_date = new DateTime(random_year, random_month, 1);
55
55
56 int random_type = random_generator.Next(0, 4);
56 int random_type = random_generator.Next(0, 4);
57
57
58 cell.AddTree(random_date, (TreeType)random_type);
58 cell.AddTree(random_date, (TreeType)random_type);
59 }
59 }
@@ -575,20 +575,20
575
575
576 // if (this.cull(x, y))
576 // if (this.cull(x, y))
577 // {
577 // {
578 batch.Draw(
578 batch.Draw(
579 Tile.TileSetTexture,
579 Tile.TileSetTexture,
580 new Rectangle(
580 new Rectangle(
581 screenx,
581 screenx,
582 screeny,
582 screeny,
583 Tile.TileWidth * scale_factor, Tile.TileHeight * scale_factor),
583 Tile.TileWidth * scale_factor, Tile.TileHeight * scale_factor),
584 Tile.GetSourceRectangle(1),
584 Tile.GetSourceRectangle(1),
585 Color.White,
585 Color.White,
586 0.0f,
586 0.0f,
587 Vector2.Zero,
587 Vector2.Zero,
588 SpriteEffects.None,
588 SpriteEffects.None,
589 0.9f);
589 0.9f);
590
590
591 this.tilesDrawn++;
591 this.tilesDrawn++;
592 // }
592 // }
593 }
593 }
594 }
594 }
@@ -685,12 +685,12
685 }
685 }
686 */
686 */
687 tileBatch.Begin(SpriteSortMode.BackToFront,
687 tileBatch.Begin(SpriteSortMode.BackToFront,
688 BlendState.AlphaBlend,
688 BlendState.AlphaBlend,
689 null,
689 null,
690 null,
690 null,
691 null,
691 null,
692 null,
692 null,
693 camera.get_transformation(GraphicsDevice));
693 camera.get_transformation(GraphicsDevice));
694
694
695 #if DEBUG
695 #if DEBUG
696 drawTileAt(4, 4, 140, 3);
696 drawTileAt(4, 4, 140, 3);
@@ -751,7 +751,7
751 drawTileAt(i, j, 210, 2);
751 drawTileAt(i, j, 210, 2);
752 }
752 }
753 else {
753 else {
754 drawTileAt(i, j, 122, 2); //122, 203, 221
754 drawTileAt(i, j, 122, 2); //122, 203, 221
755 }
755 }
756 // if ((i + j) % 8 == 0)
756 // if ((i + j) % 8 == 0)
757 // {
757 // {
@@ -807,14 +807,14
807 if (treeStatus != CellStatus.Clear)
807 if (treeStatus != CellStatus.Clear)
808 {
808 {
809 status_left = String.Format("{0:},{1:} {2} {3} ({4})", this.mouseGrid.X, this.mouseGrid.Y,
809 status_left = String.Format("{0:},{1:} {2} {3} ({4})", this.mouseGrid.X, this.mouseGrid.Y,
810 treeStatusAdjective,
810 treeStatusAdjective,
811 treeType,
811 treeType,
812 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused"));
812 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused"));
813 }
813 }
814 else {
814 else {
815 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
815 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
816 treeStatusAdjective,
816 treeStatusAdjective,
817 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused"));
817 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unused"));
818 }
818 }
819 }
819 }
820
820
@@ -46,8 +46,8
46 var context = ImGui.CreateContext();
46 var context = ImGui.CreateContext();
47 ImGui.SetCurrentContext(context);
47 ImGui.SetCurrentContext(context);
48 var plotContext = ImPlot.CreateContext();
48 var plotContext = ImPlot.CreateContext();
49 ImPlot.SetCurrentContext(plotContext);
49 ImPlot.SetCurrentContext(plotContext);
50 ImPlot.SetImGuiContext(context);
50 ImPlot.SetImGuiContext(context);
51
51
52 _game = game ?? throw new ArgumentNullException(nameof(game));
52 _game = game ?? throw new ArgumentNullException(nameof(game));
53 _graphicsDevice = game.GraphicsDevice;
53 _graphicsDevice = game.GraphicsDevice;
@@ -17,7 +17,7
17 Options,
17 Options,
18 NewGame,
18 NewGame,
19 Dialog,
19 Dialog,
20 Graph,
20 Graph,
21 }
21 }
22
22
23
23
@@ -147,9 +147,9
147 break;
147 break;
148 case Window.NewGame:
148 case Window.NewGame:
149 NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine);
149 NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine);
150 break;
150 break;
151 case Window.Graph:
151 case Window.Graph:
152 GraphWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine);
152 GraphWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine);
153 break;
153 break;
154 case Window.Dialog:
154 case Window.Dialog:
155 dialog_count++;
155 dialog_count++;
@@ -39,7 +39,7
39 public int trees;
39 public int trees;
40 public int dead_trees;
40 public int dead_trees;
41 public int crowded_trees;
41 public int crowded_trees;
42 //Kind of a hack but allos for tracking figures over time without creating a whole new infrastructure
42 //Kind of a hack but allows for tracking figures over time without creating a whole new infrastructure
43
43
44 }
44 }
45
45
@@ -135,10 +135,10
135
135
136 public System.Collections.Generic.IEnumerable<Budget> allBudgets()
136 public System.Collections.Generic.IEnumerable<Budget> allBudgets()
137 {
137 {
138 foreach(var budget in this.budgets)
138 foreach(var budget in this.budgets)
139 {
139 {
140 yield return budget;
140 yield return budget;
141 }
141 }
142
142
143 }
143 }
144 private Grammar grammar;
144 private Grammar grammar;
@@ -227,10 +227,10
227
227
228 ImGui.Text(string.Format("fps: {0:F3}", debugInfo.fps));
228 ImGui.Text(string.Format("fps: {0:F3}", debugInfo.fps));
229 ImGui.Text(string.Format("Draw Time: {0:F3}", debugInfo.drawTime.TotalMilliseconds.ToString()));
229 ImGui.Text(string.Format("Draw Time: {0:F3}", debugInfo.drawTime.TotalMilliseconds.ToString()));
230 ImGui.Text(string.Format("\tTree: {0:F3}; Grid: {1:F3}; Tile: {2:F3}",
230 ImGui.Text(string.Format("\tTree: {0:F3}; Grid: {1:F3}; Tile: {2:F3}",
231 debugInfo.treeDrawTime.TotalMilliseconds.ToString(),
231 debugInfo.treeDrawTime.TotalMilliseconds.ToString(),
232 debugInfo.gridDrawTime.TotalMilliseconds.ToString(),
232 debugInfo.gridDrawTime.TotalMilliseconds.ToString(),
233 debugInfo.tileDrawTime.TotalMilliseconds.ToString()));
233 debugInfo.tileDrawTime.TotalMilliseconds.ToString()));
234 ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString()));
234 ImGui.Text(string.Format("Update Time: {0:F3}", debugInfo.updateTime.TotalMilliseconds.ToString()));
235 ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn));
235 ImGui.Text(string.Format("Tiles Drawn: {0:F}", debugInfo.tilesDrawn));
236
236
@@ -245,9 +245,9
245 this.show_test_window = !this.show_test_window;
245 this.show_test_window = !this.show_test_window;
246 }
246 }
247
247
248 if (ImGui.Button("Implot Test Window")){
248 if (ImGui.Button("Implot Test Window")) {
249 show_implot_test_window = !show_implot_test_window;
249 show_implot_test_window = !show_implot_test_window;
250 }
250 }
251 if (ImGui.Button("Test Logging"))
251 if (ImGui.Button("Test Logging"))
252 {
252 {
253 Logging.Log(LogLevel.Critical, "Test");
253 Logging.Log(LogLevel.Critical, "Test");
@@ -319,10 +319,10
319 ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver);
319 ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver);
320 ImGui.ShowDemoWindow(ref show_test_window);
320 ImGui.ShowDemoWindow(ref show_test_window);
321 }
321 }
322 if (this.show_implot_test_window)
322 if (this.show_implot_test_window)
323 {
323 {
324 ImPlot.ShowDemoWindow(ref this.show_implot_test_window);
324 ImPlot.ShowDemoWindow(ref this.show_implot_test_window);
325 }
325 }
326 }
326 }
327 }
327 }
328 }
328 }
@@ -27,16 +27,17
27 public static bool show_upkeep = false;
27 public static bool show_upkeep = false;
28
28
29 private static string[] money_series = { "Total Funds",
29 private static string[] money_series = { "Total Funds",
30 "Subsidies", "Upkeep", "Contracts", "Cashflow", "Misc"};
30 "Subsidies", "Upkeep", "Contracts", "Cashflow", "Misc"
31 };
31 private static string[] tree_series = { "Total trees", "Dead trees", "Crowded trees"};
32 private static string[] tree_series = { "Total trees", "Dead trees", "Crowded trees"};
32
33
33 public static Dictionary<string, IEnumerable<double>> data_sets = new Dictionary<string, IEnumerable<double>>();
34 public static Dictionary<string, IEnumerable<double>> data_sets = new Dictionary<string, IEnumerable<double>>();
34
35
35 public static Dictionary<String, bool> data_sets_show = new List<string>()
36 public static Dictionary<String, bool> data_sets_show = new List<string>()
36 .Concat(money_series)
37 .Concat(money_series)
37 .Concat(tree_series)
38 .Concat(tree_series)
38 .Select(e => (e, false))
39 .Select(e => (e, false))
39 .ToDictionary(t => t.Item1, t=> t.Item2);
40 .ToDictionary(t => t.Item1, t=> t.Item2);
40
41
41
42
42 public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
43 public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
@@ -44,128 +45,128
44 bool newShow = true;
45 bool newShow = true;
45
46
46
47
47 ImGui.PushFont(font);
48 ImGui.PushFont(font);
48
49
49 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
50 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
50 StyleSets.defaultSet.push();
51 StyleSets.defaultSet.push();
51
52
52 if(GraphWindow.hadFocus)
53 if(GraphWindow.hadFocus)
53 {
54 {
54 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
55 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
55 }
56 }
56 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
57 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
57
58
58 ImGui.Begin("Graph", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
59 ImGui.Begin("Graph", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
59 if (GraphWindow.hadFocus)
60 if (GraphWindow.hadFocus)
60 {
61 {
61 ImGui.PopStyleColor();
62 ImGui.PopStyleColor();
62 }
63 }
63 GraphWindow.hadFocus = ImGui.IsWindowFocused();
64 GraphWindow.hadFocus = ImGui.IsWindowFocused();
64
65
65 data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money);
66 data_sets["Total Funds"] = sim.allBudgets().Select(b => (double)b.money);
66 data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy);
67 data_sets["Subsidies"] = sim.allBudgets().Select(b => (double)b.subsidy);
67 data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep);
68 data_sets["Upkeep"] = sim.allBudgets().Select(b => (double)b.upkeep);
68 data_sets["Contracts"] = sim.allBudgets().Select(b => (double)b.contracts);
69 data_sets["Contracts"] = sim.allBudgets().Select(b => (double)b.contracts);
69 data_sets["Misc"] = sim.allBudgets().Select(b => (double)b.misc);
70 data_sets["Misc"] = sim.allBudgets().Select(b => (double)b.misc);
70 data_sets["Cashflow"] = sim.allBudgets().Select(b => (double)b.cashflow);
71 data_sets["Cashflow"] = sim.allBudgets().Select(b => (double)b.cashflow);
72
73 data_sets["Total trees"] = sim.allBudgets().Select(b => (double)b.trees);
74 data_sets["Dead trees"] = sim.allBudgets().Select(b => (double)b.dead_trees);
75 data_sets["Crowded trees"] = sim.allBudgets().Select(b => (double)b.crowded_trees);
76
77 var periods = 12.0d * GraphWindow.year;
78 var keys = data_sets_show.Keys.ToList();
79
80 var totals = data_sets["Total Funds"];
71
81
72 data_sets["Total trees"] = sim.allBudgets().Select(b => (double)b.trees);
82 var max = 0.0d;
73 data_sets["Dead trees"] = sim.allBudgets().Select(b => (double)b.dead_trees);
83 var min = 0.0d;
74 data_sets["Crowded trees"] = sim.allBudgets().Select(b => (double)b.crowded_trees);
75
84
76 var periods = 12.0d * GraphWindow.year;
85 foreach( var key in keys) {
77 var keys = data_sets_show.Keys.ToList();
86 if (data_sets_show[key] && totals.Count() > 0) {
87 var series_max = data_sets[key].Max() * 1.10f;
88 max = Math.Max(series_max, max);
89 }
90 }
78
91
79 var totals = data_sets["Total Funds"];
92 foreach( var key in keys) {
80
93 if (data_sets_show[key] && totals.Count() > 0) {
81 var max = 0.0d;
94 var series_min = data_sets[key].Min();
82 var min = 0.0d;
95 series_min = series_min >= 0? series_min * 0.90f : series_min *1.10f;
96 min = Math.Min(series_min, min);
97 }
98 }
83
99
84 foreach( var key in keys) {
100 ImPlot.PushStyleVar(ImPlotStyleVar.LineWeight, 2.0f);
85 if (data_sets_show[key] && totals.Count() > 0) {
101 ImPlot.PushStyleVar(ImPlotStyleVar.MinorAlpha, 0.0f);
86 var series_max = data_sets[key].Max() * 1.10f;
102 // ImPlot.PushStyleVar(ImPlotStyleVar.MajorGridSize, new Num.Vector2(0.0f, 0.0f));
87 max = Math.Max(series_max, max);
103 // ImPlot.PushStyleVar(ImPlotStyleVar.MinorGridSize, new Num.Vector2(0.0f, 0.0f));
88 }
89 }
90
104
91 foreach( var key in keys) {
105 ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), min, max, ImGuiCond.Always);
92 if (data_sets_show[key] && totals.Count() > 0) {
106 if( ImPlot.BeginPlot("My Plot", null, null, new Num.Vector2(-1,0), ImPlotFlags.NoLegend | ImPlotFlags.NoMousePos )) {
93 var series_min = data_sets[key].Min();
107 // Span<double> totals = new Span<double>(new double[]{0.0, 1.0, 2.0, 9.0});
94 series_min = series_min >= 0? series_min * 0.90f : series_min *1.10f;
108 foreach (var key in keys) {
95 min = Math.Min(series_min, min);
109 var show = data_sets_show[key];
110 var data = data_sets[key];
111 var data_array = data_sets[key].ToArray();
112 if (data_array.Length > 0 && show)
113 {
114 ImPlot.PlotLine(key, ref data_array[0], data_array.Length);
115 ImPlot.AnnotateClamped(data_array.Length-1, data_array[data_array.Length-1],
116 new Num.Vector2(5, -10), StyleSets.grey, key);
96 }
117 }
97 }
118 }
98
119
99 ImPlot.PushStyleVar(ImPlotStyleVar.LineWeight, 2.0f);
120 ImPlot.EndPlot();
100 ImPlot.PushStyleVar(ImPlotStyleVar.MinorAlpha, 0.0f);
121 }
101 // ImPlot.PushStyleVar(ImPlotStyleVar.MajorGridSize, new Num.Vector2(0.0f, 0.0f));
122
102 // ImPlot.PushStyleVar(ImPlotStyleVar.MinorGridSize, new Num.Vector2(0.0f, 0.0f));
123 ImPlot.PopStyleVar(2);
103
124
104 ImPlot.SetNextPlotLimits(totals.Count()-periods, totals.Count(), min, max , ImGuiCond.Always);
125 ImGui.RadioButton("1 year", ref GraphWindow.year, 1);
105 if( ImPlot.BeginPlot("My Plot", null, null, new Num.Vector2(-1,0), ImPlotFlags.NoLegend | ImPlotFlags.NoMousePos )) {
126 ImGui.SameLine();
106 // Span<double> totals = new Span<double>(new double[]{0.0, 1.0, 2.0, 9.0});
127 ImGui.RadioButton("5 years", ref GraphWindow.year, 5);
107 foreach (var key in keys) {
128 ImGui.SameLine();
108 var show = data_sets_show[key];
129 ImGui.RadioButton("25 years", ref GraphWindow.year, 25);
109 var data = data_sets[key];
130 ImGui.SameLine();
110 var data_array = data_sets[key].ToArray();
131 ImGui.RadioButton("100 years", ref GraphWindow.year, 100);
111 if (data_array.Length > 0 && show)
132
112 {
133 ImGui.Text("Trees:");
113 ImPlot.PlotLine(key, ref data_array[0], data_array.Length);
134 for (int i = 0; i < tree_series.Length; i++)
114 ImPlot.AnnotateClamped(data_array.Length-1, data_array[data_array.Length-1],
135 {
115 new Num.Vector2(5, -10), StyleSets.grey, key);
136 var key = tree_series[i];
116 }
137 if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white))
117 }
138 {
118
139 data_sets_show[key] = !data_sets_show[key];
119 ImPlot.EndPlot();
120 }
140 }
121
141
122 ImPlot.PopStyleVar(2);
142 if (i != tree_series.Length-1)
123
124 ImGui.RadioButton("1 year", ref GraphWindow.year, 1);
125 ImGui.SameLine();
126 ImGui.RadioButton("5 years", ref GraphWindow.year, 5);
127 ImGui.SameLine();
128 ImGui.RadioButton("25 years", ref GraphWindow.year, 25);
129 ImGui.SameLine();
130 ImGui.RadioButton("100 years", ref GraphWindow.year, 100);
131
132 ImGui.Text("Trees:");
133 for (int i = 0; i < tree_series.Length; i++)
134 {
143 {
135 var key = tree_series[i];
144 ImGui.SameLine();
136 if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white))
137 {
138 data_sets_show[key] = !data_sets_show[key];
139 }
140
141 if (i != tree_series.Length-1)
142 {
143 ImGui.SameLine();
144 }
145
146 }
145 }
147
146
148 ImGui.Text("Money:");
147 }
149 for (int i = 0; i < money_series.Length; i++)
148
149 ImGui.Text("Money:");
150 for (int i = 0; i < money_series.Length; i++)
151 {
152 var key = money_series[i];
153 if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white))
150 {
154 {
151 var key = money_series[i];
155 data_sets_show[key] = !data_sets_show[key];
152 if (Menu.activeButton(key, data_sets_show[key], StyleSets.selected, StyleSets.white))
156 }
153 {
157 if ((i % 4 != 3) && (i != money_series.Length-1)) {
154 data_sets_show[key] = !data_sets_show[key];
158 ImGui.SameLine();
155 }
159 }
156 if ((i % 4 != 3) && (i != money_series.Length-1)) {
157 ImGui.SameLine();
158 }
159
160
160 }
161 }
161
162
162
163
163
164
164
165
165 ImGui.End();
166 ImGui.End();
166 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
167 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
167 StyleSets.defaultSet.pop();
168 StyleSets.defaultSet.pop();
168 ImGui.PopFont();
169 ImGui.PopFont();
169
170
170 }
171 }
171 }
172 }
@@ -25,12 +25,12
25 private static ProfanityLevel profanityLevel = default;
25 private static ProfanityLevel profanityLevel = default;
26
26
27
27
28 private static bool origFullscreen = OptionsWindow.newFullscreen;
28 private static bool origFullscreen = OptionsWindow.newFullscreen;
29 private static Vector2 origResolution = OptionsWindow.newResolution;
29 private static Vector2 origResolution = OptionsWindow.newResolution;
30
30
31 private static string origFontName = OptionsWindow.fontName;
31 private static string origFontName = OptionsWindow.fontName;
32 private static int origFontSize = OptionsWindow.fontSize;
32 private static int origFontSize = OptionsWindow.fontSize;
33 private static ProfanityLevel origProfanityLevel = OptionsWindow.profanityLevel;
33 private static ProfanityLevel origProfanityLevel = OptionsWindow.profanityLevel;
34
34
35 public static void Initialize(Vector2 resolution, bool fullscreen, ProfanityLevel profanityLevel)
35 public static void Initialize(Vector2 resolution, bool fullscreen, ProfanityLevel profanityLevel)
36 {
36 {
@@ -72,7 +72,7
72 ImGui.SameLine();
72 ImGui.SameLine();
73
73
74 if (ImGui.BeginCombo("##resolutions", string.Format("{0}x{1}",
74 if (ImGui.BeginCombo("##resolutions", string.Format("{0}x{1}",
75 newResolution.X, newResolution.Y)))
75 newResolution.X, newResolution.Y)))
76 {
76 {
77
77
78 foreach(var (width_option, height_option) in new[] {(1280, 640),
78 foreach(var (width_option, height_option) in new[] {(1280, 640),
@@ -174,12 +174,12
174 fontName = OptionsWindow.fontName
174 fontName = OptionsWindow.fontName
175 });
175 });
176
176
177 origFullscreen = OptionsWindow.newFullscreen;
177 origFullscreen = OptionsWindow.newFullscreen;
178 origResolution = OptionsWindow.newResolution;
178 origResolution = OptionsWindow.newResolution;
179
179
180 origFontName = OptionsWindow.fontName;
180 origFontName = OptionsWindow.fontName;
181 origFontSize = OptionsWindow.fontSize;
181 origFontSize = OptionsWindow.fontSize;
182 origProfanityLevel = OptionsWindow.profanityLevel;
182 origProfanityLevel = OptionsWindow.profanityLevel;
183
183
184 }
184 }
185 ImGui.SameLine();
185 ImGui.SameLine();
@@ -194,26 +194,26
194 fontName = OptionsWindow.fontName
194 fontName = OptionsWindow.fontName
195 });
195 });
196
196
197 origFullscreen = OptionsWindow.newFullscreen;
197 origFullscreen = OptionsWindow.newFullscreen;
198 origResolution = OptionsWindow.newResolution;
198 origResolution = OptionsWindow.newResolution;
199
199
200 origFontName = OptionsWindow.fontName;
200 origFontName = OptionsWindow.fontName;
201 origFontSize = OptionsWindow.fontSize;
201 origFontSize = OptionsWindow.fontSize;
202 origProfanityLevel = OptionsWindow.profanityLevel;
202 origProfanityLevel = OptionsWindow.profanityLevel;
203
203
204 }
204 }
205
205
206 ImGui.SameLine();
206 ImGui.SameLine();
207 if (ImGui.Button("Cancel")) {
207 if (ImGui.Button("Cancel")) {
208 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Options});
208 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Options});
209
209
210 OptionsWindow.newFullscreen = origFullscreen;
210 OptionsWindow.newFullscreen = origFullscreen;
211 OptionsWindow.newResolution = origResolution;
211 OptionsWindow.newResolution = origResolution;
212
212
213 OptionsWindow.fontName = origFontName;
213 OptionsWindow.fontName = origFontName;
214 OptionsWindow.fontSize = origFontSize;
214 OptionsWindow.fontSize = origFontSize;
215 OptionsWindow.profanityLevel = origProfanityLevel;
215 OptionsWindow.profanityLevel = origProfanityLevel;
216 }
216 }
217
217
218
218
219 ImGui.End();
219 ImGui.End();
@@ -2,14 +2,14
2 using JM.LinqFaster;
2 using JM.LinqFaster;
3 namespace isometricparkfna
3 namespace isometricparkfna
4 {
4 {
5 public class EmptyArrayException : Exception {
5 public class EmptyArrayException : Exception {
6 public EmptyArrayException() {
6 public EmptyArrayException() {
7 }
7 }
8
8
9 public EmptyArrayException(string message) : base(message) {
9 public EmptyArrayException(string message) : base(message) {
10 }
10 }
11
11
12 }
12 }
13 public class MathUtils
13 public class MathUtils
14 {
14 {
15 public MathUtils()
15 public MathUtils()
@@ -136,38 +136,38
136 return integers[index];
136 return integers[index];
137 }
137 }
138
138
139 public static float Percentile(float[] floats, float percentile) {
139 public static float Percentile(float[] floats, float percentile) {
140 if (floats.Length > 0) {
140 if (floats.Length > 0) {
141 Array.Sort(floats);
141 Array.Sort(floats);
142 var raw_position = (floats.Length-1) * percentile;
142 var raw_position = (floats.Length-1) * percentile;
143
143
144 var lower_position = (int)raw_position;
144 var lower_position = (int)raw_position;
145 var higher_position = Math.Min((int)(raw_position+1), floats.Length-1);
145 var higher_position = Math.Min((int)(raw_position+1), floats.Length-1);
146
146
147 var remainder = (raw_position % 1);
147 var remainder = (raw_position % 1);
148
148
149 return (floats[lower_position] * (1-remainder)) + (floats[higher_position] * remainder);
149 return (floats[lower_position] * (1-remainder)) + (floats[higher_position] * remainder);
150 }
150 }
151 else {
151 else {
152 throw new EmptyArrayException("Array must not be empty");
152 throw new EmptyArrayException("Array must not be empty");
153 }
153 }
154 }
154 }
155
155
156 public static double Percentile(double[] doubles, double percentile) {
156 public static double Percentile(double[] doubles, double percentile) {
157 if (doubles.Length > 0) {
157 if (doubles.Length > 0) {
158 Array.Sort(doubles);
158 Array.Sort(doubles);
159 var raw_position = (doubles.Length-1) * percentile;
159 var raw_position = (doubles.Length-1) * percentile;
160
160
161 var lower_position = (int)raw_position;
161 var lower_position = (int)raw_position;
162 var higher_position = Math.Min((int)raw_position + 1, doubles.Length -1);
162 var higher_position = Math.Min((int)raw_position + 1, doubles.Length -1);
163
163
164 var remainder = (raw_position % 1);
164 var remainder = (raw_position % 1);
165
165
166 return (doubles[lower_position] * (1-remainder)) + (doubles[higher_position] * remainder);
166 return (doubles[lower_position] * (1-remainder)) + (doubles[higher_position] * remainder);
167 }
167 }
168 else {
168 else {
169 throw new EmptyArrayException("Array must not be empty");
169 throw new EmptyArrayException("Array must not be empty");
170 }
170 }
171 }
171 }
172 }
172 }
173 }
173 }
You need to be logged in to leave comments. Login now