Description:
Refactor some window code out of FNAGame.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -45,12 +45,6 | |||||
|
45 | case Window.Budget: |
|
45 | case Window.Budget: |
|
46 | game.showBudget = !game.showBudget; |
|
46 | game.showBudget = !game.showBudget; |
|
47 | break; |
|
47 | break; |
|
48 | case Window.Forest: |
|
||
|
49 | game.showForest = !game.showForest; |
|
||
|
50 | break; |
|
||
|
51 | case Window.News: |
|
||
|
52 | game.showNews = !game.showNews; |
|
||
|
53 | break; |
|
||
|
54 |
|
48 | ||
|
55 | } |
|
49 | } |
|
56 | } |
|
50 | } |
@@ -37,6 +37,7 | |||||
|
37 | }); |
|
37 | }); |
|
38 |
|
38 | ||
|
39 | var newCost = message.newEnforcementLevel switch { |
|
39 | var newCost = message.newEnforcementLevel switch { |
|
|
40 | EnforcementLevel.Unspecified => 0, | ||
|
40 | EnforcementLevel.NoEnforcement => 0, |
|
41 | EnforcementLevel.NoEnforcement => 0, |
|
41 | EnforcementLevel.EnforcedWithWarnings => 100, |
|
42 | EnforcementLevel.EnforcedWithWarnings => 100, |
|
42 | EnforcementLevel.EnforcedWithFines => 100 |
|
43 | EnforcementLevel.EnforcedWithFines => 100 |
@@ -101,8 +101,6 | |||||
|
101 | private GraphicsDeviceManager gdm; |
|
101 | private GraphicsDeviceManager gdm; |
|
102 | public bool showBudget; |
|
102 | public bool showBudget; |
|
103 | private BudgetWindow budgetWindow; |
|
103 | private BudgetWindow budgetWindow; |
|
104 | public bool showForest; |
|
||
|
105 | public bool showNews; |
|
||
|
106 |
|
104 | ||
|
107 | //Encompass |
|
105 | //Encompass |
|
108 | private WorldBuilder WorldBuilder = new WorldBuilder(); |
|
106 | private WorldBuilder WorldBuilder = new WorldBuilder(); |
@@ -158,8 +156,6 | |||||
|
158 |
|
156 | ||
|
159 |
|
157 | ||
|
160 | showBudget = false; |
|
158 | showBudget = false; |
|
161 | showForest = false; |
|
||
|
162 | showNews = false; |
|
||
|
163 | showGrid = true; |
|
159 | showGrid = true; |
|
164 | showTrees = true; |
|
160 | showTrees = true; |
|
165 |
|
161 | ||
@@ -276,7 +272,7 | |||||
|
276 | WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); |
|
272 | WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); |
|
277 |
|
273 | ||
|
278 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
274 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
279 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, this.gdm) , 2); |
|
275 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, this.simulation, debugWindow.monoFont, debugWindow.italicFont, this.imGuiWindowBridgeEngine, this.gdm) , 2); |
|
280 | var contractWindow = WorldBuilder.CreateEntity(); |
|
276 | var contractWindow = WorldBuilder.CreateEntity(); |
|
281 | WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false }); |
|
277 | WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false }); |
|
282 | WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts }); |
|
278 | WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts }); |
@@ -834,16 +830,6 | |||||
|
834 |
|
830 | ||
|
835 | #region window |
|
831 | #region window |
|
836 |
|
832 | ||
|
837 | if (this.showForest) |
|
||
|
838 | { |
|
||
|
839 | ForestWindow.Render(this.showForest, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); |
|
||
|
840 | } |
|
||
|
841 |
|
|||
|
842 | if (this.showNews) |
|
||
|
843 | { |
|
||
|
844 | NewsWindow.Render(this.showNews, debugWindow.monoFont, this.simulation, this.imGuiWindowBridgeEngine); |
|
||
|
845 | } |
|
||
|
846 |
|
|||
|
847 | bool quit = false; |
|
833 | bool quit = false; |
|
848 | Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left); |
|
834 | Menu.Render(debugWindow.monoFont, FNAGame.width, this.imGuiWindowBridgeEngine, ref quit, ref this.simulation.paused, ref this.simulation.currentRate, ref this.showBudget, header_left); |
|
849 |
|
835 |
@@ -24,15 +24,17 | |||||
|
24 | private ImFontPtr italicFont; |
|
24 | private ImFontPtr italicFont; |
|
25 | private ImGuiWindowBridgeEngine BridgeEngine; |
|
25 | private ImGuiWindowBridgeEngine BridgeEngine; |
|
26 | private FNAGame game; |
|
26 | private FNAGame game; |
|
|
27 | private Simulation simulation; | ||
|
27 |
|
28 | ||
|
28 | private GraphicsDeviceManager gdm; |
|
29 | private GraphicsDeviceManager gdm; |
|
29 |
|
30 | ||
|
30 | public ImGuiWindowRenderer(FNAGame game, ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, GraphicsDeviceManager gdm) |
|
31 | public ImGuiWindowRenderer(FNAGame game, Simulation simulation, ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine engine, GraphicsDeviceManager gdm) |
|
31 | { |
|
32 | { |
|
32 | // this.font = font; |
|
33 | // this.font = font; |
|
33 | this.italicFont = italicFont; |
|
34 | this.italicFont = italicFont; |
|
34 | this.BridgeEngine = engine; |
|
35 | this.BridgeEngine = engine; |
|
35 | this.game = game; |
|
36 | this.game = game; |
|
|
37 | this.simulation = simulation; | ||
|
36 | this.gdm = gdm; |
|
38 | this.gdm = gdm; |
|
37 | } |
|
39 | } |
|
38 |
|
40 | ||
@@ -128,6 +130,12 | |||||
|
128 | ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, data); |
|
130 | ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, data); |
|
129 |
|
131 | ||
|
130 | break; |
|
132 | break; |
|
|
133 | case Window.News: | ||
|
|
134 | NewsWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine); | ||
|
|
135 | break; | ||
|
|
136 | case Window.Forest: | ||
|
|
137 | ForestWindow.Render(this.BridgeEngine.font, this.simulation, this.BridgeEngine); | ||
|
|
138 | break; | ||
|
131 | case Window.MainMenu: |
|
139 | case Window.MainMenu: |
|
132 | MainMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width); |
|
140 | MainMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width); |
|
133 | break; |
|
141 | break; |
@@ -15,12 +15,12 | |||||
|
15 | public static bool hadFocus = false; |
|
15 | public static bool hadFocus = false; |
|
16 |
|
16 | ||
|
17 | private static bool enforceTresspassing1 = false; |
|
17 | private static bool enforceTresspassing1 = false; |
|
18 |
private static string enforceTresspassing2 = " |
|
18 | private static string enforceTresspassing2 = "Unspecified"; |
|
19 |
|
19 | ||
|
20 |
public static void Render( |
|
20 | public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine) |
|
21 | { |
|
21 | { |
|
22 |
bool newShow = |
|
22 | bool newShow = true; |
|
23 |
if ( |
|
23 | if (newShow) |
|
24 | { |
|
24 | { |
|
25 | ImGui.PushFont(font); |
|
25 | ImGui.PushFont(font); |
|
26 |
|
26 | ||
@@ -33,7 +33,7 | |||||
|
33 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); |
|
33 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); |
|
34 | } |
|
34 | } |
|
35 |
|
35 | ||
|
36 |
ImGui.Begin("Forest Policy", ref |
|
36 | ImGui.Begin("Forest Policy", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings); |
|
37 | if (ForestWindow.hadFocus) |
|
37 | if (ForestWindow.hadFocus) |
|
38 | { |
|
38 | { |
|
39 | ImGui.PopStyleColor(); |
|
39 | ImGui.PopStyleColor(); |
@@ -102,7 +102,7 | |||||
|
102 |
|
102 | ||
|
103 | if (ImGui.Button("Okay")) |
|
103 | if (ImGui.Button("Okay")) |
|
104 | { |
|
104 | { |
|
105 |
|
|
105 | newShow = false; |
|
106 | Logging.Spy(new {newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
106 | Logging.Spy(new {newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
107 | engine.trespassingPolicyMessages.Add(new SetTrespassingPolicyMessage{newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
107 | engine.trespassingPolicyMessages.Add(new SetTrespassingPolicyMessage{newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
108 | } |
|
108 | } |
@@ -112,7 +112,7 | |||||
|
112 | StyleSets.defaultSet.pop(); |
|
112 | StyleSets.defaultSet.pop(); |
|
113 | ImGui.PopFont(); |
|
113 | ImGui.PopFont(); |
|
114 | } |
|
114 | } |
|
115 |
if ( |
|
115 | if (!newShow) |
|
116 | { |
|
116 | { |
|
117 | engine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Forest }); |
|
117 | engine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Forest }); |
|
118 | } |
|
118 | } |
@@ -68,10 +68,10 | |||||
|
68 |
|
68 | ||
|
69 | public static bool had_focus = false; |
|
69 | public static bool had_focus = false; |
|
70 |
|
70 | ||
|
71 |
public static void Render( |
|
71 | public static void Render(ImFontPtr font, Simulation sim, ImGuiWindowBridgeEngine engine) |
|
72 | { |
|
72 | { |
|
73 |
bool newShow = |
|
73 | bool newShow = true; |
|
74 |
if ( |
|
74 | if (newShow) |
|
75 | { |
|
75 | { |
|
76 | ImGui.PushFont(font); |
|
76 | ImGui.PushFont(font); |
|
77 |
|
77 | ||
@@ -145,7 +145,7 | |||||
|
145 |
|
145 | ||
|
146 | if (ImGui.Button("Okay")) |
|
146 | if (ImGui.Button("Okay")) |
|
147 | { |
|
147 | { |
|
148 |
|
|
148 | newShow = false; |
|
149 | } |
|
149 | } |
|
150 |
|
150 | ||
|
151 | ImGui.End(); |
|
151 | ImGui.End(); |
@@ -156,7 +156,7 | |||||
|
156 | ImGui.PopFont(); |
|
156 | ImGui.PopFont(); |
|
157 | } |
|
157 | } |
|
158 |
|
158 | ||
|
159 |
if ( |
|
159 | if (!newShow) |
|
160 | { |
|
160 | { |
|
161 | engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.News }); |
|
161 | engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.News }); |
|
162 | } |
|
162 | } |
You need to be logged in to leave comments.
Login now