Description:
Factor out dialog code.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r42:c9249850e243 -

@@ -18,3 +18,4
18 18 /Users/alys/repos/isometric-park-fna/FNA/obj/Debug/FNA.csproj.CoreCompileInputs.cache
19 19 /Users/alys/repos/isometric-park-fna/FNA/obj/Debug/FNA.dll
20 20 /Users/alys/repos/isometric-park-fna/FNA/obj/Debug/FNA.pdb
21 /Users/alys/repos/isometric-park-fna/FNA/obj/Debug/FNA.csprojAssemblyReference.cache
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,6 +1,10
1 1 using System;
2 using ImGuiNET;
2 3 using isometricparkfna.Utils;
3 4
5 using Num = System.Numerics;
6
7
4 8 namespace isometricparkfna
5 9 {
6 10
@@ -28,6 +32,87
28 32
29 33 })
30 34 );
31 }
35
36 public static Node<DialogOption> testTree = new Node<DialogOption>(
37 new DialogOption
38 {
39 response = "Hi.",
40 },
41
42 new Node<DialogOption>[]{
43 new Node<DialogOption>(new DialogOption {choice="Hi.", response="*walks away*" }),
44 new Node<DialogOption>(new DialogOption {choice="What's up?", response="Not much!" })
45
46 }
47 );
48
49 }
50
51 public static class DialogInterface
52 {
53 public static Node<DialogOption> RenderDialog(string title, ref bool show, ref bool paused, ImFontPtr font, Node<DialogOption> currentNode)
54 {
55 if (show)
56 {
57 ImGui.PushFont(font);
58
59 ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
60 ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
61 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
62 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
63
64 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
65 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
66 ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar);
67 ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar);
68
69 ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
70 ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
71
72
73
74 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
75 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
76 ImGui.Begin(title, ref show);
77
78
79 ImGui.TextWrapped(currentNode.data.response);
80 if ((currentNode.children != null) && currentNode.children.Length > 0)
81 {
82 foreach (Node<DialogOption> child in currentNode.children)
83 {
84 if (ImGui.Button(child.data.choice))
85 {
86 return child;
87 }
88 }
89 }
90 else
91 {
92 if (ImGui.Button("Okay"))
93 {
94 show = false;
95 paused = false;
96 //return null;
97 }
98 }
99
100 if (currentNode.data.response == null)
101 {
102 show = false;
103 paused = false;
104 //return null;
105
106 }
107 ImGui.End();
108 ImGui.PopStyleVar(3);
109 ImGui.PopStyleColor(8);
110 ImGui.PopFont();
111 }
112 return currentNode;
113
114 }
115 }
116
32 117
33 118 }
@@ -15,7 +15,6
15 15 using static isometricparkfna.TileMap;
16 16 using isometricparkfna.Utils;
17 17
18 using Num = System.Numerics;
19 18
20 19
21 20
@@ -73,6 +72,7
73 72
74 73 private bool showGrid = true;
75 74 private string output;
75 private bool showSecond = true;
76 76
77 77 private static void Main(string[] args)
78 78 {
@@ -776,60 +776,11
776 776 // 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?" },
777 777 // new DialogOption{ response="Oh yeah, of course.", choice="..." }};
778 778
779 if (showInitial)
780 {
781 ImGui.PushFont(debugWindow.monoFont);
782
783 ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0.0f);
784 ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 0.0f);
785 ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
786 ImGui.PushStyleColor(ImGuiCol.WindowBg, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
787
788 var title_bar = new Num.Vector4(0.65f, 0.65f, 0.65f, 1f);
789 ImGui.PushStyleColor(ImGuiCol.TitleBg, title_bar);
790 ImGui.PushStyleColor(ImGuiCol.TitleBgActive, title_bar);
791 ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, title_bar);
792
793 ImGui.PushStyleColor(ImGuiCol.Border, new Num.Vector4(0f, 0f, 0f, 1f));
794 ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Num.Vector4(0f, 0f, 0f, 0.5f));
795
796
797
798 ImGui.PushStyleColor(ImGuiCol.Button, new Num.Vector4(0.75f, 0.75f, 0.75f, 1f));
799 ImGui.PushStyleColor(ImGuiCol.Text, new Num.Vector4(0f, 0f, 0f, 1f));
800 ImGui.Begin("The Governor", ref showInitial);
801
802 779
803 ImGui.TextWrapped(currentNode.data.response);
804 if ((currentNode.children != null) && currentNode.children.Length > 0)
805 {
806 foreach (Node<DialogOption> child in currentNode.children)
807 {
808 if (ImGui.Button(child.data.choice))
809 {
810 currentNode = child;
811 }
812 }
813 }
814 else
815 {
816 if (ImGui.Button("Okay")) {
817 this.showInitial = false;
818 this.simulation.paused = false;
819 }
820 }
780 this.currentNode = DialogInterface.RenderDialog("The Governor", ref this.showInitial,
781 ref this.simulation.paused, debugWindow.monoFont, this.currentNode);
821 782
822 if (currentNode.data.response == null)
823 {
824 this.showInitial = false;
825 this.simulation.paused = false;
826
827 }
828 ImGui.End();
829 ImGui.PopStyleVar(3);
830 ImGui.PopStyleColor(8);
831 ImGui.PopFont();
832 }
783
833 784
834 785 _imGuiRenderer.AfterLayout();
835 786
@@ -29,6 +29,7
29 29 <LangVersion>8.0</LangVersion>
30 30 <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
31 31 <ExternalConsole>false</ExternalConsole>
32 <NoWarn></NoWarn>
32 33 </PropertyGroup>
33 34 <ItemGroup>
34 35 <Compile Include="FNAGame.cs" />
You need to be logged in to leave comments. Login now