void cmd_brief_new_stage(int stage) { if (stage < 0) { cmd_brief_stop_anim(); Cur_stage = -1; } Cur_stage = stage; brief_color_text_init(Cur_cmd_brief->stage[stage].text.c_str(), Cmd_text_wnd_coords[Uses_scroll_buttons][gr_screen.res][CMD_W_COORD]); // load a new animation if it's different to what's already playing if (strcmp(Cur_anim_filename, Cur_cmd_brief->stage[stage].ani_filename) != 0) { // unload the previous anim if(Cur_Anim.num_frames > 0) { generic_anim_unload(&Cur_Anim); } // save new filename Cur_anim_filename = Cur_cmd_brief->stage[stage].ani_filename; // try to load the new anim in either high or low res int stream_result = generic_anim_init_and_stream(&Cur_Anim, Cur_anim_filename, bm_get_type(Cmd_brief_background_bitmap), true); // we've failed to load any animation if (stream_result < 0) { // load an image and treat it like a 1 frame animation Cur_Anim.first_frame = bm_load(Cur_cmd_brief->stage[stage].ani_filename); //if we fail here, the value is still -1 if(Cur_Anim.first_frame != -1) { Cur_Anim.num_frames = 1; } } } //resetting the audio here cmd_brief_stop_anim(); Top_cmd_brief_text_line = 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); }
// 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); }