44 #define STAT_COLUMN1_W 40
45 #define STAT_COLUMN2_W 10
60 #define BARRACKS_X_COORD 0
61 #define BARRACKS_Y_COORD 1
62 #define BARRACKS_W_COORD 2
63 #define BARRACKS_H_COORD 3
137 #define BARRACKS_NUM_BUTTONS 19
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
151 #define B_SQUAD_PREV_BUTTON 17
152 #define B_SQUAD_NEXT_BUTTON 18
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
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
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
182 #define BARRACKS_IMAGE_NOT_LOADED -2
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) {}
201 static int Background_bitmap = -1;
255 #define BARRACKS_NUM_TEXT 2
270 static int Num_stat_lines;
274 static int Player_sel_mode;
277 static int Num_pilots;
278 static int Selected_line;
281 static int Pic_number;
282 static int Pic_squad_number;
283 static bool Barracks_callsign_enter_mode;
285 static int List_scroll_offset;
286 static int Stats_scroll_offset;
287 static int Clone_flag;
290 static int Rank_pips_bitmaps;
291 static int Rank_pips_count;
303 #define STRCPY1(a, b) do { \
304 Assert(strlen(b) < STAT_COLUMN1_W); \
310 int Max_stat_lines =
Ship_info.size() + 23;
313 int score_from_kills = 0;
316 if(Stat_labels != NULL)
318 delete[] Stat_labels;
331 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"*All Time Stats", 50));
332 Stats[Num_stat_lines][0] = 0;
335 Assert(Num_stat_lines < Max_stat_lines);
336 Stat_labels[Num_stat_lines][0] = 0;
337 Stats[Num_stat_lines][0] = 0;
340 Assert(Num_stat_lines < Max_stat_lines);
341 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Primary weapon shots:", 51));
345 Assert(Num_stat_lines < Max_stat_lines);
346 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Primary weapon hits:", 52));
350 Assert(Num_stat_lines < Max_stat_lines);
351 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Primary friendly hits:", 53));
355 Assert(Num_stat_lines < Max_stat_lines);
356 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Primary hit %:", 54));
362 sprintf(Stats[Num_stat_lines],
XSTR(
"%.1f%%", 55), f);
365 Assert(Num_stat_lines < Max_stat_lines);
366 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Primary friendly hit %:", 56));
372 sprintf(Stats[Num_stat_lines],
XSTR(
"%.1f%%", 55), f);
375 Assert(Num_stat_lines < Max_stat_lines);
376 Stat_labels[Num_stat_lines][0] = 0;
377 Stats[Num_stat_lines][0] = 0;
380 Assert(Num_stat_lines < Max_stat_lines);
381 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Secondary weapon shots:", 57));
385 Assert(Num_stat_lines < Max_stat_lines);
386 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Secondary weapon hits:", 58));
390 Assert(Num_stat_lines < Max_stat_lines);
391 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Secondary friendly hits:", 59));
395 Assert(Num_stat_lines < Max_stat_lines);
396 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Secondary hit %:", 60));
402 sprintf(Stats[Num_stat_lines],
XSTR(
"%.1f%%", 55), f);
405 Assert(Num_stat_lines < Max_stat_lines);
406 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Secondary friendly hit %:", 61));
412 sprintf(Stats[Num_stat_lines],
XSTR(
"%.1f%%", 55), f);
415 Assert(Num_stat_lines < Max_stat_lines);
416 Stat_labels[Num_stat_lines][0] = 0;
417 Stats[Num_stat_lines][0] = 0;
420 Assert(Num_stat_lines < Max_stat_lines);
421 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Total kills:", 62));
425 Assert(Num_stat_lines < Max_stat_lines);
426 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"Assists:", 63));
430 Assert(Num_stat_lines < Max_stat_lines);
431 Stat_labels[Num_stat_lines][0] = 0;
432 Stats[Num_stat_lines][0] = 0;
435 Assert(Num_stat_lines < Max_stat_lines);
436 STRCPY1(Stat_labels[Num_stat_lines],
"Current Score:");
440 Assert(Num_stat_lines < Max_stat_lines);
441 Stat_labels[Num_stat_lines][0] = 0;
442 Stats[Num_stat_lines][0] = 0;
445 Assert(Num_stat_lines < Max_stat_lines);
446 Stat_labels[Num_stat_lines][0] = 0;
447 Stats[Num_stat_lines][0] = 0;
450 STRCPY1(Stat_labels[Num_stat_lines],
XSTR(
"*Kills by Ship Type", 64));
451 Stats[Num_stat_lines][0] = 0;
454 Assert(Num_stat_lines < Max_stat_lines);
455 Stat_labels[Num_stat_lines][0] = 0;
456 Stats[Num_stat_lines][0] = 0;
460 Assert((Num_stat_lines + static_cast<int>(
Ship_info.size())) < Max_stat_lines);
464 if (stats->
kills[i]) {
465 Assert(Num_stat_lines < Max_stat_lines);
468 if (Num_stat_lines >= Max_stat_lines)
474 sprintf(Stat_labels[Num_stat_lines],
NOX(
"%s:"), it->name);
479 score_from_kills += stats->
kills[
i] * it->score;
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);
489 for (i=0; i<Num_stat_lines; i++) {
514 int flen = strlen(str);
516 if ((flen > 4) && !
stricmp(str + flen - elen,
".pcx")) {
517 str[flen - elen] =
'\0';
532 if ((Num_pilots < 1) || (Selected_line < 0) || (Selected_line >= Num_pilots)) {
570 Pic_squad_number =
i;
578 Barracks_callsign_enter_mode = set_callsign_enter_mode;
591 Inputbox.
enable(set_callsign_enter_mode);
593 Inputbox.
hide(!set_callsign_enter_mode);
614 int idx = Num_pilots;
618 Pilot_ranks[idx + 1] = Pilot_ranks[
idx];
623 Pilots[Selected_line][0] = 0;
624 Pilot_ranks[Selected_line] = 0;
625 List_scroll_offset = 0;
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));
672 if (Selected_line > 0) {
679 if ((Selected_line >= 0) && (Selected_line < List_scroll_offset)) {
680 List_scroll_offset = Selected_line;
687 if (Selected_line < Num_pilots - 1) {
696 if (Selected_line >= List_scroll_offset + num_pilots_to_fill_height) {
697 List_scroll_offset++;
704 if (Stats_scroll_offset > 0) {
705 Stats_scroll_offset--;
718 Stats_scroll_offset++;
736 if (Pic_number < 0) {
784 if (Pic_squad_number < 0) {
813 Pic_squad_number = 0;
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));
849 if (popup_rval != 1) {
870 for (
int i=Selected_line;
i<Num_pilots-1;
i++) {
872 Pilot_ranks[
i] = Pilot_ranks[i + 1];
876 if (Selected_line >= Num_pilots) {
877 Selected_line = Num_pilots - 1;
881 if (Selected_line >= 0) {
899 if (rank >= Rank_pips_count)
900 rank = Rank_pips_count - 1;
903 Pilot_ranks[Num_pilots++] = rank;
922 Player_sel_mode =
mode;
958 for (i=0; i<Num_pilots; i++) {
959 for (j=0; j<Num_pilots; j++) {
961 ranks[
i] = Pilot_ranks[j];
968 for (i=0; i<Num_pilots; i++) {
969 Pilot_ranks[
i] = ranks[
i];
972 Selected_line = List_scroll_offset = 0;
1051 if (Num_pilots < 1) {
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));
1136 int cur_pilot_idx = List_scroll_offset;
1145 if (cur_pilot_idx >= Num_pilots)
1151 if (cur_pilot_idx == Selected_line) {
1153 }
else if (cur_pilot_idx == prospective_pilot) {
1161 gr_set_bitmap(Rank_pips_bitmaps + Pilot_ranks[cur_pilot_idx]);
1174 int z = Stats_scroll_offset;
1179 if (z >= Num_stat_lines) {
1183 str = Stat_labels[
z];
1221 if (!isalpha(*buf)) {
1224 for (i=1; buf[
i]; i++) {
1225 if (!isalpha(buf[i]) && !isdigit(buf[i]) && !strchr(
VALID_PILOT_CHARS, buf[i])) {
1232 for (i=1; i<Num_pilots; i++) {
1237 for (z=i; z<Num_pilots-1; z++) {
1239 Pilot_ranks[
z] = Pilot_ranks[z + 1];
1250 if (!*buf || (i < Num_pilots)) {
1287 if (Pilot_images[Pic_number] >= 0) {
1290 Palman_allow_any_color = 1;
1293 Palman_allow_any_color = 0;
1312 if (Pilot_squad_images[Pic_squad_number] >= 0) {
1315 Palman_allow_any_color = 1;
1318 Palman_allow_any_color = 0;
1327 Pic_squad_number = -1;
1349 if(Background_bitmap < 0){
1401 Barracks_callsign_enter_mode = 0;
1402 List_scroll_offset = Stats_scroll_offset = Pic_number = Pic_squad_number = Selected_line = 0;
1456 int prospective_pilot = -1;
1460 if (Barracks_callsign_enter_mode) {
1468 for (i=0; i<Num_pilots; i++) {
1470 Pilot_ranks[
i] = Pilot_ranks[i + 1];
1546 if ((pilot_index >= 0) && (pilot_index < Num_pilots)) {
1547 prospective_pilot = pilot_index;
1553 if (prospective_pilot != -1) {
1554 Selected_line = prospective_pilot;
1569 if (Pilot_images[Pic_number] >= 0) {
1572 bm_get_info(Pilot_images[Pic_number], &w, &h, NULL);
1576 Pilot_images[Pic_number] = -1;
1588 if (Pilot_squad_images[Pic_squad_number] >= 0) {
1591 bm_get_info(Pilot_squad_images[Pic_squad_number], &w, &h, NULL);
1594 bm_release(Pilot_squad_images[Pic_squad_number]);
1595 Pilot_squad_images[Pic_squad_number] = -1;
1600 Pic_squad_number = -1;
1606 if (Background_bitmap >= 0) {
1645 if (Background_bitmap >= 0) {
1654 if (Pilot_images[
i] >= 0) {
1659 if(Stat_labels != NULL)
1661 delete[] Stat_labels;
#define PLAYER_SQUAD_PIC_H
void set_text(const char *in)
void set_highlight_action(void(*_user_function)(void))
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
void barracks_set_hotkeys(bool pilot_text_enter_mode)
#define B_PILOT_CONVERT_BUTTON
#define UI_INPUTBOX_FLAG_LETTER_FIRST
#define VALID_PILOT_CHARS
int kills[MAX_SHIP_CLASSES]
void player_set_squad_bitmap(player *p, char *fname, bool ismulti)
char image_filename[MAX_FILENAME_LEN+1]
GLfloat GLfloat GLfloat GLfloat h
void barracks_prev_squad_pic()
#define B_PILOT_SCROLL_UP_BUTTON
#define MOUSE_LEFT_BUTTON
#define BARRACKS_NUM_TEXT
void init_new_pilot(player *p, int reset)
int barracks_new_pilot_selected()
UI_XSTR Barracks_text[GR_NUM_RESOLUTIONS][BARRACKS_NUM_TEXT]
#define GR_NUM_RESOLUTIONS
void barracks_next_squad_pic()
#define B_PILOT_DELETE_BUTTON
char * Pilot_squad_image_names[MAX_PILOT_IMAGES]
general failure sound for any event
int Palman_allow_any_color
char * drop_white_space(char *str)
void barracks_scroll_stats_down()
int bm_get_info(int handle, int *w, int *h, ubyte *flags, int *nframes, int *fps)
Gets info on the bitmap indexed by handle.
int Barracks_squad_coords[GR_NUM_RESOLUTIONS][4]
char s_squad_filename[MAX_FILENAME_LEN+1]
int bm_load_duplicate(const char *filename)
Reloads a bitmap as a duplicate.
#define GR_MAYBE_CLEAR_RES(bmap)
int barracks_pilot_filter(const char *filename)
#define B_STATS_SCROLL_UP_BUTTON
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
void gr_set_color_fast(color *dst)
#define B_PILOT_CREATE_BUTTON
#define PLAYER_SQUAD_PIC_W
void barracks_init_stats(scoring_struct *stats)
unsigned int s_shots_fired
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
GLenum GLuint GLenum GLsizei const GLchar * buf
bool verify(const char *fname, int *rank=NULL, char *valid_language=NULL)
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
char callsign[CALLSIGN_LEN+1]
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.
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
#define B_PILOT_CLONE_BUTTON
int Campaign_file_missing
void barracks_scroll_callsign_up()
void draw_forced(int frame_num)
player Players[MAX_PLAYERS]
void os_config_write_string(const char *section, const char *name, const char *value)
void set_mask_bmap(char *fname)
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
GLdouble GLdouble GLdouble r
void barracks_set_callsign_enter_mode(bool set_callsign_enter_mode)
char current_campaign[MAX_FILENAME_LEN+1]
#define B_PILOT_MULTI_MODE_BUTTON
void barracks_display_pilot_stats()
#define B_STATS_SCROLL_DOWN_BUTTON
unsigned int p_shots_fired
Switching to a new screen, but not commit.
void barracks_squad_change_popup()
#define B_PILOT_SET_ACTIVE_BUTTON
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
bool save_player(player *_p=NULL)
void barracks_accept_new_pilot_callsign()
int delete_pilot_file(char *pilot_name)
int barracks_pilot_accepted()
#define B_PILOT_SCROLL_DOWN_BUTTON
#define B_SQUAD_NEXT_BUTTON
int Barracks_squad_number_coords[GR_NUM_RESOLUTIONS][2]
const char * XSTR(const char *str, int index)
user_click (mouse selects a control)
void barracks_draw_squad_pic()
void barracks_button_pressed(int n)
#define B_PIC_PREV_PILOT_BUTTON
#define GM_STANDALONE_SERVER
void barracks_draw_pilot_pic()
int pilot_verify_overwrite()
void set_hotkey(int keycode)
#define B_SQUAD_PREV_BUTTON
GLuint const GLchar * name
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
void barracks_display_pilot_callsigns(int prospective_pilot)
#define BARRACKS_IMAGE_NOT_LOADED
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
color Color_text_subselected
void update_dimensions(int _x, int _y, int _w, int _h)
color Color_text_selected
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void pilot_load_squad_pic_list()
int Num_pilot_squad_images
bool load_savefile(const char *campaign)
scroll pressed (and scroll)
#define B_STATS_MEDAL_BUTTON
void link_hotspot(int num)
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
GLubyte GLubyte GLubyte GLubyte w
#define BARRACKS_NUM_BUTTONS
void barracks_scroll_callsign_down()
#define UI_XSTR_COLOR_PINK
bool load_player(const char *callsign, player *_p=NULL)
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
void barracks_init_player_stuff(int mode)
int gr_force_fit_string(char *str, int max_str, int max_width)
void barracks_delete_pilot()
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
unsigned int p_bonehead_hits
SCP_vector< ship_info > Ship_info
void common_play_highlight_sound()
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)
void gamesnd_play_error_beep()
void barracks_do_frame(float frametime)
void get_mouse_pos(int *xx, int *yy)
#define UI_INPUTBOX_FLAG_INVIS
void game_feature_disabled_popup()
void gr_bitmap(int _x, int _y, int resize_mode)
#define UI_XSTR_COLOR_GREEN
void set_valid_chars(char *vchars)
#define PLAYER_PILOT_PIC_W
#define PLAYER_FLAGS_IS_MULTI
char m_squad_filename[MAX_FILENAME_LEN+1]
void set_disabled_action(void(*_user_function)(void))
void pilot_load_pic_list()
void launch_context_help()
void gamesnd_play_iface(int n)
void barracks_strip_pcx(char *str)
void barracks_scroll_stats_up()
#define STATS_FLAG_MULTIPLAYER
int process(int key_in=-1, int process_mouse=1)
int help_overlay_get_index(const char *overlay_name)
void _cdecl gr_printf_menu(int x, int y, const char *format,...)
void gameseq_post_event(int event)
#define UI_INPUTBOX_FLAG_KEYTHRU
void barracks_create_new_pilot()
void help_overlay_maybe_blit(int overlay_id, int resolution_index)
int help_overlay_active(int overlay_id)
unsigned int s_bonehead_hits
#define B_PILOT_SINGLE_MODE_BUTTON
#define PLAYER_PILOT_PIC_H
char * Pilot_image_names[MAX_PILOT_IMAGES]
int(* Get_file_list_filter)(const char *filename)