Description:
Add dialogue, yeah!
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r32:11e74a08597d -

@@ -0,0 +1,25
1 using System;
2 using System.Text.Json;
3 using isometricparkfna.Utils;
4
5 namespace isometricparkfna
6 {
7
8
9 //#nullable enable
10 public struct DialogOption
11 {
12 public String? choice;
13 public String response;
14 }
15
16 public static class Dialog
17 {
18
19 public static Node<DialogOption> Parse(JsonDocument document)
20 {
21
22 }
23 }
24
25 }
@@ -0,0 +1,47
1 using System;
2 namespace isometricparkfna
3 {
4 public class MathUtils
5 {
6 public MathUtils()
7 {
8 }
9
10 public static bool Between(float val, float x, float y)
11 {
12 return ((x < val && val < y) || (y < val && val < x));
13
14 }
15
16 public static bool Between(int val, int x, int y)
17 {
18 return ((x < val && val < y) || (y < val && val < x));
19
20 }
21
22 protected float Decrement(float value, float delta)
23 {
24 float magnitude = Math.Abs(value);
25
26 //If distance from zero is less than our delta,
27 //go to zero to prevent overshooting:
28 if (magnitude < delta)
29 {
30 return 0.0f;
31 }
32 else if (value > 0)
33 {
34 return value - delta;
35 }
36 else if (value < 0)
37 {
38 return value + delta;
39 }
40 else
41 {
42 return 0.0f;
43 }
44 }
45
46 }
47 }
@@ -0,0 +1,32
1 using System;
2 namespace isometricparkfna.Utils
3 {
4 public class Node<T>
5 {
6 public Node<T>[] children; //TODO RECONSIDER??
7
8 public T data;
9
10
11 public Node()
12 {
13 }
14
15 public Node(T data)
16 {
17 this.data = data;
18 }
19
20 public Node(T data, Node<T>[] children)
21 {
22 this.data = data;
23 this.children = children;
24 }
25
26 public Node(T data, Node<T> child)
27 {
28 this.data = data;
29 this.children = new Node<T>[] { child };
30 }
31 }
32 }
@@ -5,12 +5,15
5 5 using Microsoft.Xna.Framework.Graphics;
6 6 using Microsoft.Xna.Framework.Media;
7 7
8
9
8 10 using System;
9 11 using System.IO;
10 12 using SpriteFontPlus;
11 13 using isometricparkfna;
12 14 using System.Diagnostics;
13 15 using static isometricparkfna.TileMap;
16 using isometricparkfna.Utils;
14 17
15 18
16 19 using ImGuiNET.SampleProgram.XNA;
@@ -65,6 +68,9
65 68 //buggy
66 69 private static bool enableCulling = false;
67 70
71 private Node<DialogOption> tree;
72 private Node<DialogOption> currentNode;
73
68 74 private bool showGrid = true;
69 75
70 76 private static void Main(string[] args)
@@ -121,6 +127,21
121 127 Content.RootDirectory = "Content";
122 128
123 129
130 tree = new Node<DialogOption>(new DialogOption
131 {
132 response = "Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.",
133 },
134 new Node<DialogOption>(new DialogOption { choice = "Okay", response = "Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!" },
135 new Node<DialogOption>[]{
136 new Node<DialogOption>(new DialogOption {choice="And I need to keep the forest healthy, too, right?", response="Uhh yeah." },
137 new Node<DialogOption>(new DialogOption {choice="..." })),
138 new Node<DialogOption>(new DialogOption {choice="Sounds good!", response="I'll check in soon." })
139
140 })
141 );
142
143 currentNode = tree;
144
124 145 }
125 146
126 147 protected override void Initialize()
@@ -471,9 +492,10
471 492
472 493 }
473 494
495
496
474 497
475 498
476
477 499
478 500 protected override void Draw(GameTime gameTime)
479 501 {
@@ -754,16 +776,44
754 776 _imGuiRenderer.BeforeLayout(gameTime);
755 777 debugWindow.Layout(debugInfo, new Dictionary<string, string>(),ref show_another_window);
756 778
757 String[] messages = { "Message1", "Message2" };
779 //String[] messages = { "Message1", "Message2" };
758 780
759 if (showInitial && (messageIndex < messages.Length))
781 //DialogOption[] dialog = { new DialogOption{ response="Welcome to your new park, director! You can use the mouse or arrow keys to move around, and the plus and minus keys to zoom in and out.", choice="Okay" },
782 // new DialogOption{ response="Make sure that you keep visitors happy and the budget in the black! You're currently getting an annual grant out of my budget—it'd sure be nice if you park were self-sufficient so we could drop that expense!", choice="And I need to keep the forest healthy, too, right?" },
783 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
784
785
786 if (showInitial)
760 787 {
761 ImGui.Begin("Welcome", ref showInitial);
788 ImGui.Begin("The Governor", ref showInitial);
762 789 ImGui.PushFont(debugWindow.monoFont);
763 ImGui.Text(messages[messageIndex]);
764 if(ImGui.Button("Okay"))
790 ImGui.TextWrapped(currentNode.data.response);
791
792
793 if ((currentNode.children != null) && currentNode.children.Length > 0)
765 794 {
766 messageIndex++;
795 foreach (Node<DialogOption> child in currentNode.children)
796 {
797 if (ImGui.Button(child.data.choice))
798 {
799 currentNode = child;
800 }
801
802 }
803
804 }
805 else
806 {
807 if (ImGui.Button("Okay")) {
808 this.showInitial = false;
809
810 }
811
812 }
813
814 if (currentNode.data.response == null)
815 {
816 this.showInitial = false;
767 817 }
768 818
769 819 ImGui.PopFont();
@@ -36,12 +36,14
36 36 <Compile Include="TileMap.cs" />
37 37 <Compile Include="Line.cs" />
38 38 <Compile Include="Camera.cs" />
39 <Compile Include="MathUtils.cs" />
40 39 <Compile Include="DrawVertDeclaration.cs" />
41 40 <Compile Include="ImGuiRenderer.cs" />
42 41 <Compile Include="DebugWindow.cs" />
43 42 <Compile Include="FilledRectangle.cs" />
44 43 <Compile Include="Simulation.cs" />
44 <Compile Include="Utils\MathUtils.cs" />
45 <Compile Include="Utils\Node.cs" />
46 <Compile Include="Dialog.cs" />
45 47 </ItemGroup>
46 48 <ItemGroup>
47 49 <ProjectReference Include="..\FNA\FNA.csproj">
@@ -132,6 +134,9
132 134 <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.4.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
133 135 </Reference>
134 136 </ItemGroup>
137 <ItemGroup>
138 <Folder Include="Utils\" />
139 </ItemGroup>
135 140 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
136 141 <Import Project="..\packages\ImGui.NET.1.78.0\build\net40\ImGui.NET.targets" Condition="Exists('..\packages\ImGui.NET.1.78.0\build\net40\ImGui.NET.targets')" />
137 142 </Project>
You need to be logged in to leave comments. Login now