Debian Codegraph @

editor/WorldObjectsPowerupDialog.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/WorldObjectsPowerupDialog.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003-08-26 03:57:39 $
23 * $Author: kevinb $
24 *
25 * WorldObjectsPowerupDialog.cpp : implementation file
26 *
27 * $Log: not supported by cvs2svn $
28 *
29 * 6 8/08/97 2:25p Matt
30 * Took out error messages which are now handled by mng_MakeLocker()
31 *
32 * 5 8/06/97 12:48p Jason
33 * fixed dumb function naming error
34 *
35 * 4 8/06/97 12:40p Jason
36 * fixed some potentially serious memory problems
37 *
38 * 3 7/24/97 6:11p Matt
39 * Created symbolic constant for default zoom, and used it every place
40 * that specifies zoom
41 *
42 * $NoKeywords: $
43 */
44
45 #include "mfc_compatibility.h"
46 #include "editor.h"
47 #include "WorldObjectsPowerupDialog.h"
48 #include "powerup.h"
49 #include "manage.h"
50 #include "powerpage.h"
51 #include "mono.h"
52 #include "vclip.h"
53 #include "polymodel.h"
54 #include "soundload.h"
55
56 #ifdef _DEBUG
57 #define new DEBUG_NEW
58 #undef THIS_FILE
59 static char THIS_FILE[] = __FILE__;
60 #endif
61
62 // LGT: missing powerup.cpp
63 powerup Powerups[MAX_POWERUPS];
64
65 /////////////////////////////////////////////////////////////////////////////
66 // CWorldObjectsPowerupDialog dialog
67
68 CWorldObjectsPowerupDialog::CWorldObjectsPowerupDialog(CWnd *pParent /*=NULL*/)
69 : CDialog(CWorldObjectsPowerupDialog::IDD, pParent) {
70 //{{AFX_DATA_INIT(CWorldObjectsPowerupDialog)
71 // NOTE: the ClassWizard will add member initialization here
72 //}}AFX_DATA_INIT
73 }
74
75 void CWorldObjectsPowerupDialog::DoDataExchange(CDataExchange *pDX) {
76 CDialog::DoDataExchange(pDX);
77 //{{AFX_DATA_MAP(CWorldObjectsPowerupDialog)
78 // NOTE: the ClassWizard will add DDX and DDV calls here
79 //}}AFX_DATA_MAP
80 }
81
82 BEGIN_MESSAGE_MAP(CWorldObjectsPowerupDialog, CDialog)
83 //{{AFX_MSG_MAP(CWorldObjectsPowerupDialog)
84 ON_BN_CLICKED(IDC_ADD_NEW_POWERUP, OnAddNewPowerup)
85 ON_BN_CLICKED(IDC_CHECKIN, OnCheckin)
86 ON_BN_CLICKED(IDC_DELETE_POWERUP, OnDeletePowerup)
87 ON_BN_CLICKED(IDC_LOCK_POWERUP, OnLockPowerup)
88 ON_BN_CLICKED(IDC_NEXT_POWERUP, OnNextPowerup)
89 ON_BN_CLICKED(IDC_PREV, OnPrev)
90 ON_BN_CLICKED(IDC_POWERUPS_OUT, OnPowerupsOut)
91 ON_WM_PAINT()
92 ON_WM_TIMER()
93 ON_EN_KILLFOCUS(IDC_POWER_NAME_EDIT, OnKillfocusPowerNameEdit)
94 ON_EN_KILLFOCUS(IDC_POWERUP_SIZE_EDIT, OnKillfocusPowerupSizeEdit)
95 ON_CBN_SELENDOK(IDC_POWER_PULLDOWN, OnSelendokPowerPulldown)
96 ON_BN_CLICKED(IDC_LOAD_IMAGE, OnLoadImage)
97 ON_BN_CLICKED(IDC_GRAVITY_CHECK, OnGravityCheck)
98 ON_BN_CLICKED(IDC_MAGNETISM_CHECK, OnMagnetismCheck)
99 ON_BN_CLICKED(IDC_WIND_CHECK, OnWindCheck)
100 ON_EN_KILLFOCUS(IDC_POW_MASS_EDIT, OnKillfocusPowMassEdit)
101 ON_EN_KILLFOCUS(IDC_POW_DRAG_EDIT, OnKillfocusPowDragEdit)
102 ON_CBN_SELENDOK(IDC_POWERUP_AMBIENT_SOUND_LIST, OnSelendokPowerupAmbientSoundList)
103 ON_CBN_SELENDOK(IDC_POWERUP_PICKUP_SOUND_LIST, OnSelendokPowerupPickupSoundList)
104 ON_WM_HELPINFO()
105 //}}AFX_MSG_MAP
106 END_MESSAGE_MAP()
107
108 /////////////////////////////////////////////////////////////////////////////
109 // CWorldObjectsPowerupDialog message handlers
110
111 // This function allocates a newpower, has the user pick the image to display the
112 // powerup, and allocs a tracklock to keep track of it
113 void CWorldObjectsPowerupDialog::OnAddNewPowerup() {
114 #if 0
115 char filename[255];
116 char cur_name[100];
117 int img_handle;
118 int powerup_handle;
119 int c=1,finding_name=1;
120 int model=0;
121
122 if (!Network_up)
123 {
124 OutrageMessageBox ("Sorry babe, the network is down. This action is a no-no.\n");
125 return;
126 }
127
128 // Get the filename of the representing image
129
130 CString filter = "Descent III files (*.oaf,*.ilf,*.abm,*.pof,*.oof)|*.oaf;*.ifl;*.abm;*.pof;*.oof||";
131
132 CFileDialog dlg_open(TRUE, 0,0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this);
133
134 if (dlg_open.DoModal() == IDCANCEL) return;
135
136 // Okay, we selected a file. Lets do what needs to be done here.
137
138 strcpy (filename,dlg_open.GetPathName());
139 img_handle=LoadPowerupImage (filename,&model);
140
141 if (img_handle<0)
142 {
143 OutrageMessageBox ("Couldn't open that animation/model file.");
144 return;
145 }
146
147 // Alloc a powerup and give a name not already taken by some other powerup
148
149 powerup_handle=AllocPowerup();
150
151 while (finding_name)
152 {
153 sprintf (cur_name,"%s%d",dlg_open.GetFileName(),c);
154 if (FindPowerupName (cur_name)!=-1)
155 c++;
156 else
157 finding_name=0;
158 }
159
160 strcpy (Powerups[powerup_handle].name,cur_name);
161
162 // If its a 3d model instead of an animation, flag it
163
164 if (!model)
165 Powerups[powerup_handle].flags|=PF_IMAGE_BITMAP;
166 else
167 Powerups[powerup_handle].flags&=~PF_IMAGE_BITMAP;
168
169
170 Powerups[powerup_handle].image_handle=img_handle;
171
172 // Finally, save a local copy of the model/anim and alloc a tracklock
173 mprintf(0,"Making a copy of this model/animation locally...\n");
174
175 if (model)
176 {
177 char destname[100];
178 sprintf (destname,"%s\\%s",LocalModelsDir,Poly_models[Powerups[powerup_handle].image_handle].name);
179 if (stricmp (destname,filename)) // only copy if they are different
180 cf_CopyFile (destname,filename);
181 }
182 else
183 {
184
185 sprintf (filename,"%s\\%s",LocalManageGraphicsDir,GameVClips[Powerups[powerup_handle].image_handle].name);
186 SaveVClip (filename,Powerups[powerup_handle].image_handle);
187 }
188
189 mng_AllocTrackLock (cur_name,PAGETYPE_POWERUP);
190
191 D3EditState.current_powerup=powerup_handle;
192
193 RemapPowerups();
194
195 UpdateDialog ();
196 #endif
197 }
198
199 // This functions saves the current powerup to the net
200 void CWorldObjectsPowerupDialog::OnCheckin() {
201 #if 0
202 int n=D3EditState.current_powerup;
203 mngs_Pagelock temp_pl;
204 int r;
205
206 if (Num_powerups<1)
207 return;
208
209 if (!mng_MakeLocker())
210 return;
211
212 // Make sure we own this powerup
213 strcpy (temp_pl.name,Powerups[n].name);
214 temp_pl.pagetype=PAGETYPE_POWERUP;
215
216 r=mng_CheckIfPageOwned (&temp_pl,TableUser);
217 if (r<0)
218 OutrageMessageBox (ErrorString);
219 else if (r==0)
220 OutrageMessageBox (InfoString);
221 else
222 {
223 // Change the pagelock state to UNLOCKED
224 strcpy (temp_pl.holder,"UNLOCKED");
225 if (!mng_ReplacePagelock (temp_pl.name,&temp_pl))
226 {
227 MessageBox (ErrorString,"Error!");
228 mng_EraseLocker();
229 return;
230 }
231 else
232 {
233 // Now actually replace the copy on the net with our local one
234
235 if (!mng_ReplacePowPage (Powerups[n].name,n,0))
236 OutrageMessageBox (ErrorString);
237 else
238 {
239 // Save this powerups anim/model to the network for all
240
241 char fname[255];
242
243 if (Powerups[n].flags & PF_IMAGE_BITMAP)
244 {
245 sprintf (fname,"%s\\%s",ManageGraphicsDir,GameVClips[Powerups[n].image_handle].name);
246 SaveVClip (fname,Powerups[n].image_handle);
247
248 sprintf (fname,"%s\\%s",LocalManageGraphicsDir,GameVClips[Powerups[n].image_handle].name);
249 SaveVClip (fname,Powerups[n].image_handle);
250 }
251 else
252 {
253 char destname[100],srcname[100];
254
255 sprintf (srcname,"%s\\%s",LocalModelsDir,Poly_models[Powerups[n].image_handle].name);
256 sprintf (destname,"%s\\%s",NetModelsDir,Poly_models[Powerups[n].image_handle].name);
257
258 cf_CopyFile (destname,srcname);
259 }
260
261 OutrageMessageBox ("Powerup checked in.");
262
263 // Delete it from local pagefile if its there
264 int dret=mng_DeletePowPage (Powerups[n].name,1);
265 ASSERT (dret==1);
266 mng_EraseLocker();
267
268 // Free the tracklock
269 int p=mng_FindTrackLock (Powerups[n].name,PAGETYPE_POWERUP);
270 ASSERT (p!=-1);
271 mng_FreeTrackLock (p);
272 UpdateDialog ();
273 }
274 }
275 }
276 #endif
277 }
278
279 // Deletes the current powerup
280 // If the user has it checked out, will delete it from the net pagefile
281 // If its local only, it will get deleted from the local pagefile
282 void CWorldObjectsPowerupDialog::OnDeletePowerup() {
283 #if 0
284 int answer,tl;
285 mngs_Pagelock pl;
286 int n=D3EditState.current_powerup;
287
288 if (Num_powerups<1)
289 return;
290
291 // Check to see if we even have it locked
292 if ((tl=mng_FindTrackLock (Powerups[n].name,PAGETYPE_POWERUP))==-1)
293 {
294 OutrageMessageBox ("This powerup is not yours to delete. Lock first.");
295 return;
296 }
297
298 //Make sure its to be deleted
299 answer=MessageBox ("Are you sure you want to delete this powerup?",Powerups[n].name,MB_YESNO);
300 if (answer==IDNO)
301 return;
302
303 if (!mng_MakeLocker())
304 return;
305
306 strcpy (pl.name,Powerups[n].name);
307 pl.pagetype=PAGETYPE_POWERUP;
308
309 // Check to see if this is a local powerup only. If so, only delete it locally
310 if (mng_CheckIfPageOwned (&pl,TableUser)!=1)
311 {
312 mng_FreeTrackLock (tl);
313 if (!mng_DeletePowPage (Powerups[n].name,1))
314 {
315 mprintf(0,ErrorString);
316 Int3();
317 }
318 }
319 else // if its network, delete it from both the net and local drives
320 {
321 mng_FreeTrackLock (tl);
322 mng_DeletePowPage (Powerups[n].name,1);
323 mng_DeletePowPage (Powerups[n].name,0);
324 mng_DeletePagelock (Powerups[n].name,PAGETYPE_POWERUP);
325 }
326
327 // Advance to the next powerup
328 D3EditState.current_powerup=GetNextPowerup (n);
329
330 if (Powerups[n].flags & PF_IMAGE_BITMAP)
331 FreeVClip (Powerups[n].image_handle);
332 else
333 FreePolyModel (Powerups[n].image_handle);
334
335 FreePowerup (n);
336 mng_EraseLocker();
337 RemapPowerups();
338
339 OutrageMessageBox ("Powerup deleted.");
340 UpdateDialog ();
341 #endif
342 }
343
344 // This functions locks a powerup from the net.
345 void CWorldObjectsPowerupDialog::OnLockPowerup() {
346 #if 0
347 int n=D3EditState.current_powerup;
348 mngs_Pagelock temp_pl;
349 mngs_power_page powpage;
350 int r;
351
352 if (Num_powerups<1)
353 return;
354
355 if (!mng_MakeLocker())
356 return;
357
358 // Make sure it can be locked
359 strcpy (temp_pl.name,Powerups[n].name);
360 temp_pl.pagetype=PAGETYPE_POWERUP;
361
362 r=mng_CheckIfPageLocked (&temp_pl);
363 if (r==2)
364 {
365 int answer;
366 answer=OutrageMessageBox (MBOX_YESNO, "This page is not even in the table file, or the database maybe corrupt. Override to 'Unlocked'? (Select NO if you don't know what you're doing)");
367 if (answer==1)
368 {
369 strcpy (temp_pl.holder,"UNLOCKED");
370 if (!mng_ReplacePagelock (temp_pl.name,&temp_pl))
371 MessageBox (ErrorString,"Error!");
372
373 }
374
375 }
376 else if (r<0)
377 OutrageMessageBox (ErrorString);
378 else if (r==1)
379 OutrageMessageBox (InfoString);
380 else
381 {
382
383 // Everything is ok. Tell the network we're locking it and get a copy to
384 // our local drive
385
386 strcpy (temp_pl.holder,TableUser);
387 if (!mng_ReplacePagelock (temp_pl.name,&temp_pl))
388 {
389 MessageBox (ErrorString,"Error!");
390 mng_EraseLocker();
391 return;
392 }
393 else
394 {
395 // Search thru the net pagefile and get a new copy in RAM in case anyone
396 // changed it since we started the editor
397 if (mng_FindSpecificPowPage (temp_pl.name,&powpage))
398 {
399 if (mng_AssignPowPageToPowerup (&powpage,n))
400 {
401 if (!mng_ReplacePowPage (Powerups[n].name,n,1))
402 {
403 OutrageMessageBox ("There was problem writing that page locally!");
404 mng_EraseLocker();
405 return;
406 }
407 OutrageMessageBox ("Powerup locked.");
408 }
409
410 else
411 OutrageMessageBox ("There was a problem loading this powerup. You might encounter problems in dealing with it. Good luck!");
412
413 mng_AllocTrackLock(Powerups[n].name,PAGETYPE_POWERUP);
414 UpdateDialog ();
415 }
416 else
417 OutrageMessageBox ("Couldn't find that powerup in the table file!");
418 }
419 }
420 mng_EraseLocker();
421
422 #endif
423 }
424
425 // Gets the next powerup and sets it as the current one
426 void CWorldObjectsPowerupDialog::OnNextPowerup() {
427 #if 0
428 D3EditState.current_powerup=GetNextPowerup(D3EditState.current_powerup);
429 UpdateDialog();
430 #endif
431 }
432
433 // Gets the previous powerup and sets it as the current one
434 void CWorldObjectsPowerupDialog::OnPrev() {
435 #if 0
436 D3EditState.current_powerup=GetPrevPowerup(D3EditState.current_powerup);
437 UpdateDialog();
438 #endif
439 }
440
441 // This simply gets a list of all the pages we have checked out
442 void CWorldObjectsPowerupDialog::OnPowerupsOut() {
443 #if 0
444 char str[10000];
445 int total=0;
446
447 mng_DisplayLockList (TableUser);
448
449 sprintf (str,"User %s has these powerups held locally:\n\n",TableUser);
450 for (int i=0;i<MAX_TRACKLOCKS;i++)
451 {
452 if (GlobalTrackLocks[i].used && GlobalTrackLocks[i].pagetype==PAGETYPE_POWERUP)
453 {
454 char temp[90];
455
456 sprintf (temp,"%s",GlobalTrackLocks[i].name);
457 strcat (str,temp);
458 strcat (str,"\n");
459 total++;
460 }
461 }
462
463 if (total!=0)
464 {
465 // Display that string
466 MessageBox (str,"Powerups",MB_OK);
467 }
468
469 #endif
470 }
471
472 // When closing, save all our checked out powerups locally so we know
473 // what stuff to flag as "checked out" the next time we start up
474 void CWorldObjectsPowerupDialog::SavePowerupsOnClose() {
475 #if 0
476 int i,t;
477
478
479 if (!Network_up)
480 return; // don't save a damn thing if the network is down
481
482
483 for (i=0;i<MAX_TRACKLOCKS;i++)
484 {
485 if (GlobalTrackLocks[i].used==1 && GlobalTrackLocks[i].pagetype==PAGETYPE_POWERUP)
486 {
487 t=FindPowerupName(GlobalTrackLocks[i].name);
488 ASSERT (t!=-1);
489 mng_ReplacePowPage (Powerups[t].name,t,1);
490 }
491 }
492 #endif
493 }
494
495 void CWorldObjectsPowerupDialog::OnPaint() {
496 #if 0
497 CPaintDC dc(this); // device context for painting
498
499 UpdateDialog();
500
501 #endif
502 }
503
504 // Redraw the dialog based on our current powerup
505 void CWorldObjectsPowerupDialog::UpdateDialog(void) {
506 #if 0
507 CEdit *ebox;
508 CButton *bbox;
509 int n=D3EditState.current_powerup;
510 char str[50];
511 int i;
512
513 if (!Powerups[n].used)
514 n=D3EditState.current_powerup=GetNextPowerup(n);
515
516 if (Num_powerups<1)
517 {
518 bbox=(CButton *) GetDlgItem (IDC_NEXT_POWERUP);
519 bbox->EnableWindow (FALSE);
520 bbox=(CButton *) GetDlgItem (IDC_PREV);
521 bbox->EnableWindow (FALSE);
522
523 return;
524 }
525 else
526 {
527 bbox=(CButton *) GetDlgItem (IDC_NEXT_POWERUP);
528 bbox->EnableWindow (TRUE);
529 bbox=(CButton *) GetDlgItem (IDC_PREV);
530 bbox->EnableWindow (TRUE);
531 }
532
533 ebox=(CEdit *) GetDlgItem (IDC_POWER_NAME_EDIT);
534 ebox->SetWindowText (Powerups[n].name);
535
536 ebox=(CEdit *) GetDlgItem (IDC_POWER_IMAGE_EDIT);
537
538 if (Powerups[n].flags & PF_IMAGE_BITMAP)
539 ebox->SetWindowText (GameVClips[Powerups[n].image_handle].name);
540 else
541 ebox->SetWindowText (Poly_models[Powerups[n].image_handle].name);
542
543 bbox=(CButton *) GetDlgItem (IDC_CHECKIN);
544 if (mng_FindTrackLock (Powerups[n].name,PAGETYPE_POWERUP)==-1)
545 {
546 bbox->EnableWindow (FALSE);
547 bbox=(CButton *) GetDlgItem (IDC_LOCK_POWERUP);
548 bbox->EnableWindow (TRUE);
549 }
550 else
551 {
552 bbox->EnableWindow (TRUE);
553 bbox=(CButton *) GetDlgItem (IDC_LOCK_POWERUP);
554 bbox->EnableWindow (FALSE);
555 }
556
557 SendDlgItemMessage( IDC_POWERUP_AMBIENT_SOUND_LIST, CB_RESETCONTENT,0,0);
558 for (i=0;i<MAX_SOUNDS;i++)
559 {
560 if (Sounds[i].used)
561 SendDlgItemMessage( IDC_POWERUP_AMBIENT_SOUND_LIST, CB_ADDSTRING,0,(LPARAM) (LPCTSTR) Sounds[i].name);
562 }
563 SendDlgItemMessage( IDC_POWERUP_AMBIENT_SOUND_LIST, CB_SELECTSTRING,0,(LPARAM) (LPCTSTR) Sounds[n].name);
564
565 SendDlgItemMessage( IDC_POWERUP_PICKUP_SOUND_LIST, CB_RESETCONTENT,0,0);
566 for (i=0;i<MAX_SOUNDS;i++)
567 {
568 if (Sounds[i].used)
569 SendDlgItemMessage( IDC_POWERUP_PICKUP_SOUND_LIST, CB_ADDSTRING,0,(LPARAM) (LPCTSTR) Sounds[i].name);
570 }
571 if(Powerups[n].sounds[PSI_PICKUP] >= 0 && Powerups[n].sounds[PSI_PICKUP] < MAX_SOUNDS && Sounds[Powerups[n].sounds[PSI_PICKUP]].used != 0)
572 SendDlgItemMessage( IDC_POWERUP_PICKUP_SOUND_LIST, CB_SELECTSTRING,0,(LPARAM) (LPCTSTR) Sounds[Powerups[n].sounds[PSI_PICKUP]].name);
573 else
574 SendDlgItemMessage( IDC_POWERUP_PICKUP_SOUND_LIST, CB_SELECTSTRING,0,(LPARAM) (LPCTSTR) "\0");
575
576 ebox=(CEdit *) GetDlgItem (IDC_POWERUP_SIZE_EDIT);
577 sprintf (str,"%f",Powerups[n].size);
578 ebox->SetWindowText (str);
579
580 ebox=(CEdit *) GetDlgItem (IDC_POW_MASS_EDIT);
581 sprintf (str,"%f",Powerups[n].phys_info.mass);
582 ebox->SetWindowText (str);
583
584 ebox=(CEdit *) GetDlgItem (IDC_POW_DRAG_EDIT);
585 sprintf (str,"%f",Powerups[n].phys_info.drag);
586 ebox->SetWindowText (str);
587
588 bbox = (CButton *)GetDlgItem(IDC_GRAVITY_CHECK);
589 bbox->SetCheck(Powerups[n].phys_info.flags & PF_GRAVITY);
590
591 // FIXME Editor
592 // bbox = (CButton *)GetDlgItem(IDC_MAGNETISM_CHECK);
593 // bbox->SetCheck(Powerups[n].phys_info.flags & PF_MAGNETISM);
594
595 bbox = (CButton *)GetDlgItem(IDC_WIND_CHECK);
596 bbox->SetCheck(Powerups[n].phys_info.flags & PF_WIND);
597
598 SendDlgItemMessage( IDC_POWER_PULLDOWN, CB_RESETCONTENT,0,0);
599
600 for (i=0;i<MAX_POWERUPS;i++)
601 {
602 if (Powerups[i].used)
603 SendDlgItemMessage( IDC_POWER_PULLDOWN, CB_ADDSTRING,0,(LPARAM) (LPCTSTR) Powerups[i].name);
604 }
605 SendDlgItemMessage( IDC_POWER_PULLDOWN, CB_SELECTSTRING,0,(LPARAM) (LPCTSTR) Powerups[n].name);
606
607 UpdatePowerupView();
608 #endif
609 }
610
611 void CWorldObjectsPowerupDialog::UpdatePowerupView(void) {
612 #if 0
613 int n=D3EditState.current_powerup;
614 CWnd *powwnd;
615 RECT rect;
616 int x, y, bm_handle,w,h;
617 static int frame=0;
618 static int last_powerup=-1;
619 static int last_image_handle=-1;
620
621 if (Num_powerups<1)
622 return;
623
624 frame++;
625
626 powwnd = GetDlgItem(IDC_POWERUPVIEW);
627 powwnd->GetWindowRect(&rect);
628 ScreenToClient(&rect);
629
630 Desktop_surf->attach_to_window((unsigned)m_hWnd);
631
632 w=rect.right-rect.left;
633 h=rect.bottom-rect.top;
634
635 if (last_powerup!=n || last_image_handle!=Powerups[n].image_handle)
636 {
637 Desktop_surf->clear(rect.left,rect.top,w,h);
638 last_powerup=n;
639 last_image_handle=Powerups[n].image_handle;
640 }
641
642 bm_handle=GetPowerupImage (n,frame);
643
644 if (Powerups[n].flags & PF_IMAGE_BITMAP)
645 {
646 m_PowerupSurf.create(bm_w(bm_handle,0), bm_h(bm_handle,0), bm_bpp(bm_handle));
647 m_PowerupSurf.load(bm_handle);
648
649 x = rect.left + ((rect.right-rect.left)/2) - m_PowerupSurf.width()/2;
650 y = rect.top + ((rect.bottom-rect.top)/2) - m_PowerupSurf.height()/2;
651
652 Desktop_surf->blt(x, y, &m_PowerupSurf);
653 m_PowerupSurf.free();
654 }
655 else
656 {
657 vector zero_vector;
658 vector view_vector={0,0,-2};
659 matrix id_matrix,rot_matrix;
660
661 vm_MakeZero (&zero_vector);
662 vm_MakeIdentity (&id_matrix);
663 vm_AnglesToMatrix (&rot_matrix,0,frame*400,0);
664
665 m_PowerupSurf.create(128, 128, BPP_16);
666 grViewport *vport=new grViewport (&m_PowerupSurf);
667 g3_StartFrame (vport,&view_vector,&id_matrix,D3_DEFAULT_ZOOM);
668 DrawPolygonModel (&zero_vector,&rot_matrix,bm_handle,NULL,0,1.0);
669 g3_EndFrame();
670
671 x = rect.left + ((rect.right-rect.left)/2) - m_PowerupSurf.width()/2;
672 y = rect.top + ((rect.bottom-rect.top)/2) - m_PowerupSurf.height()/2;
673 Desktop_surf->blt(x, y, &m_PowerupSurf);
674
675 delete vport;
676 m_PowerupSurf.free();
677 }
678 #endif
679 }
680
681 BOOL CWorldObjectsPowerupDialog::OnInitDialog() {
682
683 CDialog::OnInitDialog();
684
685 CWnd::SetTimer(1, 100, NULL);
686
687 return TRUE; // return TRUE unless you set the focus to a control
688 // EXCEPTION: OCX Property Pages should return FALSE
689 }
690
691 void CWorldObjectsPowerupDialog::OnTimer(UINT nIDEvent) {
692 UpdatePowerupView();
693
694 CDialog::OnTimer(nIDEvent);
695 }
696
697 BOOL CWorldObjectsPowerupDialog::DestroyWindow() {
698
699 SavePowerupsOnClose();
700
701 return CDialog::DestroyWindow();
702 }
703
704 void CWorldObjectsPowerupDialog::OnKillfocusPowerNameEdit() {
705 #if 0
706 CEdit *ebox;
707 int n=D3EditState.current_powerup;
708 char name[PAGENAME_LEN];
709 mngs_Pagelock pl;
710
711 // Make sure we have this powerup locked, if not reset name and bail
712 int p=mng_FindTrackLock (Powerups[n].name,PAGETYPE_POWERUP);
713 if (p==-1)
714 {
715 OutrageMessageBox ("You must lock this powerup if you wish to change its name.");
716 CEdit *ebox=(CEdit *) GetDlgItem (IDC_POWER_NAME_EDIT);
717 ebox->SetWindowText (Powerups[n].name);
718 return;
719 }
720
721 // Get the new name
722 ebox=(CEdit *) GetDlgItem (IDC_POWER_NAME_EDIT);
723 ebox->GetWindowText (name,PAGENAME_LEN);
724
725
726 // Check to see if there is already a powerup with this name. If so, reset and bail
727 if (FindPowerupName(name)!=-1)
728 {
729 OutrageMessageBox ("There already is a powerup with that name...choose another name.");
730
731 CEdit *ebox=(CEdit *) GetDlgItem (IDC_POWER_NAME_EDIT);
732 ebox->SetWindowText (Powerups[n].name);
733 return;
734
735 }
736
737
738 if (!mng_MakeLocker())
739 return;
740
741 // Check to see if this page exists on the network. If so, we have to
742 // rename it so we can prevent havoc
743 strcpy (pl.name,Powerups[n].name);
744 pl.pagetype=PAGETYPE_POWERUP;
745
746 int ret=mng_CheckIfPageOwned (&pl,TableUser);
747 if (ret<0)
748 OutrageMessageBox (ErrorString);
749 else if (ret==1)
750 mng_RenamePage (Powerups[n].name,name,PAGETYPE_POWERUP);
751 else if (ret==2)
752 {
753 // This page has never been checked in, replace only local copy
754
755 char oldname[PAGENAME_LEN];
756 strcpy (oldname,Powerups[n].name);
757 strcpy (Powerups[n].name,name);
758 mng_ReplacePowPage (oldname,n,1);
759 }
760 else if (ret==0)
761 {
762 OutrageMessageBox ("You don't own this page. Get Jason now!");
763 mng_FreeTrackLock (p);
764 return;
765 }
766
767 RemapPowerups();
768
769 // Finally, copy our new name to the appropriate arrays
770 strcpy (GlobalTrackLocks[p].name,name);
771 strcpy (Powerups[n].name,name);
772 UpdateDialog();
773 mng_EraseLocker();
774 #endif
775 }
776
777 void CWorldObjectsPowerupDialog::OnKillfocusPowerupSizeEdit() {
778 #if 0
779 CEdit *ebox;
780 char str[20];
781 int n=D3EditState.current_powerup;
782
783 ebox=(CEdit *) GetDlgItem (IDC_POWERUP_SIZE_EDIT);
784 ebox->GetWindowText (str,20);
785
786 Powerups[n].size=atof (str);
787 #endif
788 }
789
790 void CWorldObjectsPowerupDialog::OnSelendokPowerPulldown() {
791 #if 0
792 int i,cur;
793 char name[200];
794
795 cur=SendDlgItemMessage( IDC_POWER_PULLDOWN, CB_GETCURSEL,0,0);
796 SendDlgItemMessage( IDC_POWER_PULLDOWN, CB_GETLBTEXT,cur,(LPARAM) (LPCTSTR)name);
797
798 i=FindPowerupName (name);
799
800 if (i==-1)
801 {
802 mprintf(0,"Possible corrupted texture list, but probably nothing.");
803 UpdateDialog();
804 }
805
806 D3EditState.current_powerup=i;
807 UpdateDialog();
808 #endif
809 }
810
811 void CWorldObjectsPowerupDialog::OnLoadImage() {
812 #if 0
813 char filename[255];
814 char curname[255];
815 int img_handle;
816 int powerup_handle;
817 int c=1,finding_name=1;
818 int model=0;
819
820 // Get the filename of the representing image
821
822 CString filter = "Descent III files (*.oaf,*.ilf,*.abm,*.pof,*.oof)|*.oaf;*.ifl;*.abm;*.pof;*.oof||";
823
824 CFileDialog dlg_open(TRUE, 0,0, OFN_FILEMUSTEXIST, (LPCTSTR)filter, this);
825
826 if (dlg_open.DoModal() == IDCANCEL) return;
827
828 // Okay, we selected a file. Lets do what needs to be done here.
829
830 strcpy (filename,dlg_open.GetPathName());
831 img_handle=LoadPowerupImage (filename,&model);
832
833 if (img_handle<0)
834 {
835 OutrageMessageBox ("Couldn't open that animation/model file.");
836 return;
837 }
838
839 // If its a 3d model instead of an animation, flag it
840
841 powerup_handle=D3EditState.current_powerup;
842
843 if (!model)
844 Powerups[powerup_handle].flags|=PF_IMAGE_BITMAP;
845 else
846 Powerups[powerup_handle].flags&=~PF_IMAGE_BITMAP;
847
848
849 Powerups[powerup_handle].image_handle=img_handle;
850
851 // Finally, save a local copy of the model/anim and alloc a tracklock
852
853
854 if (model)
855 {
856 sprintf (curname,"%s\\%s",LocalModelsDir,Poly_models[Powerups[powerup_handle].image_handle].name);
857 cf_CopyFile (curname,filename);
858 }
859 else
860 {
861 sprintf (filename,"%s\\%s",LocalManageGraphicsDir,GameVClips[Powerups[powerup_handle].image_handle].name);
862 SaveVClip (filename,Powerups[powerup_handle].image_handle);
863 }
864
865 UpdateDialog();
866 #endif
867 }
868
869 void CWorldObjectsPowerupDialog::OnGravityCheck() {
870 #if 0
871 // TODO: Add your control notification handler code here
872 int n=D3EditState.current_powerup;
873 CButton *btn;
874
875 btn = (CButton *)GetDlgItem(IDC_GRAVITY_CHECK);
876
877 if (btn->GetCheck())
878 Powerups[n].phys_info.flags |= PF_GRAVITY;
879 else
880 Powerups[n].phys_info.flags &= ~PF_GRAVITY;
881 #endif
882 }
883
884 void CWorldObjectsPowerupDialog::OnMagnetismCheck() {
885 #if 0
886 // TODO: Add your control notification handler code here
887 int n=D3EditState.current_powerup;
888 CButton *btn;
889
890 btn = (CButton *)GetDlgItem(IDC_MAGNETISM_CHECK);
891
892 if (btn->GetCheck())
893 Powerups[n].phys_info.flags |= PF_MAGNETISM;
894 else
895 Powerups[n].phys_info.flags &= ~PF_MAGNETISM;
896
897 #endif
898 }
899
900 void CWorldObjectsPowerupDialog::OnWindCheck() {
901 // TODO: Add your control notification handler code here
902 int n = D3EditState.current_powerup;
903 CButton *btn;
904
905 btn = (CButton *)GetDlgItem(IDC_WIND_CHECK);
906
907 if (btn->GetCheck())
908 Powerups[n].phys_info.flags |= PF_WIND;
909 else
910 Powerups[n].phys_info.flags &= ~PF_WIND;
911 }
912
913 void CWorldObjectsPowerupDialog::OnKillfocusPowMassEdit() {
914 // TODO: Add your control notification handler code here
915 CEdit *ebox;
916 char str[20];
917 int n = D3EditState.current_powerup;
918
919 ebox = (CEdit *)GetDlgItem(IDC_POW_MASS_EDIT);
920 ebox->GetWindowText(str, 20);
921
922 Powerups[n].phys_info.mass = atof(str);
923 }
924
925 void CWorldObjectsPowerupDialog::OnKillfocusPowDragEdit() {
926 // TODO: Add your control notification handler code here
927 CEdit *ebox;
928 char str[20];
929 int n = D3EditState.current_powerup;
930
931 ebox = (CEdit *)GetDlgItem(IDC_POW_DRAG_EDIT);
932 ebox->GetWindowText(str, 20);
933
934 Powerups[n].phys_info.drag = atof(str);
935 }
936
937 void CWorldObjectsPowerupDialog::OnSelendokPowerupAmbientSoundList() {
938 // TODO: Add your control notification handler code here
939 }
940
941 void CWorldObjectsPowerupDialog::OnSelendokPowerupPickupSoundList() {
942 // TODO: Add your control notification handler code here
943 int cur;
944 char name[200];
945 int n = D3EditState.current_powerup;
946
947 cur = SendDlgItemMessage(IDC_POWERUP_PICKUP_SOUND_LIST, CB_GETCURSEL, 0, 0);
948 SendDlgItemMessage(IDC_POWERUP_PICKUP_SOUND_LIST, CB_GETLBTEXT, cur, (LPARAM)(LPCTSTR)name);
949
950 Powerups[n].sounds[PSI_PICKUP] = FindSoundName(name);
951 // ASSERT(Powerups[n].sounds[PSI_PICKUP] != -1);
952 }
953
954 BOOL CWorldObjectsPowerupDialog::OnHelpInfo(HELPINFO *pHelpInfo) {
955 // TODO: Add your message handler code here and/or call default
956 WinHelp(HID_POWERUPSDLG, HELP_CONTEXT);
957 return TRUE;
958 // return CDialog::OnHelpInfo(pHelpInfo);
959 }