Deletes the currently selected audio taunt
| 3474 | |
| 3475 | // Deletes the currently selected audio taunt |
| 3476 | void ShipSelectDeleteTaunt(pilot *Pilot, tCustomListInfo *cust_snds, newuiComboBox *lb, |
| 3477 | tAudioTauntComboBoxes *taunt_boxes) { |
| 3478 | ASSERT(Pilot); |
| 3479 | ASSERT(cust_snds); |
| 3480 | ASSERT(taunt_boxes); |
| 3481 | |
| 3482 | int selected_index = lb->GetCurrentIndex(); |
| 3483 | char custom_filename[384]; |
| 3484 | char custom_logoname[384]; |
| 3485 | |
| 3486 | // check for None selected |
| 3487 | if (selected_index == 0) { |
| 3488 | mprintf(0, "Listbox selected item is None\n"); |
| 3489 | return; |
| 3490 | } |
| 3491 | |
| 3492 | lb->GetItem(selected_index, custom_logoname, 384); |
| 3493 | |
| 3494 | // Get the filename |
| 3495 | char *p = GetStringInList(selected_index - 1, cust_snds->files, cust_snds->needed_size); |
| 3496 | if (p) { |
| 3497 | strncpy(custom_filename, p, 383); |
| 3498 | custom_filename[383] = '\0'; |
| 3499 | } else { |
| 3500 | mprintf(0, "Listbox selected item not found\n"); |
| 3501 | Int3(); |
| 3502 | return; |
| 3503 | } |
| 3504 | |
| 3505 | // delete custom_filename, we don't want it.... |
| 3506 | char buffer[512]; |
| 3507 | snprintf(buffer, sizeof(buffer), TXT_PLTOKDEL, custom_logoname); |
| 3508 | if (DoMessageBox(TXT_PLTDELCONF, buffer, MSGBOX_YESNO, UICOL_WINDOW_TITLE, UICOL_TEXT_NORMAL)) { |
| 3509 | mprintf(0, "Deleting audio taunt %s (%s)\n", custom_logoname, custom_filename); |
| 3510 | |
| 3511 | char olddir[_MAX_PATH]; |
| 3512 | ddio_GetWorkingDir(olddir, _MAX_PATH); |
| 3513 | ddio_SetWorkingDir(LocalCustomSoundsDir); |
| 3514 | if (ddio_DeleteFile(custom_filename)) { |
| 3515 | // Update the list boxes, select none |
| 3516 | UpdateAudioTauntBoxes(cust_snds, taunt_boxes->taunt_a, taunt_boxes->taunt_b, taunt_boxes->taunt_c, |
| 3517 | taunt_boxes->taunt_d, Pilot); |
| 3518 | } else { |
| 3519 | mprintf(0, "Unable to delete file %s\n", custom_filename); |
| 3520 | Int3(); |
| 3521 | } |
| 3522 | ddio_SetWorkingDir(olddir); |
| 3523 | } |
| 3524 | } |
| 3525 | |
| 3526 | void UI3DWindow::OnDraw() { |
| 3527 | AudioStream::Frame(); |
no test coverage detected