37 #define MAX_MISSIONS 1024
58 #define C_SUBTEXT_X 19
63 #define M_TEXT_X C_SUBTEXT_X //0
65 #define MODE_CAMPAIGNS 0
66 #define MODE_MISSIONS 1
69 #define MAX_DESC_LINES 200
70 #define NUM_BUTTONS 11
71 #define LIST_BUTTONS_MAX 42
73 #define SCROLL_UP_BUTTON 0
74 #define SCROLL_DOWN_BUTTON 1
76 #define CAMPAIGN_TAB 3
78 #define COMMIT_BUTTON 5
79 #define OPTIONS_BUTTON 6
80 #define TECH_DATABASE_BUTTON 7
81 #define SIMULATOR_BUTTON 8
82 #define CUTSCENES_BUTTON 9
83 #define CREDITS_BUTTON 10
90 #define CAMPAIGN_MISSION_HASH_SIZE 307
98 sim_room_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) {}
158 #define NUM_SIM_MISC_TEXT 2
159 #define SIM_MISC_TEXT_MISSION 0
160 #define SIM_MISC_TEXT_FILENAME 1
182 #define READYROOM_LINE_CAMPAIGN 1
183 #define READYROOM_LINE_CMISSION 2
184 #define READYROOM_LINE_MISSION 3
186 #define READYROOM_FLAG_FROM_VOLITION (1<<0) // volition made
197 static char *Mission_filenames[
MAX_MISSIONS] = { NULL };
198 static char *Standalone_mission_names[
MAX_MISSIONS] = { NULL };
200 static char *Campaign_missions[
MAX_MISSIONS] = { NULL };
203 static int Simroom_show_all = 0;
204 static int Standalone_mission_names_inited = 0;
205 static int Campaign_mission_names_inited = 0;
206 static int Num_standalone_missions;
207 static int Num_campaign_missions;
209 static int Scroll_offset;
210 static int Selected_line;
211 static int Num_lines;
212 static int Num_campaign_missions_with_info = 0;
213 static int Num_standalone_missions_with_info = 0;
220 static int Background_bitmap;
239 static int Hash_table_inited;
242 #define NUM_MISSION_ICONS 1
243 #define MISSION_ICON_VOLITION 0 // mini volition death's head :)
247 #define MISSION_ICON_VOLITION_Y_OFFSET (-1)
274 for (
int i=0;
i < ((
signed int)(strlen(filename)) - 4);
i++) {
275 hash_val = (hash_val << 4) + toupper(*ptr++);
289 if (Campaign_mission_hash_table[hash_val] == NULL) {
290 Campaign_mission_hash_table[hash_val] =
new hash_node;
292 cur_node = Campaign_mission_hash_table[hash_val];
294 if (cur_node == NULL) {
300 cur_node = Campaign_mission_hash_table[hash_val];
301 while (cur_node->
next != NULL) {
302 cur_node = cur_node->
next;
308 if (cur_node->
next == NULL) {
312 cur_node = cur_node->
next;
317 cur_node->
next = NULL;
330 hash_node *cur_node = Campaign_mission_hash_table[hash_val];
332 if (cur_node == NULL) {
341 cur_node = cur_node->
next;
342 }
while (cur_node != NULL);
355 for (
int i=0;
i<Num_campaign_missions;
i++) {
374 if (Campaign_mission_hash_table[
i] != NULL) {
375 cur_node = Campaign_mission_hash_table[
i];
378 while (cur_node->
next != NULL) {
386 Campaign_mission_hash_table[
i] = NULL;
398 sim_room_lines[Num_lines].type =
type;
399 sim_room_lines[Num_lines].name =
name;
400 sim_room_lines[Num_lines].filename =
filename;
401 sim_room_lines[Num_lines].x =
x;
402 sim_room_lines[Num_lines].y =
y;
403 sim_room_lines[Num_lines].flags =
flags;
417 Num_campaign_missions +=
num;
425 char mission_name[255];
452 if (Num_standalone_missions == 0) {
453 Standalone_mission_names_inited = 1;
458 Standalone_mission_names[Num_standalone_missions_with_info] = NULL;
459 Standalone_mission_flags[Num_standalone_missions_with_info] = 0;
461 if (Num_standalone_missions > 0) {
462 if (strlen(Mission_filenames[Num_standalone_missions_with_info]) <
MAX_FILENAME_LEN - 4) {
463 strcpy_s(filename, Mission_filenames[Num_standalone_missions_with_info]);
467 sprintf(str,
XSTR(
"Single Mission\n\n%s",989), filename);
475 int y = Num_lines * (font_height + 2);
489 Num_standalone_missions_with_info++;
492 if (Num_standalone_missions_with_info == Num_standalone_missions) {
493 Standalone_mission_names_inited = 1;
509 static int valid_missions_with_info = 0;
513 Campaign_mission_names_inited = 1;
523 Campaign_mission_names[Num_campaign_missions_with_info] = NULL;
524 Campaign_mission_flags[Num_campaign_missions_with_info] = 0;
534 int y = valid_missions_with_info * (font_height + 2);
545 valid_missions_with_info++;
549 Num_campaign_missions_with_info++;
552 valid_missions_with_info = 0;
553 Campaign_mission_names_inited = 1;
564 int i,
y, max_num_entries_viewable;
566 char full_filename[256];
574 if (Hash_table_inited) {
575 if (!Standalone_mission_names_inited) {
579 for (i=0; i<Num_standalone_missions_with_info; i++) {
580 if (Standalone_mission_names[i]) {
583 memset(full_filename, 0, 256);
591 y += font_height + 2;
598 list_y += font_height + 2;
599 list_h -= font_height - 2;
601 if (!Campaign_mission_names_inited) {
605 for (i=0; i<Num_campaign_missions_with_info; i++) {
606 if (Campaign_mission_names[i]) {
609 memset(full_filename, 0, 256);
617 y += font_height + 2;
627 max_num_entries_viewable = list_h / (font_height + 2);
628 Sim_room_slider.
set_numberItems((Num_lines > max_num_entries_viewable) ? (Num_lines - max_num_entries_viewable) : 0);
634 if (!Campaign_mission_names_inited)
639 if (Campaign_mission_names[
i]) {
640 vm_free(Campaign_mission_names[i]);
641 Campaign_mission_names[
i] = NULL;
645 Campaign_mission_names_inited = 0;
646 Num_campaign_missions_with_info = 0;
655 if ((n < 0) || (n >= Num_lines))
658 y = sim_room_lines[
n].y - sim_room_lines[Scroll_offset].y;
667 if (Scroll_offset > 0) {
672 Assert(Selected_line > Scroll_offset);
689 if (Selected_line < Scroll_offset)
691 Scroll_offset = Selected_line;
703 if (sim_room_lines[Num_lines - 1].
y +
gr_get_font_height() > sim_room_lines[Scroll_offset].
y + list_h) {
711 Assert(Selected_line < Num_lines);
723 if (Selected_line < Num_lines - 1) {
726 Assert(Selected_line > Scroll_offset);
764 #ifdef FREESPACE_SAVERESTORE_SYSTEM
767 if (state_read_description(savegame_filename, NULL, savegame_mission)) {
882 else if(mc_rval == -2)
898 if ((Selected_line >= Num_lines) || !sim_room_lines[Selected_line].
filename) {
925 Simroom_show_all = 0;
927 Selected_line = Scroll_offset = 0;
939 Simroom_show_all = 0;
1017 b->
button.
create(&Ui_window,
"", b->
x, b->
y, 60, 30, (i < 2), 1);
1042 List_buttons[
i].
create(&Ui_window,
"", 0, 0, 60, 30, 0, 1);
1043 List_buttons[
i].
hide();
1058 Scroll_offset = Selected_line = 0;
1070 Num_campaign_missions = 0;
1075 Hash_table_inited = 0;
1077 Hash_table_inited = 1;
1086 if(Background_bitmap != -1){
1094 memset(wild_card, 0, 256);
1102 Num_campaign_missions_with_info = Num_standalone_missions_with_info = Standalone_mission_names_inited = Campaign_mission_names_inited = 0;
1103 Simroom_show_all = 0;
1120 for (i=0; i<Num_campaign_missions; i++) {
1121 if (Campaign_missions[i]) {
1122 vm_free(Campaign_missions[i]);
1123 Campaign_missions[
i] = NULL;
1127 if (Background_bitmap >= 0)
1130 if (Standalone_mission_names_inited){
1131 for (i=0; i<Num_standalone_missions; i++){
1132 if (Standalone_mission_names[i] != NULL){
1133 vm_free(Standalone_mission_names[i]);
1134 Standalone_mission_names[
i] = NULL;
1136 Standalone_mission_flags[
i] = 0;
1140 if (Campaign_mission_names_inited) {
1142 if (Campaign_mission_names[i]) {
1143 vm_free(Campaign_mission_names[i]);
1144 Campaign_mission_names[
i] = NULL;
1149 for (i=0; i<Num_standalone_missions; i++) {
1150 vm_free(Mission_filenames[i]);
1151 Mission_filenames[
i] = NULL;
1177 int select_tease_line = -1;
1227 Selected_line = Scroll_offset = Simroom_show_all = 0;
1239 Simroom_show_all = !Simroom_show_all;
1254 if (List_buttons[i].is_mouse_on())
1255 select_tease_line = i + Scroll_offset;
1257 if (List_buttons[i].pressed()) {
1258 Selected_line = i + Scroll_offset;
1264 if (Background_bitmap >= 0) {
1302 char full_name[256];
1303 memset(full_name, 0, 256);
1312 line = Scroll_offset;
1314 y = list_y + sim_room_lines[line].y - sim_room_lines[Scroll_offset].y;
1317 List_buttons[line - Scroll_offset].
update_dimensions(list_x1, y, list_x2 + list_w2 - list_x1, font_height);
1318 List_buttons[line - Scroll_offset].
enable();
1321 List_buttons[line - Scroll_offset].
disable();
1323 if (line == Selected_line)
1325 else if (line == select_tease_line)
1334 if (sim_room_lines[line].
filename) {
1335 strcpy_s(buf, sim_room_lines[line].filename);
1346 i = line - Scroll_offset;
1347 while (i < LIST_BUTTONS_MAX)
1358 int is_from_volition = 0;
1393 #define CR_NUM_BUTTONS 6
1395 #define CR_SCROLL_UP_BUTTON 0
1396 #define CR_SCROLL_DOWN_BUTTON 1
1397 #define CR_SCROLL_INFO_UP_BUTTON 2
1398 #define CR_SCROLL_INFO_DOWN_BUTTON 3
1399 #define CR_RESET_BUTTON 4
1400 #define CR_COMMIT_BUTTON 5
1402 #define MAX_INFO_LINES 20
1404 #define MAX_INFO_LINE_LEN 256
1426 #define CR_NUM_TEXT 3
1447 static int Num_desc_lines;
1448 static int Desc_scroll_offset;
1449 static int Selected_campaign_index;
1450 static int Active_campaign_index;
1475 y += font_height + 2;
1484 Selected_campaign_index =
n;
1492 Desc_scroll_offset = 0;
1497 if (Desc_scroll_offset) {
1498 Desc_scroll_offset--;
1508 Desc_scroll_offset++;
1542 if (Selected_campaign_index < 0) {
1613 if ( (Active_campaign_index < 0) || (Active_campaign_index >=
Num_campaigns) )
1648 b->
button.
create(&Ui_window,
"", b->
x, b->
y, 60, 30, (i < 2), 1);
1656 List_buttons[
i].
create(&Ui_window,
"", 0, 0, 60, 30, 0, 1);
1657 List_buttons[
i].
hide();
1680 Desc_scroll_offset = Scroll_offset = 0;
1698 Selected_campaign_index = Active_campaign_index = -1;
1703 Active_campaign_index =
i;
1713 if (Background_bitmap >= 0)
1730 int select_tease_line = -1;
1763 if (Selected_campaign_index < 0)
1764 Selected_campaign_index = 1;
1766 if (Selected_campaign_index) {
1789 if (List_buttons[i].is_mouse_on()){
1790 select_tease_line = i + Scroll_offset;
1793 if (List_buttons[i].pressed()) {
1800 if (Background_bitmap >= 0) {
1808 line = Scroll_offset;
1813 List_buttons[line - Scroll_offset].
enable();
1817 i = y + font_height / 2 - 1;
1827 if (line == Selected_campaign_index)
1829 else if (line == select_tease_line)
1840 i = line - Scroll_offset;
1841 while (i < LIST_BUTTONS_MAX)
1845 i = Desc_scroll_offset;
void set_highlight_action(void(*_user_function)(void))
#define SIM_MISC_TEXT_FILENAME
int Mission_icon_bitmaps[NUM_MISSION_ICONS]
#define FS_MISSION_FILE_EXT
#define SIM_MISC_TEXT_MISSION
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
char * Campaign_names[MAX_CAMPAIGNS]
const char * Info_text_ptrs[MAX_INFO_LINES]
void campaign_room_init()
void sim_room_scroll_screen_up()
GLfloat GLfloat GLfloat GLfloat h
int Cr_info_coords[GR_NUM_RESOLUTIONS][4]
char Game_current_mission_filename[MAX_FILENAME_LEN]
void campaign_room_do_frame(float frametime)
#define NUM_SIM_MISC_TEXT
__inline void gr_circle(int xc, int yc, int d, int resize_mode=GR_RESIZE_FULL)
int sim_room_maybe_resume_savegame()
void campaign_room_commit()
int Campaign_list_coords[GR_NUM_RESOLUTIONS][4]
#define GR_NUM_RESOLUTIONS
void sim_room_unload_mission_icons()
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
void campaign_mission_hash_table_delete()
char * Campaign_descs[MAX_CAMPAIGNS]
general failure sound for any event
char * drop_white_space(char *str)
char * Sim_mask_filename[GR_NUM_RESOLUTIONS]
#define GR_MAYBE_CLEAR_RES(bmap)
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
void set_ignore_gadgets(int state)
void gr_set_color_fast(color *dst)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
#define CAMPAIGN_MISSION_HASH_SIZE
#define CR_SCROLL_DOWN_BUTTON
GLenum GLuint GLenum GLsizei const GLchar * buf
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
bool Campaign_room_no_campaigns
UI_XSTR Cr_text[GR_NUM_RESOLUTIONS][CR_NUM_TEXT]
#define READYROOM_LINE_MISSION
#define READYROOM_FLAG_FROM_VOLITION
void common_set_interface_palette(char *filename)
void draw_forced(int frame_num)
int sim_room_line_add(int type, char *name, char *filename, int x, int y, int flags)
#define FS_CAMPAIGN_FILE_EXT
int Sim_room_slider_coords[GR_NUM_RESOLUTIONS][4]
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void set_mask_bmap(char *fname)
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
#define MISSION_TYPE_SINGLE
int hash_insert(char *filename)
void sim_room_build_listing()
void common_free_interface_palette()
void set_numberItems(int _numberItems, int _reset=1)
char * Mission_icon_bitmap_filenames[NUM_MISSION_ICONS]
int sim_room_line_query_visible(int n)
void campaign_room_close()
int build_campaign_mission_list_do_frame()
int build_standalone_mission_list_do_frame()
int mission_parse_is_multi(const char *filename, char *mission_name)
char current_campaign[MAX_FILENAME_LEN+1]
char * Sim_filename[GR_NUM_RESOLUTIONS]
ui_button_info Cr_buttons[GR_NUM_RESOLUTIONS][CR_NUM_BUTTONS]
void create(UI_WINDOW *wnd, int _x, int _y, int _w, int _h, int _numberItems, char *_bitmapSliderControl, void(*_upCallback)(), void(*_downCallback)(), void(*_captureCallback)())
int readyroom_listing_mode
int sim_room_standalone_mission_filter(const char *filename)
int build_campaign_mission_filename_hash_table()
Switching to a new screen, but not commit.
unsigned __int64 ulonglong
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
int campaign_mission_hash_collision(const char *filename)
#define CAMPAIGN_ROOM_OVERLAY
void sim_room_do_frame(float frametime)
int split_str(const char *src, int max_pixel_w, int *n_chars, const char **p_str, int max_lines, char ignore_char)
int Info_text_line_size[MAX_INFO_LINES]
#define CF_CUSTOM_TECH_DATABASE
bool save_player(player *_p=NULL)
int sim_room_button_pressed(int n)
#define TECH_DATABASE_BUTTON
void mission_campaign_savefile_delete(char *cfilename)
void campaign_room_scroll_info_down()
GLint GLint GLint GLint GLint x
void sim_room_scroll_line_up()
int get_mission_info(const char *filename, mission *mission_p, bool basic)
const char * XSTR(const char *str, int index)
int sim_room_campaign_mission_filter(const char *filename)
void campaign_room_build_listing()
int mission_load_up_campaign(player *pl)
user_click (mouse selects a control)
void sim_room_reset_campaign_listing()
int Mission_list_coords[GR_NUM_RESOLUTIONS][4]
int sim_room_can_resume_savegame(char *savegame_filename)
#define MAX_INFO_LINE_LEN
void set_hotkey(int keycode)
void sim_room_scroll_line_down()
int hash_filename(const char *filename)
int readyroom_continue_campaign()
GLuint const GLchar * name
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
void sim_room_blit_icons(int line_index, int y_start, fs_builtin_mission *fb=NULL, int is_md=0)
char * cf_add_ext(const char *filename, const char *ext)
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
color Color_text_subselected
GLboolean GLboolean GLboolean b
struct hash_node hash_node
int Campaign_room_overlay_id
int campaign_room_reset_campaign(int n)
void update_dimensions(int _x, int _y, int _w, int _h)
color Color_text_selected
#define CR_SCROLL_UP_BUTTON
void mission_campaign_eval_next_mission()
scroll pressed (and scroll)
void sim_room_scroll_screen_down()
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)
int mission_campaign_load(char *filename, player *pl, int load_savefile, bool reset_stats)
#define UI_XSTR_COLOR_PINK
void create(int _x, int _y, int _w, int _h, int _flags, int _f_id=-1)
int Sim_misc_text_coords[GR_NUM_RESOLUTIONS][NUM_SIM_MISC_TEXT][2]
int gr_force_fit_string(char *str, int max_str, int max_width)
void sim_room_scroll_capture()
#define CR_SCROLL_INFO_DOWN_BUTTON
#define FSB_FROM_VOLITION
int mission_campaign_get_mission_list(const char *filename, char **list, int max)
#define READYROOM_LINE_CMISSION
int campaign_room_button_pressed(int n)
void common_play_highlight_sound()
#define CR_SCROLL_INFO_UP_BUTTON
#define READYROOM_LINE_CAMPAIGN
int mission_campaign_next_mission()
char * Campaign_mask_filename[GR_NUM_RESOLUTIONS]
#define MAX_CAMPAIGN_MISSIONS
void gr_bitmap(int _x, int _y, int resize_mode)
#define CAMPAIGN_LOOP_MISSION_UNINITIALIZED
#define UI_XSTR_COLOR_GREEN
void campaign_room_scroll_info_up()
char filename[MAX_FILENAME_LEN]
char * Sim_room_slider_filename[GR_NUM_RESOLUTIONS]
int Cr_list_coords[GR_NUM_RESOLUTIONS][4]
Campaign room stuff below.
void mission_campaign_build_list(bool desc, bool sort, bool multiplayer)
#define SCROLL_DOWN_BUTTON
#define MISSION_ICON_VOLITION
int bm_unload(int handle, int clear_render_targets, bool nodebug)
Unloads a bitmap's data, but not the bitmap info.
void launch_context_help()
void gamesnd_play_iface(int n)
struct ui_button_info ui_button_info
void gr_set_font(int fontnum)
#define MISSION_ICON_VOLITION_Y_OFFSET
int cf_get_file_list(SCP_vector< SCP_string > &list, int pathtype, const char *filter, int sort=CF_SORT_NONE, SCP_vector< file_list_info > *info=NULL)
char * Campaign_filename[GR_NUM_RESOLUTIONS]
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 CMISSION_FLAG_HAS_LOOP
void sim_room_load_mission_icons()
char * Campaign_file_names[MAX_CAMPAIGNS]
void help_overlay_maybe_blit(int overlay_id, int resolution_index)
#define NUM_MISSION_ICONS
int help_overlay_active(int overlay_id)
void mission_campaign_free_list()
cmission missions[MAX_CAMPAIGN_MISSIONS]
int(* Get_file_list_filter)(const char *filename)
void mission_campaign_load_failure_popup()
struct fs_builtin_mission * game_find_builtin_mission(char *)
void set_new_campaign_line(int n)