// exiting screen without canceling, so load in the new pilot selected here int barracks_pilot_accepted() { // check if pilot active. If not, don't allow accept. if (!Cur_pilot->callsign[0]){ return -1; } // check that pilot language is OK if (!valid_pilot_lang(Cur_pilot->callsign)) { popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR( "Selected pilot was created with a different language\n" "to the currently active language.\n\n" "Please select a different pilot or change the language", 1637)); return -1; } // set pilot image if (Game_mode & GM_MULTIPLAYER) { player_set_squad_bitmap(Cur_pilot, Cur_pilot->m_squad_filename, true); } else { player_set_squad_bitmap(Cur_pilot, Cur_pilot->s_squad_filename, false); } // MWA -- I think that we should be writing Cur_pilot here. Pilot.save_player(Cur_pilot); os_config_write_string(NULL, "LastPlayer", Cur_pilot->callsign); return 0; }
void player_select_button_pressed(int n) { int ret; switch (n) { case SCROLL_LIST_UP_BUTTON: player_select_set_bottom_text(""); player_select_scroll_list_up(); break; case SCROLL_LIST_DOWN_BUTTON: player_select_set_bottom_text(""); player_select_scroll_list_down(); break; case ACCEPT_BUTTON: // make sure he has a valid pilot selected if (Player_select_pilot < 0) { popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR( "You must select a valid pilot first", 378)); } else { if (valid_pilot_lang(Pilots[Player_select_pilot])) { player_select_commit(); } else { popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR( "Selected pilot was created with a different language\n" "to the currently active language.\n\n" "Please select a different pilot or change the language", 1637)); } } break; case CLONE_BUTTON: // if we're at max-pilots, don't allow another to be added if (Player_select_num_pilots >= MAX_PILOTS) { player_select_set_bottom_text(XSTR( "You already have the maximum # of pilots!", 379)); gamesnd_play_iface(SND_GENERAL_FAIL); break; } if (Player_select_pilot >= 0) { // first we have to make sure this guy is actually loaded for when we create the clone if (Player == NULL) { Player = &Players[0]; Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE; } // attempt to read in the pilot file of the guy to be cloned if ( !Pilot.load_player(Pilots[Player_select_pilot], Player) ) { Error(LOCATION,"Couldn't load pilot file, bailing"); Player = NULL; Int3(); } // set the clone flag Player_select_clone_flag = 1; // create the new pilot (will be cloned with Player_select_clone_flag_set) if ( !player_select_create_new_pilot() ) { player_select_set_bottom_text(XSTR( "Error creating new pilot file!", 380)); Player_select_clone_flag = 0; Player->reset(); Player = NULL; break; } // display some text on the bottom of the dialog player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381)); // gray out all controls in the dialog player_select_set_controls(1); } break; case CREATE_PILOT_BUTTON: // if we're at max-pilots, don't allow another to be added if(Player_select_num_pilots >= MAX_PILOTS) { player_select_set_bottom_text(XSTR( "You already have the maximum # of pilots!", 379)); gamesnd_play_iface(SND_GENERAL_FAIL); break; } // create a new pilot if ( !player_select_create_new_pilot() ) { player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381)); } // don't clone anyone Player_select_clone_flag = 0; // display some text on the bottom of the dialog player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381)); // gray out all controls player_select_set_controls(1); break; case DELETE_BUTTON: player_select_set_bottom_text(""); if (Player_select_pilot >= 0) { if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) { popup(PF_TITLE_BIG | PF_TITLE_RED | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("Disabled!\n\nMulti and single player pilots are now identical. " "Deleting a multi-player pilot will also delete all single-player data for that pilot.\n\nAs a safety precaution, pilots can only be " "deleted from the single-player menu.", 1610)); } else { // display a popup requesting confirmation ret = popup(PF_TITLE_BIG | PF_TITLE_RED, 2, POPUP_NO, POPUP_YES, XSTR( "Warning!\n\nAre you sure you wish to delete this pilot?", 382)); // delete the pilot if (ret == 1) { player_select_delete_pilot(); } } } break; case SINGLE_BUTTON: player_select_set_bottom_text(""); Player_select_autoaccept = 0; // switch to single player mode if (Player_select_mode != PLAYER_SELECT_MODE_SINGLE) { // play a little sound gamesnd_play_iface(SND_USER_SELECT); player_select_set_bottom_text(XSTR( "Single Player Mode", 376)); // reinitialize as single player mode player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } break; case MULTI_BUTTON: player_select_set_bottom_text(""); Player_select_autoaccept = 0; if ( Networking_disabled ) { game_feature_disabled_popup(); break; } // switch to multiplayer mode if (Player_select_mode != PLAYER_SELECT_MODE_MULTI) { // play a little sound gamesnd_play_iface(SND_USER_SELECT); player_select_set_bottom_text(XSTR( "Multiplayer Mode", 377)); // reinitialize as multiplayer mode player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI); } else { gamesnd_play_iface(SND_GENERAL_FAIL); } break; } }