61 #define MSC_FLASH_AFTER_TIME 60000 // time before flashing a button
62 #define MSC_FLASH_INTERVAL 200 // time between flashes
72 static int InterfacePaletteBitmap = -1;
166 #define COMMON_BRIEFING_BUTTON 0
167 #define COMMON_SS_BUTTON 1
168 #define COMMON_WEAPON_BUTTON 2
169 #define COMMON_COMMIT_BUTTON 3
170 #define COMMON_HELP_BUTTON 4
171 #define COMMON_OPTIONS_BUTTON 5
174 static anim *Background_anim;
286 int background_bitmap = -1;
288 if (custom_background && (*custom_background !=
'\0'))
290 background_bitmap =
bm_load(custom_background);
291 if (background_bitmap < 0)
292 mprintf((
"Failed to load custom background bitmap %s!\n", custom_background));
296 if (background_bitmap < 0)
299 background_bitmap =
bm_load(multi_background);
301 background_bitmap =
bm_load(single_background);
305 return background_bitmap;
310 Active_ui_window = ui_window;
365 int num_valid_cutscenes = 0;
373 num_valid_cutscenes++;
377 return num_valid_cutscenes;
382 bool music_off =
false;
399 if (music_off && restart_music) {
411 filename =
NOX(
"palette01");
414 if ( (InterfacePaletteBitmap != -1) && !
stricmp(filename, buf) )
420 if (InterfacePaletteBitmap != -1) {
422 InterfacePaletteBitmap = -1;
433 #ifndef HARDWARE_ONLY
442 if (InterfacePaletteBitmap != -1) {
444 InterfacePaletteBitmap = -1;
477 Wss_slots = Wss_slots_teams[
team];
507 nprintf((
"Alan",
"common_select_init() returning without doing anything\n"));
511 nprintf((
"Alan",
"entering common_select_init()\n"));
515 Background_anim = NULL;
577 gr_create_shader(&Icon_shaders[ICON_FRAME_DISABLED_HIGH], 100, 100, 100, 255);
622 new_k = Active_ui_window->
process(k);
624 new_k = Active_ui_window->
process(k, 0);
663 if ( (k>0) || (new_k>0) ) {
951 nprintf((
"Alan",
"common_select_close() returning without doing anything\n"));
955 nprintf((
"Alan",
"entering common_select_close()\n"));
998 int first_frame, num_frames;
1001 if ( first_frame == -1 ) {
1002 Error(
LOCATION,
"Could not load icons from %s\n", filename);
1017 if ( size <= max_show ) {
1021 if ( (size - *start) > max_show ) {
1034 if ( size <= max_show ) {
1098 last_loadout_ships[
i] = 0;
1099 this_loadout_ships[
i] = 0;
1102 last_loadout_weapons[
i] = 0;
1103 this_loadout_weapons[
i] = 0;
1114 last_loadout_weapons[slot->
wep[j]] += slot->
wep_count[j];
1122 if ((Wss_slots[i].ship_class >= 0) && (Wss_slots[
i].
ship_class <
static_cast<int>(
Ship_info.size()))) {
1127 this_loadout_weapons[Wss_slots[
i].wep[j]] += Wss_slots[
i].wep_count[j];
1135 for (i = 0; i < static_cast<int>(
Ship_info.size()); i++) {
1139 if ( this_loadout_ships[i] < last_loadout_ships[i]) {
1148 if ( this_loadout_weapons[i] < last_loadout_weapons[i]) {
1159 Assertion((this_loadout_ships[slot->
ship_class] >= 0),
"Attempting to restore the previous missions loadout has resulted in an invalid number of ships available");
1166 if ((slot->
ship_class >= 0) && (slot->
wep[j] >= 0) && (slot->
wep[j] < Num_weapon_types)) {
1167 this_loadout_weapons[slot->
wep[j]] -= slot->
wep_count[j];
1168 Assertion((this_loadout_weapons[slot->
wep[j]] >= 0),
"Attempting to restore the previous missions loadout has resulted in an invalid number of weapons available");
1171 Wss_slots[
i].
wep[j]= slot->
wep[j];
1177 for ( i = 0; i < static_cast<int>(
Ship_info.size()); i++ ) {
1202 int valid_wing_index = -1;
1235 cleanup_ship_index[k] = -1;
1244 slot = &Player_loadout.
unit_data[valid_wing_index*MAX_WING_SLOTS+j];
1262 if ( cleanup_ship_index[k] != -1 ) {
1274 Assert( Wss_slots != NULL );
1277 if ( Wss_slots[i].ship_class >= 0 )
1281 if ( i == MAX_WSS_SLOTS )
1288 int wss_get_mode(
int from_slot,
int from_list,
int to_slot,
int to_list,
int wl_ship_slot)
1290 int mode, to_slot_empty=0;
1292 Assert( Wss_slots != NULL );
1294 if ( wl_ship_slot >= 0 ) {
1296 if ( to_slot >= 0 ) {
1297 if ( Wss_slots[wl_ship_slot].wep_count[to_slot] == 0 ) {
1303 if ( to_slot >= 0 ) {
1304 if ( Wss_slots[to_slot].ship_class == -1 ){
1311 if ( from_slot >= 0 && to_slot >= 0 ) {
1313 }
else if ( from_slot >= 0 && to_list >= 0 ) {
1315 }
else if ( (from_list >= 0) && (to_slot >= 0) && (to_slot_empty) ) {
1317 }
else if ( (from_list >= 0) && (to_slot >= 0) && (!to_slot_empty) ) {
1343 for ( i = 0; i < static_cast<int>(
Ship_info.size()); i++ ) {
1345 block[offset++] = (
ubyte)i;
1350 block[offset++] = 0xff;
1357 block[offset++] = 0xff;
1362 block[offset++] = (
ubyte)i;
1364 memcpy(block+offset, &ishort,
sizeof(
short));
1365 offset +=
sizeof(short);
1371 block[offset++] = 0xff;
1374 Assert( Wss_slots[i].ship_class < UCHAR_MAX );
1375 if(Wss_slots[i].ship_class == -1){
1376 block[offset++] = 0xff;
1378 block[offset++] = (
ubyte)(Wss_slots[i].ship_class);
1382 Assert( Wss_slots[i].wep[j] < UCHAR_MAX );
1383 if(Wss_slots[i].wep[j] == -1){
1384 block[offset++] = 0xff;
1386 block[offset++] = (
ubyte)(Wss_slots[i].wep[j]);
1389 Assert( Wss_slots[i].wep_count[j] < SHRT_MAX );
1390 ishort =
INTEL_SHORT( (
short)Wss_slots[i].wep_count[j] );
1392 memcpy(&(block[offset]), &(ishort),
sizeof(
short) );
1393 offset +=
sizeof(short);
1403 block[offset++] = 0xff;
1405 block[offset++] = (
ubyte)sound;
1411 if(player_index != -1){
1416 memcpy(block+offset,&player_id,
sizeof(player_id));
1417 offset +=
sizeof(player_id);
1419 Assert( offset < max_size );
1447 b1 = block[offset++];
1453 b2 = block[offset++];
1470 b1 = block[offset++];
1475 memcpy(&ishort, block+offset,
sizeof(
short));
1476 offset +=
sizeof(short);
1481 if(block[offset] == 0xff){
1489 if(block[offset] == 0xff){
1490 Wss_slots[
i].
wep[j] = -1;
1493 Wss_slots[
i].
wep[j] = (
int)(block[offset++]);
1496 memcpy( &ishort, &(block[offset]),
sizeof(
short) );
1499 offset +=
sizeof(short);
1508 sound = block[offset++];
1511 memcpy(&player_id,block+offset,
sizeof(player_id));
1513 offset +=
sizeof(short);
1533 angles rot_angles = {0.0f,0.0f,0.0f};
1534 float zoom = closeup_zoom * 2.5f;
1539 rot_angles.
h = -(
PI_2);
1548 rot_angles.
p = -(
PI_2);
1558 rot_angles.
h =
PI_2;
1590 vec3d weap_closeup = *closeup_pos;
1592 float tm_zoom = closeup_zoom;
1598 weap_closeup.
xyz.z = -(bs->
rad/tanf(tm_zoom/2.0
f));
1600 y_closeup = -(weap_closeup.
xyz.y/tanf(tm_zoom / 2.0
f));
1601 if(y_closeup < weap_closeup.
xyz.z)
1603 weap_closeup.
xyz.z = y_closeup;
1627 light_dir.
xyz.x = -0.5;
1628 light_dir.
xyz.y = 2.0f;
1629 light_dir.
xyz.z = -2.0f;
1653 void draw_model_rotating(
model_render_params *render_info,
int model_id,
int x1,
int y1,
int x2,
int y2,
float *rotation_buffer,
vec3d *closeup_pos,
float closeup_zoom,
float rev_rate,
int flags,
int resize_mode,
int effect)
1660 angles rot_angles, view_angles;
1668 *rotation_buffer =
PI;
1669 while (*rotation_buffer >
PI2){
1670 *rotation_buffer -=
PI2;
1673 view_angles.
p = -
PI_2;
1677 view_angles.
p = -0.6f;
1679 view_angles.
p = (
PI_2-0.6f)*(time-3.0
f)*1.66667f -
PI_2;
1683 view_angles.
b = 0.0f;
1684 view_angles.
h = 0.0f;
1686 rot_angles.
p = 0.0f;
1687 rot_angles.
b = 0.0f;
1688 rot_angles.
h = *rotation_buffer;
1691 vec3d wire_normal,ship_normal,plane_point;
1694 wire_normal.
xyz.x = 0.0f;
1695 wire_normal.
xyz.y = 1.0f;
1696 wire_normal.
xyz.z = 0.0f;
1699 ship_normal.
xyz.x = 0.0f;
1700 ship_normal.
xyz.y = -1.0f;
1701 ship_normal.
xyz.z = 0.0f;
1705 float clip = -pm->
rad*0.7f;
1706 if (time < 1.5f && time >= 0.5
f)
1707 clip = pm->
rad*(time-1.0f)*1.4
f;
1710 clip = pm->
rad*(time-2.0f)*(-1.4
f);
1715 if ( (closeup_pos != NULL) && (
vm_vec_mag(closeup_pos) > 0.0
f) ) {
1718 vec3d pos = { { { 0.0f, 0.0f, -(pm->
rad * 1.5f) } } };
1727 float start_scale =
MIN(time,0.5
f)*2.5f;
1734 start.
xyz.x = size*start_scale;
1736 start.
xyz.z = -clip;
1737 stop.
xyz.x = -size*start_scale;
1749 start.
xyz.z = size+offset*0.5f;
1751 stop.
xyz.z = -size+offset*0.5f;
1759 for (i = -3; i < 4; i++) {
1760 start.
xyz.x = stop.
xyz.x = size*0.333f*
i;
1767 for (i = 3; i > -4; i--) {
1768 start.
xyz.z = stop.
xyz.z = size*0.333f*i+offset*0.5f;
1769 if ((time < 1.5
f) && (start.
xyz.z <= -clip))
1779 light_dir.
xyz.y = 1.0f;
1780 light_dir.
xyz.x = 0.0000001f;
1822 if ( (time < 2.5
f) && (time >= 0.5
f) ) {
1840 start.
xyz.x = size*1.25f;
1842 start.
xyz.z = -clip;
1843 stop.
xyz.x = -size*1.25f;
1865 while (*rotation_buffer >
PI2){
1866 *rotation_buffer -=
PI2;
1869 view_angles.
p = -0.6f;
1870 view_angles.
b = 0.0f;
1871 view_angles.
h = 0.0f;
1874 rot_angles.
p = 0.0f;
1875 rot_angles.
b = 0.0f;
1876 rot_angles.
h = *rotation_buffer;
1884 if ( (closeup_pos != NULL) && (
vm_vec_mag(closeup_pos) > 0.0
f) ) {
1887 vec3d pos = { { { 0.0f, 0.0f, -(pm->
rad * 1.5f) } } };
1894 light_dir.
xyz.y = 1.0f;
void light_add_directional(const vec3d *dir, float intensity, float r, float g, float b, float spec_r, float spec_g, float spec_b, bool specular)
void ship_wing_cleanup(int shipnum, wing *wingp)
#define COMMON_BRIEFING_BUTTON
void set_highlight_action(void(*_user_function)(void))
void hud_set_wingman_status_none(int wing_index, int wing_pos)
char Starting_wing_names[MAX_STARTING_WINGS][NAME_LENGTH]
int timestamp(int delta_ms)
char wing_status_wing_pos
void add_XSTR(char *string, int _xstr_id, int _x, int _y, UI_GADGET *_assoc, int _color_type, int _font_id=-1)
#define MR_SHOW_OUTLINE_HTL
void briefing_load_music(char *fname)
int Cmdline_freespace_no_music
GLfloat GLfloat GLfloat GLfloat h
int Mission_music[NUM_SCORES]
#define COMMON_OPTIONS_BUTTON
brief_common_buttons Common_buttons[3][GR_NUM_RESOLUTIONS][NUM_COMMON_BUTTONS]
char Game_current_mission_filename[MAX_FILENAME_LEN]
polymodel * model_get(int model_num)
float vm_vec_mag(const vec3d *v)
#define gr_end_view_matrix
void draw_model_icon(int model_id, int flags, float closeup_zoom, int x, int y, int w, int h, const ship_info *sip, int resize_mode, const vec3d *closeup_pos)
#define IS_MISSION_MULTI_TEAMS
char wing_status_wing_index
void common_show_no_ship_error()
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
void vm_rotate_matrix_by_angles(matrix *orient, const angles *tangles)
void ship_add_exited_ship(ship *sp, int reason)
void _cdecl void void _cdecl void _cdecl Warning(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
#define MSC_FLASH_INTERVAL
char filename[MAX_FILENAME_LEN]
#define GR_NUM_RESOLUTIONS
int Wss_num_wings_teams[MAX_TVT_TEAMS]
void gr_init_alphacolor(color *clr, int r, int g, int b, int alpha, int type)
general failure sound for any event
int weapon_pool[MAX_WEAPON_TYPES]
void set_flags(uint flags)
void ss_set_team_pointers(int team)
struct vec3d::@225::@227 xyz
void wl_bash_ship_weapons(ship_weapon *swp, wss_unit *slot)
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d *pos, int render, bool sort)
#define ANIMATED_SHADER_LOADOUTSELECT_FS2
#define SEF_PLAYER_DELETED
#define Assertion(expr, msg,...)
int brief_only_allow_briefing()
void common_check_buttons()
#define END_OF_LIST(head)
int Ss_pool_teams[MAX_TVT_TEAMS][MAX_SHIP_CLASSES]
#define GR_MAYBE_CLEAR_RES(bmap)
void common_music_close()
void set_detail_level_lock(int detail_level_lock)
int restore_wss_data(ubyte *block)
int common_scroll_up_pressed(int *start, int size, int max_show)
int Ship_select_overlay_id
void help_overlay_set_state(int overlay_id, int resolution_index, int state)
void set_ignore_gadgets(int state)
void weapon_select_close_team()
void ss_synch_interface()
void common_buttons_maybe_reload(UI_WINDOW *ui_window)
void set_active_ui(UI_WINDOW *ui_window)
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
void ss_reset_team_pointers()
void anim_release_all_instances(int screen_id)
Free all anim instances that are on the anim_render_list.
#define WSS_GRAB_FROM_LIST
#define COMMON_WEAPON_REGION
void multi_ts_common_init()
int Mouse_down_last_frame
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.
#define gr_end_proj_matrix
void common_button_do(int i)
void ss_reset_selected_ship()
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.
void wl_update_parse_object_weapons(p_object *pobjp, wss_unit *slot)
void shadows_end_render()
int wep_count[MAX_SHIP_WEAPONS]
#define ON_BRIEFING_SELECT
void g3_done_instance(bool set_api=false)
void gr_set_color(int r, int g, int b)
void common_reset_buttons()
void common_set_interface_palette(char *filename)
void common_flash_button_init()
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
void draw_forced(int frame_num)
#define gr_set_view_matrix
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
UI_WINDOW * Active_ui_window
matrix shadows_start_render(matrix *eye_orient, vec3d *eye_pos, float fov, float aspect, float veryneardist, float neardist, float middist, float fardist)
void skip_first_highlight_callback()
int set_bmaps(char *ani_filename, int nframes=3, int start_frame=1)
void g3_start_instance_angles(const vec3d *pos, const angles *orient)
void batch_render_all(int stream_buffer)
#define gr_set_proj_matrix
void common_free_interface_palette()
void common_redraw_pressed_buttons()
int common_select_do(float frametime)
void common_maybe_play_cutscene(int movie_type, bool restart_music, int music)
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
void model_clear_instance(int model_num)
void weapon_select_common_init()
Switching to a new screen, but not commit.
#define ICON_FRAME_DISABLED_HIGH
wss_unit unit_data[MAX_WSS_SLOTS]
void weapon_select_close()
void light_set_all_relevent()
#define ANIMATED_SHADER_LOADOUTSELECT_FS1
void common_select_init()
void common_set_team_pointers(int team)
#define ICON_FRAME_DISABLED
int wss_get_mode(int from_slot, int from_list, int to_slot, int to_list, int wl_ship_slot)
void anim_render_all(int screen_id, float frametime)
Display the frames for the currently playing anims.
void set_color(color &clr)
int Briefing_music_begin_timestamp
int common_num_cutscenes_valid(int movie_type)
void common_check_keys(int k)
void common_render_selected_screen_button()
void vm_vec_scale_sub(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
void ship_select_common_init()
int Cmdline_shadow_quality
GLint GLint GLint GLint GLint x
bool Glowpoint_use_depth_buffer
shader Icon_shaders[NUM_ICON_FRAMES]
int Wing_slot_disabled_bitmap
SCP_vector< mission_cutscene > cutscenes
const char * XSTR(const char *str, int index)
char modified[DATE_TIME_LENGTH]
void wl_set_team_pointers(int team)
void briefing_stop_music(bool fade)
void _cdecl void void _cdecl Error(const char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void briefing_start_music()
menu_music Spooled_music[MAX_SPOOLED_MUSIC]
void set_hotkey(int keycode)
int Starting_wings[MAX_STARTING_WINGS]
GLuint const GLchar * name
void common_buttons_init(UI_WINDOW *ui_window)
#define ICON_FRAME_SELECTED
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
int multi_quit_game(int prompt, int notify_code, int err_code, int wsa_error)
GLboolean GLboolean GLboolean b
void wss_direct_restore_loadout()
#define NUM_COMMON_BUTTONS
#define WING_INDEX(wingp)
int common_scroll_down_pressed(int *start, int size, int max_show)
brief_icon * brief_get_closeup_icon()
void obj_delete(int objnum)
color Icon_colors[NUM_ICON_FRAMES]
void link_hotspot(int num)
void common_select_close()
void create(UI_WINDOW *wnd, char *_text, int _x, int _y, int _w, int _h, int do_repeat=0, int ignore_focus=0)
int wep[MAX_SHIP_WEAPONS]
GLubyte GLubyte GLubyte GLubyte w
int Weapon_select_overlay_id
void draw_model_rotating(model_render_params *render_info, int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, vec3d *closeup_pos, float closeup_zoom, float rev_rate, int flags, int resize_mode, int effect)
press briefing, ship selection or weapons bar (top-left)
#define UI_XSTR_COLOR_PINK
void palette_use_bm_palette(int n)
void wss_maybe_restore_loadout()
loadout_data Player_loadout
int eval_sexp(int cur_node, int referenced_node)
int Wing_slot_empty_bitmap
#define COMMON_WEAPON_BUTTON
void palette_restore_palette()
int store_wss_data(ubyte *block, int max_size, int sound, int player_index)
#define ICON_FRAME_PLAYER
#define WSS_SWAP_SLOT_SLOT
SCP_vector< ship_info > Ship_info
void common_play_highlight_sound()
int Wl_pool_teams[MAX_TVT_TEAMS][MAX_WEAPON_TYPES]
#define BRIEFING_MUSIC_DELAY
#define timestamp_elapsed(stamp)
int chatbox_process(int key_in)
#define WSS_SWAP_LIST_SLOT
int Brief_background_bitmap
bool movie_play(char *name)
wss_unit Wss_slots_teams[MAX_TVT_TEAMS][MAX_WSS_SLOTS]
void change_ship_type(int n, int ship_type, int by_sexp)
void set_clip_plane(vec3d &pos, vec3d &normal)
void gr_bitmap(int _x, int _y, int resize_mode)
void cutscene_mark_viewable(char *filename)
p_object Ship_arrival_list
#define UI_XSTR_COLOR_GREEN
void set_animated_effect(int effect_num, float timer)
void brief_turn_off_closeup_icon()
int mission_ui_background_load(const char *custom_background, const char *single_background, const char *multi_background)
int ship_index[MAX_SHIPS_PER_WING]
void gr_create_shader(shader *shade, ubyte r, ubyte g, ubyte b, ubyte c)
void load_wing_icons(char *filename)
#define COMMON_HELP_BUTTON
void wl_synch_interface()
void launch_context_help()
void gamesnd_play_iface(int n)
#define COMMON_BRIEFING_REGION
void common_render(float frametime)
void wl_reset_team_pointers()
void common_reset_team_pointers()
int common_flash_bright()
int process(int key_in=-1, int process_mouse=1)
net_player Net_players[MAX_PLAYERS]
int timer_get_milliseconds()
void gameseq_post_event(int event)
int ship_pool[MAX_SHIP_CLASSES]
matrix vmd_identity_matrix
#define COMMON_COMMIT_BUTTON
int help_overlay_active(int overlay_id)
void common_music_init(int score_index)
#define ICON_FRAME_NORMAL
#define g3_start_frame(zbuffer_flag)
char last_modified[DATE_TIME_LENGTH]
int wss_slots_all_empty()
#define MSC_FLASH_AFTER_TIME
void g3_draw_htl_line(const vec3d *start, const vec3d *end)