2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/MenuUI/PlayerMenu.cpp $
15 * Code to drive the Player Select initial screen
18 * Revision 1.9 2005/03/29 02:18:47 taylor
19 * Various 64-bit platform fixes
20 * Fix compiler errors with MAKE_FS1 and fix gr_set_bitmap() too
21 * Make sure that turrets can fire at asteroids for FS1 (needed for a couple missions)
22 * Streaming audio support (big thanks to Pierre Willenbrock!!)
23 * Removed dependance on strings.tbl for FS1 since we don't actually need it now
25 * Revision 1.8 2004/09/20 01:31:44 theoddone33
28 * Revision 1.7 2003/08/09 03:18:03 taylor
29 * fix tips popup not having any tips
31 * Revision 1.6 2003/06/11 18:30:32 taylor
34 * Revision 1.5 2003/05/25 02:30:42 taylor
37 * Revision 1.4 2003/05/22 16:13:35 taylor
38 * fix missed German build option for auto-lang
40 * Revision 1.3 2002/06/09 04:41:22 relnev
41 * added copyright header
43 * Revision 1.2 2002/05/07 03:16:46 theoddone33
44 * The Great Newline Fix
46 * Revision 1.1.1.1 2002/05/03 03:28:09 root
50 * 43 11/02/99 11:42a Jefff
51 * fixed copyright symbol in german fonts
53 * 42 10/27/99 12:27a Jefff
54 * localized tips correctly
56 * 41 9/13/99 4:52p Dave
59 * 40 9/02/99 11:10a Jefff
60 * fixed 1024 list display bug - was only showing 8 pilots at a time
62 * 39 8/26/99 8:51p Dave
63 * Gave multiplayer TvT messaging a heavy dose of sanity. Cheat codes.
65 * 38 8/26/99 9:45a Dave
66 * First pass at easter eggs and cheats.
68 * 37 8/16/99 6:39p Jefff
70 * 36 8/16/99 6:37p Jefff
71 * minor string alterations
73 * 35 8/05/99 4:17p Dave
74 * Tweaks to client interpolation.
76 * 34 8/05/99 11:29a Mikek
77 * Jacked up number of comments from 20 to 40, thereby doubling the
78 * quality of our game.
80 * 33 8/04/99 10:53a Dave
81 * Added title to the user tips popup.
83 * 32 8/03/99 3:21p Jefff
85 * 31 8/03/99 10:32a Jefff
86 * raised location of bottom_text to not interfere w/ logo. changed
87 * "please enter callsign" to "type callsign and press enter"
89 * 30 8/02/99 9:13p Dave
92 * 29 7/30/99 10:29a Jefff
93 * fixed colors of bottom display texts
95 * 28 7/27/99 7:17p Jefff
96 * Replaced some art text with XSTR() text.
98 * 27 7/19/99 2:06p Jasons
99 * Remove all palette stuff from player select menu.
101 * 26 7/15/99 9:20a Andsager
102 * FS2_DEMO initial checkin
104 * 25 7/09/99 9:51a Dave
105 * Added thick polyline code.
107 * 24 6/11/99 11:13a Dave
108 * last minute changes before press tour build.
110 * 23 5/21/99 6:45p Dave
111 * Sped up ui loading a bit. Sped up localization disk access stuff. Multi
112 * start game screen, multi password, and multi pxo-help screen.
114 * 22 4/25/99 3:02p Dave
115 * Build defines for the E3 build.
117 * 21 3/25/99 2:31p Neilk
118 * Coordinate changes to handle new artwork
120 * 20 2/25/99 4:19p Dave
121 * Added multiplayer_beta defines. Added cd_check define. Fixed a few
122 * release build warnings. Added more data to the squad war request and
125 * 19 2/01/99 5:55p Dave
126 * Removed the idea of explicit bitmaps for buttons. Fixed text
127 * highlighting for disabled gadgets.
129 * 18 1/30/99 5:08p Dave
130 * More new hi-res stuff.Support for nice D3D textures.
132 * 17 1/30/99 1:53a Dave
133 * Fix some harcoded coords.
135 * 16 1/30/99 1:28a Dave
136 * 1024x768 full support.
138 * 15 1/29/99 1:25p Dave
139 * New code for choose pilot screen.
141 * 14 1/29/99 12:47a Dave
142 * Put in sounds for beam weapon. A bunch of interface screens (tech
145 * 13 1/12/99 12:53a Dave
146 * More work on beam weapons - made collision detection very efficient -
147 * collide against all object types properly - made 3 movement types
148 * smooth. Put in test code to check for possible non-darkening pixels on
151 * 12 12/18/98 1:13a Dave
152 * Rough 1024x768 support for Direct3D. Proper detection and usage through
155 * 11 12/06/98 2:36p Dave
156 * Drastically improved nebula fogging.
158 * 10 12/01/98 6:20p Dave
159 * Removed tga test bitmap code.
161 * 9 12/01/98 4:46p Dave
162 * Put in targa bitmap support (16 bit).
164 * 8 11/30/98 1:07p Dave
165 * 16 bit conversion, first run.
167 * 7 11/20/98 11:16a Dave
168 * Fixed up IPX support a bit. Making sure that switching modes and
169 * loading/saving pilot files maintains proper state.
171 * 6 11/19/98 4:19p Dave
172 * Put IPX sockets back in psnet. Consolidated all multiplayer config
175 * 5 11/05/98 4:18p Dave
176 * First run nebula support. Beefed up localization a bit. Removed all
177 * conditional compiles for foreign versions. Modified mission file
180 * 4 10/13/98 9:28a Dave
181 * Started neatening up freespace.h. Many variables renamed and
182 * reorganized. Added AlphaColors.[h,cpp]
184 * 3 10/09/98 2:57p Dave
185 * Starting splitting up OS stuff.
187 * 2 10/07/98 10:53a Dave
190 * 1 10/07/98 10:49a Dave
199 #include "playermenu.h"
206 #include "managepilot.h"
207 #include "missionscreencommon.h"
209 #include "freespace.h"
211 #include "gamesequence.h"
214 #include "osregistry.h"
216 #include "mainhallmenu.h"
220 #include "alphacolors.h"
221 #include "localize.h"
223 // --------------------------------------------------------------------------------------------------------
225 #if defined(FS2_DEMO) || defined(FS1_DEMO)
226 static int Demo_title_active = 0;
227 static int Demo_title_bitmap = -1;
228 static int Demo_title_expire_timestamp = 0;
229 static int Demo_title_need_fade_in = 1;
230 static char *Demo_title_bitmap_filename = NOX("DemoTitle1");
233 // --------------------------------------------------------------------------------------------------------
234 // PLAYER SELECT defines
237 //#define MAX_PLAYER_SELECT_LINES 8 // max # of pilots displayed at once
238 int Player_select_max_lines[GR_NUM_RESOLUTIONS] = { // max # of pilots displayed at once
243 // button control defines
244 #define NUM_PLAYER_SELECT_BUTTONS 8 // button control defines
246 #define CREATE_PILOT_BUTTON 0 //
247 #define CLONE_BUTTON 1 //
248 #define DELETE_BUTTON 2 //
249 #define SCROLL_LIST_UP_BUTTON 3 //
250 #define SCROLL_LIST_DOWN_BUTTON 4 //
251 #define ACCEPT_BUTTON 5 //
252 #define SINGLE_BUTTON 6 //
253 #define MULTI_BUTTON 7 //
255 // list text display area
256 int Choose_list_coords[GR_NUM_RESOLUTIONS][4] = {
269 char *Player_select_background_bitmap_name[GR_NUM_RESOLUTIONS] = {
273 char *Player_select_background_mask_bitmap[GR_NUM_RESOLUTIONS] = {
277 // #define PLAYER_SELECT_PALETTE NOX("ChoosePilotPalette") // palette for the screen
279 #define PLAYER_SELECT_MAIN_HALL_OVERLAY NOX("MainHall1") // main hall help overlay
281 // convenient struct for handling all button controls
282 struct barracks_buttons {
286 UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
288 barracks_buttons(char *name, int x1, int y1, int xt1, int yt1, int h) : filename(name), x(x1), y(y1), xt(xt1), yt(yt1), hotspot(h) {}
291 static barracks_buttons Player_select_buttons[GR_NUM_RESOLUTIONS][NUM_PLAYER_SELECT_BUTTONS] = {
294 barracks_buttons("CHP_00", 126, 211, -1, -1, 0), // create
295 barracks_buttons("CHP_13", 181, 211, -1, -1, 13), // clone
296 barracks_buttons("CHP_11", 228, 211, -1, -1, 11), // delete
297 barracks_buttons("CHP_01", 423, 232, -1, -1, 1), // scroll up
298 barracks_buttons("CHP_02", 452, 232, -1, -1, 2), // scroll down
299 barracks_buttons("CHP_12", 475, 213, -1, -1, 12), // accept
300 barracks_buttons("CHP_14", 438, 104, -1, -1, 14), // single
301 barracks_buttons("CHP_15", 485, 104, -1, -1, 15) // multi
303 // create, clone and delete (respectively)
304 barracks_buttons("CPB_00", 114, 205, 117, 240, 0),
305 barracks_buttons("CPB_01", 172, 205, 175, 240, 1),
306 barracks_buttons("CPB_02", 226, 205, 229, 240, 2),
308 // scroll up, scroll down, and accept (respectively)
309 barracks_buttons("CPB_03", 429, 213, -1, -1, 3),
310 barracks_buttons("CPB_04", 456, 213, -1, -1, 4),
311 barracks_buttons("CPB_05", 481, 207, 484, 246, 5),
313 // single player select and multiplayer select, respectively
314 barracks_buttons("CPB_06", 428, 82, 430, 108, 6),
315 barracks_buttons("CPB_07", 477, 82, 481, 108, 7)
319 // create, clone and delete (respectively)
320 barracks_buttons("2_CPB_00", 182, 328, 199, 384, 0),
321 barracks_buttons("2_CPB_01", 275, 328, 292, 384, 1),
322 barracks_buttons("2_CPB_02", 361, 328, 379, 384, 2),
324 // scroll up, scroll down, and accept (respectively)
325 barracks_buttons("2_CPB_03", 686, 341, -1, -1, 3),
326 barracks_buttons("2_CPB_04", 729, 341, -1, -1, 4),
327 barracks_buttons("2_CPB_05", 770, 332, 787, 394, 5),
329 // single player select and multiplayer select, respectively
330 barracks_buttons("2_CPB_06", 685, 132, 700, 173, 6),
331 barracks_buttons("2_CPB_07", 764, 132, 782, 173, 7)
335 // FIXME add to strings.tbl
337 #define PLAYER_SELECT_NUM_TEXT 1
339 UI_XSTR Player_select_text[GR_NUM_RESOLUTIONS][PLAYER_SELECT_NUM_TEXT] = {
341 { "Choose Pilot", 1436, 122, 90, UI_XSTR_COLOR_GREEN, -1, NULL }
344 { "Choose Pilot", 1436, 195, 143, UI_XSTR_COLOR_GREEN, -1, NULL }
349 UI_WINDOW Player_select_window; // ui window for this screen
350 UI_BUTTON Player_select_list_region; // button for detecting mouse clicks on this screen
351 UI_INPUTBOX Player_select_input_box; // input box for adding new pilot names
353 // #define PLAYER_SELECT_PALETTE_FNAME NOX("InterfacePalette")
354 int Player_select_background_bitmap; // bitmap for this screen
355 // int Player_select_palette; // palette bitmap for this screen
356 int Player_select_autoaccept = 0;
357 // int Player_select_palette_set = 0;
359 // flag indicating if this is the absolute first pilot created and selected. Used to determine
360 // if the main hall should display the help overlay screen
361 int Player_select_very_first_pilot = 0;
362 int Player_select_initial_count = 0;
363 char Player_select_very_first_pilot_callsign[CALLSIGN_LEN + 2];
365 extern int Main_hall_bitmap; // bitmap handle to the main hall bitmap
367 int Player_select_mode; // single or multiplayer - never set directly. use player_select_init_player_stuff()
368 int Player_select_num_pilots; // # of pilots on the list
369 int Player_select_list_start; // index of first list item to start displaying in the box
370 int Player_select_pilot; // index into the Pilot array of which is selected as the active pilot
371 int Player_select_input_mode; // 0 if the player _isn't_ typing a callsign, 1 if he is
372 char Pilots_arr[MAX_PILOTS][MAX_FILENAME_LEN];
373 char *Pilots[MAX_PILOTS];
374 int Player_select_clone_flag; // clone the currently selected pilot
375 char Player_select_last_pilot[CALLSIGN_LEN + 10]; // callsign of the last used pilot, or none if there wasn't one
376 int Player_select_last_is_multi;
378 int Player_select_force_bastion = 0;
380 // notification text areas
382 static int Player_select_bottom_text_y[GR_NUM_RESOLUTIONS] = {
391 static int Player_select_middle_text_y[GR_NUM_RESOLUTIONS] = {
400 char Player_select_bottom_text[150] = "";
401 char Player_select_middle_text[150] = "";
402 void player_select_set_bottom_text(char *txt);
403 void player_select_set_middle_text(char *txt);
406 // FORWARD DECLARATIONS
407 void player_select_init_player_stuff(int mode); // switch between single and multiplayer modes
408 void player_select_set_input_mode(int n);
409 void player_select_button_pressed(int n);
410 void player_select_scroll_list_up();
411 void player_select_scroll_list_down();
412 int player_select_create_new_pilot();
413 void player_select_delete_pilot();
414 void player_select_display_all_text();
415 void player_select_display_copyright();
416 void player_select_set_bottom_text(char *txt);
417 void player_select_set_controls(int gray);
418 void player_select_draw_list();
419 void player_select_process_noninput(int k);
420 void player_select_process_input(int k);
421 int player_select_pilot_file_filter(char *filename);
422 int player_select_get_last_pilot_info();
423 void player_select_eval_very_first_pilot();
424 void player_select_commit();
425 void player_select_cancel_create();
428 // basically, gray out all controls (gray == 1), or ungray the controls (gray == 0)
429 void player_select_set_controls(int gray)
433 for(idx=0;idx<NUM_PLAYER_SELECT_BUTTONS;idx++){
435 Player_select_buttons[gr_screen.res][idx].button.disable();
437 Player_select_buttons[gr_screen.res][idx].button.enable();
442 // functions for selecting single/multiplayer pilots at the very beginning of Freespace
443 void player_select_init()
451 // start a looping ambient sound
452 main_hall_start_ambient();
454 Player_select_force_bastion = 0;
458 Demo_title_bitmap = bm_load(Demo_title_bitmap_filename);
459 if ( Demo_title_bitmap >= 0 ) {
460 #ifndef HARDWARE_ONLY
461 palette_use_bm_palette(Demo_title_bitmap);
463 Demo_title_active = 1;
464 Demo_title_expire_timestamp = timestamp(5000);
466 Demo_title_active = 0;
469 Demo_title_active = 0;
472 // create the UI window
473 Player_select_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
474 Player_select_window.set_mask_bmap(Player_select_background_mask_bitmap[gr_screen.res]);
477 common_set_interface_palette("ChoosePilotPalette");
480 // initialize the control buttons
481 for (i=0; i<NUM_PLAYER_SELECT_BUTTONS; i++) {
482 b = &Player_select_buttons[gr_screen.res][i];
485 if ( (i == SCROLL_LIST_UP_BUTTON) || (i == SCROLL_LIST_DOWN_BUTTON) )
486 b->button.create(&Player_select_window, NULL, b->x, b->y, 60, 30, 1, 1);
488 b->button.create(&Player_select_window, NULL, b->x, b->y, 60, 30, 1, 1);
490 // set its highlight action
491 b->button.set_highlight_action(common_play_highlight_sound);
493 // set its animation bitmaps
494 b->button.set_bmaps(b->filename);
496 // link the mask hotspot
497 b->button.link_hotspot(b->hotspot);
502 w = &Player_select_window;
503 w->add_XSTR("Create", 1034, Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].xt, Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].yt, &Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button, UI_XSTR_COLOR_GREEN);
504 w->add_XSTR("Clone", 1040, Player_select_buttons[gr_screen.res][CLONE_BUTTON].xt, Player_select_buttons[gr_screen.res][CLONE_BUTTON].yt, &Player_select_buttons[gr_screen.res][CLONE_BUTTON].button, UI_XSTR_COLOR_GREEN);
505 w->add_XSTR("Remove", 1038, Player_select_buttons[gr_screen.res][DELETE_BUTTON].xt, Player_select_buttons[gr_screen.res][DELETE_BUTTON].yt, &Player_select_buttons[gr_screen.res][DELETE_BUTTON].button, UI_XSTR_COLOR_GREEN);
507 w->add_XSTR("Select", 1039, Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].xt, Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].yt, &Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button, UI_XSTR_COLOR_PINK);
508 w->add_XSTR("Single", 1041, Player_select_buttons[gr_screen.res][SINGLE_BUTTON].xt, Player_select_buttons[gr_screen.res][SINGLE_BUTTON].yt, &Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button, UI_XSTR_COLOR_GREEN);
509 w->add_XSTR("Multi", 1042, Player_select_buttons[gr_screen.res][MULTI_BUTTON].xt, Player_select_buttons[gr_screen.res][MULTI_BUTTON].yt, &Player_select_buttons[gr_screen.res][MULTI_BUTTON].button, UI_XSTR_COLOR_GREEN);
510 for(i=0; i<PLAYER_SELECT_NUM_TEXT; i++) {
511 w->add_XSTR(&Player_select_text[gr_screen.res][i]);
515 // create the list button text select region
516 Player_select_list_region.create(&Player_select_window, "", Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1], Choose_list_coords[gr_screen.res][2], Choose_list_coords[gr_screen.res][3], 0, 1);
517 Player_select_list_region.hide();
519 // create the pilot callsign input box
520 Player_select_input_box.create(&Player_select_window, Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1], Choose_list_coords[gr_screen.res][2] , CALLSIGN_LEN - 1, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_LETTER_FIRST);
521 Player_select_input_box.set_valid_chars(VALID_PILOT_CHARS);
522 Player_select_input_box.hide();
523 Player_select_input_box.disable();
525 // not currently entering any text
526 Player_select_input_mode = 0;
528 // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed
529 Player_select_buttons[gr_screen.res][SCROLL_LIST_UP_BUTTON].button.set_hotkey(KEY_UP);
530 Player_select_buttons[gr_screen.res][SCROLL_LIST_DOWN_BUTTON].button.set_hotkey(KEY_DOWN);
531 Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(KEY_ENTER);
532 Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(KEY_C);
534 // disable the single player button in the multiplayer beta
535 #ifdef MULTIPLAYER_BETA_BUILD
536 Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button.hide();
537 Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button.disable();
538 #elif defined(E3_BUILD) || defined(PRESS_TOUR_BUILD)
539 Player_select_buttons[gr_screen.res][MULTI_BUTTON].button.hide();
540 Player_select_buttons[gr_screen.res][MULTI_BUTTON].button.disable();
544 // attempt to load in the background bitmap
545 Player_select_background_bitmap = bm_load(Player_select_background_bitmap_name[gr_screen.res]);
546 Assert(Player_select_background_bitmap >= 0);
548 // load in the palette for the screen
549 // Player_select_palette = bm_load(PLAYER_SELECT_PALETTE);
550 // Player_select_palette_set = 0;
552 // unset the very first pilot data
553 Player_select_very_first_pilot = 0;
554 Player_select_initial_count = -1;
555 memset(Player_select_very_first_pilot_callsign, 0, CALLSIGN_LEN + 2);
557 // if(Player_select_num_pilots == 0){
558 // Player_select_autoaccept = 1;
561 // if we found a pilot
562 #if defined(DEMO) || defined(OEM_BUILD) || defined(E3_BUILD) || defined(PRESS_TOUR_BUILD) // not for FS2_DEMO
563 player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
564 #elif defined(MULTIPLAYER_BETA_BUILD)
565 player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
567 if (player_select_get_last_pilot_info()) {
568 if (Player_select_last_is_multi) {
569 player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
571 player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
574 // otherwise go to the single player mode by default
576 player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
580 if((Player_select_num_pilots == 1) && Player_select_input_mode){
581 Player_select_autoaccept = 1;
585 #if defined(FS2_DEMO) || defined(FS1_DEMO)
586 // Display the demo title screen
587 void demo_title_blit()
593 if ( timestamp_elapsed(Demo_title_expire_timestamp) ) {
594 Demo_title_active = 0;
599 Demo_title_active = 0;
602 if ( Demo_title_need_fade_in ) {
606 gr_set_bitmap(Demo_title_bitmap);
611 if ( Demo_title_need_fade_in ) {
613 Demo_title_need_fade_in = 0;
616 if ( !Demo_title_active ) {
624 void player_select_do()
629 if ( Demo_title_active ) {
630 // demo_title_blit();
635 //if ( !Player_select_palette_set ) {
636 // Assert(Player_select_palette >= 0);
637 //#ifndef HARDWARE_ONLY
638 // palette_use_bm_palette(Player_select_palette);
640 // Player_select_palette_set = 1;
643 // set the input box at the "virtual" line 0 to be active so the player can enter a callsign
644 if (Player_select_input_mode){
645 Player_select_input_box.set_focus();
648 // process any ui window stuff
649 k = Player_select_window.process();
651 extern void game_process_cheats(int k);
652 game_process_cheats(k);
655 // switch between single and multiplayer modes
657 #if defined(DEMO) || defined(OEM_BUILD) // not for FS2_DEMO
661 if(Player_select_input_mode){
662 gamesnd_play_iface(SND_GENERAL_FAIL);
665 // play a little sound
666 gamesnd_play_iface(SND_USER_SELECT);
667 if(Player_select_mode == PLAYER_SELECT_MODE_MULTI){
669 player_select_set_bottom_text(XSTR( "Single Player Mode", 376));
671 player_select_set_bottom_text(XSTR( "Single-Player Mode", 376));
674 // reinitialize as single player mode
675 player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
676 } else if(Player_select_mode == PLAYER_SELECT_MODE_SINGLE){
677 player_select_set_bottom_text(XSTR( "Multiplayer Mode", 377));
679 // reinitialize as multiplayer mode
680 player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
686 // draw the player select pseudo-dialog over it
687 gr_set_bitmap(Player_select_background_bitmap, GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1);
690 // press the accept button
691 if (Player_select_autoaccept) {
692 Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.press_button();
695 // draw any ui window stuf
696 Player_select_window.draw();
698 // light up the correct mode button (single or multi)
699 if (Player_select_mode == PLAYER_SELECT_MODE_SINGLE){
700 Player_select_buttons[gr_screen.res][SINGLE_BUTTON].button.draw_forced(2);
702 Player_select_buttons[gr_screen.res][MULTI_BUTTON].button.draw_forced(2);
705 // draw the pilot list text
706 player_select_draw_list();
708 // draw copyright message on the bottom on the screen
709 player_select_display_copyright();
711 if (!Player_select_input_mode) {
712 player_select_process_noninput(k);
714 player_select_process_input(k);
717 // draw any pending messages on the bottom or middle of the screen
718 player_select_display_all_text();
721 // gr_set_color_fast(&Color_bright_green);
722 // gr_string(0x8000, 10, "Development version - DO NOT RELEASE");
726 gr_set_color(255, 0, 0);
728 vector *arr[5] = {&whee[0], &whee[1], &whee[2], &whee[3], &whee[4]};
729 whee[0].x = 10; whee[0].y = 10; whee[0].z = 0.0f;
730 whee[1].x = 50; whee[1].y = 50; whee[1].z = 0.0f;
731 whee[2].x = 50; whee[2].y = 90; whee[2].z = 0.0f;
732 whee[3].x = 90; whee[3].y = 130; whee[3].z = 0.0f;
733 whee[4].x = 180; whee[4].y = 130; whee[4].z = 0.0f;
734 gr_pline_special(arr, 5, 2);
741 void player_select_close()
743 // destroy the player select window
744 Player_select_window.destroy();
746 // if we're in input mode - we should undo the pilot create reqeust
747 if(Player_select_input_mode){
748 player_select_cancel_create();
751 // actually set up the Player struct here
752 if((Player_select_pilot == -1) || (Player_select_num_pilots == 0)){
753 nprintf(("General","WARNING! No pilot selected! We should be exiting the game now!\n"));
757 // unload all bitmaps
758 if(Player_select_background_bitmap >= 0){
759 bm_release(Player_select_background_bitmap);
760 Player_select_background_bitmap = -1;
762 // if(Player_select_palette >= 0){
763 // bm_release(Player_select_palette);
764 //Player_select_palette = -1;
768 common_free_interface_palette();
771 // setup the player struct
773 Player = &Players[0];
774 Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE;
776 // now read in a the pilot data
777 if (read_pilot_file(Pilots[Player_select_pilot], !Player_select_mode, Player) != 0) {
778 Error(LOCATION,"Couldn't load pilot file, bailing");
782 if (Player_select_force_bastion) {
783 Player->on_bastion = 1;
787 void player_select_set_input_mode(int n)
791 // set the input mode
792 Player_select_input_mode = n;
794 // enable all the player select buttons
795 for (i=0; i<NUM_PLAYER_SELECT_BUTTONS; i++){
796 Player_select_buttons[gr_screen.res][i].button.enable(!n);
799 Player_select_buttons[gr_screen.res][ACCEPT_BUTTON].button.set_hotkey(n ? -1 : KEY_ENTER);
800 Player_select_buttons[gr_screen.res][CREATE_PILOT_BUTTON].button.set_hotkey(n ? -1 : KEY_C);
802 // enable the player select input box
803 if(Player_select_input_mode){
804 Player_select_input_box.enable();
805 Player_select_input_box.unhide();
807 Player_select_input_box.hide();
808 Player_select_input_box.disable();
812 void player_select_button_pressed(int n)
817 case SCROLL_LIST_UP_BUTTON:
818 player_select_set_bottom_text("");
820 player_select_scroll_list_up();
823 case SCROLL_LIST_DOWN_BUTTON:
824 player_select_set_bottom_text("");
826 player_select_scroll_list_down();
830 // make sure he has a valid pilot selected
831 if (Player_select_pilot < 0) {
832 popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR( "You must select a valid pilot first", 378));
834 player_select_commit();
839 // if we're at max-pilots, don't allow another to be added
840 if (Player_select_num_pilots >= MAX_PILOTS) {
841 player_select_set_bottom_text(XSTR( "You already have the maximum # of pilots!", 379));
843 gamesnd_play_iface(SND_GENERAL_FAIL);
847 if (Player_select_pilot >= 0) {
848 // first we have to make sure this guy is actually loaded for when we create the clone
849 if (Player == NULL) {
850 Player = &Players[0];
851 Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE;
854 // attempt to read in the pilot file of the guy to be cloned
855 if (read_pilot_file(Pilots[Player_select_pilot], !Player_select_mode, Player) != 0) {
856 Error(LOCATION,"Couldn't load pilot file, bailing");
861 // set the clone flag
862 Player_select_clone_flag = 1;
864 // create the new pilot (will be cloned with Player_select_clone_flag_set)
865 if (!player_select_create_new_pilot()) {
866 player_select_set_bottom_text(XSTR( "Error creating new pilot file!", 380));
867 Player_select_clone_flag = 0;
868 memset(Player,0,sizeof(player));
873 // clear the player out
874 // JH: What the hell? How do you clone a pilot if you clear out the source you are copying
875 // from? These next 2 lines are pure stupidity, so I commented them out!
876 // memset(Player,0,sizeof(player));
879 // display some text on the bottom of the dialog
880 player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381));
882 // gray out all controls in the dialog
883 player_select_set_controls(1);
887 case CREATE_PILOT_BUTTON:
888 // if we're at max-pilots, don't allow another to be added
889 if(Player_select_num_pilots >= MAX_PILOTS){
890 player_select_set_bottom_text(XSTR( "You already have the maximum # of pilots!", 379));
892 gamesnd_play_iface(SND_GENERAL_FAIL);
896 // create a new pilot
897 if (!player_select_create_new_pilot()) {
898 player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381));
901 // don't clone anyone
902 Player_select_clone_flag = 0;
904 // display some text on the bottom of the dialog
905 player_select_set_bottom_text(XSTR( "Type Callsign and Press Enter", 381));
907 // gray out all controls
908 player_select_set_controls(1);
912 player_select_set_bottom_text("");
914 if (Player_select_pilot >= 0) {
915 // display a popup requesting confirmation
916 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));
920 player_select_delete_pilot();
926 player_select_set_bottom_text("");
928 Player_select_autoaccept = 0;
929 // switch to single player mode
930 if (Player_select_mode != PLAYER_SELECT_MODE_SINGLE) {
931 // play a little sound
932 gamesnd_play_iface(SND_USER_SELECT);
934 player_select_set_bottom_text(XSTR( "Single Player Mode", 376));
936 // reinitialize as single player mode
937 player_select_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
939 gamesnd_play_iface(SND_GENERAL_FAIL);
944 player_select_set_bottom_text("");
946 Player_select_autoaccept = 0;
947 #if defined(DEMO) || defined(OEM_BUILD) // not for FS2_DEMO
948 game_feature_not_in_demo_popup();
950 // switch to multiplayer mode
951 if (Player_select_mode != PLAYER_SELECT_MODE_MULTI) {
952 // play a little sound
953 gamesnd_play_iface(SND_USER_SELECT);
955 player_select_set_bottom_text(XSTR( "Multiplayer Mode", 377));
957 // reinitialize as multiplayer mode
958 player_select_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
960 gamesnd_play_iface(SND_GENERAL_FAIL);
967 int player_select_create_new_pilot()
971 // make sure we haven't reached the max
972 if (Player_select_num_pilots >= MAX_PILOTS) {
973 gamesnd_play_iface(SND_GENERAL_FAIL);
977 int play_scroll_sound = 1;
979 #if defined(FS2_DEMO) || defined(FS1_DEMO)
980 if ( Demo_title_active ) {
981 play_scroll_sound = 0;
985 if ( play_scroll_sound ) {
986 gamesnd_play_iface(SND_SCROLL);
989 idx = Player_select_num_pilots;
991 // move all the pilots in the list up
993 strcpy(Pilots[idx + 1], Pilots[idx]);
996 // by default, set the default netgame protocol to be VMT
997 Multi_options_g.protocol = NET_TCP;
999 // select the beginning of the list
1000 Player_select_pilot = 0;
1001 Player_select_num_pilots++;
1002 Pilots[Player_select_pilot][0] = 0;
1003 Player_select_list_start= 0;
1005 // set us to be in input mode
1006 player_select_set_input_mode(1);
1008 // set the input box to have focus
1009 Player_select_input_box.set_focus();
1010 Player_select_input_box.set_text("");
1011 Player_select_input_box.update_dimensions(Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1], Choose_list_coords[gr_screen.res][2], gr_get_font_height());
1016 void player_select_delete_pilot()
1018 char filename[MAX_PATH_LEN + 1];
1019 int i, deleted_cur_pilot;
1021 deleted_cur_pilot = 0;
1023 // tack on the full path and the pilot file extension
1024 // build up the path name length
1025 // make sure we do this based upon whether we're in single or multiplayer mode
1026 strcpy( filename, Pilots[Player_select_pilot] );
1027 strcat( filename, NOX(".plr") );
1029 // attempt to delete the pilot
1030 if (Player_select_mode == PLAYER_SELECT_MODE_SINGLE) {
1031 cf_delete( filename, CF_TYPE_SINGLE_PLAYERS );
1033 cf_delete( filename, CF_TYPE_MULTI_PLAYERS );
1036 // delete all the campaign save files for this pilot.
1037 mission_campaign_delete_all_savefiles( Pilots[Player_select_pilot], (Player_select_mode != PLAYER_SELECT_MODE_SINGLE) );
1039 // move all the players down
1040 for (i=Player_select_pilot; i<Player_select_num_pilots-1; i++){
1041 strcpy(Pilots[i], Pilots[i + 1]);
1044 // correcly set the # of pilots and the currently selected pilot
1045 Player_select_num_pilots--;
1046 if (Player_select_pilot >= Player_select_num_pilots) {
1047 Player_select_pilot = Player_select_num_pilots - 1;
1052 // scroll the list of players up
1053 void player_select_scroll_list_up()
1055 if (Player_select_pilot == -1)
1058 // change the pilot selected index and play the appropriate sound
1059 if (Player_select_pilot) {
1060 Player_select_pilot--;
1061 gamesnd_play_iface(SND_SCROLL);
1063 gamesnd_play_iface(SND_GENERAL_FAIL);
1066 if (Player_select_pilot < Player_select_list_start){
1067 Player_select_list_start = Player_select_pilot;
1071 // scroll the list of players down
1072 void player_select_scroll_list_down()
1074 // change the pilot selected index and play the appropriate sound
1075 if (Player_select_pilot < Player_select_num_pilots - 1) {
1076 Player_select_pilot++;
1077 gamesnd_play_iface(SND_SCROLL);
1079 gamesnd_play_iface(SND_GENERAL_FAIL);
1082 if (Player_select_pilot >= (Player_select_list_start + Player_select_max_lines[gr_screen.res])){
1083 Player_select_list_start++;
1087 // fill in the data on the last played pilot (callsign and is_multi or not)
1088 int player_select_get_last_pilot_info()
1092 last_player = os_config_read_string( NULL, "LastPlayer", NULL);
1094 if(last_player == NULL){
1097 strcpy(Player_select_last_pilot,last_player);
1100 // determine if he was a single or multi-player based upon the last character in his callsign
1101 Player_select_last_is_multi = Player_select_last_pilot[strlen(Player_select_last_pilot)-1] == 'M' ? 1 : 0;
1102 Player_select_last_pilot[strlen(Player_select_last_pilot)-1]='\0';
1107 int player_select_get_last_pilot()
1109 // if the player has the Cmdline_use_last_pilot command line option set, try and drop out quickly
1110 if(Cmdline_use_last_pilot){
1113 if(!player_select_get_last_pilot_info()){
1117 if(Player_select_last_is_multi){
1118 Player_select_num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_MULTI_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
1120 Player_select_num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_SINGLE_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
1123 Player_select_pilot = -1;
1125 // pick the last player
1126 for(idx=0;idx<Player_select_num_pilots;idx++){
1127 if(strcmp(Player_select_last_pilot,Pilots_arr[idx])==0){
1128 Player_select_pilot = idx;
1133 // set this so that we don't incorrectly create a "blank" pilot - .plr
1134 // in the player_select_close() function
1135 Player_select_num_pilots = 0;
1137 // if we've actually found a valid pilot, load him up
1138 if(Player_select_pilot != -1){
1139 Player = &Players[0];
1140 read_pilot_file(Pilots_arr[idx],!Player_select_last_is_multi,Player);
1141 Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE;
1149 void player_select_init_player_stuff(int mode)
1151 Player_select_list_start = 0;
1153 // set the select mode to single player for default
1154 Player_select_mode = mode;
1156 // load up the list of players based upon the Player_select_mode (single or multiplayer)
1157 Get_file_list_filter = player_select_pilot_file_filter;
1158 if (mode == PLAYER_SELECT_MODE_SINGLE){
1159 Player_select_num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_SINGLE_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
1161 Player_select_num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_MULTI_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
1166 // if this value is -1, it means we should set it to the num pilots count
1167 if(Player_select_initial_count == -1){
1168 Player_select_initial_count = Player_select_num_pilots;
1171 // select the first pilot if any exist, otherwise set to -1
1172 if (Player_select_num_pilots == 0) {
1173 Player_select_pilot = -1;
1174 player_select_set_middle_text(XSTR( "Type Callsign and Press Enter", 381));
1175 player_select_set_controls(1); // gray out the controls
1176 player_select_create_new_pilot();
1178 Player_select_pilot = 0;
1182 void player_select_draw_list()
1186 for (idx=0; idx<Player_select_max_lines[gr_screen.res]; idx++) {
1187 // only draw as many pilots as we have
1188 if ((idx + Player_select_list_start) == Player_select_num_pilots)
1191 // if the currently selected pilot is this line, draw it highlighted
1192 if ( (idx + Player_select_list_start) == Player_select_pilot) {
1193 // if he's the active pilot and is also the current selection, super-highlight him
1194 gr_set_color_fast(&Color_text_active);
1196 // otherwise draw him normally
1198 gr_set_color_fast(&Color_text_normal);
1201 // draw the actual callsign
1202 gr_printf(Choose_list_coords[gr_screen.res][0], Choose_list_coords[gr_screen.res][1] + (idx * gr_get_font_height()), Pilots[idx + Player_select_list_start]);
1206 void player_select_process_noninput(int k)
1210 // check for pressed buttons
1211 for (idx=0; idx<NUM_PLAYER_SELECT_BUTTONS; idx++) {
1212 if (Player_select_buttons[gr_screen.res][idx].button.pressed()) {
1213 player_select_button_pressed(idx);
1217 // check for keypresses
1219 // quit the game entirely
1221 gameseq_post_event(GS_EVENT_QUIT_GAME);
1224 case KEY_ENTER | KEY_CTRLED:
1225 player_select_button_pressed(ACCEPT_BUTTON);
1228 // delete the currently highlighted pilot
1230 if (Player_select_pilot >= 0) {
1233 // display a popup requesting confirmation
1234 ret = popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON,2,POPUP_NO,POPUP_YES,XSTR( "Are you sure you want to delete this pilot?", 383));
1238 player_select_delete_pilot();
1244 // check to see if the user has clicked on the "list region" button
1245 // and change the selected pilot appropriately
1246 if (Player_select_list_region.pressed()) {
1248 // get the mouse position
1249 Player_select_list_region.get_mouse_pos(NULL, &click_y);
1251 // determine what index to select
1252 //idx = (click_y+5) / 10;
1253 idx = click_y / gr_get_font_height();
1256 // if he selected a valid item
1257 if(((idx + Player_select_list_start) < Player_select_num_pilots) && (idx >= 0)){
1258 Player_select_pilot = idx + Player_select_list_start;
1262 // if the player has double clicked on a valid pilot, choose it and hit the accept button
1263 if (Player_select_list_region.double_clicked()) {
1264 if ((Player_select_pilot >= 0) && (Player_select_pilot < Player_select_num_pilots)) {
1265 player_select_button_pressed(ACCEPT_BUTTON);
1270 void player_select_process_input(int k)
1272 char buf[CALLSIGN_LEN + 1];
1275 // if the player is in the process of typing in a new pilot name...
1277 // cancel create pilot
1279 player_select_cancel_create();
1282 // accept a new pilot name
1284 Player_select_input_box.get_text(buf);
1285 drop_white_space(buf);
1287 if (!isalpha(*buf)) {
1290 for (idx=1; buf[idx]; idx++) {
1291 if (!isalpha(buf[idx]) && !isdigit(buf[idx]) && !strchr(VALID_PILOT_CHARS, buf[idx])) {
1298 for (idx=1; idx<Player_select_num_pilots; idx++) {
1299 if (!stricmp(buf, Pilots[idx])) {
1300 // verify if it is ok to overwrite the file
1301 if (pilot_verify_overwrite() == 1) {
1302 // delete the pilot and select the beginning of the list
1303 Player_select_pilot = idx;
1304 player_select_delete_pilot();
1305 Player_select_pilot = 0;
1306 idx = Player_select_num_pilots;
1316 if (!*buf || (idx < Player_select_num_pilots)) {
1321 gamesnd_play_iface(SND_GENERAL_FAIL);
1325 // Create the new pilot, and write out his file
1326 strcpy(Pilots[0], buf);
1328 // if this is the first guy, we should set the Player struct
1329 if (Player == NULL) {
1330 Player = &Players[0];
1331 memset(Player, 0, sizeof(player));
1332 Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE;
1335 strcpy(Player->callsign, buf);
1336 init_new_pilot(Player, !Player_select_clone_flag);
1338 // set him as being a multiplayer pilot if we're in the correct mode
1339 if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) {
1340 Player->flags |= PLAYER_FLAGS_IS_MULTI;
1341 Player->stats.flags |= STATS_FLAG_MULTIPLAYER;
1344 // create his pilot file
1345 write_pilot_file(Player);
1348 memset(Player, 0, sizeof(player));
1351 // make this guy the selected pilot and put him first on the list
1352 Player_select_pilot = 0;
1354 // unset the input mode
1355 player_select_set_input_mode(0);
1357 // clear any pending bottom text
1358 player_select_set_bottom_text("");
1360 // clear any pending middle text
1361 player_select_set_middle_text("");
1363 // ungray all the controls
1364 player_select_set_controls(0);
1366 // evaluate whether or not this is the very first pilot
1367 player_select_eval_very_first_pilot();
1373 // always kill middle text when a char is pressed in input mode
1375 player_select_set_middle_text("");
1380 // draw copyright message on the bottom on the screen
1381 void player_select_display_copyright()
1384 char Copyright_msg1[256], Copyright_msg2[256];
1387 gr_set_color_fast(&Color_bright);
1390 sprintf(Copyright_msg1, XSTR("Descent: FreeSpace - The Great War, Copyright %c 1998, Volition, Inc.", 384), '\xA8');
1392 sprintf(Copyright_msg1, XSTR("Descent: FreeSpace - The Great War, Copyright %c 1998, Volition, Inc.", 384), '\x83');
1394 sprintf(Copyright_msg2, XSTR("All Rights Reserved", 385));
1396 gr_set_color_fast(&Color_white);
1398 sprintf(Copyright_msg1, NOX("FreeSpace 2"));
1400 sprintf(Copyright_msg2, XSTR("Copyright %c 1999, Volition, Inc. All rights reserved.", 385), '\xA8');
1402 sprintf(Copyright_msg2, XSTR("Copyright %c 1999, Volition, Inc. All rights reserved.", 385), '\x83');
1406 gr_get_string_size(&w, NULL, Copyright_msg1);
1407 sx = fl2i((gr_screen.max_w / 2) - w/2.0f + 0.5f);
1408 sy = (gr_screen.max_h - 2) - 2*gr_get_font_height();
1409 gr_string(sx, sy, Copyright_msg1);
1411 gr_get_string_size(&w, NULL, Copyright_msg2);
1412 sx = fl2i((gr_screen.max_w / 2) - w/2.0f + 0.5f);
1413 sy = (gr_screen.max_h - 2) - gr_get_font_height();
1414 gr_string(sx, sy, Copyright_msg2);
1417 void player_select_display_all_text()
1421 // only draw if we actually have a valid string
1422 if (strlen(Player_select_bottom_text)) {
1423 gr_get_string_size(&w, &h, Player_select_bottom_text);
1425 w = (gr_screen.max_w - w) / 2;
1427 gr_set_color_fast(&Color_bright);
1429 gr_set_color_fast(&Color_bright_white);
1431 gr_printf(w, Player_select_bottom_text_y[gr_screen.res], Player_select_bottom_text);
1434 // only draw if we actually have a valid string
1435 if (strlen(Player_select_middle_text)) {
1436 gr_get_string_size(&w, &h, Player_select_middle_text);
1438 w = (gr_screen.max_w - w) / 2;
1439 gr_set_color_fast(&Color_bright_white);
1440 gr_printf(w, Player_select_middle_text_y[gr_screen.res], Player_select_middle_text);
1444 int player_select_pilot_file_filter(char *filename)
1446 return !verify_pilot_file(filename, Player_select_mode == PLAYER_SELECT_MODE_SINGLE);
1449 void player_select_set_bottom_text(char *txt)
1452 strncpy(Player_select_bottom_text, txt, 149);
1456 void player_select_set_middle_text(char *txt)
1459 strncpy(Player_select_middle_text, txt, 149);
1463 void player_select_eval_very_first_pilot()
1465 // never bring up the initial main hall help overlay
1466 // Player_select_very_first_pilot = 0;
1468 // if we already have this flag set, check to see if our callsigns match
1469 if(Player_select_very_first_pilot){
1470 // if the callsign has changed, unset the flag
1471 if(strcmp(Player_select_very_first_pilot_callsign,Pilots[Player_select_pilot])){
1472 Player_select_very_first_pilot = 0;
1475 // otherwise check to see if there is only 1 pilot
1477 if((Player_select_num_pilots == 1) && (Player_select_initial_count == 0)){
1479 Player_select_very_first_pilot = 1;
1480 strcpy(Player_select_very_first_pilot_callsign,Pilots[Player_select_pilot]);
1485 void player_select_commit()
1487 // if we've gotten to this point, we should have ensured this was the case
1488 Assert(Player_select_num_pilots > 0);
1490 gameseq_post_event(GS_EVENT_MAIN_MENU);
1491 gamesnd_play_iface(SND_COMMIT_PRESSED);
1493 // evaluate if this is the _very_ first pilot
1494 player_select_eval_very_first_pilot();
1497 void player_select_cancel_create()
1501 Player_select_num_pilots--;
1503 // make sure we correct the Selected_pilot index to account for the cancelled action
1504 if (Player_select_num_pilots == 0) {
1505 Player_select_pilot = -1;
1508 // move all pilots down
1509 for (idx=0; idx<Player_select_num_pilots; idx++) {
1510 strcpy(Pilots[idx], Pilots[idx + 1]);
1513 // unset the input mode
1514 player_select_set_input_mode(0);
1516 // clear any bottom text
1517 player_select_set_bottom_text("");
1519 // clear any middle text
1520 player_select_set_middle_text("");
1522 // ungray all controls
1523 player_select_set_controls(0);
1525 // disable the autoaccept
1526 Player_select_autoaccept = 0;
1529 DCF(bastion,"Sets the player to be on the bastion")
1531 if(gameseq_get_state() == GS_STATE_INITIAL_PLAYER_SELECT){
1532 Player_select_force_bastion = 1;
1533 dc_printf("Player is now in the Bastion\n");
1537 #define MAX_PLAYER_TIPS 40
1539 char *Player_tips[MAX_PLAYER_TIPS];
1540 int Num_player_tips;
1541 int Player_tips_shown = 0;
1544 void player_tips_init()
1547 Num_player_tips = 0;
1549 // begin external localization stuff
1552 read_file_text("tips.tbl");
1555 while(!optional_string("#end")){
1556 required_string("+Tip:");
1558 if(Num_player_tips >= MAX_PLAYER_TIPS){
1561 Player_tips[Num_player_tips++] = stuff_and_malloc_string(F_NAME, NULL, 1024);
1564 // stop externalizing, homey
1569 void player_tips_close()
1574 for (i=0; i<MAX_PLAYER_TIPS; i++) {
1575 if (Player_tips[i]) {
1576 free(Player_tips[i]);
1577 Player_tips[i] = NULL;
1583 void player_tips_popup()
1588 // player has disabled tips
1589 if((Player != NULL) && !Player->tips){
1592 // only show tips once per instance of Freespace
1593 if(Player_tips_shown == 1){
1596 Player_tips_shown = 1;
1598 // randomly pick one
1599 tip = (int)frand_range(0.0f, (float)Num_player_tips - 1.0f);
1604 sprintf(all_txt, XSTR("NEW USER TIP\n\n%s", 1565), Player_tips[tip]);
1605 ret = popup(PF_NO_SPECIAL_BUTTONS | PF_TITLE | PF_TITLE_WHITE, 3, XSTR("&Ok", 669), XSTR("&Next", 1444), XSTR("Don't show me this again", 1443), all_txt);
1611 if(tip >= Num_player_tips - 1){
1618 // don't show me this again
1622 write_pilot_file(Player);