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 | 45 | case Window.Budget: |
|
46 | 46 | game.showBudget = !game.showBudget; |
|
47 | 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 | 39 | var newCost = message.newEnforcementLevel switch { |
|
40 | EnforcementLevel.Unspecified => 0, | |
|
40 | 41 | EnforcementLevel.NoEnforcement => 0, |
|
41 | 42 | EnforcementLevel.EnforcedWithWarnings => 100, |
|
42 | 43 | EnforcementLevel.EnforcedWithFines => 100 |
@@ -101,8 +101,6 | |||
|
101 | 101 | private GraphicsDeviceManager gdm; |
|
102 | 102 | public bool showBudget; |
|
103 | 103 | private BudgetWindow budgetWindow; |
|
104 | public bool showForest; | |
|
105 | public bool showNews; | |
|
106 | 104 | |
|
107 | 105 | //Encompass |
|
108 | 106 | private WorldBuilder WorldBuilder = new WorldBuilder(); |
@@ -158,8 +156,6 | |||
|
158 | 156 | |
|
159 | 157 | |
|
160 | 158 | showBudget = false; |
|
161 | showForest = false; | |
|
162 | showNews = false; | |
|
163 | 159 | showGrid = true; |
|
164 | 160 | showTrees = true; |
|
165 | 161 | |
@@ -276,7 +272,7 | |||
|
276 | 272 | WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); |
|
277 | 273 | |
|
278 | 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 | 276 | var contractWindow = WorldBuilder.CreateEntity(); |
|
281 | 277 | WorldBuilder.SetComponent(contractWindow, new VisibilityComponent { visible = false }); |
|
282 | 278 | WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Contracts }); |
@@ -834,16 +830,6 | |||
|
834 | 830 | |
|
835 | 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 | 833 | bool quit = false; |
|
848 | 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 | 24 | private ImFontPtr italicFont; |
|
25 | 25 | private ImGuiWindowBridgeEngine BridgeEngine; |
|
26 | 26 | private FNAGame game; |
|
27 | private Simulation simulation; | |
|
27 | 28 | |
|
28 | 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 | 33 | // this.font = font; |
|
33 | 34 | this.italicFont = italicFont; |
|
34 | 35 | this.BridgeEngine = engine; |
|
35 | 36 | this.game = game; |
|
37 | this.simulation = simulation; | |
|
36 | 38 | this.gdm = gdm; |
|
37 | 39 | } |
|
38 | 40 | |
@@ -128,6 +130,12 | |||
|
128 | 130 | ContractWindow.Render(this.BridgeEngine.font, this.italicFont, this.BridgeEngine, data); |
|
129 | 131 | |
|
130 | 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 | 139 | case Window.MainMenu: |
|
132 | 140 | MainMenu.Render(this.BridgeEngine.font, this.BridgeEngine, width); |
|
133 | 141 | break; |
@@ -15,12 +15,12 | |||
|
15 | 15 | public static bool hadFocus = false; |
|
16 | 16 | |
|
17 | 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 = |
|
|
23 |
if ( |
|
|
22 | bool newShow = true; | |
|
23 | if (newShow) | |
|
24 | 24 | { |
|
25 | 25 | ImGui.PushFont(font); |
|
26 | 26 | |
@@ -33,7 +33,7 | |||
|
33 | 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 | 37 | if (ForestWindow.hadFocus) |
|
38 | 38 | { |
|
39 | 39 | ImGui.PopStyleColor(); |
@@ -102,7 +102,7 | |||
|
102 | 102 | |
|
103 | 103 | if (ImGui.Button("Okay")) |
|
104 | 104 | { |
|
105 |
|
|
|
105 | newShow = false; | |
|
106 | 106 | Logging.Spy(new {newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
107 | 107 | engine.trespassingPolicyMessages.Add(new SetTrespassingPolicyMessage{newEnforcementLevel = (EnforcementLevel)Enum.Parse(typeof(EnforcementLevel), enforceTresspassing2)}); |
|
108 | 108 | } |
@@ -112,7 +112,7 | |||
|
112 | 112 | StyleSets.defaultSet.pop(); |
|
113 | 113 | ImGui.PopFont(); |
|
114 | 114 | } |
|
115 |
if ( |
|
|
115 | if (!newShow) | |
|
116 | 116 | { |
|
117 | 117 | engine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.Forest }); |
|
118 | 118 | } |
@@ -68,10 +68,10 | |||
|
68 | 68 | |
|
69 | 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 = |
|
|
74 |
if ( |
|
|
73 | bool newShow = true; | |
|
74 | if (newShow) | |
|
75 | 75 | { |
|
76 | 76 | ImGui.PushFont(font); |
|
77 | 77 | |
@@ -145,7 +145,7 | |||
|
145 | 145 | |
|
146 | 146 | if (ImGui.Button("Okay")) |
|
147 | 147 | { |
|
148 |
|
|
|
148 | newShow = false; | |
|
149 | 149 | } |
|
150 | 150 | |
|
151 | 151 | ImGui.End(); |
@@ -156,7 +156,7 | |||
|
156 | 156 | ImGui.PopFont(); |
|
157 | 157 | } |
|
158 | 158 | |
|
159 |
if ( |
|
|
159 | if (!newShow) | |
|
160 | 160 | { |
|
161 | 161 | engine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.News }); |
|
162 | 162 | } |
You need to be logged in to leave comments.
Login now