Description:
Add contracts window.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,10 | |||
|
1 | using Encompass; | |
|
2 | ||
|
3 | using isometricparkfna.Messages; | |
|
4 | ||
|
5 | namespace isometricparkfna.Components { | |
|
6 | ||
|
7 | public struct WindowTypeComponent : IComponent { | |
|
8 | public Window type; | |
|
9 | } | |
|
10 | } |
@@ -0,0 +1,35 | |||
|
1 | ||
|
2 | ||
|
3 | ||
|
4 | using Microsoft.Xna.Framework.Input; | |
|
5 | ||
|
6 | using Encompass; | |
|
7 | ||
|
8 | using isometricparkfna.Messages; | |
|
9 | using isometricparkfna.Components; | |
|
10 | ||
|
11 | namespace isometricparkfna.Engines { | |
|
12 | ||
|
13 | [Receives(typeof(ToggleWindowMessage), typeof(ToggleVisibilityMessage))] | |
|
14 | [Reads(typeof(WindowTypeComponent), typeof(VisibilityComponent))] | |
|
15 | [Writes(typeof(VisibilityComponent))] | |
|
16 | class UIEngine : Engine | |
|
17 | { | |
|
18 | ||
|
19 | public override void Update(double dt) | |
|
20 | { | |
|
21 | foreach (ref readonly var windowMessage in ReadMessages<ToggleWindowMessage>()) | |
|
22 | { | |
|
23 | foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>()) | |
|
24 | { | |
|
25 | var window_type = GetComponent<WindowTypeComponent>(entity).type; | |
|
26 | if (window_type == windowMessage.Window) | |
|
27 | { | |
|
28 | var visibilityComponent = GetComponent<VisibilityComponent>(entity); | |
|
29 | SetComponent(entity, new VisibilityComponent{visible = !visibilityComponent.visible}); | |
|
30 | } | |
|
31 | } | |
|
32 | } | |
|
33 | } | |
|
34 | } | |
|
35 | } No newline at end of file |
@@ -0,0 +1,63 | |||
|
1 | using Microsoft.Xna.Framework; | |
|
2 | using Microsoft.Xna.Framework.Graphics; | |
|
3 | ||
|
4 | using System.Collections.Generic; | |
|
5 | ||
|
6 | using isometricparkfna.UI; | |
|
7 | using isometricparkfna.Engines; | |
|
8 | using isometricparkfna.Components; | |
|
9 | using isometricparkfna.Messages; | |
|
10 | ||
|
11 | using ImGuiNET; | |
|
12 | ||
|
13 | using Encompass; | |
|
14 | using SpriteFontPlus; | |
|
15 | ||
|
16 | namespace isometricparkfna.Renderers | |
|
17 | { | |
|
18 | public class ImGuiWindowRenderer : GeneralRenderer | |
|
19 | { | |
|
20 | private ImFontPtr font; | |
|
21 | private ImGuiWindowBridgeEngine BridgeEngine; | |
|
22 | public ImGuiWindowRenderer(ImFontPtr font, ImGuiWindowBridgeEngine engine) | |
|
23 | { | |
|
24 | this.font = font; | |
|
25 | this.BridgeEngine = engine; | |
|
26 | } | |
|
27 | ||
|
28 | public override void Render() | |
|
29 | { | |
|
30 | foreach (ref readonly var entity in ReadEntities<WindowTypeComponent>()) | |
|
31 | { | |
|
32 | var window_type = GetComponent<WindowTypeComponent>(entity).type; | |
|
33 | var visible = GetComponent<VisibilityComponent>(entity).visible; | |
|
34 | ||
|
35 | if (visible) | |
|
36 | { | |
|
37 | switch (window_type) | |
|
38 | { | |
|
39 | case Window.Contracts: | |
|
40 | var contracts = ReadEntities<AreaComponent>(); | |
|
41 | ||
|
42 | var names = new List<string>(); | |
|
43 | ||
|
44 | // var names = contracts.Select(entity => GetComponent<NameComponent>(entity).DisplayName) | |
|
45 | foreach(var e in contracts) | |
|
46 | { | |
|
47 | names.Add(GetComponent<NameComponent>(e).DisplayName); | |
|
48 | ||
|
49 | } | |
|
50 | ||
|
51 | ContractsWindow.Render(this.font, this.BridgeEngine, names); | |
|
52 | break; | |
|
53 | default: | |
|
54 | break; | |
|
55 | } | |
|
56 | } | |
|
57 | ||
|
58 | } | |
|
59 | ||
|
60 | } | |
|
61 | ||
|
62 | } | |
|
63 | } No newline at end of file |
@@ -0,0 +1,73 | |||
|
1 | using System.Collections.Generic; | |
|
2 | ||
|
3 | using ImGuiNET; | |
|
4 | ||
|
5 | using isometricparkfna.Engines; | |
|
6 | using isometricparkfna.Messages; | |
|
7 | ||
|
8 | using Num = System.Numerics; | |
|
9 | ||
|
10 | namespace isometricparkfna.UI | |
|
11 | { | |
|
12 | public static class ContractsWindow | |
|
13 | { | |
|
14 | ||
|
15 | public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine engine, List<string> contracts ) | |
|
16 | { | |
|
17 | bool newShow = true; | |
|
18 | if (newShow) | |
|
19 | { | |
|
20 | ImGui.PushFont(font); | |
|
21 | ||
|
22 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; | |
|
23 | ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f); | |
|
24 | ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f); | |
|
25 | ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f); | |
|
26 | ImGui.PushStyleVar(ImGuiStyleVar.TabRounding, 0.0f); | |
|
27 | ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
28 | ImGui.PushStyleColor(ImGuiCol.Header, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
29 | ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
30 | ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
31 | ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
32 | ||
|
33 | var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f); | |
|
34 | ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar); | |
|
35 | ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar); | |
|
36 | ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar); | |
|
37 | ||
|
38 | ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f)); | |
|
39 | ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f)); | |
|
40 | ||
|
41 | ||
|
42 | ||
|
43 | ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f)); | |
|
44 | ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f)); | |
|
45 | ImGui.SetNextWindowSize(new Num.Vector2(400, 400)); | |
|
46 | ImGui.Begin("Contracts", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings); | |
|
47 | ImGui.ListBoxHeader("Contracts:"); | |
|
48 | foreach (var contract in contracts) | |
|
49 | { | |
|
50 | // ImGui.Text(contract); | |
|
51 | ImGui.Selectable(contract, false); | |
|
52 | } | |
|
53 | ImGui.ListBoxFooter(); | |
|
54 | if (ImGui.Button("Okay")) | |
|
55 | { | |
|
56 | newShow = false; | |
|
57 | } | |
|
58 | ||
|
59 | ImGui.End(); | |
|
60 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; | |
|
61 | ImGui.PopStyleVar(4); | |
|
62 | ImGui.PopStyleColor(12); | |
|
63 | ImGui.PopFont(); | |
|
64 | } | |
|
65 | ||
|
66 | if (!newShow) | |
|
67 | { | |
|
68 | engine.messages.Add(new ToggleWindowMessage {Window = Window.Contracts }); | |
|
69 | } | |
|
70 | ||
|
71 | } | |
|
72 | } | |
|
73 | } No newline at end of file |
@@ -10,7 +10,7 | |||
|
10 | 10 | "args": [], |
|
11 | 11 | "env": { |
|
12 | 12 | "LD_LIBRARY_PATH": "${workspaceFolder}/isometric-park-fna/bin/Debug/netcoreapp3.1/lib64", |
|
13 |
"DYLD_LIBRARY_PATH": "${workspaceFolder}/ |
|
|
13 | "DYLD_LIBRARY_PATH": "${workspaceFolder}/fnalibs/osx" | |
|
14 | 14 | }, |
|
15 | 15 | "cwd": "${workspaceFolder}/isometric-park-fna/bin/Debug/netcoreapp3.1", |
|
16 | 16 | "console": "integratedTerminal", |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -11,7 +11,7 | |||
|
11 | 11 | EndProject |
|
12 | 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImGui.NET", "ImGui.NET\ImGui.NET.csproj", "{0023328E-2EFD-448B-BD85-A76769CD106A}" |
|
13 | 13 | EndProject |
|
14 |
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "encompass-cs", "encompass-cs\encompass-cs\encompass-cs.csproj", "{ |
|
|
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "encompass-cs", "encompass-cs\encompass-cs\encompass-cs.csproj", "{D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}" | |
|
15 | 15 | EndProject |
|
16 | 16 | Global |
|
17 | 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
@@ -71,18 +71,18 | |||
|
71 | 71 | {0023328E-2EFD-448B-BD85-A76769CD106A}.Debug|x64.Build.0 = Debug|Any CPU |
|
72 | 72 | {0023328E-2EFD-448B-BD85-A76769CD106A}.Release|x64.ActiveCfg = Release|Any CPU |
|
73 | 73 | {0023328E-2EFD-448B-BD85-A76769CD106A}.Release|x64.Build.0 = Release|Any CPU |
|
74 |
{ |
|
|
75 |
{ |
|
|
76 |
{ |
|
|
77 |
{ |
|
|
78 |
{ |
|
|
79 |
{ |
|
|
80 |
{ |
|
|
81 |
{ |
|
|
82 |
{ |
|
|
83 |
{ |
|
|
84 |
{ |
|
|
85 |
{ |
|
|
74 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|anycpu.ActiveCfg = Debug|Any CPU | |
|
75 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|anycpu.Build.0 = Debug|Any CPU | |
|
76 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|anycpu.ActiveCfg = Release|Any CPU | |
|
77 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|anycpu.Build.0 = Release|Any CPU | |
|
78 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x86.ActiveCfg = Debug|Any CPU | |
|
79 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x86.Build.0 = Debug|Any CPU | |
|
80 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x86.ActiveCfg = Release|Any CPU | |
|
81 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x86.Build.0 = Release|Any CPU | |
|
82 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x64.ActiveCfg = Debug|Any CPU | |
|
83 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Debug|x64.Build.0 = Debug|Any CPU | |
|
84 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x64.ActiveCfg = Release|Any CPU | |
|
85 | {D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}.Release|x64.Build.0 = Release|Any CPU | |
|
86 | 86 | EndGlobalSection |
|
87 | 87 | GlobalSection(SolutionProperties) = preSolution |
|
88 | 88 | HideSolutionNode = FALSE |
@@ -6,6 +6,7 | |||
|
6 | 6 | using Encompass; |
|
7 | 7 | |
|
8 | 8 | using isometricparkfna.Messages; |
|
9 | using isometricparkfna.Components; | |
|
9 | 10 | |
|
10 | 11 | namespace isometricparkfna.Engines { |
|
11 | 12 | |
@@ -18,6 +19,8 | |||
|
18 | 19 | typeof(ToggleVisibilityMessage), |
|
19 | 20 | typeof(TogglePauseMessage), |
|
20 | 21 | typeof(GameRateMessage))] |
|
22 | [Reads(typeof(WindowTypeComponent), | |
|
23 | typeof(VisibilityComponent))] | |
|
21 | 24 | public class InputEngine : Engine |
|
22 | 25 | { |
|
23 | 26 | private KeyboardState keyboardPrev; |
@@ -141,6 +144,10 | |||
|
141 | 144 | SendMessage(new ToggleWindowMessage{Window = Window.News}); |
|
142 | 145 | |
|
143 | 146 | } |
|
147 | if (keyboardCur.IsKeyDown(Keys.O) && keyboardPrev.IsKeyUp(Keys.O)) | |
|
148 | { | |
|
149 | SendMessage(new ToggleWindowMessage{Window = Window.Contracts}); | |
|
150 | } | |
|
144 | 151 | if (keyboardCur.IsKeyDown(Keys.G) && keyboardPrev.IsKeyUp(Keys.G)) |
|
145 | 152 | { |
|
146 | 153 | SendMessage(new ToggleVisibilityMessage{Element = Element.Grid}); |
@@ -90,6 +90,7 | |||
|
90 | 90 | private BudgetWindow budgetWindow; |
|
91 | 91 | public bool showForest; |
|
92 | 92 | public bool showNews; |
|
93 | public bool showContracts; | |
|
93 | 94 | |
|
94 | 95 | //Encompass |
|
95 | 96 | private WorldBuilder WorldBuilder = new WorldBuilder(); |
@@ -186,20 +187,32 | |||
|
186 | 187 | |
|
187 | 188 | Line.initialize(GraphicsDevice); |
|
188 | 189 | |
|
190 | //Has to happen before Encompass stuff, because the Encompass machinery around ImGui requires debugWindow's monoFont to be loaded: | |
|
191 | this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); | |
|
192 | ||
|
189 | 193 | //let's see if this works: |
|
190 | 194 | // WorldBuilder = new WorldBuilder(); |
|
191 | 195 | var dummy_entity = WorldBuilder.CreateEntity(); |
|
192 | 196 | |
|
193 | 197 | |
|
194 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); | |
|
195 | 198 | WorldBuilder.AddEngine(new InputEngine(Menu.MENU_BAR_HEIGHT, FNAGame.width, FNAGame.height)); |
|
199 | WorldBuilder.AddEngine(new UIEngine()); | |
|
200 | ||
|
196 | 201 | WorldBuilder.AddEngine(new GameBridgeEngine(this)); |
|
197 | 202 | WorldBuilder.AddEngine(new SimulationBridgeEngine(this.simulation)); |
|
198 | 203 | WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); |
|
199 | 204 | this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(); |
|
200 | 205 | WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine); |
|
206 | ||
|
201 | 207 | WorldBuilder.AddEngine(new ContractSpawner()); |
|
202 | 208 | |
|
209 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); | |
|
210 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, this.imGuiWindowBridgeEngine), 2); | |
|
211 | var contractWindow = WorldBuilder.CreateEntity(); | |
|
212 | WorldBuilder.SetComponent(contractWindow, new VisibilityComponent{visible = false}); | |
|
213 | WorldBuilder.SetComponent(contractWindow, new WindowTypeComponent{type = isometricparkfna.Messages.Window.Contracts}); | |
|
214 | ||
|
215 | ||
|
203 | 216 | // var budgetWindow = WorldBuilder.CreateEntity(); |
|
204 | 217 | // WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true}); |
|
205 | 218 | // WorldBuilder.SetComponent(budgetWindow, new BudgetComponent()); |
@@ -226,7 +239,6 | |||
|
226 | 239 | } |
|
227 | 240 | ); |
|
228 | 241 | |
|
229 | this.debugWindow = new DebugWindow(this._imGuiRenderer, GraphicsDevice); | |
|
230 | 242 | |
|
231 | 243 | var json2 = new FileInfo(@"Content/grammar.json"); |
|
232 | 244 | |
@@ -710,7 +722,9 | |||
|
710 | 722 | drawTileAt(1, 1, 140, 2); |
|
711 | 723 | drawTileAt(3, 2, 140, 2); |
|
712 | 724 | |
|
725 | _imGuiRenderer.BeforeLayout(gameTime); | |
|
713 | 726 | World.Draw(); |
|
727 | // _imGuiRenderer.AfterLayout(); | |
|
714 | 728 | batch.End(); |
|
715 | 729 | |
|
716 | 730 | #region draw_header |
@@ -797,7 +811,7 | |||
|
797 | 811 | }; |
|
798 | 812 | |
|
799 | 813 | //Finally, draw the debug window |
|
800 | _imGuiRenderer.BeforeLayout(gameTime); | |
|
814 | // _imGuiRenderer.BeforeLayout(gameTime); | |
|
801 | 815 | |
|
802 | 816 | var additionalInfo = new Dictionary<string, string>(); |
|
803 | 817 |
@@ -6,7 +6,8 | |||
|
6 | 6 | Debug, |
|
7 | 7 | Budget, |
|
8 | 8 | Forest, |
|
9 | News | |
|
9 | News, | |
|
10 | Contracts | |
|
10 | 11 | } |
|
11 | 12 | |
|
12 | 13 | public struct ToggleWindowMessage : IMessage//, IHasEntity |
@@ -52,6 +52,7 | |||
|
52 | 52 | <Compile Include="Utils\Extensions.cs" /> |
|
53 | 53 | <Compile Include="Utils\Node.cs" /> |
|
54 | 54 | <Compile Include="UI\BudgetWindow.cs" /> |
|
55 | <Compile Include="UI\ContractsWindow.cs" /> | |
|
55 | 56 | <Compile Include="UI\DebugWindow.cs" /> |
|
56 | 57 | <Compile Include="UI\Dialog.cs" /> |
|
57 | 58 | <Compile Include="UI\ForestWindow.cs" /> |
@@ -73,7 +74,7 | |||
|
73 | 74 | <HintPath>..\packages\ImGui.NET.1.78.0\lib\netstandard2.0\ImGui.NET.dll</HintPath> |
|
74 | 75 | </ProjectReference> |
|
75 | 76 | <ProjectReference Include="..\encompass-cs\encompass-cs\encompass-cs.csproj"> |
|
76 | <Project>{93842D17-2CBE-40A9-AA4C-A2BCE836B817}</Project> | |
|
77 | <Project>{D0CCEB74-D8A8-446A-AFFC-2B043DAF1E5F}</Project> | |
|
77 | 78 | <Name>encompass-cs</Name> |
|
78 | 79 | </ProjectReference> |
|
79 | 80 | </ItemGroup> |
You need to be logged in to leave comments.
Login now