Description:
Do some basic reformatting.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -9,240 +9,248 | |||
|
9 | 9 | using isometricparkfna.Components; |
|
10 | 10 | using isometricparkfna.UI; |
|
11 | 11 | |
|
12 |
namespace isometricparkfna.Engines |
|
|
12 | namespace isometricparkfna.Engines | |
|
13 | { | |
|
13 | 14 | |
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 | { | |
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
|
15 | [Sends(typeof(ToggleWindowMessage), | |
|
16 | typeof(ToggleWindowTypeMessage), | |
|
17 | typeof(ChangeContractStatusMessage), | |
|
18 | typeof(SelectMessage), | |
|
19 | typeof(JumpCameraMessage), | |
|
20 | typeof(GameStateMessage), | |
|
21 | typeof(GameStateMessage), | |
|
22 | typeof(SetResolutionMessage), | |
|
23 | typeof(SetFontMessage), | |
|
24 | typeof(SetTrespassingPolicyMessage), | |
|
25 | typeof(SpawnGameMessage), | |
|
26 | typeof(SetTextVariableMessage), | |
|
27 | typeof(SetDialogMessage), | |
|
28 | typeof(DialogChoiceMessage), | |
|
29 | typeof(SetOptionMessage))] | |
|
30 | [Reads(typeof(VisibilityComponent), | |
|
31 | typeof(WindowTypeComponent), | |
|
32 | typeof(TrespassingPolicyComponent), | |
|
33 | typeof(ContractStatusComponent), | |
|
34 | typeof(RelatedOrganizationComponent), | |
|
35 | typeof(NameAndDescriptionComponent), | |
|
36 | typeof(OptionsComponent))] | |
|
37 | [Writes(typeof(OptionsComponent))] | |
|
38 | public class ImGuiWindowBridgeEngine : Engine | |
|
39 | { | |
|
40 | public List<ToggleWindowMessage> messages; | |
|
41 | public List<ToggleWindowTypeMessage> typeMessages; | |
|
42 | public List<ChangeContractStatusMessage> contractStatusMessages; | |
|
43 | public List<SelectMessage> selectedMessages; | |
|
44 | public List<JumpCameraMessage> jumpCameraMessages; | |
|
45 | public List<GameStateMessage> gameStateMessages; | |
|
46 | public List<SetResolutionMessage> resolutionMessages; | |
|
47 | public List<SetFontMessage> fontMessages; | |
|
48 | public List<SetTrespassingPolicyMessage> trespassingPolicyMessages; | |
|
49 | public List<SpawnGameMessage> spawnGameMessages; | |
|
50 | public List<SetTextVariableMessage> setTextVariableMessages; | |
|
51 | public List<SetDialogMessage> setDialogMessages; | |
|
52 | public List<DialogChoiceMessage> dialogChoiceMessages; | |
|
53 | public List<SetOptionMessage> setOptionMessages; | |
|
53 | 54 | |
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
55 | bool showBudget { get; } | |
|
56 | bool showForest { get; } | |
|
57 | bool showNews { get; } | |
|
58 | bool showGrid { get; } | |
|
59 | bool showTrees { get; } | |
|
59 | 60 | |
|
60 |
|
|
|
61 | public Dictionary<Window, bool> windowStatuses { get; } | |
|
62 | ||
|
63 | public bool showContractIndicator; | |
|
64 | public List<string> contracts; | |
|
61 | 65 | |
|
62 | public bool showContractIndicator; | |
|
63 | public List<string> contracts; | |
|
66 | public ImFontPtr font; | |
|
67 | public ImFontPtr italicFont; | |
|
68 | private DebugWindow debugWindow; | |
|
69 | ||
|
70 | private Simulation Simulation; | |
|
64 | 71 | |
|
65 | public ImFontPtr font; | |
|
66 | public ImFontPtr italicFont; | |
|
67 | private DebugWindow debugWindow; | |
|
68 | ||
|
69 | private Simulation Simulation; | |
|
70 | ||
|
71 | public DateTime DateTime { get { | |
|
72 | return this.Simulation.DateTime; | |
|
73 | }} | |
|
72 | public DateTime DateTime | |
|
73 | { | |
|
74 | get | |
|
75 | { | |
|
76 | return this.Simulation.DateTime; | |
|
77 | } | |
|
78 | } | |
|
74 | 79 | |
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 | { | |
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
|
80 | public ImGuiWindowBridgeEngine(DebugWindow debugWindow, | |
|
81 | ImFontPtr font, ImFontPtr italicFont, | |
|
82 | Simulation simulation) | |
|
83 | { | |
|
84 | this.messages = new List<ToggleWindowMessage>(); | |
|
85 | this.typeMessages = new List<ToggleWindowTypeMessage>(); | |
|
86 | this.contractStatusMessages = new List<ChangeContractStatusMessage>(); | |
|
87 | this.selectedMessages = new List<SelectMessage>(); | |
|
88 | this.jumpCameraMessages = new List<JumpCameraMessage>(); | |
|
89 | this.gameStateMessages = new List<GameStateMessage>(); | |
|
90 | this.resolutionMessages = new List<SetResolutionMessage>(); | |
|
91 | this.fontMessages = new List<SetFontMessage>(); | |
|
92 | this.trespassingPolicyMessages = new List<SetTrespassingPolicyMessage>(); | |
|
93 | this.spawnGameMessages = new List<SpawnGameMessage>(); | |
|
94 | this.setTextVariableMessages = new List<SetTextVariableMessage>(); | |
|
95 | this.setDialogMessages = new List<SetDialogMessage>(); | |
|
96 | this.dialogChoiceMessages = new List<DialogChoiceMessage>(); | |
|
97 | this.setOptionMessages = new List<SetOptionMessage>(); | |
|
98 | this.windowStatuses = new Dictionary<Window, bool>(); | |
|
94 | 99 | |
|
95 |
|
|
|
100 | this.showContractIndicator = false; | |
|
96 | 101 | |
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
|
102 | this.font = font; | |
|
103 | this.italicFont = italicFont; | |
|
104 | this.debugWindow = debugWindow; | |
|
105 | this.Simulation = simulation; | |
|
101 | 106 | |
|
102 | 107 | |
|
103 |
|
|
|
108 | this.contracts = new List<string>(); | |
|
104 | 109 | |
|
105 | 110 | |
|
106 |
|
|
|
107 |
|
|
|
108 | { | |
|
109 |
|
|
|
110 | } | |
|
111 | } | |
|
111 | //Prepopulate: | |
|
112 | foreach (var type in System.Enum.GetValues(typeof(Window))) | |
|
113 | { | |
|
114 | windowStatuses.Add((Window)type, false); | |
|
115 | } | |
|
116 | } | |
|
112 | 117 | |
|
113 |
|
|
|
114 | { | |
|
115 |
|
|
|
116 | { | |
|
117 |
|
|
|
118 | } | |
|
119 |
|
|
|
120 | { | |
|
121 |
|
|
|
122 | } | |
|
123 |
|
|
|
124 | { | |
|
125 |
|
|
|
126 | } | |
|
127 |
|
|
|
128 | { | |
|
129 |
|
|
|
130 |
|
|
|
131 | } | |
|
132 |
|
|
|
133 | { | |
|
134 |
|
|
|
135 | } | |
|
118 | public override void Update(double dt) | |
|
119 | { | |
|
120 | foreach (var message in this.messages) | |
|
121 | { | |
|
122 | SendMessage(message); | |
|
123 | } | |
|
124 | foreach (var message in this.typeMessages) | |
|
125 | { | |
|
126 | SendMessage(message); | |
|
127 | } | |
|
128 | foreach (var message in this.contractStatusMessages) | |
|
129 | { | |
|
130 | SendMessage(message); | |
|
131 | } | |
|
132 | foreach (var message in this.selectedMessages) | |
|
133 | { | |
|
134 | SendMessage(message); | |
|
135 | // SetComponent<SelectedComponent>(message.Entity, new SelectedComponent { selected = true}); | |
|
136 | } | |
|
137 | foreach (var message in this.jumpCameraMessages) | |
|
138 | { | |
|
139 | SendMessage(message); | |
|
140 | } | |
|
136 | 141 | |
|
137 | // | |
|
138 |
|
|
|
139 | { | |
|
140 |
|
|
|
141 | } | |
|
142 |
|
|
|
143 | { | |
|
144 |
|
|
|
145 | } | |
|
146 |
|
|
|
147 | { | |
|
148 |
|
|
|
149 | } | |
|
150 |
|
|
|
151 | { | |
|
152 |
|
|
|
153 |
|
|
|
142 | // | |
|
143 | foreach (var message in this.setTextVariableMessages) | |
|
144 | { | |
|
145 | SendMessage(message); | |
|
146 | } | |
|
147 | foreach (var message in this.gameStateMessages) | |
|
148 | { | |
|
149 | SendMessage(message); | |
|
150 | } | |
|
151 | foreach (var message in this.resolutionMessages) | |
|
152 | { | |
|
153 | SendMessage(message); | |
|
154 | } | |
|
155 | foreach (var message in this.fontMessages) | |
|
156 | { | |
|
157 | this.font = debugWindow.addFont(message.fontName, | |
|
158 | message.fontSize, false); | |
|
154 | 159 | |
|
155 |
|
|
|
160 | debugWindow.setMonoFont(this.font); | |
|
156 | 161 | |
|
157 |
|
|
|
158 |
|
|
|
162 | this.italicFont = debugWindow.addFont(message.fontName, | |
|
163 | message.fontSize, true); | |
|
159 | 164 | |
|
160 |
|
|
|
161 |
|
|
|
165 | debugWindow.setItalicFont(this.italicFont); | |
|
166 | SendMessage(message); | |
|
162 | 167 | |
|
163 |
|
|
|
164 | message.fontSize); | |
|
165 | } | |
|
168 | OptionsWindow.setFont(message.fontName, | |
|
169 | message.fontSize); | |
|
170 | } | |
|
166 | 171 | |
|
167 |
|
|
|
168 | { | |
|
169 |
|
|
|
170 | } | |
|
172 | foreach (var message in this.trespassingPolicyMessages) | |
|
173 | { | |
|
174 | SendMessage(message); | |
|
175 | } | |
|
171 | 176 | |
|
172 |
|
|
|
173 | { | |
|
174 |
|
|
|
175 | } | |
|
177 | foreach (var message in this.spawnGameMessages) | |
|
178 | { | |
|
179 | SendMessage(message); | |
|
180 | } | |
|
176 | 181 | |
|
177 | 182 | |
|
178 |
|
|
|
179 | { | |
|
180 |
|
|
|
181 | } | |
|
182 |
|
|
|
183 | { | |
|
184 |
|
|
|
185 | } | |
|
183 | foreach (var message in this.setDialogMessages) | |
|
184 | { | |
|
185 | SendMessage(message); | |
|
186 | } | |
|
187 | foreach (var message in this.dialogChoiceMessages) | |
|
188 | { | |
|
189 | SendMessage(message); | |
|
190 | } | |
|
191 | ||
|
192 | foreach (var message in this.setOptionMessages) | |
|
193 | { | |
|
194 | foreach (var entity in ReadEntities<OptionsComponent>()) | |
|
195 | { | |
|
186 | 196 | |
|
187 | foreach(var message in this.setOptionMessages) | |
|
188 | { | |
|
189 | foreach(var entity in ReadEntities<OptionsComponent>()) | |
|
190 | { | |
|
191 | ||
|
192 | SetComponent(entity, new OptionsComponent { | |
|
193 | ProfanitySetting = message.NewProfanitySetting}); | |
|
194 | } | |
|
197 | SetComponent(entity, new OptionsComponent | |
|
198 | { | |
|
199 | ProfanitySetting = message.NewProfanitySetting | |
|
200 | }); | |
|
201 | } | |
|
195 | 202 | |
|
196 | } | |
|
203 | } | |
|
197 | 204 | |
|
198 |
|
|
|
199 | { | |
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 | } | |
|
205 | foreach (var entity in ReadEntities<WindowTypeComponent>()) | |
|
206 | { | |
|
207 | var type = GetComponent<WindowTypeComponent>(entity).type; | |
|
208 | var visibility = HasComponent<VisibilityComponent>(entity) ? GetComponent<VisibilityComponent>(entity).visible : false; | |
|
209 | windowStatuses[type] = visibility; | |
|
210 | } | |
|
204 | 211 | |
|
205 | //reset | |
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 | { | |
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
|
213 |
|
|
|
214 | { | |
|
215 | try { | |
|
216 | this.showContractIndicator = true; | |
|
217 | if (HasComponent<RelatedOrganizationComponent>(entity)) | |
|
218 | { | |
|
219 | var organizationEntity = GetComponent<RelatedOrganizationComponent>(entity).Entity; | |
|
220 | var name = GetComponent<NameAndDescriptionComponent>(organizationEntity).DisplayName; | |
|
221 | this.contracts.Add(name); | |
|
212 | //reset | |
|
213 | this.showContractIndicator = false; | |
|
214 | this.contracts.Clear(); | |
|
215 | foreach (var entity in ReadEntities<ContractStatusComponent>()) | |
|
216 | { | |
|
217 | var contractStatus = GetComponent<ContractStatusComponent>(entity); | |
|
218 | var age = this.Simulation.DateTime - contractStatus.date; | |
|
219 | if ((age.TotalDays > (5 * 30)) | |
|
220 | && (contractStatus.status == ContractStatus.Proposed)) | |
|
221 | { | |
|
222 | try | |
|
223 | { | |
|
224 | this.showContractIndicator = true; | |
|
225 | if (HasComponent<RelatedOrganizationComponent>(entity)) | |
|
226 | { | |
|
227 | var organizationEntity = GetComponent<RelatedOrganizationComponent>(entity).Entity; | |
|
228 | var name = GetComponent<NameAndDescriptionComponent>(organizationEntity).DisplayName; | |
|
229 | this.contracts.Add(name); | |
|
222 | 230 | |
|
223 | } | |
|
224 | } | |
|
225 |
|
|
|
226 | { | |
|
227 |
|
|
|
228 | } | |
|
229 | } | |
|
230 | } | |
|
231 | } | |
|
232 | } | |
|
233 | catch (Exception e) | |
|
234 | { | |
|
235 | Logging.Error(string.Format("Exception: {0}", e.ToString())); | |
|
236 | } | |
|
237 | } | |
|
238 | } | |
|
231 | 239 | |
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
|
|
|
239 |
|
|
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 | } | |
|
247 | } | |
|
240 | this.messages.Clear(); | |
|
241 | this.typeMessages.Clear(); | |
|
242 | this.contractStatusMessages.Clear(); | |
|
243 | this.selectedMessages.Clear(); | |
|
244 | this.jumpCameraMessages.Clear(); | |
|
245 | this.gameStateMessages.Clear(); | |
|
246 | this.resolutionMessages.Clear(); | |
|
247 | this.fontMessages.Clear(); | |
|
248 | this.trespassingPolicyMessages.Clear(); | |
|
249 | this.spawnGameMessages.Clear(); | |
|
250 | this.setTextVariableMessages.Clear(); | |
|
251 | this.setDialogMessages.Clear(); | |
|
252 | this.dialogChoiceMessages.Clear(); | |
|
253 | this.setOptionMessages.Clear(); | |
|
254 | } | |
|
255 | } | |
|
248 | 256 | } |
@@ -20,37 +20,38 | |||
|
20 | 20 | } |
|
21 | 21 | |
|
22 | 22 | |
|
23 |
|
|
|
24 | { | |
|
25 |
|
|
|
26 |
|
|
|
27 | { | |
|
28 |
|
|
|
29 |
|
|
|
30 | { | |
|
23 | public override void Update(double dt) | |
|
24 | { | |
|
25 | foreach (ref readonly var message | |
|
26 | in ReadMessages<SetTrespassingPolicyMessage>()) | |
|
27 | { | |
|
28 | foreach (ref readonly var entity | |
|
29 | in ReadEntities<TrespassingPolicyComponent>()) | |
|
30 | { | |
|
31 | 31 | |
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
32 | SetComponent<TrespassingPolicyComponent>(entity, | |
|
33 | new TrespassingPolicyComponent | |
|
34 | { | |
|
35 | tresspassingPolicy | |
|
36 | = message.newEnforcementLevel | |
|
37 | }); | |
|
35 | 38 | |
|
36 |
|
|
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
|
40 | ||
|
41 | ||
|
42 | }; | |
|
43 | ||
|
39 | var newCost = message.newEnforcementLevel switch { | |
|
40 | EnforcementLevel.NoEnforcement => 0, | |
|
41 | EnforcementLevel.EnforcedWithWarnings => 100, | |
|
42 | EnforcementLevel.EnforcedWithFines => 100 | |
|
43 | }; | |
|
44 | 44 | |
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
|
45 | SetComponent<BudgetLineComponent>(entity, | |
|
46 | new BudgetLineComponent | |
|
47 | { | |
|
48 | category = "Enforcement", | |
|
49 | amount = newCost | |
|
50 | }); | |
|
51 | } | |
|
52 | } | |
|
49 | 53 | |
|
50 | } | |
|
51 | } | |
|
52 | ||
|
53 | } | |
|
54 | } | |
|
54 | 55 | |
|
55 | 56 | } |
|
56 | 57 | } |
@@ -15,21 +15,21 | |||
|
15 | 15 | { |
|
16 | 16 | |
|
17 | 17 | [Receives(typeof(ToggleWindowMessage), |
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
|
18 | typeof(ToggleWindowTypeMessage), | |
|
19 | typeof(ToggleVisibilityMessage), | |
|
20 | typeof(SetWindowVisibilityMessage), | |
|
21 | typeof(SelectMessage), | |
|
22 | typeof(SetDialogMessage), | |
|
23 | typeof(DialogChoiceMessage))] | |
|
24 | 24 | [Reads(typeof(DialogComponent), |
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
[Writes(typeof(VisibilityComponent), |
|
|
29 |
|
|
|
25 | typeof(WindowTypeComponent), | |
|
26 | typeof(VisibilityComponent), | |
|
27 | typeof(SelectedComponent))] | |
|
28 | [Writes(typeof(VisibilityComponent), | |
|
29 | typeof(SelectedComponent))] | |
|
30 | 30 | class UIEngine : Engine |
|
31 | 31 | { |
|
32 |
|
|
|
32 | public Story Story; | |
|
33 | 33 | |
|
34 | 34 | public UIEngine(Story story) |
|
35 | 35 | { |
@@ -23,7 +23,7 | |||
|
23 | 23 | { |
|
24 | 24 | public String? choice; |
|
25 | 25 | public String response; |
|
26 |
|
|
|
26 | public String speaker; | |
|
27 | 27 | } |
|
28 | 28 | |
|
29 | 29 | |
@@ -31,177 +31,187 | |||
|
31 | 31 | { |
|
32 | 32 | |
|
33 | 33 | public static Node<DialogOption> introTree = new Node<DialogOption>( |
|
34 | 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. B opens the budget and F lets you adjust Forest Policy.", | |
|
35 | speaker = "The Governor" | |
|
36 | }, | |
|
37 | new Node<DialogOption>(new DialogOption { choice = "Okay", | |
|
38 | 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!", | |
|
39 | speaker = "The Governor" | |
|
40 | }, | |
|
41 | new Node<DialogOption>[]{ | |
|
34 | new DialogOption | |
|
35 | { | |
|
36 | 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. B opens the budget and F lets you adjust Forest Policy.", | |
|
37 | speaker = "The Governor" | |
|
38 | }, | |
|
39 | new Node<DialogOption>(new DialogOption | |
|
40 | { | |
|
41 | choice = "Okay", | |
|
42 | 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!", | |
|
43 | speaker = "The Governor" | |
|
44 | }, | |
|
45 | new Node<DialogOption>[]{ | |
|
42 | 46 | new Node<DialogOption>(new DialogOption {choice="And I need to keep the forest healthy, too, right?", response="Uhh yeah.", speaker = "The Governor" }, |
|
43 | 47 | new Node<DialogOption>(new DialogOption {choice="...", speaker = "The Governor"})), |
|
44 | 48 | new Node<DialogOption>(new DialogOption {choice="Sounds good!", response="I'll check in soon.", speaker = "The Governor" }) |
|
45 | 49 | |
|
46 | 50 | }) |
|
47 | ); | |
|
51 | ); | |
|
48 | 52 | |
|
49 |
|
|
|
50 |
|
|
|
51 | { | |
|
52 |
|
|
|
53 |
|
|
|
54 | }, | |
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
53 | public static Node<DialogOption> testTree = new Node<DialogOption>( | |
|
54 | new DialogOption | |
|
55 | { | |
|
56 | response = "#addressGreetingFormal#", | |
|
57 | speaker = "#assistantName#" | |
|
58 | }, | |
|
59 | new Node<DialogOption>[]{ | |
|
60 | new Node<DialogOption>(new DialogOption {choice="Call me #playerCasual#", response="Sure", | |
|
61 | speaker = "#assistantName#" }), | |
|
62 | new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!", | |
|
63 | speaker = "#assistantName#" }), | |
|
64 | new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#", | |
|
65 | speaker = "#assistantName#" }) | |
|
62 | 66 | |
|
63 | } | |
|
64 | ); | |
|
67 | } | |
|
68 | ); | |
|
65 | 69 | |
|
66 |
|
|
|
67 |
|
|
|
68 | { | |
|
69 |
|
|
|
70 |
|
|
|
71 | }, | |
|
70 | public static Node<DialogOption> testTree2 = new Node<DialogOption>( | |
|
71 | new DialogOption | |
|
72 | { | |
|
73 | response = "#whatever#", | |
|
74 | speaker = "#assistantName#" | |
|
75 | }, | |
|
72 | 76 | |
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
77 | new Node<DialogOption>[]{ | |
|
78 | new Node<DialogOption>(new DialogOption {choice="Hi.", response="Bye!", | |
|
79 | speaker = "#assistantName#" }), | |
|
80 | new Node<DialogOption>(new DialogOption {choice="How are you?", response="#howdoing#", | |
|
81 | speaker = "#assistantName#" }) | |
|
78 | 82 | |
|
79 | } | |
|
80 | ); | |
|
83 | } | |
|
84 | ); | |
|
81 | 85 | |
|
82 | 86 | |
|
83 |
|
|
|
87 | public static Node<DialogOption> flatten(Node<DialogOption> node, Grammar grammar) | |
|
88 | { | |
|
84 | 89 | |
|
85 |
|
|
|
86 | { | |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 | }; | |
|
90 | DialogOption new_data = new DialogOption | |
|
91 | { | |
|
92 | choice = node.data.choice != null ? grammar.Flatten(node.data.choice) : node.data.choice, | |
|
93 | response = grammar.Flatten(node.data.response), | |
|
94 | speaker = grammar.Flatten(node.data.speaker) | |
|
95 | }; | |
|
91 | 96 | |
|
92 | 97 | |
|
93 |
|
|
|
94 | List<Node<DialogOption>> new_children = new List<Node<DialogOption>>(); | |
|
95 | foreach (Node<DialogOption> child in node.children) | |
|
96 | { | |
|
97 | new_children.Add(flatten(child, grammar)); | |
|
98 | } | |
|
98 | if (node.children != null) | |
|
99 | { | |
|
100 | List<Node<DialogOption>> new_children = new List<Node<DialogOption>>(); | |
|
101 | foreach (Node<DialogOption> child in node.children) | |
|
102 | { | |
|
103 | new_children.Add(flatten(child, grammar)); | |
|
104 | } | |
|
99 | 105 | |
|
100 |
|
|
|
101 | } | |
|
102 | else | |
|
106 | return new Node<DialogOption>(new_data, new_children.ToArray()); | |
|
107 | } | |
|
108 | else | |
|
103 | 109 | { |
|
104 |
|
|
|
110 | return new Node<DialogOption>(new_data); | |
|
105 | 111 | |
|
106 | } | |
|
112 | } | |
|
107 | 113 | |
|
108 | } | |
|
114 | } | |
|
109 | 115 | |
|
110 | } | |
|
116 | } | |
|
111 | 117 | |
|
112 | 118 | public static class DialogInterface |
|
113 | 119 | { |
|
114 | 120 | |
|
115 |
|
|
|
121 | public static bool hadFocus = false; | |
|
116 | 122 | |
|
117 | 123 | public static ImGuiImageMap map; |
|
118 | 124 | private static IntPtr _imGuiTexture; |
|
119 | 125 | |
|
120 |
public static void LoadContent(ImGuiRenderer _imGuiRenderer, |
|
|
126 | public static void LoadContent(ImGuiRenderer _imGuiRenderer, | |
|
121 | 127 | ImGuiImageMap map) |
|
122 | 128 | { |
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
|
129 | DialogInterface.map = map; | |
|
130 | var _xnaTexture = map.ImageMapTexture; | |
|
131 | DialogInterface._imGuiTexture = _imGuiRenderer.BindTexture(_xnaTexture); | |
|
126 | 132 | } |
|
127 | 133 | |
|
128 | 134 | public static void RenderDialog(Entity entity, |
|
129 | 135 | ImGuiWindowBridgeEngine bridgeEngine, ref bool show, ref bool paused, ImFontPtr font, DialogComponent dialogComponent) |
|
130 | 136 | { |
|
131 | if (show) | |
|
132 | { | |
|
133 |
|
|
|
134 |
|
|
|
137 | if (show) | |
|
138 | { | |
|
139 | ImGui.PushFont(font); | |
|
140 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.None; | |
|
135 | 141 | |
|
136 |
|
|
|
142 | StyleSets.defaultSet.push(); | |
|
137 | 143 | |
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
142 |
|
|
|
144 | ImGui.SetNextWindowSize(new Num.Vector2(400, 200)); | |
|
145 | if (DialogInterface.hadFocus) | |
|
146 | { | |
|
147 | ImGui.PushStyleColor(ImGuiCol.Text, StyleSets.white); | |
|
148 | } | |
|
143 | 149 | |
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
|
149 |
|
|
|
150 | ImGui.Begin(dialogComponent.CurrentSpeaker, ref show, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoSavedSettings); | |
|
151 | if (DialogInterface.hadFocus) | |
|
152 | { | |
|
153 | ImGui.PopStyleColor(); | |
|
154 | } | |
|
155 | DialogInterface.hadFocus = ImGui.IsWindowFocused(); | |
|
150 | 156 | |
|
151 |
|
|
|
157 | ImGui.Columns(2); | |
|
152 | 158 | |
|
153 |
|
|
|
159 | Widgets.MapImage(DialogInterface.map, new Num.Vector2(150, 100), 1); | |
|
154 | 160 | |
|
155 |
|
|
|
161 | ImGui.NextColumn(); | |
|
156 | 162 | |
|
157 | 163 | |
|
158 |
|
|
|
164 | if (dialogComponent.CurrentDialog != null) | |
|
159 | 165 | { |
|
160 |
|
|
|
161 |
|
|
|
162 | } | |
|
166 | string messageText = dialogComponent.CurrentDialog; | |
|
167 | ImGui.TextWrapped(messageText); | |
|
168 | } | |
|
163 | 169 | |
|
164 |
|
|
|
170 | ImGui.Columns(1); | |
|
165 | 171 | |
|
166 |
|
|
|
167 | { | |
|
168 |
|
|
|
169 | { | |
|
170 |
|
|
|
171 |
|
|
|
172 | { | |
|
173 |
|
|
|
172 | if ((dialogComponent.Options != null) && dialogComponent.Options.Count > 0) | |
|
173 | { | |
|
174 | for (int i = 0; i < dialogComponent.Options.Count; i++) | |
|
175 | { | |
|
176 | string buttonText = dialogComponent.Options[i]; | |
|
177 | if (ImGui.Button(buttonText)) | |
|
178 | { | |
|
179 | bridgeEngine.dialogChoiceMessages.Add(new DialogChoiceMessage | |
|
180 | { | |
|
174 | 181 | |
|
175 |
|
|
|
176 |
|
|
|
182 | Entity = entity, | |
|
183 | Choice = i | |
|
184 | }); | |
|
177 | 185 | |
|
178 | } | |
|
179 | } | |
|
180 | } | |
|
181 | else | |
|
182 | { | |
|
183 |
|
|
|
184 | { | |
|
185 | show = false; | |
|
186 | paused = false; | |
|
187 |
|
|
|
186 | } | |
|
187 | } | |
|
188 | } | |
|
189 | else | |
|
190 | { | |
|
191 | if (ImGui.Button("Okay")) | |
|
192 | { | |
|
193 | show = false; | |
|
194 | paused = false; | |
|
195 | bridgeEngine.dialogChoiceMessages.Add(new DialogChoiceMessage | |
|
196 | { | |
|
188 | 197 | |
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 | } | |
|
193 | ||
|
194 | if (dialogComponent.CurrentDialog == null) | |
|
195 | { | |
|
196 | show = false; | |
|
197 | paused = false; | |
|
198 | Entity = entity, | |
|
199 | Choice = -1 | |
|
200 | }); | |
|
201 | } | |
|
202 | } | |
|
198 | 203 | |
|
199 | } | |
|
200 | ImGui.End(); | |
|
201 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; | |
|
202 | StyleSets.defaultSet.pop(); | |
|
203 | ImGui.PopFont(); | |
|
204 | } | |
|
205 | } | |
|
206 | } | |
|
204 | if (dialogComponent.CurrentDialog == null) | |
|
205 | { | |
|
206 | show = false; | |
|
207 | paused = false; | |
|
208 | ||
|
209 | } | |
|
210 | ImGui.End(); | |
|
211 | ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Left; | |
|
212 | StyleSets.defaultSet.pop(); | |
|
213 | ImGui.PopFont(); | |
|
214 | } | |
|
215 | } | |
|
216 | } | |
|
207 | 217 | } |
You need to be logged in to leave comments.
Login now