Debian Codegraph @

editor/DeathDialog.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 // DeathDialog.cpp : implementation file
20 //
21
22 #include "stdafx.h"
23 #include "editor.h"
24 #include "DeathDialog.h"
25
26 #ifdef _DEBUG
27 #define new DEBUG_NEW
28 #undef THIS_FILE
29 static char THIS_FILE[] = __FILE__;
30 #endif
31
32 // Stuff for Copy/Paste
33 static death_info Paste_data;
34 static bool Paste_data_used = 0;
35
36 /////////////////////////////////////////////////////////////////////////////
37 // CDeathDialog dialog
38
39 CDeathDialog::CDeathDialog(death_info *death_info, CWnd *pParent /*=NULL*/) : CDialog(CDeathDialog::IDD, pParent) {
40 //{{AFX_DATA_INIT(CDeathDialog)
41 m_explosion_size_radio = -1;
42 m_delay_max = 0.0f;
43 m_delay_min = 0.0f;
44 //}}AFX_DATA_INIT
45
46 m_death_info_ptr = death_info;
47
48 m_flags = death_info->flags;
49 m_delay_min = death_info->delay_min;
50 m_delay_max = death_info->delay_max;
51 }
52
53 void CDeathDialog::DoDataExchange(CDataExchange *pDX) {
54 CDialog::DoDataExchange(pDX);
55 //{{AFX_DATA_MAP(CDeathDialog)
56 DDX_Radio(pDX, IDC_DEATH_EXPLOSION_SMALL, m_explosion_size_radio);
57 DDX_Text(pDX, IDC_DEATH_DELAY_MAX, m_delay_max);
58 DDV_MinMaxFloat(pDX, m_delay_max, 0.f, 10.f);
59 DDX_Text(pDX, IDC_DEATH_DELAY_MIN, m_delay_min);
60 DDV_MinMaxFloat(pDX, m_delay_min, 0.f, 10.f);
61 //}}AFX_DATA_MAP
62 }
63
64 BEGIN_MESSAGE_MAP(CDeathDialog, CDialog)
65 //{{AFX_MSG_MAP(CDeathDialog)
66 ON_BN_CLICKED(IDC_DEATH_BREAKS_APART, OnDeathBreaksApart)
67 ON_BN_CLICKED(IDC_DEATH_COMMON_ANIMAL, OnDeathCommonAnimal)
68 ON_BN_CLICKED(IDC_DEATH_COMMON_DESCENT, OnDeathCommonDescent)
69 ON_BN_CLICKED(IDC_DEATH_COMMON_QUICK_EXPLOSION, OnDeathCommonQuickExplosion)
70 ON_BN_CLICKED(IDC_DEATH_COMMON_R2D2, OnDeathCommonR2D2)
71 ON_BN_CLICKED(IDC_DEATH_COMMON_SHOOT_UP, OnDeathCommonShootUp)
72 ON_BN_CLICKED(IDC_DEATH_CONTACT_BREAKS_APART, OnDeathContactBreaksApart)
73 ON_BN_CLICKED(IDC_DEATH_CONTACT_EXPLODES, OnDeathContactExplodes)
74 ON_BN_CLICKED(IDC_DEATH_CONTACT_REMAINS, OnDeathContactRemains)
75 ON_BN_CLICKED(IDC_DEATH_COPY, OnDeathCopy)
76 ON_BN_CLICKED(IDC_DEATH_DEBRIS_CONTACT_EXPLODES, OnDeathDebrisContactExplodes)
77 ON_BN_CLICKED(IDC_DEATH_DEBRIS_CONTACT_REMAINS, OnDeathDebrisContactRemains)
78 ON_BN_CLICKED(IDC_DEATH_DELAY_FIREBALLS, OnDeathDelayFireballs)
79 ON_BN_CLICKED(IDC_DEATH_DELAY_FLYING, OnDeathDelayFlying)
80 ON_BN_CLICKED(IDC_DEATH_DELAY_LOSES_ANTIGRAV, OnDeathDelayLosesAntigrav)
81 ON_EN_CHANGE(IDC_DEATH_DELAY_MAX, OnChangeDeathDelayMax)
82 ON_EN_CHANGE(IDC_DEATH_DELAY_MIN, OnChangeDeathDelayMin)
83 ON_BN_CLICKED(IDC_DEATH_DELAY_SPARKS, OnDeathDelaySparks)
84 ON_BN_CLICKED(IDC_DEATH_EXPLODES, OnDeathExplodes)
85 ON_BN_CLICKED(IDC_DEATH_EXPLOSION_LARGE, OnDeathExplosionLarge)
86 ON_BN_CLICKED(IDC_DEATH_EXPLOSION_MEDIUM, OnDeathExplosionMedium)
87 ON_BN_CLICKED(IDC_DEATH_EXPLOSION_SMALL, OnDeathExplosionSmall)
88 ON_BN_CLICKED(IDC_DEATH_PASTE, OnDeathPaste)
89 ON_BN_CLICKED(IDC_DEATH_BLAST_RING, OnDeathBlastRing)
90 ON_BN_CLICKED(IDC_DEATH_CONTACT_BLAST_RING, OnDeathContactBlastRing)
91 ON_BN_CLICKED(IDC_DEATH_CONTACT_FIREBALL, OnDeathContactFireball)
92 ON_BN_CLICKED(IDC_DEATH_DEBRIS_CONTACT_BLAST_RING, OnDeathDebrisContactBlastRing)
93 ON_BN_CLICKED(IDC_DEATH_DEBRIS_CONTACT_FIREBALL, OnDeathDebrisContactFireball)
94 ON_BN_CLICKED(IDC_DEATH_DEBRIS_SMOKES, OnDeathDebrisSmokes)
95 ON_BN_CLICKED(IDC_DEATH_DELAY_FROM_ANIM, OnDeathDelayFromAnim)
96 ON_BN_CLICKED(IDC_DEATH_DELAY_SMOKE, OnDeathDelaySmoke)
97 ON_BN_CLICKED(IDC_DEATH_FIREBALL, OnDeathFireball)
98 ON_BN_CLICKED(IDC_DEATH_LOSES_ANTIGRAV, OnDeathLosesAntigrav)
99 ON_BN_CLICKED(IDC_DEATH_REMAINS, OnDeathRemains)
100 ON_BN_CLICKED(IDC_DEATH_DELAY_FADE_AWAY, OnDeathDelayFadeAway)
101 ON_BN_CLICKED(IDC_DEATH_FADES_AWAY, OnDeathFadesAway)
102 ON_BN_CLICKED(IDC_DEATH_DELAY_SOUND, OnDeathDelaySound)
103 ON_BN_CLICKED(IDC_DEATH_DELAY_NO_TUMBLE, OnDeathDelayNoTumble)
104 //}}AFX_MSG_MAP
105 END_MESSAGE_MAP()
106
107 /////////////////////////////////////////////////////////////////////////////
108 // CDeathDialog message handlers
109
110 BOOL CDeathDialog::OnInitDialog() {
111 CDialog::OnInitDialog();
112
113 UpdateDialog();
114
115 return TRUE; // return TRUE unless you set the focus to a control
116 // EXCEPTION: OCX Property Pages should return FALSE
117 }
118
119 // Handy macros
120 #define SET_CHECK(id, state) ((CButton *)GetDlgItem(id))->SetCheck((state) != 0)
121 #define GET_CHECK(id) ((CButton *)GetDlgItem(id))->GetCheck()
122 #define ENABLE(id, state) ((CButton *)GetDlgItem(id))->EnableWindow((state) != 0)
123
124 void CDeathDialog::UpdateDialog() {
125 // Set member variables for explosion size radio button
126 m_explosion_size_radio = (m_flags & DF_EXPL_SIZE_MASK) >> DF_EXPL_SIZE_SHIFT;
127
128 // Update the dialog from member variables
129 UpdateData(false);
130
131 // Set the delay checkboxes
132 SET_CHECK(IDC_DEATH_DELAY_FROM_ANIM, (m_flags & DF_DELAY_FROM_ANIM));
133 SET_CHECK(IDC_DEATH_DELAY_LOSES_ANTIGRAV, (m_flags & DF_DELAY_LOSES_ANTIGRAV));
134 SET_CHECK(IDC_DEATH_DELAY_SPARKS, (m_flags & DF_DELAY_SPARKS));
135 SET_CHECK(IDC_DEATH_DELAY_SMOKE, (m_flags & DF_DELAY_SMOKES));
136 SET_CHECK(IDC_DEATH_DELAY_FLYING, (m_flags & DF_DELAY_FLYING));
137 SET_CHECK(IDC_DEATH_DELAY_FIREBALLS, (m_flags & DF_DELAY_FIREBALL));
138 SET_CHECK(IDC_DEATH_DELAY_FADE_AWAY, (m_flags & DF_DELAY_FADE_AWAY));
139 SET_CHECK(IDC_DEATH_DELAY_SOUND, (m_flags & DF_DELAY_SOUND));
140 SET_CHECK(IDC_DEATH_DELAY_NO_TUMBLE, (m_flags & DF_DELAY_NO_TUMBLE_FLY));
141
142 // Set the death checkboxes
143 SET_CHECK(IDC_DEATH_FIREBALL, (m_flags & DF_FIREBALL));
144 SET_CHECK(IDC_DEATH_BREAKS_APART, (m_flags & DF_BREAKS_APART));
145 SET_CHECK(IDC_DEATH_FADES_AWAY, (m_flags & DF_FADE_AWAY));
146 SET_CHECK(IDC_DEATH_BLAST_RING, (m_flags & DF_BLAST_RING));
147 SET_CHECK(IDC_DEATH_REMAINS, (m_flags & DF_REMAINS));
148 SET_CHECK(IDC_DEATH_LOSES_ANTIGRAV, (m_flags & DF_LOSES_ANTIGRAV));
149
150 // Set the contact checkboxes
151 SET_CHECK(IDC_DEATH_CONTACT_FIREBALL, (m_flags & DF_CONTACT_FIREBALL));
152 SET_CHECK(IDC_DEATH_CONTACT_BREAKS_APART, (m_flags & DF_CONTACT_BREAKS_APART));
153 SET_CHECK(IDC_DEATH_CONTACT_BLAST_RING, (m_flags & DF_CONTACT_BLAST_RING));
154 SET_CHECK(IDC_DEATH_CONTACT_REMAINS, (m_flags & DF_CONTACT_REMAINS));
155
156 // Set the debris checkbox
157 SET_CHECK(IDC_DEATH_DEBRIS_SMOKES, (m_flags & DF_DEBRIS_SMOKES));
158
159 // Set the debris contact checkboxes
160 SET_CHECK(IDC_DEATH_DEBRIS_CONTACT_FIREBALL, (m_flags & DF_DEBRIS_FIREBALL));
161 SET_CHECK(IDC_DEATH_DEBRIS_CONTACT_BLAST_RING, (m_flags & DF_DEBRIS_BLAST_RING));
162 SET_CHECK(IDC_DEATH_DEBRIS_CONTACT_REMAINS, (m_flags & DF_DEBRIS_REMAINS));
163
164 // Enable/disable delay options
165 bool delay = ((m_flags & DF_DELAY_FROM_ANIM) || (m_delay_min != 0.0) || (m_delay_max != 0.0));
166 ENABLE(IDC_DEATH_DELAY_GROUP, delay);
167 ENABLE(IDC_DEATH_DELAY_LOSES_ANTIGRAV, delay);
168 ENABLE(IDC_DEATH_DELAY_SPARKS, delay);
169 ENABLE(IDC_DEATH_DELAY_SMOKE, delay);
170 ENABLE(IDC_DEATH_DELAY_FLYING, delay);
171 ENABLE(IDC_DEATH_DELAY_FIREBALLS, delay);
172 ENABLE(IDC_DEATH_DELAY_FADE_AWAY, delay);
173 ENABLE(IDC_DEATH_DELAY_SOUND, delay);
174 ENABLE(IDC_DEATH_DELAY_NO_TUMBLE, delay && (m_flags & DF_DELAY_FLYING));
175
176 // Enable/disable delay times
177 bool user_delay = !(m_flags & DF_DELAY_FROM_ANIM);
178 ENABLE(IDC_DEATH_DELAY_MIN, user_delay);
179 ENABLE(IDC_DEATH_DELAY_MAX, user_delay);
180 ENABLE(IDC_DEATH_DELAY_MIN_LABEL, user_delay);
181 ENABLE(IDC_DEATH_DELAY_MAX_LABEL, user_delay);
182
183 // Enable/disable contact options
184 ENABLE(IDC_DEATH_CONTACT_FIREBALL, delay);
185 ENABLE(IDC_DEATH_CONTACT_BREAKS_APART, delay);
186 ENABLE(IDC_DEATH_CONTACT_BLAST_RING, delay);
187 ENABLE(IDC_DEATH_CONTACT_REMAINS, delay);
188 ENABLE(IDC_DEATH_CONTACT_GROUP, delay);
189
190 // Enable/disable explosion options
191 bool explodes = ((m_flags & DF_FIREBALL) != 0);
192 ENABLE(IDC_DEATH_EXPLOSION_SMALL, explodes);
193 ENABLE(IDC_DEATH_EXPLOSION_MEDIUM, explodes);
194 ENABLE(IDC_DEATH_EXPLOSION_LARGE, explodes);
195 ENABLE(IDC_DEATH_EXPLOSION_OPTIONS_GROUP, explodes);
196
197 // Enable/disable debris options
198 bool breaks_apart = ((m_flags & DF_BREAKS_APART) != 0);
199 ENABLE(IDC_DEATH_DEBRIS_CONTACT_FIREBALL, breaks_apart);
200 ENABLE(IDC_DEATH_DEBRIS_CONTACT_BLAST_RING, breaks_apart);
201 ENABLE(IDC_DEATH_DEBRIS_CONTACT_REMAINS, breaks_apart);
202 ENABLE(IDC_DEATH_DEBRIS_CONTACT_GROUP, breaks_apart);
203 ENABLE(IDC_DEATH_DEBRIS_SMOKES, breaks_apart);
204 ENABLE(IDC_DEATH_DEBRIS_OPTIONS_GROUP, breaks_apart);
205
206 // Enable/disable Paste
207 ENABLE(IDC_DEATH_PASTE, Paste_data_used);
208 }
209
210 void CDeathDialog::OnDeathDelayFromAnim() {
211 m_flags ^= DF_DELAY_FROM_ANIM;
212
213 UpdateDialog();
214 }
215
216 void CDeathDialog::OnChangeDeathDelayMin() {
217 // TODO: If this is a RICHEDIT control, the control will not
218 // send this notification unless you override the CDialog::OnInitDialog()
219 // function and call CRichEditCtrl().SetEventMask()
220 // with the ENM_CHANGE flag ORed into the mask.
221
222 // Update the member variables from the dialog
223 UpdateData(true);
224
225 UpdateDialog();
226 }
227
228 void CDeathDialog::OnChangeDeathDelayMax() {
229 // TODO: If this is a RICHEDIT control, the control will not
230 // send this notification unless you override the CDialog::OnInitDialog()
231 // function and call CRichEditCtrl().SetEventMask()
232 // with the ENM_CHANGE flag ORed into the mask.
233
234 // Update the member variables from the dialog
235 UpdateData(true);
236
237 UpdateDialog();
238 }
239
240 void CDeathDialog::OnDeathDelaySparks() {
241 m_flags ^= DF_DELAY_SPARKS;
242
243 UpdateDialog();
244 }
245
246 void CDeathDialog::OnDeathDelayFireballs() {
247 m_flags ^= DF_DELAY_FIREBALL;
248
249 UpdateDialog();
250 }
251
252 void CDeathDialog::OnDeathDelaySmoke() {
253 m_flags ^= DF_DELAY_SMOKES;
254
255 UpdateDialog();
256 }
257
258 void CDeathDialog::OnDeathDelayFlying() {
259 m_flags ^= DF_DELAY_FLYING;
260
261 UpdateDialog();
262 }
263
264 void CDeathDialog::OnDeathDelayLosesAntigrav() {
265 m_flags ^= DF_DELAY_LOSES_ANTIGRAV;
266
267 UpdateDialog();
268 }
269
270 void CDeathDialog::OnDeathDelayFadeAway() {
271 m_flags ^= DF_DELAY_FADE_AWAY;
272
273 UpdateDialog();
274 }
275
276 void CDeathDialog::OnDeathExplodes() {
277 m_flags ^= DF_FIREBALL;
278
279 UpdateDialog();
280 }
281
282 void CDeathDialog::OnDeathBreaksApart() {
283 m_flags ^= DF_BREAKS_APART;
284
285 UpdateDialog();
286 }
287
288 void CDeathDialog::OnDeathExplosionSmall() {
289 m_flags = (m_flags & ~DF_EXPL_SIZE_MASK) | DF_EXPL_SMALL;
290
291 UpdateDialog();
292 }
293
294 void CDeathDialog::OnDeathExplosionMedium() {
295 m_flags = (m_flags & ~DF_EXPL_SIZE_MASK) | DF_EXPL_MEDIUM;
296
297 UpdateDialog();
298 }
299
300 void CDeathDialog::OnDeathExplosionLarge() {
301 m_flags = (m_flags & ~DF_EXPL_SIZE_MASK) | DF_EXPL_LARGE;
302
303 UpdateDialog();
304 }
305
306 void CDeathDialog::OnDeathBlastRing() {
307 m_flags ^= DF_BLAST_RING;
308
309 UpdateDialog();
310 }
311
312 void CDeathDialog::OnDeathContactBreaksApart() {
313 m_flags ^= DF_CONTACT_BREAKS_APART;
314
315 UpdateDialog();
316 }
317
318 void CDeathDialog::OnDeathContactExplodes() {
319 m_flags ^= DF_CONTACT_FIREBALL;
320
321 UpdateDialog();
322 }
323
324 void CDeathDialog::OnDeathContactRemains() {
325 m_flags ^= DF_CONTACT_REMAINS;
326
327 UpdateDialog();
328 }
329
330 void CDeathDialog::OnDeathDebrisContactExplodes() {
331 m_flags ^= DF_DEBRIS_FIREBALL;
332
333 UpdateDialog();
334 }
335
336 void CDeathDialog::OnDeathDebrisContactRemains() {
337 m_flags ^= DF_DEBRIS_REMAINS;
338
339 UpdateDialog();
340 }
341
342 void CDeathDialog::OnDeathCommonDescent() {
343 m_flags = DF_DELAY_FIREBALL + DF_FIREBALL + DF_BREAKS_APART + DF_DEBRIS_FIREBALL + DF_EXPL_MEDIUM;
344 m_delay_min = m_delay_max = 2.0;
345
346 UpdateDialog();
347 }
348
349 void CDeathDialog::OnDeathCommonQuickExplosion() {
350 m_flags = DF_FIREBALL + DF_BREAKS_APART + DF_DEBRIS_FIREBALL + DF_EXPL_MEDIUM;
351 m_delay_min = m_delay_max = 0.0;
352
353 UpdateDialog();
354 }
355
356 void CDeathDialog::OnDeathCommonShootUp() {
357 m_flags = DF_DELAY_FLYING + DF_FIREBALL + DF_BREAKS_APART + DF_DEBRIS_FIREBALL + DF_EXPL_MEDIUM;
358 m_delay_min = 1.0;
359 m_delay_max = 3.0;
360
361 UpdateDialog();
362 }
363
364 void CDeathDialog::OnDeathCommonR2D2() {
365 m_flags = DF_DELAY_SPARKS + DF_FIREBALL + DF_BREAKS_APART + DF_DEBRIS_FIREBALL + DF_EXPL_MEDIUM;
366 m_delay_min = 2.0;
367 m_delay_max = 4.0;
368
369 UpdateDialog();
370 }
371
372 void CDeathDialog::OnDeathCommonAnimal() {
373 m_flags = DF_CONTACT_REMAINS;
374 m_delay_min = m_delay_max = 0.0;
375
376 UpdateDialog();
377 }
378
379 void CDeathDialog::OnDeathCopy() {
380 Paste_data.flags = m_flags;
381 Paste_data.delay_min = m_delay_min;
382 Paste_data.delay_max = m_delay_max;
383
384 Paste_data_used = 1;
385
386 UpdateDialog();
387 }
388
389 void CDeathDialog::OnDeathPaste() {
390 m_flags = Paste_data.flags;
391 m_delay_min = Paste_data.delay_min;
392 m_delay_max = Paste_data.delay_max;
393
394 UpdateDialog();
395 }
396
397 #include "pserror.h"
398
399 void CDeathDialog::OnOK() {
400 if (m_delay_max < m_delay_min) {
401 EditorMessageBox("Max delay must be greater than or equal to min delay.");
402 return;
403 }
404
405 // Copy data into input struct
406 m_death_info_ptr->flags = m_flags;
407 m_death_info_ptr->delay_min = m_delay_min;
408 m_death_info_ptr->delay_max = m_delay_max;
409
410 CDialog::OnOK();
411 }
412
413 void CDeathDialog::OnDeathContactBlastRing() {
414 m_flags ^= DF_CONTACT_BLAST_RING;
415
416 UpdateDialog();
417 }
418
419 void CDeathDialog::OnDeathContactFireball() {
420 m_flags ^= DF_CONTACT_FIREBALL;
421
422 UpdateDialog();
423 }
424
425 void CDeathDialog::OnDeathDebrisContactBlastRing() {
426 m_flags ^= DF_DEBRIS_BLAST_RING;
427
428 UpdateDialog();
429 }
430
431 void CDeathDialog::OnDeathDebrisContactFireball() {
432 m_flags ^= DF_DEBRIS_FIREBALL;
433
434 UpdateDialog();
435 }
436
437 void CDeathDialog::OnDeathDebrisSmokes() {
438 m_flags ^= DF_DEBRIS_SMOKES;
439
440 UpdateDialog();
441 }
442
443 void CDeathDialog::OnDeathFireball() {
444 m_flags ^= DF_FIREBALL;
445
446 UpdateDialog();
447 }
448
449 void CDeathDialog::OnDeathLosesAntigrav() {
450 m_flags ^= DF_LOSES_ANTIGRAV;
451
452 UpdateDialog();
453 }
454
455 void CDeathDialog::OnDeathRemains() {
456 m_flags ^= DF_REMAINS;
457
458 UpdateDialog();
459 }
460
461 void CDeathDialog::OnDeathFadesAway() {
462 m_flags ^= DF_FADE_AWAY;
463
464 UpdateDialog();
465 }
466
467 void CDeathDialog::OnDeathDelaySound() {
468 m_flags ^= DF_DELAY_SOUND;
469
470 UpdateDialog();
471 }
472
473 void CDeathDialog::OnDeathDelayNoTumble() {
474 m_flags ^= DF_DELAY_NO_TUMBLE_FLY;
475
476 UpdateDialog();
477 }