FS2_Open
Open source remastering of the Freespace 2 engine
barracks.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #include <ctype.h>
13 
14 
15 #include "cfile/cfile.h"
16 #include "freespace2/freespace.h"
17 #include "gamehelp/contexthelp.h"
19 #include "gamesnd/gamesnd.h"
20 #include "globalincs/alphacolors.h"
21 #include "graphics/font.h"
22 #include "io/key.h"
23 #include "io/mouse.h"
24 #include "menuui/barracks.h"
25 #include "menuui/playermenu.h"
27 #include "osapi/osregistry.h"
28 #include "parse/parselo.h"
29 #include "pilotfile/pilotfile.h"
30 #include "playerman/managepilot.h"
31 #include "playerman/player.h"
32 #include "popup/popup.h"
33 #include "ship/ship.h"
34 #include "ui/ui.h"
35 
36 
37 
38 
39 //Returns 0 on failure, 1 on success
40 int delete_pilot_file( char *pilot_name ); // manage_pilot.cpp
41 
42 // stats defines
43 //#define NUM_STAT_LINES (21 + MAX_SHIP_CLASSES) // Goober5000
44 #define STAT_COLUMN1_W 40
45 #define STAT_COLUMN2_W 10
46 
47 static int Stat_column1_w[GR_NUM_RESOLUTIONS] =
48 {
49  40, // GR_640
50  40 // GR_1024
51 };
52 
53 static int Stat_column2_w[GR_NUM_RESOLUTIONS] =
54 {
55  10, // GR_640
56  10 // GR_1024
57 };
58 
59 // constants for coordinate lookup
60 #define BARRACKS_X_COORD 0
61 #define BARRACKS_Y_COORD 1
62 #define BARRACKS_W_COORD 2
63 #define BARRACKS_H_COORD 3
64 
65 // area ints
66 
67 // pilot selection field
68 static int Barracks_list_coords[GR_NUM_RESOLUTIONS][4] = {
69  { // GR_640
70  42, 34, 400, 90
71  },
72  { // GR_1024
73  45, 51, 646, 144
74  }
75 };
76 
77 // pilot stats field
78 static int Barracks_stats_coords[GR_NUM_RESOLUTIONS][4] = {
79  { // GR_640
80  32, 212, 240, 250
81  },
82  { // GR_1024
83  42, 351, 240, 400
84  }
85 };
86 
87 static int Barracks_stats2_coords[GR_NUM_RESOLUTIONS][3] = {
88  { // GR_640
89  276, 212, 81 // X2, , W2
90  },
91  { // GR_1024
92  286, 351, 81 // X2, , W2
93  }
94 };
95 
96 // pilot picture field
97 static int Barracks_image_coords[GR_NUM_RESOLUTIONS][4] = {
98  { // GR_640
99  461, 23, 160, 120
100  },
101  { // GR_1024
102  782, 58, 160, 120
103  }
104 };
105 
106 // pilot picture # of # location
107 static int Barracks_image_number_coords[GR_NUM_RESOLUTIONS][2] = {
108  { // GR_640
109  461, 145
110  },
111  { // GR_1024
112  732, 239
113  }
114 };
115 
116 // pilot squad logo field
118  { // GR_640
119  495, 177, 128, 128
120  },
121  { // GR_1024
122  829, 323, 128, 128
123  }
124 };
125 
126 // pilot squad # of # location
128  { // GR_640
129  492, 307
130  },
131  { // GR_1024
132  794, 500
133  }
134 };
135 
136 // button defines
137 #define BARRACKS_NUM_BUTTONS 19
138 
139 // pilot selection buttons
140 #define B_PILOT_CREATE_BUTTON 0 // B_PILOT_CREATE_BUTTON
141 #define B_PILOT_SCROLL_UP_BUTTON 1 // B_PILOT_SCROLL_UP_BUTTON
142 #define B_PILOT_SCROLL_DOWN_BUTTON 2 // B_PILOT_SCROLL_DOWN_BUTTON
143 #define B_PILOT_DELETE_BUTTON 11 // B_PILOT_B_PILOT_DELETE_BUTTON
144 #define B_PILOT_SET_ACTIVE_BUTTON 12 // B_PILOT_B_PILOT_SET_ACTIVE_BUTTON
145 #define B_PILOT_CLONE_BUTTON 13 // B_PILOT_B_PILOT_CLONE_BUTTON
146 #define B_PILOT_SINGLE_MODE_BUTTON 14 // B_PILOT_SINGLE_MODE_BUTTON
147 #define B_PILOT_MULTI_MODE_BUTTON 15 // B_PILOT_MULTI_MODE_BUTTON
148 #define B_PILOT_CONVERT_BUTTON 16 // B_PILOT_B_PILOT_CONVERT_BUTTON
149 
150 // squad logo picture buttons
151 #define B_SQUAD_PREV_BUTTON 17
152 #define B_SQUAD_NEXT_BUTTON 18
153 
154 // pilot picture buttons
155 #define B_PIC_PREV_PILOT_BUTTON 3 // B_PILOT_B_PIC_PREV_PILOT_BUTTON
156 #define B_PIC_NEXT_PILOT_BUTTON 4 // B_PILOT_B_PIC_NEXT_PILOT_BUTTON
157 
158 // pilot stat buttons
159 #define B_STATS_MEDAL_BUTTON 8 // B_STATS_MEDAL_BUTTON
160 #define B_STATS_SCROLL_DOWN_BUTTON 9 // B_STATS_SCROLL_DOWN_BUTTON
161 #define B_STATS_SCROLL_UP_BUTTON 10 // B_STATS_SCROLL_UP_BUTTON
162 
163 // general buttons
164 #define B_ACCEPT_BUTTON 5 // B_B_ACCEPT_BUTTON
165 #define B_HELP_BUTTON 6 // B_B_HELP_BUTTON
166 #define B_OPTION_BUTTON 7 // B_OPTION_BUTTON
167 
168 //XSTR:OFF
169 // bitmaps defs
170 static char *Barracks_bitmap_fname[GR_NUM_RESOLUTIONS] = {
171  "Barracks", // GR_640
172  "2_Barracks" // GR_1024
173 };
174 
175 static char *Barracks_bitmap_mask_fname[GR_NUM_RESOLUTIONS] = {
176  "Barracks-M", // GR_640
177  "2_Barracks-M" // GR_1024
178 };
179 
180 //XSTR:ON
181 
182 #define BARRACKS_IMAGE_NOT_LOADED -2
183 
185  char *filename;
186  int x, y;
187  int b;
188 };
189 
191  char *filename;
192  int x, y;
193  int text_x, text_y; // this is where the text label is
194  int hotspot;
195  int repeat;
196  UI_BUTTON button; // because we have a class inside this struct, we need the constructor below..
197 
198  barracks_buttons(char *name, int x1, int y1, int x2, int y2, int h, int r = 0) : filename(name), x(x1), y(y1), text_x(x2), text_y(y2), hotspot(h), repeat(r) {}
199 };
200 
201 static int Background_bitmap = -1;
202 static UI_WINDOW Ui_window;
203 static UI_BUTTON List_region;
204 static UI_INPUTBOX Inputbox;
205 
207 //XSTR:OFF
208  { // GR_640
209  barracks_buttons("BAB_00", 8, 122, 11, 157, 0),
210  barracks_buttons("BAB_01", 323, 130, 0, 0, 1, 1),
211  barracks_buttons("BAB_02", 350, 130, 0, 0, 2, 1),
212  barracks_buttons("BAB_03", 559, 143, 0, 0, 3, 1),
213  barracks_buttons("BAB_04", 598, 143, 0, 0, 4, 1),
214  barracks_buttons("BAB_05", 571, 425, 578, 413, 5),
215  barracks_buttons("BAB_06", 533, 425, 500, 438, 6),
216  barracks_buttons("BAB_07", 533, 453, 481, 465, 7),
217  barracks_buttons("BAB_08", 361, 425, 401, 465, 8),
218  barracks_buttons("BAB_09", 0, 267, 0, 0, 9, 1),
219  barracks_buttons("BAB_10", 0, 224, 0, 0, 10,1),
220  barracks_buttons("BAB_11", 120, 122, 123, 157, 11),
221  barracks_buttons("BAB_12", 376, 124, 378, 163, 12),
222  barracks_buttons("BAB_13", 66, 122, 69, 157, 13),
223  barracks_buttons("BAB_14", 323, 0, 324, 25, 14),
224  barracks_buttons("BAB_15", 372, 0, 374, 25, 15),
225  barracks_buttons("BAB_16", 180, 122, 182, 157, 16),
226  barracks_buttons("BAB_17", 559, 306, 0, 0, 17),
227  barracks_buttons("BAB_18", 598, 306, 0, 0, 18)
228  },
229  { // GR_1024
230  barracks_buttons("2_BAB_00", 14, 196, 35, 252, 0),
231  barracks_buttons("2_BAB_01", 518, 209, 0, 0, 1, 1),
232  barracks_buttons("2_BAB_02", 561, 209, 0, 0, 2, 1),
233  barracks_buttons("2_BAB_03", 896, 229, 0, 0, 3, 1),
234  barracks_buttons("2_BAB_04", 958, 229, 0, 0, 4, 1),
235  barracks_buttons("2_BAB_05", 914, 681, 932, 665, 5),
236  barracks_buttons("2_BAB_06", 854, 681, 800, 704, 6),
237  barracks_buttons("2_BAB_07", 854, 724, 778, 743, 7),
238  barracks_buttons("2_BAB_08", 579, 681, 641, 743, 8),
239  barracks_buttons("2_BAB_09", 0, 428, 0, 0, 9, 1),
240  barracks_buttons("2_BAB_10", 0, 360, 0, 0, 10,1),
241  barracks_buttons("2_BAB_11", 193, 196, 214, 252, 11),
242  barracks_buttons("2_BAB_12", 602, 200, 617, 262, 12),
243  barracks_buttons("2_BAB_13", 107, 196, 128, 252, 13),
244  barracks_buttons("2_BAB_14", 517, 0, 532, 40, 14),
245  barracks_buttons("2_BAB_15", 596, 0, 614, 40, 15),
246  barracks_buttons("2_BAB_16", 289, 196, 309, 252, 16),
247  barracks_buttons("2_BAB_17", 896, 491, 0, 0, 17),
248  barracks_buttons("2_BAB_18", 958, 491, 0, 0, 18)
249  }
250 //XSTR:ON
251 };
252 
253 
254 // FIXME add to strings.tbl, set correct coords
255 #define BARRACKS_NUM_TEXT 2
257  {
258  // GR_640
259  { "Barracks", 1434, 17, 7, UI_XSTR_COLOR_GREEN, -1, NULL },
260  { "Pilot Stats", 1435, 17, 180, UI_XSTR_COLOR_GREEN, -1, NULL }
261  },
262  {
263  // GR_1024
264  { "Barracks", 1434, 27, 11, UI_XSTR_COLOR_GREEN, -1, NULL },
265  { "Pilot Stats", 1435, 27, 288, UI_XSTR_COLOR_GREEN, -1, NULL }
266  }
267 };
268 
269 
270 static int Num_stat_lines;
271 static char (*Stat_labels)[STAT_COLUMN1_W];
272 static char (*Stats)[STAT_COLUMN2_W];
273 
274 static int Player_sel_mode;
275 
276 static player *Cur_pilot;
277 static int Num_pilots;
278 static int Selected_line;
280 static char *Pilots[MAX_PILOTS];
281 static int Pic_number;
282 static int Pic_squad_number;
283 static bool Barracks_callsign_enter_mode;
284 static int Pilot_ranks[MAX_PILOTS];
285 static int List_scroll_offset;
286 static int Stats_scroll_offset;
287 static int Clone_flag;
288 static int Pilot_images[MAX_PILOT_IMAGES];
289 static int Pilot_squad_images[MAX_PILOT_IMAGES];
290 static int Rank_pips_bitmaps;
291 static int Rank_pips_count;
292 
294 
296 
297 
298 // -------------------------------------------------------------------------------------------------
299 //
300 // BARRACKS screen
301 //
302 
303 #define STRCPY1(a, b) do { \
304  Assert(strlen(b) < STAT_COLUMN1_W); \
305  strcpy_s(a, b); \
306 } while (0)
307 
309 {
310  int Max_stat_lines = Ship_info.size() + 23;
311  int i;
312  float f;
313  int score_from_kills = 0;
314 
315  //Set up variables
316  if(Stat_labels != NULL)
317  {
318  delete[] Stat_labels;
319  }
320  if(Stats != NULL)
321  {
322  delete[] Stats;
323  }
324 
325  Stat_labels = (char (*)[STAT_COLUMN1_W]) new char[Max_stat_lines * STAT_COLUMN1_W];
326  Stats = (char (*)[STAT_COLUMN2_W]) new char[Max_stat_lines * STAT_COLUMN2_W];
327 
328  //Now start throwing stuff in
329  Num_stat_lines = 0;
330 
331  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "*All Time Stats", 50));
332  Stats[Num_stat_lines][0] = 0;
333  Num_stat_lines++;
334 
335  Assert(Num_stat_lines < Max_stat_lines);
336  Stat_labels[Num_stat_lines][0] = 0;
337  Stats[Num_stat_lines][0] = 0;
338  Num_stat_lines++;
339 
340  Assert(Num_stat_lines < Max_stat_lines);
341  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary weapon shots:", 51));
342  sprintf(Stats[Num_stat_lines], "%u", stats->p_shots_fired);
343  Num_stat_lines++;
344 
345  Assert(Num_stat_lines < Max_stat_lines);
346  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary weapon hits:", 52));
347  sprintf(Stats[Num_stat_lines], "%u", stats->p_shots_hit);
348  Num_stat_lines++;
349 
350  Assert(Num_stat_lines < Max_stat_lines);
351  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary friendly hits:", 53));
352  sprintf(Stats[Num_stat_lines], "%u", stats->p_bonehead_hits);
353  Num_stat_lines++;
354 
355  Assert(Num_stat_lines < Max_stat_lines);
356  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary hit %:", 54));
357  if (stats->p_shots_fired > 0) {
358  f = (float) stats->p_shots_hit * 100.0f / (float) stats->p_shots_fired;
359  } else {
360  f = 0.0f;
361  }
362  sprintf(Stats[Num_stat_lines], XSTR( "%.1f%%", 55), f);
363  Num_stat_lines++;
364 
365  Assert(Num_stat_lines < Max_stat_lines);
366  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Primary friendly hit %:", 56));
367  if (stats->p_shots_fired > 0) {
368  f = (float) stats->p_bonehead_hits * 100.0f / (float) stats->p_shots_fired;
369  } else {
370  f = 0.0f;
371  }
372  sprintf(Stats[Num_stat_lines], XSTR( "%.1f%%", 55), f);
373  Num_stat_lines++;
374 
375  Assert(Num_stat_lines < Max_stat_lines);
376  Stat_labels[Num_stat_lines][0] = 0;
377  Stats[Num_stat_lines][0] = 0;
378  Num_stat_lines++;
379 
380  Assert(Num_stat_lines < Max_stat_lines);
381  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary weapon shots:", 57));
382  sprintf(Stats[Num_stat_lines], "%u", stats->s_shots_fired);
383  Num_stat_lines++;
384 
385  Assert(Num_stat_lines < Max_stat_lines);
386  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary weapon hits:", 58));
387  sprintf(Stats[Num_stat_lines], "%u", stats->s_shots_hit);
388  Num_stat_lines++;
389 
390  Assert(Num_stat_lines < Max_stat_lines);
391  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary friendly hits:", 59));
392  sprintf(Stats[Num_stat_lines], "%u", stats->s_bonehead_hits);
393  Num_stat_lines++;
394 
395  Assert(Num_stat_lines < Max_stat_lines);
396  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary hit %:", 60));
397  if (stats->s_shots_fired > 0) {
398  f = (float) stats->s_shots_hit * 100.0f / (float) stats->s_shots_fired;
399  } else {
400  f = 0.0f;
401  }
402  sprintf(Stats[Num_stat_lines], XSTR( "%.1f%%", 55), f);
403  Num_stat_lines++;
404 
405  Assert(Num_stat_lines < Max_stat_lines);
406  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Secondary friendly hit %:", 61));
407  if (stats->s_shots_fired > 0) {
408  f = (float) stats->s_bonehead_hits * 100.0f / (float) stats->s_shots_fired;
409  } else {
410  f = 0.0f;
411  }
412  sprintf(Stats[Num_stat_lines], XSTR( "%.1f%%", 55), f);
413  Num_stat_lines++;
414 
415  Assert(Num_stat_lines < Max_stat_lines);
416  Stat_labels[Num_stat_lines][0] = 0;
417  Stats[Num_stat_lines][0] = 0;
418  Num_stat_lines++;
419 
420  Assert(Num_stat_lines < Max_stat_lines);
421  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Total kills:", 62));
422  sprintf(Stats[Num_stat_lines], "%d", stats->kill_count_ok);
423  Num_stat_lines++;
424 
425  Assert(Num_stat_lines < Max_stat_lines);
426  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Assists:", 63));
427  sprintf(Stats[Num_stat_lines], "%d", stats->assists);
428  Num_stat_lines++;
429 
430  Assert(Num_stat_lines < Max_stat_lines);
431  Stat_labels[Num_stat_lines][0] = 0;
432  Stats[Num_stat_lines][0] = 0;
433  Num_stat_lines++;
434 
435  Assert(Num_stat_lines < Max_stat_lines);
436  STRCPY1(Stat_labels[Num_stat_lines], "Current Score:");
437  sprintf(Stats[Num_stat_lines], "%d", stats->score);
438  Num_stat_lines++;
439 
440  Assert(Num_stat_lines < Max_stat_lines);
441  Stat_labels[Num_stat_lines][0] = 0;
442  Stats[Num_stat_lines][0] = 0;
443  Num_stat_lines++;
444 
445  Assert(Num_stat_lines < Max_stat_lines);
446  Stat_labels[Num_stat_lines][0] = 0;
447  Stats[Num_stat_lines][0] = 0;
448  Num_stat_lines++;
449 
450  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "*Kills by Ship Type", 64));
451  Stats[Num_stat_lines][0] = 0;
452  Num_stat_lines++;
453 
454  Assert(Num_stat_lines < Max_stat_lines);
455  Stat_labels[Num_stat_lines][0] = 0;
456  Stats[Num_stat_lines][0] = 0;
457  Num_stat_lines++;
458 
459  // Goober5000 - make sure we have room for all ships
460  Assert((Num_stat_lines + static_cast<int>(Ship_info.size())) < Max_stat_lines);
461 
462  i = 0;
463  for (auto it = Ship_info.cbegin(); it != Ship_info.cend(); i++, ++it) {
464  if (stats->kills[i]) {
465  Assert(Num_stat_lines < Max_stat_lines);
466 
467  // Goober5000 - in case above Assert isn't triggered (such as in non-debug builds)
468  if (Num_stat_lines >= Max_stat_lines)
469  {
470  break;
471  }
472 
473  Assert(strlen(it->name) + 1 < STAT_COLUMN1_W);
474  sprintf(Stat_labels[Num_stat_lines], NOX("%s:"), it->name);
475  sprintf(Stats[Num_stat_lines], "%d", stats->kills[i]);
476  Num_stat_lines++;
477 
478  // work out the total score from ship kills
479  score_from_kills += stats->kills[i] * it->score;
480  }
481  }
482 
483  // add the score from kills
484  Assert((Num_stat_lines + 1) < Max_stat_lines);
485  STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Score from kills only:", 1636));
486  sprintf(Stats[Num_stat_lines], "%d", score_from_kills);
487  Num_stat_lines++;
488 
489  for (i=0; i<Num_stat_lines; i++) {
490  gr_force_fit_string(Stat_labels[i], Stat_column1_w[gr_screen.res], Barracks_stats_coords[gr_screen.res][BARRACKS_W_COORD]);
491  gr_force_fit_string(Stats[i], Stat_column2_w[gr_screen.res], Barracks_stats2_coords[gr_screen.res][BARRACKS_W_COORD]);
492  }
493 }
494 
495 // sets or clears hotkeys for pilot selection.
496 void barracks_set_hotkeys(bool pilot_text_enter_mode)
497 {
498  Buttons[gr_screen.res][B_PILOT_SCROLL_UP_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_UP : -1);
499  Buttons[gr_screen.res][B_PILOT_SCROLL_DOWN_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_DOWN : -1);
500 
501  Buttons[gr_screen.res][B_PILOT_CREATE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_C : -1);
502  Buttons[gr_screen.res][B_PILOT_SET_ACTIVE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_ENTER : -1);
503  Buttons[gr_screen.res][B_PILOT_DELETE_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_DELETE : -1);
504 
505  Buttons[gr_screen.res][B_PIC_PREV_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_LEFT : -1);
506  Buttons[gr_screen.res][B_PIC_NEXT_PILOT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_RIGHT : -1);
507 
508  Buttons[gr_screen.res][B_ACCEPT_BUTTON].button.set_hotkey(pilot_text_enter_mode ? KEY_CTRLED | KEY_ENTER : -1);
509 }
510 
511 // strip the possible .pcx extension off a filename
512 void barracks_strip_pcx(char *str)
513 {
514  int flen = strlen(str);
515  int elen = 4;
516  if ((flen > 4) && !stricmp(str + flen - elen, ".pcx")) {
517  str[flen - elen] = '\0';
518  }
519 }
520 
521 // new pilot name has focus, so update stats/pic to that pilot
523 {
524  char stripped[MAX_FILENAME_LEN+1] = "";
525 
526  // save the previous pilot first, so changes to it are kept
527  if (strlen(Cur_pilot->callsign)) {
528  Pilot.save_player(Cur_pilot);
529  }
530 
531  // check if we have a valid pilot hilighted. If so, attempt to active it
532  if ((Num_pilots < 1) || (Selected_line < 0) || (Selected_line >= Num_pilots)) {
533  Cur_pilot->callsign[0] = 0; // this indicates no pilot active
534  return -1;
535  }
536 
537  if ( !Pilot.load_player(Pilots[Selected_line], Cur_pilot) ) {
538  Cur_pilot->callsign[0] = 0; // this indicates no pilot active
539  return -1;
540  } else {
541  if (!Pilot.load_savefile(Cur_pilot->current_campaign)) {
542  // set single player squad image to multi if campaign can't be loaded
543  strcpy_s(Cur_pilot->s_squad_filename, Cur_pilot->m_squad_filename);
544  }
545  }
546 
547  // init stuff to reflect new pilot
548  int i;
549  barracks_init_stats(&Cur_pilot->stats);
550  strcpy_s(stripped, Cur_pilot->image_filename);
551  barracks_strip_pcx(stripped);
552  for (i=0; i<Num_pilot_images; i++) {
553  if (!stricmp(stripped, Pilot_image_names[i])) {
554  break;
555  }
556  }
557  Pic_number = i;
558 
559  if (Game_mode & GM_MULTIPLAYER) {
560  strcpy_s(stripped, Cur_pilot->m_squad_filename);
561  } else {
562  strcpy_s(stripped, Cur_pilot->s_squad_filename);
563  }
564  barracks_strip_pcx(stripped);
565  for ( i=0; i<Num_pilot_squad_images; i++) {
566  if (!stricmp(stripped, Pilot_squad_image_names[i])) {
567  break;
568  }
569  }
570  Pic_squad_number = i;
571 
572  return 0;
573 }
574 
575 void barracks_set_callsign_enter_mode(bool set_callsign_enter_mode)
576 {
577  // set global mode variable
578  Barracks_callsign_enter_mode = set_callsign_enter_mode;
579 
580  // disable/enable all buttons
581  for (int idx=0; idx<BARRACKS_NUM_BUTTONS; idx++) {
582  // don't ever mess with the prev and next squad logo buttons
584  Buttons[gr_screen.res][idx].button.enable(!set_callsign_enter_mode);
585  }
586  }
587 
588  // enable/disable hotkeys
589  barracks_set_hotkeys(!set_callsign_enter_mode);
590  // disable/enable inputbox
591  Inputbox.enable(set_callsign_enter_mode);
592  // hide/unhide inputbox
593  Inputbox.hide(!set_callsign_enter_mode);
594 }
595 
596 // creates a new pilot file
598 {
599  // check if too many pilots
600  if (Num_pilots >= MAX_PILOTS) {
602  return;
603  }
604 
605  // play sound for pilot creation
607 
608  // only write pilot file if there is an active pilot
609  if (strlen(Player->callsign)) {
611  }
612 
613  // move other pilot names and ranks down to make room for the new one
614  int idx = Num_pilots;
615  Assert(Num_pilots >= 0);
616  while (idx--) {
617  strcpy(Pilots[idx + 1], Pilots[idx]);
618  Pilot_ranks[idx + 1] = Pilot_ranks[idx];
619  }
620 
621  Selected_line = 0;
622  Num_pilots++;
623  Pilots[Selected_line][0] = 0;
624  Pilot_ranks[Selected_line] = 0;
625  List_scroll_offset = 0;
626 
627  // set mode to accept pilot name text
629  // set focus to input box
630  Inputbox.set_focus();
631  // set initial pilot name to ""
632  Inputbox.set_text("");
633  // reset size of input box to only 1 line
634  Inputbox.update_dimensions(Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_W_COORD], gr_get_font_height());
635 }
636 
637 // exiting screen without canceling, so load in the new pilot selected here
639 {
640  // check if pilot active. If not, don't allow accept.
641  if (!Cur_pilot->callsign[0]){
642  return -1;
643  }
644 
645  // check that pilot language is OK
646  if (!valid_pilot_lang(Cur_pilot->callsign)) {
648  "Selected pilot was created with a different language\n"
649  "to the currently active language.\n\n"
650  "Please select a different pilot or change the language", 1637));
651  return -1;
652  }
653 
654  // set pilot image
655  if (Game_mode & GM_MULTIPLAYER) {
656  player_set_squad_bitmap(Cur_pilot, Cur_pilot->m_squad_filename, true);
657  } else {
658  player_set_squad_bitmap(Cur_pilot, Cur_pilot->s_squad_filename, false);
659  }
660 
661  // MWA -- I think that we should be writing Cur_pilot here.
662  Pilot.save_player(Cur_pilot);
663 
664  os_config_write_string(NULL, "LastPlayer", Cur_pilot->callsign);
665 
666  return 0;
667 }
668 
669 // scroll up barracks pilot list one line
671 {
672  if (Selected_line > 0) {
673  Selected_line--;
675  } else {
677  }
678 
679  if ((Selected_line >= 0) && (Selected_line < List_scroll_offset)) {
680  List_scroll_offset = Selected_line;
681  }
682 }
683 
684 // scroll down barracks pilot list one line
686 {
687  if (Selected_line < Num_pilots - 1) {
688  Selected_line++;
690  } else {
692  }
693 
694  // num_pilots_to_fill_height is the number of pilots that can fit in given height
695  int num_pilots_to_fill_height = Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD] / gr_get_font_height();
696  if (Selected_line >= List_scroll_offset + num_pilots_to_fill_height) {
697  List_scroll_offset++;
698  }
699 }
700 
701 // scroll up barracks stats list one line
703 {
704  if (Stats_scroll_offset > 0) {
705  Stats_scroll_offset--;
707  } else {
709  }
710 }
711 
712 // scroll down barracks stats list one line
714 {
715  int font_height = gr_get_font_height();
716 
717  if (Stats_scroll_offset + Barracks_stats_coords[gr_screen.res][BARRACKS_H_COORD] / font_height < Num_stat_lines) {
718  Stats_scroll_offset++;
720  } else {
722  }
723 }
724 
725 // show previous pilot pic
727 {
728  // check if no pilot images or no pilot selected
729  if ((Num_pilot_images == 0) || (Cur_pilot->callsign[0] == '\0')) {
731  return;
732  }
733 
734  // reset pilot pic number
735  Pic_number--;
736  if (Pic_number < 0) {
737  Pic_number = Num_pilot_images - 1;
738  }
739 
740  // copy pilot pic filename into pilot struct
741  if ((Pic_number >= 0) && (Pic_number < Num_pilot_images)) {
742  strcpy_s(Cur_pilot->image_filename, Pilot_image_names[Pic_number]);
743  }
744 
745  // play scroll sound
747 }
748 
749 // show next pilot pic
751 {
752  // check if no pilot images or no pilot selected
753  if ((Num_pilot_images == 0) || (Cur_pilot->callsign[0] == '\0')) {
755  return;
756  }
757 
758  // reset pilot pic number
759  Pic_number++;
760  if (Pic_number >= Num_pilot_images){
761  Pic_number = 0;
762  }
763 
764  // copy pilot pic filename into pilot struct
765  if ((Pic_number >= 0) && (Pic_number < Num_pilot_images)){
766  strcpy_s(Cur_pilot->image_filename, Pilot_image_names[Pic_number]);
767  }
768 
769  // play scroll sound
771 }
772 
773 // show previous squad pic
775 {
776  // check if no squad images or no pilot selected
777  if ((Num_pilot_squad_images == 0) || (Cur_pilot->callsign[0] == '\0')) {
779  return;
780  }
781 
782  // reset squad pic number
783  Pic_squad_number--;
784  if (Pic_squad_number < 0) {
785  Pic_squad_number = Num_pilot_squad_images - 1;
786  }
787 
788  // copy squad pic filename into pilot struct
789  if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)) {
790  if (Game_mode & GM_MULTIPLAYER) {
791  strcpy_s(Cur_pilot->m_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
792  } else {
793  strcpy_s(Cur_pilot->s_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
794  }
795  }
796 
797  // play scroll sound
799 }
800 
801 // show next squad pic
803 {
804  // check if no squad images or no pilot selected
805  if ((Num_pilot_squad_images == 0) || (Cur_pilot->callsign[0] == '\0')) {
807  return;
808  }
809 
810  // reset squad pic number
811  Pic_squad_number++;
812  if (Pic_squad_number >= Num_pilot_squad_images){
813  Pic_squad_number = 0;
814  }
815 
816  // copy squad pic filename into pilot struct
817  if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)){
818  if (Game_mode & GM_MULTIPLAYER) {
819  strcpy_s(Cur_pilot->m_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
820  } else {
821  strcpy_s(Cur_pilot->s_squad_filename, Pilot_squad_image_names[Pic_squad_number]);
822  }
823  }
824 
825  // play scroll sound
827 }
828 
830 {
831  char buf[MAX_FILENAME_LEN];
832  int active = 0;
833  int del_rval;
834 
835  if (!Num_pilots) {
837  return;
838  }
839 
840  if (Player_sel_mode == PLAYER_SELECT_MODE_MULTI) {
842  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. "
843  "Deleting a multi-player pilot will also delete all single-player data for that pilot.\n\nAs a safety precaution, pilots can only be "
844  "deleted from the single-player menu.", 1598));
845  return;
846  }
847 
848  int popup_rval = popup(PF_TITLE_BIG | PF_TITLE_RED, 2, POPUP_NO, POPUP_YES, XSTR( "Warning!\n\nAre you sure you wish to delete this pilot?", 65));
849  if (popup_rval != 1) {
850  return;
851  }
852 
853  if (!stricmp(Pilots[Selected_line], Cur_pilot->callsign)) {
854  active = 1;
855  }
856 
857  strcpy_s(buf, Pilots[Selected_line]);
858 
859  del_rval = delete_pilot_file(buf);
860 
861  if ( !del_rval ) {
862  popup(PF_USE_AFFIRMATIVE_ICON | PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, XSTR("Error\nFailed to delete pilot file. File may be read-only.", 1599));
863  return;
864  } else {
865  if (active) {
866  Cur_pilot->callsign[0] = 0;
867  }
868  }
869 
870  for (int i=Selected_line; i<Num_pilots-1; i++) {
871  strcpy(Pilots[i], Pilots[i + 1]);
872  Pilot_ranks[i] = Pilot_ranks[i + 1];
873  }
874 
875  Num_pilots--;
876  if (Selected_line >= Num_pilots) {
877  Selected_line = Num_pilots - 1;
878  }
879 
880  if (active) {
881  if (Selected_line >= 0) {
883  } else {
884  Cur_pilot->callsign[0] = 0;
885  }
886  }
887 
889 }
890 
891 // Filter out pilots of wrong type (which shouldn't be in the directory we are checking, but just to be safe..)
893 {
894  bool r = false;
895  int rank = 0;
896 
897  r = Pilot.verify(filename, &rank);
898 
899  if (rank >= Rank_pips_count)
900  rank = Rank_pips_count - 1;
901 
902  if (r) {
903  Pilot_ranks[Num_pilots++] = rank;
904  }
905 
906  return (int)r;
907 }
908 
909 // callback handler for the squadon selection buttons when they are disabled (in single player)
911 {
912  // show a popup
913  popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR("You cannot change your squadron in Single Player mode.", 1445));
914 }
915 
916 
918 {
919  int i, j;
920 
921  // determine if we should be looking for single or multiplayers at the outset
922  Player_sel_mode = mode;
923 
924  // single player specific stuff
925  if (mode == PLAYER_SELECT_MODE_SINGLE) {
927  Game_mode |= GM_NORMAL;
928 
929  // disable squad logo switching
936  }
937  // multiplayer specific stuff
938  else if (mode == PLAYER_SELECT_MODE_MULTI) {
939  Game_mode &= ~GM_NORMAL;
941 
942  // enable squad logo switching
947  }
948 
949  // get the list of pilots based upon whether we're in single or multiplayer mode
950  // moved down here so pilotfile::verify knows which Game_mode to get ranks for
951  Num_pilots = 0;
953 
955 
956  int ranks[MAX_PILOTS];
957 
958  for (i=0; i<Num_pilots; i++) {
959  for (j=0; j<Num_pilots; j++) {
960  if (!strcmp(Pilots[i], Pilots_arr[j])) {
961  ranks[i] = Pilot_ranks[j];
962  break;
963  }
964  }
965  Assert(j < Num_pilots); // Pilot not found? How is that possible?
966  }
967 
968  for (i=0; i<Num_pilots; i++) {
969  Pilot_ranks[i] = ranks[i];
970  }
971 
972  Selected_line = List_scroll_offset = 0;
974 
975 }
976 
978 {
979  switch (n) {
982  break;
983 
986  break;
987 
990  break;
991 
994  break;
995 
998  break;
999 
1002  break;
1003 
1004  case B_SQUAD_PREV_BUTTON:
1006  break;
1007 
1008  case B_SQUAD_NEXT_BUTTON:
1010  break;
1011 
1015 
1016  // if it's just the missing campaign file that failed for us then don't give the second popup
1017  if (Campaign_file_missing) {
1018  break;
1019  }
1020  } else {
1022 
1023  if (Campaign_file_missing) {
1024  popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "The currently active campaign cannot be found. Please select another...", 1600));
1026  }
1027  }
1028  break;
1029 
1030  case B_ACCEPT_BUTTON:
1031  if (Num_pilots && !barracks_pilot_accepted()) {
1033 
1034  if (Campaign_file_missing) {
1035  popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "The currently active campaign cannot be found. Please select another...", 1600));
1037  } else {
1039  }
1040  } else {
1042 
1043  // if it's just the missing campaign file that failed for us then don't give the second popup
1044  if (Campaign_file_missing) {
1045  break;
1046  }
1047  }
1048  break;
1049 
1050  case B_PILOT_CLONE_BUTTON:
1051  if (Num_pilots < 1) {
1053  break;
1054  }
1055 
1056  Clone_flag = 1;
1058  break;
1059 
1060  case B_PILOT_CONVERT_BUTTON: {
1061  /* New Pilot code no longer needs a conversion function. */
1063  XSTR("Disabled!\n\n\nMulti and Single Player Pilot files are now identical.\n\n"
1064  "Conversion between the two is no longer necessary.", 1601));
1065  /* // no actual conversion with new pilot code
1066  if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) {
1067  barracks_init_player_stuff(PLAYER_SELECT_MODE_MULTI);
1068  } else {
1069  // make sure we don't carry over the multi flag
1070  if (Cur_pilot->flags & PLAYER_FLAGS_IS_MULTI) {
1071  Cur_pilot->flags &= ~PLAYER_FLAGS_IS_MULTI;
1072  }
1073  barracks_init_player_stuff(PLAYER_SELECT_MODE_SINGLE);
1074  }
1075 
1076  gamesnd_play_iface(SND_USER_SELECT); */
1077  break;
1078  }
1079 
1080  case B_PILOT_CREATE_BUTTON:
1081  Clone_flag = 0;
1083  break;
1084 
1085  case B_HELP_BUTTON:
1088  break;
1089 
1090  case B_OPTION_BUTTON:
1093  break;
1094 
1095  case B_STATS_MEDAL_BUTTON:
1098  break;
1099 
1100  case B_PILOT_DELETE_BUTTON:
1102  break;
1103 
1105  if (Player_sel_mode != PLAYER_SELECT_MODE_SINGLE) {
1107  // make sure we don't carry over the multi flag
1108  if (Cur_pilot->flags & PLAYER_FLAGS_IS_MULTI) {
1109  Cur_pilot->flags &= ~PLAYER_FLAGS_IS_MULTI;
1110  }
1111  Pilot.save_player(Cur_pilot);
1113  }
1114  break;
1115 
1117  if ( Networking_disabled ) {
1119  break;
1120  }
1121 
1122  if (Player_sel_mode != PLAYER_SELECT_MODE_MULTI) {
1124  Cur_pilot->flags |= PLAYER_FLAGS_IS_MULTI;
1125  Pilot.save_player(Cur_pilot);
1127  }
1128  break;
1129  }
1130 }
1131 
1132 
1133 void barracks_display_pilot_callsigns(int prospective_pilot)
1134 {
1135  int y = 0;
1136  int cur_pilot_idx = List_scroll_offset;
1137 
1138  int multi = 0;
1139  if (Player_sel_mode == PLAYER_SELECT_MODE_MULTI) {
1140  multi = 1;
1141  }
1142 
1143  int font_height = gr_get_font_height();
1144  while (y + font_height <= Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD]) {
1145  if (cur_pilot_idx >= Num_pilots)
1146  break;
1147 
1148  if (!stricmp(Cur_pilot->callsign, Pilots[cur_pilot_idx]) && multi) {
1150  } else {
1151  if (cur_pilot_idx == Selected_line) {
1153  } else if (cur_pilot_idx == prospective_pilot) {
1155  } else {
1157  }
1158  }
1159 
1160  gr_printf_menu(Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD] + y, Pilots[cur_pilot_idx]);
1161  gr_set_bitmap(Rank_pips_bitmaps + Pilot_ranks[cur_pilot_idx]);
1162  gr_bitmap(Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD] - 34, Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD] + y, GR_RESIZE_MENU);
1163 
1164  y += font_height;
1165  cur_pilot_idx++;
1166  }
1167 }
1168 
1169 
1170 
1172 {
1173  int y = 0;
1174  int z = Stats_scroll_offset;
1175  int font_height = gr_get_font_height();
1176  char *str;
1177  int i, w, h;
1178  while (y + font_height <= Barracks_stats_coords[gr_screen.res][BARRACKS_H_COORD]) {
1179  if (z >= Num_stat_lines) {
1180  break;
1181  }
1182 
1183  str = Stat_labels[z];
1184  if (*str == '*') {
1186  str++;
1187 
1188  gr_get_string_size(&w, &h, str);
1189  i = Barracks_stats_coords[gr_screen.res][BARRACKS_Y_COORD] + y + h / 2 - 1;
1190  gr_line(Barracks_stats_coords[gr_screen.res][BARRACKS_X_COORD], i, Barracks_stats_coords[gr_screen.res][BARRACKS_X_COORD] + Barracks_stats_coords[gr_screen.res][BARRACKS_W_COORD] - w - 2, i, GR_RESIZE_MENU);
1191  gr_line(Barracks_stats_coords[gr_screen.res][BARRACKS_X_COORD] + Barracks_stats_coords[gr_screen.res][BARRACKS_W_COORD] + 1, i, Barracks_stats2_coords[gr_screen.res][BARRACKS_X_COORD] + Barracks_stats2_coords[gr_screen.res][BARRACKS_W_COORD], i, GR_RESIZE_MENU);
1192 
1193  } else {
1195  }
1196 
1197  gr_get_string_size(&w, NULL, str);
1198  gr_printf_menu(Barracks_stats_coords[gr_screen.res][BARRACKS_X_COORD] + Barracks_stats_coords[gr_screen.res][BARRACKS_W_COORD] - w, Barracks_stats_coords[gr_screen.res][BARRACKS_Y_COORD] + y, "%s", str);
1199  str = Stats[z];
1200  if (*str) {
1201  gr_printf_menu(Barracks_stats2_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_stats_coords[gr_screen.res][BARRACKS_Y_COORD] + y, "%s", str);
1202  }
1203 
1204  y += font_height;
1205  z++;
1206  }
1207 }
1208 
1209 
1210 // process pilot callsign
1212 {
1213  char buf[CALLSIGN_LEN + 1];
1214  char name[MAX_FILENAME_LEN];
1215  int i;
1216 
1217  int z = 0;
1218  Inputbox.get_text(buf);
1219  drop_white_space(buf);
1220 
1221  if (!isalpha(*buf)) {
1222  z = 1;
1223  } else {
1224  for (i=1; buf[i]; i++) {
1225  if (!isalpha(buf[i]) && !isdigit(buf[i]) && !strchr(VALID_PILOT_CHARS, buf[i])) {
1226  z = 1;
1227  return;
1228  }
1229  }
1230  }
1231 
1232  for (i=1; i<Num_pilots; i++) {
1233  if (!stricmp(buf, Pilots[i])) {
1234  z = 1;
1235  if (pilot_verify_overwrite() == 1) {
1236  strcpy_s(name, Pilots[Selected_line]);
1237  for (z=i; z<Num_pilots-1; z++) {
1238  strcpy(Pilots[z], Pilots[z + 1]);
1239  Pilot_ranks[z] = Pilot_ranks[z + 1];
1240  }
1241 
1242  Num_pilots--;
1243  delete_pilot_file(name);
1244  z = 0;
1245  }
1246  return;
1247  }
1248  }
1249 
1250  if (!*buf || (i < Num_pilots)) { // duplicate name, alert user
1251  z = 1;
1252  }
1253 
1254  if (z) {
1256  return;
1257  }
1258 
1259  strcpy(Pilots[0], buf);
1260  strcpy_s(Cur_pilot->callsign, buf);
1261  init_new_pilot(Cur_pilot, !Clone_flag);
1262 
1263  // again, make sure we set his flags correctly to ensure that he gets saved to the proper directory and gets
1264  // displayed correctly
1265  if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) {
1266  Cur_pilot->flags &= ~(PLAYER_FLAGS_IS_MULTI);
1267  } else {
1268  Cur_pilot->flags |= PLAYER_FLAGS_IS_MULTI;
1269  Cur_pilot->stats.flags |= STATS_FLAG_MULTIPLAYER;
1270  }
1271 
1272  if ( !(Game_mode & GM_STANDALONE_SERVER) ) {
1273  Pilot.save_player(Cur_pilot);
1274  }
1275 
1276  Selected_line = 0;
1279 }
1280 
1281 
1282 // draw pilot image and clean up afterwards
1284 {
1285  // draw pilot pic
1286  if (Cur_pilot->callsign[0] && (Pic_number >= 0) && (Pic_number < Num_pilot_images)) {
1287  if (Pilot_images[Pic_number] >= 0) {
1288  // JAS: This code is hacked to allow the animation to use all 256 colors
1289  extern int Palman_allow_any_color;
1290  Palman_allow_any_color = 1;
1291  gr_set_bitmap(Pilot_images[Pic_number]);
1292  gr_bitmap(Barracks_image_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_image_coords[gr_screen.res][BARRACKS_Y_COORD], GR_RESIZE_MENU);
1293  Palman_allow_any_color = 0;
1294 
1295  // print number of the current pic
1296  char buf[40];
1297  sprintf(buf, XSTR( "%d of %d", 71), Pic_number + 1, Num_pilot_images);
1298  gr_printf_menu(Barracks_image_number_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_image_number_coords[gr_screen.res][BARRACKS_Y_COORD], buf);
1299  }
1300  } else {
1301  Pic_number = -1;
1302  }
1303 }
1304 
1305 // draw squad image and clean up afterwards
1307 {
1308  char buf[40];
1309 
1310  // draw pilot pic
1311  if (Cur_pilot->callsign[0] && (Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)) {
1312  if (Pilot_squad_images[Pic_squad_number] >= 0) {
1313  // JAS: This code is hacked to allow the animation to use all 256 colors
1314  extern int Palman_allow_any_color;
1315  Palman_allow_any_color = 1;
1316  gr_set_bitmap(Pilot_squad_images[Pic_squad_number]);
1318  Palman_allow_any_color = 0;
1319 
1320  // print number of current squad pic
1321  if(Player_sel_mode != PLAYER_SELECT_MODE_SINGLE){
1322  sprintf(buf,XSTR( "%d of %d", 71), Pic_squad_number+1, Num_pilot_squad_images);
1324  }
1325  }
1326  } else {
1327  Pic_squad_number = -1;
1328  }
1329 }
1330 
1331 // -----------------------------------------------------------------------------
1333 {
1334  //Set these to null, 'cause they aren't allocated yet.
1335  Stat_labels = NULL;
1336  Stats = NULL;
1337 
1338  UI_WINDOW *w = &Ui_window;
1339 
1340  // save current pilot file, so we don't possibly loose it.
1341  Pilot.save_player();
1342 
1343  // create interface
1345  Ui_window.set_mask_bmap(Barracks_bitmap_mask_fname[gr_screen.res]);
1346 
1347  // load background bitmap
1348  Background_bitmap = bm_load(Barracks_bitmap_fname[gr_screen.res]);
1349  if(Background_bitmap < 0){
1350  // we failed to load the bitmap - this is very bad
1351  Int3();
1352  }
1353 
1354  // create buttons
1355  int i;
1356  for (i=0; i<BARRACKS_NUM_BUTTONS; i++) {
1357  // create the object
1358  Buttons[gr_screen.res][i].button.create(&Ui_window, "", Buttons[gr_screen.res][i].x, Buttons[gr_screen.res][i].y, 60, 30, Buttons[gr_screen.res][i].repeat, 1);
1359 
1360  // set the sound to play when highlighted
1362 
1363  // set the ani for the button
1364  Buttons[gr_screen.res][i].button.set_bmaps(Buttons[gr_screen.res][i].filename);
1365 
1366  // set the hotspot
1367  Buttons[gr_screen.res][i].button.link_hotspot(Buttons[gr_screen.res][i].hotspot);
1368  }
1369 
1370  // add all strings
1371  w->add_XSTR("Create", 1034, Buttons[gr_screen.res][0].text_x, Buttons[gr_screen.res][0].text_y, &Buttons[gr_screen.res][0].button, UI_XSTR_COLOR_GREEN);
1372  w->add_XSTR("Accept", 1035, Buttons[gr_screen.res][5].text_x, Buttons[gr_screen.res][5].text_y, &Buttons[gr_screen.res][5].button, UI_XSTR_COLOR_PINK);
1373  w->add_XSTR("Help", 928, Buttons[gr_screen.res][6].text_x, Buttons[gr_screen.res][6].text_y, &Buttons[gr_screen.res][6].button, UI_XSTR_COLOR_GREEN);
1374  w->add_XSTR("Options",1036, Buttons[gr_screen.res][7].text_x, Buttons[gr_screen.res][7].text_y, &Buttons[gr_screen.res][7].button, UI_XSTR_COLOR_GREEN);
1375  w->add_XSTR("Medals", 1037, Buttons[gr_screen.res][8].text_x, Buttons[gr_screen.res][8].text_y, &Buttons[gr_screen.res][8].button, UI_XSTR_COLOR_GREEN);
1376  w->add_XSTR("Remove", 1038, Buttons[gr_screen.res][11].text_x, Buttons[gr_screen.res][11].text_y, &Buttons[gr_screen.res][11].button, UI_XSTR_COLOR_GREEN);
1377  w->add_XSTR("Select", 1552, Buttons[gr_screen.res][12].text_x, Buttons[gr_screen.res][12].text_y, &Buttons[gr_screen.res][12].button, UI_XSTR_COLOR_GREEN);
1378  w->add_XSTR("Clone", 1040, Buttons[gr_screen.res][13].text_x, Buttons[gr_screen.res][13].text_y, &Buttons[gr_screen.res][13].button, UI_XSTR_COLOR_GREEN);
1379  w->add_XSTR("Single", 1041, Buttons[gr_screen.res][14].text_x, Buttons[gr_screen.res][14].text_y, &Buttons[gr_screen.res][14].button, UI_XSTR_COLOR_GREEN);
1380  w->add_XSTR("Multi", 1042, Buttons[gr_screen.res][15].text_x, Buttons[gr_screen.res][15].text_y, &Buttons[gr_screen.res][15].button, UI_XSTR_COLOR_GREEN);
1381 // w->add_XSTR("Convert",1043, Buttons[gr_screen.res][16].text_x, Buttons[gr_screen.res][16].text_y, &Buttons[gr_screen.res][16].button, UI_XSTR_COLOR_GREEN);
1382  for(i=0; i<BARRACKS_NUM_TEXT; i++) {
1383  w->add_XSTR(&Barracks_text[gr_screen.res][i]);
1384  }
1385 
1386  // button for selecting pilot
1387  List_region.create(&Ui_window, "", Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_W_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_H_COORD], 0, 1);
1388  List_region.hide();
1389 
1390  // create input box (for new pilot)
1391  Inputbox.create(&Ui_window, Barracks_list_coords[gr_screen.res][BARRACKS_X_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_Y_COORD], Barracks_list_coords[gr_screen.res][BARRACKS_W_COORD], CALLSIGN_LEN - 1, "", UI_INPUTBOX_FLAG_INVIS | UI_INPUTBOX_FLAG_KEYTHRU | UI_INPUTBOX_FLAG_LETTER_FIRST);
1393  Inputbox.disable();
1394  Inputbox.hide();
1395 
1396  // load in help overlay bitmap
1399 
1400  // other init stuff
1401  Barracks_callsign_enter_mode = 0;
1402  List_scroll_offset = Stats_scroll_offset = Pic_number = Pic_squad_number = Selected_line = 0;
1403  Cur_pilot = &Players[Player_num];
1404 
1405  // disable squad logo selection buttons in single player
1406  if(!(Cur_pilot->flags & PLAYER_FLAGS_IS_MULTI)){
1407  // squad logo picture buttons
1412  } else {
1413  // squad logo picture buttons
1418  }
1419 
1420  // set up hotkeys for buttons so we draw the correct animation frame when a key is pressed
1422 
1423  // load ramp pips
1424  Rank_pips_bitmaps = bm_load_animation("IconRankMini.ani", &Rank_pips_count);
1425 
1426  // load up the pilot pic list
1429 
1430  // don't load pilot images yet
1431  for (i=0; i<MAX_PILOT_IMAGES; i++) {
1432  Pilot_images[i] = BARRACKS_IMAGE_NOT_LOADED; // while -1 is can't load
1433  Pilot_squad_images[i] = BARRACKS_IMAGE_NOT_LOADED;
1434  }
1435 
1436  // init stats
1437  barracks_init_stats(&Cur_pilot->stats);
1438 
1439  // base the mode we're in (single or multi) on the status of the currently selected pilot
1440  barracks_init_player_stuff((Game_mode & GM_MULTIPLAYER) == GM_MULTIPLAYER);
1441 }
1442 
1443 // -----------------------------------------------------------------------------
1444 void barracks_do_frame(float frametime)
1445 {
1446  int k = Ui_window.process();
1447 
1448  if ( k > 0 ) {
1451  k = 0;
1452  }
1453  }
1454 
1455  // pilot that mouse is over
1456  int prospective_pilot = -1;
1457  int i;
1458 
1459  // Entering pilot callsign
1460  if (Barracks_callsign_enter_mode) {
1461  // set focus to inputbox
1462  Inputbox.set_focus();
1463 
1464  switch (k) {
1465  case KEY_ESC:
1466  // cancel create pilot
1467  Num_pilots--;
1468  for (i=0; i<Num_pilots; i++) {
1469  strcpy(Pilots[i], Pilots[i + 1]);
1470  Pilot_ranks[i] = Pilot_ranks[i + 1];
1471  }
1472 
1474  break;
1475 
1476  case KEY_ENTER:
1478  break;
1479  }
1480  } else {
1481  // not entering pilot callsign
1482  switch (k) {
1483  case KEY_ENTER:
1486  } else {
1488  }
1489  break;
1490 
1491  case KEY_ESC: // cancel
1493  if (Num_pilots && !barracks_pilot_accepted()) {
1495  } else {
1497  }
1498  } else {
1499  // kill the overlay
1501  }
1502  break;
1503 
1504  case KEY_TAB: // switch mode (simgle/multi)
1505  if ( Networking_disabled ) {
1507  break;
1508  }
1509 
1510  if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) {
1511  Cur_pilot->flags |= PLAYER_FLAGS_IS_MULTI;
1512  Pilot.save_player(Cur_pilot);
1514  } else {
1515  // make sure we don't carry over the multi flag
1516  Cur_pilot->flags &= ~PLAYER_FLAGS_IS_MULTI;
1517  Pilot.save_player(Cur_pilot);
1519  }
1520 
1522  break;
1523 
1524  case KEY_F1: // show help overlay
1526  break;
1527 
1528  case KEY_F2: // goto options screen
1531  break;
1532  } // end switch
1533 
1534  // process buttons
1535  for (i=0; i<BARRACKS_NUM_BUTTONS; i++) {
1536  if (Buttons[gr_screen.res][i].button.pressed()) {
1538  }
1539  }
1540 
1541  // if mouse is over a pilot, find index into Pilots array
1542  if (List_region.is_mouse_on()) {
1543  int y;
1544  List_region.get_mouse_pos(NULL, &y);
1545  int pilot_index = List_scroll_offset + (y / gr_get_font_height());
1546  if ((pilot_index >= 0) && (pilot_index < Num_pilots)) {
1547  prospective_pilot = pilot_index;
1548  }
1549  }
1550 
1551  // if mouse clicked in list region, find index into Pilots array
1552  if (List_region.pressed()) {
1553  if (prospective_pilot != -1) {
1554  Selected_line = prospective_pilot;
1556  }
1557  }
1558  }
1559 
1560  // check mouse over help
1563  }
1564 
1565  // do pilot pic stuff
1566  if ((Pic_number >= 0) && (Pic_number < Num_pilot_images)) {
1567  if (Pilot_images[Pic_number] == BARRACKS_IMAGE_NOT_LOADED) { // haven't tried loading it yet
1568  Pilot_images[Pic_number] = bm_load(Pilot_image_names[Pic_number]);
1569  if (Pilot_images[Pic_number] >= 0) {
1570  int w, h;
1571 
1572  bm_get_info(Pilot_images[Pic_number], &w, &h, NULL);
1573  // check for invalid pilot pic file
1574  if ((w != PLAYER_PILOT_PIC_W) || (h != PLAYER_PILOT_PIC_H)) {
1575  bm_release(Pilot_images[Pic_number]);
1576  Pilot_images[Pic_number] = -1;
1577  }
1578  }
1579  }
1580  } else {
1581  Pic_number = -1;
1582  }
1583 
1584  // do squad pic stuff
1585  if ((Pic_squad_number >= 0) && (Pic_squad_number < Num_pilot_squad_images)) {
1586  if (Pilot_squad_images[Pic_squad_number] == BARRACKS_IMAGE_NOT_LOADED) { // haven't tried loading it yet
1587  Pilot_squad_images[Pic_squad_number] = bm_load_duplicate(Pilot_squad_image_names[Pic_squad_number]);
1588  if (Pilot_squad_images[Pic_squad_number] >= 0) {
1589  int w, h;
1590 
1591  bm_get_info(Pilot_squad_images[Pic_squad_number], &w, &h, NULL);
1592  // check for invalid pilot pic file
1593  if ((w != PLAYER_SQUAD_PIC_W) || (h != PLAYER_SQUAD_PIC_H)) {
1594  bm_release(Pilot_squad_images[Pic_squad_number]);
1595  Pilot_squad_images[Pic_squad_number] = -1;
1596  }
1597  }
1598  }
1599  } else {
1600  Pic_squad_number = -1;
1601  }
1602 
1603  // draw the background, etc
1604  gr_reset_clip();
1605  GR_MAYBE_CLEAR_RES(Background_bitmap);
1606  if (Background_bitmap >= 0) {
1607  gr_set_bitmap(Background_bitmap);
1608  gr_bitmap(0, 0, GR_RESIZE_MENU);
1609  }
1610 
1611  // draw pilot image and clean up afterwards
1614 
1615  // draw the window
1616  Ui_window.draw();
1617 
1618  // light up the correct mode button (single or multi)
1619  if (Player_sel_mode == PLAYER_SELECT_MODE_SINGLE) {
1621  } else {
1623  }
1624 
1625  // write out pilot call signs
1626  barracks_display_pilot_callsigns(prospective_pilot);
1627 
1628  // write out current pilot stats
1630 
1631  // blit help overlay if active
1633 
1634  // flip the page
1635  gr_flip();
1636 }
1637 
1638 // -----------------------------------------------------------------------------
1640 {
1641  // destroy window
1642  Ui_window.destroy();
1643 
1644  // release background bitmap
1645  if (Background_bitmap >= 0) {
1646  bm_release(Background_bitmap);
1647  }
1648 
1649  // release rank pip bitmaps
1650  bm_release(Rank_pips_bitmaps);
1651 
1652  // release pilot pic bitmaps
1653  for (int i=0; i<Num_pilot_images; i++) {
1654  if (Pilot_images[i] >= 0) {
1655  bm_release(Pilot_images[i]);
1656  }
1657  }
1658 
1659  if(Stat_labels != NULL)
1660  {
1661  delete[] Stat_labels;
1662  Stat_labels = NULL;
1663  }
1664  if(Stats != NULL)
1665  {
1666  delete[] Stats;
1667  Stats = NULL;
1668  }
1669 
1670  game_flush();
1671 }
#define PLAYER_SQUAD_PIC_H
Definition: player.h:33
void game_flush()
Definition: fredstubs.cpp:83
void set_text(const char *in)
Definition: inputbox.cpp:490
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
#define MAX_PILOTS
Definition: managepilot.h:19
void set_highlight_action(void(*_user_function)(void))
Definition: button.cpp:375
pilotfile Pilot
Definition: pilotfile.cpp:7
#define BARRACKS_OVERLAY
Definition: contexthelp.h:25
int i
Definition: multi_pxo.cpp:466
int kill_count_ok
Definition: scoring.h:90
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
Definition: window.cpp:476
#define STRCPY1(a, b)
Definition: barracks.cpp:303
void barracks_set_hotkeys(bool pilot_text_enter_mode)
Definition: barracks.cpp:496
#define B_PILOT_CONVERT_BUTTON
Definition: barracks.cpp:148
#define UI_INPUTBOX_FLAG_LETTER_FIRST
Definition: ui.h:41
void barracks_init()
Definition: barracks.cpp:1332
#define VALID_PILOT_CHARS
Definition: managepilot.h:17
#define KEY_DOWN
Definition: key.h:180
int flags
Definition: player.h:104
int kills[MAX_SHIP_CLASSES]
Definition: scoring.h:87
void player_set_squad_bitmap(player *p, char *fname, bool ismulti)
char image_filename[MAX_FILENAME_LEN+1]
Definition: player.h:95
int Game_mode
Definition: systemvars.cpp:24
GLfloat GLfloat GLfloat GLfloat h
Definition: Glext.h:7280
void barracks_prev_squad_pic()
Definition: barracks.cpp:774
#define KEY_LEFT
Definition: key.h:181
void gr_flip()
Definition: 2d.cpp:2113
commit pressed
Definition: gamesnd.h:294
void barracks_prev_pic()
Definition: barracks.cpp:726
#define B_PILOT_SCROLL_UP_BUTTON
Definition: barracks.cpp:141
int is_mouse_on()
Definition: gadget.cpp:371
#define CF_TYPE_PLAYERS
Definition: cfile.h:67
UI_BUTTON button
Definition: barracks.cpp:196
#define GR_RESIZE_MENU
Definition: 2d.h:684
#define MOUSE_LEFT_BUTTON
Definition: mouse.h:43
#define BARRACKS_NUM_TEXT
Definition: barracks.cpp:255
int Barracks_overlay_id
Definition: barracks.cpp:293
#define KEY_RIGHT
Definition: key.h:182
void init_new_pilot(player *p, int reset)
Definition: managepilot.cpp:78
int barracks_new_pilot_selected()
Definition: barracks.cpp:522
#define BARRACKS_X_COORD
Definition: barracks.cpp:60
virtual void unhide()
Definition: gadget.cpp:217
Assert(pm!=NULL)
UI_XSTR Barracks_text[GR_NUM_RESOLUTIONS][BARRACKS_NUM_TEXT]
Definition: barracks.cpp:256
#define GR_NUM_RESOLUTIONS
Definition: 2d.h:651
void barracks_next_squad_pic()
Definition: barracks.cpp:802
#define B_PILOT_DELETE_BUTTON
Definition: barracks.cpp:143
char * Pilot_squad_image_names[MAX_PILOT_IMAGES]
Definition: managepilot.cpp:47
general failure sound for any event
Definition: gamesnd.h:297
int Palman_allow_any_color
Definition: palman.cpp:181
help pressed
Definition: gamesnd.h:293
int res
Definition: 2d.h:370
char * drop_white_space(char *str)
Definition: parselo.cpp:159
int max_h_unscaled
Definition: 2d.h:361
void barracks_scroll_stats_down()
Definition: barracks.cpp:713
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
Definition: bmpman.cpp:769
int Barracks_squad_coords[GR_NUM_RESOLUTIONS][4]
Definition: barracks.cpp:117
char s_squad_filename[MAX_FILENAME_LEN+1]
Definition: player.h:96
void set_focus()
Definition: gadget.cpp:321
GLclampf f
Definition: Glext.h:7097
int bm_load_duplicate(const char *filename)
Reloads a bitmap as a duplicate.
Definition: bmpman.cpp:1668
#define GR_MAYBE_CLEAR_RES(bmap)
Definition: 2d.h:639
int barracks_pilot_filter(const char *filename)
Definition: barracks.cpp:892
#define B_STATS_SCROLL_UP_BUTTON
Definition: barracks.cpp:161
GLenum mode
Definition: Glext.h:5794
#define KEY_C
Definition: key.h:84
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
virtual void hide(int n)
Definition: gadget.cpp:207
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
Definition: ui.h:195
#define B_PILOT_CREATE_BUTTON
Definition: barracks.cpp:140
#define PLAYER_SQUAD_PIC_W
Definition: player.h:32
void barracks_init_stats(scoring_struct *stats)
Definition: barracks.cpp:308
unsigned int s_shots_fired
Definition: scoring.h:92
#define PLAYER_SELECT_MODE_SINGLE
Definition: playermenu.h:16
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
Definition: 2d.cpp:2105
int max_w_unscaled
Definition: 2d.h:361
#define Int3()
Definition: pstypes.h:292
#define KEY_DELETE
Definition: key.h:176
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
bool verify(const char *fname, int *rank=NULL, char *valid_language=NULL)
Definition: plr.cpp:1006
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
Definition: bmpman.cpp:2603
char callsign[CALLSIGN_LEN+1]
Definition: player.h:91
int bm_load_animation(const char *real_filename, int *nframes, int *fps, int *keyframe, int can_drop_frames, int dir_type)
Loads a bitmap sequance so we can draw with it.
Definition: bmpman.cpp:1420
int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char **list, int type, const char *filter, int sort=CF_SORT_NONE, file_list_info *info=NULL)
#define B_PIC_NEXT_PILOT_BUTTON
Definition: barracks.cpp:156
#define B_PILOT_CLONE_BUTTON
Definition: barracks.cpp:145
int Campaign_file_missing
void barracks_scroll_callsign_up()
Definition: barracks.cpp:670
void draw_forced(int frame_num)
Definition: button.cpp:104
int mouse_down(int btn)
Definition: mouse.cpp:315
player Players[MAX_PLAYERS]
void os_config_write_string(const char *section, const char *name, const char *value)
Definition: osregistry.cpp:221
void destroy()
Definition: window.cpp:189
#define gr_reset_clip
Definition: 2d.h:745
void set_mask_bmap(char *fname)
Definition: window.cpp:75
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
Definition: gadget.cpp:71
Definition: player.h:85
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
void barracks_set_callsign_enter_mode(bool set_callsign_enter_mode)
Definition: barracks.cpp:575
#define GM_MULTIPLAYER
Definition: systemvars.h:18
char current_campaign[MAX_FILENAME_LEN+1]
Definition: player.h:101
#define B_PILOT_MULTI_MODE_BUTTON
Definition: barracks.cpp:147
void barracks_display_pilot_stats()
Definition: barracks.cpp:1171
#define B_STATS_SCROLL_DOWN_BUTTON
Definition: barracks.cpp:160
unsigned int p_shots_fired
Definition: scoring.h:91
#define CF_SORT_TIME
Definition: cfile.h:94
#define PLAYER_SELECT_MODE_MULTI
Definition: playermenu.h:17
char * filename
int pressed()
Definition: button.cpp:325
Switching to a new screen, but not commit.
Definition: gamesnd.h:292
int Num_pilot_images
Definition: managepilot.cpp:43
void barracks_squad_change_popup()
Definition: barracks.cpp:910
#define B_PILOT_SET_ACTIVE_BUTTON
Definition: barracks.cpp:144
void barracks_close()
Definition: barracks.cpp:1639
#define w(p)
Definition: modelsinc.h:68
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
GLdouble GLdouble z
Definition: Glext.h:5451
#define KEY_ENTER
Definition: key.h:125
bool save_player(player *_p=NULL)
Definition: plr.cpp:935
void barracks_accept_new_pilot_callsign()
Definition: barracks.cpp:1211
int idx
Definition: multiui.cpp:761
int Networking_disabled
Definition: fredstubs.cpp:32
#define B_ACCEPT_BUTTON
Definition: barracks.cpp:164
int delete_pilot_file(char *pilot_name)
Definition: managepilot.cpp:54
int barracks_pilot_accepted()
Definition: barracks.cpp:638
#define B_PILOT_SCROLL_DOWN_BUTTON
Definition: barracks.cpp:142
GLclampd n
Definition: Glext.h:7286
#define B_SQUAD_NEXT_BUTTON
Definition: barracks.cpp:152
int Barracks_squad_number_coords[GR_NUM_RESOLUTIONS][2]
Definition: barracks.cpp:127
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
user_click (mouse selects a control)
Definition: gamesnd.h:305
void barracks_draw_squad_pic()
Definition: barracks.cpp:1306
void barracks_button_pressed(int n)
Definition: barracks.cpp:977
#define BARRACKS_W_COORD
Definition: barracks.cpp:62
#define NOX(s)
Definition: pstypes.h:473
#define KEY_F1
Definition: key.h:143
#define B_PIC_PREV_PILOT_BUTTON
Definition: barracks.cpp:155
#define GM_STANDALONE_SERVER
Definition: systemvars.h:27
void barracks_draw_pilot_pic()
Definition: barracks.cpp:1283
int pilot_verify_overwrite()
void set_hotkey(int keycode)
Definition: gadget.cpp:280
#define B_SQUAD_PREV_BUTTON
Definition: barracks.cpp:151
color Color_text_active
Definition: alphacolors.cpp:27
GLuint const GLchar * name
Definition: Glext.h:5608
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:791
void barracks_display_pilot_callsigns(int prospective_pilot)
Definition: barracks.cpp:1133
#define BARRACKS_IMAGE_NOT_LOADED
Definition: barracks.cpp:182
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
Definition: bmpman.cpp:1119
color Color_text_subselected
Definition: alphacolors.cpp:26
#define BARRACKS_H_COORD
Definition: barracks.cpp:63
void update_dimensions(int _x, int _y, int _w, int _h)
Definition: gadget.cpp:187
color Color_text_selected
Definition: alphacolors.cpp:26
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void pilot_load_squad_pic_list()
int Num_pilot_squad_images
Definition: managepilot.cpp:48
bool load_savefile(const char *campaign)
Definition: csg.cpp:1347
scroll pressed (and scroll)
Definition: gamesnd.h:296
#define CALLSIGN_LEN
Definition: globals.h:31
#define B_STATS_MEDAL_BUTTON
Definition: barracks.cpp:159
void link_hotspot(int num)
Definition: gadget.cpp:50
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
Definition: button.cpp:26
#define KEY_ESC
Definition: key.h:124
GLubyte GLubyte GLubyte GLubyte w
Definition: Glext.h:5679
#define BARRACKS_NUM_BUTTONS
Definition: barracks.cpp:137
void barracks_scroll_callsign_down()
Definition: barracks.cpp:685
#define UI_XSTR_COLOR_PINK
Definition: ui.h:161
bool load_player(const char *callsign, player *_p=NULL)
Definition: plr.cpp:779
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
Definition: window.cpp:140
void barracks_init_player_stuff(int mode)
Definition: barracks.cpp:917
player * Player
bool valid_pilot_lang(char *callsign)
Definition: playermenu.cpp:212
int gr_force_fit_string(char *str, int max_str, int max_width)
Definition: font.cpp:48
void barracks_delete_pilot()
Definition: barracks.cpp:829
Definition: ui.h:584
screen gr_screen
Definition: 2d.cpp:46
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
Definition: font.cpp:196
Definition: ui.h:162
unsigned int p_shots_hit
Definition: scoring.h:94
void enable(int n=1)
Definition: gadget.cpp:440
#define KEY_F2
Definition: key.h:144
int gr_get_font_height()
Definition: font.cpp:187
unsigned int p_bonehead_hits
Definition: scoring.h:97
SCP_vector< ship_info > Ship_info
Definition: ship.cpp:164
void common_play_highlight_sound()
Definition: gamesnd.cpp:1151
#define STAT_COLUMN2_W
Definition: barracks.cpp:45
char Pilots_arr[MAX_PILOTS][MAX_FILENAME_LEN]
Definition: playermenu.cpp:154
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _textlen, char *_text, int _flags=0, int pixel_lim=-1, color *clr=NULL)
Definition: inputbox.cpp:101
void gamesnd_play_error_beep()
Definition: gamesnd.cpp:1159
void barracks_do_frame(float frametime)
Definition: barracks.cpp:1444
void get_mouse_pos(int *xx, int *yy)
Definition: gadget.cpp:341
#define UI_INPUTBOX_FLAG_INVIS
Definition: ui.h:35
#define MAX_PILOT_IMAGES
Definition: managepilot.h:20
void game_feature_disabled_popup()
Definition: fredstubs.cpp:219
#define KEY_CTRLED
Definition: key.h:64
#define KEY_TAB
Definition: key.h:127
#define B_HELP_BUTTON
Definition: barracks.cpp:165
void barracks_next_pic()
Definition: barracks.cpp:750
#define B_OPTION_BUTTON
Definition: barracks.cpp:166
void get_text(char *out)
Definition: inputbox.cpp:484
void gr_bitmap(int _x, int _y, int resize_mode)
Definition: 2d.cpp:1303
#define KEY_UP
Definition: key.h:179
#define UI_XSTR_COLOR_GREEN
Definition: ui.h:160
color Color_text_normal
Definition: alphacolors.cpp:26
void set_valid_chars(char *vchars)
Definition: inputbox.cpp:152
color Color_text_heading
Definition: alphacolors.cpp:28
#define PLAYER_PILOT_PIC_W
Definition: player.h:29
#define PLAYER_FLAGS_IS_MULTI
Definition: player.h:42
char m_squad_filename[MAX_FILENAME_LEN+1]
Definition: player.h:98
void set_disabled_action(void(*_user_function)(void))
Definition: button.cpp:380
#define GM_NORMAL
Definition: systemvars.h:19
void pilot_load_pic_list()
void launch_context_help()
void gamesnd_play_iface(int n)
Definition: gamesnd.cpp:260
#define BARRACKS_Y_COORD
Definition: barracks.cpp:61
void disable()
Definition: gadget.cpp:432
void draw()
Definition: window.cpp:220
void barracks_strip_pcx(char *str)
Definition: barracks.cpp:512
void barracks_scroll_stats_up()
Definition: barracks.cpp:702
char * Pilots[MAX_PILOTS]
Definition: playermenu.cpp:155
#define STATS_FLAG_MULTIPLAYER
Definition: scoring.h:75
int process(int key_in=-1, int process_mouse=1)
Definition: window.cpp:401
int help_overlay_get_index(const char *overlay_name)
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
Definition: font.cpp:314
void gameseq_post_event(int event)
#define UI_INPUTBOX_FLAG_KEYTHRU
Definition: ui.h:36
#define stricmp(s1, s2)
Definition: config.h:271
unsigned int s_shots_hit
Definition: scoring.h:95
void barracks_create_new_pilot()
Definition: barracks.cpp:597
void help_overlay_maybe_blit(int overlay_id, int resolution_index)
barracks_buttons(char *name, int x1, int y1, int x2, int y2, int h, int r=0)
Definition: barracks.cpp:198
int help_overlay_active(int overlay_id)
unsigned int s_bonehead_hits
Definition: scoring.h:98
#define B_PILOT_SINGLE_MODE_BUTTON
Definition: barracks.cpp:146
#define PLAYER_PILOT_PIC_H
Definition: player.h:30
char * Pilot_image_names[MAX_PILOT_IMAGES]
Definition: managepilot.cpp:42
GLint y
Definition: Gl.h:1505
int(* Get_file_list_filter)(const char *filename)
scoring_struct stats
Definition: player.h:127
int Player_num
#define strcpy_s(...)
Definition: safe_strings.h:67
#define STAT_COLUMN1_W
Definition: barracks.cpp:44