// Initialize the dead popup data void popupdead_start() { int i; UI_BUTTON *b; if ( Popupdead_active ) { return; } // increment number of deaths Player->failures_this_session++; // create base window Popupdead_window.create(Popupdead_background_coords[gr_screen.res][0], Popupdead_background_coords[gr_screen.res][1], 1, 1, 0); Popupdead_window.set_foreground_bmap(Popupdead_background_filename[gr_screen.res]); Popupdead_num_choices = 0; Popupdead_multi_type = -1; if ((The_mission.max_respawn_delay >= 0) && ( Game_mode & GM_MULTIPLAYER )) { Popupdead_timer = timestamp(The_mission.max_respawn_delay * 1000); if (Game_mode & GM_MULTIPLAYER) { if(!(Net_player->flags & NETINFO_FLAG_LIMBO)){ if (The_mission.max_respawn_delay) { HUD_printf("Player will automatically respawn in %d seconds", The_mission.max_respawn_delay); } else { HUD_printf("Player will automatically respawn now"); } } } } if ( Game_mode & GM_NORMAL ) { // also do a campaign check here? if (0) { //((Player->show_skip_popup) && (!Popupdead_skip_already_shown) && (Game_mode & GM_CAMPAIGN_MODE) && (Game_mode & GM_NORMAL) && (Player->failures_this_session >= PLAYER_MISSION_FAILURE_LIMIT)) { // init the special preliminary death popup that gives the skip option Popupdead_button_text[0] = XSTR( "Do Not Skip This Mission", 1473); Popupdead_button_text[1] = XSTR( "Advance To The Next Mission", 1474); Popupdead_button_text[2] = XSTR( "Don't Show Me This Again", 1475); Popupdead_num_choices = POPUPDEAD_NUM_CHOICES_SKIP; Popupdead_skip_active = 1; } else if(The_mission.flags & MISSION_FLAG_RED_ALERT) { // We can't staticly declare these because they are externalized Popupdead_button_text[0] = XSTR( "Quick Start Mission", 105); Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106); Popupdead_button_text[2] = XSTR( "Return To Briefing", 107); Popupdead_button_text[3] = XSTR( "Replay previous mission", 1432); Popupdead_num_choices = POPUPDEAD_NUM_CHOICES_RA; } else { Popupdead_button_text[0] = XSTR( "Quick Start Mission", 105); Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106); Popupdead_button_text[2] = XSTR( "Return To Briefing", 107); Popupdead_num_choices = POPUPDEAD_NUM_CHOICES; } } else { // in multiplayer, we have different choices depending on respawn mode, etc. // if the player has run out of respawns and must either quit and become an observer if(Net_player->flags & NETINFO_FLAG_LIMBO){ // the master should not be able to quit the game if( ((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (multi_num_players() > 1)) || (Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN) ) { Popupdead_button_text[0] = XSTR( "Observer Mode", 108); Popupdead_num_choices = 1; Popupdead_multi_type = POPUPDEAD_OBS_ONLY; } else { Popupdead_button_text[0] = XSTR( "Observer Mode", 108); Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106); Popupdead_num_choices = 2; Popupdead_multi_type = POPUPDEAD_OBS_QUIT; } } else { // the master of the game should not be allowed to quit if ( ((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (multi_num_players() > 1)) || (Net_player->flags & NETINFO_FLAG_TEAM_CAPTAIN) ) { Popupdead_button_text[0] = XSTR( "Respawn", 109); Popupdead_num_choices = 1; Popupdead_multi_type = POPUPDEAD_RESPAWN_ONLY; } else { Popupdead_button_text[0] = XSTR( "Respawn", 109); if(!Cmdline_mpnoreturn) { Popupdead_button_text[1] = XSTR( "Return To Flight Deck", 106); Popupdead_num_choices = 2; } else { Popupdead_num_choices = 1; } Popupdead_multi_type = POPUPDEAD_RESPAWN_QUIT; } } } // create buttons for (i=0; i < Popupdead_num_choices; i++) { b = &Popupdead_buttons[i]; b->create(&Popupdead_window, "", Popupdead_button_coords[gr_screen.res][i][0], Popupdead_button_coords[gr_screen.res][i][1], 30, 20, 0, 1); b->set_bmaps(Popupdead_button_filenames[gr_screen.res][i], 3, 0); b->set_highlight_action(common_play_highlight_sound); // create invisible buttons to detect mouse presses... can't use mask since button region is dynamically sized int lx, w, h; gr_get_string_size(&w, &h, Popupdead_button_text[i]); lx = Popupdead_region_coords[gr_screen.res][i][0] - w; b = &Popupdead_button_regions[i]; b->create(&Popupdead_window, "", lx, Popupdead_region_coords[gr_screen.res][i][1], Popupdead_region_coords[gr_screen.res][i][2]-lx, Popupdead_region_coords[gr_screen.res][i][3]-Popupdead_region_coords[gr_screen.res][i][1], 0, 1); b->hide(); } Popupdead_default_choice = 0; Popupdead_choice = -1; Popupdead_active = 1; }
// init the Popup window int popup_init(popup_info *pi, int flags) { int i; UI_BUTTON *b; popup_background *pbg; char *fname; if(pi->nchoices == 0){ pbg = &Popup_background[gr_screen.res][0]; } else { pbg = &Popup_background[gr_screen.res][pi->nchoices-1]; } // anytime in single player, and multiplayer, not in mission, go ahead and stop time if ( (Game_mode & GM_NORMAL) || ((Game_mode & GM_MULTIPLAYER) && !(Game_mode & GM_IN_MISSION)) ){ game_stop_time(); } // create base window Popup_window.create(pbg->coords[0], pbg->coords[1], Popup_text_coords[gr_screen.res][2]+100, Popup_text_coords[gr_screen.res][3]+50, 0); Popup_window.set_foreground_bmap(pbg->filename); // create buttons for (i=0; i<pi->nchoices; i++) { b = &Popup_buttons[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", Button_coords[gr_screen.res][i+1][0], Button_coords[gr_screen.res][i+1][1], 30, 25, 0, 1); } else { b->create(&Popup_window, "", Button_coords[gr_screen.res][i][0], Button_coords[gr_screen.res][i][1], 30, 25, 0, 1); } fname = popup_get_button_filename(pi, i, flags); b->set_bmaps(fname, 3, 0); b->set_highlight_action(common_play_highlight_sound); if ( pi->keypress[i] >= 0 ) { b->set_hotkey(pi->keypress[i]); } // create invisible buttons to detect mouse presses... can't use mask since button region is dynamically sized int lx, w, h; gr_get_string_size(&w, &h, pi->button_text[i]); lx = Button_regions[gr_screen.res][i][0] - w; b = &Popup_button_regions[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i+1][1], Button_regions[gr_screen.res][i+1][2]-lx, Button_regions[gr_screen.res][i+1][3]-Button_regions[gr_screen.res][i+1][1], 0, 1); } else { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i][1], Button_regions[gr_screen.res][i][2]-lx, Button_regions[gr_screen.res][i][3]-Button_regions[gr_screen.res][i][1], 0, 1); } b->hide(); } // webcursor setup if (Web_cursor_bitmap >= 0) { if (flags & PF_WEB_CURSOR_1) { Popup_buttons[1].set_custom_cursor_bmap(Web_cursor_bitmap); } if (flags & PF_WEB_CURSOR_2) { Popup_buttons[2].set_custom_cursor_bmap(Web_cursor_bitmap); } } // if this is an input popup, create and center the popup if(flags & PF_INPUT){ Popup_input.create(&Popup_window, Popup_text_coords[gr_screen.res][0], pbg->coords[1] + Popup_input_y_offset[gr_screen.res], Popup_text_coords[gr_screen.res][2], pi->max_input_text_len, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_CLR | UI_INPUTBOX_FLAG_ESC_FOC | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_TEXT_CEN); Popup_input.set_focus(); } Popup_default_choice=0; Popup_should_die = 0; if (flags & PF_RUN_STATE) { Popup_running_state = 1; } else { Popup_running_state = 0; } popup_split_lines(pi, flags); // create the popup slider (which we may not need to use Popup_slider.create(&Popup_window, Popup_slider_coords[gr_screen.res][0], Popup_slider_coords[gr_screen.res][1], Popup_slider_coords[gr_screen.res][2], Popup_slider_coords[gr_screen.res][3], pi->nlines > Popup_max_display[gr_screen.res] ? pi->nlines - Popup_max_display[gr_screen.res] : 0, Popup_slider_name[gr_screen.res], popup_slider_bogus, popup_slider_bogus, NULL); return 0; }
// init the Popup window int popup_init(popup_info *pi, int flags) { int i; UI_BUTTON *b; popup_background *pbg; char *fname; int state, choice; // to have those cool holo projection popups we need to find what // state the game is then load the appropiate popup graphic for // display state = gameseq_get_state(); choice = pi->nchoices - 2; if (choice < 0) choice = 0; //pbg = &Popup_background[gr_screen.res][0][POPUP_DEFAULT]; switch (state) { case GS_STATE_INITIAL_PLAYER_SELECT: pbg = &Popup_background[gr_screen.res][choice][POPUP_REGDESK]; break; case GS_STATE_MAIN_MENU: pbg = &Popup_background[gr_screen.res][choice][POPUP_CONCOURSE]; break; case GS_STATE_SIMULATOR_ROOM: pbg = &Popup_background[gr_screen.res][choice][POPUP_LOADMISSION]; break; case GS_STATE_PILOT_MANAGE: pbg = &Popup_background[gr_screen.res][choice][POPUP_PILOTMANAGE]; break; case GS_STATE_VIEW_CUTSCENES: pbg = &Popup_background[gr_screen.res][choice][POPUP_FILMROOM]; break; case GS_STATE_GAME_PLAY: pbg = &Popup_background[gr_screen.res][choice][POPUP_FLY]; break; /*case GS_STATE_MULTI_DOGFIGHT_DEBRIEF: case GS_STATE_MULTI_JOIN_GAME: case GS_STATE_DEBRIEF: pbg = &Popup_background[gr_screen.res][choice][POPUP_DEFAULT]; break;*/ default: pbg = &Popup_background[gr_screen.res][choice][POPUP_DEFAULT]; } // anytime in single player, and multiplayer, not in mission, go ahead and stop time if ( (Game_mode & GM_NORMAL) || ((Game_mode && GM_MULTIPLAYER) && !(Game_mode & GM_IN_MISSION)) ){ game_stop_time(); } // create base window Popup_window.create(pbg->coords[0], pbg->coords[1], Popup_text_coords[gr_screen.res][2]+100, Popup_text_coords[gr_screen.res][3]+50, 0); Popup_window.set_foreground_bmap(pbg->filename); // create buttons for (i=0; i<pi->nchoices; i++) { b = &Popup_buttons[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", Button_coords[gr_screen.res][i+1][0], Button_coords[gr_screen.res][i+1][1], 30, 25, 0, 1); } else { b->create(&Popup_window, "", Button_coords[gr_screen.res][i][0], Button_coords[gr_screen.res][i][1], 30, 25, 0, 1); } fname = popup_get_button_filename(pi, i, flags); b->set_bmaps(fname, 3, 0); b->set_highlight_action(common_play_highlight_sound); if ( pi->keypress[i] >= 0 ) { b->set_hotkey(pi->keypress[i]); } // create invisible buttons to detect mouse presses... can't use mask since button region is dynamically sized int lx, w, h; gr_get_string_size(&w, &h, pi->button_text[i]); lx = Button_regions[gr_screen.res][i][0] - w; b = &Popup_button_regions[i]; // accommodate single-choice positive icon being positioned differently if ( (pi->nchoices == 1) && (flags&PF_USE_AFFIRMATIVE_ICON) ) { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i+1][1], Button_regions[gr_screen.res][i+1][2]-lx, Button_regions[gr_screen.res][i+1][3]-Button_regions[gr_screen.res][i+1][1], 0, 1); } else { b->create(&Popup_window, "", lx, Button_regions[gr_screen.res][i][1], Button_regions[gr_screen.res][i][2]-lx, Button_regions[gr_screen.res][i][3]-Button_regions[gr_screen.res][i][1], 0, 1); } b->hide(); } // webcursor setup if (Web_cursor_bitmap >= 0) { if (flags & PF_WEB_CURSOR_1) { Popup_buttons[1].set_custom_cursor_bmap(Web_cursor_bitmap); } if (flags & PF_WEB_CURSOR_2) { Popup_buttons[2].set_custom_cursor_bmap(Web_cursor_bitmap); } } // if this is an input popup, create and center the popup if(flags & PF_INPUT){ Popup_input.create(&Popup_window, Popup_text_coords[gr_screen.res][0], pbg->coords[1] + Popup_input_y_offset[gr_screen.res], Popup_text_coords[gr_screen.res][2], pi->max_input_text_len, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_ESC_CLR | UI_INPUTBOX_FLAG_ESC_FOC | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_TEXT_CEN); Popup_input.set_focus(); } Popup_default_choice=0; Popup_should_die = 0; if (flags & PF_RUN_STATE) { Popup_running_state = 1; } else { Popup_running_state = 0; } popup_split_lines(pi, flags); // create the popup slider (which we may not need to use Popup_slider.create(&Popup_window, Popup_slider_coords[gr_screen.res][0], Popup_slider_coords[gr_screen.res][1], Popup_slider_coords[gr_screen.res][2], Popup_slider_coords[gr_screen.res][3], pi->nlines > Popup_max_display[gr_screen.res] ? pi->nlines - Popup_max_display[gr_screen.res] : 0, Popup_slider_name[gr_screen.res], popup_slider_bogus, popup_slider_bogus, NULL); return 0; }