diff --git a/isometric-park-fna/Components/BudgetLineComponent.cs b/isometric-park-fna/Components/BudgetLineComponent.cs --- a/isometric-park-fna/Components/BudgetLineComponent.cs +++ b/isometric-park-fna/Components/BudgetLineComponent.cs @@ -1,10 +1,12 @@ using Encompass; -namespace isometricparkfna.Components { +namespace isometricparkfna.Components +{ - public struct BudgetLineComponent : IComponent { + public struct BudgetLineComponent : IComponent + { public string category; public decimal amount; - } + } } diff --git a/isometric-park-fna/Engines/GameStateEngine.cs b/isometric-park-fna/Engines/GameStateEngine.cs --- a/isometric-park-fna/Engines/GameStateEngine.cs +++ b/isometric-park-fna/Engines/GameStateEngine.cs @@ -22,7 +22,7 @@ { startGame(); } - SendMessage(new ToggleWindowTypeMessage { Window = Window.MainMenu }); + // SendMessage(new ToggleWindowTypeMessage { Window = Window.MainMenu }); foreach (var entity in ReadEntities()) { diff --git a/isometric-park-fna/Engines/Spawners/GameSpawner.cs b/isometric-park-fna/Engines/Spawners/GameSpawner.cs --- a/isometric-park-fna/Engines/Spawners/GameSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/GameSpawner.cs @@ -9,7 +9,6 @@ using isometricparkfna.Messages; using static isometricparkfna.CellMap; -// using isometricparkfna.Components; namespace isometricparkfna.Spawners { @@ -22,14 +21,12 @@ private Simulation simulation; Random random_generator; - - public GameSpawner(Simulation simulation) + public GameSpawner(Simulation simulation) { this.simulation = simulation; this.random_generator = new Random(); } - protected override void Spawn(in SpawnGameMessage message) { 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 @@ -194,6 +194,7 @@ Logging.Success("Initialized Quad texture."); ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); + NewGameWindow.Initialize(); //Must be done before SetFontMessage is sent var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), @@ -282,6 +283,10 @@ WorldBuilder.SetComponent(optionsWindow, new VisibilityComponent { visible = false }); WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options }); + var newGameWindow = WorldBuilder.CreateEntity(); + WorldBuilder.SetComponent(newGameWindow, new VisibilityComponent { visible = false }); + WorldBuilder.SetComponent(newGameWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.NewGame }); + var gameEntity = WorldBuilder.CreateEntity(); diff --git a/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs b/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs --- a/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs +++ b/isometric-park-fna/Messages/ToggleWindowTypeMessage.cs @@ -14,7 +14,8 @@ Contract, MainMenu, InGameMenu, - Options + Options, + NewGame } diff --git a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs --- a/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs +++ b/isometric-park-fna/Renderers/ImGuiWindowRenderer.cs @@ -107,7 +107,11 @@ case Window.Options: OptionsWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine, width); break; + case Window.NewGame: + NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine); + break; default: + // Logging.Error(String.Format("Unknown window type {0} ", window_type)); break; } } @@ -119,4 +123,4 @@ this.BridgeEngine.font = font; } } -} \ No newline at end of file +} diff --git a/isometric-park-fna/UI/MainMenu.cs b/isometric-park-fna/UI/MainMenu.cs --- a/isometric-park-fna/UI/MainMenu.cs +++ b/isometric-park-fna/UI/MainMenu.cs @@ -33,7 +33,7 @@ if (ImGui.Button("New Game", button_size)) { bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true}); - bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage()); + bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.NewGame }); } if (ImGui.Button("Quit", button_size)) diff --git a/isometric-park-fna/UI/NewGameWindow.cs b/isometric-park-fna/UI/NewGameWindow.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/UI/NewGameWindow.cs @@ -0,0 +1,123 @@ + +using System; +using ImGuiNET; + +using Num = System.Numerics; + +using Microsoft.Xna.Framework; + +using isometricparkfna.Engines; +using isometricparkfna.Messages; + +namespace isometricparkfna.UI +{ + + public static class NewGameWindow + { + + + public static bool had_focus = false; + + public static byte[] parkNameBuffer; + public static int pos; + + public static byte[] playerNameBuffer; + public static int playerNamePos; + + public static String selectedTitle; + + public static void Initialize() + { + parkNameBuffer = new byte[32]; + pos = 0; + + playerNameBuffer = new byte[32]; + playerNamePos = 0; + + selectedTitle = ""; + + } + + public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine) + { + ImGui.PushFont(font); + StyleSets.defaultSet.push(); + + ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; + var newShow = true; + + if (NewGameWindow.had_focus) + { + ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); + } + ImGui.Begin("New Game", ref newShow, + ImGuiWindowFlags.AlwaysAutoResize | + ImGuiWindowFlags.NoResize | + ImGuiWindowFlags.NoCollapse | + ImGuiWindowFlags.NoSavedSettings ); + if (NewGameWindow.had_focus) + { + ImGui.PopStyleColor(); + } + NewGameWindow.had_focus = ImGui.IsWindowFocused(); + + ImGui.Text("Park Name: "); + ImGui.SameLine(); + + int newPos = NewGameWindow.pos; + + //God this sucks: + unsafe { + ImGui.InputText("##name", parkNameBuffer, (uint)parkNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPos)); + } + NewGameWindow.pos = newPos; + + ImGui.Text("Your Name: "); + ImGui.SameLine(); + if (ImGui.BeginCombo("##title", selectedTitle)) + { + + foreach (var title in new String[] {"", "", "Mr.", "Mrs.", "Ms.", "Mx.", "Dr."}) + { + if (ImGui.Selectable(title)) + { + selectedTitle = title; + } + } + + ImGui.EndCombo(); + } + + int newPlayerNamePos = NewGameWindow.playerNamePos; + + ImGui.SameLine(); + //God this sucks: + unsafe { + ImGui.InputText("##playerNameBuffer", playerNameBuffer, (uint)playerNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); + } + + NewGameWindow.playerNamePos = newPlayerNamePos; + + if (ImGui.Button("Okay")) + { + bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage{}); + bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); + bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu }); + } + + ImGui.SameLine(); + if ( ImGui.Button("Cancel")) + { + bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); + + bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = false}); + } + + ImGui.End(); + + StyleSets.defaultSet.pop(); + 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 @@ -71,6 +71,7 @@ + @@ -183,7 +184,7 @@ ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll ..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll