Description:
Add NewGameWindow.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,123 | |||
|
1 | ||
|
2 | using System; | |
|
3 | using ImGuiNET; | |
|
4 | ||
|
5 | using Num = System.Numerics; | |
|
6 | ||
|
7 | using Microsoft.Xna.Framework; | |
|
8 | ||
|
9 | using isometricparkfna.Engines; | |
|
10 | using isometricparkfna.Messages; | |
|
11 | ||
|
12 | namespace isometricparkfna.UI | |
|
13 | { | |
|
14 | ||
|
15 | public static class NewGameWindow | |
|
16 | { | |
|
17 | ||
|
18 | ||
|
19 | public static bool had_focus = false; | |
|
20 | ||
|
21 | public static byte[] parkNameBuffer; | |
|
22 | public static int pos; | |
|
23 | ||
|
24 | public static byte[] playerNameBuffer; | |
|
25 | public static int playerNamePos; | |
|
26 | ||
|
27 | public static String selectedTitle; | |
|
28 | ||
|
29 | public static void Initialize() | |
|
30 | { | |
|
31 | parkNameBuffer = new byte[32]; | |
|
32 | pos = 0; | |
|
33 | ||
|
34 | playerNameBuffer = new byte[32]; | |
|
35 | playerNamePos = 0; | |
|
36 | ||
|
37 | selectedTitle = ""; | |
|
38 | ||
|
39 | } | |
|
40 | ||
|
41 | public static void Render(ImFontPtr font, ImFontPtr italicFont, ImGuiWindowBridgeEngine bridgeEngine) | |
|
42 | { | |
|
43 | ImGui.PushFont(font); | |
|
44 | StyleSets.defaultSet.push(); | |
|
45 | ||
|
46 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; | |
|
47 | var newShow = true; | |
|
48 | ||
|
49 | if (NewGameWindow.had_focus) | |
|
50 | { | |
|
51 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); | |
|
52 | } | |
|
53 | ImGui.Begin("New Game", ref newShow, | |
|
54 | ImGuiWindowFlags.AlwaysAutoResize | | |
|
55 | ImGuiWindowFlags.NoResize | | |
|
56 | ImGuiWindowFlags.NoCollapse | | |
|
57 | ImGuiWindowFlags.NoSavedSettings ); | |
|
58 | if (NewGameWindow.had_focus) | |
|
59 | { | |
|
60 | ImGui.PopStyleColor(); | |
|
61 | } | |
|
62 | NewGameWindow.had_focus = ImGui.IsWindowFocused(); | |
|
63 | ||
|
64 | ImGui.Text("Park Name: "); | |
|
65 | ImGui.SameLine(); | |
|
66 | ||
|
67 | int newPos = NewGameWindow.pos; | |
|
68 | ||
|
69 | //God this sucks: | |
|
70 | unsafe { | |
|
71 | ImGui.InputText("##name", parkNameBuffer, (uint)parkNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPos)); | |
|
72 | } | |
|
73 | NewGameWindow.pos = newPos; | |
|
74 | ||
|
75 | ImGui.Text("Your Name: "); | |
|
76 | ImGui.SameLine(); | |
|
77 | if (ImGui.BeginCombo("##title", selectedTitle)) | |
|
78 | { | |
|
79 | ||
|
80 | foreach (var title in new String[] {"", "<No Title>", "Mr.", "Mrs.", "Ms.", "Mx.", "Dr."}) | |
|
81 | { | |
|
82 | if (ImGui.Selectable(title)) | |
|
83 | { | |
|
84 | selectedTitle = title; | |
|
85 | } | |
|
86 | } | |
|
87 | ||
|
88 | ImGui.EndCombo(); | |
|
89 | } | |
|
90 | ||
|
91 | int newPlayerNamePos = NewGameWindow.playerNamePos; | |
|
92 | ||
|
93 | ImGui.SameLine(); | |
|
94 | //God this sucks: | |
|
95 | unsafe { | |
|
96 | ImGui.InputText("##playerNameBuffer", playerNameBuffer, (uint)playerNameBuffer.Length, ImGuiInputTextFlags.AutoSelectAll, null, (IntPtr)(&newPlayerNamePos)); | |
|
97 | } | |
|
98 | ||
|
99 | NewGameWindow.playerNamePos = newPlayerNamePos; | |
|
100 | ||
|
101 | if (ImGui.Button("Okay")) | |
|
102 | { | |
|
103 | bridgeEngine.spawnGameMessages.Add(new SpawnGameMessage{}); | |
|
104 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); | |
|
105 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.MainMenu }); | |
|
106 | } | |
|
107 | ||
|
108 | ImGui.SameLine(); | |
|
109 | if ( ImGui.Button("Cancel")) | |
|
110 | { | |
|
111 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage {Window = Window.NewGame}); | |
|
112 | ||
|
113 | bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = false}); | |
|
114 | } | |
|
115 | ||
|
116 | ImGui.End(); | |
|
117 | ||
|
118 | StyleSets.defaultSet.pop(); | |
|
119 | ImGui.PopFont(); | |
|
120 | ||
|
121 | } | |
|
122 | } | |
|
123 | } |
@@ -1,10 +1,12 | |||
|
1 | 1 | using Encompass; |
|
2 | 2 | |
|
3 |
namespace isometricparkfna.Components |
|
|
3 | namespace isometricparkfna.Components | |
|
4 | { | |
|
4 | 5 | |
|
5 |
|
|
|
6 | public struct BudgetLineComponent : IComponent | |
|
7 | { | |
|
6 | 8 | |
|
7 | 9 | public string category; |
|
8 | 10 | public decimal amount; |
|
9 | } | |
|
11 | } | |
|
10 | 12 | } |
@@ -22,7 +22,7 | |||
|
22 | 22 | { |
|
23 | 23 | startGame(); |
|
24 | 24 | } |
|
25 | SendMessage(new ToggleWindowTypeMessage { Window = Window.MainMenu }); | |
|
25 | // SendMessage(new ToggleWindowTypeMessage { Window = Window.MainMenu }); | |
|
26 | 26 | |
|
27 | 27 | foreach (var entity in ReadEntities<GameStateComponent>()) |
|
28 | 28 | { |
@@ -9,7 +9,6 | |||
|
9 | 9 | |
|
10 | 10 | using isometricparkfna.Messages; |
|
11 | 11 | using static isometricparkfna.CellMap; |
|
12 | // using isometricparkfna.Components; | |
|
13 | 12 | |
|
14 | 13 | namespace isometricparkfna.Spawners { |
|
15 | 14 | |
@@ -22,14 +21,12 | |||
|
22 | 21 | private Simulation simulation; |
|
23 | 22 | Random random_generator; |
|
24 | 23 | |
|
25 | ||
|
26 | public GameSpawner(Simulation simulation) | |
|
24 | public GameSpawner(Simulation simulation) | |
|
27 | 25 | { |
|
28 | 26 | this.simulation = simulation; |
|
29 | 27 | this.random_generator = new Random(); |
|
30 | 28 | } |
|
31 | 29 | |
|
32 | ||
|
33 | 30 | protected override void Spawn(in SpawnGameMessage message) |
|
34 | 31 | { |
|
35 | 32 |
@@ -194,6 +194,7 | |||
|
194 | 194 | Logging.Success("Initialized Quad texture."); |
|
195 | 195 | ContractWindow.LoadContent(this._imGuiRenderer, this.imageMap); |
|
196 | 196 | OptionsWindow.Initialize(new Vector2(FNAGame.width, FNAGame.height), gdm.IsFullScreen); |
|
197 | NewGameWindow.Initialize(); | |
|
197 | 198 | |
|
198 | 199 | //Must be done before SetFontMessage is sent |
|
199 | 200 | var bakedMono = TtfFontBaker.Bake(File.OpenRead(@"Content/iosevka-term-extendedmedium.ttf"), |
@@ -282,6 +283,10 | |||
|
282 | 283 | WorldBuilder.SetComponent(optionsWindow, new VisibilityComponent { visible = false }); |
|
283 | 284 | WorldBuilder.SetComponent(optionsWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.Options }); |
|
284 | 285 | |
|
286 | var newGameWindow = WorldBuilder.CreateEntity(); | |
|
287 | WorldBuilder.SetComponent(newGameWindow, new VisibilityComponent { visible = false }); | |
|
288 | WorldBuilder.SetComponent(newGameWindow, new WindowTypeComponent { type = isometricparkfna.Messages.Window.NewGame }); | |
|
289 | ||
|
285 | 290 | |
|
286 | 291 | |
|
287 | 292 | var gameEntity = WorldBuilder.CreateEntity(); |
@@ -14,7 +14,8 | |||
|
14 | 14 | Contract, |
|
15 | 15 | MainMenu, |
|
16 | 16 | InGameMenu, |
|
17 | Options | |
|
17 | Options, | |
|
18 | NewGame | |
|
18 | 19 | } |
|
19 | 20 | |
|
20 | 21 |
@@ -107,7 +107,11 | |||
|
107 | 107 | case Window.Options: |
|
108 | 108 | OptionsWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine, width); |
|
109 | 109 | break; |
|
110 | case Window.NewGame: | |
|
111 | NewGameWindow.Render(this.BridgeEngine.font, this.BridgeEngine.italicFont, this.BridgeEngine); | |
|
112 | break; | |
|
110 | 113 | default: |
|
114 | // Logging.Error(String.Format("Unknown window type {0} ", window_type)); | |
|
111 | 115 | break; |
|
112 | 116 | } |
|
113 | 117 | } |
@@ -119,4 +123,4 | |||
|
119 | 123 | this.BridgeEngine.font = font; |
|
120 | 124 | } |
|
121 | 125 | } |
|
122 | } No newline at end of file | |
|
126 | } |
@@ -33,7 +33,7 | |||
|
33 | 33 | if (ImGui.Button("New Game", button_size)) |
|
34 | 34 | { |
|
35 | 35 | bridgeEngine.gameStateMessages.Add(new GameStateMessage { isPlaying = true}); |
|
36 |
bridgeEngine. |
|
|
36 | bridgeEngine.typeMessages.Add(new ToggleWindowTypeMessage { Window = Window.NewGame }); | |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | if (ImGui.Button("Quit", button_size)) |
@@ -71,6 +71,7 | |||
|
71 | 71 | <Compile Include="UI\MainMenu.cs" /> |
|
72 | 72 | <Compile Include="UI\InGameMenu.cs" /> |
|
73 | 73 | <Compile Include="UI\OptionsWindow.cs" /> |
|
74 | <Compile Include="UI\NewGameWindow.cs" /> | |
|
74 | 75 | </ItemGroup> |
|
75 | 76 | <ItemGroup> |
|
76 | 77 | <ProjectReference Include="..\FNA\FNA.csproj"> |
@@ -183,7 +184,7 | |||
|
183 | 184 | <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath> |
|
184 | 185 | </Reference> |
|
185 | 186 | <Reference Include="Newtonsoft.Json"> |
|
186 |
<HintPath>..\packages\Newtonsoft.Json.1 |
|
|
187 | <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> | |
|
187 | 188 | </Reference> |
|
188 | 189 | <Reference Include="YamlDotNet" Version="11.0.1"> |
|
189 | 190 | <HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath> |
You need to be logged in to leave comments.
Login now