MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ShipSelectDeleteLogo

Function ShipSelectDeleteLogo

Descent3/pilot.cpp:3428–3473  ·  view source on GitHub ↗

Deletes the currently selected ship logo

Source from the content-addressed store, hash-verified

3426
3427// Deletes the currently selected ship logo
3428void ShipSelectDeleteLogo(tCustomListInfo *cust_bmps, newuiListBox *lb) {
3429 ASSERT(lb);
3430 ASSERT(cust_bmps);
3431
3432 int selected_index = lb->GetCurrentIndex();
3433 char custom_filename[384];
3434 char custom_logoname[384];
3435
3436 // check for None selected
3437 if (selected_index == 0) {
3438 mprintf(0, "Listbox selected item is None\n");
3439 return;
3440 }
3441
3442 lb->GetItem(selected_index, custom_logoname, 384);
3443
3444 // Get the filename
3445 char *p = GetStringInList(selected_index - 1, cust_bmps->files, cust_bmps->needed_size);
3446 if (p) {
3447 strncpy(custom_filename, p, 383);
3448 custom_filename[383] = '\0';
3449 } else {
3450 mprintf(0, "Listbox selected item not found\n");
3451 Int3();
3452 return;
3453 }
3454
3455 // delete custom_filename, we don't want it....
3456 char buffer[512];
3457 snprintf(buffer, sizeof(buffer), TXT_PLTOKDEL, custom_logoname);
3458 if (DoMessageBox(TXT_PLTDELCONF, buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) {
3459 mprintf(0, "Deleting pilot logo %s (%s)\n", custom_logoname, custom_filename);
3460
3461 char olddir[_MAX_PATH];
3462 ddio_GetWorkingDir(olddir, _MAX_PATH);
3463 ddio_SetWorkingDir(LocalCustomGraphicsDir);
3464 if (ddio_DeleteFile(custom_filename)) {
3465 // Update the list box, select none
3466 UpdateGraphicsListbox(cust_bmps, lb, NULL);
3467 } else {
3468 mprintf(0, "Unable to delete file %s\n", custom_filename);
3469 Int3();
3470 }
3471 ddio_SetWorkingDir(olddir);
3472 }
3473}
3474
3475// Deletes the currently selected audio taunt
3476void ShipSelectDeleteTaunt(pilot *Pilot, tCustomListInfo *cust_snds, newuiComboBox *lb,

Callers 1

PltSelectShipFunction · 0.85

Calls 8

GetStringInListFunction · 0.85
DoMessageBoxFunction · 0.85
UpdateGraphicsListboxFunction · 0.85
GetCurrentIndexMethod · 0.80
ddio_GetWorkingDirFunction · 0.50
ddio_SetWorkingDirFunction · 0.50
ddio_DeleteFileFunction · 0.50
GetItemMethod · 0.45

Tested by

no test coverage detected