Exemplo n.º 1
0
// start playback of the red alert voice
void red_alert_voice_play()
{
	if ( !Briefing_voice_enabled ) {
		return;
	}

	if ( Red_alert_voice < 0 ) {
		// play simulated speech?
		if (fsspeech_play_from(FSSPEECH_FROM_BRIEFING)) {
			if (fsspeech_playing()) {
				return;
			}

			fsspeech_play(FSSPEECH_FROM_BRIEFING, Briefing->stages[0].text.c_str());
			Red_alert_voice_started = 1;
		}
	} else {
		if (audiostream_is_playing(Red_alert_voice)) {
			return;
		}

		audiostream_play(Red_alert_voice, Master_voice_volume, 0);
		Red_alert_voice_started = 1;
	}
}
Exemplo n.º 2
0
void techroom_select_new_entry()
{
	Assert(Current_list != NULL);
	if (Current_list == NULL || Current_list_size <= 0) {
		Cur_entry_index = Cur_entry = -1;
		techroom_init_desc(NULL,0);
		return;
	}

	Cur_entry_index = Current_list[Cur_entry].index;
	Assert( Cur_entry_index >= 0 );

	// if we are in the ships tab, load the ship model
	if (Tab == SHIPS_DATA_TAB) {
		ship_info *sip = &Ship_info[Cur_entry_index];

		// little memory management, kinda hacky but it should keep the techroom at around
		// 100meg rather than the 700+ it can get to with all ships loaded - taylor
		for (int i=0; i<Current_list_size; i++) {
			if ((Current_list[i].model_num > -1) && (Current_list[i].textures_loaded)) {
				// don't unload any spot within 5 of current
				if ( (i < Cur_entry + 5) && (i > Cur_entry - 5) )
					continue;

				mprintf(("TECH ROOM: Dumping excess ship textures...\n"));

				model_page_out_textures(Current_list[i].model_num);

				Current_list[i].textures_loaded = 0;
			}
		}

		Techroom_ship_modelnum = model_load(sip->pof_file, sip->n_subsystems, &sip->subsystems[0]);

		Current_list[Cur_entry].model_num = Techroom_ship_modelnum;

		// page in ship textures properly (takes care of nondimming pixels)
		model_page_in_textures(Techroom_ship_modelnum, Cur_entry_index);

		Current_list[Cur_entry].textures_loaded = 1;
	} else {
		Techroom_ship_modelnum = -1;
		Trackball_mode = 0;

		// load animation here, we now only have one loaded
		int stream_result = generic_anim_init_and_stream(&Current_list[Cur_entry].animation, Current_list[Cur_entry].tech_anim_filename, bm_get_type(Tech_background_bitmap), true);

		if (stream_result >= 0) {
			Current_list[Cur_entry].has_anim = 1;
		} else {
			// we've failed to load any animation
			// load an image and treat it like a 1 frame animation
			Current_list[Cur_entry].bitmap = bm_load(Current_list[Cur_entry].tech_anim_filename);
		}
	}

	techroom_init_desc(Current_list[Cur_entry].desc, Tech_desc_coords[gr_screen.res][SHIP_W_COORD]);
	fsspeech_play(FSSPEECH_FROM_TECHROOM, Current_list[Cur_entry].desc);
}
Exemplo n.º 3
0
// display ingame,inmission message text
void multi_msg_display_mission_text(const char *msg, int player_index)
{
	// play a cue voice sound and text to speech if not from this player
	if(Net_players[player_index].player_id != MY_NET_PLAYER_NUM) {
		snd_play(&Snds[MULTI_MSG_TEXT_SOUND]);
		fsspeech_play(FSSPEECH_FROM_MULTI, msg);
	}

	if(MULTI_STANDALONE(Net_players[player_index])){
		HUD_sourced_printf(HUD_SOURCE_NETPLAYER,"%s %s",XSTR("<SERVER>", 698), msg);			
	} else {
		HUD_sourced_printf(HUD_SOURCE_NETPLAYER,"%s: %s", Net_players[player_index].m_player->callsign, msg);			
	}
}
// init
void loop_brief_init()
{
	int idx;
	ui_button_info *b;

	// load the background bitmap
	Loop_brief_bitmap = bm_load(Loop_brief_fname[gr_screen.res]);
	Assert(Loop_brief_bitmap != -1);

	// window
	Loop_brief_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0);
	Loop_brief_window.set_mask_bmap(Loop_brief_mask[gr_screen.res]);	

	// add the buttons
	for (idx=0; idx<NUM_LOOP_BRIEF_BUTTONS; idx++) {
		b = &Loop_buttons[gr_screen.res][idx];

		b->button.create(&Loop_brief_window, "", b->x, b->y, 60, 30, 0, 1);		
		b->button.set_highlight_action(common_play_highlight_sound);
		b->button.set_bmaps(b->filename);
		b->button.link_hotspot(b->hotspot);
	}

	// add text
	for(idx=0; idx<NUM_LOOP_TEXT; idx++){
		Loop_brief_window.add_XSTR(&Loop_text[gr_screen.res][idx]);
	}

	const char* anim_name;
	// load animation if any
	if(Campaign.missions[Campaign.current_mission].mission_branch_brief_anim != NULL){
		anim_name = Campaign.missions[Campaign.current_mission].mission_branch_brief_anim;
	} else {
		anim_name = "CB_default";
	}

	int stream_result = generic_anim_init_and_stream(&Loop_anim, anim_name, bm_get_type(Loop_brief_bitmap), true);
	// we've failed to load any animation
	if (stream_result < 0) {
		// load an image and treat it like a 1 frame animation
		Loop_anim.first_frame = bm_load(anim_name);	//if we fail here, the value is still -1
		if(Loop_anim.first_frame != -1) {
			Loop_anim.num_frames = 1;
		}
	}

	// init brief text
	if(Campaign.missions[Campaign.current_mission].mission_branch_desc != NULL){
		brief_color_text_init(Campaign.missions[Campaign.current_mission].mission_branch_desc, Loop_brief_text_coords[gr_screen.res][2], default_loop_briefing_color);
	}

	bool sound_played = false;


	// open sound
	if(Campaign.missions[Campaign.current_mission].mission_branch_brief_sound != NULL){
		Loop_sound = audiostream_open(Campaign.missions[Campaign.current_mission].mission_branch_brief_sound, ASF_VOICE);

		if(Loop_sound != -1){
			audiostream_play(Loop_sound, Master_voice_volume, 0);
			sound_played = true;
		}
	}

	if(sound_played == false) {
		fsspeech_play(FSSPEECH_FROM_BRIEFING, 
			Campaign.missions[Campaign.current_mission].mission_branch_desc);

	}

	// music
	common_music_init(SCORE_BRIEFING);
}
/**
 * Start playback of the voice for a particular briefing stage
 * @param stage_num Particular briefing stage
 */
void cmd_brief_voice_play(int stage_num)
{
	int voice = -1;
	int stage = -1;

	if (!Voice_good_to_go) {
		Voice_started_time = 0;
		return;
	}

	if (!Voice_started_time) {
		Voice_started_time = timer_get_milliseconds();
		Voice_ended_time = 0;
	}

	if (!Briefing_voice_enabled){
		return;
	}

	if (Cur_stage >= 0 && Cur_stage < Cur_cmd_brief->num_stages){
		voice = Cur_cmd_brief->stage[stage_num].wave;
		stage = stage_num;
	}

	// do we need to play simulated speech?
	if (voice < 0 && fsspeech_play_from(FSSPEECH_FROM_BRIEFING)) {
		// are we still on the same stage?
		if (Cmd_brief_last_stage == stage) {
			return;  // no changes, nothing to do.
		}

		// if previous stage is still playing, stop it first.
		if (Cmd_brief_last_stage >= 0) {
			fsspeech_stop();
			Cmd_brief_last_stage = -1;
		}

		// ok, new text needs speaking
		Cmd_brief_last_stage = stage;
		if (stage >= 0) {
			fsspeech_play(FSSPEECH_FROM_BRIEFING, Cur_cmd_brief->stage[stage_num].text.c_str());
		}
	} else {
		// are we still on same voice that is currently playing/played?
		if (Cmd_brief_last_voice == voice) {
			return;  // no changes, nothing to do.
		}

		// if previous wave is still playing, stop it first.
		if (Cmd_brief_last_voice >= 0) {
			audiostream_stop(Cmd_brief_last_voice, 1, 0);  // stream is automatically rewound
			Cmd_brief_last_voice = -1;
		}

		// ok, new wave needs playing, so we can start playing it now (and it becomes the current wave)
		Cmd_brief_last_voice = voice;
		if (voice >= 0) {
			audiostream_play(voice, Master_voice_volume, 0);
		}
	}
}