Debian Codegraph @

editor/WorldWeaponsDialog.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 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/editor/WorldWeaponsDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:40 $
23 * $Author: kevinb $
24 *
25 * WorldWeaponsDialog.cpp : implementation file
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 86 10/24/99 9:34a Chris
30 *
31 * 85 10/21/99 1:33p Jeff
32 * fixed compile error
33 *
34 * 84 4/12/99 12:29p Jeff
35 * added recoil_force to weapon's page
36 *
37 * 83 4/05/99 4:39p Jason
38 * added groovy new smoke trails
39 *
40 * 82 2/22/99 3:55p Jason
41 * added generic damage boxes
42 *
43 * 81 2/22/99 2:03p Jason
44 * added different damages for players and generics
45 *
46 * 80 2/08/99 5:18p Jason
47 * took out EMD effect and added more weapon options
48 *
49 * 79 1/21/99 11:15p Jeff
50 * pulled out some structs and defines from header files and moved them
51 * into seperate header files so that multiplayer dlls don't require major
52 * game headers, just those new headers. Side effect is a shorter build
53 * time. Also cleaned up some header file #includes that weren't needed.
54 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
55 * manage.h and multi.h
56 *
57 * 78 11/06/98 12:35p Jason
58 * more speedups for manage system
59 *
60 * 77 10/15/98 6:46p Chris
61 * Added custom size for weapons
62 *
63 * 76 10/08/98 4:24p Kevin
64 * Changed code to comply with memory library usage. Always use mem_malloc
65 * , mem_free and mem_strdup
66 *
67 * 75 9/08/98 5:27p Jason
68 * added WF_NO_ROTATE flag to weapons
69 *
70 * 74 9/01/98 4:41p Matt
71 * Removed obsolete fields in the weapon structure
72 *
73 * 73 8/06/98 12:58p Chris
74 * Added new homing flags
75 *
76 * 72 8/03/98 1:09p Jason
77 * added some more weapons flags
78 *
79 * 71 7/31/98 11:52a Chris
80 * Weapons can be persistent. Added ability for objects to be manually
81 * set for no object collisions.
82 *
83 * 70 7/30/98 4:35p Jason
84 * added more weapon checkboxes
85 *
86 * 69 7/30/98 11:09a Jason
87 * added weapons that freeze and deform terrain
88 *
89 * 68 7/01/98 12:11p Jason
90 * added countermeasures
91 *
92 * 67 6/30/98 3:35p Jason
93 * adding countermeasures
94 *
95 * 66 6/23/98 2:43p Matt
96 * Changed calls to OutrageMessageBox() & Debug_MessageBox() to deal with
97 * int return value (instead of bool).
98 *
99 * 65 6/22/98 6:26p Jason
100 * added gravity field effect for weapons
101 *
102 * 64 6/19/98 12:04p Jason
103 *
104 * 63 6/15/98 4:00p Jason
105 * replaced monochromatic polymodel lighting with rgb lighting
106 *
107 * 62 5/25/98 8:36p Matt
108 * Added code to set different sizes for different weapon scorch marks.
109 * Also, don't leave scorch marks on lights.
110 *
111 * 61 5/25/98 6:39p Jason
112 * got icons working for weapons
113 *
114 * 60 5/22/98 12:34p Matt
115 * Added scorch mark/bullet hole system.
116 *
117 * 59 5/19/98 4:42a Chris
118 * Added shockwave's -- enjoy. :)
119 *
120 * 58 5/18/98 4:46p Mark
121 * Bail on a current weapon of -1
122 *
123 * 57 5/07/98 2:46p Chris
124 *
125 * 56 5/07/98 2:44p Chris
126 *
127 * 55 5/07/98 2:39p Chris
128 * Added death_dot and bounce sound for weapons
129 *
130 * 54 4/19/98 5:00p Jason
131 * added cool napalm effect, plus made object effects dynamically
132 * allocated
133 *
134 * 53 4/17/98 2:00p Jason
135 * added cool object effects
136 *
137 * 52 4/15/98 12:22p Jason
138 * lots of miscellaneous stuff pertaining to lighting and vis effects
139 *
140 * 51 4/10/98 12:39p Jason
141 * added expanding explosion bitmaps
142 *
143 * 50 4/09/98 4:49p Chris
144 * Allowed the copying and pasting of weapons
145 *
146 * 49 4/07/98 3:31p Jason
147 * got particle effects working with weapons
148 *
149 * 48 4/06/98 4:53p Jason
150 * got pageable polymodels working correctly with editor
151 *
152 * 47 4/02/98 3:54p Jason
153 * first pass in getting polymodel paging to work
154 *
155 * 46 3/13/98 5:55p Chris
156 * Added the new collision spheres
157 *
158 * 45 3/11/98 4:57p Chris
159 * Changed the ComputeDefualtSize function call
160 *
161 * 44 3/09/98 8:12a Chris
162 * Added the start of the homing code
163 *
164 * 43 2/26/98 2:48p Mark
165 * fixed changing of fire image handle stuff
166 *
167 * 42 2/25/98 3:48p Jason
168 * added ifl to list of discharge files
169 *
170 * 41 2/19/98 1:52p Jason
171 * added emergency override to unlock function
172 *
173 * 40 2/11/98 2:04p Jason
174 * got spawning weapons working
175 *
176 * 39 2/09/98 3:18p Matt
177 * Added checkbox to set Enable Camera property for a weapon
178 *
179 * 38 2/05/98 6:29p Jason
180 * added user settable explode time/size
181 *
182 * 37 2/05/98 4:28p Jason
183 * made models selectable on add weapon
184 *
185 * 36 2/05/98 12:37p Jason
186 * added more weapon effects
187 *
188 * 35 2/04/98 9:28p Jason
189 * added some new weapons effects
190 *
191 * 34 1/29/98 6:06p Jason
192 * added new weapons
193 *
194 * 33 1/28/98 5:37p Jason
195 * added streamer weapons
196 *
197 * 32 1/23/98 6:25p Jason
198 * Got spray weapons working
199 *
200 * 31 12/19/97 11:25a Samir
201 * g3_StartFrame and g3_EndFrame replaced by EditorStartFrame and
202 * EditorEndFrame
203 *
204 * 30 12/08/97 6:46p Jason
205 * reenabled editing of thrusttime
206 *
207 * 29 12/05/97 11:26a Jason
208 * fixed smoke pulldown bug
209 *
210 * 28 12/05/97 11:02a Mark
211 * If there was no current selection for the pulldown smoke menu, then
212 * don't do anything. -Samir
213 *
214 * 27 12/04/97 12:15p Jason
215 * gave designers the ability to set their own weapon-to-wall hit vclips
216 *
217 * 26 12/03/97 11:54a Jason
218 * added designer-settable smoketrails
219 *
220 * 25 12/02/97 5:31p Samir
221 * New file dialog interface implemented.
222 *
223 * 24 12/01/97 9:54a Chris
224 * Added support for concussive forces, generalized robot collisions to
225 * generic collisions
226 *
227 * 23 11/14/97 10:09p Jason
228 * added model sizing functionality
229 *
230 * 22 11/06/97 6:18p Jason
231 * added support for electrical weapons
232 *
233 * 21 11/05/97 11:09a Jason
234 * fixed stupid window naming bug I introduced
235 *
236 * 20 11/04/97 5:16p Jason
237 * disable blob size window if this is a model
238 *
239 * 19 11/04/97 2:46p Jason
240 * changes to weapon system
241 *
242 * 18 11/02/97 4:27p Matt
243 * Made physics dialog copy data back into original struct, instead of
244 * having the caller do it.
245 *
246 * 17 10/30/97 5:57p Matt
247 * Fixed bug that prevented clearing of smoke flag
248 *
249 * 16 10/30/97 5:00p Jason
250 * Made weapons use generic lighting code
251 *
252 * 15 10/30/97 2:53p Matt
253 * Revamped weapon dialog
254 *
255 * 14 10/29/97 1:27p Chris
256 * Added PF_STICK for weapons
257 *
258 * 13 10/22/97 4:19p Jason
259 * added smoke trail effects
260 *
261 * 12 10/20/97 4:46p Jason
262 * changes for explosions
263 *
264 * 11 10/15/97 5:20p Jason
265 * did a HUGE overhaul of the bitmap system
266 *
267 * 10 9/17/97 1:35p Matt
268 * Fixed some compiler warnings
269 *
270 * 9 9/17/97 10:59a Chris
271 * Added a new way to compute radi
272 *
273 * 8 9/09/97 6:55p Jason
274 * better error checking for model usage counts
275 *
276 * 7 9/03/97 3:53p Jason
277 * got objects to cast light
278 *
279 * 6 8/08/97 2:25p Matt
280 * Took out error messages which are now handled by mng_MakeLocker()
281 *
282 * 5 8/07/97 5:24p Chris
283 * Expanded the weapon system
284 *
285 * 4 8/06/97 4:33p Chris
286 * Expanded the weapons page
287 *
288 * 3 7/24/97 6:11p Matt
289 * Created symbolic constant for default zoom, and used it every place
290 * that specifies zoom
291 *
292 * $NoKeywords: $
293 */
294
295 #include "mfc_compatibility.h"
296 #include "editor.h"
297 #include "WorldWeaponsDialog.h"
298 #include "manage.h"
299 #include "vclip.h"
300 #include "bitmap.h"
301 #include "weaponpage.h"
302 #include "weapon.h"
303 #include "polymodel.h"
304 #include "soundpage.h"
305 #include "soundload.h"
306 #include "object.h"
307 #include "gametexture.h"
308 #include "PhysicsDlg.h"
309 #include "EditLineDialog.h"
310 #include "GenericLightDialog.h"
311 #include "ddio.h"
312 #include "mem.h"
313
314 #ifdef _DEBUG
315 #define new DEBUG_NEW
316 #undef THIS_FILE
317 static char THIS_FILE[] = __FILE__;
318 #endif
319
320 /////////////////////////////////////////////////////////////////////////////
321 // CWorldWeaponsDialog dialog
322
323 CWorldWeaponsDialog::CWorldWeaponsDialog(CWnd *pParent /*=NULL*/) : CDialog(CWorldWeaponsDialog::IDD, pParent) {
324 //{{AFX_DATA_INIT(CWorldWeaponsDialog)
325 // NOTE: the ClassWizard will add member initialization here
326 //}}AFX_DATA_INIT
327 }
328
329 void CWorldWeaponsDialog::DoDataExchange(CDataExchange *pDX) {
330 CDialog::DoDataExchange(pDX);
331 //{{AFX_DATA_MAP(CWorldWeaponsDialog)
332 // NOTE: the ClassWizard will add DDX and DDV calls here
333 //}}AFX_DATA_MAP
334 }
335
336 BEGIN_MESSAGE_MAP(CWorldWeaponsDialog, CDialog)
337 //{{AFX_MSG_MAP(CWorldWeaponsDialog)
338 ON_BN_CLICKED(IDC_ADD_WEAPON, OnAddWeapon)
339 ON_BN_CLICKED(IDC_DELETE_WEAPON, OnDeleteWeapon)
340 ON_BN_CLICKED(IDC_CHECKIN_WEAPON, OnCheckinWeapon)
341 ON_BN_CLICKED(IDC_LOCK_WEAPON, OnLockWeapon)
342 ON_BN_CLICKED(IDC_NEXT_WEAPON, OnNextWeapon)
343 ON_BN_CLICKED(IDC_PREV_WEAPON, OnPrevWeapon)
344 ON_BN_CLICKED(IDC_LOAD_WEAPON_ANIM, OnLoadWeaponAnim)
345 ON_CBN_SELENDOK(IDC_WEAPON_PULLDOWN, OnSelendokWeaponPulldown)
346 ON_BN_CLICKED(IDC_WEAPONS_OUT, OnWeaponsOut)
347 ON_WM_TIMER()
348 ON_BN_CLICKED(IDC_LOAD_WEAPON_DISCHARGE, OnLoadWeaponDischarge)
349 ON_CBN_SELENDOK(IDC_FIRE_SOUND_PULLDOWN, OnSelendokFireSoundPulldown)
350 ON_CBN_SELENDOK(IDC_WEAPON_WALL_SOUND_PULLDOWN, OnSelendokWeaponWallSoundPulldown)
351 ON_WM_HELPINFO()
352 ON_BN_CLICKED(IDC_WEAPON_HOMING_CHECK, OnWeaponHomingCheck)
353 ON_BN_CLICKED(IDC_WEAPON_COLLIDE_WITH_SIBLING_CHECK, OnWeaponCollideWithSiblingCheck)
354 ON_BN_CLICKED(IDC_WEAPON_USE_PARENT_VELOCITY_CHECK, OnWeaponUseParentVelocityCheck)
355 ON_EN_KILLFOCUS(IDC_WEAPON_THRUST_EDIT, OnKillfocusWeaponThrustTimeEdit)
356 ON_EN_KILLFOCUS(IDC_WEAPON_BLOB_SIZE_EDIT, OnKillfocusWeaponBlobSizeEdit)
357 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_SIZE_EDIT, OnKillfocusWeaponImpactSizeEdit)
358 ON_EN_KILLFOCUS(IDC_WEAPON_LIFE_TIME_EDIT, OnKillfocusWeaponLifeTimeEdit)
359 ON_EN_KILLFOCUS(IDC_WEAPON_DAMAGE_EDIT, OnKillfocusWeaponDamageEdit)
360 ON_BN_CLICKED(IDC_SMOKE_CHECK, OnSmokeCheck)
361 ON_BN_CLICKED(IDC_EDIT_PHYSICS, OnEditPhysics)
362 ON_BN_CLICKED(IDC_CHANGE_NAME, OnChangeName)
363 ON_BN_CLICKED(IDC_WEAPON_LIGHT_INFO, OnWeaponLightInfo)
364 ON_BN_CLICKED(IDC_ENERGY_RADIO, OnEnergyRadio)
365 ON_BN_CLICKED(IDC_MATTER_RADIO, OnMatterRadio)
366 ON_BN_CLICKED(IDC_ELECTRICAL_CHECK, OnElectricalCheck)
367 ON_BN_CLICKED(IDC_DEFAULT_SIZE, OnDefaultSize)
368 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_TIME_EDIT, OnKillfocusWeaponImpactTimeEdit)
369 ON_CBN_SELENDOK(IDC_SMOKE_PULLDOWN, OnSelendokSmokePulldown)
370 ON_CBN_SELENDOK(IDC_EXPLODE_PULLDOWN, OnSelendokExplodePulldown)
371 ON_BN_CLICKED(IDC_SPRAY_CHECK, OnSprayCheck)
372 ON_BN_CLICKED(IDC_INSTANT_CHECK, OnInstantCheck)
373 ON_BN_CLICKED(IDC_INVISIBLE, OnInvisible)
374 ON_BN_CLICKED(IDC_RING, OnRing)
375 ON_BN_CLICKED(IDC_EXPLODE_RING, OnExplodeRing)
376 ON_BN_CLICKED(IDC_PLANAR_BLAST, OnPlanarBlast)
377 ON_BN_CLICKED(IDC_SATURATE_CHECK, OnSaturateCheck)
378 ON_EN_KILLFOCUS(IDC_WEAPON_ALPHA_EDIT, OnKillfocusWeaponAlphaEdit)
379 ON_BN_CLICKED(IDC_PLANAR_CHECK, OnPlanarCheck)
380 ON_EN_KILLFOCUS(IDC_EXPLODE_SIZE_EDIT, OnKillfocusExplodeSizeEdit)
381 ON_EN_KILLFOCUS(IDC_EXPLODE_TIME_EDIT, OnKillfocusExplodeTimeEdit)
382 ON_CBN_SELENDOK(IDC_WEAPON_SPAWN_PULLDOWN, OnSelendokWeaponSpawnPulldown)
383 ON_EN_KILLFOCUS(IDC_WEAPON_SPAWN_EDIT, OnKillfocusWeaponSpawnEdit)
384 ON_BN_CLICKED(IDC_SPAWNS_ON_IMPACT, OnSpawnsOnImpact)
385 ON_BN_CLICKED(IDC_SPAWNS_ON_TIMEOUT, OnSpawnsOnTimeout)
386 ON_BN_CLICKED(IDC_OVERRIDE, OnOverride)
387 ON_EN_KILLFOCUS(IDC_PARTICLE_COUNT_EDIT, OnKillfocusParticleCountEdit)
388 ON_EN_KILLFOCUS(IDC_PARTICLE_LIFE_EDIT, OnKillfocusParticleLifeEdit)
389 ON_EN_KILLFOCUS(IDC_PARTICLE_SIZE_EDIT, OnKillfocusParticleSizeEdit)
390 ON_CBN_SELENDOK(IDC_PARTICLE_PULLDOWN, OnSelendokParticlePulldown)
391 ON_BN_CLICKED(IDC_WEAPON_COPY_BUTTON, OnWeaponCopyButton)
392 ON_BN_CLICKED(IDC_WEAPON_PASTE_BUTTON, OnWeaponPasteButton)
393 ON_BN_CLICKED(IDC_EXPANDING_CHECK, OnExpandingCheck)
394 ON_BN_CLICKED(IDC_MUZZLE_FLASH, OnMuzzleFlash)
395 ON_BN_CLICKED(IDC_MICROWAVE, OnMicrowave)
396 ON_BN_CLICKED(IDC_NAPALM, OnNapalm)
397 ON_CBN_SELENDOK(IDC_WEAPON_BOUNCE_SOUND_COMBO, OnSelendokWeaponBounceSoundCombo)
398 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_TIME_EDIT2, OnKillfocusWeaponImpactTimeEdit2)
399 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_DAMAGE_EDIT, OnKillfocusWeaponImpactDamageEdit)
400 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_FORCE_EDIT, OnKillfocusWeaponImpactForceEdit)
401 ON_CBN_SELENDOK(IDC_SCORCH_PULLDOWN, OnSelendokScorchPulldown)
402 ON_EN_KILLFOCUS(IDC_WEAPON_SCORCH_SIZE_EDIT, OnKillfocusWeaponScorchSizeEdit)
403 ON_CBN_SELENDOK(IDC_SMALLIMG_PULLDOWN, OnSelendokSmallimgPulldown)
404 ON_CBN_SELENDOK(IDC_SPAWN2_PULLDOWN, OnSelendokSpawn2Pulldown)
405 ON_EN_KILLFOCUS(IDC_ALTERNATE_CHANCE_EDIT, OnKillfocusAlternateChanceEdit)
406 ON_BN_CLICKED(IDC_REVERSE_SMOKE_CHECK, OnReverseSmokeCheck)
407 ON_BN_CLICKED(IDC_GRAVITY_FIELD_CHECK, OnGravityFieldCheck)
408 ON_EN_KILLFOCUS(IDC_GRAVITY_SIZE, OnKillfocusGravitySize)
409 ON_EN_KILLFOCUS(IDC_GRAVITY_TIME, OnKillfocusGravityTime)
410 ON_BN_CLICKED(IDC_COUNTERMEASURE_CHECK, OnCountermeasureCheck)
411 ON_BN_CLICKED(IDC_SPAWNS_ROBOT_CHECK, OnSpawnsRobotCheck)
412 ON_CBN_SELENDOK(IDC_SPAWN_ROBOT_PULLDOWN, OnSelendokSpawnRobotPulldown)
413 ON_EN_KILLFOCUS(IDC_TERRIAN_DAMAGE_SIZE, OnKillfocusTerrianDamageSize)
414 ON_EN_KILLFOCUS(IDC_TERRAIN_DAMAGE_DEPTH, OnKillfocusTerrainDamageDepth)
415 ON_BN_CLICKED(IDC_FREEZE_CHECK, OnFreezeCheck)
416 ON_BN_CLICKED(IDC_SILENT_HOMING_CHECK, OnSilentHomingCheck)
417 ON_BN_CLICKED(IDC_HOMED_SPLIT_CHECK, OnHomedSplitCheck)
418 ON_EN_KILLFOCUS(IDC_HOMING_FOV_TEXT, OnKillfocusHomingFovText)
419 ON_BN_CLICKED(IDC_NO_ROTATE_CHECK, OnNoRotateCheck)
420 ON_BN_CLICKED(IDC_CUSTOM_SIZE_CHECK, OnCustomSizeCheck)
421 ON_EN_KILLFOCUS(IDC_CUSTOM_SIZE_EDIT, OnKillfocusCustomSizeEdit)
422 ON_BN_CLICKED(IDC_TIMEOUT_WALL_CHECK, OnTimeoutWallCheck)
423 ON_BN_CLICKED(IDC_ENABLE_CAMERA, OnEnableCamera)
424 ON_EN_KILLFOCUS(IDC_WEAPON_GENERIC_DAMAGE_EDIT, OnKillfocusWeaponGenericDamageEdit)
425 ON_EN_KILLFOCUS(IDC_WEAPON_IMPACT_GENERIC_DAMAGE_EDIT, OnKillfocusWeaponImpactGenericDamageEdit)
426 ON_BN_CLICKED(IDC_PLANAR_SMOKE_CHECK, OnPlanarSmokeCheck)
427 ON_EN_KILLFOCUS(IDC_WEAPON_THRUST_TIME_EDIT, OnKillfocusWeaponThrustTimeEdit)
428 ON_EN_KILLFOCUS(IDC_WEAPON_RECOIL_FORCE_EDIT, OnKillfocusWeaponRecoilForceEdit)
429 //}}AFX_MSG_MAP
430 END_MESSAGE_MAP()
431
432 /////////////////////////////////////////////////////////////////////////////
433 // CWorldWeaponsDialog message handlers
434
435 void CWorldWeaponsDialog::OnAddWeapon() {
436 char filename[255], dir[255], fname[128], ext[32];
437 char cur_name[100];
438 int bm_handle, weapon_handle;
439 int c = 1, finding_name = 1;
440 int anim = 0, model = 0;
441
442 if (!Network_up) {
443 OutrageMessageBox("Sorry babe, the network is down. This action is a no-no.\n");
444 return;
445 }
446
447 MessageBox("First select what this weapons image will be on the cockpit (HUD)");
448
449 CString filter =
450 "Descent III files "
451 "(*.itl,*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ifl,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl;*.itl||";
452
453 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_weapon_dir, sizeof(Current_weapon_dir)))
454 return;
455
456 ddio_SplitPath(filename, dir, fname, ext);
457
458 // Okay, we selected a file. Lets do what needs to be done here.
459 bm_handle = LoadWeaponHudImage(filename, &anim);
460
461 if (bm_handle < 0) {
462 OutrageMessageBox("Couldn't open that bitmap/anim file.");
463 return;
464 }
465
466 weapon_handle = AllocWeapon();
467
468 while (finding_name) {
469 sprintf(cur_name, "%s%d", fname, c);
470 if (FindWeaponName(cur_name) != -1)
471 c++;
472 else
473 finding_name = 0;
474 }
475
476 strcpy(Weapons[weapon_handle].name, cur_name);
477
478 if (anim)
479 Weapons[weapon_handle].flags |= WF_HUD_ANIMATED;
480 else
481 Weapons[weapon_handle].flags &= ~WF_HUD_ANIMATED;
482
483 Weapons[weapon_handle].hud_image_handle = bm_handle;
484
485 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
486
487 if (!anim) {
488 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
489 GameBitmaps[Weapons[weapon_handle].hud_image_handle].name);
490 bm_SaveFileBitmap(filename, Weapons[weapon_handle].hud_image_handle);
491 } else {
492 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
493 GameVClips[Weapons[weapon_handle].hud_image_handle].name);
494 SaveVClip(filename, Weapons[weapon_handle].hud_image_handle);
495 }
496
497 // Now do the firing image
498
499 MessageBox("Now select what this weapons discharge image/model will be when it is fired!");
500
501 CString ffilter =
502 "Descent III files "
503 "(*.ifl,*.tga,*.bbm,*.lbm,*.ogf,*.pcx,*.pof,*.oof)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.pof;*.oof;*.oaf;*.ifl;*.itl||";
504
505 if (!OpenFileDialog(this, (LPCSTR)ffilter, filename, Current_weapon_dir, sizeof(Current_weapon_dir)))
506 return;
507
508 // Okay, we selected a file. Lets do what needs to be done here.
509 anim = 0;
510 bm_handle = LoadWeaponFireImage(filename, &model, &anim, 0);
511
512 if (bm_handle < 0) {
513 OutrageMessageBox("Couldn't open that bitmap/model file.");
514 return;
515 }
516
517 // figure out size of the weapon
518 if (model) {
519 ComputeDefaultSize(OBJ_WEAPON, bm_handle, &Weapons[weapon_handle].size);
520 } else {
521 Weapons[weapon_handle].size = DEFAULT_WEAPON_SIZE;
522 }
523
524 if (!model) {
525 if (anim)
526 Weapons[weapon_handle].flags |= WF_IMAGE_VCLIP;
527 else
528 Weapons[weapon_handle].flags |= WF_IMAGE_BITMAP;
529 } else {
530 Weapons[weapon_handle].flags &= ~WF_IMAGE_BITMAP;
531 Weapons[weapon_handle].flags &= ~WF_ELECTRICAL;
532 Weapons[weapon_handle].flags &= ~WF_IMAGE_VCLIP;
533 }
534
535 Weapons[weapon_handle].fire_image_handle = bm_handle;
536
537 mprintf(0, "Making a copy of this bitmap/model locally...\n");
538
539 if (!model) {
540 if (!anim) {
541 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
542 GameBitmaps[Weapons[weapon_handle].fire_image_handle].name);
543 bm_SaveFileBitmap(filename, Weapons[weapon_handle].fire_image_handle);
544 } else {
545 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
546 GameVClips[Weapons[weapon_handle].fire_image_handle].name);
547 SaveVClip(filename, Weapons[weapon_handle].fire_image_handle);
548 }
549 } else {
550 std::filesystem::path destname = LocalModelsDir / Poly_models[Weapons[weapon_handle].fire_image_handle].name;
551 cf_CopyFile(destname, filename);
552 }
553
554 mng_AllocTrackLock(cur_name, PAGETYPE_WEAPON);
555
556 D3EditState.current_weapon = weapon_handle;
557
558 UpdateDialog();
559 }
560
561 void CWorldWeaponsDialog::OnDeleteWeapon() {
562 int answer, tl;
563 mngs_Pagelock pl;
564 int n = D3EditState.current_weapon;
565
566 if (Num_weapons < 1)
567 return;
568
569 // Check to see if we even have it locked
570 if ((tl = mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON)) == -1) {
571 OutrageMessageBox("This weapon is not yours to delete. Lock first.");
572 return;
573 }
574
575 // Make sure its to be deleted
576 answer = MessageBox("Are you sure you want to delete this weapon?", Weapons[n].name, MB_YESNO);
577 if (answer == IDNO)
578 return;
579
580 if (!mng_MakeLocker())
581 return;
582
583 strcpy(pl.name, Weapons[n].name);
584 pl.pagetype = PAGETYPE_WEAPON;
585
586 // Check to see if this is a local weapon only. If so, only delete it locally
587 if (mng_CheckIfPageOwned(&pl, TableUser) != 1) {
588 mng_FreeTrackLock(tl);
589 if (!mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 1)) {
590 mprintf(0, ErrorString);
591 Int3();
592 }
593 } else // if its network, delete it from both the net and local drives
594 {
595
596 mng_FreeTrackLock(tl);
597 mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 1);
598 mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 0);
599 mng_DeletePagelock(Weapons[n].name, PAGETYPE_WEAPON);
600 }
601
602 // Advance to the next weapon
603 D3EditState.current_weapon = GetNextWeapon(n);
604
605 // Free weapon images
606 if (Weapons[n].flags & WF_HUD_ANIMATED)
607 FreeVClip(Weapons[n].hud_image_handle);
608 else
609 bm_FreeBitmap(Weapons[n].hud_image_handle);
610
611 if (Weapons[n].fire_image_handle != -1) {
612 if (Weapons[n].flags & WF_IMAGE_BITMAP)
613 bm_FreeBitmap(Weapons[n].fire_image_handle);
614 else if (Weapons[n].flags & WF_IMAGE_VCLIP)
615 FreeVClip(Weapons[n].fire_image_handle);
616 else
617 FreePolyModel(Weapons[n].fire_image_handle);
618 }
619
620 FreeWeapon(n);
621 mng_EraseLocker();
622
623 OutrageMessageBox("Weapon deleted.");
624
625 RemapWeapons();
626
627 UpdateDialog();
628 }
629
630 void CWorldWeaponsDialog::OnCheckinWeapon() {
631 int n = D3EditState.current_weapon;
632 mngs_Pagelock temp_pl;
633 int r;
634
635 if (Num_weapons < 1)
636 return;
637
638 if (!mng_MakeLocker())
639 return;
640
641 // Make sure we own this weapon
642 strcpy(temp_pl.name, Weapons[n].name);
643 temp_pl.pagetype = PAGETYPE_WEAPON;
644
645 r = mng_CheckIfPageOwned(&temp_pl, TableUser);
646 if (r < 0)
647 OutrageMessageBox(ErrorString);
648 else if (r == 0)
649 OutrageMessageBox(InfoString);
650 else {
651 // Change the pagelock state to UNLOCKED
652 strcpy(temp_pl.holder, "UNLOCKED");
653 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
654 MessageBox(ErrorString, "Error!");
655 mng_EraseLocker();
656 return;
657 } else {
658 // Now actually replace the copy on the net with our local one
659
660 if (!mng_ReplacePage(Weapons[n].name, Weapons[n].name, n, PAGETYPE_WEAPON, 0))
661 OutrageMessageBox(ErrorString);
662 else {
663 // Save this weapon anim/image to the network for all
664 std::filesystem::path srcname, destname;
665 if (Weapons[n].flags & WF_HUD_ANIMATED) {
666 srcname = LocalManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name;
667 destname = ManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name;
668 } else {
669 srcname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name;
670 destname = ManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name;
671 }
672
673 cf_CopyFile(destname, srcname);
674
675 if (Weapons[n].flags & WF_IMAGE_BITMAP) {
676 srcname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].fire_image_handle].name;
677 destname = ManageGraphicsDir, GameBitmaps[Weapons[n].fire_image_handle].name;
678
679 } else if (Weapons[n].flags & WF_IMAGE_VCLIP) {
680 srcname = LocalManageGraphicsDir / GameVClips[Weapons[n].fire_image_handle].name;
681 destname = ManageGraphicsDir / GameVClips[Weapons[n].fire_image_handle].name;
682 } else {
683 srcname = LocalModelsDir / Poly_models[Weapons[n].fire_image_handle].name;
684 destname = NetModelsDir / Poly_models[Weapons[n].fire_image_handle].name;
685 }
686
687 cf_CopyFile(destname, srcname);
688
689 OutrageMessageBox("Weapon checked in.");
690
691 // Delete it from local pagefile if its there
692 int dret = mng_DeletePage(Weapons[n].name, PAGETYPE_WEAPON, 1);
693 ASSERT(dret == 1);
694 mng_EraseLocker();
695
696 // Free the tracklock
697 int p = mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON);
698 ASSERT(p != -1);
699 mng_FreeTrackLock(p);
700 UpdateDialog();
701 }
702 }
703 }
704 }
705
706 void CWorldWeaponsDialog::OnLockWeapon() {
707 int n = D3EditState.current_weapon;
708 mngs_Pagelock temp_pl;
709 mngs_weapon_page weaponpage;
710 int r;
711
712 if (Num_weapons < 1)
713 return;
714
715 if (!mng_MakeLocker())
716 return;
717
718 // Make sure it can be locked
719 strcpy(temp_pl.name, Weapons[n].name);
720 temp_pl.pagetype = PAGETYPE_WEAPON;
721
722 r = mng_CheckIfPageLocked(&temp_pl);
723 if (r == 2) {
724 int answer;
725 answer = OutrageMessageBox(MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. "
726 "Override to 'Unlocked'? (Select NO if you don't know what you're doing)");
727 if (answer == IDYES) {
728 strcpy(temp_pl.holder, "UNLOCKED");
729 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl))
730 MessageBox(ErrorString, "Error!");
731 }
732 }
733
734 else if (r < 0)
735 OutrageMessageBox(ErrorString);
736 else if (r == 1)
737 OutrageMessageBox(InfoString);
738 else {
739
740 // Everything is ok. Tell the network we're locking it and get a copy to
741 // our local drive
742
743 strcpy(temp_pl.holder, TableUser);
744 if (!mng_ReplacePagelock(temp_pl.name, &temp_pl)) {
745 MessageBox(ErrorString, "Error!");
746 mng_EraseLocker();
747 return;
748 } else {
749 // Search thru the net pagefile and get a new copy in RAM in case anyone
750 // changed it since we started the editor
751 if (mng_FindSpecificWeaponPage(temp_pl.name, &weaponpage, 0)) {
752 if (mng_AssignWeaponPageToWeapon(&weaponpage, n)) {
753 if (!mng_ReplacePage(Weapons[n].name, Weapons[n].name, n, PAGETYPE_WEAPON, 1)) {
754 OutrageMessageBox("There was problem writing that page locally!");
755 mng_EraseLocker();
756 return;
757 }
758
759 OutrageMessageBox("Weapon locked.");
760 } else
761 OutrageMessageBox(
762 "There was a problem loading this weapon. You might encounter problems in dealing with it. Good luck!");
763
764 mng_AllocTrackLock(Weapons[n].name, PAGETYPE_WEAPON);
765 UpdateDialog();
766 } else
767 OutrageMessageBox("Couldn't find that weapon in the table file!");
768 }
769 }
770 mng_EraseLocker();
771 }
772
773 void CWorldWeaponsDialog::OnNextWeapon() {
774 D3EditState.current_weapon = GetNextWeapon(D3EditState.current_weapon);
775 UpdateDialog();
776 }
777
778 void CWorldWeaponsDialog::OnPrevWeapon() {
779 D3EditState.current_weapon = GetPrevWeapon(D3EditState.current_weapon);
780 UpdateDialog();
781 }
782
783 void CWorldWeaponsDialog::OnLoadWeaponAnim() {
784 char filename[255];
785 int bm_handle;
786 int anim = 0;
787
788 CString filter =
789 "Descent III files (*.tga,*.bbm,*.lbm,*.ogf,*.oaf,*.ilf,*.pcx)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.oaf;*.ifl||";
790
791 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_weapon_dir, sizeof(Current_weapon_dir)))
792 return;
793
794 // Okay, we selected a file. Lets do what needs to be done here.
795 bm_handle = LoadWeaponHudImage(filename, &anim);
796
797 if (bm_handle < 0) {
798 OutrageMessageBox("Could not load that bitmap...restoring previous bitmap.");
799 return;
800 }
801 int n = D3EditState.current_weapon;
802
803 Weapons[n].hud_image_handle = bm_handle;
804
805 if (anim)
806 Weapons[n].flags |= WF_HUD_ANIMATED;
807 else
808 Weapons[n].flags &= ~WF_HUD_ANIMATED;
809
810 mprintf(0, "Making a copy of this bitmap/anim locally...\n");
811
812 std::filesystem::path curname;
813 if (anim) {
814 curname = LocalManageGraphicsDir / GameVClips[Weapons[n].hud_image_handle].name;
815 SaveVClip(curname, Weapons[n].hud_image_handle);
816
817 } else {
818 curname = LocalManageGraphicsDir / GameBitmaps[Weapons[n].hud_image_handle].name;
819 bm_SaveFileBitmap(curname, Weapons[n].hud_image_handle);
820 }
821
822 UpdateDialog();
823 }
824
825 void CWorldWeaponsDialog::OnSelendokWeaponPulldown() {
826 int i, cur;
827 char name[200];
828
829 cur = SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_GETCURSEL, 0, 0);
830 SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
831
832 i = FindWeaponName(name);
833
834 if (i == -1) {
835 mprintf(0, "Possible corrupted weapon list, but probably nothing.");
836 UpdateDialog();
837 return;
838 }
839
840 D3EditState.current_weapon = i;
841 UpdateDialog();
842 }
843
844 void CWorldWeaponsDialog::OnWeaponsOut() {
845 char str[10000];
846 int total = 0;
847
848 mng_DisplayLockList(TableUser);
849
850 sprintf(str, "User %s has these weapons held locally:\n\n", TableUser);
851 for (int i = 0; i < MAX_TRACKLOCKS; i++) {
852 if (GlobalTrackLocks[i].used && GlobalTrackLocks[i].pagetype == PAGETYPE_WEAPON) {
853 char temp[90];
854
855 sprintf(temp, "%s", GlobalTrackLocks[i].name);
856 strcat(str, temp);
857 strcat(str, "\n");
858 total++;
859 }
860 }
861
862 if (total != 0) {
863 // Display that string
864 MessageBox(str, "Weapons", MB_OK);
865 }
866 }
867
868 // When closing, save all our checked out weapons locally so we know
869 // what stuff to flag as "checked out" the next time we start up
870 void CWorldWeaponsDialog::SaveWeaponsOnClose() {
871 int i, t;
872
873 if (!Network_up)
874 return; // don't save a damn thing if the network is down
875
876 for (i = 0; i < MAX_TRACKLOCKS; i++) {
877 if (GlobalTrackLocks[i].used == 1 && GlobalTrackLocks[i].pagetype == PAGETYPE_WEAPON) {
878 t = FindWeaponName(GlobalTrackLocks[i].name);
879 ASSERT(t != -1);
880 mng_ReplacePage(Weapons[t].name, Weapons[t].name, t, PAGETYPE_WEAPON, 1);
881 }
882 }
883 }
884
885 #define NULL_NAME "<none>"
886
887 void CWorldWeaponsDialog::UpdateDialog() {
888 CEdit *ebox;
889 CButton *bbox;
890 int n = D3EditState.current_weapon;
891 char str[50];
892
893 if (Num_weapons < 1) {
894 bbox = (CButton *)GetDlgItem(IDC_NEXT_WEAPON);
895 bbox->EnableWindow(FALSE);
896 bbox = (CButton *)GetDlgItem(IDC_PREV_WEAPON);
897 bbox->EnableWindow(FALSE);
898
899 return;
900 } else {
901 bbox = (CButton *)GetDlgItem(IDC_NEXT_WEAPON);
902 bbox->EnableWindow(TRUE);
903 bbox = (CButton *)GetDlgItem(IDC_PREV_WEAPON);
904 bbox->EnableWindow(TRUE);
905 }
906
907 if (!Weapons[n].used)
908 n = D3EditState.current_weapon = GetNextWeapon(n);
909
910 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_VCLIP_EDIT);
911 if (Weapons[n].flags & WF_HUD_ANIMATED)
912 ebox->SetWindowText(GameVClips[Weapons[n].hud_image_handle].name);
913 else
914 ebox->SetWindowText(GameBitmaps[Weapons[n].hud_image_handle].name);
915
916 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_DISCHARGE_EDIT);
917
918 if (Weapons[n].flags & WF_IMAGE_BITMAP)
919 ebox->SetWindowText(GameBitmaps[Weapons[n].fire_image_handle].name);
920 else if (Weapons[n].flags & WF_IMAGE_VCLIP)
921 ebox->SetWindowText(GameVClips[Weapons[n].fire_image_handle].name);
922 else
923 ebox->SetWindowText(Poly_models[Weapons[n].fire_image_handle].name);
924
925 bbox = (CButton *)GetDlgItem(IDC_CHECKIN_WEAPON);
926 if (mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON) == -1) {
927 bbox->EnableWindow(FALSE);
928 bbox = (CButton *)GetDlgItem(IDC_LOCK_WEAPON);
929 bbox->EnableWindow(TRUE);
930 } else {
931 bbox->EnableWindow(TRUE);
932 bbox = (CButton *)GetDlgItem(IDC_LOCK_WEAPON);
933 bbox->EnableWindow(FALSE);
934 }
935
936 SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_RESETCONTENT, 0, 0);
937
938 for (int i = 0; i < MAX_WEAPONS; i++) {
939 if (Weapons[i].used)
940 SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Weapons[i].name);
941 }
942 SendDlgItemMessage(IDC_WEAPON_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)Weapons[n].name);
943
944 SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_RESETCONTENT, 0, 0);
945 for (int i = 0; i < MAX_SOUNDS; i++) {
946 if (Sounds[i].used)
947 SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name);
948 }
949 if (Weapons[n].sounds[WSI_FIRE] >= 0 && Weapons[n].sounds[WSI_FIRE] < MAX_SOUNDS &&
950 Sounds[Weapons[n].sounds[WSI_FIRE]].used != 0)
951 SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_SELECTSTRING, 0,
952 (LPARAM)(LPCTSTR)Sounds[Weapons[n].sounds[WSI_FIRE]].name);
953 else
954 SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
955
956 SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_RESETCONTENT, 0, 0);
957 for (int i = 0; i < MAX_SOUNDS; i++) {
958 if (Sounds[i].used)
959 SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name);
960 }
961 if (Weapons[n].sounds[WSI_BOUNCE] >= 0 && Weapons[n].sounds[WSI_BOUNCE] < MAX_SOUNDS &&
962 Sounds[Weapons[n].sounds[WSI_BOUNCE]].used != 0)
963 SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_SELECTSTRING, 0,
964 (LPARAM)(LPCTSTR)Sounds[Weapons[n].sounds[WSI_BOUNCE]].name);
965 else
966 SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
967
968 SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_RESETCONTENT, 0, 0);
969 for (int i = 0; i < MAX_SOUNDS; i++) {
970 if (Sounds[i].used)
971 SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Sounds[i].name);
972 }
973 if (Weapons[n].sounds[WSI_IMPACT_WALL] >= 0 && Weapons[n].sounds[WSI_IMPACT_WALL] < MAX_SOUNDS &&
974 Sounds[Weapons[n].sounds[WSI_IMPACT_WALL]].used != 0)
975 SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_SELECTSTRING, 0,
976 (LPARAM)(LPCTSTR)Sounds[Weapons[n].sounds[WSI_IMPACT_WALL]].name);
977 else
978 SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
979
980 SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_RESETCONTENT, 0, 0);
981
982 if (Weapons[n].flags & WF_SMOKE) {
983 for (int i = 0; i < MAX_TEXTURES; i++) {
984 if (GameTextures[i].used)
985 SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
986 }
987 }
988
989 if ((Weapons[n].flags & WF_SMOKE) && Weapons[n].smoke_handle >= 0 && GameTextures[Weapons[n].smoke_handle].used)
990 SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_SELECTSTRING, 0,
991 (LPARAM)(LPCTSTR)GameTextures[Weapons[n].smoke_handle].name);
992 else
993 SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
994
995 // Do scorch pulldown
996 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_RESETCONTENT, 0, 0);
997 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME);
998 for (int i = 0; i < MAX_TEXTURES; i++) {
999 if (GameTextures[i].used)
1000 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
1001 }
1002
1003 if ((Weapons[n].scorch_handle >= 0) && GameTextures[Weapons[n].scorch_handle].used)
1004 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_SELECTSTRING, 0,
1005 (LPARAM)(LPCTSTR)GameTextures[Weapons[n].scorch_handle].name);
1006 else
1007 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME);
1008
1009 // Do icon pulldown
1010 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_RESETCONTENT, 0, 0);
1011 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME);
1012 for (int i = 0; i < MAX_TEXTURES; i++) {
1013 if (GameTextures[i].used)
1014 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
1015 }
1016
1017 if ((Weapons[n].icon_handle >= 0) && GameTextures[Weapons[n].icon_handle].used)
1018 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_SELECTSTRING, 0,
1019 (LPARAM)(LPCTSTR)GameTextures[Weapons[n].icon_handle].name);
1020 else
1021 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR)NULL_NAME);
1022
1023 SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_RESETCONTENT, 0, 0);
1024 for (int i = 0; i < MAX_TEXTURES; i++) {
1025 if (GameTextures[i].used)
1026 SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
1027 }
1028
1029 if (Weapons[n].explode_image_handle >= 0 && GameTextures[Weapons[n].explode_image_handle].used)
1030 SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_SELECTSTRING, 0,
1031 (LPARAM)(LPCTSTR)GameTextures[Weapons[n].explode_image_handle].name);
1032 else {
1033 SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
1034 Weapons[n].explode_image_handle = -1;
1035 }
1036
1037 // Do particle handle
1038 SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_RESETCONTENT, 0, 0);
1039 for (int i = 0; i < MAX_TEXTURES; i++) {
1040 if (GameTextures[i].used)
1041 SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)GameTextures[i].name);
1042 }
1043
1044 if (Weapons[n].particle_handle >= 0 && GameTextures[Weapons[n].particle_handle].used)
1045 SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_SELECTSTRING, 0,
1046 (LPARAM)(LPCTSTR)GameTextures[Weapons[n].particle_handle].name);
1047 else {
1048 SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
1049 Weapons[n].particle_handle = -1;
1050 }
1051
1052 // Do spawn handles
1053 SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_RESETCONTENT, 0, 0);
1054 SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_RESETCONTENT, 0, 0);
1055 for (int i = 0; i < MAX_WEAPONS; i++) {
1056 if (Weapons[i].used) {
1057 SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Weapons[i].name);
1058 SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Weapons[i].name);
1059 }
1060 }
1061
1062 if (Weapons[n].spawn_handle >= 0 && Weapons[Weapons[n].spawn_handle].used)
1063 SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_SELECTSTRING, 0,
1064 (LPARAM)(LPCTSTR)Weapons[Weapons[n].spawn_handle].name);
1065 else {
1066 SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
1067 Weapons[n].spawn_handle = -1;
1068 }
1069
1070 if (Weapons[n].alternate_spawn_handle >= 0 && Weapons[Weapons[n].alternate_spawn_handle].used)
1071 SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_SELECTSTRING, 0,
1072 (LPARAM)(LPCTSTR)Weapons[Weapons[n].alternate_spawn_handle].name);
1073 else {
1074 SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
1075 Weapons[n].alternate_spawn_handle = -1;
1076 }
1077
1078 // Do spawn robot stuff
1079 SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_RESETCONTENT, 0, 0);
1080 for (int i = 0; i < MAX_OBJECT_IDS; i++) {
1081 if (Object_info[i].type == OBJ_ROBOT)
1082 SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)Object_info[i].name);
1083 }
1084
1085 if (Weapons[n].robot_spawn_handle >= 0 && Object_info[Weapons[n].robot_spawn_handle].type == OBJ_ROBOT)
1086 SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_SELECTSTRING, 0,
1087 (LPARAM)(LPCTSTR)Object_info[Weapons[n].robot_spawn_handle].name);
1088 else {
1089 SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_SELECTSTRING, 0, (LPARAM)(LPCTSTR) "\0");
1090 Weapons[n].robot_spawn_handle = -1;
1091 }
1092
1093 CheckDlgButton(IDC_WEAPON_HOMING_CHECK, Weapons[n].phys_info.flags & PF_HOMING ? 1 : 0);
1094
1095 CheckDlgButton(IDC_WEAPON_COLLIDE_WITH_SIBLING_CHECK, Weapons[n].phys_info.flags & PF_HITS_SIBLINGS ? 1 : 0);
1096 CheckDlgButton(IDC_WEAPON_USE_PARENT_VELOCITY_CHECK, Weapons[n].phys_info.flags & PF_USES_PARENT_VELOCITY ? 1 : 0);
1097 CheckDlgButton(IDC_SMOKE_CHECK, Weapons[n].flags & WF_SMOKE ? 1 : 0);
1098 CheckDlgButton(IDC_PLANAR_SMOKE_CHECK, Weapons[n].flags & WF_PLANAR_SMOKE ? 1 : 0);
1099
1100 CheckDlgButton(IDC_NO_ROTATE_CHECK, Weapons[n].flags & WF_NO_ROTATE ? 1 : 0);
1101 CheckDlgButton(IDC_CUSTOM_SIZE_CHECK, Weapons[n].flags & WF_CUSTOM_SIZE ? 1 : 0);
1102 CheckDlgButton(IDC_HOMED_SPLIT_CHECK, Weapons[n].flags & WF_HOMING_SPLIT ? 1 : 0);
1103 CheckDlgButton(IDC_SILENT_HOMING_CHECK, Weapons[n].flags & WF_SILENT_HOMING ? 1 : 0);
1104 CheckDlgButton(IDC_TIMEOUT_WALL_CHECK, Weapons[n].flags & WF_TIMEOUT_WALL ? 1 : 0);
1105 CheckDlgButton(IDC_FREEZE_CHECK, Weapons[n].flags & WF_FREEZE ? 1 : 0);
1106 CheckDlgButton(IDC_COUNTERMEASURE_CHECK, Weapons[n].flags & WF_COUNTERMEASURE ? 1 : 0);
1107 CheckDlgButton(IDC_SPAWNS_ROBOT_CHECK, Weapons[n].flags & WF_SPAWNS_ROBOT ? 1 : 0);
1108 CheckDlgButton(IDC_GRAVITY_FIELD_CHECK, Weapons[n].flags & WF_GRAVITY_FIELD ? 1 : 0);
1109 CheckDlgButton(IDC_MATTER_RADIO, Weapons[n].flags & WF_MATTER_WEAPON ? 1 : 0);
1110 CheckDlgButton(IDC_ENERGY_RADIO, (Weapons[n].flags & WF_MATTER_WEAPON) == 0 ? 1 : 0);
1111 CheckDlgButton(IDC_ELECTRICAL_CHECK, (Weapons[n].flags & WF_ELECTRICAL) ? 1 : 0);
1112 CheckDlgButton(IDC_SPRAY_CHECK, (Weapons[n].flags & WF_SPRAY) ? 1 : 0);
1113 CheckDlgButton(IDC_INSTANT_CHECK, (Weapons[n].flags & WF_STREAMER) ? 1 : 0);
1114 CheckDlgButton(IDC_MUZZLE_FLASH, (Weapons[n].flags & WF_MUZZLE) ? 1 : 0);
1115 CheckDlgButton(IDC_MICROWAVE, (Weapons[n].flags & WF_MICROWAVE) ? 1 : 0);
1116 CheckDlgButton(IDC_NAPALM, (Weapons[n].flags & WF_NAPALM) ? 1 : 0);
1117 CheckDlgButton(IDC_INVISIBLE, (Weapons[n].flags & WF_INVISIBLE) ? 1 : 0);
1118 CheckDlgButton(IDC_RING, (Weapons[n].flags & WF_RING) ? 1 : 0);
1119 CheckDlgButton(IDC_EXPLODE_RING, (Weapons[n].flags & WF_BLAST_RING) ? 1 : 0);
1120 CheckDlgButton(IDC_SATURATE_CHECK, (Weapons[n].flags & WF_SATURATE) ? 1 : 0);
1121 CheckDlgButton(IDC_PLANAR_CHECK, (Weapons[n].flags & WF_PLANAR) ? 1 : 0);
1122 CheckDlgButton(IDC_EXPANDING_CHECK, (Weapons[n].flags & WF_EXPAND) ? 1 : 0);
1123 CheckDlgButton(IDC_PLANAR_BLAST, (Weapons[n].flags & WF_PLANAR_BLAST) ? 1 : 0);
1124 CheckDlgButton(IDC_ENABLE_CAMERA, (Weapons[n].flags & WF_ENABLE_CAMERA) ? 1 : 0);
1125 CheckDlgButton(IDC_SPAWNS_ON_IMPACT, (Weapons[n].flags & WF_SPAWNS_IMPACT) ? 1 : 0);
1126 CheckDlgButton(IDC_SPAWNS_ON_TIMEOUT, (Weapons[n].flags & WF_SPAWNS_TIMEOUT) ? 1 : 0);
1127 CheckDlgButton(IDC_REVERSE_SMOKE_CHECK, (Weapons[n].flags & WF_REVERSE_SMOKE) ? 1 : 0);
1128
1129 ebox = (CEdit *)GetDlgItem(IDC_GRAVITY_SIZE);
1130 sprintf(str, "%f", Weapons[n].gravity_size);
1131 ebox->SetWindowText(str);
1132
1133 ebox = (CEdit *)GetDlgItem(IDC_GRAVITY_TIME);
1134 sprintf(str, "%f", Weapons[n].gravity_time);
1135 ebox->SetWindowText(str);
1136
1137 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_DAMAGE_EDIT);
1138 sprintf(str, "%f", Weapons[n].player_damage);
1139 ebox->SetWindowText(str);
1140
1141 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_GENERIC_DAMAGE_EDIT);
1142 sprintf(str, "%f", Weapons[n].generic_damage);
1143 ebox->SetWindowText(str);
1144
1145 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_BLOB_SIZE_EDIT);
1146 sprintf(str, "%f", Weapons[n].size);
1147 ebox->SetWindowText(str);
1148
1149 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_SCORCH_SIZE_EDIT);
1150 sprintf(str, "%f", Weapons[n].scorch_size);
1151 ebox->SetWindowText(str);
1152
1153 ebox = (CEdit *)GetDlgItem(IDC_ALTERNATE_CHANCE_EDIT);
1154 sprintf(str, "%d", Weapons[n].alternate_chance);
1155 ebox->SetWindowText(str);
1156
1157 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_ALPHA_EDIT);
1158 sprintf(str, "%f", Weapons[n].alpha);
1159 ebox->SetWindowText(str);
1160
1161 ebox = (CEdit *)GetDlgItem(IDC_EXPLODE_TIME_EDIT);
1162 sprintf(str, "%f", Weapons[n].explode_time);
1163 ebox->SetWindowText(str);
1164
1165 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_SPAWN_EDIT);
1166 sprintf(str, "%d", Weapons[n].spawn_count);
1167 ebox->SetWindowText(str);
1168
1169 ebox = (CEdit *)GetDlgItem(IDC_EXPLODE_SIZE_EDIT);
1170 sprintf(str, "%f", Weapons[n].explode_size);
1171 ebox->SetWindowText(str);
1172
1173 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_SIZE_EDIT);
1174 sprintf(str, "%f", Weapons[n].particle_size);
1175 ebox->SetWindowText(str);
1176
1177 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_LIFE_EDIT);
1178 sprintf(str, "%f", Weapons[n].particle_life);
1179 ebox->SetWindowText(str);
1180
1181 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_COUNT_EDIT);
1182 sprintf(str, "%d", Weapons[n].particle_count);
1183 ebox->SetWindowText(str);
1184
1185 ebox = (CEdit *)GetDlgItem(IDC_DEFAULT_SIZE);
1186 if ((Weapons[n].flags & WF_IMAGE_BITMAP) || (Weapons[n].flags & WF_IMAGE_VCLIP)) {
1187 ebox->EnableWindow(FALSE);
1188 ebox = (CEdit *)GetDlgItem(IDC_SIZE_MESSAGE);
1189 ebox->SetWindowText(" ");
1190 } else {
1191 ebox->EnableWindow(TRUE);
1192 ebox = (CEdit *)GetDlgItem(IDC_SIZE_MESSAGE);
1193
1194 PageInPolymodel(Weapons[n].fire_image_handle);
1195
1196 if (Poly_models[Weapons[n].fire_image_handle].new_style &&
1197 (Poly_models[Weapons[n].fire_image_handle].flags & PMF_TIMED)) {
1198 float temp_size;
1199
1200 if (Weapons[n].size != ComputeDefaultSize(OBJ_WEAPON, Weapons[n].fire_image_handle, &temp_size))
1201 ebox->SetWindowText("Using custom size");
1202 else
1203 ebox->SetWindowText("Using model size");
1204 } else
1205 ebox->SetWindowText("Not timed .oof");
1206 }
1207
1208 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_SIZE_EDIT);
1209 sprintf(str, "%f", Weapons[n].impact_size);
1210 ebox->SetWindowText(str);
1211
1212 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_TIME_EDIT2);
1213 sprintf(str, "%f", Weapons[n].impact_time);
1214 ebox->SetWindowText(str);
1215
1216 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_DAMAGE_EDIT);
1217 sprintf(str, "%f", Weapons[n].impact_player_damage);
1218 ebox->SetWindowText(str);
1219
1220 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_GENERIC_DAMAGE_EDIT);
1221 sprintf(str, "%f", Weapons[n].impact_generic_damage);
1222 ebox->SetWindowText(str);
1223
1224 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_FORCE_EDIT);
1225 sprintf(str, "%f", Weapons[n].impact_force);
1226 ebox->SetWindowText(str);
1227
1228 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_THRUST_TIME_EDIT);
1229 sprintf(str, "%f", Weapons[n].thrust_time);
1230 ebox->SetWindowText(str);
1231
1232 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_RECOIL_FORCE_EDIT);
1233 sprintf(str, "%f", Weapons[n].recoil_force);
1234 ebox->SetWindowText(str);
1235
1236 ebox = (CEdit *)GetDlgItem(IDC_HOMING_FOV_TEXT);
1237 sprintf(str, "%f", acos(Weapons[n].homing_fov) * (360.0 / PI));
1238 ebox->SetWindowText(str);
1239
1240 ebox = (CEdit *)GetDlgItem(IDC_CUSTOM_SIZE_EDIT);
1241 sprintf(str, "%f", Weapons[n].custom_size);
1242 ebox->SetWindowText(str);
1243
1244 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_LIFE_TIME_EDIT);
1245 sprintf(str, "%f", Weapons[n].life_time);
1246 ebox->SetWindowText(str);
1247
1248 ebox = (CEdit *)GetDlgItem(IDC_TERRIAN_DAMAGE_SIZE);
1249 sprintf(str, "%f", Weapons[n].terrain_damage_size);
1250 ebox->SetWindowText(str);
1251
1252 ebox = (CEdit *)GetDlgItem(IDC_TERRAIN_DAMAGE_DEPTH);
1253 sprintf(str, "%d", Weapons[n].terrain_damage_depth);
1254 ebox->SetWindowText(str);
1255
1256 UpdateWeaponView();
1257 }
1258
1259 void CWorldWeaponsDialog::UpdateWeaponView() {
1260 int n = D3EditState.current_weapon;
1261 CWnd *weaponwnd;
1262 RECT rect;
1263 int x, y, bm_handle, w, h;
1264 static int frame = 0;
1265 static int last_weapon = -1;
1266 static int last_image_handle = -1;
1267 int clearit = 0;
1268
1269 if (Num_weapons < 1)
1270 return;
1271
1272 frame++;
1273
1274 weaponwnd = GetDlgItem(IDC_WEAPONVIEW);
1275 weaponwnd->GetWindowRect(&rect);
1276 ScreenToClient(&rect);
1277
1278 Desktop_surf->attach_to_window((unsigned)m_hWnd);
1279
1280 w = rect.right - rect.left;
1281 h = rect.bottom - rect.top;
1282
1283 if (last_weapon != n || last_image_handle != Weapons[n].hud_image_handle) {
1284 Desktop_surf->clear(rect.left, rect.top, w, h);
1285 last_weapon = n;
1286 last_image_handle = Weapons[n].hud_image_handle;
1287 clearit = 1;
1288 }
1289
1290 bm_handle = GetWeaponHudImage(n, frame);
1291
1292 m_WeaponSurf.create(128, 128, bm_bpp(bm_handle));
1293 m_WeaponSurf.load(bm_handle);
1294
1295 x = rect.left + ((rect.right - rect.left) / 2) - m_WeaponSurf.width() / 2;
1296 y = rect.top + ((rect.bottom - rect.top) / 2) - m_WeaponSurf.height() / 2;
1297
1298 Desktop_surf->blt(x, y, &m_WeaponSurf);
1299 m_WeaponSurf.free();
1300
1301 weaponwnd = GetDlgItem(IDC_WEAPONFIREVIEW);
1302 weaponwnd->GetWindowRect(&rect);
1303 ScreenToClient(&rect);
1304
1305 w = rect.right - rect.left;
1306 h = rect.bottom - rect.top;
1307
1308 if (clearit)
1309 Desktop_surf->clear(rect.left, rect.top, w, h);
1310
1311 bm_handle = GetWeaponFireImage(n, frame);
1312
1313 if ((Weapons[n].flags & WF_IMAGE_BITMAP) || (Weapons[n].flags & WF_IMAGE_VCLIP)) {
1314 m_WeaponSurf.create(bm_w(bm_handle, 0), bm_h(bm_handle, 0), bm_bpp(bm_handle));
1315 m_WeaponSurf.load(bm_handle);
1316
1317 x = rect.left + ((rect.right - rect.left) / 2) - m_WeaponSurf.width() / 2;
1318 y = rect.top + ((rect.bottom - rect.top) / 2) - m_WeaponSurf.height() / 2;
1319
1320 Desktop_surf->blt(x, y, &m_WeaponSurf);
1321 m_WeaponSurf.free();
1322 } else {
1323 vector zero_vector;
1324 vector view_vector = {0, 0, -2};
1325 matrix id_matrix, rot_matrix;
1326
1327 vm_MakeZero(&zero_vector);
1328 vm_MakeIdentity(&id_matrix);
1329 vm_AnglesToMatrix(&rot_matrix, 0, frame * 400, 0);
1330
1331 m_WeaponSurf.create(128, 128, BPP_16);
1332 grViewport *vport = new grViewport(&m_WeaponSurf);
1333 StartEditorFrame(vport, &view_vector, &id_matrix, D3_DEFAULT_ZOOM);
1334 DrawPolygonModel(&zero_vector, &rot_matrix, bm_handle, NULL, 0, 1.0, 1.0, 1.0);
1335 EndEditorFrame();
1336
1337 x = rect.left + ((rect.right - rect.left) / 2) - m_WeaponSurf.width() / 2;
1338 y = rect.top + ((rect.bottom - rect.top) / 2) - m_WeaponSurf.height() / 2;
1339 Desktop_surf->blt(x, y, &m_WeaponSurf);
1340
1341 delete vport;
1342 m_WeaponSurf.free();
1343 }
1344
1345 Desktop_surf->attach_to_window((unsigned)NULL);
1346 }
1347
1348 BOOL CWorldWeaponsDialog::DestroyWindow() {
1349 // TODO: Add your specialized code here and/or call the base class
1350
1351 SaveWeaponsOnClose();
1352 return CDialog::DestroyWindow();
1353 }
1354
1355 BOOL CWorldWeaponsDialog::OnInitDialog() {
1356 CDialog::OnInitDialog();
1357
1358 CWnd::SetTimer(1, 50, NULL);
1359
1360 UpdateDialog();
1361
1362 return TRUE; // return TRUE unless you set the focus to a control
1363 // EXCEPTION: OCX Property Pages should return FALSE
1364 }
1365
1366 void CWorldWeaponsDialog::OnTimer(UINT nIDEvent) {
1367 // TODO: Add your message handler code here and/or call default
1368
1369 UpdateWeaponView();
1370
1371 CDialog::OnTimer(nIDEvent);
1372 }
1373
1374 void CWorldWeaponsDialog::OnLoadWeaponDischarge() {
1375 char filename[255];
1376 int bm_handle;
1377 int model = 0;
1378 int anim = 0;
1379
1380 CString filter =
1381 "Descent III files "
1382 "(*.oaf,*.ifl,*.tga,*.bbm,*.lbm,*.ogf,*.pcx,*.pof,*.oof)|*.pcx;*.tga;*.bbm;*.lbm;*.ogf;*.pof;*.oof;*.oaf;*.ifl||";
1383
1384 if (!OpenFileDialog(this, (LPCSTR)filter, filename, Current_weapon_dir, sizeof(Current_weapon_dir)))
1385 return;
1386
1387 // Okay, we selected a file. Lets do what needs to be done here.
1388 bm_handle = LoadWeaponFireImage(filename, &model, &anim, 0);
1389
1390 if (bm_handle < 0) {
1391 OutrageMessageBox("Could not load that image...restoring previous image.");
1392 return;
1393 }
1394 int n = D3EditState.current_weapon;
1395
1396 Weapons[n].fire_image_handle = bm_handle;
1397
1398 if (!model) {
1399 if (anim) {
1400 Weapons[n].flags |= WF_IMAGE_VCLIP;
1401 Weapons[n].flags &= ~WF_IMAGE_BITMAP;
1402 } else {
1403 Weapons[n].flags |= WF_IMAGE_BITMAP;
1404 Weapons[n].flags &= ~WF_IMAGE_VCLIP;
1405 }
1406 } else {
1407 Weapons[n].flags &= ~WF_IMAGE_BITMAP;
1408 Weapons[n].flags &= ~WF_IMAGE_VCLIP;
1409 Weapons[n].flags &= ~WF_ELECTRICAL;
1410 }
1411
1412 mprintf(0, "Making a copy of this bitmap/model locally...\n");
1413
1414 if (!model) {
1415 if (!anim) {
1416 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1417 GameBitmaps[Weapons[n].fire_image_handle].name);
1418 bm_SaveFileBitmap(filename, Weapons[n].fire_image_handle);
1419 } else {
1420 sprintf(filename, "%s\\%s", LocalManageGraphicsDir.u8string().c_str(),
1421 GameVClips[Weapons[n].fire_image_handle].name);
1422 SaveVClip(filename, Weapons[n].fire_image_handle);
1423 }
1424 } else {
1425 std::filesystem::path destname = LocalModelsDir / Poly_models[Weapons[n].fire_image_handle].name;
1426 cf_CopyFile(destname, filename);
1427 }
1428
1429 UpdateDialog();
1430 }
1431
1432 void CWorldWeaponsDialog::OnSelendokFireSoundPulldown() {
1433 int cur;
1434 char name[200];
1435 int n = D3EditState.current_weapon;
1436
1437 cur = SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_GETCURSEL, 0, 0);
1438 SendDlgItemMessage(IDC_FIRE_SOUND_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1439
1440 Weapons[n].sounds[WSI_FIRE] = FindSoundName(name);
1441 }
1442
1443 void CWorldWeaponsDialog::OnSelendokWeaponWallSoundPulldown() {
1444 int cur;
1445 char name[200];
1446 int n = D3EditState.current_weapon;
1447
1448 cur = SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_GETCURSEL, 0, 0);
1449 SendDlgItemMessage(IDC_WEAPON_WALL_SOUND_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1450
1451 Weapons[n].sounds[WSI_IMPACT_WALL] = FindSoundName(name);
1452 }
1453
1454 BOOL CWorldWeaponsDialog::OnHelpInfo(HELPINFO *pHelpInfo) {
1455 WinHelp(HID_WEAPONSDLG, HELP_CONTEXT);
1456 return TRUE;
1457 // return CDialog::OnHelpInfo(pHelpInfo);
1458 }
1459
1460 void CWorldWeaponsDialog::OnWeaponHomingCheck() {
1461 int n = D3EditState.current_weapon;
1462 int c = IsDlgButtonChecked(IDC_WEAPON_HOMING_CHECK);
1463
1464 if (c)
1465 Weapons[n].phys_info.flags |= PF_HOMING;
1466 else
1467 Weapons[n].phys_info.flags &= ~PF_HOMING;
1468 }
1469
1470 void CWorldWeaponsDialog::OnWeaponCollideWithSiblingCheck() {
1471 int n = D3EditState.current_weapon;
1472 int c = IsDlgButtonChecked(IDC_WEAPON_COLLIDE_WITH_SIBLING_CHECK);
1473
1474 if (c)
1475 Weapons[n].phys_info.flags |= PF_HITS_SIBLINGS;
1476 else
1477 Weapons[n].phys_info.flags &= ~PF_HITS_SIBLINGS;
1478 }
1479
1480 void CWorldWeaponsDialog::OnWeaponUseParentVelocityCheck() {
1481 // TODO: Add your control notification handler code here
1482 int n = D3EditState.current_weapon;
1483 int c = IsDlgButtonChecked(IDC_WEAPON_USE_PARENT_VELOCITY_CHECK);
1484
1485 if (c)
1486 Weapons[n].phys_info.flags |= PF_USES_PARENT_VELOCITY;
1487 else
1488 Weapons[n].phys_info.flags &= ~PF_USES_PARENT_VELOCITY;
1489 }
1490
1491 void CWorldWeaponsDialog::OnKillfocusWeaponBlobSizeEdit() {
1492 CEdit *ebox;
1493 char str[20];
1494 int n = D3EditState.current_weapon;
1495
1496 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_BLOB_SIZE_EDIT);
1497 ebox->GetWindowText(str, 20);
1498
1499 Weapons[n].size = atof(str);
1500 UpdateDialog();
1501 }
1502
1503 void CWorldWeaponsDialog::OnKillfocusWeaponImpactSizeEdit() {
1504 CEdit *ebox;
1505 char str[20];
1506 int n = D3EditState.current_weapon;
1507
1508 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_SIZE_EDIT);
1509 ebox->GetWindowText(str, 20);
1510
1511 Weapons[n].impact_size = atof(str);
1512 UpdateDialog();
1513 }
1514
1515 void CWorldWeaponsDialog::OnKillfocusWeaponThrustTimeEdit() {
1516 CEdit *ebox;
1517 char str[20];
1518 int n = D3EditState.current_weapon;
1519
1520 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_THRUST_TIME_EDIT);
1521 ebox->GetWindowText(str, 20);
1522
1523 Weapons[n].thrust_time = atof(str);
1524 UpdateDialog();
1525 }
1526
1527 void CWorldWeaponsDialog::OnKillfocusWeaponLifeTimeEdit() {
1528 CEdit *ebox;
1529 char str[20];
1530 int n = D3EditState.current_weapon;
1531
1532 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_LIFE_TIME_EDIT);
1533 ebox->GetWindowText(str, 20);
1534
1535 Weapons[n].life_time = atof(str);
1536 UpdateDialog();
1537 }
1538
1539 void CWorldWeaponsDialog::OnKillfocusWeaponDamageEdit() {
1540 CEdit *ebox;
1541 char str[20];
1542 int n = D3EditState.current_weapon;
1543 float val;
1544
1545 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_DAMAGE_EDIT);
1546 ebox->GetWindowText(str, 20);
1547
1548 val = atof(str);
1549 if (val < -200)
1550 val = -200.0f;
1551 if (val > 4000.0)
1552 val = 4000.0f;
1553 Weapons[n].player_damage = val;
1554 UpdateDialog();
1555 }
1556
1557 void CWorldWeaponsDialog::OnSmokeCheck() {
1558 int n = D3EditState.current_weapon;
1559 int c = IsDlgButtonChecked(IDC_SMOKE_CHECK);
1560
1561 if (c)
1562 Weapons[n].flags |= WF_SMOKE;
1563 else
1564 Weapons[n].flags &= ~WF_SMOKE;
1565
1566 UpdateDialog();
1567 }
1568
1569 void CWorldWeaponsDialog::OnEditPhysics() {
1570 int n = D3EditState.current_weapon;
1571
1572 CPhysicsDlg dlg(&Weapons[n].phys_info);
1573
1574 dlg.DoModal();
1575 }
1576
1577 // Gets a name from the user, making sure it's unique
1578 // Returns true if got new name, false if cancelled.
1579 // the data in buf not changed if cancel is pressed
1580 bool InputWeaponName(char *buf, int len, char *title, char *prompt, CWnd *wnd) {
1581 char *tempbuf = (char *)mem_malloc(len);
1582
1583 strcpy(tempbuf, buf);
1584
1585 try_again:
1586
1587 if (!InputString(tempbuf, len, title, prompt, wnd)) {
1588 mem_free(tempbuf);
1589 return 0;
1590 }
1591
1592 if (FindWeaponName(tempbuf) != -1) {
1593 OutrageMessageBox("The name you specified is already in use. Enter another name.");
1594 goto try_again;
1595 }
1596
1597 strcpy(buf, tempbuf);
1598 mem_free(tempbuf);
1599
1600 return 1;
1601 }
1602
1603 void CWorldWeaponsDialog::OnChangeName() {
1604 char name[PAGENAME_LEN];
1605 mngs_Pagelock pl;
1606 int n = D3EditState.current_weapon;
1607
1608 // Make sure we have this ship locked, if not reset name and bail
1609 int p = mng_FindTrackLock(Weapons[n].name, PAGETYPE_WEAPON);
1610 if (p == -1) {
1611 OutrageMessageBox("You must lock this weapon if you wish to change its name.");
1612 return;
1613 }
1614
1615 // Get new name
1616 strcpy(name, Weapons[n].name);
1617 if (!InputWeaponName(name, sizeof(name), "Weapon name", "Enter a new name for this weapon:", this))
1618 return;
1619
1620 if (!mng_MakeLocker())
1621 return;
1622
1623 // Check to see if this page exists on the network. If so, we have to
1624 // rename it so we can prevent havoc
1625 strcpy(pl.name, Weapons[n].name);
1626 pl.pagetype = PAGETYPE_WEAPON;
1627
1628 int ret = mng_CheckIfPageOwned(&pl, TableUser);
1629 if (ret < 0)
1630 OutrageMessageBox(ErrorString);
1631 else if (ret == 1)
1632 mng_RenamePage(Weapons[n].name, name, PAGETYPE_WEAPON);
1633 else if (ret == 2) {
1634 // This page has never been checked in, replace only local copy
1635
1636 char oldname[PAGENAME_LEN];
1637 strcpy(oldname, Weapons[n].name);
1638 strcpy(Weapons[n].name, name);
1639
1640 mng_ReplacePage(oldname, Weapons[n].name, n, PAGETYPE_WEAPON, 1);
1641 } else if (ret == 0) {
1642 OutrageMessageBox("You don't own this page. Get Jason now!");
1643 mng_FreeTrackLock(p);
1644 return;
1645 }
1646
1647 // Finally, copy our new name to the appropriate arrays
1648 strcpy(GlobalTrackLocks[p].name, name);
1649 strcpy(Weapons[n].name, name);
1650 mng_EraseLocker();
1651
1652 RemapWeapons();
1653
1654 // check to see if current has been remapped
1655 if (!Weapons[n].used)
1656 D3EditState.current_weapon = GetNextWeapon(n);
1657
1658 UpdateDialog();
1659 }
1660
1661 void CWorldWeaponsDialog::OnWeaponLightInfo() {
1662 int n = D3EditState.current_weapon;
1663
1664 CGenericLightDialog dlg(&Weapons[n].lighting_info);
1665 dlg.DoModal();
1666
1667 UpdateDialog();
1668 }
1669
1670 void CWorldWeaponsDialog::OnEnergyRadio() {
1671 int n = D3EditState.current_weapon;
1672
1673 Weapons[n].flags &= ~WF_MATTER_WEAPON;
1674 UpdateDialog();
1675 }
1676
1677 void CWorldWeaponsDialog::OnMatterRadio() {
1678 int n = D3EditState.current_weapon;
1679
1680 Weapons[n].flags |= WF_MATTER_WEAPON;
1681 UpdateDialog();
1682 }
1683
1684 void CWorldWeaponsDialog::OnElectricalCheck() {
1685
1686 int n = D3EditState.current_weapon;
1687 int c = IsDlgButtonChecked(IDC_ELECTRICAL_CHECK);
1688
1689 if (!((Weapons[n].flags & WF_IMAGE_BITMAP) || (Weapons[n].flags & WF_IMAGE_VCLIP))) {
1690 mprintf(0, "The firing image must be a bitmap(not a model) for 'electrical' to work!\n");
1691 return;
1692 }
1693
1694 if (c)
1695 Weapons[n].flags |= WF_ELECTRICAL;
1696 else
1697 Weapons[n].flags &= ~WF_ELECTRICAL;
1698
1699 UpdateDialog();
1700 }
1701
1702 void CWorldWeaponsDialog::OnDefaultSize() {
1703 int n = D3EditState.current_weapon;
1704 poly_model *pm = GetPolymodelPointer(Weapons[n].fire_image_handle);
1705
1706 if (!pm->new_style || !(pm->flags & PMF_TIMED)) {
1707 OutrageMessageBox("This model must be a timed oof for this function to work!");
1708 return;
1709 }
1710
1711 ComputeDefaultSize(OBJ_WEAPON, Weapons[n].fire_image_handle, &Weapons[n].size);
1712 UpdateDialog();
1713 }
1714
1715 void CWorldWeaponsDialog::OnKillfocusWeaponImpactTimeEdit() {
1716 CEdit *ebox;
1717 char str[20];
1718 int n = D3EditState.current_weapon;
1719
1720 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_FORCE_EDIT);
1721 ebox->GetWindowText(str, 20);
1722
1723 Weapons[n].impact_force = atof(str);
1724 UpdateDialog();
1725 }
1726
1727 void CWorldWeaponsDialog::OnSelendokSmokePulldown() {
1728 int n = D3EditState.current_weapon;
1729
1730 if (!(Weapons[n].flags & WF_SMOKE))
1731 return;
1732
1733 int cur;
1734 char name[200];
1735
1736 cur = SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_GETCURSEL, 0, 0);
1737 SendDlgItemMessage(IDC_SMOKE_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1738
1739 Weapons[n].smoke_handle = FindTextureName(name);
1740
1741 UpdateDialog();
1742 }
1743
1744 void CWorldWeaponsDialog::OnSelendokScorchPulldown() {
1745 int n = D3EditState.current_weapon;
1746 int cur;
1747 char name[200];
1748
1749 cur = SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_GETCURSEL, 0, 0);
1750 SendDlgItemMessage(IDC_SCORCH_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1751
1752 if (strcmp(name, NULL_NAME) == 0)
1753 Weapons[n].scorch_handle = -1;
1754 else
1755 Weapons[n].scorch_handle = FindTextureName(name);
1756
1757 UpdateDialog();
1758 }
1759
1760 void CWorldWeaponsDialog::OnSelendokExplodePulldown() {
1761 int n = D3EditState.current_weapon;
1762
1763 int cur;
1764 char name[200];
1765
1766 cur = SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_GETCURSEL, 0, 0);
1767 SendDlgItemMessage(IDC_EXPLODE_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1768
1769 Weapons[n].explode_image_handle = FindTextureName(name);
1770
1771 UpdateDialog();
1772 }
1773
1774 void CWorldWeaponsDialog::OnSprayCheck() {
1775 int n = D3EditState.current_weapon;
1776 int c = IsDlgButtonChecked(IDC_SPRAY_CHECK);
1777
1778 if (!(Weapons[n].flags & WF_IMAGE_VCLIP)) {
1779 mprintf(0, "The firing image must be a bitmap(not a model) for spray to work!\n");
1780 return;
1781 }
1782
1783 if (c)
1784 Weapons[n].flags |= WF_SPRAY;
1785 else
1786 Weapons[n].flags &= ~WF_SPRAY;
1787
1788 UpdateDialog();
1789 }
1790
1791 void CWorldWeaponsDialog::OnInstantCheck() {
1792 int n = D3EditState.current_weapon;
1793 int c = IsDlgButtonChecked(IDC_INSTANT_CHECK);
1794
1795 if (c)
1796 Weapons[n].flags |= WF_STREAMER;
1797 else
1798 Weapons[n].flags &= ~WF_STREAMER;
1799
1800 UpdateDialog();
1801 }
1802
1803 void CWorldWeaponsDialog::OnInvisible() {
1804 int n = D3EditState.current_weapon;
1805 int c = IsDlgButtonChecked(IDC_INVISIBLE);
1806
1807 if (c)
1808 Weapons[n].flags |= WF_INVISIBLE;
1809 else
1810 Weapons[n].flags &= ~WF_INVISIBLE;
1811
1812 UpdateDialog();
1813 }
1814
1815 void CWorldWeaponsDialog::OnRing() {
1816 int n = D3EditState.current_weapon;
1817 int c = IsDlgButtonChecked(IDC_RING);
1818
1819 if (c)
1820 Weapons[n].flags |= WF_RING;
1821 else
1822 Weapons[n].flags &= ~WF_RING;
1823
1824 UpdateDialog();
1825 }
1826
1827 void CWorldWeaponsDialog::OnExplodeRing() {
1828 int n = D3EditState.current_weapon;
1829 int c = IsDlgButtonChecked(IDC_EXPLODE_RING);
1830
1831 if (c)
1832 Weapons[n].flags |= WF_BLAST_RING;
1833 else
1834 Weapons[n].flags &= ~WF_BLAST_RING;
1835
1836 UpdateDialog();
1837 }
1838
1839 void CWorldWeaponsDialog::OnPlanarBlast() {
1840 int n = D3EditState.current_weapon;
1841 int c = IsDlgButtonChecked(IDC_PLANAR_BLAST);
1842
1843 if (c)
1844 Weapons[n].flags |= WF_PLANAR_BLAST;
1845 else
1846 Weapons[n].flags &= ~WF_PLANAR_BLAST;
1847
1848 UpdateDialog();
1849 }
1850
1851 void CWorldWeaponsDialog::OnSaturateCheck() {
1852 int n = D3EditState.current_weapon;
1853 int c = IsDlgButtonChecked(IDC_SATURATE_CHECK);
1854
1855 if (c)
1856 Weapons[n].flags |= WF_SATURATE;
1857 else
1858 Weapons[n].flags &= ~WF_SATURATE;
1859
1860 UpdateDialog();
1861 }
1862
1863 void CWorldWeaponsDialog::OnKillfocusWeaponAlphaEdit() {
1864 CEdit *ebox;
1865 char str[20];
1866 int n = D3EditState.current_weapon;
1867
1868 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_ALPHA_EDIT);
1869 ebox->GetWindowText(str, 20);
1870
1871 Weapons[n].alpha = atof(str);
1872 if (Weapons[n].alpha < 0)
1873 Weapons[n].alpha = 0;
1874 if (Weapons[n].alpha > 1)
1875 Weapons[n].alpha = 1;
1876
1877 UpdateDialog();
1878 }
1879
1880 void CWorldWeaponsDialog::OnPlanarCheck() {
1881 int n = D3EditState.current_weapon;
1882 int c = IsDlgButtonChecked(IDC_PLANAR_CHECK);
1883
1884 if (c)
1885 Weapons[n].flags |= WF_PLANAR;
1886 else
1887 Weapons[n].flags &= ~WF_PLANAR;
1888
1889 UpdateDialog();
1890 }
1891
1892 void CWorldWeaponsDialog::OnKillfocusExplodeSizeEdit() {
1893 CEdit *ebox;
1894 char str[20];
1895 int n = D3EditState.current_weapon;
1896
1897 ebox = (CEdit *)GetDlgItem(IDC_EXPLODE_SIZE_EDIT);
1898 ebox->GetWindowText(str, 20);
1899
1900 Weapons[n].explode_size = atof(str);
1901 if (Weapons[n].explode_size < 0)
1902 Weapons[n].explode_size = 0;
1903
1904 UpdateDialog();
1905 }
1906
1907 void CWorldWeaponsDialog::OnKillfocusExplodeTimeEdit() {
1908 CEdit *ebox;
1909 char str[20];
1910 int n = D3EditState.current_weapon;
1911
1912 ebox = (CEdit *)GetDlgItem(IDC_EXPLODE_TIME_EDIT);
1913 ebox->GetWindowText(str, 20);
1914
1915 Weapons[n].explode_time = atof(str);
1916 if (Weapons[n].explode_time < 0)
1917 Weapons[n].explode_time = 0;
1918
1919 UpdateDialog();
1920 }
1921
1922 void CWorldWeaponsDialog::OnEnableCamera() {
1923 CButton *btn;
1924 int n = D3EditState.current_weapon;
1925
1926 btn = (CButton *)GetDlgItem(IDC_ENABLE_CAMERA);
1927
1928 if (btn->GetCheck())
1929 Weapons[n].flags |= WF_ENABLE_CAMERA;
1930 else
1931 Weapons[n].flags &= ~WF_ENABLE_CAMERA;
1932 }
1933
1934 void CWorldWeaponsDialog::OnSelendokWeaponSpawnPulldown() {
1935 int n = D3EditState.current_weapon;
1936
1937 int cur;
1938 char name[200];
1939
1940 cur = SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_GETCURSEL, 0, 0);
1941 SendDlgItemMessage(IDC_WEAPON_SPAWN_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
1942
1943 Weapons[n].spawn_handle = FindWeaponName(name);
1944
1945 UpdateDialog();
1946 }
1947
1948 void CWorldWeaponsDialog::OnKillfocusWeaponSpawnEdit() {
1949 CEdit *ebox;
1950 char str[20];
1951 int n = D3EditState.current_weapon;
1952
1953 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_SPAWN_EDIT);
1954 ebox->GetWindowText(str, 20);
1955
1956 Weapons[n].spawn_count = atoi(str);
1957
1958 if (Weapons[n].spawn_count < 0)
1959 Weapons[n].spawn_count = 0;
1960 if (Weapons[n].spawn_count > 20)
1961 Weapons[n].spawn_count = 20;
1962
1963 UpdateDialog();
1964 }
1965
1966 void CWorldWeaponsDialog::OnSpawnsOnImpact() {
1967 int n = D3EditState.current_weapon;
1968 int c = IsDlgButtonChecked(IDC_SPAWNS_ON_IMPACT);
1969
1970 if (c)
1971 Weapons[n].flags |= WF_SPAWNS_IMPACT;
1972 else
1973 Weapons[n].flags &= ~WF_SPAWNS_IMPACT;
1974
1975 UpdateDialog();
1976 }
1977
1978 void CWorldWeaponsDialog::OnSpawnsOnTimeout() {
1979 int n = D3EditState.current_weapon;
1980 int c = IsDlgButtonChecked(IDC_SPAWNS_ON_TIMEOUT);
1981
1982 if (c)
1983 Weapons[n].flags |= WF_SPAWNS_TIMEOUT;
1984 else
1985 Weapons[n].flags &= ~WF_SPAWNS_TIMEOUT;
1986
1987 UpdateDialog();
1988 }
1989
1990 void CWorldWeaponsDialog::OnOverride() {
1991 int n = D3EditState.current_weapon;
1992 mngs_Pagelock temp_pl;
1993
1994 strcpy(temp_pl.name, Weapons[n].name);
1995 temp_pl.pagetype = PAGETYPE_WEAPON;
1996
1997 mng_OverrideToUnlocked(&temp_pl);
1998 }
1999
2000 void CWorldWeaponsDialog::OnKillfocusParticleCountEdit() {
2001 CEdit *ebox;
2002 char str[20];
2003 int n = D3EditState.current_weapon;
2004
2005 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_COUNT_EDIT);
2006 ebox->GetWindowText(str, 20);
2007
2008 Weapons[n].particle_count = atoi(str);
2009 if (Weapons[n].particle_count < 0)
2010 Weapons[n].particle_count = 0;
2011
2012 UpdateDialog();
2013 }
2014
2015 void CWorldWeaponsDialog::OnKillfocusParticleLifeEdit() {
2016 CEdit *ebox;
2017 char str[20];
2018 int n = D3EditState.current_weapon;
2019
2020 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_LIFE_EDIT);
2021 ebox->GetWindowText(str, 20);
2022
2023 Weapons[n].particle_life = atof(str);
2024 if (Weapons[n].particle_life < 0)
2025 Weapons[n].particle_life = 0;
2026
2027 UpdateDialog();
2028 }
2029
2030 void CWorldWeaponsDialog::OnKillfocusParticleSizeEdit() {
2031 CEdit *ebox;
2032 char str[20];
2033 int n = D3EditState.current_weapon;
2034
2035 ebox = (CEdit *)GetDlgItem(IDC_PARTICLE_SIZE_EDIT);
2036 ebox->GetWindowText(str, 20);
2037
2038 Weapons[n].particle_size = atof(str);
2039 if (Weapons[n].particle_size < 0)
2040 Weapons[n].particle_size = 0;
2041
2042 UpdateDialog();
2043 }
2044
2045 void CWorldWeaponsDialog::OnSelendokParticlePulldown() {
2046 int n = D3EditState.current_weapon;
2047
2048 int cur;
2049 char name[200];
2050
2051 cur = SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_GETCURSEL, 0, 0);
2052 SendDlgItemMessage(IDC_PARTICLE_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2053
2054 Weapons[n].particle_handle = FindTextureName(name);
2055
2056 UpdateDialog();
2057 }
2058
2059 weapon WeaponCopyBuffer;
2060 bool f_has_weapon = false;
2061
2062 void CWorldWeaponsDialog::OnWeaponCopyButton() {
2063 int n = D3EditState.current_weapon;
2064
2065 WeaponCopyBuffer = Weapons[n];
2066 f_has_weapon = true;
2067 }
2068
2069 void CWorldWeaponsDialog::OnWeaponPasteButton() {
2070 int n = D3EditState.current_weapon;
2071 char name[256];
2072
2073 strcpy(name, Weapons[n].name);
2074
2075 if (f_has_weapon) {
2076 Weapons[n] = WeaponCopyBuffer;
2077 strcpy(Weapons[n].name, name);
2078
2079 UpdateDialog();
2080 } else {
2081 OutrageMessageBox(MB_OK, "No weapon in paste buffer.\n");
2082 }
2083 }
2084
2085 void CWorldWeaponsDialog::OnExpandingCheck() {
2086 int n = D3EditState.current_weapon;
2087 int c = IsDlgButtonChecked(IDC_EXPANDING_CHECK);
2088
2089 if (c)
2090 Weapons[n].flags |= WF_EXPAND;
2091 else
2092 Weapons[n].flags &= ~WF_EXPAND;
2093
2094 UpdateDialog();
2095 }
2096
2097 void CWorldWeaponsDialog::OnMuzzleFlash() {
2098 int n = D3EditState.current_weapon;
2099 int c = IsDlgButtonChecked(IDC_MUZZLE_FLASH);
2100
2101 if (c)
2102 Weapons[n].flags |= WF_MUZZLE;
2103 else
2104 Weapons[n].flags &= ~WF_MUZZLE;
2105
2106 UpdateDialog();
2107 }
2108
2109 void CWorldWeaponsDialog::OnMicrowave() {
2110 int n = D3EditState.current_weapon;
2111 int c = IsDlgButtonChecked(IDC_MICROWAVE);
2112
2113 if (c)
2114 Weapons[n].flags |= WF_MICROWAVE;
2115 else
2116 Weapons[n].flags &= ~WF_MICROWAVE;
2117
2118 UpdateDialog();
2119 }
2120
2121 void CWorldWeaponsDialog::OnNapalm() {
2122 int n = D3EditState.current_weapon;
2123 int c = IsDlgButtonChecked(IDC_NAPALM);
2124
2125 if (c)
2126 Weapons[n].flags |= WF_NAPALM;
2127 else
2128 Weapons[n].flags &= ~WF_NAPALM;
2129
2130 UpdateDialog();
2131 }
2132
2133 void CWorldWeaponsDialog::OnSelendokWeaponBounceSoundCombo() {
2134 int cur;
2135 char name[200];
2136 int n = D3EditState.current_weapon;
2137
2138 cur = SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_GETCURSEL, 0, 0);
2139 SendDlgItemMessage(IDC_WEAPON_BOUNCE_SOUND_COMBO, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2140
2141 Weapons[n].sounds[WSI_BOUNCE] = FindSoundName(name);
2142 }
2143
2144 void CWorldWeaponsDialog::OnKillfocusWeaponImpactTimeEdit2() {
2145 CEdit *ebox;
2146 char str[20];
2147 int n = D3EditState.current_weapon;
2148
2149 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_TIME_EDIT2);
2150 ebox->GetWindowText(str, 20);
2151
2152 Weapons[n].impact_time = atof(str);
2153 UpdateDialog();
2154 }
2155
2156 void CWorldWeaponsDialog::OnKillfocusWeaponImpactDamageEdit() {
2157 CEdit *ebox;
2158 char str[20];
2159 int n = D3EditState.current_weapon;
2160
2161 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_DAMAGE_EDIT);
2162 ebox->GetWindowText(str, 20);
2163
2164 Weapons[n].impact_player_damage = atof(str);
2165 UpdateDialog();
2166 }
2167
2168 void CWorldWeaponsDialog::OnKillfocusWeaponImpactForceEdit() {
2169 CEdit *ebox;
2170 char str[20];
2171 int n = D3EditState.current_weapon;
2172
2173 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_FORCE_EDIT);
2174 ebox->GetWindowText(str, 20);
2175
2176 Weapons[n].impact_force = atof(str);
2177 UpdateDialog();
2178 }
2179
2180 void CWorldWeaponsDialog::OnKillfocusWeaponScorchSizeEdit() {
2181 CEdit *ebox;
2182 char str[20];
2183 int n = D3EditState.current_weapon;
2184
2185 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_SCORCH_SIZE_EDIT);
2186 ebox->GetWindowText(str, 20);
2187
2188 Weapons[n].scorch_size = atof(str);
2189 UpdateDialog();
2190 }
2191
2192 void CWorldWeaponsDialog::OnSelendokSmallimgPulldown() {
2193 int n = D3EditState.current_weapon;
2194 int cur;
2195 char name[200];
2196
2197 cur = SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_GETCURSEL, 0, 0);
2198 SendDlgItemMessage(IDC_SMALLIMG_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2199
2200 if (strcmp(name, NULL_NAME) == 0)
2201 Weapons[n].icon_handle = -1;
2202 else
2203 Weapons[n].icon_handle = FindTextureName(name);
2204
2205 UpdateDialog();
2206 }
2207
2208 void CWorldWeaponsDialog::OnSelendokSpawn2Pulldown() {
2209 int n = D3EditState.current_weapon;
2210
2211 int cur;
2212 char name[200];
2213
2214 cur = SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_GETCURSEL, 0, 0);
2215 SendDlgItemMessage(IDC_SPAWN2_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2216
2217 Weapons[n].alternate_spawn_handle = FindWeaponName(name);
2218
2219 UpdateDialog();
2220 }
2221
2222 void CWorldWeaponsDialog::OnKillfocusAlternateChanceEdit() {
2223 CEdit *ebox;
2224 char str[20];
2225 int n = D3EditState.current_weapon;
2226 int val;
2227
2228 ebox = (CEdit *)GetDlgItem(IDC_ALTERNATE_CHANCE_EDIT);
2229 ebox->GetWindowText(str, 20);
2230
2231 val = atoi(str);
2232 if (val < 0 || val > 100) {
2233 OutrageMessageBox("Alternate chance value must be between 0 and 100!");
2234
2235 } else {
2236 Weapons[n].alternate_chance = val;
2237 }
2238
2239 UpdateDialog();
2240 }
2241
2242 void CWorldWeaponsDialog::OnReverseSmokeCheck() {
2243 int n = D3EditState.current_weapon;
2244 int c = IsDlgButtonChecked(IDC_REVERSE_SMOKE_CHECK);
2245
2246 if (c)
2247 Weapons[n].flags |= WF_REVERSE_SMOKE;
2248 else
2249 Weapons[n].flags &= ~WF_REVERSE_SMOKE;
2250
2251 UpdateDialog();
2252 }
2253
2254 void CWorldWeaponsDialog::OnGravityFieldCheck() {
2255 int n = D3EditState.current_weapon;
2256 int c = IsDlgButtonChecked(IDC_GRAVITY_FIELD_CHECK);
2257
2258 if (c)
2259 Weapons[n].flags |= WF_GRAVITY_FIELD;
2260 else
2261 Weapons[n].flags &= ~WF_GRAVITY_FIELD;
2262
2263 UpdateDialog();
2264 }
2265
2266 void CWorldWeaponsDialog::OnKillfocusGravitySize() {
2267 CEdit *ebox;
2268 char str[20];
2269 int n = D3EditState.current_weapon;
2270
2271 ebox = (CEdit *)GetDlgItem(IDC_GRAVITY_SIZE);
2272 ebox->GetWindowText(str, 20);
2273
2274 Weapons[n].gravity_size = atof(str);
2275 UpdateDialog();
2276 }
2277
2278 void CWorldWeaponsDialog::OnKillfocusGravityTime() {
2279 CEdit *ebox;
2280 char str[20];
2281 int n = D3EditState.current_weapon;
2282
2283 ebox = (CEdit *)GetDlgItem(IDC_GRAVITY_TIME);
2284 ebox->GetWindowText(str, 20);
2285
2286 Weapons[n].gravity_time = atof(str);
2287 UpdateDialog();
2288 }
2289
2290 void CWorldWeaponsDialog::OnCountermeasureCheck() {
2291 int n = D3EditState.current_weapon;
2292 int c = IsDlgButtonChecked(IDC_COUNTERMEASURE_CHECK);
2293
2294 if (c)
2295 Weapons[n].flags |= WF_COUNTERMEASURE;
2296 else
2297 Weapons[n].flags &= ~WF_COUNTERMEASURE;
2298
2299 UpdateDialog();
2300 }
2301
2302 void CWorldWeaponsDialog::OnSpawnsRobotCheck() {
2303 int n = D3EditState.current_weapon;
2304 int c = IsDlgButtonChecked(IDC_SPAWNS_ROBOT_CHECK);
2305
2306 if (c)
2307 Weapons[n].flags |= WF_SPAWNS_ROBOT;
2308 else
2309 Weapons[n].flags &= ~WF_SPAWNS_ROBOT;
2310
2311 UpdateDialog();
2312 }
2313
2314 void CWorldWeaponsDialog::OnSelendokSpawnRobotPulldown() {
2315 int n = D3EditState.current_weapon;
2316
2317 int cur;
2318 char name[200];
2319
2320 cur = SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_GETCURSEL, 0, 0);
2321 SendDlgItemMessage(IDC_SPAWN_ROBOT_PULLDOWN, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
2322
2323 Weapons[n].robot_spawn_handle = FindObjectIDName(name);
2324
2325 UpdateDialog();
2326 }
2327
2328 void CWorldWeaponsDialog::OnKillfocusTerrianDamageSize() {
2329 CEdit *ebox;
2330 char str[20];
2331 int n = D3EditState.current_weapon;
2332
2333 ebox = (CEdit *)GetDlgItem(IDC_TERRIAN_DAMAGE_SIZE);
2334 ebox->GetWindowText(str, 20);
2335
2336 float val = atof(str);
2337 if (val < 0)
2338 val = 0;
2339 if (val > 100)
2340 val = 100;
2341
2342 Weapons[n].terrain_damage_size = val;
2343 UpdateDialog();
2344 }
2345
2346 void CWorldWeaponsDialog::OnKillfocusTerrainDamageDepth() {
2347 CEdit *ebox;
2348 char str[20];
2349 int n = D3EditState.current_weapon;
2350
2351 ebox = (CEdit *)GetDlgItem(IDC_TERRAIN_DAMAGE_DEPTH);
2352 ebox->GetWindowText(str, 20);
2353
2354 int val = atoi(str);
2355 if (val < 0)
2356 val = 0;
2357 if (val > 255)
2358 val = 255;
2359
2360 Weapons[n].terrain_damage_depth = val;
2361 UpdateDialog();
2362 }
2363
2364 void CWorldWeaponsDialog::OnFreezeCheck() {
2365 int n = D3EditState.current_weapon;
2366 int c = IsDlgButtonChecked(IDC_FREEZE_CHECK);
2367
2368 if (c)
2369 Weapons[n].flags |= WF_FREEZE;
2370 else
2371 Weapons[n].flags &= ~WF_FREEZE;
2372
2373 UpdateDialog();
2374 }
2375
2376 void CWorldWeaponsDialog::OnSilentHomingCheck() {
2377 int n = D3EditState.current_weapon;
2378 int c = IsDlgButtonChecked(IDC_SILENT_HOMING_CHECK);
2379
2380 if (c)
2381 Weapons[n].flags |= WF_SILENT_HOMING;
2382 else
2383 Weapons[n].flags &= ~WF_SILENT_HOMING;
2384
2385 UpdateDialog();
2386 }
2387
2388 void CWorldWeaponsDialog::OnHomedSplitCheck() {
2389 int n = D3EditState.current_weapon;
2390 int c = IsDlgButtonChecked(IDC_HOMED_SPLIT_CHECK);
2391
2392 if (c)
2393 Weapons[n].flags |= WF_HOMING_SPLIT;
2394 else
2395 Weapons[n].flags &= ~WF_HOMING_SPLIT;
2396
2397 UpdateDialog();
2398 }
2399
2400 void CWorldWeaponsDialog::OnKillfocusHomingFovText() {
2401 CEdit *ebox;
2402 char str[20];
2403 int n = D3EditState.current_weapon;
2404
2405 ebox = (CEdit *)GetDlgItem(IDC_HOMING_FOV_TEXT);
2406 ebox->GetWindowText(str, 20);
2407
2408 Weapons[n].homing_fov = cos(atof(str) * PI / (360.0));
2409 UpdateDialog();
2410 }
2411
2412 void CWorldWeaponsDialog::OnNoRotateCheck() {
2413 int n = D3EditState.current_weapon;
2414 int c = IsDlgButtonChecked(IDC_NO_ROTATE_CHECK);
2415
2416 if (c)
2417 Weapons[n].flags |= WF_NO_ROTATE;
2418 else
2419 Weapons[n].flags &= ~WF_NO_ROTATE;
2420
2421 UpdateDialog();
2422 }
2423
2424 void CWorldWeaponsDialog::OnCustomSizeCheck() {
2425 int n = D3EditState.current_weapon;
2426 int c = IsDlgButtonChecked(IDC_CUSTOM_SIZE_CHECK);
2427
2428 if (c)
2429 Weapons[n].flags |= WF_CUSTOM_SIZE;
2430 else
2431 Weapons[n].flags &= ~WF_CUSTOM_SIZE;
2432
2433 UpdateDialog();
2434 }
2435
2436 void CWorldWeaponsDialog::OnKillfocusCustomSizeEdit() {
2437 CEdit *ebox;
2438 char str[20];
2439 int n = D3EditState.current_weapon;
2440
2441 ebox = (CEdit *)GetDlgItem(IDC_CUSTOM_SIZE_EDIT);
2442 ebox->GetWindowText(str, 20);
2443
2444 Weapons[n].custom_size = atof(str);
2445 UpdateDialog();
2446 }
2447
2448 void CWorldWeaponsDialog::OnTimeoutWallCheck() {
2449 int n = D3EditState.current_weapon;
2450 int c = IsDlgButtonChecked(IDC_TIMEOUT_WALL_CHECK);
2451
2452 if (c)
2453 Weapons[n].flags |= WF_TIMEOUT_WALL;
2454 else
2455 Weapons[n].flags &= ~WF_TIMEOUT_WALL;
2456
2457 UpdateDialog();
2458 }
2459
2460 void CWorldWeaponsDialog::OnKillfocusWeaponGenericDamageEdit() {
2461 CEdit *ebox;
2462 char str[20];
2463 int n = D3EditState.current_weapon;
2464 float val;
2465
2466 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_GENERIC_DAMAGE_EDIT);
2467 ebox->GetWindowText(str, 20);
2468
2469 val = atof(str);
2470 if (val < -200)
2471 val = -200.0f;
2472 if (val > 4000.0)
2473 val = 4000.0f;
2474 Weapons[n].generic_damage = val;
2475 UpdateDialog();
2476 }
2477
2478 void CWorldWeaponsDialog::OnKillfocusWeaponImpactGenericDamageEdit() {
2479 CEdit *ebox;
2480 char str[20];
2481 int n = D3EditState.current_weapon;
2482
2483 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_IMPACT_GENERIC_DAMAGE_EDIT);
2484 ebox->GetWindowText(str, 20);
2485
2486 Weapons[n].impact_generic_damage = atof(str);
2487 UpdateDialog();
2488 }
2489
2490 void CWorldWeaponsDialog::OnPlanarSmokeCheck() {
2491 int n = D3EditState.current_weapon;
2492 int c = IsDlgButtonChecked(IDC_PLANAR_SMOKE_CHECK);
2493
2494 if (c)
2495 Weapons[n].flags |= WF_PLANAR_SMOKE;
2496 else
2497 Weapons[n].flags &= ~WF_PLANAR_SMOKE;
2498
2499 UpdateDialog();
2500 }
2501
2502 void CWorldWeaponsDialog::OnKillfocusWeaponRecoilForceEdit() {
2503 CEdit *ebox;
2504 char str[20];
2505 int n = D3EditState.current_weapon;
2506
2507 ebox = (CEdit *)GetDlgItem(IDC_WEAPON_RECOIL_FORCE_EDIT);
2508 ebox->GetWindowText(str, 20);
2509
2510 Weapons[n].recoil_force = atof(str);
2511 UpdateDialog();
2512 }