FS2_Open
Open source remastering of the Freespace 2 engine
hud.h File Reference
#include "globalincs/vmallocator.h"
#include "graphics/2d.h"
#include "graphics/font.h"
#include "hud/hudgauges.h"
#include "hud/hudparse.h"

Go to the source code of this file.

Classes

struct  hud_anim
 
struct  hud_frames
 
struct  objective_display_info
 
struct  hud_subsys_info
 
struct  hud_subsys_damage
 
class  HudGauge
 
class  HudGaugeMissionTime
 
class  HudGaugeTextWarnings
 
class  HudGaugeKills
 
class  HudGaugeLag
 
class  HudGaugeObjectiveNotify
 
class  HudGaugeDamage
 
class  HudGaugeSupport
 
class  HudGaugeMultiMsg
 
class  HudGaugeVoiceStatus
 
class  HudGaugePing
 
class  HudGaugeSupernova
 
class  HudGaugeFlightPath
 

Macros

#define HUD_NUM_COLOR_LEVELS   16
 
#define HUD_COLOR_ALPHA_USER_MAX   13
 
#define HUD_COLOR_ALPHA_USER_MIN   3
 
#define HUD_COLOR_ALPHA_MAX   15
 
#define HUD_COLOR_ALPHA_DEFAULT   8
 
#define HUD_BRIGHT_DELTA   7
 
#define GR_AABITMAP(a, b, c)   { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap(jx, jy); } }
 
#define GR_AABITMAP_EX(a, b, c, d, e, f, g)   { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap_ex(jx, jy, d, e, f, g); } }
 
#define RTIF_CROSSHAIRS   (1<<0)
 
#define RTIF_BLINK   (1<<1)
 
#define RTIF_PULSATE   (1<<2)
 
#define RTIF_ENLARGE   (1<<3)
 
#define HUD_C_NONE   -4
 
#define HUD_C_BRIGHT   -3
 
#define HUD_C_DIM   -2
 
#define HUD_C_NORMAL   -1
 

Typedefs

typedef struct hud_anim hud_anim
 
typedef struct hud_frames hud_frames
 
typedef struct objective_display_info objective_display_info
 
typedef struct hud_subsys_info hud_subsys_info
 
typedef struct hud_subsys_damage hud_subsys_damage
 

Functions

void HUD_init_colors ()
 
void HUD_init ()
 Called each level to initialize HUD systems. More...
 
void hud_close ()
 Delete all HUD gauge objects, for all ships. More...
 
void hud_level_close ()
 Do post mission cleanup of HUD. More...
 
void hud_update_frame (float frametime)
 Updates HUD systems each frame. More...
 
void hud_render_preprocess (float frametime)
 Render gauges that need to be between a g3_start_frame() and a g3_end_frame() More...
 
void hud_render_all ()
 Undertakes main HUD render. More...
 
void hud_render_gauges (int cockpit_display_num=-1)
 
void hud_stop_looped_engine_sounds ()
 Called when the game decides to stop all looping sounds. More...
 
void HUD_set_offsets (object *viewer_obj, int wiggedy_wack, matrix *eye_orient)
 Set the offset values for this render frame. More...
 
void HUD_get_nose_coordinates (int *x, int *y)
 Returns the offset between the player's view vector and the forward vector of the ship in pixels (Swifty) More...
 
void HUD_reset_clip ()
 Like gr_reset_clip() only it accounts for HUD jittering. More...
 
void hud_save_restore_camera_data (int save)
 Called to save and restore the 3D camera settings. More...
 
void HUD_set_clip (int x, int y, int w, int h)
 Like gr_set_clip() only it accounts for HUD jittering. More...
 
void hud_start_text_flash (const char *txt, int t, int interval=200)
 
void hud_num_make_mono (char *num_str, int font_num=FONT1)
 Convert a number string to use mono-spaced 1 character. More...
 
void hud_anim_init (hud_anim *ha, int sx, int sy, const char *filename)
 Initialise the members of the hud_anim struct to default values. More...
 
void hud_frames_init (hud_frames *hf)
 Initialise the members of the hud_frames struct to default values. More...
 
int hud_anim_render (hud_anim *ha, float frametime, int draw_alpha=0, int loop=1, int hold_last=0, int reverse=0, int resize_mode=GR_RESIZE_FULL, bool mirror=false)
 Render out a frame of the targetbox static animation, based on how much time has elapsed. More...
 
int hud_anim_load (hud_anim *ha)
 Load a hud_anim. More...
 
void hud_support_view_start ()
 Start displaying the support view pop-up. This will remain up until hud_support_view_stop() is called. More...
 
void hud_support_view_stop (int stop_now=0)
 Stop displaying the support view pop-up. More...
 
void hud_support_view_abort ()
 
void hud_support_view_update ()
 
void HUD_init_hud_color_array ()
 
void hud_set_default_color ()
 Set the current color to the default HUD color (with default alpha) More...
 
void hud_set_iff_color (object *objp, int is_bright=0)
 Will set the color to the IFF color based on the team. More...
 
colorhud_get_iff_color (object *objp, int is_bright=0)
 
void hud_set_bright_color ()
 Set the current color to a bright HUD color (ie high alpha) More...
 
void hud_set_dim_color ()
 Set the current color to a dim HUD color (ie low alpha) More...
 
void hud_set_gauge_color (int gauge_index, int bright_index=HUD_C_NONE)
 Set the HUD color for the gauge, based on whether it is flashing or not. More...
 
int hud_gauge_active (int gauge_index)
 Determine if the specified HUD gauge should be displayed. More...
 
void hud_gauge_start_flash (int gauge_index)
 Call HUD function to flash gauge. More...
 
int hud_gauge_maybe_flash (int gauge_index)
 Set the color for a gauge that may be flashing. More...
 
void hud_gauge_popup_start (int gauge_index, int time=4000)
 Start a gauge to pop-up. More...
 
int hud_gauge_is_popup (int gauge_index)
 Determine if gauge is in pop-up mode or not. More...
 
void hud_update_objective_message ()
 
void hud_add_objective_messsage (int type, int status)
 Add objective status on the HUD. More...
 
int hud_get_dock_time (object *docker_objp)
 Get the number of seconds until repair ship will dock with ther player. More...
 
void hud_show_target_model ()
 
void hud_show_voice_status ()
 
void hud_subspace_notify_abort ()
 
void hud_maybe_render_multi_text ()
 
int hud_get_draw ()
 
void hud_toggle_draw ()
 
int hud_disabled ()
 Checks if HUD disabled. More...
 
int hud_support_find_closest (int objnum)
 Locate the closest support ship which is trying to dock with player. More...
 
void hud_set_draw (int draw)
 
void hud_disable_except_messages (int disable)
 
int hud_disabled_except_messages ()
 Like hud_disabled(), except messages are still drawn. More...
 
void hud_toggle_contrast ()
 
void hud_set_contrast (int high)
 
HudGaugehud_get_gauge (const char *name)
 

Variables

int HUD_draw
 
int HUD_contrast
 
color HUD_color_defaults [HUD_NUM_COLOR_LEVELS]
 
int radar_target_id_flags
 
int HUD_color_red
 
int HUD_color_green
 
int HUD_color_blue
 
int HUD_color_alpha
 
color HUD_color_debug
 
float HUD_offset_x
 
float HUD_offset_y
 
int HUD_nose_x
 
int HUD_nose_y
 
float Pl_target_integrity
 
float Player_rearm_eta
 
int Hud_max_targeting_range
 
SCP_vector< HudGauge * > default_hud_gauges
 
flag_def_list Hud_gauge_types []
 
int Num_hud_gauge_types
 

Macro Definition Documentation

#define GR_AABITMAP (   a,
  b,
  c 
)    { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap(jx, jy); } }

Definition at line 79 of file hud.h.

#define GR_AABITMAP_EX (   a,
  b,
  c,
  d,
  e,
  f,
  g 
)    { int jx, jy; if(emp_should_blit_gauge()) { gr_set_bitmap(a); jx = b; jy = c; emp_hud_jitter(&jx, &jy); gr_aabitmap_ex(jx, jy, d, e, f, g); } }

Definition at line 80 of file hud.h.

#define HUD_BRIGHT_DELTA   7

Definition at line 76 of file hud.h.

#define HUD_C_BRIGHT   -3

Definition at line 162 of file hud.h.

#define HUD_C_DIM   -2

Definition at line 163 of file hud.h.

#define HUD_C_NONE   -4

Definition at line 161 of file hud.h.

#define HUD_C_NORMAL   -1

Definition at line 164 of file hud.h.

#define HUD_COLOR_ALPHA_DEFAULT   8

Definition at line 74 of file hud.h.

#define HUD_COLOR_ALPHA_MAX   15

Definition at line 73 of file hud.h.

#define HUD_COLOR_ALPHA_USER_MAX   13

Definition at line 70 of file hud.h.

#define HUD_COLOR_ALPHA_USER_MIN   3

Definition at line 71 of file hud.h.

#define HUD_NUM_COLOR_LEVELS   16

Definition at line 66 of file hud.h.

#define RTIF_BLINK   (1<<1)

Definition at line 84 of file hud.h.

#define RTIF_CROSSHAIRS   (1<<0)

Definition at line 83 of file hud.h.

#define RTIF_ENLARGE   (1<<3)

Definition at line 86 of file hud.h.

#define RTIF_PULSATE   (1<<2)

Definition at line 85 of file hud.h.

Typedef Documentation

typedef struct hud_anim hud_anim
typedef struct hud_frames hud_frames

Function Documentation

void hud_add_objective_messsage ( int  type,
int  status 
)

Add objective status on the HUD.

Parameters
typeType of goal, one of: PRIMARY_GOAL, SECONDARY_GOAL, BONUS_GOAL
statusStatus of goal, one of: GOAL_FAILED, GOAL_COMPLETE, GOAL_INCOMPLETE
Todo:
Play a sound?

Definition at line 3230 of file hud.cpp.

void hud_anim_init ( hud_anim ha,
int  sx,
int  sy,
const char *  filename 
)

Initialise the members of the hud_anim struct to default values.

Definition at line 2169 of file hud.cpp.

int hud_anim_load ( hud_anim ha)

Load a hud_anim.

Returns
If successful return 0, otherwise return -1

Definition at line 2193 of file hud.cpp.

int hud_anim_render ( hud_anim ha,
float  frametime,
int  draw_alpha,
int  loop,
int  hold_last,
int  reverse,
int  resize_mode,
bool  mirror 
)

Render out a frame of the targetbox static animation, based on how much time has elapsed.

Parameters
haPointer to hud_anim info
frametimeSeconds elapsed since last frame
draw_alphaDraw bitmap as alpha-bitmap (default 0)
loopAnim should loop (default 1)
hold_lastShould last frame be held (default 0)
reversePlay animation in reverse (default 0)
resize_modeResize for non-standard resolutions
mirrorMirror along y-axis so icon points left instead of right

Definition at line 2228 of file hud.cpp.

void hud_close ( )

Delete all HUD gauge objects, for all ships.

Definition at line 1247 of file hud.cpp.

void hud_disable_except_messages ( int  disable)

Definition at line 1288 of file hud.cpp.

int hud_disabled ( )

Checks if HUD disabled.

Returns
!0 if HUD is disabled (ie no gauges are shown/usable), otherwise return 0

Definition at line 1306 of file hud.cpp.

int hud_disabled_except_messages ( )

Like hud_disabled(), except messages are still drawn.

Definition at line 1297 of file hud.cpp.

void hud_frames_init ( hud_frames hf)

Initialise the members of the hud_frames struct to default values.

Definition at line 2183 of file hud.cpp.

int hud_gauge_active ( int  gauge_index)

Determine if the specified HUD gauge should be displayed.

Definition at line 3006 of file hud.cpp.

int hud_gauge_is_popup ( int  gauge_index)

Determine if gauge is in pop-up mode or not.

Definition at line 3026 of file hud.cpp.

int hud_gauge_maybe_flash ( int  gauge_index)

Set the color for a gauge that may be flashing.

Parameters
gauge_indexGauge to test
Returns
Gauge is not flashing -1; gauge is flashing, draw dim 0; gauge is flashing, draw bright 1

Definition at line 3167 of file hud.cpp.

void hud_gauge_popup_start ( int  gauge_index,
int  time 
)

Start a gauge to pop-up.

Load gauge properties defined in the HUD config if gauge is not customized.

Definition at line 3036 of file hud.cpp.

void hud_gauge_start_flash ( int  gauge_index)

Call HUD function to flash gauge.

Load gauge properties defined in the HUD config if gauge is not customized.

Definition at line 3066 of file hud.cpp.

int hud_get_dock_time ( object docker_objp)

Get the number of seconds until repair ship will dock with ther player.

mwa made this function more general purpose. Goober5000 made clearer

Parameters
docker_objpThe object which is attempting to dock with the player
Returns
The number of seconds, 0 if already docked, -1 if error
Todo:
This function is pretty stupid now. It just assumes the dockee is sitting still, and the docker is moving directly to the dockee.

Definition at line 2582 of file hud.cpp.

int hud_get_draw ( )

Definition at line 1282 of file hud.cpp.

HudGauge* hud_get_gauge ( const char *  name)

Definition at line 3721 of file hud.cpp.

color* hud_get_iff_color ( object objp,
int  is_bright = 0 
)
void HUD_get_nose_coordinates ( int x,
int y 
)

Returns the offset between the player's view vector and the forward vector of the ship in pixels (Swifty)

Definition at line 3583 of file hud.cpp.

void HUD_init ( )

Called each level to initialize HUD systems.

Definition at line 1164 of file hud.cpp.

void HUD_init_colors ( )

Definition at line 219 of file hud.cpp.

void HUD_init_hud_color_array ( )

Definition at line 208 of file hud.cpp.

void hud_level_close ( )

Do post mission cleanup of HUD.

Definition at line 1229 of file hud.cpp.

void hud_maybe_render_multi_text ( )
void hud_num_make_mono ( char *  num_str,
int  font_num = FONT1 
)

Convert a number string to use mono-spaced 1 character.

Definition at line 2275 of file hud.cpp.

void hud_render_all ( )

Undertakes main HUD render.

Definition at line 1716 of file hud.cpp.

void hud_render_gauges ( int  cockpit_display_num = -1)

Definition at line 1733 of file hud.cpp.

void hud_render_preprocess ( float  frametime)

Render gauges that need to be between a g3_start_frame() and a g3_end_frame()

Definition at line 1580 of file hud.cpp.

void HUD_reset_clip ( )

Like gr_reset_clip() only it accounts for HUD jittering.

Definition at line 3633 of file hud.cpp.

void hud_save_restore_camera_data ( int  save)

Called to save and restore the 3D camera settings.

Parameters
saveSave global view variables if 1, restore them if not 1

Definition at line 3656 of file hud.cpp.

void hud_set_bright_color ( )

Set the current color to a bright HUD color (ie high alpha)

Definition at line 2927 of file hud.cpp.

void HUD_set_clip ( int  x,
int  y,
int  w,
int  h 
)

Like gr_set_clip() only it accounts for HUD jittering.

Definition at line 3644 of file hud.cpp.

void hud_set_contrast ( int  high)

Definition at line 3687 of file hud.cpp.

void hud_set_default_color ( )

Set the current color to the default HUD color (with default alpha)

Definition at line 2918 of file hud.cpp.

void hud_set_dim_color ( )

Set the current color to a dim HUD color (ie low alpha)

Definition at line 2937 of file hud.cpp.

void hud_set_draw ( int  draw)

Definition at line 1276 of file hud.cpp.

void hud_set_gauge_color ( int  gauge_index,
int  bright_index = HUD_C_NONE 
)

Set the HUD color for the gauge, based on whether it is flashing or not.

Definition at line 3095 of file hud.cpp.

void hud_set_iff_color ( object objp,
int  is_bright 
)

Will set the color to the IFF color based on the team.

Parameters
objpObject to test for team color to base on
is_brightDefault parameter (value 0) which uses bright version of IFF color

Definition at line 2950 of file hud.cpp.

void HUD_set_offsets ( object viewer_obj,
int  wiggedy_wack,
matrix eye_orient 
)

Set the offset values for this render frame.

Since the player's view vector may be different from the ship's forward vector, we calculate the offset of those two in pixels and store the x and y offsets in variables HUD_nose_x and HUD_nose_y (Swifty)

Parameters
viewer_objObject, likely to be player
wiggedy_wack
eye_orient

Definition at line 3536 of file hud.cpp.

void hud_show_target_model ( )
void hud_show_voice_status ( )
void hud_start_text_flash ( const char *  txt,
int  t,
int  interval = 200 
)

Definition at line 2304 of file hud.cpp.

void hud_stop_looped_engine_sounds ( )

Called when the game decides to stop all looping sounds.

This function will set the loop id's for the engine noises to -1, this will force any looping engine sounds to stop.

Definition at line 1816 of file hud.cpp.

void hud_subspace_notify_abort ( )

Definition at line 3489 of file hud.cpp.

int hud_support_find_closest ( int  objnum)

Locate the closest support ship which is trying to dock with player.

Parameters
objnumObject number of player
Returns
Number of support ship, -1 if there is no support ship currently trying to dock

Definition at line 2655 of file hud.cpp.

void hud_support_view_abort ( )

Definition at line 2566 of file hud.cpp.

void hud_support_view_start ( )

Start displaying the support view pop-up. This will remain up until hud_support_view_stop() is called.

Definition at line 2540 of file hud.cpp.

void hud_support_view_stop ( int  stop_now)

Stop displaying the support view pop-up.

Parameters
stop_nowIf set, stop now, otherwise in 2 seconds.

Definition at line 2551 of file hud.cpp.

void hud_support_view_update ( )

Definition at line 2696 of file hud.cpp.

void hud_toggle_contrast ( )

Definition at line 3682 of file hud.cpp.

void hud_toggle_draw ( )

Definition at line 1270 of file hud.cpp.

void hud_update_frame ( float  frametime)

Updates HUD systems each frame.

This function updates those parts of the HUD that are not dependant on the rendering of the HUD.

Definition at line 1336 of file hud.cpp.

void hud_update_objective_message ( )

Definition at line 3194 of file hud.cpp.

Variable Documentation

SCP_vector<HudGauge*> default_hud_gauges

Definition at line 57 of file hud.cpp.

int HUD_color_alpha

Definition at line 76 of file hud.cpp.

int HUD_color_blue

Definition at line 75 of file hud.cpp.

color HUD_color_debug

Definition at line 85 of file hud.cpp.

color HUD_color_defaults[HUD_NUM_COLOR_LEVELS]

Definition at line 84 of file hud.cpp.

int HUD_color_green

Definition at line 74 of file hud.cpp.

int HUD_color_red

Definition at line 73 of file hud.cpp.

int HUD_contrast

Definition at line 79 of file hud.cpp.

int HUD_draw

Definition at line 78 of file hud.cpp.

flag_def_list Hud_gauge_types[]

Definition at line 99 of file hudparse.cpp.

int Hud_max_targeting_range

Definition at line 99 of file hud.cpp.

int HUD_nose_x

Definition at line 94 of file hud.cpp.

int HUD_nose_y

Definition at line 95 of file hud.cpp.

float HUD_offset_x

Definition at line 90 of file hud.cpp.

float HUD_offset_y

Definition at line 91 of file hud.cpp.

int Num_hud_gauge_types

Definition at line 152 of file hudparse.cpp.

float Pl_target_integrity

Definition at line 97 of file hud.cpp.

float Player_rearm_eta

Definition at line 179 of file hud.cpp.

int radar_target_id_flags

Definition at line 69 of file radarsetup.cpp.