| 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(), |
nothing calls this directly
no test coverage detected