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

r298:2bf66fdd5ddf -

@@ -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,55
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
17 public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine
18 /*ImFontPtr smallFont, GameBridgeEngine bridgeEngine */ //, ref bool quit, ref bool paused, ref int rate, ref bool showBudget, string header
19 )
20 {
21
22 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None;
23 bool newShow = true;
24 StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars);
25 StyleSet.pushColorSet(StyleSet.defaultWindowColors);
26
27 ImGui.PushFont(font);
28 // ImGui.PushFont(smallFont);
29 ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar);
30 // ImGui.PopFont();
31 //
32 if (ImGui.Button("New Game"))
33 {
34 bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true});
35
36
37 }
38 if (ImGui.Button("Quit"))
39 {
40
41 System.Console.WriteLine("Quitting");
42 Environment.Exit(0);
43 }
44
45
46 ImGui.End();
47
48
49 ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left;
50 StyleSet.popStyleVarSet(StyleSet.defaultWindowVars);
51 StyleSet.popColorSet(StyleSet.defaultWindowColors);
52 ImGui.PopFont();
53 }
54 }
55 }
@@ -9,6 +9,7
9 namespace isometricparkfna.Engines {
9 namespace isometricparkfna.Engines {
10
10
11 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
11 [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage),
12 typeof(GameStateMessage),
12 typeof(ToggleVisibilityMessage))]
13 typeof(ToggleVisibilityMessage))]
13 [Reads(typeof(AreaComponent),
14 [Reads(typeof(AreaComponent),
14 typeof(ContractStatusComponent))]
15 typeof(ContractStatusComponent))]
@@ -54,6 +55,10
54 break;
55 break;
55 }
56 }
56 }
57 }
58 foreach (ref readonly var stateMessage in ReadMessages<GameStateMessage>())
59 {
60 game.isPlaying = stateMessage.isPlaying;
61 }
57
62
58 game.in_zone = false;
63 game.in_zone = false;
59 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
64 foreach (ref readonly var entity in ReadEntities<AreaComponent>())
@@ -11,7 +11,8
11 typeof(ToggleWindowTypeMessage),
11 typeof(ToggleWindowTypeMessage),
12 typeof(ChangeContractStatusMessage),
12 typeof(ChangeContractStatusMessage),
13 typeof(SelectMessage),
13 typeof(SelectMessage),
14 typeof(JumpCameraMessage))]
14 typeof(JumpCameraMessage),
15 typeof(GameStateMessage))]
15 [Reads(typeof(VisibilityComponent),
16 [Reads(typeof(VisibilityComponent),
16 typeof(WindowTypeComponent)
17 typeof(WindowTypeComponent)
17 //, typeof(SelectedComponent)
18 //, typeof(SelectedComponent)
@@ -25,6 +26,7
25 public List<ChangeContractStatusMessage> contractStatusMessages;
26 public List<ChangeContractStatusMessage> contractStatusMessages;
26 public List<SelectMessage> selectedMessages;
27 public List<SelectMessage> selectedMessages;
27 public List<JumpCameraMessage> jumpCameraMessages;
28 public List<JumpCameraMessage> jumpCameraMessages;
29 public List<GameStateMessage> gameStateMessages;
28
30
29 bool showBudget {get;}
31 bool showBudget {get;}
30 bool showForest {get;}
32 bool showForest {get;}
@@ -42,6 +44,7
42 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
44 this.contractStatusMessages = new List<ChangeContractStatusMessage>();
43 this.selectedMessages = new List<SelectMessage>();
45 this.selectedMessages = new List<SelectMessage>();
44 this.jumpCameraMessages = new List<JumpCameraMessage>();
46 this.jumpCameraMessages = new List<JumpCameraMessage>();
47 this.gameStateMessages = new List<GameStateMessage>();
45 this.windowStatuses = new Dictionary<Window, bool>();
48 this.windowStatuses = new Dictionary<Window, bool>();
46 //Prepopulate:
49 //Prepopulate:
47 foreach(var type in System.Enum.GetValues(typeof(Window)))
50 foreach(var type in System.Enum.GetValues(typeof(Window)))
@@ -74,6 +77,10
74 SendMessage(message);
77 SendMessage(message);
75 }
78 }
76
79
80 foreach(var message in this.gameStateMessages)
81 {
82 SendMessage(message);
83 }
77
84
78 foreach(var entity in ReadEntities<WindowTypeComponent>())
85 foreach(var entity in ReadEntities<WindowTypeComponent>())
79 {
86 {
@@ -87,6 +94,7
87 this.contractStatusMessages.Clear();
94 this.contractStatusMessages.Clear();
88 this.selectedMessages.Clear();
95 this.selectedMessages.Clear();
89 this.jumpCameraMessages.Clear();
96 this.jumpCameraMessages.Clear();
97 this.gameStateMessages.Clear();
90 }
98 }
91 }
99 }
92 }
100 }
@@ -21,6 +21,7
21 using isometricparkfna.Renderers;
21 using isometricparkfna.Renderers;
22 using isometricparkfna.Messages;
22 using isometricparkfna.Messages;
23 using isometricparkfna.Spawners;
23 using isometricparkfna.Spawners;
24 using Num = System.Numerics;
24
25
25 using ImGuiNET.SampleProgram.XNA;
26 using ImGuiNET.SampleProgram.XNA;
26 using ImGuiNET;
27 using ImGuiNET;
@@ -259,7 +260,6
259 }
260 }
260
261
261 }
262 }
262
263 for (int i = 0; i < 3; i++)
263 for (int i = 0; i < 3; i++)
264 {
264 {
265
265
@@ -292,6 +292,7
292 {
292 {
293 name = "Aeres Maximalis Ltd."
293 name = "Aeres Maximalis Ltd."
294 });
294 });
295
295 World = WorldBuilder.Build();
296 World = WorldBuilder.Build();
296
297
297 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
298 var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"),
@@ -855,6 +856,8
855
856
856 Vector2 middle_dimensions = monoFont.MeasureString("Isometric Park");
857 Vector2 middle_dimensions = monoFont.MeasureString("Isometric Park");
857 float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2));
858 float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2));
859 ImGui.SetNextWindowPos(new Num.Vector2(FNAGame.width/2, 200));
860 MainMenu.Render(debugWindow.monoFont, imGuiWindowBridgeEngine);
858
861
859 batch.DrawString(largeMonoFont, "Isometric Park",
862 batch.DrawString(largeMonoFont, "Isometric Park",
860 new Vector2(middle_start, 50),
863 new Vector2(middle_start, 50),
@@ -65,6 +65,7
65 <Compile Include="UI\Menu.cs" />
65 <Compile Include="UI\Menu.cs" />
66 <Compile Include="UI\NewsWindow.cs" />
66 <Compile Include="UI\NewsWindow.cs" />
67 <Compile Include="UI\StyleSet.cs" />
67 <Compile Include="UI\StyleSet.cs" />
68 <Compile Include="UI\MainMenu.cs" />
68 </ItemGroup>
69 </ItemGroup>
69 <ItemGroup>
70 <ItemGroup>
70 <ProjectReference Include="..\FNA\FNA.csproj">
71 <ProjectReference Include="..\FNA\FNA.csproj">
You need to be logged in to leave comments. Login now