+#include "scoreboard.qh"
+#include "teamradar.qh"
+#include "../common/buffs.qh"
+#include "../common/counting.qh"
+#include "../common/mapinfo.qh"
+#include "../common/nades.qh"
+#include "../server/t_items.qh"
+
/*
==================
Misc HUD functions
drawpic(theOrigin, pic, theSize, theColor, theAlpha, 0);
return;
}
- if (theBorderSize_x == 0 && theBorderSize_y == 0) // no border
+ if (theBorderSize.x == 0 && theBorderSize.y == 0) // no border
{
// draw only the central part
drawsubpic(theOrigin, theSize, pic, '0.25 0.25 0', '0.5 0.5 0', theColor, theAlpha, 0);
float blinkingamt;
vector color;
if(x >= maxvalue) {
- color_x = sin(2*M_PI*time);
- color_y = 1;
- color_z = sin(2*M_PI*time);
+ color.x = sin(2*M_PI*time);
+ color.y = 1;
+ color.z = sin(2*M_PI*time);
}
else if(x > maxvalue * 0.75) {
- color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
- color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
- color_z = 0;
+ color.x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0
+ color.y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1
+ color.z = 0;
}
else if(x > maxvalue * 0.5) {
- color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
- color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
- color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0
+ color.x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4
+ color.y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9
+ color.z = 1 - (x-100)*0.02; // blue value between 1 -> 0
}
else if(x > maxvalue * 0.25) {
- color_x = 1;
- color_y = 1;
- color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
+ color.x = 1;
+ color.y = 1;
+ color.z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1
}
else if(x > maxvalue * 0.1) {
- color_x = 1;
- color_y = (x-20)*90/27/100; // green value between 0 -> 1
- color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
+ color.x = 1;
+ color.y = (x-20)*90/27/100; // green value between 0 -> 1
+ color.z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2
}
else {
- color_x = 1;
- color_y = 0;
- color_z = 0;
+ color.x = 1;
+ color.y = 0;
+ color.z = 0;
}
blinkingamt = (1 - x/maxvalue/0.25);
if(blinkingamt > 0)
{
- color_x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
- color_y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
- color_z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
+ color.x = color.x - color.x * blinkingamt * sin(2*M_PI*time);
+ color.y = color.y - color.y * blinkingamt * sin(2*M_PI*time);
+ color.z = color.z - color.z * blinkingamt * sin(2*M_PI*time);
}
return color;
}
+float HUD_GetRowCount(float item_count, vector size, float item_aspect)
+{
+ float aspect = size_y / size_x;
+ return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count);
+}
+
float stringwidth_colors(string s, vector theSize)
{
return stringwidth(s, true, theSize);
void drawstringcenter(vector position, string text, vector theScale, vector rgb, float theAlpha, float flag)
{
- position_x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
+ position.x = 0.5 * (vid_conwidth - 0.6025 * strlen(text) * theScale.x);
drawstring(position, text, theScale, rgb, theAlpha, flag);
}
return 0;
}
-float GetPlayerColorForce(float i)
+float GetPlayerColorForce(int i)
{
if(!teamplay)
return 0;
return stof(getplayerkeyvalue(i, "colors")) & 15;
}
-float GetPlayerColor(float i)
+float GetPlayerColor(int i)
{
if(!playerslots[i].gotscores) // unconnected
return NUM_SPECTATOR;
return GetPlayerColorForce(i);
}
-string GetPlayerName(float i)
+string GetPlayerName(int i)
{
return ColorTranslateRGB(getplayerkeyvalue(i, "name"));
}
*/
// draw the background/borders
-#define HUD_Panel_DrawBg(theAlpha)\
-if(panel.current_panel_bg != "0" && panel.current_panel_bg != "")\
- draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER))
+#define HUD_Panel_DrawBg(theAlpha) do { \
+ if(panel.current_panel_bg != "0" && panel.current_panel_bg != "") \
+ draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel.current_panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * theAlpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
+} while(0)
//basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu
void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float length_ratio, float vertical, float baralign, vector theColor, float theAlpha, float drawflag)
// Weapon icons (#0)
//
entity weaponorder[WEP_MAXCOUNT];
-void weaponorder_swap(float i, float j, entity pass)
+void weaponorder_swap(int i, int j, entity pass)
{
- entity h;
- h = weaponorder[i];
+ entity h = weaponorder[i];
weaponorder[i] = weaponorder[j];
weaponorder[j] = h;
}
float screen_ar;
vector center = '0 0 0';
float weapon_count, weapon_id;
- float row, column, rows = 0, columns = 0;
+ float row, column, rows = 0, columns;
float aspect = autocvar_hud_panel_weapons_aspect;
- float panel_weapon_accuracy;
-
float timeout = autocvar_hud_panel_weapons_timeout;
float timein_effect_length = autocvar_hud_panel_weapons_timeout_speed_in; //? 0.375 : 0);
float timeout_effect_length = autocvar_hud_panel_weapons_timeout_speed_out; //? 0.75 : 0);
- float ammo_full;
vector barsize = '0 0 0', baroffset = '0 0 0';
vector ammo_color = '1 0 1';
float ammo_alpha = 1;
// figure out weapon order (how the weapons are sorted) // TODO make this configurable
if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0])
{
- float weapon_cnt;
+ int weapon_cnt;
if(weaponorder_bypriority)
strunzone(weaponorder_bypriority);
if(weaponorder_byimpulse)
if(!autocvar_hud_panel_weapons_complainbubble || autocvar__hud_configure || time - complain_weapon_time >= when + fadetime)
complain_weapon = 0;
+ if(autocvar__hud_configure)
+ {
+ if(!weapons_stat)
+ for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
+ weapons_stat |= WepSet_FromWeapon(i);
+ }
+
// determine which weapons are going to be shown
if (autocvar_hud_panel_weapons_onlyowned)
{
if(autocvar__hud_configure)
{
- if (!weapons_stat)
- for(i = WEP_FIRST; i <= WEP_LAST; i += floor((WEP_LAST-WEP_FIRST)/5))
- weapons_stat |= WepSet_FromWeapon(i);
-
if(menu_enabled != 2)
HUD_Panel_DrawBg(1); // also draw the bg of the entire panel
}
// do we own this weapon?
weapon_count = 0;
for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i)
- if(weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon))
+ if((weapons_stat & WepSet_FromWeapon(weaponorder[i].weapon)) || (weaponorder[i].weapon == complain_weapon))
++weapon_count;
- // add it anyway if weaponcomplain is shown
- if(complain_weapon)
- ++weapon_count;
-
// might as well commit suicide now, no reason to live ;)
if (weapon_count == 0)
{
return;
}
- vector max_panel_size = panel_size - '2 2 0' * panel_bg_padding;
+ vector old_panel_size = panel_size;
+ if(panel_bg_padding)
+ old_panel_size -= '2 2 0' * panel_bg_padding;
- // calculate distribution and size of table cells
- if(max_panel_size.x > max_panel_size.y)
- {
- while(weapon_count > columns * rows)
- {
- ++rows;
- columns = ceil(max_panel_size.x / (max_panel_size.y / rows * aspect));
- }
+ // NOTE: the goal is to use the all-weapons layout and remove unneeded cells
+ // this way weapon icons always have the same size regardless of owned weapon count
- weapon_size_x = max_panel_size.x / columns;
- weapon_size_y = max_panel_size.y / rows;
- columns = ceil(weapon_count / rows);
- }
- else
- {
- while(weapon_count > columns * rows)
- {
- ++columns;
- rows = ceil(max_panel_size.y / (max_panel_size.x / columns / aspect));
- }
+ // get the all-weapons layout
+ rows = HUD_GetRowCount(WEP_COUNT, old_panel_size, aspect);
+ columns = ceil(WEP_COUNT/rows);
+ weapon_size.x = old_panel_size.x / columns;
+ weapon_size.y = old_panel_size.y / rows;
- weapon_size_x = max_panel_size.x / columns;
- weapon_size_y = max_panel_size.y / rows;
- rows = ceil(weapon_count / columns);
- }
+ // reduce rows and columns as needed
+ columns = ceil(weapon_count / rows);
+ rows = ceil(weapon_count / columns);
- // reduce size of the panel
- panel_size_x = columns * weapon_size.x;
- panel_size_y = rows * weapon_size.y;
- panel_pos.x += (max_panel_size.x - panel_size.x) / 2;
- panel_pos.y += (max_panel_size.y - panel_size.y) / 2;
+ // NOTE: although weapons should aways look the same even if onlyowned is disabled,
+ // we enlarge them a bit when possible to better match the desired aspect ratio
+ // as they look much better
+ weapon_size.x = min(old_panel_size.x / columns, aspect * weapon_size.y);
+ weapon_size.y = min(old_panel_size.y / rows, weapon_size.x / aspect);
- panel_size += '2 2 0' * panel_bg_padding;
+ // reduce size of the panel
+ panel_size.x = columns * weapon_size.x;
+ panel_size.y = rows * weapon_size.y;
+ panel_pos.x += (old_panel_size.x - panel_size.x) / 2;
+ panel_pos.y += (old_panel_size.y - panel_size.y) / 2;
+ if(panel_bg_padding)
+ panel_size += '2 2 0' * panel_bg_padding;
}
else
weapon_count = WEP_COUNT;
if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3)
{
f *= f; // for a cooler movement
- center_x = panel_pos.x + panel_size.x/2;
- center_y = panel_pos.y + panel_size.y/2;
+ center.x = panel_pos.x + panel_size.x/2;
+ center.y = panel_pos.y + panel_size.y/2;
screen_ar = vid_conwidth/vid_conheight;
if (center.x/center.y < screen_ar) //bottom left
{
panel_pos.y -= f * (panel_pos.y + panel_size.y);
}
if(f == 1)
- center_x = -1; // mark the panel as off screen
+ center.x = -1; // mark the panel as off screen
}
weaponprevtime = time - (1 - f) * timein_effect_length;
}
{
f *= f; // for a cooler movement
f = 1 - f;
- center_x = panel_pos.x + panel_size.x/2;
- center_y = panel_pos.y + panel_size.y/2;
+ center.x = panel_pos.x + panel_size.x/2;
+ center.y = panel_pos.y + panel_size.y/2;
screen_ar = vid_conwidth/vid_conheight;
if (center.x/center.y < screen_ar) //bottom left
{
// draw the background, then change the virtual size of it to better fit other items inside
HUD_Panel_DrawBg(1);
- if(center_x == -1)
+ if(center.x == -1)
{
draw_endBoldFont();
return;
if(!rows) // if rows is > 0 onlyowned code has already updated these vars
{
- rows = panel_size.y/panel_size.x;
- rows = bound(1, floor((sqrt(4 * aspect * rows * weapon_count + rows * rows) + rows + 0.5) / 2), weapon_count);
+ rows = HUD_GetRowCount(weapon_count, panel_size, aspect);
columns = ceil(weapon_count/rows);
weapon_size = eX * panel_size.x*(1/columns) + eY * panel_size.y*(1/rows);
}
if(weapon_size.x/weapon_size.y > aspect)
{
- barsize_x = aspect * weapon_size.y;
- barsize_y = weapon_size.y;
- baroffset_x = (weapon_size.x - barsize.x) / 2;
+ barsize.x = aspect * weapon_size.y;
+ barsize.y = weapon_size.y;
+ baroffset.x = (weapon_size.x - barsize.x) / 2;
}
else
{
- barsize_y = 1/aspect * weapon_size.x;
- barsize_x = weapon_size.x;
- baroffset_y = (weapon_size.y - barsize.y) / 2;
+ barsize.y = 1/aspect * weapon_size.x;
+ barsize.x = weapon_size.x;
+ baroffset.y = (weapon_size.y - barsize.y) / 2;
}
}
if(autocvar_hud_panel_weapons_accuracy)
// draw the weapon accuracy
if(autocvar_hud_panel_weapons_accuracy)
{
- panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
+ float panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST];
if(panel_weapon_accuracy >= 0)
{
color = Accuracy_GetColor(panel_weapon_accuracy);
// draw ammo status bar
if(autocvar_hud_panel_weapons_ammo && (self.ammo_field != ammo_none))
{
+ float ammo_full;
a = getstati(GetAmmoStat(self.ammo_field)); // how much ammo do we have?
if(a > 0)
// Ammo (#1)
void DrawNadeScoreBar(vector myPos, vector mySize, vector color)
{
-
+
HUD_Panel_DrawProgressBar(
myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize.x,
- autocvar_hud_panel_ammo_progressbar_name,
- getstatf(STAT_NADE_BONUS_SCORE), 0, 0, color,
+ autocvar_hud_panel_ammo_progressbar_name,
+ getstatf(STAT_NADE_BONUS_SCORE), 0, 0, color,
autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
}
{
float theAlpha = 1, a, b;
vector nade_color, picpos, numpos;
-
+
nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE));
-
+
a = getstatf(STAT_NADE_BONUS);
b = getstatf(STAT_NADE_BONUS_SCORE);
-
+
if(autocvar_hud_panel_ammo_iconalign)
{
numpos = myPos;
{
if(autocvar_hud_panel_ammo_text)
drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
-
+
if(draw_expanding)
drawpic_aspect_skin_expanding(picpos, "nade_nbg", '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL, expand_time);
-
+
drawpic_aspect_skin(picpos, "nade_bg" , '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
drawpic_aspect_skin(picpos, "nade_nbg" , '1 1 0' * mySize.y, nade_color, panel_fg_alpha * theAlpha, DRAWFLAG_NORMAL);
}
else
nade_prevstatus = nade_prevframe = nade_statuschange_time = 0;
- rows = mySize.y/mySize.x;
- rows = bound(1, floor((sqrt(4 * (3/1) * rows * (total_ammo_count) + rows * rows) + rows + 0.5) / 2), (total_ammo_count));
- // ^^^ ammo item aspect goes here
-
+ rows = HUD_GetRowCount(total_ammo_count, mySize, 3);
columns = ceil((total_ammo_count)/rows);
-
ammo_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
-
vector offset = '0 0 0'; // fteqcc sucks
float newSize;
if(ammo_size.x/ammo_size.y > 3)
{
newSize = 3 * ammo_size.y;
- offset_x = ammo_size.x - newSize;
+ offset.x = ammo_size.x - newSize;
pos.x += offset.x/2;
- ammo_size_x = newSize;
+ ammo_size.x = newSize;
}
else
{
newSize = 1/3 * ammo_size.x;
- offset_y = ammo_size.y - newSize;
+ offset.y = ammo_size.y - newSize;
pos.y += offset.y/2;
- ammo_size_y = newSize;
+ ammo_size.y = newSize;
}
float i;
{
if(mySize.y/mySize.x > 2)
{
- newSize_y = 2 * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 2 * mySize.x;
+ newSize.x = mySize.x;
- newPos_y = myPos.y + (mySize.y - newSize.y) / 2;
- newPos_x = myPos.x;
+ newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+ newPos.x = myPos.x;
}
else
{
- newSize_x = 1/2 * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = 1/2 * mySize.y;
+ newSize.y = mySize.y;
- newPos_x = myPos.x + (mySize.x - newSize.x) / 2;
- newPos_y = myPos.y;
+ newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+ newPos.y = myPos.y;
}
if(icon_right_align)
if(mySize.x/mySize.y > 3)
{
- newSize_x = 3 * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = 3 * mySize.y;
+ newSize.y = mySize.y;
- newPos_x = myPos.x + (mySize.x - newSize.x) / 2;
- newPos_y = myPos.y;
+ newPos.x = myPos.x + (mySize.x - newSize.x) / 2;
+ newPos.y = myPos.y;
}
else
{
- newSize_y = 1/3 * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 1/3 * mySize.x;
+ newSize.x = mySize.x;
- newPos_y = myPos.y + (mySize.y - newSize.y) / 2;
- newPos_x = myPos.x;
+ newPos.y = myPos.y + (mySize.y - newSize.y) / 2;
+ newPos.x = myPos.x;
}
if(icon_right_align) // right align
if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
{
mySize.x *= (1.0 / 3.0);
- superweapons_offset_x = mySize.x;
+ superweapons_offset.x = mySize.x;
if (autocvar_hud_panel_powerups_flip)
- shield_offset_x = 2*mySize.x;
+ shield_offset.x = 2*mySize.x;
else
- strength_offset_x = 2*mySize.x;
+ strength_offset.x = 2*mySize.x;
}
else
{
mySize.y *= (1.0 / 3.0);
- superweapons_offset_y = mySize.y;
+ superweapons_offset.y = mySize.y;
if (autocvar_hud_panel_powerups_flip)
- shield_offset_y = 2*mySize.y;
+ shield_offset.y = 2*mySize.y;
else
- strength_offset_y = 2*mySize.y;
+ strength_offset.y = 2*mySize.y;
}
}
else
{
mySize.x *= 0.5;
if (autocvar_hud_panel_powerups_flip)
- shield_offset_x = mySize.x;
+ shield_offset.x = mySize.x;
else
- strength_offset_x = mySize.x;
+ strength_offset.x = mySize.x;
}
else
{
mySize.y *= 0.5;
if (autocvar_hud_panel_powerups_flip)
- shield_offset_y = mySize.y;
+ shield_offset.y = mySize.y;
else
- strength_offset_y = mySize.y;
+ strength_offset.y = mySize.y;
}
}
{
mySize.x *= 0.5;
if (autocvar_hud_panel_healtharmor_flip)
- health_offset_x = mySize.x;
+ health_offset.x = mySize.x;
else
- armor_offset_x = mySize.x;
+ armor_offset.x = mySize.x;
}
else
{
mySize.y *= 0.5;
if (autocvar_hud_panel_healtharmor_flip)
- health_offset_y = mySize.y;
+ health_offset.y = mySize.y;
else
- armor_offset_y = mySize.y;
+ armor_offset.y = mySize.y;
}
float health_baralign, armor_baralign, fuel_baralign;
if (hud_panel_radar_maximized && !autocvar__hud_configure)
{
panel_size = autocvar_hud_panel_radar_maximized_size;
- panel_size_x = bound(0.2, panel_size.x, 1) * vid_conwidth;
- panel_size_y = bound(0.2, panel_size.y, 1) * vid_conheight;
- panel_pos_x = (vid_conwidth - panel_size.x) / 2;
- panel_pos_y = (vid_conheight - panel_size.y) / 2;
+ panel_size.x = bound(0.2, panel_size.x, 1) * vid_conwidth;
+ panel_size.y = bound(0.2, panel_size.y, 1) * vid_conheight;
+ panel_pos.x = (vid_conwidth - panel_size.x) / 2;
+ panel_pos.y = (vid_conheight - panel_size.y) / 2;
string panel_bg;
panel_bg = strcat(hud_skin_path, "/border_default"); // always use the default border when maximized
c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
span = '0 0 0';
- span_x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
- span_y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
+ span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
+ span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
// max-min distance must fit the radar in x=x, y=y
bigsize = min(
}
if(spectatee_status == -1)
{
- rows = mySize.y/mySize.x;
- rows = bound(1, floor((sqrt(4 * (3/1) * rows * team_count + rows * rows) + rows + 0.5) / 2), team_count);
- // ^^^ ammo item aspect goes here
-
+ rows = HUD_GetRowCount(team_count, mySize, 3);
columns = ceil(team_count/rows);
-
score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
float newSize;
if(score_size.x/score_size.y > 3)
{
newSize = 3 * score_size.y;
- offset_x = score_size.x - newSize;
+ offset.x = score_size.x - newSize;
pos.x += offset.x/2;
- score_size_x = newSize;
+ score_size.x = newSize;
}
else
{
newSize = 1/3 * score_size.x;
- offset_y = score_size.y - newSize;
+ offset.y = score_size.y - newSize;
pos.y += offset.y/2;
- score_size_y = newSize;
+ score_size.y = newSize;
}
}
else
vector newSize = '0 0 0';
if(mySize.x/mySize.y > 4)
{
- newSize_x = 4 * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = 4 * mySize.y;
+ newSize.y = mySize.y;
- pos_x = pos.x + (mySize.x - newSize.x) / 2;
+ pos.x = pos.x + (mySize.x - newSize.x) / 2;
}
else
{
- newSize_y = 1/4 * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 1/4 * mySize.x;
+ newSize.x = mySize.x;
- pos_y = pos.y + (mySize.y - newSize.y) / 2;
+ pos.y = pos.y + (mySize.y - newSize.y) / 2;
}
mySize = newSize;
vector newSize = '0 0 0';
if(mySize.x/mySize.y > 3)
{
- newSize_x = 3 * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = 3 * mySize.y;
+ newSize.y = mySize.y;
- pos_x = pos.x + (mySize.x - newSize.x) / 2;
+ pos.x = pos.x + (mySize.x - newSize.x) / 2;
}
else
{
- newSize_y = 1/3 * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 1/3 * mySize.x;
+ newSize.x = mySize.x;
- pos_y = pos.y + (mySize.y - newSize.y) / 2;
+ pos.y = pos.y + (mySize.y - newSize.y) / 2;
}
mySize = newSize;
if(mySize.x/mySize.y > aspect_ratio)
{
i = aspect_ratio * mySize.y;
- myPos_x = myPos.x + (mySize.x - i) / 2;
- mySize_x = i;
+ myPos.x = myPos.x + (mySize.x - i) / 2;
+ mySize.x = i;
}
else
{
i = 1/aspect_ratio * mySize.x;
- myPos_y = myPos.y + (mySize.y - i) / 2;
- mySize_y = i;
+ myPos.y = myPos.y + (mySize.y - i) / 2;
+ mySize.y = i;
}
if(layout)
else //if(gametype == MAPINFO_TYPE_FREEZETAG)
layout = autocvar_hud_panel_modicons_freezetag_layout;
float rows, columns, aspect_ratio;
- rows = mySize.y/mySize.x;
aspect_ratio = (layout) ? 2 : 1;
- rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
+ rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
columns = ceil(team_count/rows);
int i;
if(mySize.x/mySize.y > aspect_ratio)
{
i = aspect_ratio * mySize.y;
- myPos_x = myPos.x + (mySize.x - i) / 2;
- mySize_x = i;
+ myPos.x = myPos.x + (mySize.x - i) / 2;
+ mySize.x = i;
}
else
{
i = 1/aspect_ratio * mySize.x;
- myPos_y = myPos.y + (mySize.y - i) / 2;
- mySize_y = i;
+ myPos.y = myPos.y + (mySize.y - i) / 2;
+ mySize.y = i;
}
if (layout) // show text too
int layout = autocvar_hud_panel_modicons_dom_layout;
float rows, columns, aspect_ratio;
- rows = mySize.y/mySize.x;
aspect_ratio = (layout) ? 3 : 1;
- rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count);
+ rows = HUD_GetRowCount(team_count, mySize, aspect_ratio);
columns = ceil(team_count/rows);
int i;
vector newSize = '0 0 0';
if(mySize.x/mySize.y > aspect)
{
- newSize_x = aspect * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = aspect * mySize.y;
+ newSize.y = mySize.y;
- pos_x = pos.x + (mySize.x - newSize.x) / 2;
+ pos.x = pos.x + (mySize.x - newSize.x) / 2;
}
else
{
- newSize_y = 1/aspect * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 1/aspect * mySize.x;
+ newSize.x = mySize.x;
- pos_y = pos.y + (mySize.y - newSize.y) / 2;
+ pos.y = pos.y + (mySize.y - newSize.y) / 2;
}
mySize = newSize;
}
if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
{
- panel_pos_y = panel_bg_border;
- panel_size_y = vid_conheight - panel_bg_border * 2;
+ panel_pos.y = panel_bg_border;
+ panel_size.y = vid_conheight - panel_bg_border * 2;
if(panel.current_panel_bg == "0") // force a border when maximized
{
string panel_bg;
// Info messages panel (#14)
//
-#define drawInfoMessage(s)\
- if(autocvar_hud_panel_infomessages_flip)\
- o_x = pos.x + mySize.x - stringwidth(s, true, fontsize);\
- drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
- o.y += fontsize.y;
+#define drawInfoMessage(s) do { \
+ if(autocvar_hud_panel_infomessages_flip) \
+ o.x = pos.x + mySize.x - stringwidth(s, true, fontsize); \
+ drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); \
+ o.y += fontsize.y; \
+} while(0)
void HUD_InfoMessages(void)
{
if(!autocvar__hud_configure)
vector newSize = '0 0 0';
if(mySize.x/mySize.y > 5)
{
- newSize_x = 5 * mySize.y;
- newSize_y = mySize.y;
+ newSize.x = 5 * mySize.y;
+ newSize.y = mySize.y;
- pos_x = pos.x + (mySize.x - newSize.x) / 2;
+ pos.x = pos.x + (mySize.x - newSize.x) / 2;
}
else
{
- newSize_y = 1/5 * mySize.x;
- newSize_x = mySize.x;
+ newSize.y = 1/5 * mySize.x;
+ newSize.x = mySize.x;
- pos_y = pos.y + (mySize.y - newSize.y) / 2;
+ pos.y = pos.y + (mySize.y - newSize.y) / 2;
}
mySize = newSize;
s = _("^1Observing");
else
s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(spectatee_status == -1)
s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey("primary fire", "+fire"));
else
s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(spectatee_status == -1)
s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey("next weapon", "weapnext"), getcommandkey("previous weapon", "weapprev"));
else
s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
if(gametype == MAPINFO_TYPE_LMS)
{
}
else
s = sprintf(_("^1Press ^3%s^1 to join"), getcommandkey("jump", "+jump"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
//show restart countdown:
if (time < getstatf(STAT_GAMESTARTTIME)) {
if(warmup_stage && !intermission)
{
s = _("^2Currently in ^1warmup^2 stage!");
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
string blinkcolor;
else
s = _("^2Waiting for others to ready up...");
}
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
else if(warmup_stage && !intermission && !spectatee_status)
{
s = sprintf(_("^2Press ^3%s^2 to end warmup"), getcommandkey("ready", "ready"));
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
if(teamplay && !intermission && !spectatee_status && gametype != MAPINFO_TYPE_CA && teamnagger)
tm = teams.sort_next;
if (tm)
{
- for(0; tm.sort_next; tm = tm.sort_next)
+ for (; tm.sort_next; tm = tm.sort_next)
{
if(!tm.team_size || tm.team == NUM_SPECTATOR)
continue;
if (tm.team != NUM_SPECTATOR)
if (tm.team_size == ts_max)
s = strcat(s, sprintf(_(" Press ^3%s%s to adjust"), getcommandkey("team menu", "menu_showteamselect"), blinkcolor));
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
}
}
else
{
s = _("^7Press ^3ESC ^7to show HUD options.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3Doubleclick ^7a panel for panel-specific options.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3CTRL ^7to disable collision testing, ^3SHIFT ^7and");
- drawInfoMessage(s)
+ drawInfoMessage(s);
s = _("^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.");
- drawInfoMessage(s)
+ drawInfoMessage(s);
}
}
{
panel_size.x *= 0.5;
if (autocvar_hud_panel_physics_flip)
- speed_offset_x = panel_size.x;
+ speed_offset.x = panel_size.x;
else
- acceleration_offset_x = panel_size.x;
+ acceleration_offset.x = panel_size.x;
}
else
{
panel_size.y *= 0.5;
if (autocvar_hud_panel_physics_flip)
- speed_offset_y = panel_size.y;
+ speed_offset.y = panel_size.y;
else
- acceleration_offset_y = panel_size.y;
+ acceleration_offset.y = panel_size.y;
}
float speed_baralign, acceleration_baralign;
if (autocvar_hud_panel_physics_baralign == 1)
vector tmp_offset = '0 0 0', tmp_size = '0 0 0';
if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 2)
{
- tmp_size_x = panel_size.x * 0.75;
- tmp_size_y = panel_size.y * text_scale;
+ tmp_size.x = panel_size.x * 0.75;
+ tmp_size.y = panel_size.y * text_scale;
if (speed_baralign)
- tmp_offset_x = panel_size.x - tmp_size.x;
+ tmp_offset.x = panel_size.x - tmp_size.x;
//else
//tmp_offset_x = 0;
- tmp_offset_y = (panel_size.y - tmp_size.y) / 2;
+ tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
drawstring_aspect(panel_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;
+ tmp_offset.x = 0;
else
- tmp_offset_x = tmp_size.x;
+ tmp_offset.x = tmp_size.x;
if (autocvar_hud_panel_physics_speed_unit_show)
{
//tmp_offset_y = 0;
- tmp_size_x = panel_size.x * (1 - 0.75);
- tmp_size_y = panel_size.y * 0.4 * text_scale;
- tmp_offset_y = (panel_size.y * 0.4 - tmp_size.y) / 2;
+ tmp_size.x = panel_size.x * (1 - 0.75);
+ tmp_size.y = panel_size.y * 0.4 * text_scale;
+ tmp_offset.y = (panel_size.y * 0.4 - tmp_size.y) / 2;
drawstring_aspect(panel_pos + speed_offset + tmp_offset, unit, tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
}
}
peak_offsetX = (1 - min(top_speed, max_speed)/max_speed) * panel_size.x;
else // if (speed_baralign == 2)
peak_offsetX = min(top_speed, max_speed)/max_speed * panel_size.x * 0.5;
- peak_size_x = floor(panel_size.x * 0.01 + 1.5);
- peak_size_y = panel_size.y;
+ peak_size.x = floor(panel_size.x * 0.01 + 1.5);
+ peak_size.y = panel_size.y;
if (speed_baralign == 2) // draw two peaks, on both sides
{
drawfill(panel_pos + speed_offset + eX * (0.5 * panel_size.x + peak_offsetX - peak_size.x), peak_size, autocvar_hud_progressbar_speed_color, f * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
}
//top speed
- tmp_offset_y = panel_size.y * 0.4;
- tmp_size_x = panel_size.x * (1 - 0.75);
- tmp_size_y = (panel_size.y - tmp_offset.y) * text_scale;
+ tmp_offset.y = panel_size.y * 0.4;
+ tmp_size.x = panel_size.x * (1 - 0.75);
+ tmp_size.y = (panel_size.y - tmp_offset.y) * text_scale;
tmp_offset.y += (panel_size.y - tmp_offset.y - tmp_size.y) / 2;
drawstring_aspect(panel_pos + speed_offset + tmp_offset, ftos(top_speed), tmp_size, '1 0 0', f * panel_fg_alpha, DRAWFLAG_NORMAL);
}
tmp_size = acceleration_progressbar_scale * panel_size.x * eX + panel_size.y * eY;
if (acceleration_baralign == 1)
- tmp_offset_x = panel_size.x - tmp_size.x;
+ tmp_offset.x = panel_size.x - tmp_size.x;
else if (acceleration_baralign == 2 || acceleration_baralign == 3)
- tmp_offset_x = (panel_size.x - tmp_size.x) / 2;
+ tmp_offset.x = (panel_size.x - tmp_size.x) / 2;
else
- tmp_offset_x = 0;
- tmp_offset_y = 0;
+ tmp_offset.x = 0;
+ tmp_offset.y = 0;
}
else
{
HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset + tmp_offset, tmp_size, "accelbar", f, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
}
- tmp_size_x = panel_size.x;
- tmp_size_y = panel_size.y * text_scale;
- tmp_offset_x = 0;
- tmp_offset_y = (panel_size.y - tmp_size.y) / 2;
+ tmp_size.x = panel_size.x;
+ tmp_size.y = panel_size.y * text_scale;
+ tmp_offset.x = 0;
+ tmp_offset.y = (panel_size.y - tmp_size.y) / 2;
if (autocvar_hud_panel_physics_text == 1 || autocvar_hud_panel_physics_text == 3)
drawstring_aspect(panel_pos + acceleration_offset + tmp_offset, strcat(ftos_decimals(acceleration, 2), "g"), tmp_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
if(target_pos.y > panel_pos.y)
{
panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
- panel_size_y = min(panel_size.y, vid_conheight - scoreboard_bottom);
+ panel_size.y = min(panel_size.y, vid_conheight - scoreboard_bottom);
}
}
if (ts != "")
{
if (align)
- pos_x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
+ pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
if (a > 0.5/255.0) // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
pos.y += fontsize.y;
msg_size = pos.y - msg_size;
if (autocvar_hud_panel_centerprint_flip)
{
- pos_y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
+ pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
{
buffs = Buff_Type_first.items; // force first buff
}
-
+
float b = 0; // counter to tell other functions that we have buffs
entity e;
string s = "";
//float is_vertical = (panel_ar < 1);
//float buff_iconalign = autocvar_hud_panel_buffs_iconalign;
vector buff_offset = '0 0 0';
-
+
for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items)
{
//DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1);