UpdateAudioTauntBoxes Resets and updates the list of audio taunt combo boxes
| 2575 | // |
| 2576 | // Resets and updates the list of audio taunt combo boxes |
| 2577 | void UpdateAudioTauntBoxes(tCustomListInfo *cust_snds, newuiComboBox *audio1_list, newuiComboBox *audio2_list, |
| 2578 | newuiComboBox *audio3_list, newuiComboBox *audio4_list, pilot *Pilot) { |
| 2579 | ASSERT(audio1_list); |
| 2580 | ASSERT(audio2_list); |
| 2581 | |
| 2582 | audio1_list->RemoveAll(); |
| 2583 | audio2_list->RemoveAll(); |
| 2584 | audio3_list->RemoveAll(); |
| 2585 | audio4_list->RemoveAll(); |
| 2586 | |
| 2587 | // free up allocated memory |
| 2588 | cust_snds->Reset(); |
| 2589 | |
| 2590 | // Get all the audio files and put them into the lists |
| 2591 | cust_snds->needed_size = GetCustomSoundFiles(); |
| 2592 | if (cust_snds->needed_size) |
| 2593 | cust_snds->files = (char *)mem_malloc(cust_snds->needed_size); |
| 2594 | else |
| 2595 | cust_snds->files = NULL; |
| 2596 | |
| 2597 | int audio_count; |
| 2598 | |
| 2599 | GetCustomSoundFiles(cust_snds->files, cust_snds->needed_size, &audio_count); |
| 2600 | |
| 2601 | int len; |
| 2602 | |
| 2603 | // Add <None> to both boxes |
| 2604 | audio1_list->AddItem(TXT_LBNONE); |
| 2605 | audio2_list->AddItem(TXT_LBNONE); |
| 2606 | audio3_list->AddItem(TXT_LBNONE); |
| 2607 | audio4_list->AddItem(TXT_LBNONE); |
| 2608 | |
| 2609 | int count = 0; |
| 2610 | |
| 2611 | char paudio1[PAGENAME_LEN], paudio2[PAGENAME_LEN]; |
| 2612 | char paudio3[PAGENAME_LEN], paudio4[PAGENAME_LEN]; |
| 2613 | Pilot->get_multiplayer_data(NULL, paudio1, paudio2, NULL, paudio3, paudio4); |
| 2614 | |
| 2615 | for (int i = 0; i < audio_count; i++) { |
| 2616 | char tfn[_MAX_PATH]; |
| 2617 | len = strlen(&cust_snds->files[count]); |
| 2618 | StripCRCFileName(&cust_snds->files[count], tfn); |
| 2619 | |
| 2620 | audio1_list->AddItem((char *)(tfn)); |
| 2621 | audio2_list->AddItem((char *)(tfn)); |
| 2622 | audio3_list->AddItem((char *)(tfn)); |
| 2623 | audio4_list->AddItem((char *)(tfn)); |
| 2624 | |
| 2625 | if (!stricmp(paudio1, &cust_snds->files[count])) { |
| 2626 | // set this as selected index for audio #1 |
| 2627 | audio1_list->SetCurrentIndex(i + 1); |
| 2628 | } |
| 2629 | if (!stricmp(paudio2, &cust_snds->files[count])) { |
| 2630 | // set this as selected index for audio #2 |
| 2631 | audio2_list->SetCurrentIndex(i + 1); |
| 2632 | } |
| 2633 | if (!stricmp(paudio3, &cust_snds->files[count])) { |
| 2634 | // set this as selected index for audio #1 |
no test coverage detected