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