seta hud_panel_strafehud_startspeed "1" "set to 1 to enable the start speed indicator which shows you the speed you had while passing the start trigger of a race map"
seta hud_panel_strafehud_startspeed_fade "4" "fade time (in seconds) of the start speed text"
seta hud_panel_strafehud_startspeed_color "1 0.75 0" "color of the start speed text"
+seta hud_panel_strafehud_startspeed_pos "0 -1 0" "position of the start speed text (relative to the panel), the Y coordinate must be <= -1 (below) or >= 1 (above) the panel"
seta hud_panel_strafehud_startspeed_size "1.5" "size of the start speed text (relative to the panel height)"
seta hud_panel_strafehud_jumpheight "0" "set to 1 to enable the jump height indicator which tells you how high you jumped"
seta hud_panel_strafehud_jumpheight_fade "4" "fade time (in seconds) of the jump height text"
seta hud_panel_strafehud_jumpheight_min "50" "minimum jump height to display in the selected unit"
seta hud_panel_strafehud_jumpheight_color "0 1 0.75" "color of the jump height text"
+seta hud_panel_strafehud_jumpheight_pos "0 -2 0" "position of the jump height text (relative to the panel), the Y coordinate must be <= -1 (below) or >= 1 (above) the panel"
seta hud_panel_strafehud_jumpheight_size "1.5" "size of the jump height text (relative to the panel height)"
seta hud_panel_strafehud_timeout_ground "0.1" "time (in seconds) after take off before changing to air strafe physics when not jumping (visually more consistent hud while on slick downwards ramps)"
seta hud_panel_strafehud_timeout_turn "0.1" "time (in seconds) after releasing the strafe keys before changing mode (visually more consistent hud while switching between left/right strafe turning)"
seta hud_panel_strafehud_sonar_pitch_exponent "1" "exponent of the dynamic playback speed range of the strafe sonar"
seta hud_panel_strafehud_vangle "0" "set to 1 to enable the vertical angle indicator"
seta hud_panel_strafehud_vangle_color "0.75 0.75 0.75" "color of the vertical angle text"
+seta hud_panel_strafehud_vangle_pos "-0.25 1 0" "position of the vertical angle text (relative to the panel), the Y coordinate must be <= -1 (below) or >= 1 (above) the panel"
seta hud_panel_strafehud_vangle_size "1" "size of the vertical angle text (relative to the panel height)"
seta hud_panel_strafehud_strafeefficiency "0" "set to 1 to enable the strafe efficiency indicator"
+seta hud_panel_strafehud_strafeefficiency_pos "0.25 1 0" "size of the strafe efficiency text (relative to the panel), the Y coordinate must be <= -1 (below) or >= 1 (above) the panel"
seta hud_panel_strafehud_strafeefficiency_size "1" "size of the strafe efficiency text (relative to the panel height)"
seta hud_panel_strafehud_projection "0" "strafehud projection mode, 0 = linear, 1 = perspective, 2 = panoramic"
}
}
- text_offset_bottom += StrafeHUD_DrawVerticalAngle(strafeplayer, text_offset_bottom);
+ StrafeHUD_DrawVerticalAngle(strafeplayer, text_offset_top, text_offset_bottom);
draw_beginBoldFont();
- text_offset_bottom += StrafeHUD_DrawStartSpeed(speed, text_offset_bottom);
- text_offset_top += StrafeHUD_DrawStrafeEfficiency(strafe_ratio, text_offset_top);
- text_offset_top += StrafeHUD_DrawJumpHeight(strafeplayer, real_onground, swimming, text_offset_top);
+ StrafeHUD_DrawStartSpeed(speed, text_offset_top, text_offset_bottom);
+ StrafeHUD_DrawStrafeEfficiency(strafe_ratio, text_offset_top, text_offset_bottom);
+ StrafeHUD_DrawJumpHeight(strafeplayer, real_onground, swimming, text_offset_top, text_offset_bottom);
draw_endBoldFont();
StrafeHUD_Sonar(strafe_ratio, StrafeHUD_UpdateSonarSound());
bool autocvar_hud_panel_strafehud_startspeed = true;
float autocvar_hud_panel_strafehud_startspeed_fade = 4;
vector autocvar_hud_panel_strafehud_startspeed_color = '1 0.75 0';
+vector autocvar_hud_panel_strafehud_startspeed_pos = '0 -1 0';
float autocvar_hud_panel_strafehud_startspeed_size = 1.5;
bool autocvar_hud_panel_strafehud_jumpheight = false;
float autocvar_hud_panel_strafehud_jumpheight_fade = 4;
float autocvar_hud_panel_strafehud_jumpheight_min = 50;
vector autocvar_hud_panel_strafehud_jumpheight_color = '0 1 0.75';
+vector autocvar_hud_panel_strafehud_jumpheight_pos = '0 -2 0';
float autocvar_hud_panel_strafehud_jumpheight_size = 1.5;
float autocvar_hud_panel_strafehud_timeout_ground = 0.1;
float autocvar_hud_panel_strafehud_timeout_turn = 0.1;
float autocvar_hud_panel_strafehud_sonar_pitch_exponent = 1;
bool autocvar_hud_panel_strafehud_vangle = false;
vector autocvar_hud_panel_strafehud_vangle_color = '0.75 0.75 0.75';
+vector autocvar_hud_panel_strafehud_vangle_pos = '-0.25 1 0';
float autocvar_hud_panel_strafehud_vangle_size = 1;
bool autocvar_hud_panel_strafehud_strafeefficiency = false;
+vector autocvar_hud_panel_strafehud_strafeefficiency_pos = '0.25 1 0';
float autocvar_hud_panel_strafehud_strafeefficiency_size = 1;
int autocvar_hud_panel_strafehud_projection = 0;
const int STRAFEHUD_INDICATOR_SOLID = 1;
const int STRAFEHUD_INDICATOR_DASHED = 2;
-const int STRAFEHUD_TEXT_TOP = 0;
-const int STRAFEHUD_TEXT_BOTTOM = 1;
-
const int STRAFEHUD_PROJECTION_LINEAR = 0;
const int STRAFEHUD_PROJECTION_PERSPECTIVE = 1;
const int STRAFEHUD_PROJECTION_PANORAMIC = 2;
}
// draw a fading text indicator above or below the strafe meter, return true if something was displayed
-bool StrafeHUD_DrawTextIndicator(string text, float height, vector color, float fadetime, float lasttime, float offset, int position)
+void StrafeHUD_DrawTextIndicator(string text, float height, vector color, float fadetime, float lasttime, vector pos, float offset_top, float offset_bottom)
{
if((height <= 0) || (lasttime <= 0) || (fadetime <= 0) || ((time - lasttime) >= fadetime))
- return false;
+ return;
float alpha = cos(((time - lasttime) / fadetime) * M_PI_2); // fade non-linear like the physics panel does
vector size = panel_size;
size.y = height;
- switch(position)
+ if(pos.y >= 1)
{
- case STRAFEHUD_TEXT_TOP:
- offset += size.y;
- offset *= -1;
- break;
- case STRAFEHUD_TEXT_BOTTOM:
- offset += panel_size.y;
- break;
+ pos.y--; // for calculations the position should not start at +1
+ pos = StrafeHUD_CalculateTextIndicatorPosition(pos);
+ pos.y += size.y + offset_top;
+ pos.y *= -1; // it's more intuitive for up to be positive
+ }
+ else if(pos.y <= -1)
+ {
+ pos.y++; // for calculations the position should not start at -1
+ pos = StrafeHUD_CalculateTextIndicatorPosition(pos);
+ pos.y *= -1; // it's more intuitive for down to be negative
+ pos.y += panel_size.y + offset_bottom;
}
+ else return;
+
+ drawstring_aspect(panel_pos + pos, text, size, color, alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+}
+
+vector StrafeHUD_CalculateTextIndicatorPosition(vector pos)
+{
+ pos.x *= panel_size.x / 2; // more intuitive since we start in the middle, this turns the range from -0.5 to +0.5 into -1 to +1
+ pos.y *= panel_size.y;
+ pos.z = 0;
- drawstring_aspect(panel_pos + eY * offset, text, size, color, alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
- return true;
+ return pos;
}
void StrafeHUD_DrawGradient(vector, vector, vector, float, float, float, float, float, int, float);
void StrafeHUD_DrawGradientFast(vector, vector, vector, float, float, float, float, int);
void StrafeHUD_DrawStrafeArrow(vector, float, vector, float, bool, float);
-bool StrafeHUD_DrawTextIndicator(string, float, vector, float, float, float, int);
+void StrafeHUD_DrawTextIndicator(string, float, vector, float, float, vector, float, float);
+vector StrafeHUD_CalculateTextIndicatorPosition(vector);
}
// vertical angle for weapon jumps
-float StrafeHUD_DrawVerticalAngle(entity e, float text_offset_bottom)
+void StrafeHUD_DrawVerticalAngle(entity e, float text_offset_top, float text_offset_bottom)
{
if(autocvar_hud_panel_strafehud_vangle)
{
float vangle_height = autocvar_hud_panel_strafehud_vangle_size * panel_size.y;
string vangle_text = strcat(ftos_decimals(vangle, 2), "°");
- bool was_drawn = StrafeHUD_DrawTextIndicator(
+ StrafeHUD_DrawTextIndicator(
vangle_text, vangle_height,
autocvar_hud_panel_strafehud_vangle_color, 1,
- time, text_offset_bottom, STRAFEHUD_TEXT_BOTTOM);
-
- if(was_drawn)
- return vangle_height;
+ time, autocvar_hud_panel_strafehud_vangle_pos,
+ text_offset_top, text_offset_bottom);
}
-
- return 0;
}
// strafe sonar for audible feedback when strafing
// show height achieved by a single jump
// FIXME: checking z position differences is unreliable (warpzones, teleporter, kill, etc), use velocity to calculate jump height instead
// FIXME: move capturing the jump height value out of the HUD
-float StrafeHUD_DrawJumpHeight(entity e, bool onground, bool swimming, float text_offset_top)
+void StrafeHUD_DrawJumpHeight(entity e, bool onground, bool swimming, float text_offset_top, float text_offset_bottom)
{
float length_conversion_factor = StrafeHUD_GetLengthUnitFactor(autocvar_hud_speed_unit);
static float height_min = 0, height_max = 0; // ground and peak of jump z coordinates
if(autocvar_hud_panel_strafehud_unit_show)
jumpheight_text = strcat(jumpheight_text, StrafeHUD_GetLengthUnit(autocvar_hud_speed_unit));
- bool was_drawn = StrafeHUD_DrawTextIndicator(
+ StrafeHUD_DrawTextIndicator(
jumpheight_text, jumpheight_height,
autocvar_hud_panel_strafehud_jumpheight_color,
autocvar_hud_panel_strafehud_jumpheight_fade,
- jumptime, text_offset_top, STRAFEHUD_TEXT_TOP);
-
- if(was_drawn)
- return jumpheight_height;
+ jumptime, autocvar_hud_panel_strafehud_jumpheight_pos,
+ text_offset_top, text_offset_bottom);
}
-
- return 0;
}
// strafe efficiency, percentage of how far away the current angle is from the optimal angle
// the percentage changes linearly with angular distance
-float StrafeHUD_DrawStrafeEfficiency(float strafe_ratio, float text_offset_top)
+void StrafeHUD_DrawStrafeEfficiency(float strafe_ratio, float text_offset_top, float text_offset_bottom)
{
+ if(autocvar_hud_panel_strafehud_strafeefficiency)
{
- if(autocvar_hud_panel_strafehud_strafeefficiency)
- {
- float strafeeff_height = autocvar_hud_panel_strafehud_strafeefficiency_size * panel_size.y;
- string strafeeff_text = strcat(ftos_decimals(strafe_ratio * 100, 2), "%");
- vector strafeeff_color = '1 1 1' - (strafe_ratio > 0 ? '1 0 1' : '0 1 1') * fabs(strafe_ratio);
-
- bool was_drawn = StrafeHUD_DrawTextIndicator(
- strafeeff_text, strafeeff_height,
- strafeeff_color, 1,
- time, text_offset_top, STRAFEHUD_TEXT_TOP);
-
- if(was_drawn)
- return strafeeff_height;
- }
+ float strafeeff_height = autocvar_hud_panel_strafehud_strafeefficiency_size * panel_size.y;
+ string strafeeff_text = strcat(ftos_decimals(strafe_ratio * 100, 2), "%");
+ vector strafeeff_color = '1 1 1' - (strafe_ratio > 0 ? '1 0 1' : '0 1 1') * fabs(strafe_ratio);
+
+ StrafeHUD_DrawTextIndicator(
+ strafeeff_text, strafeeff_height,
+ strafeeff_color, 1,
+ time, autocvar_hud_panel_strafehud_strafeefficiency_pos,
+ text_offset_top, text_offset_bottom);
}
-
- return 0;
}
// show speed when crossing the start trigger
// FIXME: move capturing the race start speed value out of the HUD
-float StrafeHUD_DrawStartSpeed(float speed, float text_offset_bottom)
+void StrafeHUD_DrawStartSpeed(float speed, float text_offset_top, float text_offset_bottom)
{
static float startspeed = 0, starttime = 0; // displayed value and timestamp for fade out
if(autocvar_hud_panel_strafehud_unit_show)
startspeed_text = strcat(startspeed_text, GetSpeedUnit(autocvar_hud_speed_unit));
- bool was_drawn = StrafeHUD_DrawTextIndicator(
+ StrafeHUD_DrawTextIndicator(
startspeed_text, startspeed_height,
autocvar_hud_panel_strafehud_startspeed_color,
autocvar_hud_panel_strafehud_startspeed_fade,
- starttime, text_offset_bottom, STRAFEHUD_TEXT_BOTTOM);
-
- if(was_drawn)
- return startspeed_height;
+ starttime, autocvar_hud_panel_strafehud_startspeed_pos,
+ text_offset_top, text_offset_bottom);
}
-
- return 0;
}
#include "../strafehud.qh"
float StrafeHUD_DrawSlickDetector(entity, bool);
-float StrafeHUD_DrawVerticalAngle(entity, float);
+void StrafeHUD_DrawVerticalAngle(entity, float, float);
void StrafeHUD_Sonar(float, string);
string StrafeHUD_UpdateSonarSound();
-float StrafeHUD_DrawJumpHeight(entity, bool, bool, float);
-float StrafeHUD_DrawStrafeEfficiency(float, float);
-float StrafeHUD_DrawStartSpeed(float, float);
+void StrafeHUD_DrawJumpHeight(entity, bool, bool, float, float);
+void StrafeHUD_DrawStrafeEfficiency(float, float, float);
+void StrafeHUD_DrawStartSpeed(float, float, float);