/** * Do cleanup when leaving a mission */ void training_mission_shutdown() { int i; if (Training_voice >= 0) { if (Training_voice_type) { audiostream_close_file(Training_voice_handle, 0); } else { snd_stop(Training_voice_handle); } } // Goober5000 for (i = 0; i < TRAINING_MESSAGE_QUEUE_MAX; i++) { if (Training_message_queue[i].special_message != NULL) { vm_free(Training_message_queue[i].special_message); Training_message_queue[i].special_message = NULL; } } Training_voice = -1; Training_num_lines = Training_obj_num_lines = 0; *Training_buf = 0; }
// close void loop_brief_close() { // this makes sure that we're all cool no matter how the user decides to exit mission_campaign_mission_over(); // free the bitmap if (Loop_brief_bitmap >= 0){ bm_release(Loop_brief_bitmap); } Loop_brief_bitmap = -1; // destroy the window Loop_brief_window.destroy(); if (Loop_anim.num_frames > 0) { generic_anim_unload(&Loop_anim); } // stop voice if(Loop_sound != -1){ audiostream_stop(Loop_sound, 1, 0); audiostream_close_file(Loop_sound, 1); Loop_sound = -1; } fsspeech_stop(); // stop music common_music_close(); }
void send_autopilot_msg(char *msg, char *snd) { // setup if (audio_handle != -1) { audiostream_close_file(audio_handle, 0); audio_handle = -1; } if (msg[0] != '\0' && strcmp(msg, "none")) change_message("autopilot builtin message", msg, -1, 0); // load sound if ((snd != NULL) && (snd[0] != '\0' && !strcmp(snd, "none"))) { audio_handle = audiostream_open(snd, ASF_MENUMUSIC ); } // send/play if (audio_handle != -1) { audiostream_play(audio_handle, (Master_event_music_volume * aav_music_volume), 0); } if (msg[0] != '\0' && strcmp(msg, "none")) message_training_queue("autopilot builtin message", timestamp(0), 5); // display message for five seconds }
void cmd_brief_close() { int i; if (Cmd_brief_inited) { cmd_brief_stop_anim(); generic_anim_unload(&Cur_Anim); for (i=0; i<Cur_cmd_brief->num_stages; i++) { if (Cur_cmd_brief->stage[i].wave >= 0) audiostream_close_file(Cur_cmd_brief->stage[i].wave, 0); } // so that the same ani will reload properly upon return Cur_anim_filename = "~~~~"; if (Cmd_brief_background_bitmap >= 0) bm_release(Cmd_brief_background_bitmap); // unload the overlay bitmap help_overlay_unload(CMD_BRIEF_OVERLAY); Ui_window.destroy(); game_flush(); Cmd_brief_inited = 0; } // Stop any speech from running over fsspeech_stop(); }
void credits_stop_music(bool fade) { if ( Credits_music_handle != -1 ) { audiostream_close_file(Credits_music_handle, fade); Credits_music_handle = -1; } }
void cmd_brief_dlg::OnDeleteStage() { int i, z; if (m_cur_stage < 0) return; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; Assert(Cur_cmd_brief->num_stages); z = m_cur_stage; m_cur_stage = -1; update_data(1); Cur_cmd_brief->stage[z].text = ""; for (i=z+1; i<Cur_cmd_brief->num_stages; i++) Cur_cmd_brief->stage[i-1] = Cur_cmd_brief->stage[i]; Cur_cmd_brief->num_stages--; m_cur_stage = z; m_last_stage = -1; if (m_cur_stage >= Cur_cmd_brief->num_stages) m_cur_stage = Cur_cmd_brief->num_stages - 1; update_data(0); }
void cmd_brief_dlg::OnInsertStage() { int i, z; if (Cur_cmd_brief->num_stages >= CMD_BRIEF_STAGES_MAX) return; if (!Cur_cmd_brief->num_stages) { OnAddStage(); return; } audiostream_close_file(m_wave_id, 0); m_wave_id = -1; z = m_cur_stage; m_cur_stage = -1; update_data(1); for (i=Cur_cmd_brief->num_stages; i>z; i--) Cur_cmd_brief->stage[i] = Cur_cmd_brief->stage[i - 1]; Cur_cmd_brief->num_stages++; copy_stage(z, z + 1); m_cur_stage = z; m_last_stage = -1; update_data(0); }
void event_editor::OnBrowseWave() { int z; CString name; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; UpdateData(TRUE); if (!stricmp(m_wave_filename, "<None>")) m_wave_filename = _T(""); if (The_mission.game_type & MISSION_TYPE_TRAINING) z = cfile_push_chdir(CF_TYPE_VOICE_TRAINING); else z = cfile_push_chdir(CF_TYPE_VOICE_SPECIAL); CFileDialog dlg(TRUE, "wav", m_wave_filename, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "Voice Files (*.ogg, *.wav)|*.ogg;*.wav|Ogg Vorbis Files (*.ogg)|*.ogg|Wave Files (*.wav)|*.wav||"); if (dlg.DoModal() == IDOK) { m_wave_filename = dlg.GetFileName(); update_persona(); } if (!z){ cfile_pop_dir(); } }
void SoundEnvironment::OnBrowseWave() { int z; if (m_wave_id >= 0) { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; } UpdateData(TRUE); m_wave_filename = _T(""); z = cfile_push_chdir(CF_TYPE_DATA); CFileDialog dlg(TRUE, "wav", m_wave_filename, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "Voice Files (*.ogg, *.wav)|*.ogg;*.wav|Ogg Vorbis Files (*.ogg)|*.ogg|Wave Files (*.wav)|*.wav||"); if (dlg.DoModal() == IDOK) { m_wave_filename = dlg.GetFileName(); m_wave_id = audiostream_open((char *)(LPCSTR) m_wave_filename, ASF_SOUNDFX); } if ( !z ) { cfile_pop_dir(); } }
// close all the briefing voice streams void red_alert_voice_unload() { if ( Red_alert_voice != -1 ) { audiostream_close_file(Red_alert_voice, 0); Red_alert_voice = -1; } }
BOOL cmd_brief_dlg::DestroyWindow() { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; m_play_bm.DeleteObject(); return CDialog::DestroyWindow(); }
void cmd_brief_dlg::OnOK() { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; update_data(); CDialog::OnOK(); }
BOOL event_editor::DestroyWindow() { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; m_play_bm.DeleteObject(); return CDialog::DestroyWindow(); }
void cmd_brief_dlg::OnPrev() { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; m_cur_stage--; update_data(); }
// this is called the clicking the ID_CANCEL button void event_editor::On_Cancel() { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; theApp.record_window_data(&Events_wnd_data, this); delete Event_editor_dlg; Event_editor_dlg = NULL; }
BOOL SoundEnvironment::DestroyWindow() { sound_env_disable(); audiostream_close_file(m_wave_id, 0); m_wave_id = -1; m_play_bm.DeleteObject(); return CDialog::DestroyWindow(); }
void audiostream_close_all(int fade) { int i; for ( i = 0; i < MAX_AUDIO_STREAMS; i++ ) { if ( Audio_streams[i].status == ASF_FREE ) continue; audiostream_close_file(i, fade); } }
void cmd_brief_dlg::OnAddStage() { int i; if (Cur_cmd_brief->num_stages >= CMD_BRIEF_STAGES_MAX) return; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; m_cur_stage = i = Cur_cmd_brief->num_stages++; copy_stage(i - 1, i); update_data(1); }
// called to do cleanup when leaving a mission void training_mission_shutdown() { if (Training_voice >= 0) { if (Training_voice_type) { audiostream_close_file(Training_voice_handle, 0); } else { snd_stop(Training_voice_handle); } } Training_voice = -1; Training_num_lines = Training_obj_num_lines = 0; *Training_text = 0; }
void event_editor::OnPlay() { GetDlgItem(IDC_WAVE_FILENAME)->GetWindowText(m_wave_filename); if (m_wave_id >= 0) { audiostream_close_file(m_wave_id, 0); m_wave_id = -1; return; } // we use ASF_EVENTMUSIC here so that it will keep the extension in place m_wave_id = audiostream_open((char *)(LPCSTR) m_wave_filename, ASF_EVENTMUSIC); if (m_wave_id >= 0) { audiostream_play(m_wave_id, 1.0f, 0); } }
void event_editor::OnSelchangeWaveFilename() { int z; CComboBox *box; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; box = (CComboBox *) GetDlgItem(IDC_WAVE_FILENAME); z = box -> GetCurSel(); UpdateData(TRUE); UpdateData(TRUE); box -> GetLBText(z, m_wave_filename); UpdateData(FALSE); update_persona(); }
void fiction_viewer_reset() { if (Fiction_viewer_text != NULL) vm_free(Fiction_viewer_text); Fiction_viewer_text = NULL; *Fiction_viewer_filename = 0; *Fiction_viewer_font_filename = 0; *Fiction_viewer_voice_filename = 0; Top_fiction_viewer_text_line = 0; if (Fiction_viewer_voice >= 0) { audiostream_close_file(Fiction_viewer_voice); Fiction_viewer_voice = -1; } }
void cmd_brief_dlg::OnBrowseWave() { int z; CString name; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; UpdateData(TRUE); z = cfile_push_chdir(CF_TYPE_VOICE_CMD_BRIEF); CFileDialog dlg(TRUE, "wav", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "Voice Files (*.ogg, *.wav)|*.ogg;*.wav|Ogg Vorbis Files (*.ogg)|*.ogg|Wave Files (*.wav)|*.wav||"); if (dlg.DoModal() == IDOK) { m_wave_filename = dlg.GetFileName(); UpdateData(FALSE); } if (!z) cfile_pop_dir(); }
void event_editor::OnClose() { int z; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; if (query_modified()) { z = MessageBox("Do you want to keep your changes?", "Close", MB_ICONQUESTION | MB_YESNOCANCEL); if (z == IDCANCEL){ return; } if (z == IDYES) { OnOk(); return; } } theApp.record_window_data(&Events_wnd_data, this); delete Event_editor_dlg; Event_editor_dlg = NULL; }
// load controls with structure data void event_editor::update_cur_message() { int enable = TRUE; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; if (m_cur_msg < 0) { enable = FALSE; m_message_name = _T(""); m_message_text = _T(""); m_avi_filename = _T(""); m_wave_filename = _T(""); m_persona = 0; m_message_team = -1; } else { m_message_name = m_messages[m_cur_msg].name; m_message_text = m_messages[m_cur_msg].message; if (m_messages[m_cur_msg].avi_info.name){ m_avi_filename = _T(m_messages[m_cur_msg].avi_info.name); } else { m_avi_filename = _T("<None>"); } if (m_messages[m_cur_msg].wave_info.name){ m_wave_filename = _T(m_messages[m_cur_msg].wave_info.name); } else { m_wave_filename = _T("<None>"); } // add persona id if ( m_messages[m_cur_msg].persona_index != -1 ){ m_persona = m_messages[m_cur_msg].persona_index + 1; // add one for the "none" at the beginning of the list } else { m_persona = 0; } if(m_messages[m_cur_msg].multi_team >= MAX_TVT_TEAMS){ m_message_team = -1; m_messages[m_cur_msg].multi_team = -1; } else { m_message_team = m_messages[m_cur_msg].multi_team; } /* m_event_num = find_event(); if (m_event_num < 0) { node = -1; m_sender = m_priority = 0; } else node = CADR(Mission_events[m_event_num].formula); */ } GetDlgItem(IDC_MESSAGE_NAME)->EnableWindow(enable); GetDlgItem(IDC_MESSAGE_TEXT)->EnableWindow(enable); GetDlgItem(IDC_AVI_FILENAME)->EnableWindow(enable); GetDlgItem(IDC_BROWSE_AVI)->EnableWindow(enable); GetDlgItem(IDC_BROWSE_WAVE)->EnableWindow(enable); GetDlgItem(IDC_WAVE_FILENAME)->EnableWindow(enable); GetDlgItem(IDC_DELETE_MSG)->EnableWindow(enable); GetDlgItem(IDC_PERSONA_NAME)->EnableWindow(enable); GetDlgItem(IDC_MESSAGE_TEAM)->EnableWindow(enable); UpdateData(FALSE); }
void event_editor::OnOk() { char buf[256], names[2][MAX_MISSION_EVENTS][NAME_LENGTH]; int i, count; audiostream_close_file(m_wave_id, 0); m_wave_id = -1; save(); if (query_modified()) set_modified(); for (i=0; i<Num_mission_events; i++) { free_sexp2(Mission_events[i].formula); if (Mission_events[i].objective_text) free(Mission_events[i].objective_text); if (Mission_events[i].objective_key_text) free(Mission_events[i].objective_key_text); } count = 0; for (i=0; i<Num_mission_events; i++) Mission_events[i].result = 0; // use this as a processed flag // rename all sexp references to old events for (i=0; i<m_num_events; i++) if (m_sig[i] >= 0) { strcpy_s(names[0][count], Mission_events[m_sig[i]].name); strcpy_s(names[1][count], m_events[i].name); count++; Mission_events[m_sig[i]].result = 1; } // invalidate all sexp references to deleted events. for (i=0; i<Num_mission_events; i++) if (!Mission_events[i].result) { sprintf(buf, "<%s>", Mission_events[i].name); strcpy(buf + NAME_LENGTH - 2, ">"); // force it to be not too long strcpy_s(names[0][count], Mission_events[i].name); strcpy_s(names[1][count], buf); count++; } Num_mission_events = m_num_events; for (i=0; i<m_num_events; i++) { Mission_events[i] = m_events[i]; Mission_events[i].formula = m_event_tree.save_tree(m_events[i].formula); Mission_events[i].objective_text = m_events[i].objective_text; Mission_events[i].objective_key_text = m_events[i].objective_key_text; Mission_events[i].mission_log_flags = m_events[i].mission_log_flags; } // now update all sexp references while (count--) update_sexp_references(names[0][count], names[1][count], OPF_EVENT_NAME); for (i=Num_builtin_messages; i<Num_messages; i++) { if (Messages[i].avi_info.name) free(Messages[i].avi_info.name); if (Messages[i].wave_info.name) free(Messages[i].wave_info.name); } Num_messages = m_num_messages + Num_builtin_messages; for (i=0; i<m_num_messages; i++) Messages[i + Num_builtin_messages] = m_messages[i]; theApp.record_window_data(&Events_wnd_data, this); delete Event_editor_dlg; Event_editor_dlg = NULL; }
// plays the voice file associated with a training message. Automatically streams the file // from disk if it's over 100k, otherwise plays it as a normal file in memory. Returns -1 // if it didn't play, otherwise index of voice int message_play_training_voice(int index) { int len; CFILE *fp; if (index < 0) { if (Training_voice >= 0) { if (Training_voice_type) { audiostream_close_file(Training_voice_handle, 0); } else { snd_stop(Training_voice_handle); } } Training_voice = -1; return -1; } if (Message_waves[index].num < 0) { fp = cfopen(Message_waves[index].name, "rb"); if (!fp) return -1; len = cfilelength(fp); cfclose(fp); if (len > 100000) { if ((Training_voice < 0) || !Training_voice_type || (Training_voice != index)) { if (Training_voice >= 0) { if (Training_voice_type) { if (Training_voice == index) audiostream_stop(Training_voice_handle, 1, 0); else audiostream_close_file(Training_voice_handle, 0); } else { snd_stop(Training_voice_handle); } } if (stricmp(Message_waves[index].name, NOX("none.wav"))) { Training_voice_handle = audiostream_open(Message_waves[index].name, ASF_VOICE); if (Training_voice_handle < 0) { nprintf(("Warning", "Unable to load voice file %s\n", Message_waves[index].name)); // Warning(LOCATION, "Unable to load voice file %s\n", Message_waves[index].name); } } } // Training_voice should be valid and loaded now Training_voice_type = 1; if (Training_voice_handle >= 0) audiostream_play(Training_voice_handle, Master_voice_volume, 0); Training_voice = index; return Training_voice; } else { game_snd tmp_gs; memset(&tmp_gs, 0, sizeof(game_snd)); strcpy(tmp_gs.filename, Message_waves[index].name); Message_waves[index].num = snd_load(&tmp_gs, 0); if (Message_waves[index].num < 0) { nprintf(("Warning", "Cannot load message wave: %s. Will not play\n", Message_waves[index].name)); return -1; } } } if (Training_voice >= 0) { if (Training_voice_type) { audiostream_close_file(Training_voice_handle, 0); } else { snd_stop(Training_voice_handle); } } Training_voice = index; if (Message_waves[index].num >= 0) Training_voice_handle = snd_play_raw(Message_waves[index].num, 0.0f); else Training_voice_handle = -1; Training_voice_type = 0; return Training_voice; }