# HG changeset patch # User Alys Brooks # Date 2021-07-29 09:12:54 # Node ID 2450f33273d82c11660a16caa21aab334c39b4c7 # Parent b15cc91c5c7a4c052f6947f02ddfe37cfe59ed46 More elaborate name input. 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 @@ -856,7 +856,7 @@ Vector2 middle_dimensions = largeMonoFont.MeasureString("Isometric Park"); float middle_start = (int)((FNAGame.width / 2) - (middle_dimensions.X / 2)); - ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200)); + // ImGui.SetNextWindowPos(new Num.Vector2(((FNAGame.width/2) - 40), 200)); batch.DrawString(largeMonoFont, "Isometric Park", new Vector2(middle_start, 50), Color.Black, 0.0f, Vector2.Zero, 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 @@ -32,7 +32,6 @@ if (ImGui.Button("New Game", button_size)) { - bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true}); bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.NewGame }); bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu }); } diff --git a/isometric-park-fna/UI/NewGameWindow.cs b/isometric-park-fna/UI/NewGameWindow.cs --- a/isometric-park-fna/UI/NewGameWindow.cs +++ b/isometric-park-fna/UI/NewGameWindow.cs @@ -34,8 +34,16 @@ public static String selectedTitle; + public static String playerName2Buffer; + public static int playerName2Pos; + + public static byte[] customTitleBuffer; + public static int customTitlePos; + public static int choice; + public static bool showModal; + public static void Initialize() { parkNameBuffer = new byte[32]; @@ -46,6 +54,14 @@ selectedTitle = ""; + playerName2Buffer = ""; + playerName2Pos = 0; + + customTitleBuffer = new byte[32]; + customTitlePos = 0; + + showModal = true; + } public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine) @@ -82,7 +98,7 @@ } NewGameWindow.pos = newPos; - ImGui.Text("Your Name: "); + ImGui.Text("Formal Name: "); ImGui.SameLine(); @@ -100,7 +116,7 @@ } ImGui.PopFont(); - foreach (var title in new String[] {"Mr.", "Mrs.", "Ms.", "Mx.", "Dr."}) + foreach (var title in new String[] {"Mr.", "Mrs.", "Ms.","Miss", "Mx.", "M", "Dr.", "Rev.", "Sir", "Madam", "Hon.", "Dishon.", "Director", "Comrade", "Brother", "Sister", "Friend"}) { if (ImGui.Selectable(title)) { @@ -108,6 +124,9 @@ } } + ImGui.PushFont(italicFont); + ImGui.PopFont(); + ImGui.EndCombo(); } @@ -116,11 +135,55 @@ //God this sucks: unsafe { - ImGui.InputText("##playerNameBuffer", playerNameBuffer, (uint)playerNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); + ImGui.InputText("##playerNameBuffer", playerNameBuffer, (uint)playerNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); } NewGameWindow.playerNamePos = newPlayerNamePos; + ImGui.SameLine(); + + if (ImGui.Button("")) + { + NewGameWindow.showModal = true; + ImGui.OpenPopup("XYZCustom"); + + } + if (ImGui.BeginPopup("XYZCustom" /*, ref showModal*/)) + { + int newCustomTitlePos = NewGameWindow.customTitlePos; + unsafe { + ImGui.InputText("##customTitleBuffer", customTitleBuffer, (uint)customTitleBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newCustomTitlePos)); + } + + NewGameWindow.customTitlePos = newCustomTitlePos; + + + if (ImGui.Button("Okay")) + { + selectedTitle = System.Text.Encoding.UTF8.GetString(customTitleBuffer); + ImGui.CloseCurrentPopup(); + } + ImGui.SameLine(); + if (ImGui.Button("Cancel")) + { + ImGui.CloseCurrentPopup(); + } + ImGui.EndPopup(); + + } + + ImGui.Text("Casual Name: "); + ImGui.SameLine(); + + int newPlayerName2Pos = NewGameWindow.playerName2Pos; + + //God this sucks: + unsafe { + ImGui.InputTextWithHint("##playerName2", "Leave blank to use full name", playerName2Buffer, 32, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); + } + + NewGameWindow.playerName2Pos = newPlayerName2Pos; + ImGui.RadioButton("Easy: Full Funding", ref choice, ((int)DifficultyLevel.Easy)); ImGui.RadioButton("Medium: Austerity", ref choice, ((int)DifficultyLevel.Medium)); ImGui.RadioButton("Hard: Unfunded", ref choice, ((int)DifficultyLevel.Hard)); @@ -130,6 +193,7 @@ { bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage{}); bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); + bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true}); } ImGui.SameLine(); @@ -137,12 +201,13 @@ { bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); - bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = false}); bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu }); } + ImGui.End(); + StyleSets.defaultSet.pop(); ImGui.PopFont();