Description:
Merge in m4-beginning.
Commit status:
[Not Reviewed]
References:
merge default
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r380:697754113206 -

@@ -0,0 +1,26
1
2 stages:
3 - build
4
5 build-debug:
6 stage: build
7 script:
8 - dotnet build isometric-park-fna-core.sln -f netcoreapp3.1
9 image: mcr.microsoft.com/dotnet/sdk:3.1-focal
10
11
12 build-release-windows:
13 stage: build
14 script:
15 - dotnet build isometric-park-fna-core.sln -f netcoreapp3.1 -c Release
16 image: mcr.microsoft.com/dotnet/sdk:3.1
17
18 build-release:
19 stage: build
20 script:
21 - dotnet build isometric-park-fna-core.sln -f netcoreapp3.1 -c Release
22 artifacts:
23 paths:
24 - screenshot.xwd
25 expire_in: 1 week
26 image: mcr.microsoft.com/dotnet/sdk:3.1-focal
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
@@ -0,0 +1,12
1
2
3 using Microsoft.Xna.Framework;
4
5 using Encompass;
6
7 namespace isometricparkfna.Components {
8
9 public struct GameStateComponent : IComponent {
10 public bool isPlaying;
11 }
12 }
@@ -0,0 +1,21
1 using Encompass;
2 using System;
3 using System.ComponentModel.DataAnnotations;
4 // using System.ComponentModel;
5
6 namespace isometricparkfna.Components {
7
8 public enum EnforcementLevel {
9 Unspecified,
10 // [Display(Name = "No Enforcement")]
11 NoEnforcement,
12 // [Display(Name = "Rangers, warnings")]
13 EnforcedWithWarnings,
14 // [Display(Name = "Rangers, citations")]
15 EnforcedWithFines
16 }
17
18 public struct TrespassingPolicyComponent : IComponent {
19 public EnforcementLevel tresspassingPolicy;
20 }
21 }
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,42
1 using Encompass;
2
3 using isometricparkfna.Messages;
4 using isometricparkfna.Components;
5
6 namespace isometricparkfna.Engines
7 {
8
9 [Receives(typeof(GameStateMessage))]
10 [Sends(typeof(ToggleWindowTypeMessage))]
11 [Reads(typeof(GameStateComponent))]
12 [Writes(typeof(GameStateComponent))]
13 class GameStateEngine : Engine
14 {
15
16 public override void Update(double dt)
17 {
18
19 foreach (var message in ReadMessages<GameStateMessage>())
20 {
21 if (message.isPlaying)
22 {
23 startGame();
24 }
25
26 foreach (var entity in ReadEntities<GameStateComponent>())
27 {
28 var state = GetComponent<GameStateComponent>(entity).isPlaying;
29 Logging.Spy(state, "state");
30
31 SetComponent(entity, new GameStateComponent { isPlaying = message.isPlaying });
32 }
33 }
34
35 }
36
37 public void startGame()
38 {
39
40 }
41 }
42 }
@@ -0,0 +1,56
1 using System;
2
3 using Encompass;
4
5 using isometricparkfna.Messages;
6 using isometricparkfna.Components;
7
8 namespace isometricparkfna.Engines
9 {
10
11 [Receives(typeof(SetTrespassingPolicyMessage))]
12 [Reads(typeof(TrespassingPolicyComponent))]
13 [Writes(typeof(TrespassingPolicyComponent),
14 typeof(BudgetLineComponent))]
15 public class PolicyEngine : Engine
16 {
17
18 public PolicyEngine()
19 {
20 }
21
22
23 public override void Update(double dt)
24 {
25 foreach (ref readonly var message
26 in ReadMessages<SetTrespassingPolicyMessage>())
27 {
28 foreach (ref readonly var entity
29 in ReadEntities<TrespassingPolicyComponent>())
30 {
31
32 SetComponent<TrespassingPolicyComponent>(entity,
33 new TrespassingPolicyComponent {tresspassingPolicy
34 = message.newEnforcementLevel });
35
36 var newCost =message.newEnforcementLevel switch {
37 EnforcementLevel.NoEnforcement => 0,
38 EnforcementLevel.EnforcedWithWarnings => 100,
39 EnforcementLevel.EnforcedWithFines => 100,
40
41
42 };
43
44
45 SetComponent<BudgetLineComponent>(entity,
46 new BudgetLineComponent {category = "Enforcement",
47 amount = newCost
48 });
49
50 }
51 }
52
53 }
54
55 }
56 }
@@ -0,0 +1,126
1
2 using System;
3 using System.Collections.Generic;
4
5 using Microsoft.Xna.Framework;
6
7 using isometricparkfna.Messages;
8 using static isometricparkfna.CellMap;
9 using isometricparkfna.UI;
10
11 using Encompass;
12 using TraceryNet;
13
14 namespace isometricparkfna.Spawners {
15
16 [Receives(typeof(SpawnGameMessage))]
17 [Sends(typeof(SpawnContractMessage),
18 typeof(SpawnOrganizationtMessage))]
19 class GameSpawner : Spawner<SpawnGameMessage>
20
21 {
22 private Simulation simulation;
23 Random random_generator;
24 FNAGame game;
25 Grammar grammar;
26
27 public GameSpawner(Simulation simulation, FNAGame game, Grammar grammar)
28 {
29 this.simulation = simulation;
30 this.random_generator = new Random();
31 this.game = game;
32 this.grammar = grammar;
33 }
34
35 protected override void Spawn(in SpawnGameMessage message)
36 {
37
38 #region generate_trees
39
40 foreach (List<Cell> row in this.simulation.map.cells)
41 {
42 foreach (Cell cell in row)
43 {
44 if (this.random_generator.NextDouble() > 0.75)
45 {
46 int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR);
47 int random_month = random_generator.Next(1, 12);
48 DateTime random_date = new DateTime(random_year, random_month, 1);
49
50 cell.addTree(random_date);
51 }
52 }
53 }
54 #endregion
55
56 #region create_contracts
57
58 var area = CreateEntity();
59 var size = 5;
60 var squares = new Vector2[size * size];
61 var start_x = 10;
62
63 for (int i = 0; i < size; i++)
64 {
65 for (int j = 0; j < size; j++)
66 {
67 squares[i * size + j] = new Vector2(i + start_x, j);
68 }
69
70 }
71 SendMessage(new SpawnContractMessage
72 {
73 squares = squares,
74 name = "Northshore Logging"
75 });
76 SendMessage(new SpawnContractMessage
77 {
78 name = "Aeres Maximalis Ltd."
79 });
80 #endregion
81
82 #region create_organizations
83 for (int i = 0; i < 3; i++)
84 {
85
86 SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
87 name = "#family_company.capitalizeAll#",
88 description = "#family_company_description#",
89 type = OrganizationType.Family });
90 SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
91 name = "#large_company.capitalizeAll#",
92 description = "#large_company_description#",
93 type = OrganizationType.LargeCorporation });
94 }
95 SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
96 name = "#logging_company.capitalizeAll#",
97 description = "#company_description#" });
98 SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
99 name = "#coop_company.capitalizeAll#",
100 description = "#coop_company_description#",
101 type = OrganizationType.Cooperative });
102 SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
103 name = "#coop_company.capitalizeAll#",
104 description = "#coop_company_description#",
105 type = OrganizationType.Cooperative });
106 #endregion
107 #region dialog
108
109 this.game.enqueueDialog(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
110 #endregion
111 this.simulation.Subsidy = message.Difficulty switch {
112 DifficultyLevel.Hard => 0M,
113 DifficultyLevel.Medium => 750M,
114 DifficultyLevel.Easy => 1000M,
115 _ => 1000M};
116
117 this.simulation.SubsidyDelta = message.Difficulty switch {
118 DifficultyLevel.Hard => 0M,
119 DifficultyLevel.Medium => -10M,
120 DifficultyLevel.Easy => 0M,
121 _ => 1000M};
122
123 Logging.Success("Spawned new game.");
124 }
125 }
126 }
@@ -0,0 +1,38
1
2 using System;
3 using System.Linq;
4
5 using Encompass;
6 using TraceryNet;
7
8 using isometricparkfna.Messages;
9 using isometricparkfna.Components;
10
11 namespace isometricparkfna.Engines
12 {
13
14 [Receives(typeof(SetTextVariableMessage))]
15 public class TraceryBridgeEngine : Engine
16 {
17 public Grammar grammar;
18
19 public TraceryBridgeEngine(Grammar grammar)
20 {
21 this.grammar = grammar;
22 }
23
24
25 public override void Update(double dt)
26 {
27 foreach (ref readonly var message in ReadMessages<SetTextVariableMessage>())
28 {
29 string variableString = "#";
30 variableString += String.Format("[{0}:{1}]", message.variable, message.value);
31 variableString += "vars# ";
32 Logging.Spy(new {var_string = variableString});
33 var result = grammar.Flatten(variableString);
34 }
35 }
36
37 }
38 }
@@ -0,0 +1,12
1
2
3 using Microsoft.Xna.Framework;
4 using Encompass;
5
6 namespace isometricparkfna.Messages {
7 public struct GameStateMessage : IMessage
8 {
9 public bool isPlaying;
10
11 }
12 }
@@ -0,0 +1,14
1
2
3
4 using Microsoft.Xna.Framework;
5 using Encompass;
6
7 namespace isometricparkfna.Messages
8 {
9 public struct SetFontMessage : IMessage
10 {
11 public string fontName;
12 public int fontSize;
13 }
14 }
@@ -0,0 +1,14
1
2
3 using Microsoft.Xna.Framework;
4 using Encompass;
5
6 namespace isometricparkfna.Messages
7 {
8 public struct SetResolutionMessage : IMessage
9 {
10 public Vector2 resolution;
11 public bool fullscreen;
12
13 }
14 }
@@ -0,0 +1,13
1
2 using Encompass;
3
4 namespace isometricparkfna.Messages
5 {
6
7
8 public struct SetTextVariableMessage : IMessage
9 {
10 public string variable;
11 public string value;
12 }
13 }
@@ -0,0 +1,9
1 using Encompass;
2 using isometricparkfna.Components;
3
4 namespace isometricparkfna.Messages {
5
6 public struct SetTrespassingPolicyMessage : IMessage {
7 public EnforcementLevel newEnforcementLevel;
8 }
9 }
@@ -0,0 +1,14
1 using Encompass;
2
3 namespace isometricparkfna.Messages {
4 public enum DifficultyLevel
5 {
6 Easy,
7 Medium,
8 Hard
9 }
10
11 public struct SpawnGameMessage : IMessage {
12 public DifficultyLevel Difficulty;
13 }
14 }
@@ -0,0 +1,26
1
2 using Encompass;
3
4 namespace isometricparkfna.Messages
5 {
6
7 public enum Window
8 {
9 Debug,
10 Budget,
11 Forest,
12 News,
13 Contracts,
14 Contract,
15 MainMenu,
16 InGameMenu,
17 Options,
18 NewGame
19 }
20
21
22 public struct ToggleWindowTypeMessage : IMessage
23 {
24 public Window Window;
25 }
26 }
@@ -0,0 +1,49
1
2 using System.IO;
3 using Newtonsoft.Json;
4
5 namespace isometricparkfna
6 {
7 public class Options
8 {
9
10 public string fontName;
11 public int fontSize;
12
13 public Options(string fontName, int fontSize)
14 {
15 this.fontName = fontName;
16 this.fontSize = fontSize;
17 }
18
19 public static void writeOptions(string fontName, int fontSize)
20 {
21
22 var options = new Options(fontName, fontSize);
23
24 string json = JsonConvert.SerializeObject(options,
25 Formatting.Indented);
26
27 File.WriteAllText(@"options.json", json);
28 Logging.Success("Writing options to file.");
29
30 }
31
32 public static Options readOptions()
33 {
34 var json = File.ReadAllText(@"options.json");
35 Logging.Spy(new {json=json});
36
37 Options options = JsonConvert.DeserializeObject<Options>(json);
38
39 Logging.Spy(new {name=options.fontName,
40 size=options.fontSize});
41 Logging.Success("Read options.");
42
43 return options;
44 }
45
46
47
48 }
49 }
@@ -0,0 +1,69
1
2 using System;
3 using ImGuiNET;
4
5 using Num = System.Numerics;
6
7 using isometricparkfna.Engines;
8 using isometricparkfna.Messages;
9 using isometricparkfna.UI;
10
11 namespace isometricparkfna.UI
12 {
13
14 public static class InGameMenu
15 {
16
17
18 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine, int width)
19 {
20
21 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
22 bool newShow = true;
23
24 //Has to go first so the measurement is correct:
25 ImGui.PushFont(font);
26
27 Num.Vector2 text_size = ImGui.CalcTextSize("Quit to Main Menu");
28 Num.Vector2 button_size = new Num.Vector2((int)text_size.X*1.1f,
29 (int)text_size.Y*1.25f+5);
30 StyleSets.defaultSet.push();
31
32
33 ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200));
34
35
36 // ImGui.PushFont(smallFont);
37 ImGui.Begin("##In-game Toolbar", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize);
38
39 if (ImGui.Button("Options", button_size))
40 {
41 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
42 }
43 if (ImGui.Button("Return to Game", button_size))
44 {
45 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.InGameMenu});
46 }
47 if (ImGui.Button("Quit to Main Menu", button_size))
48 {
49
50 bridgeEngine.gameStateMessages.Add(new GameStateMessage{isPlaying = false});
51 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.InGameMenu});
52 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.MainMenu});
53 }
54 if (ImGui.Button("Quit", button_size))
55 {
56
57 System.Console.WriteLine("Quitting");
58 Environment.Exit(0);
59 }
60
61 ImGui.End();
62
63
64 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
65 StyleSets.defaultSet.pop();
66 ImGui.PopFont();
67 }
68 }
69 }
@@ -0,0 +1,54
1 using System;
2 using ImGuiNET;
3
4 using Num = System.Numerics;
5
6 using isometricparkfna.Engines;
7 using isometricparkfna.Messages;
8 using isometricparkfna.UI;
9
10 namespace isometricparkfna.UI
11 {
12
13 public static class MainMenu
14 {
15
16 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine, int width)
17 {
18 //Has to go first so the measurement is correct:
19 ImGui.PushFont(font);
20
21 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
22 bool newShow = true;
23
24 Num.Vector2 text_size = ImGui.CalcTextSize("Quit to Main Menu");
25 Num.Vector2 button_size = new Num.Vector2((int)text_size.X*1.1f,
26 (int)text_size.Y*1.25f+5);
27
28
29 StyleSets.defaultSet.push();
30
31 ImGui.SetNextWindowPos(new Num.Vector2(((width/2) - 40), 200));
32
33 ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar);
34
35 if (ImGui.Button("New Game", button_size))
36 {
37 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.NewGame });
38 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu });
39 }
40
41 if (ImGui.Button("Quit", button_size))
42 {
43 System.Console.WriteLine("Quitting");
44 Environment.Exit(0);
45 }
46
47 ImGui.End();
48
49 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
50 StyleSets.defaultSet.pop();
51 ImGui.PopFont();
52 }
53 }
54 }
@@ -0,0 +1,232
1
2 using System;
3 using System.Text;
4 using Num = System.Numerics;
5 using Microsoft.Xna.Framework;
6
7 using ImGuiNET;
8 using TraceryNet;
9
10 using isometricparkfna.Engines;
11 using isometricparkfna.Messages;
12
13 namespace isometricparkfna.UI
14 {
15
16 public static class NewGameWindow
17 {
18
19 private static Grammar grammar;
20
21 public static bool had_focus = false;
22
23 public static byte[] parkNameBuffer;
24 public static int pos;
25
26 public static byte[] playerNameBuffer;
27 public static int playerNamePos;
28
29 public static String selectedTitle;
30
31 public static String playerName2Buffer;
32 public static int playerName2Pos;
33
34 public static byte[] customTitleBuffer;
35 public static int customTitlePos;
36
37 public static int choice;
38
39 public static bool showModal;
40
41 public const int BUFFER_SIZE = 32;
42
43 public static void Initialize(Grammar grammar)
44 {
45 NewGameWindow.grammar = grammar;
46 showModal = true;
47
48 NewGameWindow.Reset();
49
50
51 }
52
53 public static void Reset() {
54 // parkNameBuffer = new byte[BUFFER_SIZE];
55 parkNameBuffer = Encoding.UTF8.GetBytes(NewGameWindow.grammar.Flatten("#park_name#"));
56 pos = 0;
57
58 playerNameBuffer = new byte[BUFFER_SIZE];
59 playerNamePos = 0;
60
61 selectedTitle = "";
62
63 playerName2Buffer = "";
64 playerName2Pos = 0;
65
66 customTitleBuffer = new byte[BUFFER_SIZE];
67 customTitlePos = 0;
68 }
69
70 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine)
71 {
72 ImGui.PushFont(font);
73 StyleSets.defaultSet.push();
74
75 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
76 var newShow = true;
77
78 if (NewGameWindow.had_focus)
79 {
80 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
81 }
82 ImGui.Begin("New Game", ref newShow,
83 ImGuiWindowFlags.AlwaysAutoResize |
84 ImGuiWindowFlags.NoResize |
85 ImGuiWindowFlags.NoCollapse |
86 ImGuiWindowFlags.NoSavedSettings );
87 if (NewGameWindow.had_focus)
88 {
89 ImGui.PopStyleColor();
90 }
91 NewGameWindow.had_focus = ImGui.IsWindowFocused();
92
93 ImGui.Text("Park Name: ");
94 ImGui.SameLine();
95
96 int newPos = NewGameWindow.pos;
97
98 //God this sucks:
99 unsafe {
100 ImGui.InputText("##name", parkNameBuffer, (uint)parkNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPos));
101 }
102 NewGameWindow.pos = newPos;
103
104 ImGui.SameLine();
105 if (ImGui.Button("Random"))
106 {
107 parkNameBuffer = Encoding.UTF8.GetBytes(NewGameWindow.grammar.Flatten("#park_name#"));
108 }
109
110 ImGui.Text("Formal Name: ");
111 ImGui.SameLine();
112
113
114
115
116 ImGui.SetNextItemWidth(ImGui.CalcTextSize("<No Title>").X
117 + ImGui.CalcTextSize("XXXX").X);
118 if (ImGui.BeginCombo("##title", selectedTitle))
119 {
120
121 ImGui.PushFont(italicFont);
122 if (ImGui.Selectable("<No Title>"))
123 {
124 selectedTitle = "<No Title>";
125 }
126 ImGui.PopFont();
127
128 foreach (var title in new String[] {"Mr.", "Mrs.", "Ms.","Miss", "Mx.", "M", "Dr.", "Rev.", "Sir", "Madam", "Hon.", "Dishon.", "Director", "Comrade", "Brother", "Sister", "Friend"})
129 {
130 if (ImGui.Selectable(title))
131 {
132 selectedTitle = title;
133 }
134 }
135
136 ImGui.PushFont(italicFont);
137 ImGui.PopFont();
138
139 ImGui.EndCombo();
140 }
141
142 ImGui.SameLine();
143 int newPlayerNamePos = NewGameWindow.playerNamePos;
144
145 //God this sucks:
146 unsafe {
147 ImGui.InputText("##playerNameBuffer", playerNameBuffer, (uint)playerNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos));
148 }
149
150 NewGameWindow.playerNamePos = newPlayerNamePos;
151
152 ImGui.SameLine();
153
154 if (ImGui.Button("Custom Title..."))
155 {
156 NewGameWindow.showModal = true;
157 ImGui.OpenPopup("Custom");
158
159 }
160 if (ImGui.BeginPopup("Custom" /*, ref showModal*/))
161 {
162 int newCustomTitlePos = NewGameWindow.customTitlePos;
163 unsafe {
164 ImGui.InputText("##customTitleBuffer", customTitleBuffer, (uint)customTitleBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newCustomTitlePos));
165 }
166
167 NewGameWindow.customTitlePos = newCustomTitlePos;
168
169
170 if (ImGui.Button("Okay"))
171 {
172 selectedTitle = System.Text.Encoding.UTF8.GetString(customTitleBuffer);
173 ImGui.CloseCurrentPopup();
174 }
175 ImGui.SameLine();
176 if (ImGui.Button("Cancel"))
177 {
178 ImGui.CloseCurrentPopup();
179 }
180 ImGui.EndPopup();
181
182 }
183
184 ImGui.Text("Casual Name: ");
185 ImGui.SameLine();
186
187 int newPlayerName2Pos = NewGameWindow.playerName2Pos;
188
189 //God this sucks:
190 unsafe {
191 ImGui.InputTextWithHint("##playerName2", "Leave blank to use full name", /*ref*/ playerName2Buffer, 32, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerName2Pos));
192 }
193
194 NewGameWindow.playerName2Pos = newPlayerName2Pos;
195
196 ImGui.RadioButton("Easy: Full Funding", ref choice, ((int)DifficultyLevel.Easy));
197 ImGui.RadioButton("Medium: Austerity", ref choice, ((int)DifficultyLevel.Medium));
198 ImGui.RadioButton("Hard: Unfunded", ref choice, ((int)DifficultyLevel.Hard));
199
200
201 if (ImGui.Button("Okay"))
202 {
203
204 bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerFormal", value = System.Text.Encoding.UTF8.GetString(playerNameBuffer) });
205 bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerCasual", value = playerName2Buffer });
206 bridgeEngine.setTextVariableMessages.Add(new SetTextVariableMessage { variable = "playerTitle", value = selectedTitle});
207
208 bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage{ Difficulty = (DifficultyLevel)choice });
209 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame});
210 bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true});
211 NewGameWindow.Reset();
212 }
213
214 ImGui.SameLine();
215 if ( ImGui.Button("Cancel"))
216 {
217 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame});
218
219 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu });
220 NewGameWindow.Reset();
221 }
222
223
224 ImGui.End();
225
226
227 StyleSets.defaultSet.pop();
228 ImGui.PopFont();
229
230 }
231 }
232 }
@@ -0,0 +1,186
1 using System;
2 using ImGuiNET;
3
4 using Num = System.Numerics;
5
6 using Microsoft.Xna.Framework;
7
8 using isometricparkfna.Engines;
9 using isometricparkfna.Messages;
10 using isometricparkfna.UI;
11
12 namespace isometricparkfna.UI
13 {
14
15 public static class OptionsWindow
16 {
17
18 public static bool hadFocus = false;
19 public static bool newFullscreen;
20 public static Vector2 newResolution;
21
22 private static string fontName = "Iosevka";
23 private static int fontSize = 15;
24
25 public static void Initialize(Vector2 resolution, bool fullscreen)
26 {
27
28 newFullscreen = fullscreen;
29 newResolution = resolution;
30 }
31
32 public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine, int width)
33 {
34
35 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
36 bool newShow = true;
37
38 // Num.Vector2 button_size = new Num.Vector2(120, 20);
39
40 StyleSets.defaultSet.push();
41
42
43 // ImGui.SetNextWindowPos(new Num.Vector2(width/2, 200));
44
45 ImGui.PushFont(font);
46 // ImGui.PushFont(smallFont);
47 //
48 // ImGui.SetNextWindowSize(new Num.Vector2(320, 320));
49 if(OptionsWindow.hadFocus)
50 {
51 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
52 }
53 ImGui.Begin("Options", ref newShow, ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse);
54
55 if (OptionsWindow.hadFocus)
56 {
57 ImGui.PopStyleColor();
58 }
59 OptionsWindow.hadFocus = ImGui.IsWindowFocused();
60
61 ImGui.PushFont(italicFont);
62 ImGui.Text("Graphics");
63 ImGui.PopFont();
64
65
66 ImGui.Text("Resolution:");
67
68 ImGui.SameLine();
69
70 if (ImGui.BeginCombo("", string.Format("{0}x{1}",
71 newResolution.X, newResolution.Y)))
72 {
73
74 foreach(var (width_option, height_option) in new[]{(1280, 640), (640, 320), (960, 480), (1600, 800),
75 (2560, 1440), (1280, 720), (1920, 1080)})
76 {
77 if (ImGui.Selectable(string.Format("{0}x{1}", width_option, height_option)))
78 {
79 newResolution.X = width_option;
80 newResolution.Y = height_option;
81 }
82 }
83
84 ImGui.EndCombo();
85 }
86 ImGui.Text("Font:\t");
87
88 ImGui.SameLine();
89
90 if (ImGui.BeginCombo("##Font", fontName))
91 {
92
93 foreach(var font_name in new[]{"Iosevka", "Roboto"})
94 {
95 if(ImGui.Selectable(font_name))
96 {
97 OptionsWindow.fontName = font_name;
98 }
99 }
100
101 ImGui.EndCombo();
102 }
103 ImGui.Text("Size:\t");
104 ImGui.SameLine();
105 if (ImGui.BeginCombo("##FontSize", fontSize.ToString()))
106 {
107
108 foreach(var size in new[]{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25})
109 {
110 if(ImGui.Selectable(size.ToString()))
111 {
112 OptionsWindow.fontSize = size;
113 }
114 }
115
116 ImGui.EndCombo();
117 }
118
119 ImGuiIOPtr io = ImGui.GetIO();
120
121
122 ImGui.Text("Scale:\t");
123
124 ImGui.SameLine();
125 ImGui.DragFloat("##Scale", ref io.FontGlobalScale, 0.005f, 0.2f, 5.0f, "%.2f");
126
127 ImGui.SameLine();
128 ImGui.TextDisabled("(?)");
129 if (ImGui.IsItemHovered())
130 {
131 ImGui.BeginTooltip();
132 ImGui.Text("Adjust this if increasing font size isn't enough.");
133 ImGui.EndTooltip();
134 }
135
136 ImGui.Checkbox("Fullscreen", ref newFullscreen);
137
138 ImGui.Separator();
139
140
141 if (ImGui.Button("Okay"))
142 {
143 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
144 bridgeEngine.resolutionMessages.Add(new SetResolutionMessage {
145 resolution = newResolution,
146 fullscreen = newFullscreen
147 });
148 bridgeEngine.fontMessages.Add(new SetFontMessage{
149 fontSize = OptionsWindow.fontSize,
150 fontName = OptionsWindow.fontName});
151
152 }
153 ImGui.SameLine();
154 if (ImGui.Button("Apply"))
155 {
156 bridgeEngine.resolutionMessages.Add(new SetResolutionMessage {
157 resolution = newResolution,
158 fullscreen = newFullscreen
159 });
160 bridgeEngine.fontMessages.Add(new SetFontMessage{
161 fontSize = OptionsWindow.fontSize,
162 fontName = OptionsWindow.fontName});
163 }
164
165
166 ImGui.End();
167
168 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
169 StyleSets.defaultSet.pop();
170 ImGui.PopFont();
171
172 if (!newShow)
173 {
174 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Options});
175 }
176 }
177
178
179 public static void setFont(string fontName, int fontSize)
180 {
181 OptionsWindow.fontName = fontName;
182 OptionsWindow.fontSize = fontSize;
183
184 }
185 }
186 }
@@ -0,0 +1,63
1
2 using System.Collections.Generic;
3 using ImGuiNET;
4
5 using Num = System.Numerics;
6
7
8 namespace isometricparkfna.UI
9 {
10 public static class StyleSets
11 {
12 public static Num.Vector4 grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f);
13 public static Num.Vector4 darkgrey = new Num.Vector4(0.45f, 0.45f, 0.45f, 1f);
14 public static Num.Vector4 black = new Num.Vector4(0f, 0f, 0f, 1f);
15 public static Num.Vector4 white = new Num.Vector4(1f, 1f, 1f, 1f);
16 public static Num.Vector4 title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
17
18 // public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.75f, 1f);
19 public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.55f, 1f);
20 public static Dictionary<ImGuiStyleVar, float> defaultWindowVars = new Dictionary<ImGuiStyleVar, float>{
21 { ImGuiStyleVar.FrameRounding, 0.0f },
22 {ImGuiStyleVar.WindowRounding, 0.0f},
23 {ImGuiStyleVar.FrameBorderSize, 1.0f},
24 {ImGuiStyleVar.TabRounding, 0.0f},
25 {ImGuiStyleVar.GrabRounding, 0.0f},
26 };
27 public static Dictionary<ImGuiCol, Num.Vector4> defaultWindowColors = new Dictionary<ImGuiCol, Num.Vector4>{
28
29 {ImGuiCol.WindowBg, grey},
30 {ImGuiCol.FrameBg, grey},
31 {ImGuiCol.FrameBgHovered, grey},
32 {ImGuiCol.Header, darkgrey},
33 {ImGuiCol.HeaderHovered, darkgrey},
34 {ImGuiCol.HeaderActive, darkgrey},
35 {ImGuiCol.ButtonHovered, grey},
36 {ImGuiCol.ButtonActive, darkgrey},
37 {ImGuiCol.SliderGrab, darkgrey},
38 {ImGuiCol.SliderGrabActive, darkgrey},
39
40
41 {ImGuiCol.Tab, darkgrey},
42 {ImGuiCol.TabHovered, darkgrey},
43 {ImGuiCol.TabActive, selected},
44
45 {ImGuiCol.CheckMark, black},
46
47 {ImGuiCol.TitleBg, title_bar},
48 {ImGuiCol.TitleBgActive, selected},
49 {ImGuiCol.TitleBgCollapsed, title_bar},
50
51 {ImGuiCol.Border, black},
52 {ImGuiCol.BorderShadow, black},
53
54 {ImGuiCol.PopupBg, white},
55
56 {ImGuiCol.Button, grey},
57 {ImGuiCol.Text, black}
58 };
59
60 public static StyleSet defaultSet = new StyleSet(defaultWindowVars, defaultWindowColors);
61 }
62
63 }
@@ -5,3 +5,4
5 78cd38bc5e9759187c5a521b6fea6e723e9f8506 0.26.12
5 78cd38bc5e9759187c5a521b6fea6e723e9f8506 0.26.12
6 acd6fd77f343e5c67281288c9dd10ef136d34a90 0.26.18
6 acd6fd77f343e5c67281288c9dd10ef136d34a90 0.26.18
7 9d88447c1044549e78323c867ba8eef7e6c6a608 0.30.04
7 9d88447c1044549e78323c867ba8eef7e6c6a608 0.30.04
8 e0c3cf126c2431f4d4485e77726fad8a193526fd 0.32.02
@@ -3,6 +3,13
3 CORE_SOLUTION = ./isometric-park-fna-core.sln
3 CORE_SOLUTION = ./isometric-park-fna-core.sln
4 FRAMEWORK_SOLUTION = ./isometric-park-fna.sln
4 FRAMEWORK_SOLUTION = ./isometric-park-fna.sln
5
5
6 DEFAULT_RUN = framework-debug
7
8 #BUILD
9
10 # While I frequently build and run using make, the convention is that running
11 # 'make' by itself merely builds the software:
12 default: $(DEFAULT_RUN)
6
13
7 core-debug:
14 core-debug:
8 dotnet build ${CORE_SOLUTION} -f netcoreapp3.1
15 dotnet build ${CORE_SOLUTION} -f netcoreapp3.1
@@ -13,36 +20,38
13 framework-release:
20 framework-release:
14 msbuild -restore:True ${FRAMEWORK_SOLUTION} -p:Configuration=Release
21 msbuild -restore:True ${FRAMEWORK_SOLUTION} -p:Configuration=Release
15
22
16
17 clean-obj:
18 rm -r isometric-park-fna/obj/
19
20 framework-debug: clean-obj
23 framework-debug: clean-obj
21 msbuild -restore:True ${FRAMEWORK_SOLUTION} -p:Configuration=Debug
24 msbuild -restore:True ${FRAMEWORK_SOLUTION} -p:Configuration=Debug
22
25
23
26
24 run-core-debug:
27 #RUN
25 cd isometric-park-fna/bin/Debug/netcoreapp3.1; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../../fnalibs/osx" dotnet ./isometric-park-fna.dll
28
29 run-core-debug:
30 cd isometric-park-fna/bin/Debug/netcoreapp3.1; LD_LIBRARY_PATH="../../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../../fnalibs/osx" dotnet ./isometric-park-fna.dll
26
31
27 run-core-release:
32 run-core-release:
28 cd isometric-park-fna/bin/Release/netcoreapp3.1; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../../fnalibs/osx" dotnet ./isometric-park-fna.dll
33 cd isometric-park-fna/bin/Release/netcoreapp3.1; LD_LIBRARY_PATH="../../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../../fnalibs/osx" dotnet ./isometric-park-fna.dll
29
34
35 run-core-release-xvfb:
36 cd isometric-park-fna/bin/Release/netcoreapp3.1; LD_LIBRARY_PATH="../../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../../fnalibs/osx" xvfb-run -a -s "-screen 0 1400x900x24 +extension RANDR +extension GLX +extension RENDER" -- dotnet ./isometric-park-fna.dll
30
37
31 run-framework-release:
38 run-framework-release:
32 cd isometric-park-fna/bin/Release/; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../fnalibs/osx" mono isometric-park-fna.exe
39 cd isometric-park-fna/bin/Release/; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../fnalibs/osx" mono isometric-park-fna.exe
33
40
41 run-framework-debug:
42 cd isometric-park-fna/bin/Debug/; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../fnalibs/osx" mono isometric-park-fna.exe
34
43
35 # lint:
44 # lint:
36 # yamllint -d relaxed isometric-park-fna/Content/news_items.yaml
45 # yamllint -d relaxed isometric-park-fna/Content/news_items.yaml
46 count:
47 tokei -e isometric-park-fna/packages -e isometric-park-fna/bin -e isometric-park-fna/build_log.txt -e isometric-park-fna/obj scripts/ isometric-park-fna/
48
49 clean-obj:
50 rm -r isometric-park-fna/obj/
37
51
38 #CONVENIENCE
52 #CONVENIENCE
39
53
40 # Just using framework for releases since I know it works for now:
54 # Just using framework for releases since I know it works for now:
41 release: framework-release
55 release: framework-release
42
56
43 run: framework-debug
57 run: $(DEFAULT_RUN) run-$(DEFAULT_RUN)
44 cd isometric-park-fna/bin/Debug/; LD_LIBRARY_PATH="../../../fnalibs/lib64" DYLD_LIBRARY_PATH="../../../fnalibs/osx" mono isometric-park-fna.exe
45
46
47
48
@@ -3,9 +3,9
3 # isometric-park-fna
3 # isometric-park-fna
4
4
5
5
6 As the director of a small state park, your job is to balance conservation, leisure, and fiscal sustainability. At the moment, there's minimal gameplay.
6 As the director of a small state park, your job is to balance conservation, leisure, and fiscal sustainability. Gameplay is still being added.
7
7
8 This is inspired by Maxis' Sim series of games, particularly SimSafari, and Chris Sawyer's Tycoon games. Premise-wise, it more closely resembles SimPark, but I never played it except for a demo. (Alternatively, watch 1990's Sim Games. SO GOOD!)
8 This is inspired by Maxis' Sim series of games, particularly SimSafari, and Chris Sawyer's Tycoon games. Its premise more closely resembles SimPark, but I never played it except for a demo. (Alternatively, watch [1990's Sim Games. SO GOOD!]())
9
9
10 ## Controls ##
10 ## Controls ##
11
11
@@ -13,7 +13,7
13
13
14 ## Overlap with past work ##
14 ## Overlap with past work ##
15
15
16 This game is a total rewrite of the original version in C#. I honestly like the original language and library more (Clojure and Quil), but Quil was starting to struggle with the amount of drawing, and I was hitting the limit of my optimization abilities and available information online. (Another drawback: I also am giving up the browser version, unless people get XNA in the browser working.)
16 This game is a total rewrite of the original version in C#. I honestly like the original language and library more (Clojure and Quil), but Quil was starting to struggle with the amount of drawing, and I was hitting the limit of my optimization abilities and available information online. (Another drawback: I'm also giving up the browser version, unless people get XNA in the browser working.)
17
17
18
18
19 ## Installing and Running ##
19 ## Installing and Running ##
@@ -29,15 +29,97
29
29
30 You can build and run the project using VSCode actions.
30 You can build and run the project using VSCode actions.
31
31
32 ### File Structure ###
33
34 ```
35 .
36 ├── *encompass-cs* ECS library (vendored)
37 ├── **FNA** Graphics and media library
38 ├── **ImGui.NET** GUI library
39 ├── **isometric-park-fna**
40 │   ├── **bin**
41 │   │   ├── **Debug** Debug version
42 │   │   └── **Release** Release version
43 │   ├── *Camera.cs*
44 │   ├── *CellMap.cs*
45 │   ├── **Components** Components that store data on entities.
46 │   ├── **Content**
47 │   │   ├── **DejaVuSerif-BoldItalic.ttf**
48 │   │   ├── **DejaVuSerif-Bold.ttf**
49 │   │   ├── **DroidSans.ttf**
50 │   │   ├── **grammar.json**
51 │   │   ├── **images** images
52 │   │   ├── **iosevka-medium.ttf**
53 │   │   ├── **iosevka-term-extendedmediumitalic.ttf**
54 │   │   ├── **iosevka-term-extendedmedium.ttf**
55 │   │   ├── **iosevka-term-medium.ttf**
56 │   │   ├── **news_items_pregenerated.yaml**
57 │   │   ├── **news_items.yaml**
58 │   │   ├── **part4_tileset_alt.png**
59 │   │   ├── **part4_tileset.png**
60 │   │   ├── **part4_tileset.xcf**
61 │   │   ├── **photos_converted3.png**
62 │   │   ├── **photos_converted.png**
63 │   │   ├── **solid_tileset.png**
64 │   │   └── **typicons.ttf**
65 │   ├── *DllMap.cs* (vendored)
66 │   ├── *DrawVertDeclaration.cs*
67 │   ├── **Engines** Engines
68 │   ├── *FilledRectangle.cs* Helper class for drawing a rectangle.
69 │   ├── *FNAGame.cs* Primary game class.
70 │   ├── **fnalibs** Compiled native libraries.
71 │   │   ├── **lib64**
72 │   │   ├── **osx**
73 │   │   ├── **x64**
74 │   │   └── **x86**
75 │   ├── *ImageMap.cs* Map of images.
76 │   ├── *ImGuiRenderer.cs* Renderer backend for ImGui. (vendored)
77 │   ├── **isometric-park-fna-core.csproj**
78 │   ├── *isometric-park-fna-core.sln*
79 │   ├── **isometric-park-fna.csproj**
80 │   ├── *Line.cs* Class for drawing a line.
81 │   ├── *Logging.cs* Logging class.
82 │   ├── **Messages** Message classes.
83 │   ├── *Quad.cs* Draw a quadrilateral.
84 │   ├── **Renderers** Renderer classes.
85 │   │   ├── *AreaRenderer.cs* Renders areas on the map.
86 │   │   ├── *BudgetWindowRenderer.cs* Renders the budget window.
87 │   │   └── *ImGuiWindowRenderer.cs* Renders ImGUI windows.
88 │   ├── *Simulation.cs* Primary simulation class.
89 │   ├── **Sources.md** List of sources.
90 │   ├── *Tile.cs* Draws tiles.
91 │   ├── **UI** User interface code,, one for each window.
92 │   │   ├── *StyleSet.cs* Utility class for setting multiple style variables and colors at once.
93 │ │ ├── .
94 │ │ ├── .
95 │   │   └── .
96 │   └── **Utils**
97 │   ├── *Extensions.cs* Extension methods.
98 │   ├── *MathUtils.cs* Math utility mentions.
99 │   └── *Node.cs* Simple tree.
100 ├── *isometric-park-fna-core.sln* .NET Core solution.
101 ├── *isometric-park-fna.sln* .NET Framework solution.
102 ├── **README_future.mkd**
103 ├── **README.mkd**
104 ├── **scripts** Helper scripts.
105 │   └── *package.py* Creates packaages.
106 ├── **SpriteFontPlus ** Font library. (Vendored)
107 └── **TODO.taskpaper** Tasks, feature requests, and bugs.
108 ```
109
110 Right now, the largest parts of the code are `UI/`, `Engines/`, `FNAGame.cs` (which
111 still contains a lot of drawing code), and `Simulation.cs`.
112
113
32 ## Acknowledgements ##
114 ## Acknowledgements ##
33
115
34 Art: [Isometric 64x64 Outside Tileset by Yar](https://opengameart.org/content/isometric-64x64-outside-tileset), various images from the Library of Congress and USDA Forest Service
116 Art: [Isometric 64x64 Outside Tileset by Yar](https://opengameart.org/content/isometric-64x64-outside-tileset), various images from the Library of Congress and USDA Forest Service
35 Libraries: [FNA](https://fna-xna.github.io/), [SpriteFontPlus](https://github.com/rds1983/SpriteFontPlus), [Tracery.Net](https://github.com/josh-perry/Tracery.Net), [ImGui.NET](http://imgui.net/), and [Encompass-cs](
117 Libraries: [FNA](https://fna-xna.github.io/), [SpriteFontPlus](https://github.com/rds1983/SpriteFontPlus), [Tracery.Net](https://github.com/josh-perry/Tracery.Net), [ImGui.NET](http://imgui.net/), and [Encompass-cs](http://moonside.games/docs/encompass/)
36 Fonts: Droid Sans, [Iosevka,](https://typeof.net/Iosevka/) [Typicons by Stephen Hutchings](https://www.s-ings.com/typicons/)
118 Fonts: Droid Sans, [Iosevka,](https://typeof.net/Iosevka/) [Typicons by Stephen Hutchings](https://www.s-ings.com/typicons/)
37
119
38 Sources for the procedural generation are documented in Sources.md.
120 Sources for the procedural generation are documented in Sources.md.
39
121
40 Watching Thin Matrix's [video devlogs](https://www.youtube.com/watch?v=90CZ7Q17sls&list=PLRIWtICgwaX1gcSZ8qj8Q473tz7PsNmpR) for Equilinox inspired me to press on. :) Despite some similarities, the design of this game wasn't really inspired by Equilinox. (I've also enjoyed and Thoughtquake's [video devlogs](https://www.youtube.com/user/Thoughtquake/videos) for Cargo Defense and Cliff Harris's Democracy 4 [video devlogs](https://www.youtube.com/user/cliffski2/videos))
122 Watching Thin Matrix's [video devlogs](https://www.youtube.com/watch?v=90CZ7Q17sls&list=PLRIWtICgwaX1gcSZ8qj8Q473tz7PsNmpR) for Equilinox inspired me to press on. :) Despite some similarities, the design of this game wasn't really inspired by Equilinox. (I've also enjoyed Thoughtquake's [video devlogs](https://www.youtube.com/user/Thoughtquake/videos) for Cargo Defense and Cliff Harris' Democracy 4 [video devlogs](https://www.youtube.com/user/cliffski2/videos))
41
123
42 The original versions used art from the [Low Poly Forest Pack](https://devilsworkshop.itch.io/lowpoly-forest-pack) by [Devil's Work.Shop](https://devilsworkshop.itch.io/). (I had converted the models into isometric 2D images, using [this process.](https://www.youtube.com/watch?v=bk0PXMgZgQg))
124 The original versions used art from the [Low Poly Forest Pack](https://devilsworkshop.itch.io/lowpoly-forest-pack) by [Devil's Work.Shop](https://devilsworkshop.itch.io/). (I had converted the models into isometric 2D images, using [this process.](https://www.youtube.com/watch?v=bk0PXMgZgQg))
43
125
@@ -45,5 +127,6
45
127
46 © 2021 Alys S. Brooks
128 © 2021 Alys S. Brooks
47
129
130 I haven't decided on a license.
48
131
49
132
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -20,5 +20,5
20 [assembly: System.Reflection.AssemblyTitleAttribute("SpriteFontPlus")]
20 [assembly: System.Reflection.AssemblyTitleAttribute("SpriteFontPlus")]
21 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
21 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
22
22
23 // Von der MSBuild WriteCodeFragment-Klasse generiert.
23 // Generated by the MSBuild WriteCodeFragment class.
24
24
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -30,8 +30,11
30 - Add tree simulation @milestone(3: Contracts) @done(2021-04-27)
30 - Add tree simulation @milestone(3: Contracts) @done(2021-04-27)
31 - Add contract generation @milestone(3: Contracts) @done(2021-04-12)
31 - Add contract generation @milestone(3: Contracts) @done(2021-04-12)
32 - Outline reserved areas @milestone(3: Contracts) @done(2021-04-09)
32 - Outline reserved areas @milestone(3: Contracts) @done(2021-04-09)
33 - Add company images @milestone(3: Contracts) @maybe
33 - Add company images @milestone(3: Contracts) @maybe @done(2021-05-21)
34 - Contracts should end
35 -
34 Trees:
36 Trees:
37
35 - Add basic maintenance cost @milestone(1: Basic Money) @done(2021-01-27)
38 - Add basic maintenance cost @milestone(1: Basic Money) @done(2021-01-27)
36 - Add basic age simulation
39 - Add basic age simulation
37 - Biodiversity @maybe
40 - Biodiversity @maybe
@@ -98,6 +101,7
98 Structure:
101 Structure:
99 - Add modes @milestone(5: Events)
102 - Add modes @milestone(5: Events)
100 - Refactor stuff out of FNAGame
103 - Refactor stuff out of FNAGame
104 At this point, virtually everything in FNAGame is setting up key Engines or doing drawing
101 - Saving @prototyped @milestone(4: Beginning)
105 - Saving @prototyped @milestone(4: Beginning)
102 - Encompass @maybe @done(2021-04-03)
106 - Encompass @maybe @done(2021-04-03)
103 Currently thinking about a hybrid model where the Simulation class receives a lot of the events from Encompass. so things like Events, Contracts, and Research agreements are handled by Encompass. Perhaps Input, too?
107 Currently thinking about a hybrid model where the Simulation class receives a lot of the events from Encompass. so things like Events, Contracts, and Research agreements are handled by Encompass. Perhaps Input, too?
@@ -108,24 +112,36
108 Technically done
112 Technically done
109 - Decide how to handle ImGUI ref parameters
113 - Decide how to handle ImGUI ref parameters
110 Basically have to decide whether to embrace its style or go toward a more functional approach
114 Basically have to decide whether to embrace its style or go toward a more functional approach
111 - Change conversation to use ImGui
115 - Add Ink @maybe
116 - Add NuGet package
117 - Load .Ink files
118 - Rewrite Dialog to show Ink
119 - SetTextVariable also sets variables within Ink
120 Technically doesn't have to be done this way, but having what would essentially be separate namespaces for Tracery variables and Ink ones seems confusing.
121 - Integrate with Tracery
122 COuld run everything through Tracery or could create an Ink function that calls Tracery
123 - Change conversation to use Encompass @milestone(5: events)
124 - Refactor out common ImGUI patterns
125 - Tooltips
126 - Status indicators (not yet implemented)
127 By status indicators, I mean putting an icon on, say, the Contracts button to indicate a contract is about to expire.
112 - Rearchitect to avoid giving everything access to Simulation
128 - Rearchitect to avoid giving everything access to Simulation
113 - Add a start screen @milestone(4: Beginning)
129 - Add a start screen @milestone(4: Beginning) @done(2021-06-08)
114 - Add a create park dialog @milestone(4: Beginning)
130 - Add a create park dialog @milestone(4: Beginning)
115 - Procgen park names (that player can override)
131 - Procgen park names (that player can override)
116 - Button to generate new name?
132 - Button to generate new name?
117 - Allow player to choose title @maybe
133 - Allow player to choose title @maybe @done(2021-07-29)
118 Some possibilities: Mr., Ms., Mx., Director, Dr., Professor, Miss, Col., Herr Dr. Dr. nothing, custom
134 Some possibilities: Mr., Ms., Mx., Director, Dr., Professor, Miss, Col., Herr Dr. Dr. nothing, custom
119 Might be fun to have tiny acknowledgement of choice — probably dialog only, no mechanical change. (E.g., a researcher might allude to you having a PhD. or an enby character might say something comiserating.)
135 Might be fun to have tiny acknowledgement of choice — probably dialog only, no mechanical change. (E.g., a researcher might allude to you having a PhD. or an enby character might say something comiserating.)
120 - Allow player to choose difficulty
136 - Allow player to choose difficulty @done(2021-07-30)
121 I'm thinking: Easy would be constant subsidy, Medium would be declining subsidy, and Hard would be none.
137 I'm thinking: Easy would be constant subsidy, Medium would be declining subsidy, and Hard would be none.
122 Could name them Benevolent, Austerity, and Hostility? Or Conservationist, Austerity, Libertarian? (Maybe too pointed!) I kind of like describing these as the government's "orientation" or "attitude" toward park.
138 Could name them Benevolent, Austerity, and Hostility? Or Conservationist, Austerity, Libertarian? (Maybe too pointed!) I kind of like describing these as the government's "orientation" or "attitude" toward park.
123 - Allow player to choose profile image @maybe
139 - Allow player to choose profile image @maybe
124 Same style as rest of the game (dithered b&w, at least right now)
140 Same style as rest of the game (dithered b&w, at least right now)
125 - Basic In-game menu @milestone(4: Beginning)
141 - Basic In-game menu @milestone(4: Beginning) @done(2021-06-13)
126 At minimum, New Game, Quit, and Quit to Menu
142 At minimum, New Game, Quit, and Quit to Menu
127 - Graphics options
143 - Graphics options
128 - Add to in-game menu
144 - Add to in-game menu @done(2021-06-13)
129 - Additional in-game menu
145 - Additional in-game menu
130 - Save
146 - Save
131 - Save & Quit
147 - Save & Quit
@@ -134,8 +150,15
134 Accessibility:
150 Accessibility:
135 - Verify contrast
151 - Verify contrast
136 - Option to Increase display size
152 - Option to Increase display size
153 - Add message for font changes @done(2021-06-26)
154 - Relocate fonts to central place @done(2021-06-26)
155 - Remove fonts from DebugWindow?
156 - Adjust window dimensions when font changes
137 - Option to Turn off bad outcomes or disasters @maybe
157 - Option to Turn off bad outcomes or disasters @maybe
138 - Dyslexic-friendly font @maybe
158 - Dyslexic-friendly font @maybe @done(2021-06-26)
159 Cursory research indicates open sans-serif fonts are best,
160 although fonts only help so much. (Monospaced fonts are also cited as good options so Iosevka might already be good enough. Still, I added Roboto.)
161
139 - Screen reader support @maybe
162 - Screen reader support @maybe
140 Would probably be a big undertaking (sort of opposite to the web, where things tend to be accessible unless you start reimplenting things or going more advanced)
163 Would probably be a big undertaking (sort of opposite to the web, where things tend to be accessible unless you start reimplenting things or going more advanced)
141 - Investigate .NET support for screen readers
164 - Investigate .NET support for screen readers
@@ -150,22 +173,26
150 - Look for prior art
173 - Look for prior art
151 - Add a "describe" button/key that speaks the current scene @maybe
174 - Add a "describe" button/key that speaks the current scene @maybe
152 -
175 -
153 - Option to Turn off bad outcomes or disasters?
154 - No fees when contracts break
176 - No fees when contracts break
155 - Contracts go dormant instead of ending.
177 - Contracts go dormant instead of ending.
156 Other QoL things:
178 Other QoL things:
157 - Adjust display size
179 - Adjust display size @done(2021-06-23)
158 - Toggle trees translucency
180 - Toggle trees translucency
159 Right now we hide trees outright, which probably should be limited to debugging
181 Right now we hide trees outright, which probably should be limited to debugging
160 - Right click to center
182 - Right click to center @done(2021-06-06)
161 Internationalization:
183 Internationalization:
162 - Probably won't pay to translate or anything, but should consider setting up the structure @maybe @milestone(4: Beginning)
184 - Probably won't pay to translate or anything, but should consider setting up the structure @maybe @milestone(4: Beginning)
163 If nothing else, might be useful for future projects.
185 If nothing else, might be useful for future projects.
164 Bugs:
186 Bugs:
165 Graphics:
187 Graphics:
166 - Trees jump around when pressing show/hide grid
188 - Trees jump around when pressing show/hide grid
189 - Grids sometimes overlap trees.
167 - Trees sometimes
190 - Trees sometimes
168 - Sometimes framerate jumps to 180-200 fps. (Better than reverse, but kinda weird)
191 - Sometimes framerate jumps to 180-200 fps. (Better than reverse, but kinda weird)
192 - Graphics don't adjust for the resolution
193 - Scroll area @done(2021-06-23)
194 - Ingame Menu @done(2021-06-22)
195 - Main Menu
169 Misc:
196 Misc:
170 - Exits are messy (does Encompass add threading?)
197 - Exits are messy (does Encompass add threading?)
171 [xcb] Unknown sequence number while appending request
198 [xcb] Unknown sequence number while appending request
@@ -1,6 +1,7
1 //------------------------------------------------------------------------------
1 //------------------------------------------------------------------------------
2 // <auto-generated>
2 // <auto-generated>
3 // This code was generated by a tool.
3 // This code was generated by a tool.
4 // Runtime Version:4.0.30319.42000
4 //
5 //
5 // Changes to this file may cause incorrect behavior and will be lost if
6 // Changes to this file may cause incorrect behavior and will be lost if
6 // the code is regenerated.
7 // the code is regenerated.
@@ -21,5 +22,5
21 [assembly: System.Reflection.AssemblyTitleAttribute("EncompassECS.Framework")]
22 [assembly: System.Reflection.AssemblyTitleAttribute("EncompassECS.Framework")]
22 [assembly: System.Reflection.AssemblyVersionAttribute("0.22.0.0")]
23 [assembly: System.Reflection.AssemblyVersionAttribute("0.22.0.0")]
23
24
24 // Von der MSBuild WriteCodeFragment-Klasse generiert.
25 // Generated by the MSBuild WriteCodeFragment class.
25
26
@@ -4,11 +4,6
4 namespace isometricparkfna
4 namespace isometricparkfna
5 {
5 {
6
6
7 //class MapRow
8 //{
9 // public List<MapCell> Columns = new List<MapCell>();
10 //}
11
12 public class CellMap
7 public class CellMap
13 {
8 {
14 public List<List<Cell>> cells;
9 public List<List<Cell>> cells;
@@ -194,7 +189,7
194 {
189 {
195 // public Boolean _hasTree = false;
190 // public Boolean _hasTree = false;
196 public CellStatus status {
191 public CellStatus status {
197 get;
192 get;
198 private set;
193 private set;
199 }
194 }
200
195
@@ -221,4 +216,4
221 }
216 }
222 }
217 }
223 }
218 }
224 } No newline at end of file
219 }
@@ -1,11 +1,11
1 using Encompass;
1 using Encompass;
2
2
3 namespace isometricparkfna.Components {
3 namespace isometricparkfna.Components
4 {
4
5
5 public struct BudgetComponent : IComponent {
6 public struct BudgetComponent : IComponent
6 public Budget currentBudget;
7 {
7 public Budget priorBudget;
8 public Budget currentBudget;
8
9 public Budget priorBudget;
9 }
10 }
10
11 }
11 }
@@ -1,12 +1,12
1 using Encompass;
1 using Encompass;
2
2
3 namespace isometricparkfna.Components {
3 namespace isometricparkfna.Components
4 {
4
5
5 public struct BudgetLineComponent : IComponent {
6 public struct BudgetLineComponent : IComponent
7 {
6
8
7 public string category;
9 public string category;
8 public decimal amount;
10 public decimal amount;
9
11 }
10 }
11
12 }
12 }
@@ -1,36 +1,38
1 using Encompass;
1 using Encompass;
2
2
3 namespace isometricparkfna.Components {
3 namespace isometricparkfna.Components
4 {
4
5
5 public struct TreeDeltaComponent : IComponent
6 public struct TreeDeltaComponent : IComponent
6 {
7 {
7 public int deltaTrees;
8 public int deltaTrees;
8
9
9 public string deltaTreesName {
10 public string deltaTreesName
10 get {
11 {
11 if (deltaTrees <= -18) {
12 get
12 return "Unsustainable";
13 {
13 }
14 if (deltaTrees <= -18)
14 else if (MathUtils.BetweenExclusive(deltaTrees, -18, -6))
15 {
15 {
16 return "Unsustainable";
16 return "Moderately unsustainable";
17 }
17 }
18 else if (MathUtils.BetweenExclusive(deltaTrees, -18, -6))
18 else if (MathUtils.Between(deltaTrees, -6, 0))
19 {
19 {
20 return "Moderately unsustainable";
20 return "Somewhat unsustainable";
21 }
21 }
22 else if (MathUtils.Between(deltaTrees, -6, 0))
22 else if (deltaTrees == 0)
23 {
23 {
24 return "Somewhat unsustainable";
24 return "Break even";
25 }
25 }
26 else if (deltaTrees == 0)
26 else if (deltaTrees > 0)
27 {
27 {
28 return "Break even";
28 return "Restoration";
29 }
29 }
30 else if (deltaTrees > 0)
30
31 {
31 return "???";
32 return "Restoration";
32
33 }
33 }
34 return "???";
34 }
35 }
35 }
36 }
37 }
36 }
38 }
@@ -32,6 +32,8
32 "Milton", "Coltrane", "Kim", "Lindgren", "Kerry", "Harris"],
32 "Milton", "Coltrane", "Kim", "Lindgren", "Kerry", "Harris"],
33 "greeting": [ "Hi", "Hello", "Greetings" ],
33 "greeting": [ "Hi", "Hello", "Greetings" ],
34 "addressGreeting": "#greeting#, #name#",
34 "addressGreeting": "#greeting#, #name#",
35 "addressGreetingFormal": "#greeting#, #playerTitle# #playerFormal#",
36 "addressGreetingCasual": "#greeting#, #playerCasual#",
35 "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ],
37 "howdoing": [ "I'm good.", "Fine", "Alright, I guess." ],
36 "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas",
38 "city": ["Milwaukee", "Chicago", "Washington", "Minneapolis", "Dallas",
37 "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe",
39 "Oklahoma City", "Boston", "Los Angeles", "Portland", "Santa Fe",
@@ -1129,6 +1131,16
1129 "Bend", "Rock", "Spring", "Whitting"],
1131 "Bend", "Rock", "Spring", "Whitting"],
1130 "town_name_adjectives": ["Little", "Big", "Royal", "Green", "Windy",
1132 "town_name_adjectives": ["Little", "Big", "Royal", "Green", "Windy",
1131 "Rocky", "Red", "Violet", "Wild"],
1133 "Rocky", "Red", "Violet", "Wild"],
1134 "park_name_adjectives": ["Little", "Big", "Green", "Windy", "Rolling",
1135 "Meandering", "Red", "Violet", "Wild", "Emerald", "Whispering"],
1136 "park_name_nouns": ["Hill", "Mound", "Wood", "Morraine", "Ridge", "Creek", "Meadow", "Willow",
1137 "Peak", "Valley"],
1138 "park_name_number": ["1000", "100", "20", "Four", "Nine", "Seven", "10,000"],
1139 "park_name": ["#park_name_adjectives# #park_name_nouns# State Park",
1140 "#park_name_adjectives# #park_name_nouns.s# State Park",
1141 "#park_name_number# #park_name_nouns.s# State Park",
1142 "#park_name_adjectives# #park_name_nouns# Park",
1143 "#park_name_adjectives# #park_name_nouns# State Forest"],
1132 "occupation": ["shift supervisor", "towtruck operator",
1144 "occupation": ["shift supervisor", "towtruck operator",
1133 "truck driver", "truck driver", "truck driver",
1145 "truck driver", "truck driver", "truck driver",
1134 "server", "server", "server", "telemarketer",
1146 "server", "server", "server", "telemarketer",
@@ -1136,8 +1148,9
1136 "librarian", "professor", "marketer", "fishmonger",
1148 "librarian", "professor", "marketer", "fishmonger",
1137 "programmer", "union organizer", "filmmaker", "medium",
1149 "programmer", "union organizer", "filmmaker", "medium",
1138 "drag performer", "lineman for the county", "steelworker",
1150 "drag performer", "lineman for the county", "steelworker",
1139 "caddy", "sex worker", "baker", "line cook"],
1151 "caddy", "sex worker", "baker", "line cook", "nurse", "nurse", "welder",
1140 "book_descriptor": ["history", "travelogue", "story", "saga", "tale", "reminiscings"],
1152 "bookbinder"],
1153 "book_descriptor": ["history", "anthology", "travelogue", "story", "saga", "tale", "reminiscings"],
1141 "noun": [
1154 "noun": [
1142 "Armour", "Barrymore", "Cabot", "Catholicism", "Chihuahua",
1155 "Armour", "Barrymore", "Cabot", "Catholicism", "Chihuahua",
1143 "Christianity", "Easter", "Frenchman", "Lowry", "Mayer",
1156 "Christianity", "Easter", "Frenchman", "Lowry", "Mayer",
@@ -1,74 +1,105
1
2 using System.IO;
1
3
2 using Microsoft.Xna.Framework.Input;
4 using Microsoft.Xna.Framework.Input;
3
5 using Newtonsoft.Json;
4 using Encompass;
6 using Encompass;
5
7
6 using isometricparkfna.Messages;
8 using isometricparkfna.Messages;
7 using isometricparkfna.Components;
9 using isometricparkfna.Components;
8
10
9 namespace isometricparkfna.Engines {
11 namespace isometricparkfna.Engines
12 {
10
13
11 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
12 typeof(ToggleVisibilityMessage))]
13 [Reads(typeof(AreaComponent))]
14 class GameBridgeEngine : Engine
15 {
16
14
17 public FNAGame game;
15 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
16 typeof(GameStateMessage),
17 typeof(ToggleVisibilityMessage),
18 typeof(SetResolutionMessage),
19 typeof(SetFontMessage))]
20 [Reads(typeof(AreaComponent),
21 typeof(ContractStatusComponent))]
22 class GameBridgeEngine : Engine
23 {
18
24
19 public GameBridgeEngine(FNAGame game) {
25 public FNAGame game;
20 this.game = game;
21 }
22
26
23 public override void Update(double dt)
27 public GameBridgeEngine(FNAGame game)
24 {
28 {
29 this.game = game;
30 }
31
32 public override void Update(double dt)
33 {
25
34
26 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowTypeMessage>())
35 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowTypeMessage>())
27 {
36 {
28 switch (windowMessage.Window) {
37 switch (windowMessage.Window)
29 case Window.Debug:
38 {
30 game.show_another_window = !game.show_another_window;
39 case Window.Debug:
31 break;
40 game.show_another_window = !game.show_another_window;
32 case Window.Budget:
41 break;
33 game.showBudget = !game.showBudget;
42 case Window.Budget:
34 break;
43 game.showBudget = !game.showBudget;
35 case Window.Forest:
44 break;
36 game.showForest = !game.showForest;
45 case Window.Forest:
37 break;
46 game.showForest = !game.showForest;
38 case Window.News:
47 break;
39 game.showNews = !game.showNews;
48 case Window.News:
40 break;
49 game.showNews = !game.showNews;
50 break;
51
52 }
53 }
54 foreach (ref readonly var visibilityMessage in ReadMessages<ToggleVisibilityMessage>())
55 {
41
56
42 }
57 switch (visibilityMessage.Element)
43 }
58 {
44 foreach (ref readonly var visibilityMessage in ReadMessages<ToggleVisibilityMessage>())
59 case Element.Grid:
45 {
60 game.showGrid = !game.showGrid;
46
61 break;
47 switch (visibilityMessage.Element) {
62 case Element.Trees:
48 case Element.Grid:
63 game.showTrees = !game.showTrees;
49 game.showGrid = !game.showGrid;
64 break;
50 break;
65 }
51 case Element.Trees:
66 }
52 game.showTrees = !game.showTrees;
67 foreach (ref readonly var stateMessage in ReadMessages<GameStateMessage>())
53 break;
68 {
54 }
69 game.isPlaying = stateMessage.isPlaying;
55 }
70 }
71 foreach (ref readonly var resolutionMessage in ReadMessages<SetResolutionMessage>())
72 {
73 game.setResolution(resolutionMessage.resolution,
74 resolutionMessage.fullscreen);
75
76 }
77 foreach (ref readonly var fontMessage in ReadMessages<SetFontMessage>())
78 {
79 game.setFont(fontMessage.fontName, fontMessage.fontSize);
80 Options.writeOptions(fontMessage.fontName, fontMessage.fontSize);
81
82 }
56
83
57 game.in_zone = false;
84 game.in_zone = false;
58 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
85 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
59 {
86 {
60 var areaComponent = GetComponent<AreaComponent>(entity);
87 var areaComponent = GetComponent<AreaComponent>(entity);
61 foreach (var square in areaComponent.squares)
88 var contractStatusComponent = GetComponent<ContractStatusComponent>(entity);
62 {
89 foreach (var square in areaComponent.squares)
63 if (game.mouseGrid == square)
90 {
64 {
91 if (game.mouseGrid == square)
65 game.in_zone = true;
92 {
66 }
93 game.in_zone = true;
67 }
94 if (contractStatusComponent.status == ContractStatus.Active)
68
95 {
69 }
96 game.in_active_zone = true;
97 }
98 }
99 }
70
100
71 }
101 }
72 }
73
102
74 }
103 }
104 }
105 } No newline at end of file
@@ -2,8 +2,11
2 using Encompass;
2 using Encompass;
3 using System.Linq;
3 using System.Linq;
4
4
5 using ImGuiNET;
6
5 using isometricparkfna.Messages;
7 using isometricparkfna.Messages;
6 using isometricparkfna.Components;
8 using isometricparkfna.Components;
9 using isometricparkfna.UI;
7
10
8 namespace isometricparkfna.Engines {
11 namespace isometricparkfna.Engines {
9
12
@@ -11,13 +14,21
11 typeof(ToggleWindowTypeMessage),
14 typeof(ToggleWindowTypeMessage),
12 typeof(ChangeContractStatusMessage),
15 typeof(ChangeContractStatusMessage),
13 typeof(SelectMessage),
16 typeof(SelectMessage),
14 typeof(JumpCameraMessage))]
17 typeof(JumpCameraMessage),
18 typeof(GameStateMessage),
19 typeof(GameStateMessage),
20 typeof(SetResolutionMessage),
21 typeof(SetFontMessage),
22 typeof(SetTrespassingPolicyMessage),
23 typeof(SpawnGameMessage),
24 typeof(SetTextVariableMessage))]
15 [Reads(typeof(VisibilityComponent),
25 [Reads(typeof(VisibilityComponent),
16 typeof(WindowTypeComponent)
26 typeof(WindowTypeComponent),
27 typeof(TrespassingPolicyComponent)
17 //, typeof(SelectedComponent)
28 //, typeof(SelectedComponent)
18 )]
29 )]
19 // [Writes(typeof(SelectedComponent))]
30 // [Writes(typeof(SelectedComponent))]
20 public class ImGuiWindowBridgeEngine : Engine
31 public class ImGuiWindowBridgeEngine : Engine
21 {
32 {
22
33
23 public List<ToggleWindowMessage> messages;
34 public List<ToggleWindowMessage> messages;
@@ -25,24 +36,48
25 public List<ChangeContractStatusMessage> contractStatusMessages;
36 public List<ChangeContractStatusMessage> contractStatusMessages;
26 public List<SelectMessage> selectedMessages;
37 public List<SelectMessage> selectedMessages;
27 public List<JumpCameraMessage> jumpCameraMessages;
38 public List<JumpCameraMessage> jumpCameraMessages;
39 public List<GameStateMessage> gameStateMessages;
40 public List<SetResolutionMessage> resolutionMessages;
41 public List<SetFontMessage> fontMessages;
42 public List<SetTrespassingPolicyMessage> trespassingPolicyMessages;
43 public List<SpawnGameMessage> spawnGameMessages;
44 public List<SetTextVariableMessage> setTextVariableMessages;
28
45
29 bool showBudget {get;}
46 bool showBudget {get;}
30 bool showForest {get;}
47 bool showForest {get;}
31 bool showNews {get;}
48 bool showNews {get;}
32 bool showGrid {get;}
49 bool showGrid {get;}
33 bool showTrees {get;}
50 bool showTrees {get;}
34
51
35 public Dictionary<Window, bool> windowStatuses {get;}
52 public Dictionary<Window, bool> windowStatuses {get;}
36
53
54 public ImFontPtr font;
55 public ImFontPtr italicFont;
56 private DebugWindow debugWindow;
37
57
38 public ImGuiWindowBridgeEngine()
58
59 public ImGuiWindowBridgeEngine(DebugWindow debugWindow,
60 ImFontPtr font, ImFontPtr italicFont)
39 {
61 {
40 this.messages = new List<ToggleWindowMessage>();
62 this.messages = new List<ToggleWindowMessage>();
41 this.typeMessages = new List<ToggleWindowTypeMessage>();
63 this.typeMessages = new List<ToggleWindowTypeMessage>();
42 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
64 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
43 this.selectedMessages = new List<SelectMessage>();
65 this.selectedMessages = new List<SelectMessage>();
44 this.jumpCameraMessages = new List<JumpCameraMessage>();
66 this.jumpCameraMessages = new List<JumpCameraMessage>();
67 this.gameStateMessages = new List<GameStateMessage>();
68 this.resolutionMessages = new List<SetResolutionMessage>();
69 this.fontMessages = new List<SetFontMessage>();
70 this.trespassingPolicyMessages = new List<SetTrespassingPolicyMessage>();
71 this.spawnGameMessages = new List<SpawnGameMessage>();
72 this.setTextVariableMessages = new List<SetTextVariableMessage>();
45 this.windowStatuses = new Dictionary<Window, bool>();
73 this.windowStatuses = new Dictionary<Window, bool>();
74
75
76 this.font = font;
77 this.italicFont = italicFont;
78 this.debugWindow = debugWindow;
79
80
46 //Prepopulate:
81 //Prepopulate:
47 foreach(var type in System.Enum.GetValues(typeof(Window)))
82 foreach(var type in System.Enum.GetValues(typeof(Window)))
48 {
83 {
@@ -50,7 +85,7
50 }
85 }
51 }
86 }
52
87
53 public override void Update(double dt)
88 public override void Update(double dt)
54 {
89 {
55 foreach(var message in this.messages)
90 foreach(var message in this.messages)
56 {
91 {
@@ -74,12 +109,57
74 SendMessage(message);
109 SendMessage(message);
75 }
110 }
76
111
112 foreach(var message in this.gameStateMessages)
113 {
114 SendMessage(message);
115 }
116 foreach(var message in this.resolutionMessages)
117 {
118 SendMessage(message);
119 }
120 foreach(var message in this.fontMessages)
121 {
122 this.font = debugWindow.addFont(message.fontName,
123 message.fontSize, false);
124
125 debugWindow.setMonoFont(this.font);
126
127 this.italicFont = debugWindow.addFont(message.fontName,
128 message.fontSize, true);
129
130 debugWindow.setItalicFont(this.italicFont);
131 SendMessage(message);
132
133 OptionsWindow.setFont(message.fontName,
134 message.fontSize);
135 }
136
137 foreach (var message in this.trespassingPolicyMessages)
138 {
139 SendMessage(message);
140 }
141
142 foreach (var message in this.spawnGameMessages)
143 {
144 SendMessage(message);
145 }
146
147 //This may need to be moved up.
148 foreach (var message in this.setTextVariableMessages)
149 {
150 SendMessage(message);
151 }
152
153
154
155
77
156
78 foreach(var entity in ReadEntities<WindowTypeComponent>())
157 foreach(var entity in ReadEntities<WindowTypeComponent>())
79 {
158 {
80 var type = GetComponent<WindowTypeComponent>(entity).type;
159 var type = GetComponent<WindowTypeComponent>(entity).type;
81 var visibility = GetComponent<VisibilityComponent>(entity).visible;
160 var visibility = GetComponent<VisibilityComponent>(entity).visible;
82 windowStatuses[type] = visibility;
161 windowStatuses[type] = visibility;
162
83 }
163 }
84
164
85 this.messages.Clear();
165 this.messages.Clear();
@@ -87,6 +167,12
87 this.contractStatusMessages.Clear();
167 this.contractStatusMessages.Clear();
88 this.selectedMessages.Clear();
168 this.selectedMessages.Clear();
89 this.jumpCameraMessages.Clear();
169 this.jumpCameraMessages.Clear();
170 this.gameStateMessages.Clear();
171 this.resolutionMessages.Clear();
172 this.fontMessages.Clear();
173 this.trespassingPolicyMessages.Clear();
174 this.spawnGameMessages.Clear();
175 this.setTextVariableMessages.Clear();
90 }
176 }
91 }
177 }
92 }
178 }
@@ -20,8 +20,10
20 typeof(ToggleWindowMessage), //???
20 typeof(ToggleWindowMessage), //???
21 typeof(ToggleVisibilityMessage),
21 typeof(ToggleVisibilityMessage),
22 typeof(TogglePauseMessage),
22 typeof(TogglePauseMessage),
23 typeof(GameRateMessage))]
23 typeof(GameRateMessage),
24 typeof(GameStateMessage))]
24 [Reads(typeof(WindowTypeComponent),
25 [Reads(typeof(WindowTypeComponent),
26 typeof(GameStateComponent),
25 typeof(VisibilityComponent))]
27 typeof(VisibilityComponent))]
26 public class InputEngine : Engine
28 public class InputEngine : Engine
27 {
29 {
@@ -29,23 +31,20
29 private MouseState mousePrev;
31 private MouseState mousePrev;
30
32
31 private GraphicsDevice graphicsDevice;
33 private GraphicsDevice graphicsDevice;
34 private GraphicsDeviceManager gdm;
32 private Camera camera;
35 private Camera camera;
33
36
34 //Area to ignore:
37 //Area to ignore:
35 private int menuBarHeight;
38 private int menuBarHeight;
36
39
37 private int viewWidth;
40 public InputEngine(int menuBarHeight, Camera camera,
38 private int viewHeight;
41 GraphicsDeviceManager gdm) {
39
40 public InputEngine(int menuBarHeight, int viewWidth, int viewHeight, Camera camera,
41 GraphicsDevice graphicsDevice) {
42 //initialize to blank for now
42 //initialize to blank for now
43 this.keyboardPrev = new KeyboardState();
43 this.keyboardPrev = new KeyboardState();
44 this.menuBarHeight = menuBarHeight;
44 this.menuBarHeight = menuBarHeight;
45 this.viewWidth = viewWidth;
46 this.viewHeight = viewHeight;
47 this.camera = camera;
45 this.camera = camera;
48 this.graphicsDevice = graphicsDevice;
46 this.gdm = gdm;
47 this.graphicsDevice = gdm.GraphicsDevice;
49 }
48 }
50
49
51 public override void Update(double dt) {
50 public override void Update(double dt) {
@@ -55,122 +54,144
55 var original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y),
54 var original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y),
56 Matrix.Invert(this.camera.get_transformation(this.graphicsDevice)));
55 Matrix.Invert(this.camera.get_transformation(this.graphicsDevice)));
57
56
58 #region camera_movement_keys
57 bool isPlaying = false;
59 if (keyboardCur.IsKeyDown(Keys.Down))
60 {
61 SendMessage(new MoveCameraMessage{ Movement = new Vector2(0, 2)});
62 }
63 if (keyboardCur.IsKeyDown(Keys.Up))
64 {
65 SendMessage(new MoveCameraMessage{ Movement = new Vector2(0, -2)});
66
58
67 }
59 var viewWidth = gdm.PreferredBackBufferWidth;
68 if (keyboardCur.IsKeyDown(Keys.Left))
60 var viewHeight = gdm.PreferredBackBufferHeight;
69 {
70 SendMessage(new MoveCameraMessage{ Movement = new Vector2(-2, 0)});
71
61
72 }
62 foreach (var entity in ReadEntities<GameStateComponent>())
73 if (keyboardCur.IsKeyDown(Keys.Right))
74 {
75 SendMessage(new MoveCameraMessage {Movement = new Vector2(2, 0)});
76
77 }
78 if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract))
79 {
80 SendMessage(new ZoomCameraMessage {ZoomIn = false});
81 }
82 else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add))
83 {
63 {
84 SendMessage(new ZoomCameraMessage {ZoomIn = true});
64 var state = GetComponent<GameStateComponent>(entity).isPlaying;
85 }
65 isPlaying = state;
86 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
87 {
88 SendMessage(new JumpCameraMessage {Movement = Vector2.Zero });
89 }
90 #endregion camera_movement_keys
91 #region gamerate_keys
92 if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P) )
93 {
94
95 SendMessage(new TogglePauseMessage());
96
97 }
98 if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0) )
99 {
100 SendMessage(new TogglePauseMessage());
101
102 }
103 if (keyboardCur.IsKeyDown(Keys.D1) && keyboardPrev.IsKeyUp(Keys.D1) )
104 {
105 SendMessage(new GameRateMessage {
106 paused = false,
107 rate = 0});
108 }
109 if (keyboardCur.IsKeyDown(Keys.D2) && keyboardPrev.IsKeyUp(Keys.D2) )
110 {
111 SendMessage(new GameRateMessage {
112 paused = false,
113 rate = 1});
114 }
66 }
115 if (keyboardCur.IsKeyDown(Keys.D3) && keyboardPrev.IsKeyUp(Keys.D3) )
116 {
117 SendMessage(new GameRateMessage {
118 paused = false,
119 rate = 2});
120 }
121 if (keyboardCur.IsKeyDown(Keys.D4) && keyboardPrev.IsKeyUp(Keys.D4) )
122 {
123 SendMessage(new GameRateMessage {
124 paused = false,
125 rate = 3});
126 }
127 #if DEBUG
128 if (keyboardCur.IsKeyDown(Keys.D5) && keyboardPrev.IsKeyUp(Keys.D5) )
129 {
130 SendMessage(new GameRateMessage {
131 paused = false,
132 rate = 4});
133 }
134 #endif
135 #endregion gamerate_keys
136 #region misc_keys
137 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash))
138 {
139 SendMessage(new ToggleWindowTypeMessage{Window = Window.Debug});
140
67
141 }
68 if (isPlaying)
142 if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B))
143 {
69 {
144 SendMessage(new ToggleWindowTypeMessage{Window = Window.Budget});
70 #region camera_movement_keys
71 if (keyboardCur.IsKeyDown(Keys.Down))
72 {
73 SendMessage(new MoveCameraMessage{ Movement = new Vector2(0, 2)});
74 }
75 if (keyboardCur.IsKeyDown(Keys.Up))
76 {
77 SendMessage(new MoveCameraMessage{ Movement = new Vector2(0, -2)});
78
79 }
80 if (keyboardCur.IsKeyDown(Keys.Left))
81 {
82 SendMessage(new MoveCameraMessage{ Movement = new Vector2(-2, 0)});
83
84 }
85 if (keyboardCur.IsKeyDown(Keys.Right))
86 {
87 SendMessage(new MoveCameraMessage {Movement = new Vector2(2, 0)});
145
88
146 }
89 }
147 if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F))
90 if (keyboardCur.IsKeyDown(Keys.Subtract) && keyboardPrev.IsKeyUp(Keys.Subtract))
148 {
91 {
149 SendMessage(new ToggleWindowTypeMessage{Window = Window.Forest});
92 SendMessage(new ZoomCameraMessage {ZoomIn = false});
93 }
94 else if (keyboardCur.IsKeyDown(Keys.Add) && keyboardPrev.IsKeyUp(Keys.Add))
95 {
96 SendMessage(new ZoomCameraMessage {ZoomIn = true});
97 }
98 if (keyboardCur.IsKeyDown(Keys.C) && keyboardPrev.IsKeyUp(Keys.C))
99 {
100 SendMessage(new JumpCameraMessage {Movement = Vector2.Zero });
101 }
102 #endregion camera_movement_keys
103 #region gamerate_keys
104 if (keyboardCur.IsKeyDown(Keys.P) && keyboardPrev.IsKeyUp(Keys.P) )
105 {
106
107 SendMessage(new TogglePauseMessage());
108
109 }
110 if (keyboardCur.IsKeyDown(Keys.D0) && keyboardPrev.IsKeyUp(Keys.D0) )
111 {
112 SendMessage(new TogglePauseMessage());
150
113
151 }
114 }
152 if (keyboardCur.IsKeyDown(Keys.N) && keyboardPrev.IsKeyUp(Keys.N))
115 if (keyboardCur.IsKeyDown(Keys.D1) && keyboardPrev.IsKeyUp(Keys.D1) )
153 {
116 {
154 SendMessage(new ToggleWindowTypeMessage{Window = Window.News});
117 SendMessage(new GameRateMessage {
118 paused = false,
119 rate = 0});
120 }
121 if (keyboardCur.IsKeyDown(Keys.D2) && keyboardPrev.IsKeyUp(Keys.D2) )
122 {
123 SendMessage(new GameRateMessage {
124 paused = false,
125 rate = 1});
126 }
127 if (keyboardCur.IsKeyDown(Keys.D3) && keyboardPrev.IsKeyUp(Keys.D3) )
128 {
129 SendMessage(new GameRateMessage {
130 paused = false,
131 rate = 2});
132 }
133 if (keyboardCur.IsKeyDown(Keys.D4) && keyboardPrev.IsKeyUp(Keys.D4) )
134 {
135 SendMessage(new GameRateMessage {
136 paused = false,
137 rate = 3});
138 }
139 #if DEBUG
140 if (keyboardCur.IsKeyDown(Keys.D5) && keyboardPrev.IsKeyUp(Keys.D5) )
141 {
142 SendMessage(new GameRateMessage {
143 paused = false,
144 rate = 4});
145 }
146 #endif
147 #endregion gamerate_keys
148 #region misc_keys
149 if (keyboardCur.IsKeyDown(Keys.B) && keyboardPrev.IsKeyUp(Keys.B))
150 {
151 SendMessage(new ToggleWindowTypeMessage{Window = Window.Budget});
155
152
156 }
153 }
157 if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O))
154 if (keyboardCur.IsKeyDown(Keys.F) && keyboardPrev.IsKeyUp(Keys.F))
155 {
156 SendMessage(new ToggleWindowTypeMessage{Window = Window.Forest});
157
158 }
159 if (keyboardCur.IsKeyDown(Keys.N) && keyboardPrev.IsKeyUp(Keys.N))
160 {
161 SendMessage(new ToggleWindowTypeMessage{Window = Window.News});
162
163 }
164 if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O))
165 {
166 Logging.Trace("Contracts toggled.");
167 SendMessage(new ToggleWindowTypeMessage{Window = Window.Contracts});
168 }
169 if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G))
170 {
171 SendMessage(new ToggleVisibilityMessage{Element = Element.Grid});
172
173 }
174 #if DEBUG
175 if (keyboardCur.IsKeyDown(Keys.T) && keyboardPrev.IsKeyUp(Keys.T))
176 {
177 SendMessage(new ToggleVisibilityMessage{Element = Element.Trees});
178
179 }
180 #endif
181
182 if (keyboardCur.IsKeyDown(Keys.Escape) && keyboardPrev.IsKeyUp(Keys.Escape))
158 {
183 {
159 Logging.Trace("Contracts toggled.");
184 // SendMessage(new TogglePauseMessage());
160 SendMessage(new ToggleWindowTypeMessage{Window = Window.Contracts});
185 SendMessage(new ToggleWindowTypeMessage{Window = Window.InGameMenu});
161 }
186 SendMessage(new GameRateMessage { paused = true, rate = null });
162 if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G))
163 {
164 SendMessage(new ToggleVisibilityMessage{Element = Element.Grid});
165
166 }
187 }
167 #if DEBUG
188 }
168 if (keyboardCur.IsKeyDown(Keys.T) && keyboardPrev.IsKeyUp(Keys.T))
169 {
170 SendMessage(new ToggleVisibilityMessage{Element = Element.Trees});
171
189
172 }
190 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash))
173 #endif
191 {
192 SendMessage(new ToggleWindowTypeMessage{Window = Window.Debug});
193
194 }
174
195
175 if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q))
196 if (keyboardCur.IsKeyDown(Keys.Q) && keyboardPrev.IsKeyUp(Keys.Q))
176 {
197 {
@@ -185,7 +206,7
185 {
206 {
186 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)});
207 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, -4)});
187 }
208 }
188 else if (MathUtils.BetweenExclusive(mouseCur.Y, (this.viewHeight - 50 -menuBarHeight), this.viewHeight-menuBarHeight))
209 else if (MathUtils.BetweenExclusive(mouseCur.Y, (viewHeight - 50 -menuBarHeight), viewHeight-menuBarHeight))
189 {
210 {
190 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)});
211 SendMessage(new MoveCameraMessage {Movement = new Vector2(0, 4)});
191 }
212 }
@@ -193,7 +214,7
193 {
214 {
194 SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)});
215 SendMessage(new MoveCameraMessage {Movement = new Vector2(-4, 0)});
195 }
216 }
196 else if (MathUtils.BetweenExclusive(mouseCur.X, (this.viewWidth - 50), this.viewWidth))
217 else if (MathUtils.BetweenExclusive(mouseCur.X, (viewWidth - 50), viewWidth))
197 {
218 {
198 SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)});
219 SendMessage(new MoveCameraMessage {Movement = new Vector2(4, 0)});
199 }
220 }
@@ -6,78 +6,88
6 using isometricparkfna.Messages;
6 using isometricparkfna.Messages;
7 using isometricparkfna.Components;
7 using isometricparkfna.Components;
8
8
9 namespace isometricparkfna.Engines {
9 namespace isometricparkfna.Engines
10 {
10
11
11 [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))]
12 [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))]
12 [Sends(typeof(SpawnContractMessage), typeof(TickMessage))]
13 [Sends(typeof(SpawnContractMessage), typeof(TickMessage))]
13 [Reads(typeof(AreaComponent),
14 [Reads(typeof(AreaComponent),
14 typeof(BudgetComponent),
15 typeof(BudgetComponent),
15 typeof(BudgetLineComponent),
16 typeof(BudgetLineComponent),
16 typeof(ContractStatusComponent),
17 typeof(ContractStatusComponent),
17 typeof(TreeDeltaComponent))]
18 typeof(TreeDeltaComponent))]
18 [Writes(typeof(BudgetComponent))]
19 [Writes(typeof(BudgetComponent))]
19 public class SimulationBridgeEngine : Engine
20 public class SimulationBridgeEngine : Engine
20 {
21 {
21 public Simulation simulation;
22 public Simulation simulation;
22 private int ticksToSend;
23 private int ticksToSend;
23 private Random random_generator;
24 private Random random_generator;
24
25
25 public SimulationBridgeEngine(Simulation simulation)
26 public SimulationBridgeEngine(Simulation simulation)
26 {
27 {
27 this.simulation = simulation;
28 this.simulation = simulation;
28 this.random_generator = new Random();
29 this.random_generator = new Random();
29 }
30 }
30
31
31 public int addTick() {
32 public int addTick()
32 this.ticksToSend++;
33 {
33 return ticksToSend;
34 this.ticksToSend++;
34 }
35 return ticksToSend;
35
36 }
36 public override void Update(double dt)
37 {
38
37
39 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
38 public override void Update(double dt)
40 {
39 {
41 ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity);
40
41 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
42 {
43 ref readonly var budgetComponent = ref GetComponent<BudgetComponent>(entity);
42
44
43 SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget,
45 SetComponent(entity, new BudgetComponent
44 priorBudget = this.simulation.previousBudget});
46 {
45 }
47 currentBudget = this.simulation.latestBudget,
46
48 priorBudget = this.simulation.previousBudget
47 foreach (ref readonly var message in ReadMessages<GameRateMessage>())
49 });
48 {
50 }
49 this.simulation.paused = message.paused;
50 this.simulation.setRate(message.rate);
51 }
52
51
53 foreach (ref readonly var message in ReadMessages<TogglePauseMessage>())
52 foreach (ref readonly var message in ReadMessages<GameRateMessage>())
54 {
53 {
55 this.simulation.paused = !this.simulation.paused;
54 this.simulation.paused = message.paused;
56 }
55 if (message.rate != null)
56 {
57 this.simulation.setRate(message.rate ?? 0);
58 }
59 }
57
60
58 decimal new_contract_amount = 0M;
61 foreach (ref readonly var message in ReadMessages<TogglePauseMessage>())
62 {
63 this.simulation.paused = !this.simulation.paused;
64 }
59
65
60 foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>())
66 decimal new_contract_amount = 0M;
61 {
67 decimal new_enforcement_amount = 0M;
62 ref readonly var budgetComponent = ref GetComponent<BudgetLineComponent>(entity);
68 // decimal new_upkeep_amount = 0M;
63 var status = GetComponent<ContractStatusComponent>(entity).status;
64
69
65 // SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget,
70 foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>())
66 // priorBudget = this.simulation.previousBudget});
71 {
67 switch (budgetComponent.category)
72 ref readonly var budgetComponent = ref GetComponent<BudgetLineComponent>(entity);
68 {
69 case "Contracts":
70
73
71 if (status == ContractStatus.Accepted)
74 // SetComponent(entity, new BudgetComponent{currentBudget = this.simulation.latestBudget,
72 {
75 // priorBudget = this.simulation.previousBudget});
73 new_contract_amount += budgetComponent.amount;
76 switch (budgetComponent.category)
74 }
77 {
75 break;
78 case "Contracts":
76 }
79 var status = GetComponent<ContractStatusComponent>(entity).status;
80 if (status == ContractStatus.Accepted)
81 {
82 new_contract_amount += budgetComponent.amount;
83 }
84 break;
85 case "Enforcement":
86 new_enforcement_amount += budgetComponent.amount;
87 break;
88 }
77
89
78 }
90 }
79
80
81
91
82 if (this.ticksToSend > 0)
92 if (this.ticksToSend > 0)
83 {
93 {
@@ -86,10 +96,12
86 }
96 }
87 for (int i = ticksToSend; i > 0; i--)
97 for (int i = ticksToSend; i > 0; i--)
88 {
98 {
89 SendMessage<TickMessage>(new TickMessage{});
99 SendMessage<TickMessage>(new TickMessage { });
90 //For now:
100 //For now:
91 SendMessage<SpawnContractMessage>(new SpawnContractMessage{ //max_squares = 100,
101 SendMessage<SpawnContractMessage>(new SpawnContractMessage
92 name = string.Format("#logging_company.capitalizeAll# {0}", this.simulation.DateTime.ToShortDateString()) });
102 { //max_squares = 100,
103 name = string.Format("#logging_company.capitalizeAll# {0}", this.simulation.DateTime.ToShortDateString())
104 });
93
105
94
106
95 foreach (ref readonly var entity in ReadEntities<TreeDeltaComponent>())
107 foreach (ref readonly var entity in ReadEntities<TreeDeltaComponent>())
@@ -101,13 +113,13
101 if (status == ContractStatus.Accepted)
113 if (status == ContractStatus.Accepted)
102 {
114 {
103 var removed = 0;
115 var removed = 0;
104 var tree_squares = area.squares.Where((square) => simulation.map.cells[(int)square.X][(int)square.Y].hasTree);
116 var tree_squares = area.squares.Where((square) => simulation.map.cells[(int)square.X][(int)square.Y].hasTree);
105 var to_remove = -delta.deltaTrees;
117 var to_remove = -delta.deltaTrees;
106
118
107 //calculate the probability in order to get the expected number of removed trees
119 //calculate the probability in order to get the expected number of removed trees
108 var expected = to_remove;
120 var expected = to_remove;
109 var trials = tree_squares.Count();
121 var trials = tree_squares.Count();
110 double probability = ((double)expected / (double)trials) / 12;
122 double probability = ((double)expected / (double)trials) / 12;
111
123
112 foreach (var square in tree_squares)
124 foreach (var square in tree_squares)
113 {
125 {
@@ -129,6 +141,7
129 this.ticksToSend = 0;
141 this.ticksToSend = 0;
130
142
131 simulation.contracts = new_contract_amount;
143 simulation.contracts = new_contract_amount;
144 simulation.enforcement = new_enforcement_amount;
132
145
133 }
146 }
134
147
@@ -1,6 +1,3
1
2
3
4 using Microsoft.Xna.Framework.Input;
1 using Microsoft.Xna.Framework.Input;
5
2
6 using Encompass;
3 using Encompass;
@@ -8,61 +5,61
8 using isometricparkfna.Messages;
5 using isometricparkfna.Messages;
9 using isometricparkfna.Components;
6 using isometricparkfna.Components;
10
7
11 namespace isometricparkfna.Engines {
8 namespace isometricparkfna.Engines
12
9 {
13 [Receives(typeof(ToggleWindowMessage), typeof(ToggleWindowTypeMessage), typeof(ToggleVisibilityMessage),
14 typeof(SelectMessage))]
15 [Reads(typeof(WindowTypeComponent), typeof(VisibilityComponent),
16 typeof(SelectedComponent))]
17 [Writes(typeof(VisibilityComponent), typeof(SelectedComponent))]
18 class UIEngine : Engine
19 {
20
21 public override void Update(double dt)
22 {
23 foreach (var entity in ReadEntities<SelectedComponent>())
24 {
25 SetComponent(entity, new SelectedComponent { selected = false});
26 }
27
10
28 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowMessage>())
11 [Receives(typeof(ToggleWindowMessage), typeof(ToggleWindowTypeMessage), typeof(ToggleVisibilityMessage),
29 {
12 typeof(SelectMessage))]
30 Logging.Spy(windowMessage, "message");
13 [Reads(typeof(WindowTypeComponent), typeof(VisibilityComponent),
31 Logging.Spy(windowMessage.Window, "message.Window");
14 typeof(SelectedComponent))]
32 Logging.Spy(windowMessage.Entity, "message.Entity");
15 [Writes(typeof(VisibilityComponent), typeof(SelectedComponent))]
33 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
16 class UIEngine : Engine
34 {
17 {
35 if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID) {
36 var visibilityComponent = GetComponent<VisibilityComponent>(entity);
37 SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible});
38
18
39 }
19 public override void Update(double dt)
40 }
20 {
41 }
21 foreach (var entity in ReadEntities<SelectedComponent>())
42 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowTypeMessage>())
22 {
43 {
23 SetComponent(entity, new SelectedComponent { selected = false });
44 Logging.Spy(windowMessage, "message");
45 Logging.Spy(windowMessage.Window, "message.Window");
46 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
47 {
48
49 var window_type = GetComponent<WindowTypeComponent>(entity).type;
50 if (window_type == windowMessage.Window)
51 {
52 var visibilityComponent = GetComponent<VisibilityComponent>(entity);
53 SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible});
54 }
55 //else if (window_type == windowMessage.Window && entity == windowMessage.Entity) {
56 // else if (entity == windowMessage.Entity) {
57 }
58 }
59
60 foreach (ref readonly var selectedMessage in ReadMessages<SelectMessage>())
61 {
62 SetComponent<SelectedComponent>(selectedMessage.Entity,
63 new SelectedComponent { selected = true});
64 }
24 }
65
25
26 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowMessage>())
27 {
28 Logging.Spy(windowMessage, "message");
29 Logging.Spy(windowMessage.Window, "message.Window");
30 Logging.Spy(windowMessage.Entity, "message.Entity");
31 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
32 {
33 if (EntityExists(windowMessage.Entity) && entity.ID == windowMessage.Entity.ID)
34 {
35 var visibilityComponent = GetComponent<VisibilityComponent>(entity);
36 SetComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible });
37
38 }
39 }
40 }
41 foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowTypeMessage>())
42 {
43 Logging.Spy(windowMessage, "message");
44 Logging.Spy(windowMessage.Window, "message.Window");
45 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
46 {
47
48 var window_type = GetComponent<WindowTypeComponent>(entity).type;
49 if (window_type == windowMessage.Window)
50 {
51 var visibilityComponent = GetComponent<VisibilityComponent>(entity);
52 SetComponent(entity, new VisibilityComponent { visible = !visibilityComponent.visible });
53 }
54
55 }
56 }
57
58 foreach (ref readonly var selectedMessage in ReadMessages<SelectMessage>())
59 {
60 SetComponent<SelectedComponent>(selectedMessage.Entity,
61 new SelectedComponent { selected = true });
62 }
66 }
63 }
67 }
64 }
68 }
65 }
This diff has been collapsed as it changes many lines, (526 lines changed) Show them Hide them
@@ -1,6 +1,4
1 using System.Collections.Generic;
1 using Microsoft.Xna.Framework;
2 using System.Linq;
3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Audio;
2 using Microsoft.Xna.Framework.Audio;
5 using Microsoft.Xna.Framework.Input;
3 using Microsoft.Xna.Framework.Input;
6 using Microsoft.Xna.Framework.Graphics;
4 using Microsoft.Xna.Framework.Graphics;
@@ -9,9 +7,12
9
7
10 using System;
8 using System;
11 using System.IO;
9 using System.IO;
10 using System.Reflection;
11 using System.Diagnostics;
12 using System.Collections.Generic;
13 using System.Linq;
12 using SpriteFontPlus;
14 using SpriteFontPlus;
13 using isometricparkfna;
15 using isometricparkfna;
14 using System.Diagnostics;
15
16
16 using static isometricparkfna.CellMap;
17 using static isometricparkfna.CellMap;
17 using isometricparkfna.Utils;
18 using isometricparkfna.Utils;
@@ -21,12 +22,20
21 using isometricparkfna.Renderers;
22 using isometricparkfna.Renderers;
22 using isometricparkfna.Messages;
23 using isometricparkfna.Messages;
23 using isometricparkfna.Spawners;
24 using isometricparkfna.Spawners;
25 using Num = System.Numerics;
24
26
25 using ImGuiNET.SampleProgram.XNA;
27 using ImGuiNET.SampleProgram.XNA;
26 using ImGuiNET;
28 using ImGuiNET;
27 using TraceryNet;
29 using TraceryNet;
28 using Encompass;
30 using Encompass;
29
31
32 //Let's let core builds be deterministic
33 #if NETCOREAPP
34 [assembly:AssemblyVersion("0.32.02.0")]
35 #else
36 [assembly:AssemblyVersion("0.32.02.*")]
37 #endif
38
30 class FNAGame : Game
39 class FNAGame : Game
31 {
40 {
32 private KeyboardState keyboardPrev = new KeyboardState();
41 private KeyboardState keyboardPrev = new KeyboardState();
@@ -35,6 +44,7
35 private SpriteBatch batch;
44 private SpriteBatch batch;
36 private SoundEffect sound;
45 private SoundEffect sound;
37 private SpriteFont monoFont;
46 private SpriteFont monoFont;
47 private SpriteFont largeMonoFont;
38
48
39 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
49 private Camera camera = new Camera(new float[] { 0.25f, 0.5f, 1.0f, 2.0f, 4.0f });
40
50
@@ -49,15 +59,13
49 Queue<float> past_fps = new Queue<float>(100);
59 Queue<float> past_fps = new Queue<float>(100);
50 int tilesDrawn = 0;
60 int tilesDrawn = 0;
51
61
52 private const int width = 1280;
62 private static int width = 1280;
53 private const int height = 640;
63 private static int height = 640;
54
64
55 //new tile stuff
65 //new tile stuff
56 int squaresAcross = 50;
66 int squaresAcross = 50;
57 int squaresDown = 50;
67 int squaresDown = 50;
58 // int baseOffsetX = -14;
68
59 // int baseOffsetY = -14;
60
61 Simulation simulation;
69 Simulation simulation;
62
70
63 public Vector2 mouseGrid;
71 public Vector2 mouseGrid;
@@ -65,6 +73,9
65
73
66 //for now
74 //for now
67 public bool in_zone;
75 public bool in_zone;
76 public bool in_active_zone;
77
78 public bool isPlaying = false;
68
79
69 private ImGuiRenderer _imGuiRenderer;
80 private ImGuiRenderer _imGuiRenderer;
70 private DebugWindow debugWindow;
81 private DebugWindow debugWindow;
@@ -114,8 +125,6
114 }
125 }
115
126
116
127
117
118
119 private FNAGame()
128 private FNAGame()
120 {
129 {
121
130
@@ -134,25 +143,10
134 IsFullScreen = false,
143 IsFullScreen = false,
135 SynchronizeWithVerticalRetrace = true
144 SynchronizeWithVerticalRetrace = true
136 };
145 };
137 //gdm.SynchronizeWithVerticalRetrace = false;
138 IsFixedTimeStep = false;
146 IsFixedTimeStep = false;
139
147
140 this.simulation = new Simulation(this.squaresAcross, this.squaresDown, new float[] {16.66667f*240, 16.66667f*120, 16.66667f*60, 16.66667f*30f, 16.66667f*1 });
148 this.simulation = new Simulation(this.squaresAcross, this.squaresDown, new float[] {16.66667f*240, 16.66667f*120, 16.66667f*60, 16.66667f*30f, 16.66667f*1 });
141
149
142 foreach (List<Cell> row in this.simulation.map.cells)
143 {
144 foreach (Cell cell in row)
145 {
146 if (this.random_generator.NextDouble() > 0.75)
147 {
148 int random_year = (int)MathHelper.Clamp((float)MathUtils.NextNormal(random_generator, 2010.0f, 40.0f), 1800, Simulation.START_YEAR);
149 int random_month = random_generator.Next(1, 12);
150 DateTime random_date = new DateTime(random_year, random_month, 1);
151
152 cell.addTree(random_date);
153 }
154 }
155 }
156
150
157 showInitial = true;
151 showInitial = true;
158 messageIndex = 0;
152 messageIndex = 0;
@@ -170,7 +164,7
170
164
171 }
165 }
172
166
173 protected override void Initialize()
167 protected override void Initialize()
174 {
168 {
175 /* This is a nice place to start up the engine, after
169 /* This is a nice place to start up the engine, after
176 * loading configuration stuff in the constructor
170 * loading configuration stuff in the constructor
@@ -199,97 +193,9
199 Quad.Initialize(GraphicsDevice, texture);
193 Quad.Initialize(GraphicsDevice, texture);
200 Logging.Success("Initialized Quad texture.");
194 Logging.Success("Initialized Quad texture.");
201 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
195 ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap);
202
196 OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen);
203 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
204 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
205
206 //Has to happen before Encompass stuff, so Spawners can use the grammar:
207 var json2 = new FileInfo(@"Content/grammar.json");
208
209 this.grammar = new TraceryNet.Grammar(json2);
210
211
212 WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, FNAGame.width, FNAGame.height, this.camera, GraphicsDevice));
213 WorldBuilder.AddEngine(new UIEngine());
214
215 WorldBuilder.AddEngine(new GameBridgeEngine(this));
216 WorldBuilder.AddEngine(this.simulation.BridgeEngine);
217 WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera));
218 this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine();
219 WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine);
220 WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation));
221
222 WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight, this.simulation, this.grammar));
223 WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar));
224
225 WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1);
226 WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine), 2);
227 var contractWindow = WorldBuilder.CreateEntity();
228 WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false });
229 WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts });
230
231
232 var forestWindow = WorldBuilder.CreateEntity();
233 WorldBuilder.SetComponent(forestWindow, new VisibilityComponent { visible = false });
234 WorldBuilder.SetComponent(forestWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Forest });
235
236 var newsWindow = WorldBuilder.CreateEntity();
237 WorldBuilder.SetComponent(newsWindow, new VisibilityComponent { visible = false });
238 WorldBuilder.SetComponent(newsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.News });
239
240 // var budgetWindow = WorldBuilder.CreateEntity();
241 // WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true});
242 // WorldBuilder.SetComponent(budgetWindow, new BudgetComponent());
243
197
244 var area = WorldBuilder.CreateEntity();
198 //Must be done before SetFontMessage is sent
245 // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}});
246 var size = 5;
247 var squares = new Vector2[size * size];
248 var start_x = 10;
249
250 for (int i = 0; i < size; i++)
251 {
252 for (int j = 0; j < size; j++)
253 {
254 squares[i * size + j] = new Vector2(i + start_x, j);
255 }
256
257 }
258
259 for (int i = 0; i < 3; i++)
260 {
261
262 WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
263 name = "#family_company.capitalizeAll#",
264 description = "#family_company_description#",
265 type = OrganizationType.Family });
266 WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
267 name = "#large_company.capitalizeAll#",
268 description = "#large_company_description#",
269 type = OrganizationType.LargeCorporation });
270 }
271 WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
272 name = "#logging_company.capitalizeAll#",
273 description = "#company_description#" });
274 WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
275 name = "#coop_company.capitalizeAll#",
276 description = "#coop_company_description#",
277 type = OrganizationType.Cooperative });
278 WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true,
279 name = "#coop_company.capitalizeAll#",
280 description = "#coop_company_description#",
281 type = OrganizationType.Cooperative });
282 WorldBuilder.SendMessage(new SpawnContractMessage
283 {
284 squares = squares,
285 name = "Northshore Logging"
286 });
287 WorldBuilder.SendMessage(new SpawnContractMessage
288 {
289 name = "Aeres Maximalis Ltd."
290 });
291 World = WorldBuilder.Build();
292
293 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
199 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
294 15,
200 15,
295 1024,
201 1024,
@@ -305,6 +211,111
305 }
211 }
306 );
212 );
307
213
214 var bakedMonoLarge = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
215 30,
216 1024,
217 1024,
218 new[]
219 {
220 CharacterRange.BasicLatin,
221 CharacterRange.Latin1Supplement,
222 CharacterRange.LatinExtendedA,
223 CharacterRange.Cyrillic,
224 CharacterRange.LatinExtendedB,
225 new CharacterRange((char) 0x00B7)
226 }
227 );
228 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
229 largeMonoFont = bakedMonoLarge.CreateSpriteFont(GraphicsDevice);
230
231 //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded:
232 this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice, this.imageMap);
233
234 //Has to happen before Encompass stuff, so Spawners can use the grammar:
235 var json2 = new FileInfo(@"Content/grammar.json");
236
237 this.grammar = new TraceryNet.Grammar(json2);
238
239 //Has to happen after Grammar initialization.
240 NewGameWindow.Initialize(this.grammar);
241
242 WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, this.camera, gdm));
243 WorldBuilder.AddEngine(new UIEngine());
244
245 var gameBridgeEngine = new GameBridgeEngine(this);
246
247 WorldBuilder.AddEngine(gameBridgeEngine);
248 WorldBuilder.AddEngine(new GameStateEngine());
249 WorldBuilder.AddEngine(this.simulation.BridgeEngine);
250 WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera));
251 this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(this.debugWindow, debugWindow.monoFont, debugWindow.italicFont);
252 WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine);
253 WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation));
254
255 WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight, this.simulation, this.grammar));
256 WorldBuilder.AddEngine(new GameSpawner(this.simulation, this, this.grammar));
257 WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar));
258 WorldBuilder.AddEngine(new PolicyEngine());
259 WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar));
260
261 WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1);
262 WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, this.gdm) , 2);
263 var contractWindow = WorldBuilder.CreateEntity();
264 WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false });
265 WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts });
266
267
268 var forestWindow = WorldBuilder.CreateEntity();
269 WorldBuilder.SetComponent(forestWindow, new VisibilityComponent { visible = false });
270 WorldBuilder.SetComponent(forestWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Forest });
271
272 var newsWindow = WorldBuilder.CreateEntity();
273 WorldBuilder.SetComponent(newsWindow, new VisibilityComponent { visible = false });
274 WorldBuilder.SetComponent(newsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.News });
275
276 var mainMenu = WorldBuilder.CreateEntity();
277 WorldBuilder.SetComponent(mainMenu, new VisibilityComponent { visible = true });
278 WorldBuilder.SetComponent(mainMenu, new WindowTypeComponent { type = isometricparkfna.Messages.Window.MainMenu });
279
280 var inputMenu = WorldBuilder.CreateEntity();
281 WorldBuilder.SetComponent(inputMenu, new VisibilityComponent { visible = false });
282 WorldBuilder.SetComponent(inputMenu, new WindowTypeComponent { type = isometricparkfna.Messages.Window.InGameMenu });
283
284 var optionsWindow = WorldBuilder.CreateEntity();
285 WorldBuilder.SetComponent(optionsWindow, new VisibilityComponent { visible = false });
286 WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options });
287
288 var newGameWindow = WorldBuilder.CreateEntity();
289 WorldBuilder.SetComponent(newGameWindow, new VisibilityComponent { visible = false });
290 WorldBuilder.SetComponent(newGameWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.NewGame });
291
292
293
294 var gameEntity = WorldBuilder.CreateEntity();
295
296 WorldBuilder.SetComponent(gameEntity, new GameStateComponent { isPlaying = false});
297
298 var policyEntity = WorldBuilder.CreateEntity();
299 WorldBuilder.SetComponent(policyEntity,
300 new TrespassingPolicyComponent { tresspassingPolicy = EnforcementLevel.NoEnforcement});
301 WorldBuilder.SetComponent(policyEntity,
302 new BudgetLineComponent { });
303
304 try {
305 var options = Options.readOptions();
306
307 this.imGuiWindowBridgeEngine.fontMessages.Add(new SetFontMessage{
308 fontSize = options.fontSize,
309 fontName = options.fontName});
310 Logging.Success("Loaded options.");
311 }
312 catch (FileNotFoundException e)
313 {
314 Logging.Error(String.Format("Error loading file: {0}", e.ToString()));
315 }
316
317 World = WorldBuilder.Build();
318
308
319
309 this.output = grammar.Flatten("#greeting#");
320 this.output = grammar.Flatten("#greeting#");
310 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
321 var result = grammar.Flatten("#[assistantName:#assistantNames#][whatever:whatever]vars#");
@@ -333,19 +344,34
333
344
334 this.remainingDialog = new Queue<Node<DialogOption>>();
345 this.remainingDialog = new Queue<Node<DialogOption>>();
335
346
336 #if DEBUG
337 this.remainingDialog.Enqueue(DialogTrees.flatten(DialogTrees.testTree, this.grammar));
338 #endif
339
340 //font = fontBakeResult.CreateSpriteFont(GraphicsDevice);
341 monoFont = bakedMono.CreateSpriteFont(GraphicsDevice);
342
343 this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0);
347 this.budgetWindow = new BudgetWindow(new Budget { }, this.monoFont, 0, 0);
344
348
345 Logging.Success("Content loaded.");
349 Logging.Success("Content loaded.");
346 }
350 }
347
351
348
352
353 public void setFont(string font, int size)
354 {
355 var font_path = DebugWindow.fonts[font];
356
357 var baked = TtfFontBaker.Bake(File.OpenRead(font_path),
358 size,
359 1024,
360 1024,
361 new[]
362 {
363 CharacterRange.BasicLatin,
364 CharacterRange.Latin1Supplement,
365 CharacterRange.LatinExtendedA,
366 CharacterRange.Cyrillic,
367 CharacterRange.LatinExtendedB,
368 new CharacterRange((char) 0x00B7)
369 }
370 );
371
372 this.monoFont = baked.CreateSpriteFont(GraphicsDevice);
373 }
374
349
375
350 protected override void UnloadContent()
376 protected override void UnloadContent()
351 {
377 {
@@ -435,80 +461,83
435
461
436 KeyboardState keyboardCur = Keyboard.GetState();
462 KeyboardState keyboardCur = Keyboard.GetState();
437 MouseState mouseCur = Mouse.GetState();
463 MouseState mouseCur = Mouse.GetState();
438
439 #region input
440 //
441 #region misc_keys
442 if (keyboardCur.IsKeyDown(Keys.OemBackslash) && keyboardPrev.IsKeyUp(Keys.OemBackslash) && keyboardCur.IsKeyDown(Keys.LeftShift))
443 {
444 sound.Play(volume, pitch, pan);
445 }
446 #endregion misc_keys
447 //
448
464
449 #endregion input
465 #region input
450
466 //
451
467 #region misc_keys
468 if (keyboardCur.IsKeyDown(Keys.OemBackslash)
469 && keyboardPrev.IsKeyUp(Keys.OemBackslash)
470 && keyboardCur.IsKeyDown(Keys.LeftShift))
471 {
472 sound.Play(volume, pitch, pan);
473 }
474 if (keyboardCur.IsKeyDown(Keys.V) && keyboardPrev.IsKeyUp(Keys.V))
475 {
476 // debugWindow.swap();
477 debugWindow.setMonoFont(debugWindow.addFont("Roboto", 25, false));
478 }
479 #endregion misc_keys
480 #endregion input
452
481
453 World.Update(gameTime.ElapsedGameTime.TotalSeconds);
482 World.Update(gameTime.ElapsedGameTime.TotalSeconds);
454 this.simulation.update(gameTime.ElapsedGameTime);
483 this.simulation.update(gameTime.ElapsedGameTime);
455
484
456 if (this.showBudget)
485 if (this.showBudget)
457 {
486 {
458 this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
487 this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
459 }
488 }
460
489
461
490
462 if (!this.showInitial && this.remainingDialog.Count > 0)
491 if (!this.showInitial && this.remainingDialog.Count > 0)
463 {
492 {
464 this.currentNode = this.remainingDialog.Dequeue();
493 this.currentNode = this.remainingDialog.Dequeue();
465 this.showInitial = true;
494 this.showInitial = true;
466 }
495 }
467
496
468 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
497 this.original_point = Vector2.Transform(new Vector2(mouseCur.X, mouseCur.Y), Matrix.Invert(camera.get_transformation(GraphicsDevice)));
469
498
470 //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX);
499 //int gridx = (int)((this.original_point.X-baseOffsetX) / Tile.TileStepX);
471 /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */
500 /* int gridx = (int)(this.original_point.Y / Tile.TileHeight + this.original_point.X / Tile.TileWidth); */
472 //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2));
501 //int gridy = (int)((this.original_point.Y-baseOffsetY) / (Tile.TileStepY*2));
473 /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */
502 /* int gridy = (int)(this.original_point.Y / Tile.TileHeight - this.original_point.X / Tile.TileWidth); */
474
503
475 //this.mouseGrid = new Vector2(gridx, gridy);
504 //this.mouseGrid = new Vector2(gridx, gridy);
476 this.mouseGrid = this.calculateMousegrid(this.original_point);
505 this.mouseGrid = this.calculateMousegrid(this.original_point);
477
506
478 elapsedTime += gameTime.ElapsedGameTime;
507 elapsedTime += gameTime.ElapsedGameTime;
479
508
480 if (elapsedTime > TimeSpan.FromSeconds(1))
509 if (elapsedTime > TimeSpan.FromSeconds(1))
481 {
510 {
482 elapsedTime -= TimeSpan.FromSeconds(1);
511 elapsedTime -= TimeSpan.FromSeconds(1);
483 frameRate = frameCounter;
512 frameRate = frameCounter;
484 frameCounter = 0;
513 frameCounter = 0;
485 }
514 }
486
515
487 this.keyboardPrev = keyboardCur;
516 this.keyboardPrev = keyboardCur;
488 this.mousePrev = mouseCur;
517 this.mousePrev = mouseCur;
489
518
490 stopWatch.Stop();
519 stopWatch.Stop();
491 this.updateTime = stopWatch.Elapsed;
520 this.updateTime = stopWatch.Elapsed;
492
521
493 base.Update(gameTime);
522 base.Update(gameTime);
494
523
495 }
524 }
496
525
497 protected float calculateDepth() {
526 protected float calculateDepth() {
498 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
527 return ((this.squaresAcross + 1) + ((this.squaresDown + 1) * Tile.TileWidth)) * 10;
499 }
528 }
500
529
501 protected Boolean cull(int gridX, int gridY)
530 protected Boolean cull(int gridX, int gridY)
502 {
531 {
503 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
532 int screenX = (gridX - gridY) * Tile.TileSpriteWidth / 2;
504 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
533 int screenY = (gridX + gridY) * Tile.TileSpriteHeight / 2;
505
534
506 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
535 Vector2 original = Vector2.Transform(new Vector2(screenX, screenY), camera.get_transformation(GraphicsDevice));
507
536
508 return (!FNAGame.enableCulling ||
537 return (!FNAGame.enableCulling ||
509 (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width)
538 (MathUtils.BetweenExclusive(original.X, -Tile.TileSpriteWidth, FNAGame.width)
510 && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
539 && MathUtils.BetweenExclusive(original.Y, -Tile.TileSpriteHeight, FNAGame.height)));
511 }
540 }
512
541
513 //Convenience method I'm not super sure about anymore.
542 //Convenience method I'm not super sure about anymore.
514 protected void drawTileAt(int x, int y, int tileIndex, int height)
543 protected void drawTileAt(int x, int y, int tileIndex, int height)
@@ -521,16 +550,20
521 }
550 }
522
551
523
552
524
525 protected override void Draw(GameTime gameTime)
553 protected override void Draw(GameTime gameTime)
526 {
554 {
527 frameCounter++;
555 frameCounter++;
528
556
529 string fps = string.Format("fps: {0}", frameRate);
557 string fps = string.Format("fps: {0}", frameRate);
558 bool has_tree = false;
530
559
531 Stopwatch stopWatch = new Stopwatch();
560 Stopwatch stopWatch = new Stopwatch();
532 stopWatch.Start();
561 stopWatch.Start();
533 GraphicsDevice.Clear(Color.CornflowerBlue);
562 GraphicsDevice.Clear(Color.CornflowerBlue);
563
564 _imGuiRenderer.BeforeLayout(gameTime);
565 if (this.isPlaying)
566 {
534 batch.Begin(SpriteSortMode.BackToFront,
567 batch.Begin(SpriteSortMode.BackToFront,
535 BlendState.AlphaBlend,
568 BlendState.AlphaBlend,
536 null,
569 null,
@@ -602,7 +635,7
602 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
635 new Vector2(((x - 0) * Tile.TileSpriteWidth / 2), (x + 0) * Tile.TileSpriteHeight / 2) + adjust,
603 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
636 //new Vector2(this.squaresAcross * Tile.TileSpriteWidth, (y+1) * Tile.TileSpriteHeight),
604 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
637 new Vector2((x - this.squaresDown) * Tile.TileSpriteWidth / 2, (x + this.squaresDown) * Tile.TileSpriteHeight / 2) + adjust,
605 Color.White, 0.81f);
638 Color.White, 0.81f);
606
639
607 }
640 }
608 }
641 }
@@ -656,7 +689,6
656 #endif
689 #endif
657
690
658 #region draw_cursor
691 #region draw_cursor
659 //drawTileAt((int)this.mouseGrid.X, (int)this.mouseGrid.Y, 2, 1, 0.85f); //between tiles and gridlines
660
692
661 if (MathUtils.Between(this.mouseGrid.X, 0, this.simulation.map.MapWidth)
693 if (MathUtils.Between(this.mouseGrid.X, 0, this.simulation.map.MapWidth)
662 && MathUtils.Between(this.mouseGrid.Y, 0, this.simulation.map.MapHeight))
694 && MathUtils.Between(this.mouseGrid.Y, 0, this.simulation.map.MapHeight))
@@ -686,7 +718,7
686 Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f);
718 Quad.FillSquare2(batch, 8, 5, Color.Teal, .5f, 0.79f);
687 Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f);
719 Quad.FillSquare2(batch, 8, 6, Color.Teal, .25f, 0.79f);
688 Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f);
720 Quad.FillSquare2(batch, 8, 7, Color.Teal, .125f, 0.79f);
689 #endif
721 #endif
690
722
691
723
692
724
@@ -699,7 +731,6
699 {
731 {
700 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
732 for (int j = 0; j < this.simulation.map.MapWidth; j += 1)
701 {
733 {
702
703 if (this.simulation.map.cells[i][j].hasTree)
734 if (this.simulation.map.cells[i][j].hasTree)
704 { //until we actually simulate:
735 { //until we actually simulate:
705 drawTileAt(i, j, 142, 2);
736 drawTileAt(i, j, 142, 2);
@@ -715,7 +746,6
715 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) {
746 else if (this.simulation.map.cells[i][j].status == CellStatus.DeadTree) {
716 drawTileAt(i, j, 141, 2);
747 drawTileAt(i, j, 141, 2);
717 // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j));
748 // System.Console.WriteLine(String.Format("Drew Dead Tree at {0},{1}", i, j));
718
719 }
749 }
720 }
750 }
721 }
751 }
@@ -728,7 +758,6
728 drawTileAt(3, 2, 140, 2);
758 drawTileAt(3, 2, 140, 2);
729 #endif
759 #endif
730
760
731 _imGuiRenderer.BeforeLayout(gameTime);
732 World.Draw();
761 World.Draw();
733 // _imGuiRenderer.AfterLayout();
762 // _imGuiRenderer.AfterLayout();
734 batch.End();
763 batch.End();
@@ -741,20 +770,17
741 null,
770 null,
742 null);
771 null);
743
772
744 bool has_tree = false;
745 if (MathUtils.BetweenExclusive(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.BetweenExclusive(this.mouseGrid.Y, 0, this.squaresAcross))
773 if (MathUtils.BetweenExclusive(this.mouseGrid.X, 0, this.squaresAcross) && MathUtils.BetweenExclusive(this.mouseGrid.Y, 0, this.squaresAcross))
746 {
774 {
747 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
775 has_tree = this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].hasTree;
748 }
776 }
749 //*/
750
777
751 String status_left = "";
778 String status_left = "";
752 if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
779 if (MathUtils.BetweenExclusive(this.mouseGrid.X, -1, this.simulation.map.MapWidth) && MathUtils.BetweenExclusive(this.mouseGrid.Y, -1, this.simulation.map.MapHeight))
753 {
780 {
754 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
781 status_left = String.Format("{0:},{1:} {2} ({3})", this.mouseGrid.X, this.mouseGrid.Y,
755 this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status,
782 this.simulation.map.cells[(int)this.mouseGrid.X][(int)this.mouseGrid.Y].status,
756 this.in_zone ? "Contracted" : "Unzoned"
783 this.in_active_zone ? "Contracted" : (this.in_zone ? "Proposed Contract": "Unzoned"));
757 );
758 }
784 }
759
785
760 String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count);
786 String header_left = String.Format("${0:}|{1:} \ue124", this.simulation.money, this.simulation.map.tree_count);
@@ -792,6 +818,70
792
818
793 batch.End();
819 batch.End();
794
820
821 #region window
822 if (this.currentNode != null)
823 {
824 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
825 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
826 }
827
828 if (this.showForest)
829 {
830 ForestWindow.Render(this.showForest, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
831 }
832
833 if (this.showNews)
834 {
835 NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
836 }
837
838 bool quit = false;
839 Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left);
840
841 if (quit) {
842 System.Environment.Exit(0);
843 }
844
845 }
846 else {
847 GraphicsDevice.Clear(Color.Teal);
848 batch.Begin(SpriteSortMode.BackToFront,
849 BlendState.AlphaBlend,
850 null,
851 null,
852 null,
853 null);
854
855 Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park");
856 float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2));
857 batch.DrawString(largeMonoFont, "Isometric Park",
858 new Vector2(middle_start, 50),
859 Color.Black, 0.0f, Vector2.Zero,
860 1.0f, SpriteEffects.None, 0.5f);
861 batch.DrawString(largeMonoFont, "Isometric Park",
862 new Vector2(middle_start-1, 49),
863 Color.White, 0.0f, Vector2.Zero,
864 1.0f, SpriteEffects.None, 0.51f);
865 World.Draw();
866
867 Vector2 version_dimensions = monoFont.MeasureString(typeof(FNAGame).Assembly.GetName().Version.ToString());
868 batch.DrawString(monoFont,
869 typeof(FNAGame).Assembly.GetName().Version.ToString(),
870 new Vector2(0, FNAGame.height-version_dimensions.Y),
871 Color.White, 0.0f, Vector2.Zero,
872 1.0f, SpriteEffects.None, 0.51f);
873
874 Vector2 name_dimensions = monoFont.MeasureString("by actuallyalys<3");
875 float name_start = (int)(FNAGame.width / 2) - (name_dimensions.X / 2);
876
877 batch.DrawString(monoFont, "by actuallyalys <3",
878 new Vector2(name_start, 50+middle_dimensions.Y),
879 Color.White, 0.0f, Vector2.Zero,
880 1.0f, SpriteEffects.None, 0.51f);
881 batch.End();
882 }
883 #endregion
884
795
885
796 #region debug_window
886 #region debug_window
797 //Calcs for debug window:
887 //Calcs for debug window:
@@ -850,39 +940,6
850
940
851 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
941 debugWindow.Layout(debugInfo, additionalInfo, ref show_another_window);
852
942
853
854 //debugWindow.ImGuiLayout();
855 //String[] messages = { "Message1", "Message2" };
856
857 //DialogOption[] dialog = { new DialogOption{ response="Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.", choice="Okay" },
858 // new DialogOption{ response="Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!", choice="And I need to keep the forest healthy, too, right?" },
859 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
860
861
862 if (this.currentNode != null)
863 {
864 this.currentNode = DialogInterface.RenderDialog(ref this.showInitial,
865 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
866 }
867
868 if (this.showForest)
869 {
870 ForestWindow.Render(this.showForest, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
871 }
872
873 if (this.showNews)
874 {
875 NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine);
876 }
877
878 bool quit = false;
879 Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left);
880
881 if (quit) {
882 System.Environment.Exit(0);
883 }
884
885
886 _imGuiRenderer.AfterLayout();
943 _imGuiRenderer.AfterLayout();
887
944
888 #endregion debug_window
945 #endregion debug_window
@@ -892,4 +949,21
892
949
893 base.Draw(gameTime);
950 base.Draw(gameTime);
894 }
951 }
952
953
954 public void setResolution(Vector2 newResolution, bool fullscreen)
955 {
956 FNAGame.width = (int)newResolution.X;
957 FNAGame.height = (int)newResolution.Y;
958
959 this.gdm.PreferredBackBufferWidth = (int)newResolution.X;
960 this.gdm.PreferredBackBufferHeight = (int)newResolution.Y;
961 this.gdm.IsFullScreen = fullscreen;
962 this.gdm.ApplyChanges();
963 }
964
965 public void enqueueDialog(Node<DialogOption> tree)
966 {
967 this.remainingDialog.Enqueue(tree);
968 }
895 }
969 }
@@ -74,13 +74,7
74 }
74 }
75
75
76 return stop;//TODO
76 return stop;//TODO
77
78
79 }
77 }
80 }
78 }
81
79
82
83
84
85
86 }
80 }
@@ -15,110 +15,119
15
15
16 namespace isometricparkfna
16 namespace isometricparkfna
17 {
17 {
18 public enum LogLevel {
18 public enum LogLevel
19 Critical,
19 {
20 Error,
20 Critical,
21 Warning,
21 Error,
22 Success,
22 Warning,
23 Info,
23 Success,
24 Debug,
24 Info,
25 Trace,
25 Debug,
26 Spy
26 Trace,
27 }
27 Spy
28 }
28
29
29 public struct LogEntry {
30 public struct LogEntry
30 public DateTime timestamp;
31 {
31 public string message;
32 public DateTime timestamp;
32 public LogLevel level;
33 public string message;
33 public ITuple data;
34 public LogLevel level;
34 }
35 public ITuple data;
36 }
35 public class Logging
37 public class Logging
36 {
38 {
37
39
38 // private
40 // private
39 //
41 //
40
42
41 public static LogLevel minimumConsoleLevel = LogLevel.Info;
43 #if DEBUG
44 public static LogLevel minimumConsoleLevel = LogLevel.Debug;
45 #else
46 public static LogLevel minimumConsoleLevel = LogLevel.Success;
47 #endif
42
48
43 public static List<LogEntry> entries = new List<LogEntry>();
49 public static List<LogEntry> entries = new List<LogEntry>();
44 public static string logFileName = string.Format("log_{0:yyyyMMdd_HHmm}.txt", DateTime.Now);
50 public static string logFileName = string.Format("log_{0:yyyyMMdd_HHmm}.txt", DateTime.Now);
45
51
46 public static StreamWriter logFile = File.CreateText(logFileName);
52 public static StreamWriter logFile = File.CreateText(logFileName);
47 private static Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> mappings = new Dictionary<LogLevel, (ConsoleColor, ConsoleColor)>
53 private static Dictionary<LogLevel, (ConsoleColor, ConsoleColor)> mappings = new Dictionary<LogLevel, (ConsoleColor, ConsoleColor)>
48 {
54 {
49 {LogLevel.Critical, (ConsoleColor.White, ConsoleColor.Red)},
55 {LogLevel.Critical, (ConsoleColor.White, ConsoleColor.Red)},
50 {LogLevel.Error, (ConsoleColor.Red, ConsoleColor.Black)},
56 {LogLevel.Error, (ConsoleColor.Red, ConsoleColor.Black)},
51 {LogLevel.Warning, (ConsoleColor.Yellow, ConsoleColor.Black)},
57 {LogLevel.Warning, (ConsoleColor.Yellow, ConsoleColor.Black)},
52 {LogLevel.Success, (ConsoleColor.Green, ConsoleColor.Black)},
58 {LogLevel.Success, (ConsoleColor.Green, ConsoleColor.Black)},
53 {LogLevel.Info, (ConsoleColor.White, ConsoleColor.Black)},
59 {LogLevel.Info, (ConsoleColor.Blue, ConsoleColor.Black)},
54 {LogLevel.Debug, (ConsoleColor.White, ConsoleColor.Blue)},
60 {LogLevel.Debug, (ConsoleColor.White, ConsoleColor.Blue)},
55 {LogLevel.Trace, (ConsoleColor.White, ConsoleColor.DarkGray)},
61 {LogLevel.Trace, (ConsoleColor.White, ConsoleColor.Yellow)},
56 {LogLevel.Spy, (ConsoleColor.Black, ConsoleColor.White)},
62 {LogLevel.Spy, (ConsoleColor.Black, ConsoleColor.White)},
57
63
58 };
64 };
59
65
60
66
61 private static void Log_(LogLevel level, string message,
67 private static void Log_(LogLevel level, string message,
62 int lineNumber, string caller, string path)
68 int lineNumber, string caller, string path)
63 {
69 {
64 var timestamp = DateTime.Now;
70 var timestamp = DateTime.Now;
65
71
66 if ( (level < minimumConsoleLevel)
72 if ((level <= minimumConsoleLevel)
67 || level == LogLevel.Spy)
73 || level == LogLevel.Spy)
68 {
74 {
69 var start_foreground = Console.ForegroundColor;
75 var start_foreground = Console.ForegroundColor;
70 var start_background = Console.BackgroundColor;
76 var start_background = Console.BackgroundColor;
71
77
72 var (new_foreground, new_background) = Logging.mappings[level];
78 var (new_foreground, new_background) = Logging.mappings[level];
73
79
74 Console.ForegroundColor = new_foreground;
80 Console.ForegroundColor = new_foreground;
75 Console.BackgroundColor = new_background;
81 Console.BackgroundColor = new_background;
76 //29/Apr/2021 22:43:30
82 //29/Apr/2021 22:43:30
77 Console.Out.Write(string.Format("[{0}] {1}", timestamp.ToString("s"), level.ToString()));
83 Console.Out.Write(string.Format("[{0}] {1}", timestamp.ToString("s"), level.ToString()));
78
84
79 Console.ForegroundColor = start_foreground;
85 Console.ForegroundColor = start_foreground;
80 Console.BackgroundColor = start_background;
86 Console.BackgroundColor = start_background;
81
87
82 Console.Out.WriteLine(string.Format(" {0} [{1}:{2}]", message, path, lineNumber));
88 Console.Out.WriteLine(string.Format(" {0} [{1}:{2}]", message, path, lineNumber));
83 }
89 }
84
90
85 logFile.WriteLine(string.Format("[{0}] {1} {2} [{3}:{4}]", timestamp.ToString("s"), level.ToString(), message, path, lineNumber));
91 logFile.WriteLine(string.Format("[{0}] {1} {2} [{3}:{4}]", timestamp.ToString("s"), level.ToString(), message, path, lineNumber));
86
92
87
93
88 Logging.entries.Add(new LogEntry{timestamp = timestamp,
94 Logging.entries.Add(new LogEntry
89 level = level,
95 {
90 message = message});
96 timestamp = timestamp,
91 }
97 level = level,
92
98 message = message
93 private static void Log_<T>(LogLevel level, string message, T data,
99 });
94 int lineNumber, string caller, string path)
100 }
95 where T : ITuple
96 {
97 // Logging.entries.Add(data);
98 // var d = data.GetType().GetProperties().ToDictionary(Info => Info.Name, Info => Info.GetValue(data));
99 // var data_strings = data.GetType().GetProperties().Select(Info => Info.Name + "=" + Info.GetValue(data).ToString());
100 // var data_string = string.Join(", ", data_strings);
101 // var str = String.Format("{0} {1}", message, data_string);
102 Logging.Log_(level, message, lineNumber, caller, path);
103 }
104
101
105 private static void Log_(LogLevel level, string message,
102 private static void Log_<T>(LogLevel level, string message, T data,
106 int lineNumber, string caller, string path, params object[] objects)
103 int lineNumber, string caller, string path)
107 {
104 where T : ITuple
108 String.Format(message, objects);
105 {
109 Logging.Log_(level, message, lineNumber, caller, path);
106 // Logging.entries.Add(data);
110 }
107 // var d = data.GetType().GetProperties().ToDictionary(Info => Info.Name, Info => Info.GetValue(data));
108 // var data_strings = data.GetType().GetProperties().Select(Info => Info.Name + "=" + Info.GetValue(data).ToString());
109 // var data_string = string.Join(", ", data_strings);
110 // var str = String.Format("{0} {1}", message, data_string);
111 Logging.Log_(level, message, lineNumber, caller, path);
112 }
111
113
112 public static void Log(LogLevel level, string message,
114 private static void Log_(LogLevel level, string message,
113 [CallerLineNumber] int lineNumber = 0,
115 int lineNumber, string caller, string path, params object[] objects)
114 [CallerMemberName] string caller = null,
116 {
115 [CallerFilePath] string path = "")
117 String.Format(message, objects);
116 {
118 Logging.Log_(level, message, lineNumber, caller, path);
119 }
117
120
118 Logging.Log_(level, message, lineNumber, caller, path);
121 public static void Log(LogLevel level, string message,
119 }
122 [CallerLineNumber] int lineNumber = 0,
123 [CallerMemberName] string caller = null,
124 [CallerFilePath] string path = "")
125 {
120
126
121 /*
127 Logging.Log_(level, message, lineNumber, caller, path);
128 }
129
130 /*
122 public static void Log<T>(LogLevel level, string message, T data,
131 public static void Log<T>(LogLevel level, string message, T data,
123 [CallerLineNumber] int lineNumber = 0,
132 [CallerLineNumber] int lineNumber = 0,
124 [CallerMemberName] string caller = null,
133 [CallerMemberName] string caller = null,
@@ -129,137 +138,137
129 Logging.Log_(level, message, data, lineNumber, caller, path);
138 Logging.Log_(level, message, data, lineNumber, caller, path);
130 }*/
139 }*/
131
140
132 public static void Log<T>(LogLevel level, string message, T data,
141 public static void Log<T>(LogLevel level, string message, T data,
133 [CallerLineNumber] int lineNumber = 0,
142 [CallerLineNumber] int lineNumber = 0,
134 [CallerMemberName] string caller = null,
143 [CallerMemberName] string caller = null,
135 [CallerFilePath] string path = "")
144 [CallerFilePath] string path = "")
136 //Constrain to Tuples and tuple-likes:
145 //Constrain to Tuples and tuple-likes:
137 where T : class
146 where T : class
138 {
147 {
139
148
140 var properties = new List<string>();
149 var properties = new List<string>();
141
150
142 foreach (var property in typeof(T).GetProperties())
151 foreach (var property in typeof(T).GetProperties())
143 {
152 {
144 properties.Add(property.ToString() + "=" + property.GetValue(data));
153 properties.Add(property.ToString() + "=" + property.GetValue(data));
145 }
154 }
146
155
147 var message_data = message + " {" + String.Join(", ", properties) + "}";
156 var message_data = message + " {" + String.Join(", ", properties) + "}";
148
157
149 Logging.Log_(level, message_data, lineNumber, caller, path);
158 Logging.Log_(level, message_data, lineNumber, caller, path);
150
159
151 }
160 }
152
161
153 public static void Log(LogLevel level, string message,
162 public static void Log(LogLevel level, string message,
154 object[] format,
163 object[] format,
155 [CallerLineNumber] int lineNumber = 0,
164 [CallerLineNumber] int lineNumber = 0,
156 [CallerMemberName] string caller = null,
165 [CallerMemberName] string caller = null,
157 [CallerFilePath] string path = "")
166 [CallerFilePath] string path = "")
158 {
167 {
159
168
160 Logging.Log_(level, message, lineNumber, caller, path, format);
169 Logging.Log_(level, message, lineNumber, caller, path, format);
161 }
170 }
162
171
163 public static void Critical(string message,
172 public static void Critical(string message,
164 [CallerLineNumber] int lineNumber = 0,
173 [CallerLineNumber] int lineNumber = 0,
165 [CallerMemberName] string caller = null,
174 [CallerMemberName] string caller = null,
166 [CallerFilePath] string path = "")
175 [CallerFilePath] string path = "")
167 {
176 {
168
177
169 Logging.Log_(LogLevel.Critical, message, lineNumber, caller, path);
178 Logging.Log_(LogLevel.Critical, message, lineNumber, caller, path);
170 }
179 }
171
180
172 public static void Error(string message,
181 public static void Error(string message,
173 [CallerLineNumber] int lineNumber = 0,
182 [CallerLineNumber] int lineNumber = 0,
174 [CallerMemberName] string caller = null,
183 [CallerMemberName] string caller = null,
175 [CallerFilePath] string path = "")
184 [CallerFilePath] string path = "")
176 {
185 {
177
186
178 Logging.Log_(LogLevel.Error, message, lineNumber, caller, path);
187 Logging.Log_(LogLevel.Error, message, lineNumber, caller, path);
179 }
188 }
180
189
181 public static void Warning(string message,
190 public static void Warning(string message,
182 [CallerLineNumber] int lineNumber = 0,
191 [CallerLineNumber] int lineNumber = 0,
183 [CallerMemberName] string caller = null,
192 [CallerMemberName] string caller = null,
184 [CallerFilePath] string path = "")
193 [CallerFilePath] string path = "")
185 {
194 {
186
195
187 Logging.Log_(LogLevel.Warning, message, lineNumber, caller, path);
196 Logging.Log_(LogLevel.Warning, message, lineNumber, caller, path);
188 }
197 }
189
198
190
199
191 public static void Success(string message,
200 public static void Success(string message,
192 [CallerLineNumber] int lineNumber = 0,
201 [CallerLineNumber] int lineNumber = 0,
193 [CallerMemberName] string caller = null,
202 [CallerMemberName] string caller = null,
194 [CallerFilePath] string path = "")
203 [CallerFilePath] string path = "")
195 {
204 {
196
205
197 Logging.Log_(LogLevel.Success, message, lineNumber, caller, path);
206 Logging.Log_(LogLevel.Success, message, lineNumber, caller, path);
198 }
207 }
199
208
200 public static void Info(string message,
209 public static void Info(string message,
201 [CallerLineNumber] int lineNumber = 0,
210 [CallerLineNumber] int lineNumber = 0,
202 [CallerMemberName] string caller = null,
211 [CallerMemberName] string caller = null,
203 [CallerFilePath] string path = "")
212 [CallerFilePath] string path = "")
204 {
213 {
205
214
206 Logging.Log_(LogLevel.Info, message, lineNumber, caller, path);
215 Logging.Log_(LogLevel.Info, message, lineNumber, caller, path);
207 }
216 }
208
217
209 public static void Debug(string message,
218 public static void Debug(string message,
210 [CallerLineNumber] int lineNumber = 0,
219 [CallerLineNumber] int lineNumber = 0,
211 [CallerMemberName] string caller = null,
220 [CallerMemberName] string caller = null,
212 [CallerFilePath] string path = "")
221 [CallerFilePath] string path = "")
213 {
222 {
214
223
215 Logging.Log_(LogLevel.Debug, message, lineNumber, caller, path);
224 Logging.Log_(LogLevel.Debug, message, lineNumber, caller, path);
216 }
225 }
217
226
218 public static void Trace(string message,
227 public static void Trace(string message,
219 [CallerLineNumber] int lineNumber = 0,
228 [CallerLineNumber] int lineNumber = 0,
220 [CallerMemberName] string caller = null,
229 [CallerMemberName] string caller = null,
221 [CallerFilePath] string path = "")
230 [CallerFilePath] string path = "")
222 {
231 {
223
232
224 Logging.Log_(LogLevel.Trace, message, lineNumber, caller, path);
233 Logging.Log_(LogLevel.Trace, message, lineNumber, caller, path);
225 }
234 }
226
235
227 public static void Spy(object value,
236 public static void Spy(object value,
228 string name,
237 string name,
229 [CallerLineNumber] int lineNumber = 0,
238 [CallerLineNumber] int lineNumber = 0,
230 [CallerMemberName] string caller = null,
239 [CallerMemberName] string caller = null,
231 [CallerFilePath] string path = ""
240 [CallerFilePath] string path = ""
232
241
233 )
242 )
234 {
243 {
235 string message = string.Format("{0} ({1}) = {2}",
244 string message = string.Format("{0} ({1}) = {2}",
236 value.GetType().ToString(), name, value.ToString());
245 value.GetType().ToString(), name, value.ToString());
237 Logging.Log_(LogLevel.Spy, message, lineNumber, caller, path);
246 Logging.Log_(LogLevel.Spy, message, lineNumber, caller, path);
238 }
247 }
239
248
240 public static void Spy<T>(T value,
249 public static void Spy<T>(T value,
241 [CallerLineNumber] int lineNumber = 0,
250 [CallerLineNumber] int lineNumber = 0,
242 [CallerMemberName] string caller = null,
251 [CallerMemberName] string caller = null,
243 [CallerFilePath] string path = ""
252 [CallerFilePath] string path = ""
244
253
245 ) where T : class
254 ) where T : class
246 {
255 {
247 // var properties = typeof(T).GetProperties();
256 // var properties = typeof(T).GetProperties();
248 // string message = string.Format("{0} = {1}",
257 // string message = string.Format("{0} = {1}",
249 // value.ToString(), .ToString() );
258 // value.ToString(), .ToString() );
250 // var message = String.Join(", ", (object[])properties);
259 // var message = String.Join(", ", (object[])properties);
251 //
260 //
252
261
253 var properties = new List<string>();
262 var properties = new List<string>();
254
263
255 foreach (var property in typeof(T).GetProperties())
264 foreach (var property in typeof(T).GetProperties())
256 {
265 {
257 properties.Add(property.ToString() + "=" + property.GetValue(value));
266 properties.Add(property.ToString() + "=" + property.GetValue(value));
258 }
267 }
259
268
260 var message = "{" + String.Join(", ", properties) + "}";
269 var message = "{" + String.Join(", ", properties) + "}";
261
270
262 Logging.Log_(LogLevel.Spy, message, lineNumber, caller, path);
271 Logging.Log_(LogLevel.Spy, message, lineNumber, caller, path);
263 }
272 }
264 }
273 }
265 }
274 }
@@ -2,12 +2,13
2
2
3 using Encompass;
3 using Encompass;
4
4
5 namespace isometricparkfna.Messages {
5 namespace isometricparkfna.Messages
6 {
6
7
7
8
8 public struct GameRateMessage : IMessage//, IHasEntity
9 public struct GameRateMessage : IMessage//, IHasEntity
9 {
10 {
10 public bool paused;
11 public bool paused;
11 public int rate;
12 public int? rate;
12 }
13 }
13 }
14 }
@@ -1,16 +1,18
1
1
2 using Encompass;
2 using Encompass;
3
3
4 namespace isometricparkfna.Messages {
4 namespace isometricparkfna.Messages
5
5 {
6 public enum Element {
7 Grid,
8 Trees
9 }
10
6
11 public struct ToggleVisibilityMessage : IMessage//, IHasEntity
7 public enum Element
12 {
8 {
9 Grid,
10 Trees
11 }
13
12
14 public Element Element;
13 public struct ToggleVisibilityMessage : IMessage
15 }
14 {
15
16 public Element Element;
17 }
16 }
18 }
@@ -1,12 +1,13
1 using Encompass;
1 using Encompass;
2
2
3 namespace isometricparkfna.Messages {
3 namespace isometricparkfna.Messages
4 {
4
5
5 //You must specify both or you get 0 for a window, which is the default window :(
6 //You must specify both or you get 0 for a window, which is the default window :(
6 public struct ToggleWindowMessage : IMessage, IHasEntity
7 public struct ToggleWindowMessage : IMessage, IHasEntity
7 {
8 {
8
9
9 public Window Window;
10 public Window Window;
10 public Entity Entity { set; get; }
11 public Entity Entity { set; get; }
11 }
12 }
12 }
13 }
@@ -8,51 +8,50
8 using Encompass;
8 using Encompass;
9 using SpriteFontPlus;
9 using SpriteFontPlus;
10
10
11 namespace isometricparkfna.Renderers
11 namespace isometricparkfna.Renderers
12 {
12 {
13 public class AreaRenderer : GeneralRenderer
13 public class AreaRenderer : GeneralRenderer
14 {
14 {
15 private SpriteBatch batch;
15 private SpriteBatch batch;
16 private SpriteFont font;
16 private SpriteFont font;
17
18
19 public AreaRenderer(SpriteBatch batch, SpriteFont font)
20 {
21 this.batch = batch;
22 this.font = font;
23 }
17
24
18
25
19 public AreaRenderer(SpriteBatch batch, SpriteFont font)
26 public override void Render()
20 {
27 {
21 this.batch = batch;
28
22 this.font = font;
29 var budgetWindow = new BudgetWindow(new Budget { }, this.font, 0, 0);
23 }
24
30
25
31 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
26 public override void Render()
32 {
27 {
33 var areaComponent = GetComponent<AreaComponent>(entity);
28
34 // var SelectedComponent = GetComponent<SelectedComponent>(entity);
29 var budgetWindow = new BudgetWindow(new Budget { }, this.font, 0, 0);
30
31 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
32 {
33 var areaComponent = GetComponent<AreaComponent>(entity);
34 // var SelectedComponent = GetComponent<SelectedComponent>(entity);
35
35
36 if (!HasComponent<ContractStatusComponent>(entity)
36 if (!HasComponent<ContractStatusComponent>(entity)
37 || GetComponent<ContractStatusComponent>(entity).status == ContractStatus.Accepted
37 || GetComponent<ContractStatusComponent>(entity).status == ContractStatus.Accepted
38 )
38 )
39 {
39 {
40 Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal);
40 Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal);
41 Quad.FillSquares(batch, areaComponent.squares, Color.Teal, 0.5f, 0.79f);
41 Quad.FillSquares(batch, areaComponent.squares, Color.Teal, 0.5f, 0.79f);
42 }
42
43
43 }
44 var selected = GetComponent<SelectedComponent>(entity).selected;
44
45 var selected = GetComponent<SelectedComponent>(entity).selected;
46
45
47 if (HasComponent<ContractStatusComponent>(entity)
46 if (HasComponent<ContractStatusComponent>(entity)
48 && selected
47 && selected
49 // && GetComponent<SelectedComponent>(entity).selected
48 // && GetComponent<SelectedComponent>(entity).selected
50 )
49 )
51 {
50 {
52 Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal);
51 Tile.DrawOutlinedSquares(batch, areaComponent.squares, Color.Teal);
53 Quad.FillSquares(batch, areaComponent.squares, Color.Gray, 0.5f, 0.80f);
52 Quad.FillSquares(batch, areaComponent.squares, Color.Gray, 0.5f, 0.80f);
54 }
53 }
55 }
54 }
56 }
55 }
57 }
56 }
58 }
57 } No newline at end of file
@@ -7,36 +7,28
7 using Encompass;
7 using Encompass;
8 using SpriteFontPlus;
8 using SpriteFontPlus;
9
9
10 namespace isometricparkfna.Renderers
10 namespace isometricparkfna.Renderers
11 {
11 {
12 public class BudgetWindowRenderer : GeneralRenderer
12 public class BudgetWindowRenderer : GeneralRenderer
13 {
13 {
14 private SpriteBatch batch;
14 private SpriteBatch batch;
15 private SpriteFont font;
15 private SpriteFont font;
16
16
17
17 public BudgetWindowRenderer(SpriteBatch batch, SpriteFont font)
18 public BudgetWindowRenderer(SpriteBatch batch, SpriteFont font)
18 {
19 {
19 this.batch = batch;
20 this.batch = batch;
20 this.font = font;
21 this.font = font;
21 }
22 }
23
22
24
23 public override void Render()
25 public override void Render()
24 {
26 {
25 var budgetWindow = new BudgetWindow(new Budget { }, this.font, 0, 0);
27
28 var budgetWindow = new BudgetWindow(new Budget { }, this.font, 0, 0);
29
26
30 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
27 foreach (ref readonly var entity in ReadEntities<BudgetComponent>())
31 {
28 {
32 // budgetWindow.update
29 // budgetWindow.update
33 // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
30 // this.showBudget = this.budgetWindow.update(mouseCur, this.simulation.latestBudget, this.simulation.previousBudget);
34
31 }
35 }
32 }
36
33 }
37
34 } No newline at end of file
38
39
40 }
41 }
42 }
@@ -1,6 +1,7
1 using Microsoft.Xna.Framework;
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
2 using Microsoft.Xna.Framework.Graphics;
3
3
4 using System;
4 using System.Collections.Generic;
5 using System.Collections.Generic;
5 using System.Linq;
6 using System.Linq;
6
7
@@ -14,22 +15,28
14 using Encompass;
15 using Encompass;
15 using SpriteFontPlus;
16 using SpriteFontPlus;
16
17
17 namespace isometricparkfna.Renderers
18 namespace isometricparkfna.Renderers
18 {
19 {
19 public class ImGuiWindowRenderer : GeneralRenderer
20 class ImGuiWindowRenderer : GeneralRenderer
20 {
21 {
21 private ImFontPtr font;
22 private ImFontPtr italicFont;
22 private ImFontPtr italicFont;
23 private ImGuiWindowBridgeEngine BridgeEngine;
23 private ImGuiWindowBridgeEngine BridgeEngine;
24 public ImGuiWindowRenderer(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine)
24 private FNAGame game;
25 {
25
26 this.font = font;
26 private GraphicsDeviceManager gdm;
27
28 public ImGuiWindowRenderer(FNAGame game, ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, GraphicsDeviceManager gdm)
29 {
30 // this.font = font;
27 this.italicFont = italicFont;
31 this.italicFont = italicFont;
28 this.BridgeEngine = engine;
32 this.BridgeEngine = engine;
29 }
33 this.game = game;
34 this.gdm = gdm;
35 }
30
36
31 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
37 private (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square)
32 getContractDetails(Entity entity) {
38 getContractDetails(Entity entity)
39 {
33
40
34 var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName;
41 var name = GetComponent<NameAndDescriptionComponent>(entity).DisplayName;
35 var status = GetComponent<ContractStatusComponent>(entity).status;
42 var status = GetComponent<ContractStatusComponent>(entity).status;
@@ -38,25 +45,27
38 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
45 var image_index = GetComponent<ImageComponent>(entity).ImageIndex;
39 var description = "";
46 var description = "";
40
47
41 var square = GetComponent<AreaComponent>(entity).squares[0];
48 var square = GetComponent<AreaComponent>(entity).squares[0];
42
49
43
50
44 if (HasComponent<RelatedOrganizationComponent>(entity))
51 if (HasComponent<RelatedOrganizationComponent>(entity))
45 {
52 {
46 var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity;
53 var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity;
47
54
48 var name_component = GetComponent<NameAndDescriptionComponent>(related_organization);
55 var name_component = GetComponent<NameAndDescriptionComponent>(related_organization);
49 name = name_component.DisplayName;
56 name = name_component.DisplayName;
50 description = name_component.Description;
57 description = name_component.Description;
51 image_index = GetComponent<ImageComponent>(related_organization).ImageIndex;
58 image_index = GetComponent<ImageComponent>(related_organization).ImageIndex;
52 }
59 }
53
60
54 return (entity, name, description, status, amount, tree_delta, image_index, square);
61 return (entity, name, description, status, amount, tree_delta, image_index, square);
55
62
56 }
63 }
57
64
58 public override void Render()
65 public override void Render()
59 {
66 {
67
68 var width = gdm.PreferredBackBufferWidth;
60 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
69 foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>())
61 {
70 {
62 var window_type = GetComponent<WindowTypeComponent>(entity).type;
71 var window_type = GetComponent<WindowTypeComponent>(entity).type;
@@ -71,33 +80,47
71
80
72 var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>();
81 var contract_data = new List<(Entity, string, string, ContractStatus, decimal, string, int, Vector2)>();
73
82
74 foreach(var e in contracts)
83 foreach (var e in contracts)
75 {
84 {
76 contract_data.Add(getContractDetails(e));
85 contract_data.Add(getContractDetails(e));
77 }
86 }
78
87
79 ContractsWindow.Render(this.font, this.BridgeEngine, contract_data);
88 ContractsWindow.Render(this.BridgeEngine.font, this.BridgeEngine, contract_data);
80 break;
89 break;
81 case Window.Contract:
90 case Window.Contract:
82
91
83 var data = getContractDetails(entity);
92 var data = getContractDetails(entity);
84
93
85 // var area_size = GetComponent<AreaComponent>(entity).squares.Length;
94 // var area_size = GetComponent<AreaComponent>(entity).squares.Length;
86 var area = GetComponent<AreaComponent>(entity).squares;
95 var area = GetComponent<AreaComponent>(entity).squares;
87 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
96 var area_size = GetComponent<AreaComponent>(entity).squares.Length;
88
97
89 ContractWindow.Render(this.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index, data.square);
98 ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, entity, data.name, data.description, data.status, data.amount, data.delta_trees, area_size, data.image_index, data.square);
90
99
91 break;
100 break;
92
101 case Window.MainMenu:
102 MainMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width);
103 break;
104 case Window.InGameMenu:
105 InGameMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width);
106 break;
107 case Window.Options:
108 OptionsWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine, width);
109 break;
110 case Window.NewGame:
111 NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine);
112 break;
93 default:
113 default:
114 // Logging.Error(String.Format("Unknown window type {0} ", window_type));
94 break;
115 break;
95 }
116 }
96 }
117 }
97
98 }
118 }
99
100 }
119 }
101
120
121 public void setFont(ImFontPtr font)
122 {
123 this.BridgeEngine.font = font;
124 }
102 }
125 }
103 }
126 }
@@ -26,6 +26,8
26 public decimal upkeep;
26 public decimal upkeep;
27 public decimal tree_planting;
27 public decimal tree_planting;
28 public decimal tree_clearing;
28 public decimal tree_clearing;
29 public decimal miscellaneous;
30 public decimal enforcement;
29
31
30
32
31 public decimal final_money;
33 public decimal final_money;
@@ -59,6 +61,14
59 public const int MAX_TREES_TO_PLANT = 25;
61 public const int MAX_TREES_TO_PLANT = 25;
60 public const int MAX_TREES_TO_CLEAR = 25;
62 public const int MAX_TREES_TO_CLEAR = 25;
61
63
64 public decimal Subsidy { get; set;
65 /* {
66 var dateSpan = DateTimeSpan.CompareDates(this.START_DATETIME, this.DateTime);
67 var months = (dateSpan.Years * 12) + dateSpan.Years; }*/
68 }
69
70 public decimal SubsidyDelta { get; set;}
71
62 public int Tick
72 public int Tick
63 {
73 {
64 get;
74 get;
@@ -87,6 +97,7
87 public SimulationBridgeEngine BridgeEngine { get; private set; }
97 public SimulationBridgeEngine BridgeEngine { get; private set; }
88 // public SimulationBridgeEngine bridgeEngine {get;}
98 // public SimulationBridgeEngine bridgeEngine {get;}
89 public decimal contracts;
99 public decimal contracts;
100 public decimal enforcement;
90
101
91 public Budget latestBudget
102 public Budget latestBudget
92 {
103 {
@@ -214,7 +225,7
214 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
225 this.DateTime = new DateTime(START_YEAR, START_MONTH, START_DAY);
215
226
216 this.map = new CellMap(width, height);
227 this.map = new CellMap(width, height);
217 this.money = 100000;
228 this.money = 100000M;
218 this.millisecondsPerAdvance = millisecondsPerAdvance;
229 this.millisecondsPerAdvance = millisecondsPerAdvance;
219
230
220 this.paused = true;
231 this.paused = true;
@@ -230,6 +241,7
230
241
231 var oldSeason = this.Season;
242 var oldSeason = this.Season;
232 this.DateTime = this.DateTime.AddMonths(1);
243 this.DateTime = this.DateTime.AddMonths(1);
244 this.Subsidy = Math.Max(0, this.Subsidy + this.SubsidyDelta);
233 var newSeason = this.Season;
245 var newSeason = this.Season;
234 var seasonChanged = oldSeason != newSeason;
246 var seasonChanged = oldSeason != newSeason;
235
247
@@ -294,8 +306,9
294 DateTime = this.DateTime,
306 DateTime = this.DateTime,
295 money = this.money,
307 money = this.money,
296 trees = this.map.tree_count,
308 trees = this.map.tree_count,
297 subsidy = 1000,
309 subsidy = this.Subsidy,
298 contracts = this.contracts,
310 contracts = this.contracts,
311 enforcement = this.enforcement,
299 upkeep = (int)(this.map.tree_count * 1.5),
312 upkeep = (int)(this.map.tree_count * 1.5),
300 tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST,
313 tree_planting = this.tree_planting * Simulation.TREE_PLANT_COST,
301 tree_clearing = this.tree_clearing * Simulation.TREE_CLEAR_COST
314 tree_clearing = this.tree_clearing * Simulation.TREE_CLEAR_COST
@@ -314,7 +327,7
314 {
327 {
315
328
316 this.money = budget.money
329 this.money = budget.money
317 - (budget.upkeep + budget.tree_planting + budget.tree_clearing)
330 - (budget.upkeep + budget.tree_planting + budget.tree_clearing + budget.enforcement)
318 + (budget.subsidy + budget.contracts);
331 + (budget.subsidy + budget.contracts);
319
332
320
333
@@ -109,6 +109,7
109 batch.DrawString(font, String.Format("Upkeep.................${0:}....${1:}", this.budget.upkeep, this.previous_budget.upkeep), new Vector2(x, bar_height * 10 + y), Color.Black);
109 batch.DrawString(font, String.Format("Upkeep.................${0:}....${1:}", this.budget.upkeep, this.previous_budget.upkeep), new Vector2(x, bar_height * 10 + y), Color.Black);
110 batch.DrawString(font, String.Format("Tree Planting..........${0:}....${1:}", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 11 + y), Color.Black);
110 batch.DrawString(font, String.Format("Tree Planting..........${0:}....${1:}", this.budget.tree_planting, this.previous_budget.tree_planting), new Vector2(x, bar_height * 11 + y), Color.Black);
111 batch.DrawString(font, String.Format("Tree Clearing..........${0:}....${1:}", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 12 + y), Color.Black);
111 batch.DrawString(font, String.Format("Tree Clearing..........${0:}....${1:}", this.budget.tree_clearing, this.previous_budget.tree_clearing), new Vector2(x, bar_height * 12 + y), Color.Black);
112 batch.DrawString(font, String.Format("Enforcement............${0:}....${1:}", this.budget.enforcement, this.previous_budget.enforcement), new Vector2(x, bar_height * 13 + y), Color.Black);
112
113
113 Color cashflow_color = Color.Black;
114 Color cashflow_color = Color.Black;
114 if (this.budget.cashflow < 0) {
115 if (this.budget.cashflow < 0) {
@@ -119,8 +120,8
119 final_color = Color.Red;
120 final_color = Color.Red;
120 }
121 }
121
122
122 batch.DrawString(font, String.Format("Cashflow.............${0:}....${1:}", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 14 + y), cashflow_color);
123 batch.DrawString(font, String.Format("Cashflow.............${0:}....${1:}", this.budget.cashflow, this.previous_budget.cashflow), new Vector2(x, bar_height * 15 + y), cashflow_color);
123 batch.DrawString(font, String.Format("Ending Funds.........${0:}....${1:}", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 15 + y), final_color);
124 batch.DrawString(font, String.Format("Ending Funds.........${0:}....${1:}", this.budget.final_money, this.previous_budget.final_money), new Vector2(x, bar_height * 16 + y), final_color);
124
125
125
126
126 FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f);
127 FilledRectangle.drawFilledRectangle(batch, new Rectangle(50, 50, 50, 50), new Color (0, 0,0, 0), 0.99f);
@@ -22,8 +22,6
22 private static ImageMap map;
22 private static ImageMap map;
23 private static IntPtr _imGuiTexture;
23 private static IntPtr _imGuiTexture;
24
24
25 private static bool show = false;
26
27 private static Dictionary<string, bool> hadFocus = new Dictionary<string, bool>();
25 private static Dictionary<string, bool> hadFocus = new Dictionary<string, bool>();
28
26
29 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
27 public static void LoadContent(ImGuiRenderer _imGuiRenderer, ImageMap map)
@@ -44,8 +42,7
44 ImGui.PushFont(font);
42 ImGui.PushFont(font);
45
43
46 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
44 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
47 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
45 StyleSets.defaultSet.push();
48 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
49 ImGui.SetNextWindowSize(new Num.Vector2(320, 420));
46 ImGui.SetNextWindowSize(new Num.Vector2(320, 420));
50
47
51 var title = string.Format("Contract {0} ## {1}", name, entity.ID);
48 var title = string.Format("Contract {0} ## {1}", name, entity.ID);
@@ -53,7 +50,7
53 if (ContractWindow.hadFocus.ContainsKey(title) &&
50 if (ContractWindow.hadFocus.ContainsKey(title) &&
54 ContractWindow.hadFocus[title])
51 ContractWindow.hadFocus[title])
55 {
52 {
56 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
53 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
57 }
54 }
58
55
59 ImGui.Begin(name, ref newShow,
56 ImGui.Begin(name, ref newShow,
@@ -164,8 +161,7
164
161
165 ImGui.End();
162 ImGui.End();
166 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
163 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
167 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
164 StyleSets.defaultSet.pop();
168 StyleSet.popColorSet(StyleSet.defaultWindowColors);
169 ImGui.PopFont();
165 ImGui.PopFont();
170
166
171 // Logging.Trace("Finished.");
167 // Logging.Trace("Finished.");
@@ -18,7 +18,7
18 public static class ContractsWindow
18 public static class ContractsWindow
19 {
19 {
20 public static bool show_all;
20 public static bool show_all;
21 public static bool had_focus = false;
21 public static bool had_focus = false;
22
22
23 private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) selected;
23 private static (Entity entity, string name, string description, ContractStatus status, decimal amount, string delta_trees, int image_index, Vector2 square) selected;
24
24
@@ -34,48 +34,44
34 ImGui.PushFont(font);
34 ImGui.PushFont(font);
35
35
36 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
36 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
37 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
37 StyleSets.defaultSet.push();
38 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
39
38
40 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
39 ImGui.SetNextWindowSize(new Num.Vector2(320, 340));
41 if(ContractsWindow.had_focus)
40 if (ContractsWindow.had_focus)
42 {
41 {
43 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
42 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
44 }
43 }
45 ImGui.Begin("Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
44 ImGui.Begin("Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
46 if (ContractsWindow.had_focus)
45 if (ContractsWindow.had_focus)
47 {
46 {
48 ImGui.PopStyleColor();
47 ImGui.PopStyleColor();
49 }
48 }
50 ContractsWindow.had_focus = ImGui.IsWindowFocused();
49 ContractsWindow.had_focus = ImGui.IsWindowFocused();
51
50
52 ImGui.ListBoxHeader("##Contracts:", new Num.Vector2(320, 150));
51 ImGui.ListBoxHeader("##Contracts:", new Num.Vector2(320, 150));
53
52
54 var filter_statuses = new[] {ContractStatus.Expired, ContractStatus.Broken, ContractStatus.Rejected};
53 var filter_statuses = new[] { ContractStatus.Expired, ContractStatus.Broken, ContractStatus.Rejected };
55
54
56 foreach (var contract in contracts.Where((contract) =>
55 foreach (var contract in contracts.Where((contract) =>
57 ((!(filter_statuses.Contains(contract.status))
56 ((!(filter_statuses.Contains(contract.status))
58 || ContractsWindow.show_all ))))
57 || ContractsWindow.show_all))))
59 {
58 {
60 if (ImGui.Selectable(String.Format("{0}##{1}",contract.name, contract.entity.ID),
59 if (ImGui.Selectable(String.Format("{0}##{1}", contract.name, contract.entity.ID),
61 ContractsWindow.selected.entity == contract.entity))
60 ContractsWindow.selected.entity == contract.entity))
62 {
61 {
63 ContractsWindow.selected.entity= contract.entity;
62 ContractsWindow.selected.entity = contract.entity;
64 // newSelected = contract.entity;
63 // newSelected = contract.entity;
65
64
66 }
65 }
67 if (ContractsWindow.selected.entity== contract.entity)
66 if (ContractsWindow.selected.entity == contract.entity)
68 {
67 {
69 ContractsWindow.selected = contract;
68 ContractsWindow.selected = contract;
70 }
69 }
71
70
72 if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0))
71 if (ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(0))
73 {
72 {
74 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity});
73 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity });
75
76
77 }
74 }
78
79
75
80 ImGui.SameLine();
76 ImGui.SameLine();
81 switch (contract.status)
77 switch (contract.status)
@@ -101,13 +97,13
101 ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), contract.status.ToString());
97 ImGui.TextColored(new Num.Vector4(0.25f, 0.25f, 0.25f, 1f), contract.status.ToString());
102 break;
98 break;
103 default:
99 default:
104 break;
100 break;
105 }
101 }
106 }
102 }
107 ImGui.ListBoxFooter();
103 ImGui.ListBoxFooter();
108
104
109 ImGui.Checkbox("Show All", ref show_all);
105 ImGui.Checkbox("Show All", ref show_all);
110
106
111 ImGui.Separator();
107 ImGui.Separator();
112 ImGui.Text(string.Format("Amount: ${0}/mo.", ContractsWindow.selected.amount));
108 ImGui.Text(string.Format("Amount: ${0}/mo.", ContractsWindow.selected.amount));
113
109
@@ -139,7 +135,7
139 {
135 {
140 System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity));
136 System.Console.Write(string.Format("{0} opened", ContractsWindow.selected.entity));
141
137
142 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity});
138 engine.messages.Add(new ToggleWindowMessage { Window = Window.Contract, Entity = ContractsWindow.selected.entity });
143
139
144 }
140 }
145
141
@@ -153,15 +149,14
153
149
154 ImGui.End();
150 ImGui.End();
155 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
151 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
156 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
152 StyleSets.defaultSet.pop();
157 StyleSet.popColorSet(StyleSet.defaultWindowColors);
158 ImGui.PopFont();
153 ImGui.PopFont();
159 }
154 }
160
155
161 if (!newShow)
156 if (!newShow)
162 {
157 {
163 Logging.Spy(newShow, "newShow");
158 Logging.Spy(newShow, "newShow");
164 Logging.Trace("Contracts toggled.");
159 Logging.Trace("Contracts toggled.");
165 engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.Contracts });
160 engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.Contracts });
166 }
161 }
167
162
@@ -36,9 +36,20
36
36
37 public ImageMap map;
37 public ImageMap map;
38
38
39 private ImGuiRenderer renderer;
40
41 public static Dictionary<string, string> fonts = new Dictionary<String, string>{{"Roboto" , @"Content/Roboto-Regular.ttf"},
42 {"RobotoMedium" , @"Content/Roboto-Medium.ttf"},
43 {"Iosevka", @"Content/iosevka-term-extendedmedium.ttf"}};
44 public static Dictionary<string, string> italicFonts = new Dictionary<String, string>{{"Roboto" , @"Content/Roboto-Italic.ttf"},
45 {"RobotoMedium" , @"Content/Roboto-Medium.ttf"},
46 {"Iosevka", @"Content/iosevka-term-extendedmediumitalic.ttf"}};
47
39
48
40 public DebugWindow(ImGuiRenderer _imGuiRenderer, GraphicsDevice graphicsDevice, ImageMap map)
49 public DebugWindow(ImGuiRenderer _imGuiRenderer, GraphicsDevice graphicsDevice, ImageMap map)
41 {
50 {
51
52 this.renderer = _imGuiRenderer;
42 ImGuiIOPtr io = ImGui.GetIO();
53 ImGuiIOPtr io = ImGui.GetIO();
43 //io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-medium.ttf", 15);
54 //io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-medium.ttf", 15);
44
55
@@ -49,6 +60,10
49 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 20);
60 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 20);
50 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 25);
61 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 25);
51 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 30);
62 io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 30);
63 io.Fonts.AddFontFromFileTTF(@"Content/Roboto-Regular.ttf", 15);
64 io.Fonts.AddFontFromFileTTF(@"Content/Roboto-Regular.ttf", 30);
65 io.Fonts.AddFontFromFileTTF(@"Content/Roboto-Medium.ttf", 15);
66 io.Fonts.AddFontFromFileTTF(@"Content/Roboto-Medium.ttf", 30);
52 #endif
67 #endif
53
68
54 this.monoFont = io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 15);
69 this.monoFont = io.Fonts.AddFontFromFileTTF(@"Content/iosevka-term-extendedmedium.ttf", 15);
@@ -81,6 +96,65
81 _imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
96 _imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture);
82 }
97 }
83
98
99 public void swap()
100 {
101 ImGuiIOPtr io = ImGui.GetIO();
102
103 this.monoFont = io.Fonts.AddFontFromFileTTF(@"Content/Roboto-Regular.ttf", 15);
104 unsafe //god this sucks
105 {
106 ImFontConfigPtr config = ImGuiNative.ImFontConfig_ImFontConfig();
107 config.MergeMode = true;
108 var builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
109 // builder.AddText("\ue125\ue126");
110 var icon_ranges = new ushort[] { 0xe000, 0xe1f4, 0 };
111 GCHandle rangeHandle = GCHandle.Alloc(icon_ranges, GCHandleType.Pinned);
112 io.Fonts.AddFontFromFileTTF(@"Content/typicons.ttf", 15, config, rangeHandle.AddrOfPinnedObject());
113
114
115 }
116 this.renderer.RebuildFontAtlas(); // Required so fonts are available for rendering
117 }
118
119 public ImFontPtr addFont(String name, int size, bool italic)
120 {
121 ImGuiIOPtr io = ImGui.GetIO();
122 ImFontPtr font;
123
124 if (italic)
125 {
126 font = io.Fonts.AddFontFromFileTTF(italicFonts[name], size);
127 }
128 else
129 {
130 font = io.Fonts.AddFontFromFileTTF(fonts[name], size);
131 }
132 unsafe //god this sucks
133 {
134 ImFontConfigPtr config = ImGuiNative.ImFontConfig_ImFontConfig();
135 config.MergeMode = true;
136 var builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
137 // builder.AddText("\ue125\ue126");
138 var icon_ranges = new ushort[] { 0xe000, 0xe1f4, 0 };
139 GCHandle rangeHandle = GCHandle.Alloc(icon_ranges, GCHandleType.Pinned);
140 io.Fonts.AddFontFromFileTTF(@"Content/typicons.ttf", size, config, rangeHandle.AddrOfPinnedObject());
141
142
143 }
144 this.renderer.RebuildFontAtlas(); // Required so fonts are available for rendering
145 return font;
146 }
147
148 public void setMonoFont(ImFontPtr font)
149 {
150 this.monoFont = font;
151 }
152
153 public void setItalicFont(ImFontPtr font)
154 {
155 this.italicFont = font;
156 }
157
84 public static Texture2D CreateTexture(GraphicsDevice device, int width, int height, Func<int, Color> paint)
158 public static Texture2D CreateTexture(GraphicsDevice device, int width, int height, Func<int, Color> paint)
85 {
159 {
86 //initialize a texture
160 //initialize a texture
@@ -180,6 +254,18
180 Logging.Spy(new {debugInfo.cameraPosition, debugInfo.updateTime, test = 9.0f /2});
254 Logging.Spy(new {debugInfo.cameraPosition, debugInfo.updateTime, test = 9.0f /2});
181
255
182 }
256 }
257
258 if (ImGui.BeginCombo("Log Level", Logging.minimumConsoleLevel.ToString()))
259 {
260 foreach(LogLevel level in LogLevel.GetValues(typeof(LogLevel)))
261 {
262 if(ImGui.Selectable(level.ToString()))
263 {
264 Logging.minimumConsoleLevel = level;
265 }
266 }
267 }
268
183 if (debugInfo.pastFps.Length >= 1)
269 if (debugInfo.pastFps.Length >= 1)
184 {
270 {
185 ImGui.PlotLines("Frame Rate", ref debugInfo.pastFps[0], debugInfo.pastFps.Length);
271 ImGui.PlotLines("Frame Rate", ref debugInfo.pastFps[0], debugInfo.pastFps.Length);
@@ -198,8 +284,6
198 ImGui.End();
284 ImGui.End();
199 }
285 }
200
286
201
202
203 if (this.show_test_window)
287 if (this.show_test_window)
204 {
288 {
205 ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver);
289 ImGui.SetNextWindowPos(new Num.Vector2(650, 20), ImGuiCond.FirstUseEver);
@@ -43,11 +43,12
43 public static Node<DialogOption> testTree = new Node<DialogOption>(
43 public static Node<DialogOption> testTree = new Node<DialogOption>(
44 new DialogOption
44 new DialogOption
45 {
45 {
46 response = "#[name:player]addressGreeting#",
46 response = "#addressGreetingFormal#",
47 speaker = "#assistantName#"
47 speaker = "#assistantName#"
48 },
48 },
49
50 new Node<DialogOption>[]{
49 new Node<DialogOption>[]{
50 new Node<DialogOption>(new DialogOption {choice="Call me #playerCasual#", response="Sure",
51 speaker = "#assistantName#" }),
51 new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!",
52 new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!",
52 speaker = "#assistantName#" }),
53 speaker = "#assistantName#" }),
53 new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#",
54 new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#",
@@ -98,7 +99,6
98
99
99 }
100 }
100
101
101
102 }
102 }
103
103
104 }
104 }
@@ -115,13 +115,12
115 ImGui.PushFont(font);
115 ImGui.PushFont(font);
116 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
116 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
117
117
118 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
118 StyleSets.defaultSet.push();
119 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
120
119
121 ImGui.SetNextWindowSize(new Num.Vector2(400, 200));
120 ImGui.SetNextWindowSize(new Num.Vector2(400, 200));
122 if(DialogInterface.hadFocus)
121 if(DialogInterface.hadFocus)
123 {
122 {
124 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
123 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
125 }
124 }
126 ImGui.Begin(currentNode.data.speaker, ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
125 ImGui.Begin(currentNode.data.speaker, ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
127 if (DialogInterface.hadFocus)
126 if (DialogInterface.hadFocus)
@@ -166,8 +165,7
166 }
165 }
167 ImGui.End();
166 ImGui.End();
168 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
167 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
169 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
168 StyleSets.defaultSet.pop();
170 StyleSet.popColorSet(StyleSet.defaultWindowColors);
171 ImGui.PopFont();
169 ImGui.PopFont();
172 }
170 }
173 return new_child;
171 return new_child;
@@ -1,8 +1,10
1 using System;
2 using Num = System.Numerics;
3
1 using ImGuiNET;
4 using ImGuiNET;
2
5
3 using Num = System.Numerics;
4
5 using isometricparkfna.Messages;
6 using isometricparkfna.Messages;
7 using isometricparkfna.Components;
6 using isometricparkfna.Engines;
8 using isometricparkfna.Engines;
7
9
8 namespace isometricparkfna.UI
10 namespace isometricparkfna.UI
@@ -11,6 +13,10
11 public static class ForestWindow
13 public static class ForestWindow
12 {
14 {
13 public static bool hadFocus = false;
15 public static bool hadFocus = false;
16
17 private static bool enforceTresspassing1 = false;
18 private static string enforceTresspassing2 = "None";
19
14 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
20 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
15 {
21 {
16 bool newShow = show;
22 bool newShow = show;
@@ -19,13 +25,12
19 ImGui.PushFont(font);
25 ImGui.PushFont(font);
20
26
21 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
27 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
22 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
28 StyleSets.defaultSet.push();
23 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
24
29
25
30
26 if(ForestWindow.hadFocus)
31 if(ForestWindow.hadFocus)
27 {
32 {
28 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
33 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
29 }
34 }
30
35
31 ImGui.Begin("Forest Policy", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
36 ImGui.Begin("Forest Policy", ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings);
@@ -44,6 +49,53
44 ImGui.SliderInt("Tree Clearing", ref new_tree_clearing, 0, Simulation.MAX_TREES_TO_CLEAR, string.Format("%d (${0})", new_tree_clearing*Simulation.TREE_CLEAR_COST));
49 ImGui.SliderInt("Tree Clearing", ref new_tree_clearing, 0, Simulation.MAX_TREES_TO_CLEAR, string.Format("%d (${0})", new_tree_clearing*Simulation.TREE_CLEAR_COST));
45 sim.tree_clearing = new_tree_clearing;
50 sim.tree_clearing = new_tree_clearing;
46
51
52 ImGui.Checkbox("Enforce Trespassing.", ref enforceTresspassing1);
53
54 ImGui.Text("Enforce tresspassing?");
55 ImGui.SameLine();
56
57 if (ImGui.BeginCombo("##tresspassing2", enforceTresspassing2))
58 {
59
60 // if ( ImGui.Selectable("None"))
61 // {
62 // enforceTresspassing2 = "None";
63 // }
64 // if (ImGui.Selectable("Rangers, warnings"))
65 // {
66 // enforceTresspassing2 = "Rangers, warnings";
67 // }
68 // if (ImGui.Selectable("Rangers, citations"))
69 // {
70 // enforceTresspassing2 = "Rangers, citations";
71 // }
72
73 foreach (EnforcementLevel option in EnforcementLevel.GetValues(typeof(EnforcementLevel)))
74 {
75
76 if (ImGui.Selectable(option.ToString()))
77 {
78 enforceTresspassing2 = option.ToString();
79 }
80 }
81
82 ImGui.EndCombo();
83 }
84 ImGui.SameLine();
85 ImGui.TextDisabled("(?)");
86 if (ImGui.IsItemHovered())
87 {
88 var rect = ImGui.GetItemRectMax();
89 ImGui.SetNextWindowPos(rect + new Num.Vector2(15, 0));
90 ImGui.BeginTooltip();
91 ImGui.Text("Enforcing tresspassing lowers upkeep, but costs money.\n\nRacial minorities may also be targeted unfairly.");
92 ImGui.EndTooltip();
93 }
94
95
96
97 ImGui.Separator();
98
47 ImGui.Text(string.Format("Crowded Trees: {0}", sim.crowded_trees ));
99 ImGui.Text(string.Format("Crowded Trees: {0}", sim.crowded_trees ));
48 ImGui.Text(string.Format("Percent Healthy Trees: {0:F2}", sim.healthy_percent));
100 ImGui.Text(string.Format("Percent Healthy Trees: {0:F2}", sim.healthy_percent));
49 ImGui.Text(string.Format("Average Age of Trees: {0:F2}", sim.average_tree_age));
101 ImGui.Text(string.Format("Average Age of Trees: {0:F2}", sim.average_tree_age));
@@ -52,15 +104,14
52 if (ImGui.Button("Okay"))
104 if (ImGui.Button("Okay"))
53 {
105 {
54 show = false;
106 show = false;
107 Logging.Spy(new {newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)});
108 engine.trespassingPolicyMessages.Add(new SetTrespassingPolicyMessage{newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)});
55 }
109 }
56
110
57 ImGui.End();
111 ImGui.End();
58 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
112 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
59 // ImGui.PopStyleVar(3);
113 StyleSets.defaultSet.pop();
60 // ImGui.PopStyleColor(8);
114 ImGui.PopFont();
61 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
62 StyleSet.popColorSet(StyleSet.defaultWindowColors);
63 ImGui.PopFont();
64 }
115 }
65 if (show != newShow)
116 if (show != newShow)
66 {
117 {
@@ -13,18 +13,18
13
13
14 public const int MENU_BAR_HEIGHT = 20;
14 public const int MENU_BAR_HEIGHT = 20;
15
15
16 private static bool activeButton(string label, bool active, Num.Vector4 activeColor) {
16 private static bool activeButton(string label, bool active, Num.Vector4 activeColor, Num.Vector4 activeTextColor) {
17
17
18 if (active) {
18 if (active) {
19 ImGui.PushStyleColor(ImGuiCol.Button, activeColor);
19 ImGui.PushStyleColor(ImGuiCol.Button, activeColor);
20 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, activeColor);
20 ImGui.PushStyleColor(ImGuiCol.ButtonHovered, activeColor);
21 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
21 ImGui.PushStyleColor(ImGuiCol.Text, activeTextColor);
22 }
22 }
23
23
24 var result = ImGui.Button(label);
24 var result = ImGui.Button(label);
25
25
26 if (active) {
26 if (active) {
27 ImGui.PopStyleColor(3);
27 ImGui.PopStyleColor(3);
28 }
28 }
29
29
30 return result;
30 return result;
@@ -35,82 +35,81
35
35
36 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
36 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
37
37
38
38 StyleSets.defaultSet.push();
39 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
39 ImGui.PushStyleColor(ImGuiCol.MenuBarBg, StyleSets.grey);
40 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
41 ImGui.PushStyleColor(ImGuiCol.MenuBarBg, StyleSet.grey);
42
40
43 if (ImGui.BeginMainMenuBar())
41 if (ImGui.BeginMainMenuBar())
44 {
42 {
45
46 ImGui.Text(header);
43 ImGui.Text(header);
47
44
48 ImGui.SetCursorPosX(width - 520);
45
46 var dimensions = ImGui.CalcTextSize("X Contracts $ Budget X Forest X News X | Pause 1 2 3 4 5") ;
49
47
50 if (Menu.activeButton("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSet.selected))
48 // ImGui.SetCursorPosX(width - 520);
49 // Add 12 pixels for each button, plus separator
50 ImGui.SetCursorPosX(width - (dimensions.X + 11*12));
51
52 if (Menu.activeButton("\ue0c2 Contracts", bridgeEngine.windowStatuses[Window.Contracts], StyleSets.selected, StyleSets.white))
51 {
53 {
52 Logging.Trace("Contracts toggled.");
54 Logging.Trace("Contracts toggled.");
53 Logging.Spy(bridgeEngine.windowStatuses, "statuses");
55 Logging.Spy(bridgeEngine.windowStatuses, "statuses");
54 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts});
56 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Contracts});
55 }
57 }
56 //Budget isn't connected to an entity yet:
58 //Budget isn't connected to an entity yet:
57 if (Menu.activeButton("$ Budget", showBudget, StyleSet.selected))
59 if (Menu.activeButton("$ Budget", showBudget, StyleSets.selected, StyleSets.white))
58 {
60 {
59 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Budget});
61 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Budget});
60
62
61 }
63 }
62 if (Menu.activeButton("\ue124 Forest", bridgeEngine.windowStatuses[Window.Forest], StyleSet.selected))
64 if (Menu.activeButton("\ue124 Forest", bridgeEngine.windowStatuses[Window.Forest], StyleSets.selected, StyleSets.white))
63 {
65 {
64 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Forest});
66 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.Forest});
65
67
66 }
68 }
67 if (Menu.activeButton("\ue0bf News", bridgeEngine.windowStatuses[Window.News], StyleSet.selected))
69 if (Menu.activeButton("\ue0bf News", bridgeEngine.windowStatuses[Window.News], StyleSets.selected, StyleSets.white))
68 {
70 {
69 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.News});
71 bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage{Window = Window.News});
70 }
72 }
71
73
72 ImGui.Text("|");
74 ImGui.Text("|");
73
75
74 if (Menu.activeButton("\ue0ac Pause", paused, StyleSet.selected ))
76 if (Menu.activeButton("\ue0ac Pause", paused, StyleSets.selected, StyleSets.white ))
75 {
77 {
76 paused = !paused;
78 paused = !paused;
77 }
79 }
78 if (Menu.activeButton("1", (rate == 0), StyleSet.selected))
80 if (Menu.activeButton("1", (rate == 0), StyleSets.selected, StyleSets.white))
79 {
81 {
80 paused = false;
82 paused = false;
81 rate = 0;
83 rate = 0;
82 }
84 }
83 else if (Menu.activeButton("2", (rate == 1), StyleSet.selected))
85 else if (Menu.activeButton("2", (rate == 1), StyleSets.selected, StyleSets.white))
84 {
86 {
85 paused = false;
87 paused = false;
86 rate = 1;
88 rate = 1;
87 }
89 }
88 else if (Menu.activeButton("3", (rate == 2), StyleSet.selected))
90 else if (Menu.activeButton("3", (rate == 2), StyleSets.selected, StyleSets.white))
89 {
91 {
90 paused = false;
92 paused = false;
91 rate = 2;
93 rate = 2;
92 }
94 }
93 else if (Menu.activeButton("4", (rate == 3), StyleSet.selected))
95 else if (Menu.activeButton("4", (rate == 3), StyleSets.selected, StyleSets.white))
94 {
96 {
95 paused = false;
97 paused = false;
96 rate = 3;
98 rate = 3;
97 }
99 }
98 #if DEBUG
100 #if DEBUG
99 else if (Menu.activeButton("5", (rate == 4), StyleSet.selected))
101 else if (Menu.activeButton("5", (rate == 4), StyleSets.selected, StyleSets.white))
100 {
102 {
101 paused = false;
103 paused = false;
102 rate = 4;
104 rate = 4;
103 }
105 }
104 #endif
106 #endif
105
107
106
107 ImGui.EndMainMenuBar();
108 ImGui.EndMainMenuBar();
108
109
109 // ImGui.End();
110 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
110 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
111
111
112 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
112 StyleSets.defaultSet.pop();
113 StyleSet.popColorSet(StyleSet.defaultWindowColors);
114 ImGui.PopStyleColor(1);
113 ImGui.PopStyleColor(1);
115 ImGui.PopFont();
114 ImGui.PopFont();
116 }
115 }
@@ -15,137 +15,151
15 namespace isometricparkfna.UI
15 namespace isometricparkfna.UI
16 {
16 {
17
17
18 public struct NewsItem {
18 public struct NewsItem
19 public string hed;
19 {
20 public string contents;
20 public string hed;
21 public string source;
21 public string contents;
22 public Dictionary<string, string> variables;
22 public string source;
23 public Dictionary<string, string> variables;
23
24
24 public NewsItem Flatten(TraceryNet.Grammar grammar) {
25 public NewsItem Flatten(TraceryNet.Grammar grammar)
26 {
25
27
26 var variableString = "#";
28 var variableString = "#";
27
29
28 if (this.variables != null) {
30 if (this.variables != null)
29 foreach (var variable in this.variables) {
31 {
30 variableString += String.Format("[{0}:{1}]", variable.Key, variable.Value);
32 foreach (var variable in this.variables)
31 }
33 {
32 }
34 variableString += String.Format("[{0}:{1}]", variable.Key, variable.Value);
35 }
36 }
33
37
34 variableString += "vars# ";
38 variableString += "vars# ";
35 var result = grammar.Flatten(variableString);
39 var result = grammar.Flatten(variableString);
36 // Logging.Trace(String.Format("{0}: {1}", variableString, result));
40 // Logging.Trace(String.Format("{0}: {1}", variableString, result));
37
41
38 return new NewsItem {
42 return new NewsItem
39 hed = grammar.Flatten(this.hed),
43 {
40 contents = grammar.Flatten(contents),
44 hed = grammar.Flatten(this.hed),
41 source = grammar.Flatten(this.source)
45 contents = grammar.Flatten(contents),
42 };
46 source = grammar.Flatten(this.source)
43 }
47 };
48 }
44
49
45
50
46
51
47 public static List<NewsItem> FromYaml(string yamlString) {
52 public static List<NewsItem> FromYaml(string yamlString)
48 var input = new StringReader(yamlString);
53 {
54 var input = new StringReader(yamlString);
49
55
50 var deserializer = new DeserializerBuilder()
56 var deserializer = new DeserializerBuilder()
51 .Build();
57 .Build();
52
53 //Dictionary<string, string>
54 var items = deserializer.Deserialize<List<NewsItem>>(input);
55
58
56 return items;
59 //Dictionary<string, string>
57 }
60 var items = deserializer.Deserialize<List<NewsItem>>(input);
58 }
59
61
60 public static class NewsWindow
62 return items;
61 {
63 }
64 }
62
65
63 public static bool had_focus = false;
66 public static class NewsWindow
67 {
68
69 public static bool had_focus = false;
64
70
65 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
71 public static void Render(bool show, ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine)
66 {
72 {
67 bool newShow = show;
73 bool newShow = show;
68 if (show)
74 if (show)
69 {
75 {
70 ImGui.PushFont(font);
76 ImGui.PushFont(font);
77
78 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
79
80 StyleSets.defaultSet.push();
81
82 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
71
83
72 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
84 if (NewsWindow.had_focus)
85 {
86 ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white);
87 }
88 ImGui.Begin("NEWS", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
73
89
74 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
90 if (NewsWindow.had_focus)
75 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
91 {
92 ImGui.PopStyleColor();
93 }
94 NewsWindow.had_focus = ImGui.IsWindowFocused();
95
96 var content = sim.latestNewsItems;
76
97
77
98
78 ImGui.SetNextWindowSize(new Num.Vector2(400, 400));
99 if (ImGui.BeginTabBar("Sources", 0))
79
100 {
80 if(NewsWindow.had_focus)
81 {
82 ImGui.PushStyleColor(ImGuiCol.Text, StyleSet.white);
83 }
84 ImGui.Begin("NEWS", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings);
85
86 if (NewsWindow.had_focus)
87 {
88 ImGui.PopStyleColor();
89 }
90 NewsWindow.had_focus = ImGui.IsWindowFocused();
91
92 var content = sim.latestNewsItems;
93
94
95 if (ImGui.BeginTabBar("Sources", 0)) {
96
101
97
102
98 if (ImGui.BeginTabItem("Wire")) {
103 if (ImGui.BeginTabItem("Wire"))
104 {
99
105
100 foreach (NewsItem story in content.Where( s => (s.source == "Wire" ) ).Take(3)) {
106 foreach (NewsItem story in content.Where(s => (s.source == "Wire")).Take(3))
101 if (ImGui.TreeNode(story.hed)) {
107 {
102 ImGui.TextWrapped(story.contents);
108 if (ImGui.TreeNode(story.hed))
103 ImGui.TreePop();
109 {
104 }
110 ImGui.TextWrapped(story.contents);
105 }
111 ImGui.TreePop();
106 ImGui.EndTabItem();
112 }
107 }
108 ImGui.EndTabItem();
109 if (ImGui.BeginTabItem("The Naturalist")) {
110 foreach (NewsItem story in content.Where( s => (s.source == "Arborist" ) ).Take(3)) {
111 if (ImGui.TreeNode(story.hed)) {
112 ImGui.TextWrapped(story.contents);
113 ImGui.TreePop();
114 }
115 }
116 ImGui.EndTabItem();
117 }
118 if (ImGui.BeginTabItem("All True News")) {
119 foreach (NewsItem story in content.Where( s => (s.source == "True" ) ).Take(3)) {
120 if (ImGui.TreeNode(story.hed)) {
121 ImGui.TextWrapped(story.contents);
122 ImGui.TreePop();
123 }
124 }
125 ImGui.EndTabItem();
126 }
127 }
113 }
114 ImGui.EndTabItem();
115 }
116 ImGui.EndTabItem();
117 if (ImGui.BeginTabItem("The Naturalist"))
118 {
119 foreach (NewsItem story in content.Where(s => (s.source == "Arborist")).Take(3))
120 {
121 if (ImGui.TreeNode(story.hed))
122 {
123 ImGui.TextWrapped(story.contents);
124 ImGui.TreePop();
125 }
126 }
127 ImGui.EndTabItem();
128 }
129 if (ImGui.BeginTabItem("All True News"))
130 {
131 foreach (NewsItem story in content.Where(s => (s.source == "True")).Take(3))
132 {
133 if (ImGui.TreeNode(story.hed))
134 {
135 ImGui.TextWrapped(story.contents);
136 ImGui.TreePop();
137 }
138 }
139 ImGui.EndTabItem();
140 }
141 }
128
142
129 ImGui.EndTabBar();
143 ImGui.EndTabBar();
130
144
131
145
132 if (ImGui.Button("Okay"))
146 if (ImGui.Button("Okay"))
133 {
147 {
134 show = false;
148 show = false;
135 }
136
137 ImGui.End();
138 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
139
140 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
141 StyleSet.popColorSet(StyleSet.defaultWindowColors);
142 ImGui.PopFont();
143 }
149 }
144
150
145 if (show != newShow)
151 ImGui.End();
146 {
152
147 engine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.News });
153 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
148 }
154 StyleSets.defaultSet.pop();
155
156 ImGui.PopFont();
157 }
158
159 if (show != newShow)
160 {
161 engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.News });
162 }
149 }
163 }
150 }
164 }
151 }
165 }
@@ -8,54 +8,8
8 {
8 {
9 public class StyleSet
9 public class StyleSet
10 {
10 {
11 public static Num.Vector4 grey = new Num.Vector4(0.75f, 0.75f, 0.75f, 1f);
12 public static Num.Vector4 darkgrey = new Num.Vector4(0.45f, 0.45f, 0.45f, 1f);
13 public static Num.Vector4 black = new Num.Vector4(0f, 0f, 0f, 1f);
14 public static Num.Vector4 white = new Num.Vector4(1f, 1f, 1f, 1f);
15 public static Num.Vector4 title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
16
11
17 // public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.75f, 1f);
12 // public static IMFont
18 public static Num.Vector4 selected = new Num.Vector4(0.0f, 0.0f, 0.55f, 1f);
19 public static Dictionary<ImGuiStyleVar, float> defaultWindowVars = new Dictionary<ImGuiStyleVar, float>{
20 { ImGuiStyleVar.FrameRounding, 0.0f },
21 {ImGuiStyleVar.WindowRounding, 0.0f},
22 {ImGuiStyleVar.FrameBorderSize, 1.0f},
23 {ImGuiStyleVar.TabRounding, 0.0f},
24 };
25 public static Dictionary<ImGuiCol, Num.Vector4> defaultWindowColors = new Dictionary<ImGuiCol, Num.Vector4>{
26
27 {ImGuiCol.WindowBg, grey},
28 {ImGuiCol.FrameBg, grey},
29 {ImGuiCol.FrameBgHovered, grey},
30 {ImGuiCol.Header, darkgrey},
31 {ImGuiCol.HeaderHovered, darkgrey},
32 {ImGuiCol.HeaderActive, darkgrey},
33 {ImGuiCol.ButtonHovered, grey},
34 {ImGuiCol.ButtonActive, darkgrey},
35 {ImGuiCol.SliderGrab, darkgrey},
36 {ImGuiCol.SliderGrabActive, darkgrey},
37
38
39 {ImGuiCol.Tab, darkgrey},
40 {ImGuiCol.TabHovered, darkgrey},
41 {ImGuiCol.TabActive, selected},
42
43 {ImGuiCol.CheckMark, black},
44
45 {ImGuiCol.TitleBg, title_bar},
46 {ImGuiCol.TitleBgActive, selected},
47 {ImGuiCol.TitleBgCollapsed, title_bar},
48
49 {ImGuiCol.Border, black},
50 {ImGuiCol.BorderShadow, black},
51
52 {ImGuiCol.PopupBg, white},
53
54 {ImGuiCol.Button, grey},
55 {ImGuiCol.Text, black}
56 };
57 /*
58 */
59 public static void pushStyleVarSet(Dictionary<ImGuiStyleVar, float> style_set)
13 public static void pushStyleVarSet(Dictionary<ImGuiStyleVar, float> style_set)
60 {
14 {
61 foreach(var pair in style_set)
15 foreach(var pair in style_set)
@@ -80,6 +34,32
80 {
34 {
81 ImGui.PopStyleColor(style_set.Count);
35 ImGui.PopStyleColor(style_set.Count);
82 }
36 }
37
38 public Dictionary<ImGuiStyleVar, float> WindowVars {get;}
39 public Dictionary<ImGuiCol, Num.Vector4> WindowColors {get;}
40
41 public StyleSet(Dictionary<ImGuiStyleVar, float> windowVars,
42 Dictionary<ImGuiCol, Num.Vector4> windowColors
43 )
44 {
45
46 this.WindowVars = windowVars;
47 this.WindowColors = windowColors;
48 }
49
50 public void push()
51 {
52 StyleSet.pushColorSet(this.WindowColors);
53 StyleSet.pushStyleVarSet(this.WindowVars);
54 }
55
56 public void pop()
57 {
58 StyleSet.popColorSet(this.WindowColors);
59 StyleSet.popStyleVarSet(this.WindowVars);
60 }
61
62
83 }
63 }
84
64
85 }
65 }
@@ -17,9 +17,7
17 source[i] = tmp;
17 source[i] = tmp;
18 }
18 }
19
19
20
21 return source;
20 return source;
22
23 }
21 }
24 }
22 }
25 }
23 }
@@ -7,11 +7,6
7
7
8 public T data;
8 public T data;
9
9
10
11 public Node()
12 {
13 }
14
15 public Node(T data)
10 public Node(T data)
16 {
11 {
17 this.data = data;
12 this.data = data;
@@ -36,7 +36,7
36 <ItemGroup>
36 <ItemGroup>
37 <Reference Include="System" />
37 <Reference Include="System" />
38 <Reference Include="Newtonsoft.Json">
38 <Reference Include="Newtonsoft.Json">
39 <HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
39 <!-- <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> -->
40 </Reference>
40 </Reference>
41 <Reference Include="Tracery.Net">
41 <Reference Include="Tracery.Net">
42 <HintPath>..\packages\Tracery.Net.1.0.0\lib\net452\Tracery.Net.dll</HintPath>
42 <HintPath>..\packages\Tracery.Net.1.0.0\lib\net452\Tracery.Net.dll</HintPath>
@@ -47,7 +47,7
47 <ItemGroup>
47 <ItemGroup>
48 <PackageReference Include="ImGui.NET" Version="1.78.0" />
48 <PackageReference Include="ImGui.NET" Version="1.78.0" />
49 <PackageReference Include="Tracery.Net" Version="1.0.0" />
49 <PackageReference Include="Tracery.Net" Version="1.0.0" />
50 <PackageReference Include="YamlDotNet" Version="11.0.0" />
50 <PackageReference Include="YamlDotNet" Version="11.0.1" />
51 <PackageReference Include="JM.LinqFaster" Version="1.1.2" />
51 <PackageReference Include="JM.LinqFaster" Version="1.1.2" />
52 </ItemGroup>
52 </ItemGroup>
53 <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
53 <Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
@@ -21,6 +21,7
21 <WarningLevel>4</WarningLevel>
21 <WarningLevel>4</WarningLevel>
22 <LangVersion>8.0</LangVersion>
22 <LangVersion>8.0</LangVersion>
23 <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
23 <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
24 <AutogenerateBindingRedirects>true</AutogenerateBindingRedirects>
24 </PropertyGroup>
25 </PropertyGroup>
25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
26 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|anycpu' ">
26 <Optimize>true</Optimize>
27 <Optimize>true</Optimize>
@@ -47,6 +48,7
47 <Compile Include="FilledRectangle.cs" />
48 <Compile Include="FilledRectangle.cs" />
48 <Compile Include="Simulation.cs" />
49 <Compile Include="Simulation.cs" />
49 <Compile Include="Logging.cs" />
50 <Compile Include="Logging.cs" />
51 <Compile Include="Options.cs" />
50 <Compile Include="Components\*.cs" />
52 <Compile Include="Components\*.cs" />
51 <Compile Include="Engines\*.cs" />
53 <Compile Include="Engines\*.cs" />
52 <Compile Include="Messages\*.cs" />
54 <Compile Include="Messages\*.cs" />
@@ -54,7 +56,6
54 <Compile Include="Engines\Spawners\*.cs" />
56 <Compile Include="Engines\Spawners\*.cs" />
55 <Compile Include="Utils\MathUtils.cs" />
57 <Compile Include="Utils\MathUtils.cs" />
56 <Compile Include="Utils\Extensions.cs" />
58 <Compile Include="Utils\Extensions.cs" />
57 <Compile Include="Utils\Extensions.cs" />
58 <Compile Include="Utils\Node.cs" />
59 <Compile Include="Utils\Node.cs" />
59 <Compile Include="UI\BudgetWindow.cs" />
60 <Compile Include="UI\BudgetWindow.cs" />
60 <Compile Include="UI\ContractWindow.cs" />
61 <Compile Include="UI\ContractWindow.cs" />
@@ -65,6 +66,11
65 <Compile Include="UI\Menu.cs" />
66 <Compile Include="UI\Menu.cs" />
66 <Compile Include="UI\NewsWindow.cs" />
67 <Compile Include="UI\NewsWindow.cs" />
67 <Compile Include="UI\StyleSet.cs" />
68 <Compile Include="UI\StyleSet.cs" />
69 <Compile Include="UI\StyleSets.cs" />
70 <Compile Include="UI\MainMenu.cs" />
71 <Compile Include="UI\InGameMenu.cs" />
72 <Compile Include="UI\OptionsWindow.cs" />
73 <Compile Include="UI\NewGameWindow.cs" />
68 </ItemGroup>
74 </ItemGroup>
69 <ItemGroup>
75 <ItemGroup>
70 <ProjectReference Include="..\FNA\FNA.csproj">
76 <ProjectReference Include="..\FNA\FNA.csproj">
@@ -89,9 +95,6
89 <None Include="Content\FNASound.wav">
95 <None Include="Content\FNASound.wav">
90 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
96 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
91 </None>
97 </None>
92 <None Include="Content\DroidSans.ttf">
93 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
94 </None>
95 <None Include="packages.config" />
98 <None Include="packages.config" />
96 <None Include="Content\part4_tileset.png">
99 <None Include="Content\part4_tileset.png">
97 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
100 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -154,6 +157,15
154 <None Include="Content\photos_converted3.png">
157 <None Include="Content\photos_converted3.png">
155 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
158 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
156 </None>
159 </None>
160 <None Include="Content\Roboto-Medium.ttf">
161 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
162 </None>
163 <None Include="Content\Roboto-Regular.ttf">
164 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
165 </None>
166 <None Include="Content\Roboto-Italic.ttf">
167 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
168 </None>
157 </ItemGroup>
169 </ItemGroup>
158 <ItemGroup>
170 <ItemGroup>
159 <Reference Include="System" />
171 <Reference Include="System" />
@@ -171,10 +183,10
171 <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
183 <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
172 </Reference>
184 </Reference>
173 <Reference Include="Newtonsoft.Json">
185 <Reference Include="Newtonsoft.Json">
174 <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
186 <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
175 </Reference>
187 </Reference>
176 <Reference Include="YamlDotNet">
188 <Reference Include="YamlDotNet" Version="11.0.1">
177 <HintPath>..\packages\YamlDotNet.11.1.1\lib\net45\YamlDotNet.dll</HintPath>
189 <HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath>
178 </Reference>
190 </Reference>
179 <Reference Include="Tracery.Net">
191 <Reference Include="Tracery.Net">
180 <HintPath>..\packages\Tracery.Net.1.0.0\lib\net452\Tracery.Net.dll</HintPath>
192 <HintPath>..\packages\Tracery.Net.1.0.0\lib\net452\Tracery.Net.dll</HintPath>
1 NO CONTENT: modified file chmod 100644 => 100755
NO CONTENT: modified file chmod 100644 => 100755
You need to be logged in to leave comments. Login now