X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=2aaa81bd512e48e56b4dadbc1e00d1244d8d52cc;hp=528b0f19aa76b383075bf2473a15057952c0e58c;hb=e921ae9f86a09d0a20cd4c72b44e6d71d25975ea;hpb=35e8f712933b0ebf9b163b7289cf975825b33803 diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 528b0f19aa..2aaa81bd51 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1,27 +1,10 @@ -#if defined(CSQC) - #include "../dpdefs/csprogsdefs.qh" - #include "defs.qh" - #include "../common/constants.qh" - #include "../common/stats.qh" - #include "../warpzonelib/mathlib.qh" - #include "../common/teams.qh" - #include "../common/util.qh" - #include "../common/nades.qh" - #include "../common/buffs.qh" - #include "../common/counting.qh" - #include "../common/weapons/weapons.qh" - #include "../common/mapinfo.qh" - #include "autocvars.qh" - #include "../common/deathtypes.qh" - #include "teamradar.qh" - #include "hud.qh" - #include "scoreboard.qh" - #include "main.qh" - #include "../csqcmodellib/cl_player.qh" - #include "../server/t_items.qh" -#elif defined(MENUQC) -#elif defined(SVQC) -#endif +#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" /* ================== @@ -44,7 +27,7 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the 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); @@ -117,46 +100,92 @@ vector HUD_Get_Num_Color (float x, float maxvalue) 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); +} + +vector HUD_GetTableSize(float item_count, vector psize, float item_aspect) +{ + float columns, rows; + float ratio, best_ratio = 0; + float best_columns = 1, best_rows = 1; + bool vertical = (psize.x / psize.y >= item_aspect); + if(vertical) + { + psize = eX * psize.y + eY * psize.x; + item_aspect = 1 / item_aspect; + } + + rows = ceil(sqrt(item_count)); + columns = ceil(item_count/rows); + while(columns >= 1) + { + ratio = (psize.x/columns) / (psize.y/rows); + if(ratio > item_aspect) + ratio = item_aspect * item_aspect / ratio; + + if(ratio <= best_ratio) + break; // ratio starts decreasing by now, skip next configurations + + best_columns = columns; + best_rows = rows; + best_ratio = ratio; + + if(columns == 1) + break; + + --columns; + rows = ceil(item_count/columns); + } + + if(vertical) + return eX * best_rows + eY * best_columns; + else + return eX * best_columns + eY * best_rows; +} + float stringwidth_colors(string s, vector theSize) { return stringwidth(s, true, theSize); @@ -175,7 +204,7 @@ void drawstringright(vector position, string text, vector theScale, vector rgb, 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); } @@ -257,7 +286,7 @@ float race_CheckName(string net_name) { return 0; } -float GetPlayerColorForce(float i) +float GetPlayerColorForce(int i) { if(!teamplay) return 0; @@ -265,7 +294,7 @@ float GetPlayerColorForce(float i) return stof(getplayerkeyvalue(i, "colors")) & 15; } -float GetPlayerColor(float i) +float GetPlayerColor(int i) { if(!playerslots[i].gotscores) // unconnected return NUM_SPECTATOR; @@ -275,7 +304,7 @@ float GetPlayerColor(float i) return GetPlayerColorForce(i); } -string GetPlayerName(float i) +string GetPlayerName(int i) { return ColorTranslateRGB(getplayerkeyvalue(i, "name")); } @@ -417,10 +446,9 @@ void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float theA // 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; } @@ -443,15 +471,13 @@ void HUD_Weapons(void) vector center = '0 0 0'; float weapon_count, weapon_id; float row, column, rows = 0, columns = 0; + bool vertical_order = true; 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; @@ -485,7 +511,7 @@ void HUD_Weapons(void) // 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) @@ -515,15 +541,29 @@ void HUD_Weapons(void) 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); + + #if 0 + /// debug code + if(cvar("wep_add")) + { + weapons_stat = '0 0 0'; + float countw = 1 + floor((floor(time * cvar("wep_add"))) % WEP_COUNT); + for(i = WEP_FIRST; i <= countw; ++i) + weapons_stat |= WepSet_FromWeapon(i); + } + #endif + } + // 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 } @@ -531,12 +571,9 @@ void HUD_Weapons(void) // 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) @@ -545,41 +582,63 @@ void HUD_Weapons(void) return; } - vector max_panel_size = panel_size - '2 2 0' * panel_bg_padding; + vector old_panel_size = panel_size; + vector padded_panel_size = 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)); - } + // get the all-weapons layout + vector table_size = HUD_GetTableSize(WEP_COUNT, padded_panel_size, aspect); + columns = table_size.x; + rows = table_size.y; + weapon_size.x = padded_panel_size.x / columns; + weapon_size.y = padded_panel_size.y / rows; - weapon_size_x = max_panel_size.x / columns; - weapon_size_y = max_panel_size.y / rows; - columns = ceil(weapon_count / rows); + // NOTE: although weapons should aways look the same even if onlyowned is enabled, + // we enlarge them a bit when possible to better match the desired aspect ratio + if(padded_panel_size.x / padded_panel_size.y < aspect) + { + // maximum number of rows that allows to display items with the desired aspect ratio + float max_rows = floor(padded_panel_size.y / (weapon_size.x / aspect)); + columns = min(columns, ceil(weapon_count / max_rows)); + rows = ceil(weapon_count / columns); + weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect); + weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y); + vertical_order = false; } else { - while(weapon_count > columns * rows) - { - ++columns; - rows = ceil(max_panel_size.y / (max_panel_size.x / columns / aspect)); - } - - weapon_size_x = max_panel_size.x / columns; - weapon_size_y = max_panel_size.y / rows; - rows = ceil(weapon_count / columns); + float max_columns = floor(padded_panel_size.x / (weapon_size.y * aspect)); + rows = min(rows, ceil(weapon_count / max_columns)); + columns = ceil(weapon_count / rows); + weapon_size.x = min(padded_panel_size.x / columns, aspect * weapon_size.y); + weapon_size.y = min(padded_panel_size.y / rows, weapon_size.x / aspect); + vertical_order = true; } // 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; - + panel_size.x = columns * weapon_size.x; + panel_size.y = rows * weapon_size.y; panel_size += '2 2 0' * panel_bg_padding; + + // center the resized panel, or snap it to the screen edge when close enough + if(panel_pos.x > vid_conwidth * 0.001) + { + if(panel_pos.x + old_panel_size.x > vid_conwidth * 0.999) + panel_pos.x += old_panel_size.x - panel_size.x; + else + panel_pos.x += (old_panel_size.x - panel_size.x) / 2; + } + else if(old_panel_size.x > vid_conwidth * 0.999) + panel_pos.x += (old_panel_size.x - panel_size.x) / 2; + + if(panel_pos.y > vid_conheight * 0.001) + { + if(panel_pos.y + old_panel_size.y > vid_conheight * 0.999) + panel_pos.y += old_panel_size.y - panel_size.y; + else + panel_pos.y += (old_panel_size.y - panel_size.y) / 2; + } + else if(old_panel_size.y > vid_conheight * 0.999) + panel_pos.y += (old_panel_size.y - panel_size.y) / 2; } else weapon_count = WEP_COUNT; @@ -607,8 +666,8 @@ void HUD_Weapons(void) 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 { @@ -625,7 +684,7 @@ void HUD_Weapons(void) 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; } @@ -650,8 +709,8 @@ void HUD_Weapons(void) { 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 { @@ -674,7 +733,7 @@ void HUD_Weapons(void) // 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; @@ -690,10 +749,12 @@ void HUD_Weapons(void) 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); - columns = ceil(weapon_count/rows); - weapon_size = eX * panel_size.x*(1/columns) + eY * panel_size.y*(1/rows); + vector table_size = HUD_GetTableSize(WEP_COUNT, panel_size, aspect); + columns = table_size.x; + rows = table_size.y; + weapon_size.x = panel_size.x / columns; + weapon_size.y = panel_size.y / rows; + vertical_order = (panel_size.x / panel_size.y >= aspect); } // calculate position/size for visual bar displaying ammount of ammo status @@ -704,15 +765,15 @@ void HUD_Weapons(void) 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) @@ -747,7 +808,7 @@ void HUD_Weapons(void) // 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); @@ -783,6 +844,7 @@ void HUD_Weapons(void) // 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) @@ -849,12 +911,33 @@ void HUD_Weapons(void) drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } + #if 0 + /// debug code + if(!autocvar_hud_panel_weapons_onlyowned) + { + drawfill(weapon_pos + '1 1 0', weapon_size - '2 2 0', '1 1 1', panel_fg_alpha * 0.2, DRAWFLAG_NORMAL); + drawstring(weapon_pos, ftos(i + 1), label_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + } + #endif + // continue with new position for the next weapon - ++row; - if(row >= rows) + if(vertical_order) { - row = 0; ++column; + if(column >= columns) + { + column = 0; + ++row; + } + } + else + { + ++row; + if(row >= rows) + { + row = 0; + ++column; + } } } @@ -864,12 +947,12 @@ void HUD_Weapons(void) // 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); } @@ -878,12 +961,12 @@ void DrawAmmoNades(vector myPos, vector mySize, float draw_expanding, float expa { 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; @@ -901,10 +984,10 @@ void DrawAmmoNades(vector myPos, vector mySize, float draw_expanding, float expa { 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); } @@ -1033,30 +1116,25 @@ void HUD_Ammo(void) 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; @@ -1131,19 +1209,19 @@ void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, fl { 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) @@ -1169,19 +1247,19 @@ void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, fl 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 @@ -1281,20 +1359,20 @@ void HUD_Powerups(void) 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 @@ -1303,17 +1381,17 @@ void HUD_Powerups(void) { 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; } } @@ -1527,17 +1605,17 @@ void HUD_HealthArmor(void) { 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; @@ -1928,10 +2006,10 @@ void HUD_Radar(void) 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 @@ -2042,8 +2120,8 @@ void HUD_Radar(void) 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( @@ -2327,28 +2405,24 @@ void HUD_Score(void) } 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 @@ -2426,17 +2500,17 @@ void HUD_RaceTimer (void) 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; @@ -2634,17 +2708,17 @@ void HUD_Vote(void) 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; @@ -2730,14 +2804,14 @@ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, int layout, flo 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) @@ -2760,9 +2834,8 @@ void HUD_Mod_CA(vector myPos, vector mySize) 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; @@ -3320,14 +3393,14 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, int layout, fl 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 @@ -3356,9 +3429,8 @@ void HUD_Mod_Dom(vector myPos, vector mySize) 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; @@ -3468,17 +3540,17 @@ void HUD_PressedKeys(void) 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; } @@ -3531,8 +3603,8 @@ void HUD_Chat(void) 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; @@ -3652,7 +3724,7 @@ void HUD_EngineInfo(void) // #define drawInfoMessage(s) do { \ if(autocvar_hud_panel_infomessages_flip) \ - o_x = pos.x + mySize.x - stringwidth(s, true, fontsize); \ + o.x = pos.x + mySize.x - stringwidth(s, true, fontsize); \ drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL); \ o.y += fontsize.y; \ } while(0) @@ -3679,17 +3751,17 @@ void HUD_InfoMessages(void) 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; @@ -3761,6 +3833,25 @@ void HUD_InfoMessages(void) drawInfoMessage(s); } + if(autocvar_cl_showspectators) + if(num_spectators) + //if(spectatee_status != -1) + { + s = ((spectatee_status) ? _("^1Spectating this player:") : _("^1Spectating you:")); + //drawInfoMessage(s) + float limit = min(num_spectators, MAX_SPECTATORS); + float i; + for(i = 0; i < limit; ++i) + { + float slot = spectatorlist[i]; + if(i == 0) + s = strcat(s, " ^3", GetPlayerName(slot)); + else + s = strcat("^3", GetPlayerName(slot)); + drawInfoMessage(s); + } + } + string blinkcolor; if(time % 1 >= 0.5) blinkcolor = "^1"; @@ -3797,7 +3888,7 @@ void HUD_InfoMessages(void) 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; @@ -3934,17 +4025,17 @@ void HUD_Physics(void) { 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) @@ -3971,26 +4062,26 @@ void HUD_Physics(void) 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); } } @@ -4034,8 +4125,8 @@ void HUD_Physics(void) 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); @@ -4046,9 +4137,9 @@ void HUD_Physics(void) } //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); } @@ -4075,12 +4166,12 @@ void HUD_Physics(void) 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 { @@ -4090,10 +4181,10 @@ void HUD_Physics(void) 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); @@ -4214,12 +4305,12 @@ void HUD_CenterPrint (void) { if(!autocvar_hud_panel_centerprint) return; - if (hud_configure_prev && hud_configure_prev != -1) + if(hud_configure_prev) reset_centerprint_messages(); } else { - if (!hud_configure_prev) + if(!hud_configure_prev) reset_centerprint_messages(); if (time > hud_configure_cp_generation_time) { @@ -4258,7 +4349,7 @@ void HUD_CenterPrint (void) 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); } } @@ -4373,7 +4464,7 @@ void HUD_CenterPrint (void) 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; @@ -4388,7 +4479,7 @@ void HUD_CenterPrint (void) 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)); @@ -4435,7 +4526,7 @@ void HUD_Buffs(void) { buffs = Buff_Type_first.items; // force first buff } - + float b = 0; // counter to tell other functions that we have buffs entity e; string s = ""; @@ -4468,7 +4559,7 @@ void HUD_Buffs(void) //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);