seta hud_progressbar_armor_color "" "R G B vector of the progress bar background color"
seta hud_progressbar_fuel_color "" "R G B vector of the progress bar background color"
seta hud_progressbar_nexball_color "" "R G B vector of the progress bar background color"
+seta hud_progressbar_speed_color "" "R G B vector of the progress bar background color"
+seta hud_progressbar_acceleration_color "" "R G B vector of the progress bar background color"
+seta hud_progressbar_acceleration_neg_color "" "R G B vector of the progress bar background color"
seta _hud_panelorder "" "contains order in which panels are to be drawn"
seta hud_panel_infomessages_bg_border "" "if set to something else than \"\" = override default size of border around the background"
seta hud_panel_infomessages_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
seta hud_panel_infomessages_flip "" "1 = align the items to the right"
+
+seta hud_panel_physics "" "enable/disable this panel
+seta hud_panel_physics_pos "" "position of this base of the panel"
+seta hud_panel_physics_size "" "size of this panel"
+seta hud_panel_physics_bg "" "if set to something else than \"\" = override default background"
+seta hud_panel_physics_bg_color "" "if set to something else than \"\" = override default panel background color"
+seta hud_panel_physics_bg_color_team "" "override panel color with team color in team based games"
+seta hud_panel_physics_bg_alpha "" "if set to something else than \"\" = override default panel background alpha"
+seta hud_panel_physics_bg_border "" "if set to something else than \"\" = override default size of border around the background"
+seta hud_panel_physics_bg_padding "" "if set to something else than \"\" = override default padding of contents from border"
+seta hud_panel_physics_baralign "" "1 = align bars to the right"
+seta hud_panel_physics_flip "" "flip speed/acceleration positions"
+seta hud_panel_physics_progressbar "" "enable progressbar in panel"
seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight 0.1 "weight of latest data point"
seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold 0.5 "threshold for fps change when to update instantly, to make big fps changes update faster"
+seta hud_panel_physics_speed_unit 3 "speed unit (1 = qu/s, 2 = m/s, 3 = km/h, 4 = mph, 5 = knots)"
+seta hud_panel_physics_speed_unit_show 1 "also show speed unit"
+seta hud_panel_physics_speed_max 1800 "speed progressbar gets filled up completely by this value (in qu/s)"
+seta hud_panel_physics_speed_z 0 "include the speed on the Z-axis"
+seta hud_panel_physics_topspeed 1 "also show top speed"
+seta hud_panel_physics_topspeed_time 4 "how many seconds the top speed takes to fade out"
+seta hud_panel_physics_acceleration_max 2 "acceleration progressbar gets filled up completely by this value"
+seta hud_panel_physics_acceleration_z 0 "include the acceleration on the Z-axis"
+
seta hud_showbinds 1 "the way to show the keys to press in HUD messages: 0 displays commands, 1 bound keys, 2 both"
seta hud_showbinds_limit 2 "maximum number of bound keys to show for a command. 0 for unlimited"
seta hud_progressbar_armor_color "0 0.6 0"
seta hud_progressbar_fuel_color "0.6 0.6 0"
seta hud_progressbar_nexball_color "0.7 0.1 0"
+seta hud_progressbar_speed_color "1 0.75 0"
+seta hud_progressbar_acceleration_color "0.5 0.75 1"
+seta hud_progressbar_acceleration_neg_color "0.125 0.25 0.5"
-seta _hud_panelorder "10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 "
+seta _hud_panelorder "10 9 6 8 14 5 0 4 13 2 7 1 3 11 12 15 "
seta hud_configure_grid "1"
seta hud_configure_grid_xsize "0.010000"
seta hud_panel_infomessages_bg_padding "0"
seta hud_panel_infomessages_flip "1"
+seta hud_panel_physics 0
+seta hud_panel_physics_pos "0.410000 0.590000"
+seta hud_panel_physics_size "0.180000 0.100000"
+seta hud_panel_physics_bg ""
+seta hud_panel_physics_bg_color ""
+seta hud_panel_physics_bg_color_team ""
+seta hud_panel_physics_bg_alpha ""
+seta hud_panel_physics_bg_border ""
+seta hud_panel_physics_bg_padding ""
+seta hud_panel_physics_flip "0"
+seta hud_panel_physics_baralign "0"
+seta hud_panel_physics_progressbar "1"
+
menu_sync
seta hud_progressbar_armor_color "0 0.6 0"
seta hud_progressbar_fuel_color "0.6 0.6 0"
seta hud_progressbar_nexball_color "0.7 0.1 0"
+seta hud_progressbar_speed_color "1 0.5 0.75"
+seta hud_progressbar_acceleration_color "0.5 1 0.75"
+seta hud_progressbar_acceleration_neg_color "0.5 0.75 1"
-seta _hud_panelorder "0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 "
+seta _hud_panelorder "0 11 8 5 6 14 9 13 7 2 3 1 10 12 4 15 "
seta hud_configure_grid "1"
seta hud_configure_grid_xsize "0.01"
seta hud_panel_infomessages_bg_padding ""
seta hud_panel_infomessages_flip "1"
+seta hud_panel_physics 0
+seta hud_panel_physics_pos "0.430000 0.640000"
+seta hud_panel_physics_size "0.140000 0.100000"
+seta hud_panel_physics_bg "0"
+seta hud_panel_physics_bg_color ""
+seta hud_panel_physics_bg_color_team ""
+seta hud_panel_physics_bg_alpha ""
+seta hud_panel_physics_bg_border ""
+seta hud_panel_physics_bg_padding ""
+seta hud_panel_physics_flip "0"
+seta hud_panel_physics_baralign "0"
+seta hud_panel_physics_progressbar "1"
+
menu_sync
var float autocvar_hud_panel_infomessages;
var float autocvar_hud_panel_infomessages_flip;
+var float autocvar_hud_panel_physics;
+
var float autocvar_scoreboard_border_thickness;
var float autocvar_cl_allow_uid2name;
case HUD_PANEL_INFOMESSAGES:
HUD_Write_PanelCvar_q("_flip");
break;
+ case HUD_PANEL_PHYSICS:
+ HUD_Write_PanelCvar_q("_flip");
+ HUD_Write_PanelCvar_q("_baralign");
+ HUD_Write_PanelCvar_q("_progressbar");
+ break;
}
HUD_Write("\n");
}
}
}
+// Physics panel (#15)
+//
+vector acc_prevspeed;
+float acc_prevtime, acc_avg, top_speed, top_speed_time;
+
+void HUD_Physics(void)
+{
+ if(!autocvar_hud_panel_physics && !autocvar__hud_configure)
+ return;
+
+ active_panel = HUD_PANEL_PHYSICS;
+ HUD_Panel_UpdateCvars(physics);
+ vector pos, mySize;
+ pos = panel_pos;
+ mySize = panel_size;
+
+ HUD_Panel_DrawBg(1);
+ if(panel_bg_padding)
+ {
+ pos += '1 1 0' * panel_bg_padding;
+ mySize -= '2 2 0' * panel_bg_padding;
+ }
+
+ //compute speed
+ float speed, conversion_factor;
+ string zspeed, unit;
+
+ switch(cvar("hud_panel_physics_speed_unit"))
+ {
+ default:
+ case 1:
+ unit = "qu/s";
+ conversion_factor = 1.0;
+ break;
+ case 2:
+ unit = "m/s";
+ conversion_factor = 0.0254;
+ break;
+ case 3:
+ unit = "km/h";
+ conversion_factor = 0.0254 * 3.6;
+ break;
+ case 4:
+ unit = "mph";
+ conversion_factor = 0.0254 * 3.6 * 0.6213711922;
+ break;
+ case 5:
+ unit = "knots";
+ conversion_factor = 0.0254 * 1.943844492; // 1 m/s = 1.943844492 knots, because 1 knot = 1.852 km/h
+ break;
+ }
+
+ float max_speed = floor( cvar("hud_panel_physics_speed_max") * conversion_factor + 0.5 );
+ if (autocvar__hud_configure)
+ speed = floor( max_speed * 0.65 + 0.5 );
+ else if(cvar("hud_panel_physics_speed_z"))
+ speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
+ else
+ speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
+
+ //compute acceleration
+ float acceleration, f;
+ float max_acceleration = cvar("hud_panel_physics_acceleration_max");
+ if (autocvar__hud_configure)
+ acceleration = max_acceleration * 0.3;
+ else
+ {
+ f = time - acc_prevtime;
+ if(cvar("hud_panel_physics_acceleration_z"))
+ acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
+ else
+ acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
+ acc_prevspeed = pmove_vel;
+ acc_prevtime = time;
+
+ f = bound(0, f * 10, 1);
+ acc_avg = acc_avg * (1 - f) + acceleration * f;
+ acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
+ }
+
+ //compute layout
+ drawfont = hud_bigfont;
+ float baralign = cvar("hud_panel_physics_baralign");
+ float progressbar = cvar("hud_panel_physics_progressbar");
+ float panel_ar = mySize_x/mySize_y;
+ vector speed_offset, acceleration_offset;
+ if (panel_ar >= 5)
+ {
+ mySize_x *= 0.5;
+ if (cvar("hud_panel_physics_flip"))
+ speed_offset_x = mySize_x;
+ else
+ acceleration_offset_x = mySize_x;
+ }
+ else
+ {
+ mySize_y *= 0.5;
+ if (cvar("hud_panel_physics_flip"))
+ speed_offset_y = mySize_y;
+ else
+ acceleration_offset_y = mySize_y;
+ }
+ float speed_baralign, acceleration_baralign;
+ if (cvar("hud_panel_physics_flip"))
+ {
+ acceleration_baralign = (baralign == 1 || baralign == 2);
+ speed_baralign = (baralign == 1 || baralign == 3);
+ }
+ else
+ {
+ speed_baralign = (baralign == 1 || baralign == 2);
+ acceleration_baralign = (baralign == 1 || baralign == 3);
+ }
+
+ //draw speed
+ if(speed && progressbar)
+ {
+ HUD_Panel_GetProgressBarColor(speed);
+ HUD_Panel_DrawProgressBar(pos + speed_offset, mySize, speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+
+ vector tmp_offset, tmp_size;
+ tmp_size_x = mySize_x * 0.75;
+ tmp_size_y = mySize_y;
+ if (speed_baralign)
+ tmp_offset_x = mySize_x - tmp_size_x;
+ //else
+ //tmp_offset_x = 0;
+ drawstring_aspect(pos + speed_offset + tmp_offset, ftos(speed), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+
+ //draw speed unit
+ if (speed_baralign)
+ tmp_offset_x = 0;
+ else
+ tmp_offset_x = tmp_size_x;
+ if (cvar("hud_panel_physics_speed_unit_show"))
+ {
+ //tmp_offset_y = 0;
+ tmp_size_x = mySize_x * (1 - 0.75);
+ tmp_size_y = mySize_y * 0.4;
+ drawstring_aspect(pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+
+ //compute and draw top speed
+ if (cvar("hud_panel_physics_topspeed"))
+ {
+ if (autocvar__hud_configure)
+ {
+ top_speed = floor( max_speed * 0.75 + 0.5 );
+ f = 1;
+ }
+ else
+ {
+ if (speed >= top_speed)
+ {
+ top_speed = speed;
+ top_speed_time = time;
+ }
+ if (top_speed == 0) //hide top speed 0, it would be stupid
+ f = 0;
+ else
+ {
+ f = max(1, cvar("hud_panel_physics_topspeed_time"));
+ // divide by f to make it start from 1
+ f = cos( ((time - top_speed_time) / f) * PI/2 );
+ }
+ }
+ if (f > 0)
+ {
+ //top speed progressbar peek
+ if(progressbar && speed < top_speed)
+ {
+ float peek_offset_x, peek_size_x;
+ if (speed_baralign)
+ peek_offset_x = (1 - min(top_speed, max_speed)/max_speed) * mySize_x;
+ else
+ peek_offset_x = min(top_speed, max_speed)/max_speed * mySize_x;
+ //if speed is not 0 the speed progressbar already fetched the color
+ if (speed == 0)
+ HUD_Panel_GetProgressBarColor(speed);
+ peek_size_x = mySize_x * 0.01;
+ drawfill(pos + speed_offset + eX * (peek_offset_x - peek_size_x), eX * peek_size_x + eY * mySize_y, progressbar_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+
+ //top speed
+ tmp_offset_y = mySize_y * 0.4;
+ tmp_size_x = mySize_x * (1 - 0.75);
+ tmp_size_y = mySize_y - tmp_offset_y;
+ drawstring_aspect(pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+ else
+ top_speed = 0;
+ }
+
+ //draw acceleration
+ if(acceleration && progressbar)
+ {
+ if (acceleration < 0)
+ HUD_Panel_GetProgressBarColor(acceleration_neg);
+ else
+ HUD_Panel_GetProgressBarColor(acceleration);
+ HUD_Panel_DrawProgressBar(pos + acceleration_offset, mySize, fabs(acceleration)/max_acceleration, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+ drawstring_aspect(pos + acceleration_offset, ftos_decimals(acceleration, 3), mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawfont = hud_font;
+}
+
/*
==================
Main HUD system
drawfont = hud_font;
}
-vector acc_prevspeed;
-float acc_prevtime;
-float acc_avg;
-
void HUD_ShowAcceleration(void)
{
float acceleration, sz, scale, alpha, f;
HUD_EngineInfo(); break;\
case (HUD_PANEL_INFOMESSAGES):\
HUD_InfoMessages(); break;\
+ case (HUD_PANEL_PHYSICS):\
+ HUD_Physics(); break;\
} ENDS_WITH_CURLY_BRACE
void HUD_Main (void)
case "shield": HUD_Panel_GetProgressBarColor(shield); break;\
case "fuel": HUD_Panel_GetProgressBarColor(fuel); break;\
case "nexball": HUD_Panel_GetProgressBarColor(nexball); break;\
+ case "speed": HUD_Panel_GetProgressBarColor(speed); break;\
+ case "acceleration": HUD_Panel_GetProgressBarColor(acceleration); break;\
+ case "acceleration_neg": HUD_Panel_GetProgressBarColor(acceleration_neg); break;\
} ENDS_WITH_CURLY_BRACE
// Get value for panel_bg: if "" fetch default, else use panel_bg_str
} ENDS_WITH_CURLY_BRACE
// Update all common cvars of given panel id
+#define HUD_Panel_UpdateCvarsForId_Part2(id) \
+switch(id) { \
+ case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
+ case HUD_PANEL_PHYSICS: HUD_Panel_UpdateCvars(physics); break;\
+}
+
#define HUD_Panel_UpdateCvarsForId(id) \
switch(id) { \
case HUD_PANEL_WEAPONS: HUD_Panel_UpdateCvars(weapons) break; \
case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdateCvars(pressedkeys) break; \
case HUD_PANEL_CHAT: HUD_Panel_UpdateCvars(chat) break; \
case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdateCvars(engineinfo) break; \
- case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdateCvars(infomessages) break; \
-}
+}\
+HUD_Panel_UpdateCvarsForId_Part2(id)
#define HUD_Panel_UpdatePosSize(name) \
panel_pos = stov(cvar_string("hud_panel_" #name "_pos")); \
HUD_Panel_GetBorder()
// Update pos and size of given panel id
+#define HUD_Panel_UpdatePosSizeForId_Part2(id) \
+switch(id) { \
+ case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages) break;\
+ case HUD_PANEL_PHYSICS: HUD_Panel_UpdatePosSize(physics); break;\
+}
#define HUD_Panel_UpdatePosSizeForId(id) \
switch(id) { \
case HUD_PANEL_WEAPONS: HUD_Panel_UpdatePosSize(weapons) break;\
case HUD_PANEL_PRESSEDKEYS: HUD_Panel_UpdatePosSize(pressedkeys) break;\
case HUD_PANEL_CHAT: HUD_Panel_UpdatePosSize(chat) break;\
case HUD_PANEL_ENGINEINFO: HUD_Panel_UpdatePosSize(engineinfo) break;\
- case HUD_PANEL_INFOMESSAGES: HUD_Panel_UpdatePosSize(infomessages)\
-}
+}\
+HUD_Panel_UpdatePosSizeForId_Part2(id)
float HUD_PANEL_CHAT = 12;
float HUD_PANEL_ENGINEINFO = 13;
float HUD_PANEL_INFOMESSAGES = 14;
-float HUD_PANEL_NUM = 15; // always last panel id + 1, please increment when adding a new panel
+float HUD_PANEL_PHYSICS = 15;
+float HUD_PANEL_NUM = 16; // always last panel id + 1, please increment when adding a new panel
string HUD_PANELNAME_WEAPONS = "weapons";
string HUD_PANELNAME_AMMO = "ammo";
string HUD_PANELNAME_CHAT = "chat";
string HUD_PANELNAME_ENGINEINFO = "engineinfo";
string HUD_PANELNAME_INFOMESSAGES = "infomessages";
+string HUD_PANELNAME_PHYSICS = "physics";
float HUD_MENU_ENABLE = 0;
switch(id) {\
case HUD_PANEL_ENGINEINFO: panel_name = HUD_PANELNAME_ENGINEINFO; break; \
case HUD_PANEL_INFOMESSAGES: panel_name = HUD_PANELNAME_INFOMESSAGES; break; \
+ case HUD_PANEL_PHYSICS: panel_name = HUD_PANELNAME_PHYSICS; break; \
} ENDS_WITH_CURLY_BRACE
// Get name of specified panel id