# HG changeset patch # User Alys Brooks # Date 2021-06-08 09:05:24 # Node ID 2bf66fdd5ddfa23e723f5aac6727ec38d5386ac7 # Parent 796d32fa41fcc4b9cbefc5f0d15ee0dd6e1f2c8e Add main menu. diff --git a/isometric-park-fna/Engines/GameBridgeEngine.cs b/isometric-park-fna/Engines/GameBridgeEngine.cs --- a/isometric-park-fna/Engines/GameBridgeEngine.cs +++ b/isometric-park-fna/Engines/GameBridgeEngine.cs @@ -9,6 +9,7 @@ namespace isometricparkfna.Engines { [Receives(typeof(ToggleWindowTypeMessage), typeof(ToggleWindowMessage), + typeof(GameStateMessage), typeof(ToggleVisibilityMessage))] [Reads(typeof(AreaComponent), typeof(ContractStatusComponent))] @@ -54,6 +55,10 @@ break; } } + foreach (ref readonly var stateMessage in ReadMessages()) + { + game.isPlaying = stateMessage.isPlaying; + } game.in_zone = false; foreach (ref readonly var entity in ReadEntities()) diff --git a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs --- a/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs +++ b/isometric-park-fna/Engines/ImGuiWindowBridgeEngine.cs @@ -11,7 +11,8 @@ typeof(ToggleWindowTypeMessage), typeof(ChangeContractStatusMessage), typeof(SelectMessage), - typeof(JumpCameraMessage))] + typeof(JumpCameraMessage), + typeof(GameStateMessage))] [Reads(typeof(VisibilityComponent), typeof(WindowTypeComponent) //, typeof(SelectedComponent) @@ -25,6 +26,7 @@ public List contractStatusMessages; public List selectedMessages; public List jumpCameraMessages; + public List gameStateMessages; bool showBudget {get;} bool showForest {get;} @@ -42,6 +44,7 @@ this.contractStatusMessages = new List(); this.selectedMessages = new List(); this.jumpCameraMessages = new List(); + this.gameStateMessages = new List(); this.windowStatuses = new Dictionary(); //Prepopulate: foreach(var type in System.Enum.GetValues(typeof(Window))) @@ -74,6 +77,10 @@ SendMessage(message); } + foreach(var message in this.gameStateMessages) + { + SendMessage(message); + } foreach(var entity in ReadEntities()) { @@ -87,6 +94,7 @@ this.contractStatusMessages.Clear(); this.selectedMessages.Clear(); this.jumpCameraMessages.Clear(); + this.gameStateMessages.Clear(); } } } diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -21,6 +21,7 @@ using isometricparkfna.Renderers; using isometricparkfna.Messages; using isometricparkfna.Spawners; +using Num = System.Numerics; using ImGuiNET.SampleProgram.XNA; using ImGuiNET; @@ -259,7 +260,6 @@ } } - for (int i = 0; i < 3; i++) { @@ -292,6 +292,7 @@ { name = "Aeres Maximalis Ltd." }); + World = WorldBuilder.Build(); var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), @@ -855,6 +856,8 @@ Vector2 middle_dimensions = monoFont.MeasureString("Isometric Park"); float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2)); + ImGui.SetNextWindowPos(new Num.Vector2(FNAGame.width/2, 200)); + MainMenu.Render(debugWindow.monoFont, imGuiWindowBridgeEngine); batch.DrawString(largeMonoFont, "Isometric Park", new Vector2(middle_start, 50), diff --git a/isometric-park-fna/Messages/GameStateMessage.cs b/isometric-park-fna/Messages/GameStateMessage.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Messages/GameStateMessage.cs @@ -0,0 +1,12 @@ + + +using Microsoft.Xna.Framework; +using Encompass; + +namespace isometricparkfna.Messages { + public struct GameStateMessage : IMessage + { + public bool isPlaying; + + } +} diff --git a/isometric-park-fna/UI/MainMenu.cs b/isometric-park-fna/UI/MainMenu.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/UI/MainMenu.cs @@ -0,0 +1,55 @@ +using System; +using ImGuiNET; + +using Num = System.Numerics; + +using isometricparkfna.Engines; +using isometricparkfna.Messages; +using isometricparkfna.UI; + +namespace isometricparkfna.UI +{ + + public static class MainMenu + { + + + public static void Render(ImFontPtr font, ImGuiWindowBridgeEngine bridgeEngine + /*ImFontPtr smallFont, GameBridgeEngine bridgeEngine */ //, ref bool quit, ref bool paused, ref int rate, ref bool showBudget, string header + ) + { + + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; + bool newShow = true; + StyleSet.pushStyleVarSet(StyleSet.defaultWindowVars); + StyleSet.pushColorSet(StyleSet.defaultWindowColors); + + ImGui.PushFont(font); + // ImGui.PushFont(smallFont); + ImGui.Begin("##Toolbar", ref newShow, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoTitleBar); + // ImGui.PopFont(); + // + if (ImGui.Button("New Game")) + { + bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true}); + + + } + if (ImGui.Button("Quit")) + { + + System.Console.WriteLine("Quitting"); + Environment.Exit(0); + } + + + ImGui.End(); + + + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; + StyleSet.popStyleVarSet(StyleSet.defaultWindowVars); + StyleSet.popColorSet(StyleSet.defaultWindowColors); + ImGui.PopFont(); + } + } +} diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -65,6 +65,7 @@ +