Xonotic
strafehud.qh File Reference
#include "../panel.qh"
+ Include dependency graph for strafehud.qh:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

string GetLengthUnit (int)
 
float GetLengthUnitFactor (int)
 
void HUD_Panel_DrawStrafeHUD (float, float, vector, float, int, int)
 
void StrafeHUD_drawGradient (vector, vector, vector, float, float, float, float, int)
 
vector StrafeHUD_mixColors (vector, vector, float)
 

Variables

bool autocvar__hud_panel_strafehud_demo = false
 
int autocvar_hud_panel_strafehud = 3
 
vector autocvar_hud_panel_strafehud_angle_accel_color = '0 1 1'
 
float autocvar_hud_panel_strafehud_angle_alpha = 0.8
 
float autocvar_hud_panel_strafehud_angle_height = 1.5
 
vector autocvar_hud_panel_strafehud_angle_neutral_color = '1 1 0'
 
vector autocvar_hud_panel_strafehud_angle_overturn_color = '1 0 1'
 
float autocvar_hud_panel_strafehud_angle_width = 0.005
 
float autocvar_hud_panel_strafehud_antiflicker_angle = 0.01
 
float autocvar_hud_panel_strafehud_antiflicker_speed = 0.0001
 
float autocvar_hud_panel_strafehud_bar_accel_alpha = 0.3
 
vector autocvar_hud_panel_strafehud_bar_accel_color = '0 1 0'
 
float autocvar_hud_panel_strafehud_bar_neutral_alpha = 0.3
 
vector autocvar_hud_panel_strafehud_bar_neutral_color = '1 1 1'
 
float autocvar_hud_panel_strafehud_bar_overturn_alpha = 0.3
 
vector autocvar_hud_panel_strafehud_bar_overturn_color = '1 0 1'
 
float autocvar_hud_panel_strafehud_direction_alpha = 1
 
vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'
 
float autocvar_hud_panel_strafehud_direction_length = 0.02
 
float autocvar_hud_panel_strafehud_direction_width = 0.25
 
bool autocvar_hud_panel_strafehud_dynamichud = true
 
vector autocvar_hud_panel_strafehud_jumpheight_color = '0 1 0.75'
 
float autocvar_hud_panel_strafehud_jumpheight_fade = 0
 
float autocvar_hud_panel_strafehud_jumpheight_min = 50
 
float autocvar_hud_panel_strafehud_jumpheight_size = 1.5
 
int autocvar_hud_panel_strafehud_mode = 0
 
float autocvar_hud_panel_strafehud_range = 0
 
float autocvar_hud_panel_strafehud_slickdetector_alpha = 0.5
 
vector autocvar_hud_panel_strafehud_slickdetector_color = '0 1 1'
 
int autocvar_hud_panel_strafehud_slickdetector_granularity = 2
 
float autocvar_hud_panel_strafehud_slickdetector_height = 0.125
 
float autocvar_hud_panel_strafehud_slickdetector_range = 0
 
vector autocvar_hud_panel_strafehud_startspeed_color = '1 0.75 0'
 
float autocvar_hud_panel_strafehud_startspeed_fade = 0
 
float autocvar_hud_panel_strafehud_startspeed_size = 1.5
 
int autocvar_hud_panel_strafehud_style = 1
 
float autocvar_hud_panel_strafehud_switch_active_alpha = 1
 
vector autocvar_hud_panel_strafehud_switch_active_color = '0 1 0'
 
float autocvar_hud_panel_strafehud_switch_inactive_alpha = 1
 
vector autocvar_hud_panel_strafehud_switch_inactive_color = '1 1 0'
 
float autocvar_hud_panel_strafehud_switch_minspeed = -1
 
float autocvar_hud_panel_strafehud_switch_width = 0.0075
 
float autocvar_hud_panel_strafehud_timeout_air = 0.1
 
float autocvar_hud_panel_strafehud_timeout_direction = 0.5
 
float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333
 
float autocvar_hud_panel_strafehud_timeout_turn = 0.1
 
int autocvar_hud_panel_strafehud_unit = 1
 
bool autocvar_hud_panel_strafehud_unit_show = true
 

Function Documentation

◆ GetLengthUnit()

string GetLengthUnit ( int  )

Definition at line 873 of file strafehud.qc.

References strcat().

Referenced by HUD_StrafeHUD().

874 {
875  switch(length_unit)
876  {
877  // translator-friendly strings without the initial space
878  default:
879  case 1: return strcat(" ", _("qu"));
880  case 2: return strcat(" ", _("m"));
881  case 3: return strcat(" ", _("km"));
882  case 4: return strcat(" ", _("mi"));
883  case 5: return strcat(" ", _("nmi"));
884  }
885 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLengthUnitFactor()

float GetLengthUnitFactor ( int  )

Definition at line 860 of file strafehud.qc.

Referenced by HUD_StrafeHUD().

861 {
862  switch(length_unit)
863  {
864  default:
865  case 1: return 1.0;
866  case 2: return 0.0254;
867  case 3: return 0.0254 * 0.001;
868  case 4: return 0.0254 * 0.001 * 0.6213711922;
869  case 5: return 0.0254 * 0.001 * 0.5399568035;
870  }
871 }
+ Here is the caller graph for this function:

◆ HUD_Panel_DrawStrafeHUD()

void HUD_Panel_DrawStrafeHUD ( float  ,
float  ,
vector  ,
float  ,
int  ,
int   
)

Definition at line 749 of file strafehud.qc.

References autocvar_hud_panel_strafehud_bar_neutral_color, direction, drawfill(), DRAWFLAG_NORMAL, eX, fabs(), hidden_width, HUD_Panel_DrawProgressBar(), max(), min(), panel_pos, panel_size, size, StrafeHUD_drawGradient(), and vector().

Referenced by HUD_StrafeHUD().

750 {
751  float mirror_offset, mirror_width;
753  vector mirror_size = panel_size;
754 
755  float original_width = width;
756  float hiddencolor_width;
757 
758  if(alpha <= 0 && type != 2 || width <= 0) return;
759 
760  if(type == 2 && gradientType == 0) type = 0;
761 
762  if(offset < 0)
763  {
764  mirror_width = min(fabs(offset), width);
765  mirror_offset = panel_size.x + hidden_width - fabs(offset);
766  width += offset;
767  offset = 0;
768  }
769  else
770  {
771  mirror_width = min(offset + width - panel_size.x - hidden_width, width);
772  mirror_offset = max(offset - panel_size.x - hidden_width, 0);
773  }
774  if((offset + width) > panel_size.x)
775  {
776  width = panel_size.x - offset;
777  }
778  if(mirror_offset < 0)
779  {
780  mirror_width += mirror_offset;
781  mirror_offset = 0;
782  }
783  if((mirror_offset + mirror_width) > panel_size.x)
784  {
785  mirror_width = panel_size.x - mirror_offset;
786  }
787 
788  if(width < 0) width = 0;
789  if(mirror_width < 0) mirror_width = 0;
790  hiddencolor_width = original_width - width - mirror_width;
791 
792  if(direction < 0) // swap mirror and non-mirror values if direction points left
793  {
794  offset += mirror_offset;
795  mirror_offset = offset - mirror_offset;
796  offset -= mirror_offset;
797 
798  width += mirror_width;
799  mirror_width = width - mirror_width;
800  width -= mirror_width;
801  }
802 
803  size.x = width;
804  mirror_size.x = mirror_width;
805 
806  switch(type)
807  {
808  default:
809  case 0: // no styling (drawfill)
810  if(mirror_size.x > 0 && mirror_size.y > 0) drawfill(panel_pos + eX * mirror_offset, mirror_size, color, alpha, DRAWFLAG_NORMAL);
811  if(size.x > 0 && size.y > 0) drawfill(panel_pos + eX * offset, size, color, alpha, DRAWFLAG_NORMAL);
812  break;
813 
814  case 1: // progress bar style
815  if(mirror_size.x > 0 && mirror_size.y > 0) HUD_Panel_DrawProgressBar(panel_pos + eX * mirror_offset, mirror_size, "progressbar", 1, 0, 0, color, alpha, DRAWFLAG_NORMAL);
816  if(size.x > 0 && size.y > 0) HUD_Panel_DrawProgressBar(panel_pos + eX * offset, size, "progressbar", 1, 0, 0, color, alpha, DRAWFLAG_NORMAL);
817  break;
818 
819  case 2: // gradient style (types: 1 = left, 2 = right, 3 = both)
820  StrafeHUD_drawGradient(color, autocvar_hud_panel_strafehud_bar_neutral_color, mirror_size, original_width, mirror_offset, alpha, width + (mirror_offset == 0 ? hiddencolor_width : 0), gradientType);
821  StrafeHUD_drawGradient(color, autocvar_hud_panel_strafehud_bar_neutral_color, size, original_width, offset, alpha, (offset == 0 ? hiddencolor_width : 0), gradientType);
822  }
823 }
vector color
float alpha
Definition: items.qc:14
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, bool vertical, float baralign, vector theColor, float theAlpha, int drawflag)
Definition: hud.qc:270
vector panel_size
Definition: hud.qh:160
int direction
Definition: strafehud.qc:24
vector size
Definition: csprogsdefs.qc:114
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
vector panel_pos
Definition: hud.qh:159
void StrafeHUD_drawGradient(vector color1, vector color2, vector size, float original_width, float offset, float alpha, float gradientOffset, int gradientType)
Definition: strafehud.qc:836
float hidden_width
Definition: strafehud.qc:23
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
vector autocvar_hud_panel_strafehud_bar_neutral_color
Definition: strafehud.qh:12
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StrafeHUD_drawGradient()

void StrafeHUD_drawGradient ( vector  ,
vector  ,
vector  ,
float  ,
float  ,
float  ,
float  ,
int   
)

Definition at line 836 of file strafehud.qc.

References autocvar_hud_panel_strafehud_bar_neutral_alpha, bound(), drawfill(), DRAWFLAG_NORMAL, eX, panel_pos, size, StrafeHUD_mixColors(), and vector().

Referenced by HUD_Panel_DrawStrafeHUD().

837 {
838  float color_ratio, alpha1, alpha2;
839  vector gradient_size = size;
840  alpha1 = bound(0, alpha, 1);
842  if((alpha1+alpha2) == 0) return;
843  color_ratio = alpha1/(alpha1+alpha2);
844  for(int i = 0; i < size.x; ++i)
845  {
846  float ratio, alpha_ratio, combine_ratio1, combine_ratio2;
847  gradient_size.x = size.x - i < 1 ? size.x - i : 1;
848  ratio = (i + gradientOffset) / original_width * (gradientType == 3 ? 2 : 1);
849  if(ratio > 1) ratio = 2 - ratio;
850  if(gradientType != 2) ratio = 1 - ratio;
851  alpha_ratio = alpha1 - (alpha1 - alpha2) * ratio;
852  combine_ratio1 = ratio*(1-color_ratio);
853  combine_ratio2 = (1-ratio)*color_ratio;
854  ratio = (combine_ratio1 + combine_ratio2) == 0 ? 1 : combine_ratio1/(combine_ratio1 + combine_ratio2);
855  if(alpha_ratio > 0) drawfill(panel_pos + eX * (offset + i), gradient_size, StrafeHUD_mixColors(color1, color2, ratio), alpha_ratio, DRAWFLAG_NORMAL);
856  }
857 }
float alpha
Definition: items.qc:14
vector size
Definition: csprogsdefs.qc:114
float autocvar_hud_panel_strafehud_bar_neutral_alpha
Definition: strafehud.qh:13
const float DRAWFLAG_NORMAL
Definition: csprogsdefs.qc:317
vector panel_pos
Definition: hud.qh:159
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const vector eX
Definition: vector.qh:44
vector StrafeHUD_mixColors(vector color1, vector color2, float ratio)
Definition: strafehud.qc:825
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StrafeHUD_mixColors()

vector StrafeHUD_mixColors ( vector  ,
vector  ,
float   
)

Definition at line 825 of file strafehud.qc.

References vector().

Referenced by HUD_StrafeHUD(), and StrafeHUD_drawGradient().

826 {
827  vector mixedColor;
828  if(ratio <= 0) return color1;
829  if(ratio >= 1) return color2;
830  mixedColor.x = color1.x + (color2.x - color1.x) * ratio;
831  mixedColor.y = color1.y + (color2.y - color1.y) * ratio;
832  mixedColor.z = color1.z + (color2.z - color1.z) * ratio;
833  return mixedColor;
834 }
vector(float skel, float bonenum) _skel_get_boneabs_hidden
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar__hud_panel_strafehud_demo

bool autocvar__hud_panel_strafehud_demo = false

Definition at line 5 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud

int autocvar_hud_panel_strafehud = 3

Definition at line 4 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_accel_color

vector autocvar_hud_panel_strafehud_angle_accel_color = '0 1 1'

Definition at line 22 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_alpha

float autocvar_hud_panel_strafehud_angle_alpha = 0.8

Definition at line 18 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_height

float autocvar_hud_panel_strafehud_angle_height = 1.5

Definition at line 19 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_neutral_color

vector autocvar_hud_panel_strafehud_angle_neutral_color = '1 1 0'

Definition at line 21 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_overturn_color

vector autocvar_hud_panel_strafehud_angle_overturn_color = '1 0 1'

Definition at line 23 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_angle_width

float autocvar_hud_panel_strafehud_angle_width = 0.005

Definition at line 20 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_antiflicker_angle

float autocvar_hud_panel_strafehud_antiflicker_angle = 0.01

Definition at line 50 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_antiflicker_speed

float autocvar_hud_panel_strafehud_antiflicker_speed = 0.0001

Definition at line 51 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_bar_accel_alpha

float autocvar_hud_panel_strafehud_bar_accel_alpha = 0.3

Definition at line 15 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_bar_accel_color

vector autocvar_hud_panel_strafehud_bar_accel_color = '0 1 0'

Definition at line 14 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_bar_neutral_alpha

float autocvar_hud_panel_strafehud_bar_neutral_alpha = 0.3

Definition at line 13 of file strafehud.qh.

Referenced by HUD_StrafeHUD(), and StrafeHUD_drawGradient().

◆ autocvar_hud_panel_strafehud_bar_neutral_color

vector autocvar_hud_panel_strafehud_bar_neutral_color = '1 1 1'

Definition at line 12 of file strafehud.qh.

Referenced by HUD_Panel_DrawStrafeHUD(), and HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_bar_overturn_alpha

float autocvar_hud_panel_strafehud_bar_overturn_alpha = 0.3

Definition at line 17 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_bar_overturn_color

vector autocvar_hud_panel_strafehud_bar_overturn_color = '1 0 1'

Definition at line 16 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_direction_alpha

float autocvar_hud_panel_strafehud_direction_alpha = 1

Definition at line 31 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_direction_color

vector autocvar_hud_panel_strafehud_direction_color = '0 0.5 1'

Definition at line 30 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_direction_length

float autocvar_hud_panel_strafehud_direction_length = 0.02

Definition at line 33 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_direction_width

float autocvar_hud_panel_strafehud_direction_width = 0.25

Definition at line 32 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_dynamichud

bool autocvar_hud_panel_strafehud_dynamichud = true

Definition at line 6 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_jumpheight_color

vector autocvar_hud_panel_strafehud_jumpheight_color = '0 1 0.75'

Definition at line 44 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_jumpheight_fade

float autocvar_hud_panel_strafehud_jumpheight_fade = 0

Definition at line 42 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_jumpheight_min

float autocvar_hud_panel_strafehud_jumpheight_min = 50

Definition at line 43 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_jumpheight_size

float autocvar_hud_panel_strafehud_jumpheight_size = 1.5

Definition at line 45 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_mode

int autocvar_hud_panel_strafehud_mode = 0

Definition at line 7 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_range

float autocvar_hud_panel_strafehud_range = 0

Definition at line 8 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_slickdetector_alpha

float autocvar_hud_panel_strafehud_slickdetector_alpha = 0.5

Definition at line 37 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_slickdetector_color

vector autocvar_hud_panel_strafehud_slickdetector_color = '0 1 1'

Definition at line 36 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_slickdetector_granularity

int autocvar_hud_panel_strafehud_slickdetector_granularity = 2

Definition at line 35 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_slickdetector_height

float autocvar_hud_panel_strafehud_slickdetector_height = 0.125

Definition at line 38 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_slickdetector_range

float autocvar_hud_panel_strafehud_slickdetector_range = 0

Definition at line 34 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_startspeed_color

vector autocvar_hud_panel_strafehud_startspeed_color = '1 0.75 0'

Definition at line 40 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_startspeed_fade

float autocvar_hud_panel_strafehud_startspeed_fade = 0

Definition at line 39 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_startspeed_size

float autocvar_hud_panel_strafehud_startspeed_size = 1.5

Definition at line 41 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_style

int autocvar_hud_panel_strafehud_style = 1

Definition at line 9 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_active_alpha

float autocvar_hud_panel_strafehud_switch_active_alpha = 1

Definition at line 26 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_active_color

vector autocvar_hud_panel_strafehud_switch_active_color = '0 1 0'

Definition at line 25 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_inactive_alpha

float autocvar_hud_panel_strafehud_switch_inactive_alpha = 1

Definition at line 28 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_inactive_color

vector autocvar_hud_panel_strafehud_switch_inactive_color = '1 1 0'

Definition at line 27 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_minspeed

float autocvar_hud_panel_strafehud_switch_minspeed = -1

Definition at line 24 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_switch_width

float autocvar_hud_panel_strafehud_switch_width = 0.0075

Definition at line 29 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_timeout_air

float autocvar_hud_panel_strafehud_timeout_air = 0.1

Definition at line 46 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_timeout_direction

float autocvar_hud_panel_strafehud_timeout_direction = 0.5

Definition at line 49 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_timeout_ground

float autocvar_hud_panel_strafehud_timeout_ground = 0.03333333

Definition at line 47 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_timeout_turn

float autocvar_hud_panel_strafehud_timeout_turn = 0.1

Definition at line 48 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_unit

int autocvar_hud_panel_strafehud_unit = 1

Definition at line 10 of file strafehud.qh.

Referenced by HUD_StrafeHUD().

◆ autocvar_hud_panel_strafehud_unit_show

bool autocvar_hud_panel_strafehud_unit_show = true

Definition at line 11 of file strafehud.qh.

Referenced by HUD_StrafeHUD().