X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=1626901db43ac8a6743464b184bea2031cd6ca3d;hb=fcf4579b494a225ae17c64ccb3acf802c841245c;hp=33158820050a2d46ed4e50fd03f592fc0fc7dac0;hpb=5733b1493c8c3fc14830f78122fe388e89f19338;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 331588200..1626901db 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -162,7 +162,7 @@ float HUD_GetRowCount(int item_count, vector size, float item_aspect) return bound(1, floor((sqrt(4 * item_aspect * aspect * item_count + aspect * aspect) + aspect + 0.5) / 2), item_count); } -vector HUD_GetTableSize(int item_count, vector psize, float item_aspect) +vector HUD_GetTableSize_BestItemAR(int item_count, vector psize, float item_aspect) { float columns, rows; float ratio, best_ratio = 0; @@ -507,7 +507,8 @@ void HUD_Weapons(void) vector color; // check to see if we want to continue - if(hud != HUD_NORMAL) { return; } + if(intermission == 2) return; + if(hud != HUD_NORMAL) return; if(!autocvar__hud_configure) { @@ -524,8 +525,6 @@ void HUD_Weapons(void) // update generic hud functions HUD_Panel_UpdateCvars(); - draw_beginBoldFont(); - // figure out weapon order (how the weapons are sorted) // TODO make this configurable if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0]) { @@ -595,16 +594,13 @@ void HUD_Weapons(void) // might as well commit suicide now, no reason to live ;) if (weapon_count == 0) - { - draw_endBoldFont(); return; - } vector old_panel_size = panel_size; vector padded_panel_size = panel_size - '2 2 0' * panel_bg_padding; // get the all-weapons layout - vector table_size = HUD_GetTableSize(WEP_COUNT, padded_panel_size, aspect); + vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, padded_panel_size, aspect); columns = table_size.x; rows = table_size.y; weapon_size.x = padded_panel_size.x / columns; @@ -752,10 +748,7 @@ void HUD_Weapons(void) HUD_Panel_DrawBg(1); if(center.x == -1) - { - draw_endBoldFont(); return; - } if(panel_bg_padding) { @@ -767,7 +760,7 @@ void HUD_Weapons(void) if(!rows) // if rows is > 0 onlyowned code has already updated these vars { - vector table_size = HUD_GetTableSize(WEP_COUNT, panel_size, aspect); + vector table_size = HUD_GetTableSize_BestItemAR(WEP_COUNT, panel_size, aspect); columns = table_size.x; rows = table_size.y; weapon_size.x = panel_size.x / columns; @@ -800,11 +793,17 @@ void HUD_Weapons(void) // draw items row = column = 0; vector label_size = '1 1 0' * min(weapon_size.x, weapon_size.y) * bound(0, autocvar_hud_panel_weapons_label_scale, 1); + vector noncurrent_pos = '0 0 0'; + vector noncurrent_size = weapon_size * bound(0, autocvar_hud_panel_weapons_noncurrent_scale, 1); + float noncurrent_alpha = panel_fg_alpha * bound(0, autocvar_hud_panel_weapons_noncurrent_alpha, 1); + bool isCurrent; + for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i) { // retrieve information about the current weapon to be drawn self = weaponorder[i]; weapon_id = self.impulse; + isCurrent = (self.weapon == switchweapon); // skip if this weapon doesn't exist if(!self || weapon_id < 0) { continue; } @@ -815,12 +814,12 @@ void HUD_Weapons(void) continue; // figure out the drawing position of weapon - weapon_pos = (panel_pos - + eX * column * weapon_size.x - + eY * row * weapon_size.y); + weapon_pos = (panel_pos + eX * column * weapon_size.x + eY * row * weapon_size.y); + noncurrent_pos.x = weapon_pos.x + (weapon_size.x - noncurrent_size.x) / 2; + noncurrent_pos.y = weapon_pos.y + (weapon_size.y - noncurrent_size.y) / 2; // draw background behind currently selected weapon - if(self.weapon == switchweapon) + if(isCurrent) drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); // draw the weapon accuracy @@ -838,7 +837,10 @@ void HUD_Weapons(void) if(weapons_stat & WepSet_FromWeapon(self.weapon)) { // draw the weapon image - drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + if(isCurrent) + drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + else + drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '1 1 1', noncurrent_alpha, DRAWFLAG_NORMAL); // draw weapon label string switch(autocvar_hud_panel_weapons_label) @@ -900,7 +902,7 @@ void HUD_Weapons(void) } else // draw a "ghost weapon icon" if you don't have the weapon { - drawpic_aspect_skin(weapon_pos, self.model2, weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); + drawpic_aspect_skin(noncurrent_pos, self.model2, noncurrent_size, '0.2 0.2 0.2', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); } // draw the complain message @@ -958,56 +960,51 @@ void HUD_Weapons(void) } } } - - draw_endBoldFont(); } // Ammo (#1) -void DrawNadeScoreBar(vector myPos, vector mySize, vector color) +void DrawNadeProgressBar(vector myPos, vector mySize, float progress, 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, + progress, 0, 0, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } void DrawAmmoNades(vector myPos, vector mySize, bool draw_expanding, float expand_time) { - float theAlpha = 1, a, b; - vector nade_color, picpos, numpos; - - nade_color = Nade_Color(getstati(STAT_NADE_BONUS_TYPE)); + float bonusNades = getstatf(STAT_NADE_BONUS); + float bonusProgress = getstatf(STAT_NADE_BONUS_SCORE); + float bonusType = getstati(STAT_NADE_BONUS_TYPE); + vector nadeColor = NADES[bonusType].m_color; + string nadeIcon = NADES[bonusType].m_icon; - a = getstatf(STAT_NADE_BONUS); - b = getstatf(STAT_NADE_BONUS_SCORE); + vector iconPos, textPos; if(autocvar_hud_panel_ammo_iconalign) { - numpos = myPos; - picpos = myPos + eX * 2 * mySize.y; + iconPos = myPos + eX * 2 * mySize.y; + textPos = myPos; } else { - numpos = myPos + eX * mySize.y; - picpos = myPos; + iconPos = myPos; + textPos = myPos + eX * mySize.y; } - DrawNadeScoreBar(myPos, mySize, nade_color); - - if(b > 0 || a > 0) + if(bonusNades > 0 || bonusProgress > 0) { + DrawNadeProgressBar(myPos, mySize, bonusProgress, nadeColor); + 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); + drawstring_aspect(textPos, ftos(bonusNades), eX * (2/3) * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, 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_expanding(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, 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); + drawpic_aspect_skin(iconPos, nadeIcon, '1 1 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); } } @@ -1088,6 +1085,7 @@ int nade_prevframe; float nade_statuschange_time; void HUD_Ammo(void) { + if(intermission == 2) return; if(hud != HUD_NORMAL) return; if(!autocvar__hud_configure) { @@ -1305,196 +1303,219 @@ void DrawNumIcon(vector myPos, vector mySize, float x, string icon, bool vertica // Powerups (#2) // + +// Powerup item fields (reusing existing fields) +.string message; // Human readable name +.string netname; // Icon name +.vector colormod; // Color +.float count; // Time left +.float lifetime; // Maximum time + +entity powerupItems; +int powerupItemsCount; + +void resetPowerupItems() +{ + entity item; + for(item = powerupItems; item; item = item.chain) + item.count = 0; + + powerupItemsCount = 0; +} + +void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime) +{ + if(!powerupItems) + powerupItems = spawn(); + + entity item; + for(item = powerupItems; item.count; item = item.chain) + if(!item.chain) + item.chain = spawn(); + + item.message = name; + item.netname = icon; + item.colormod = color; + item.count = currentTime; + item.lifetime = lifeTime; + + ++powerupItemsCount; +} + +int getPowerupItemAlign(int align, int column, int row, int columns, int rows, bool isVertical) +{ + if(align < 2) + return align; + + bool isTop = isVertical && rows > 1 && row == 0; + bool isBottom = isVertical && rows > 1 && row == rows-1; + bool isLeft = !isVertical && columns > 1 && column == 0; + bool isRight = !isVertical && columns > 1 && column == columns-1; + + if(isTop || isLeft) return (align == 2) ? 1 : 0; + if(isBottom || isRight) return (align == 2) ? 0 : 1; + + return 2; +} + void HUD_Powerups(void) { - float strength_time, shield_time, superweapons_time; + if(intermission == 2) return; + + int allItems = getstati(STAT_ITEMS, 0, 24); + int allBuffs = getstati(STAT_BUFFS, 0, 24); + int strengthTime, shieldTime, superTime; + + // Initialize items if(!autocvar__hud_configure) { if(!autocvar_hud_panel_powerups) return; if(spectatee_status == -1) return; - if(!(getstati(STAT_ITEMS, 0, 24) & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON))) return; - if (getstati(STAT_HEALTH) <= 0) return; + if(getstati(STAT_HEALTH) <= 0) return; + if(!(allItems & (IT_STRENGTH | IT_INVINCIBLE | IT_SUPERWEAPON)) && !allBuffs) return; - strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99); - shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99); - superweapons_time = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99); + strengthTime = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99); + shieldTime = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99); + superTime = bound(0, getstatf(STAT_SUPERWEAPONS_FINISHED) - time, 99); - if (getstati(STAT_ITEMS, 0, 24) & IT_UNLIMITED_SUPERWEAPONS) - superweapons_time = 99; // force max + if(allItems & IT_UNLIMITED_SUPERWEAPONS) + superTime = 99; - // prevent stuff to show up on mismatch that will be fixed next frame - if (!(getstati(STAT_ITEMS, 0, 24) & IT_SUPERWEAPON)) - superweapons_time = 0; + // Prevent stuff to show up on mismatch that will be fixed next frame + if(!(allItems & IT_SUPERWEAPON)) + superTime = 0; } else { - strength_time = 15; - shield_time = 27; - superweapons_time = 13; + strengthTime = 15; + shieldTime = 27; + superTime = 13; + allBuffs = 0; } - HUD_Panel_UpdateCvars(); + // Add items to linked list + resetPowerupItems(); - draw_beginBoldFont(); + if(strengthTime) + addPowerupItem("Strength", "strength", autocvar_hud_progressbar_strength_color, strengthTime, 30); + if(shieldTime) + addPowerupItem("Shield", "shield", autocvar_hud_progressbar_shield_color, shieldTime, 30); + if(superTime) + addPowerupItem("Superweapons", "superweapons", autocvar_hud_progressbar_superweapons_color, superTime, 30); - vector pos, mySize; - pos = panel_pos; - mySize = panel_size; + entity item; + for(item = Buff_Type_first; item; item = item.enemy) + if(allBuffs & item.items) + addPowerupItem(item.message, strcat("buff_", item.netname), item.colormod, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60); + + if(!powerupItemsCount) + return; + + // Draw panel background + HUD_Panel_UpdateCvars(); + HUD_Panel_DrawBg(1); + + // Set drawing area + vector pos = panel_pos; + vector size = panel_size; + bool isVertical = size.y > size.x; - HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time, superweapons_time), 1)); if(panel_bg_padding) { pos += '1 1 0' * panel_bg_padding; - mySize -= '2 2 0' * panel_bg_padding; + size -= '2 2 0' * panel_bg_padding; } - float panel_ar = mySize.x/mySize.y; - bool is_vertical = (panel_ar < 1); - vector shield_offset = '0 0 0', strength_offset = '0 0 0', superweapons_offset = '0 0 0'; - - int superweapons_is = -1; + // Find best partitioning of the drawing area + const float DESIRED_ASPECT = 6; + float aspect = 0, a; + int columns = 0, c; + int rows = 0, r; + int i = 1; - if(superweapons_time) + do { - if(strength_time) - { - if(shield_time) - superweapons_is = 0; - else - superweapons_is = 2; - } - else - { - if(shield_time) - superweapons_is = 1; - else - superweapons_is = 2; - } - } + c = floor(powerupItemsCount / i); + r = ceil(powerupItemsCount / c); + a = isVertical ? (size.y/r) / (size.x/c) : (size.x/c) / (size.y/r); - // FIXME handle superweapons here - if(superweapons_is == 0) - { - if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1)) + if(i == 1 || fabs(DESIRED_ASPECT - a) < fabs(DESIRED_ASPECT - aspect)) { - mySize.x *= (1.0 / 3.0); - superweapons_offset.x = mySize.x; - if (autocvar_hud_panel_powerups_flip) - shield_offset.x = 2*mySize.x; - else - strength_offset.x = 2*mySize.x; - } - else - { - mySize.y *= (1.0 / 3.0); - superweapons_offset.y = mySize.y; - if (autocvar_hud_panel_powerups_flip) - shield_offset.y = 2*mySize.y; - else - strength_offset.y = 2*mySize.y; + aspect = a; + columns = c; + rows = r; } } - else + while(++i <= powerupItemsCount); + + // Prevent single items from getting too wide + if(powerupItemsCount == 1 && aspect > DESIRED_ASPECT) { - if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1)) + if(isVertical) { - mySize.x *= 0.5; - if (autocvar_hud_panel_powerups_flip) - shield_offset.x = mySize.x; - else - strength_offset.x = mySize.x; + size.y *= 0.5; + pos.y += size.y * 0.5; } else { - mySize.y *= 0.5; - if (autocvar_hud_panel_powerups_flip) - shield_offset.y = mySize.y; - else - strength_offset.y = mySize.y; + size.x *= 0.5; + pos.x += size.x * 0.5; } } - bool shield_baralign, strength_baralign, superweapons_baralign; - bool shield_iconalign, strength_iconalign, superweapons_iconalign; + // Draw items from linked list + vector itemPos = pos; + vector itemSize = eX * (size.x / columns) + eY * (size.y / rows); + vector textColor = '1 1 1'; - if (autocvar_hud_panel_powerups_flip) - { - strength_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1); - shield_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1); - strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1); - shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1); - } - else - { - shield_baralign = (autocvar_hud_panel_powerups_baralign == 2 || autocvar_hud_panel_powerups_baralign == 1); - strength_baralign = (autocvar_hud_panel_powerups_baralign == 3 || autocvar_hud_panel_powerups_baralign == 1); - shield_iconalign = (autocvar_hud_panel_powerups_iconalign == 2 || autocvar_hud_panel_powerups_iconalign == 1); - strength_iconalign = (autocvar_hud_panel_powerups_iconalign == 3 || autocvar_hud_panel_powerups_iconalign == 1); - } + int fullSeconds = 0; + int align = 0; + int column = 0; + int row = 0; - if(superweapons_is == 0) - { - superweapons_iconalign = strength_iconalign; - superweapons_baralign = 2; - } - else if(superweapons_is == 1) - { - superweapons_offset = strength_offset; - superweapons_iconalign = strength_iconalign; - superweapons_baralign = strength_baralign; - } - else // if(superweapons_is == 2) + draw_beginBoldFont(); + for(item = powerupItems; item.count; item = item.chain) { - superweapons_offset = shield_offset; - superweapons_iconalign = shield_iconalign; - superweapons_baralign = shield_baralign; - } + itemPos = eX * (pos.x + column * itemSize.x) + eY * (pos.y + row * itemSize.y); - if(shield_time) - { - const float maxshield = 30; - float shield = ceil(shield_time); + // Draw progressbar if(autocvar_hud_panel_powerups_progressbar) - HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, autocvar_hud_progressbar_shield_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - if(autocvar_hud_panel_powerups_text) { - if(shield > 1) - DrawNumIcon(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1); - if(shield <= 5) - DrawNumIcon_expanding(pos + shield_offset, mySize, shield, "shield", is_vertical, shield_iconalign, '1 1 1', 1, bound(0, (shield - shield_time) / 0.5, 1)); + align = getPowerupItemAlign(autocvar_hud_panel_powerups_baralign, column, row, columns, rows, isVertical); + HUD_Panel_DrawProgressBar(itemPos, itemSize, "progressbar", item.count / item.lifetime, isVertical, align, item.colormod, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - } - if(strength_time) - { - const float maxstrength = 30; - float strength = ceil(strength_time); - if(autocvar_hud_panel_powerups_progressbar) - HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, autocvar_hud_progressbar_strength_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + // Draw icon and text if(autocvar_hud_panel_powerups_text) { - if(strength > 1) - DrawNumIcon(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1); - if(strength <= 5) - DrawNumIcon_expanding(pos + strength_offset, mySize, strength, "strength", is_vertical, strength_iconalign, '1 1 1', 1, bound(0, (strength - strength_time) / 0.5, 1)); + align = getPowerupItemAlign(autocvar_hud_panel_powerups_iconalign, column, row, columns, rows, isVertical); + fullSeconds = ceil(item.count); + textColor = '0.6 0.6 0.6' + (item.colormod * 0.4); + + if(item.count > 1) + DrawNumIcon(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha); + if(item.count <= 5) + DrawNumIcon_expanding(itemPos, itemSize, fullSeconds, item.netname, isVertical, align, textColor, panel_fg_alpha, bound(0, (fullSeconds - item.count) / 0.5, 1)); } - } - if(superweapons_time) - { - const float maxsuperweapons = 30; - float superweapons = ceil(superweapons_time); - if(autocvar_hud_panel_powerups_progressbar) - HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, autocvar_hud_progressbar_superweapons_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - if(autocvar_hud_panel_powerups_text) + // Determine next section + if(isVertical) { - if(superweapons > 1) - DrawNumIcon(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1); - if(superweapons <= 5) - DrawNumIcon_expanding(pos + superweapons_offset, mySize, superweapons, "superweapons", is_vertical, superweapons_iconalign, '1 1 1', 1, bound(0, (superweapons - superweapons_time) / 0.5, 1)); + if(++column >= columns) + { + column = 0; + ++row; + } + } + else + { + if(++row >= rows) + { + row = 0; + ++column; + } } } - draw_endBoldFont(); } @@ -1505,6 +1526,7 @@ void HUD_Powerups(void) void HUD_HealthArmor(void) { int armor, health, fuel; + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_healtharmor) return; @@ -1554,6 +1576,9 @@ void HUD_HealthArmor(void) } HUD_Panel_UpdateCvars(); + + draw_beginBoldFont(); + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -1759,6 +1784,8 @@ void HUD_HealthArmor(void) HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } } + + draw_endBoldFont(); } // Notification area (#4) @@ -1806,6 +1833,7 @@ void HUD_Notify_Push(string icon, string attacker, string victim) void HUD_Notify(void) { + if(intermission == 2) return; if (!autocvar__hud_configure) if (!autocvar_hud_panel_notify) return; @@ -1931,6 +1959,7 @@ string seconds_tostring(float sec) void HUD_Timer(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_timer) return; @@ -1990,6 +2019,7 @@ void HUD_Timer(void) // void HUD_Radar(void) { + if(intermission == 2) return; if (!autocvar__hud_configure) { if (hud_panel_radar_maximized) @@ -2301,6 +2331,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me) void HUD_Score(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_score) return; @@ -2324,7 +2355,7 @@ void HUD_Score(void) vector distribution_color; entity tm, pl, me; - me = playerslots[player_localentnum - 1]; + me = playerslots[current_player]; if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD string timer, distrtimer; @@ -2484,6 +2515,7 @@ void HUD_Score(void) // void HUD_RaceTimer (void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_racetimer) return; @@ -2493,8 +2525,6 @@ void HUD_RaceTimer (void) HUD_Panel_UpdateCvars(); - draw_beginBoldFont(); - vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -2530,7 +2560,9 @@ void HUD_RaceTimer (void) if(autocvar__hud_configure) { s = "0:13:37"; + draw_beginBoldFont(); drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.60 0.60 0' * mySize.y), s, '0.60 0.60 0' * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + draw_endBoldFont(); s = _("^1Intermediate 1 (+15.42)"); drawcolorcodedstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, true, '1 1 0' * 0.20 * mySize.y) + eY * 0.60 * mySize.y, s, '1 1 0' * 0.20 * mySize.y, panel_fg_alpha, DRAWFLAG_NORMAL); s = sprintf(_("^1PENALTY: %.1f (%s)"), 2, "missing a checkpoint"); @@ -2580,6 +2612,8 @@ void HUD_RaceTimer (void) } } + draw_beginBoldFont(); + if(forcetime != "") { a = bound(0, (time - race_checkpointtime) / 0.5, 1); @@ -2593,6 +2627,8 @@ void HUD_RaceTimer (void) s = TIME_ENCODED_TOSTRING(TIME_ENCODE(time + TIME_DECODE(race_penaltyaccumulator) - race_laptime)); drawstring(pos + eX * 0.5 * mySize.x - '0.5 0 0' * stringwidth(s, false, '0.6 0.6 0' * mySize.y), s, '0.6 0.6 0' * mySize.y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } + + draw_endBoldFont(); } else { @@ -2623,8 +2659,6 @@ void HUD_RaceTimer (void) } } } - - draw_endBoldFont(); } // Vote window (#9) @@ -2632,6 +2666,7 @@ void HUD_RaceTimer (void) void HUD_Vote(void) { + if(intermission == 2) return; if(autocvar_cl_allow_uid2name == -1 && (gametype == MAPINFO_TYPE_CTS || gametype == MAPINFO_TYPE_RACE || (serverflags & SERVERFLAG_PLAYERSTATS))) { vote_active = 1; @@ -2889,66 +2924,36 @@ void HUD_Mod_CTF(vector pos, vector mySize) yellowflag = (stat_items/CTF_YELLOW_FLAG_TAKEN) & 3; pinkflag = (stat_items/CTF_PINK_FLAG_TAKEN) & 3; neutralflag = (stat_items/CTF_NEUTRAL_FLAG_TAKEN) & 3; - + ctf_oneflag = (stat_items & CTF_FLAG_NEUTRAL); - if(redflag || blueflag || yellowflag || pinkflag || neutralflag) - mod_active = 1; - else - mod_active = 0; + mod_active = (redflag || blueflag || yellowflag || pinkflag || neutralflag); - if(autocvar__hud_configure) - { + if (autocvar__hud_configure) { redflag = 1; blueflag = 2; - if(team_count >= 3) + if (team_count >= 3) yellowflag = 2; - if(team_count >= 4) + if (team_count >= 4) pinkflag = 3; ctf_oneflag = neutralflag = 0; // disable neutral flag in hud editor? } // when status CHANGES, set old status into prevstatus and current status into status - if (redflag != redflag_prevframe) - { - redflag_statuschange_time = time; - redflag_prevstatus = redflag_prevframe; - redflag_prevframe = redflag; - } - - if (blueflag != blueflag_prevframe) - { - blueflag_statuschange_time = time; - blueflag_prevstatus = blueflag_prevframe; - blueflag_prevframe = blueflag; - } - - if (yellowflag != yellowflag_prevframe) - { - yellowflag_statuschange_time = time; - yellowflag_prevstatus = yellowflag_prevframe; - yellowflag_prevframe = yellowflag; - } - - if (pinkflag != pinkflag_prevframe) - { - pinkflag_statuschange_time = time; - pinkflag_prevstatus = pinkflag_prevframe; - pinkflag_prevframe = pinkflag; - } - - if (neutralflag != neutralflag_prevframe) - { - neutralflag_statuschange_time = time; - neutralflag_prevstatus = neutralflag_prevframe; - neutralflag_prevframe = neutralflag; - } - - redflag_statuschange_elapsedtime = time - redflag_statuschange_time; - blueflag_statuschange_elapsedtime = time - blueflag_statuschange_time; - yellowflag_statuschange_elapsedtime = time - yellowflag_statuschange_time; - pinkflag_statuschange_elapsedtime = time - pinkflag_statuschange_time; - neutralflag_statuschange_elapsedtime = time - neutralflag_statuschange_time; + #define X(team) do { \ + if (team##flag != team##flag_prevframe) { \ + team##flag_statuschange_time = time; \ + team##flag_prevstatus = team##flag_prevframe; \ + team##flag_prevframe = team##flag; \ + } \ + team##flag_statuschange_elapsedtime = time - team##flag_statuschange_time; \ + } while (0) + X(red); + X(blue); + X(yellow); + X(pink); + X(neutral); + #undef X const float BLINK_FACTOR = 0.15; const float BLINK_BASE = 0.85; @@ -2959,214 +2964,92 @@ void HUD_Mod_CTF(vector pos, vector mySize) // ensure RMS == 1 const float BLINK_FREQ = 5; // circle frequency, = 2*pi*frequency in hertz - string red_icon, red_icon_prevstatus; - int red_alpha, red_alpha_prevstatus; - red_alpha = red_alpha_prevstatus = 1; - switch(redflag) - { - case 1: red_icon = "flag_red_taken"; break; - case 2: red_icon = "flag_red_lost"; break; - case 3: red_icon = "flag_red_carrying"; red_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_1)) - red_icon = "flag_red_shielded"; - else - red_icon = string_null; - break; - } - switch(redflag_prevstatus) - { - case 1: red_icon_prevstatus = "flag_red_taken"; break; - case 2: red_icon_prevstatus = "flag_red_lost"; break; - case 3: red_icon_prevstatus = "flag_red_carrying"; red_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if(redflag == 3) - red_icon_prevstatus = "flag_red_carrying"; // make it more visible - else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_1)) - red_icon_prevstatus = "flag_red_shielded"; - else - red_icon_prevstatus = string_null; - break; - } - - string blue_icon, blue_icon_prevstatus; - int blue_alpha, blue_alpha_prevstatus; - blue_alpha = blue_alpha_prevstatus = 1; - switch(blueflag) - { - case 1: blue_icon = "flag_blue_taken"; break; - case 2: blue_icon = "flag_blue_lost"; break; - case 3: blue_icon = "flag_blue_carrying"; blue_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_2)) - blue_icon = "flag_blue_shielded"; - else - blue_icon = string_null; - break; - } - switch(blueflag_prevstatus) - { - case 1: blue_icon_prevstatus = "flag_blue_taken"; break; - case 2: blue_icon_prevstatus = "flag_blue_lost"; break; - case 3: blue_icon_prevstatus = "flag_blue_carrying"; blue_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if(blueflag == 3) - blue_icon_prevstatus = "flag_blue_carrying"; // make it more visible - else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_2)) - blue_icon_prevstatus = "flag_blue_shielded"; - else - blue_icon_prevstatus = string_null; - break; - } - - string yellow_icon, yellow_icon_prevstatus; - int yellow_alpha, yellow_alpha_prevstatus; - yellow_alpha = yellow_alpha_prevstatus = 1; - switch(yellowflag) - { - case 1: yellow_icon = "flag_yellow_taken"; break; - case 2: yellow_icon = "flag_yellow_lost"; break; - case 3: yellow_icon = "flag_yellow_carrying"; yellow_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_3)) - yellow_icon = "flag_yellow_shielded"; - else - yellow_icon = string_null; - break; - } - switch(yellowflag_prevstatus) - { - case 1: yellow_icon_prevstatus = "flag_yellow_taken"; break; - case 2: yellow_icon_prevstatus = "flag_yellow_lost"; break; - case 3: yellow_icon_prevstatus = "flag_yellow_carrying"; yellow_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if(yellowflag == 3) - yellow_icon_prevstatus = "flag_yellow_carrying"; // make it more visible - else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_3)) - yellow_icon_prevstatus = "flag_yellow_shielded"; - else - yellow_icon_prevstatus = string_null; - break; - } - - string pink_icon, pink_icon_prevstatus; - int pink_alpha, pink_alpha_prevstatus; - pink_alpha = pink_alpha_prevstatus = 1; - switch(pinkflag) - { - case 1: pink_icon = "flag_pink_taken"; break; - case 2: pink_icon = "flag_pink_lost"; break; - case 3: pink_icon = "flag_pink_carrying"; pink_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_4)) - pink_icon = "flag_pink_shielded"; - else - pink_icon = string_null; - break; - } - switch(pinkflag_prevstatus) - { - case 1: pink_icon_prevstatus = "flag_pink_taken"; break; - case 2: pink_icon_prevstatus = "flag_pink_lost"; break; - case 3: pink_icon_prevstatus = "flag_pink_carrying"; pink_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if(pinkflag == 3) - pink_icon_prevstatus = "flag_pink_carrying"; // make it more visible - else if((stat_items & CTF_SHIELDED) && (myteam != NUM_TEAM_4)) - pink_icon_prevstatus = "flag_pink_shielded"; - else - pink_icon_prevstatus = string_null; - break; - } - - string neutral_icon, neutral_icon_prevstatus; - int neutral_alpha, neutral_alpha_prevstatus; - neutral_alpha = neutral_alpha_prevstatus = 1; - switch(neutralflag) - { - case 1: neutral_icon = "flag_neutral_taken"; break; - case 2: neutral_icon = "flag_neutral_lost"; break; - case 3: neutral_icon = "flag_neutral_carrying"; neutral_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if((stat_items & CTF_SHIELDED)) - neutral_icon = "flag_neutral_shielded"; - else - neutral_icon = string_null; - break; - } - switch(neutralflag_prevstatus) - { - case 1: neutral_icon_prevstatus = "flag_neutral_taken"; break; - case 2: neutral_icon_prevstatus = "flag_neutral_lost"; break; - case 3: neutral_icon_prevstatus = "flag_neutral_carrying"; neutral_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; - default: - if(neutralflag == 3) - neutral_icon_prevstatus = "flag_neutral_carrying"; // make it more visible - else if((stat_items & CTF_SHIELDED)) - neutral_icon_prevstatus = "flag_neutral_shielded"; - else - neutral_icon_prevstatus = string_null; - break; - } - - if(ctf_oneflag) - { + #define X(team, cond) \ + string team##_icon, team##_icon_prevstatus; \ + int team##_alpha, team##_alpha_prevstatus; \ + team##_alpha = team##_alpha_prevstatus = 1; \ + do { \ + switch (team##flag) { \ + case 1: team##_icon = "flag_" #team "_taken"; break; \ + case 2: team##_icon = "flag_" #team "_lost"; break; \ + case 3: team##_icon = "flag_" #team "_carrying"; team##_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \ + default: \ + if ((stat_items & CTF_SHIELDED) && (cond)) { \ + team##_icon = "flag_" #team "_shielded"; \ + } else { \ + team##_icon = string_null; \ + } \ + break; \ + } \ + switch (team##flag_prevstatus) { \ + case 1: team##_icon_prevstatus = "flag_" #team "_taken"; break; \ + case 2: team##_icon_prevstatus = "flag_" #team "_lost"; break; \ + case 3: team##_icon_prevstatus = "flag_" #team "_carrying"; team##_alpha_prevstatus = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); break; \ + default: \ + if (team##flag == 3) { \ + team##_icon_prevstatus = "flag_" #team "_carrying"; /* make it more visible */\ + } else if((stat_items & CTF_SHIELDED) && (cond)) { \ + team##_icon_prevstatus = "flag_" #team "_shielded"; \ + } else { \ + team##_icon_prevstatus = string_null; \ + } \ + break; \ + } \ + } while (0) + X(red, myteam != NUM_TEAM_1); + X(blue, myteam != NUM_TEAM_2); + X(yellow, myteam != NUM_TEAM_3); + X(pink, myteam != NUM_TEAM_4); + X(neutral, true); + #undef X + + if (ctf_oneflag) { // hacky, but these aren't needed red_icon = red_icon_prevstatus = blue_icon = blue_icon_prevstatus = yellow_icon = yellow_icon_prevstatus = pink_icon = pink_icon_prevstatus = string_null; fs = fs2 = fs3 = 1; - } - else switch(team_count) - { + } else switch (team_count) { default: case 2: fs = 0.5; fs2 = 0.5; fs3 = 0.5; break; case 3: fs = 1; fs2 = 0.35; fs3 = 0.35; break; case 4: fs = 0.75; fs2 = 0.25; fs3 = 0.5; break; } - if(mySize_x > mySize_y) - { + if (mySize_x > mySize_y) { size1 = mySize_x; size2 = mySize_y; e1 = eX; e2 = eY; - } - else - { + } else { size1 = mySize_y; size2 = mySize_x; e1 = eY; e2 = eX; } - switch(myteam) - { + switch (myteam) { default: - case NUM_TEAM_1: - { + case NUM_TEAM_1: { redflag_pos = pos; blueflag_pos = pos + eX * fs2 * size1; yellowflag_pos = pos - eX * fs2 * size1; pinkflag_pos = pos + eX * fs3 * size1; break; } - case NUM_TEAM_2: - { + case NUM_TEAM_2: { redflag_pos = pos + eX * fs2 * size1; blueflag_pos = pos; yellowflag_pos = pos - eX * fs2 * size1; pinkflag_pos = pos + eX * fs3 * size1; break; } - case NUM_TEAM_3: - { + case NUM_TEAM_3: { redflag_pos = pos + eX * fs3 * size1; blueflag_pos = pos - eX * fs2 * size1; yellowflag_pos = pos; pinkflag_pos = pos + eX * fs2 * size1; break; } - case NUM_TEAM_4: - { + case NUM_TEAM_4: { redflag_pos = pos - eX * fs2 * size1; blueflag_pos = pos + eX * fs3 * size1; yellowflag_pos = pos + eX * fs2 * size1; @@ -3177,35 +3060,19 @@ void HUD_Mod_CTF(vector pos, vector mySize) neutralflag_pos = pos; flag_size = e1 * fs * size1 + e2 * size2; - f = bound(0, redflag_statuschange_elapsedtime*2, 1); - if(red_icon_prevstatus && f < 1) - drawpic_aspect_skin_expanding(redflag_pos, red_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * red_alpha_prevstatus, DRAWFLAG_NORMAL, f); - if(red_icon) - drawpic_aspect_skin(redflag_pos, red_icon, flag_size, '1 1 1', panel_fg_alpha * red_alpha * f, DRAWFLAG_NORMAL); - - f = bound(0, blueflag_statuschange_elapsedtime*2, 1); - if(blue_icon_prevstatus && f < 1) - drawpic_aspect_skin_expanding(blueflag_pos, blue_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * blue_alpha_prevstatus, DRAWFLAG_NORMAL, f); - if(blue_icon) - drawpic_aspect_skin(blueflag_pos, blue_icon, flag_size, '1 1 1', panel_fg_alpha * blue_alpha * f, DRAWFLAG_NORMAL); - - f = bound(0, yellowflag_statuschange_elapsedtime*2, 1); - if(yellow_icon_prevstatus && f < 1) - drawpic_aspect_skin_expanding(yellowflag_pos, yellow_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * yellow_alpha_prevstatus, DRAWFLAG_NORMAL, f); - if(yellow_icon) - drawpic_aspect_skin(yellowflag_pos, yellow_icon, flag_size, '1 1 1', panel_fg_alpha * yellow_alpha * f, DRAWFLAG_NORMAL); - - f = bound(0, pinkflag_statuschange_elapsedtime*2, 1); - if(pink_icon_prevstatus && f < 1) - drawpic_aspect_skin_expanding(pinkflag_pos, pink_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * pink_alpha_prevstatus, DRAWFLAG_NORMAL, f); - if(pink_icon) - drawpic_aspect_skin(pinkflag_pos, pink_icon, flag_size, '1 1 1', panel_fg_alpha * pink_alpha * f, DRAWFLAG_NORMAL); - - f = bound(0, neutralflag_statuschange_elapsedtime*2, 1); - if(neutral_icon_prevstatus && f < 1) - drawpic_aspect_skin_expanding(neutralflag_pos, neutral_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * neutral_alpha_prevstatus, DRAWFLAG_NORMAL, f); - if(neutral_icon) - drawpic_aspect_skin(neutralflag_pos, neutral_icon, flag_size, '1 1 1', panel_fg_alpha * neutral_alpha * f, DRAWFLAG_NORMAL); + #define X(team) do { \ + f = bound(0, team##flag_statuschange_elapsedtime * 2, 1); \ + if (team##_icon_prevstatus && f < 1) \ + drawpic_aspect_skin_expanding(team##flag_pos, team##_icon_prevstatus, flag_size, '1 1 1', panel_fg_alpha * team##_alpha_prevstatus, DRAWFLAG_NORMAL, f); \ + if (team##_icon) \ + drawpic_aspect_skin(team##flag_pos, team##_icon, flag_size, '1 1 1', panel_fg_alpha * team##_alpha * f, DRAWFLAG_NORMAL); \ + } while (0) + X(red); + X(blue); + X(yellow); + X(pink); + X(neutral); + #undef X } // Keyhunt HUD modicon section @@ -3676,6 +3543,7 @@ float mod_change; // "time" when mod_active changed void HUD_ModIcons(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_modicons) return; @@ -3717,6 +3585,7 @@ void HUD_ModIcons(void) // void HUD_PressedKeys(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_pressedkeys) return; @@ -3803,6 +3672,15 @@ void HUD_Chat(void) HUD_Panel_UpdateCvars(); + if(intermission == 2) + { + // reserve some more space to the mapvote panel + // by resizing and moving chat panel to the bottom + panel_size.y = min(panel_size.y, vid_conheight * 0.2); + panel_pos.y = vid_conheight - panel_size.y - panel_bg_border * 2; + chat_posy = panel_pos.y; + chat_sizey = panel_size.y; + } if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized { panel_pos.y = panel_bg_border; @@ -3871,6 +3749,7 @@ float frametimeavg1; // 1 frame ago float frametimeavg2; // 2 frames ago void HUD_EngineInfo(void) { + //if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_engineinfo) return; @@ -3932,6 +3811,7 @@ void HUD_EngineInfo(void) } while(0) void HUD_InfoMessages(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_infomessages) return; @@ -3986,7 +3866,7 @@ void HUD_InfoMessages(void) if(spectatee_status == -1) s = _("^1Observing"); else - s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(player_localentnum - 1)); + s = sprintf(_("^1Spectating: ^7%s"), GetPlayerName(current_player)); drawInfoMessage(s); if(spectatee_status == -1) @@ -4113,6 +3993,7 @@ float acc_prevtime, acc_avg, top_speed, top_speed_time; float physics_update_time, discrete_speed, discrete_acceleration; void HUD_Physics(void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_physics) return; @@ -4504,6 +4385,7 @@ void reset_centerprint_messages(void) float hud_configure_cp_generation_time; void HUD_CenterPrint (void) { + if(intermission == 2) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_centerprint) return; @@ -4722,63 +4604,249 @@ void HUD_CenterPrint (void) } } -// Buffs (#18) +// ItemsTime (#XX) // -void HUD_Buffs(void) +const float ITEMSTIME_MAXITEMS = 10; +float ItemsTime_time[ITEMSTIME_MAXITEMS]; +float ItemsTime_availableTime[ITEMSTIME_MAXITEMS]; +string GetItemsTimePicture(float i) { - int buffs = getstati(STAT_BUFFS, 0, 24); - if(!autocvar__hud_configure) + switch(i) { - if(!autocvar_hud_panel_buffs) return; - if(spectatee_status == -1) return; - if(getstati(STAT_HEALTH) <= 0) return; - if(!buffs) return; + case 0: return "item_large_armor"; + case 1: return "item_mega_health"; + case 2: return "strength"; + case 3: return "shield"; + case 4: return "item_mega_health"; + case 5: return "strength"; + case 6: return "shield"; + case 7: return "fuelregen"; + case 8: return "jetpack"; + case 9: return "superweapons"; + default: return ""; + } +} + +void DrawItemsTimeItem(vector myPos, vector mySize, float ar, float itemcode, float item_time, bool item_available, float item_availableTime) +{ + float t = 0; + vector color = '0 0 0'; + float picalpha; + + if(autocvar_hud_panel_itemstime_hidespawned == 2) + picalpha = 1; + else if(item_available) + { + float BLINK_FACTOR = 0.15; + float BLINK_BASE = 0.85; + float BLINK_FREQ = 5; + picalpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); } else + picalpha = 0.5; + t = floor(item_time - time + 0.999); + if(t < 5) + color = '0.7 0 0'; + else if(t < 10) + color = '0.7 0.7 0'; + else + color = '1 1 1'; + + vector picpos, numpos; + if(autocvar_hud_panel_itemstime_iconalign) { - buffs = Buff_Type_first.items; // force first buff + numpos = myPos; + picpos = myPos + eX * (ar - 1) * mySize_y; + } + else + { + numpos = myPos + eX * mySize_y; + picpos = myPos; } - int b = 0; // counter to tell other functions that we have buffs - entity e; - string s = ""; - for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items) + if(t > 0 && autocvar_hud_panel_itemstime_progressbar) { - ++b; - string o = strcat(rgb_to_hexcolor(Buff_Color(e.items)), Buff_PrettyName(e.items)); - if(s == "") - s = o; + vector p_pos, p_size; + if(autocvar_hud_panel_itemstime_progressbar_reduced) + { + p_pos = numpos; + p_size = eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y; + } else - s = strcat(s, " ", o); + { + p_pos = myPos; + p_size = mySize; + } + HUD_Panel_DrawProgressBar(p_pos, p_size, autocvar_hud_panel_itemstime_progressbar_name, t/autocvar_hud_panel_itemstime_progressbar_maxtime, 0, autocvar_hud_panel_itemstime_iconalign, color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - HUD_Panel_UpdateCvars(); + if(t > 0 && autocvar_hud_panel_itemstime_text) + drawstring_aspect(numpos, ftos(t), eX * ((ar - 1)/ar) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + else + picpos.x = myPos.x + mySize.x / 2 - mySize.y / 2; + if(item_availableTime) + drawpic_aspect_skin_expanding(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL, item_availableTime); + drawpic_aspect_skin(picpos, GetItemsTimePicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * picalpha, DRAWFLAG_NORMAL); +} - draw_beginBoldFont(); +void HUD_ItemsTime(void) +{ + if(!autocvar__hud_configure) + { + if(!( + (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0) + || (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage)) + )) { return; } + + ItemsTime_time[0] = getstatf(STAT_ARMOR_LARGE_TIME); + ItemsTime_time[1] = getstatf(STAT_HEALTH_MEGA_TIME); + ItemsTime_time[2] = getstatf(STAT_INVISIBLE_TIME); + ItemsTime_time[3] = getstatf(STAT_SPEED_TIME); + ItemsTime_time[4] = getstatf(STAT_EXTRALIFE_TIME); + ItemsTime_time[5] = getstatf(STAT_STRENGTH_TIME); + ItemsTime_time[6] = getstatf(STAT_SHIELD_TIME); + ItemsTime_time[7] = getstatf(STAT_FUELREGEN_TIME); + ItemsTime_time[8] = getstatf(STAT_JETPACK_TIME); + ItemsTime_time[9] = getstatf(STAT_SUPERWEAPONS_TIME); + } + else + { + // do not show here mutator-dependent items + ItemsTime_time[0] = time + 0; + ItemsTime_time[1] = time + 8; + ItemsTime_time[2] = -1; // mutator-dependent + ItemsTime_time[3] = -1; // mutator-dependent + ItemsTime_time[4] = -1; // mutator-dependent + ItemsTime_time[5] = time + 0; + ItemsTime_time[6] = time + 4; + ItemsTime_time[7] = time + 49; + ItemsTime_time[8] = -1; + ItemsTime_time[9] = time + 28; + } + + float i; + float count = 0; + if(autocvar_hud_panel_itemstime_hidespawned == 1) + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] > time || -ItemsTime_time[i] > time); + else if(autocvar_hud_panel_itemstime_hidespawned == 2) + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] > time); + else + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) + count += (ItemsTime_time[i] != -1); + if (count == 0) + return; + + HUD_Panel_UpdateCvars(); vector pos, mySize; pos = panel_pos; mySize = panel_size; - HUD_Panel_DrawBg(bound(0, b, 1)); if(panel_bg_padding) { pos += '1 1 0' * panel_bg_padding; mySize -= '2 2 0' * panel_bg_padding; } - //float panel_ar = mySize_x/mySize_y; - //bool is_vertical = (panel_ar < 1); - //float buff_iconalign = autocvar_hud_panel_buffs_iconalign; - vector buff_offset = '0 0 0'; + float rows, columns; + float ar = max(2, autocvar_hud_panel_itemstime_ratio) + 1; + rows = HUD_GetRowCount(count, mySize, ar); + columns = ceil(count/rows); + + vector itemstime_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows); - for(e = Buff_Type_first; e; e = e.enemy) if(buffs & e.items) + vector offset = '0 0 0'; + float newSize; + if(autocvar_hud_panel_itemstime_dynamicsize) { - //DrawNumIcon(pos + buff_offset, mySize, shield, "shield", is_vertical, buff_iconalign, '1 1 1', 1); - drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); + if(autocvar__hud_configure) + if(menu_enabled != 2) + HUD_Panel_DrawBg(1); // also draw the bg of the entire panel + + // reduce panel to avoid spacing items + if(itemstime_size.x / itemstime_size.y < ar) + { + newSize = rows * itemstime_size.x / ar; + pos.y += (mySize.y - newSize) / 2; + mySize.y = newSize; + itemstime_size.y = mySize.y / rows; + } + else + { + newSize = columns * itemstime_size.y * ar; + pos.x += (mySize.x - newSize) / 2; + mySize.x = newSize; + itemstime_size.x = mySize.x / columns; + } + panel_pos = pos - '1 1 0' * panel_bg_padding; + panel_size = mySize + '2 2 0' * panel_bg_padding; + } + else + { + if(itemstime_size.x/itemstime_size.y > ar) + { + newSize = ar * itemstime_size.y; + offset.x = itemstime_size.x - newSize; + pos.x += offset.x/2; + itemstime_size.x = newSize; + } + else + { + newSize = 1/ar * itemstime_size.x; + offset.y = itemstime_size.y - newSize; + pos.y += offset.y/2; + itemstime_size.y = newSize; + } } - draw_endBoldFont(); + HUD_Panel_DrawBg(1); + + float row = 0, column = 0; + bool item_available; + for (i = 0; i < ITEMSTIME_MAXITEMS; ++i) { + if (ItemsTime_time[i] == -1) + continue; + + float item_time = ItemsTime_time[i]; + if(item_time < -1) + { + item_available = true; + item_time = -item_time; + } + else + item_available = (item_time <= time); + + if(ItemsTime_time[i] >= 0) + { + if(time <= ItemsTime_time[i]) + ItemsTime_availableTime[i] = 0; + else if(ItemsTime_availableTime[i] == 0) + ItemsTime_availableTime[i] = time; + } + else if(ItemsTime_availableTime[i] == 0) + ItemsTime_availableTime[i] = time; + + float f = (time - ItemsTime_availableTime[i]) * 2; + f = (f > 1) ? 0 : bound(0, f, 1); + + if(autocvar_hud_panel_itemstime_hidespawned == 1) + if(!(ItemsTime_time[i] > time || -ItemsTime_time[i] > time)) + continue; + + if(autocvar_hud_panel_itemstime_hidespawned == 2) + if(!(ItemsTime_time[i] > time)) + continue; + + DrawItemsTimeItem(pos + eX * column * (itemstime_size.x + offset.x) + eY * row * (itemstime_size.y + offset.y), itemstime_size, ar, i, item_time, item_available, f); + ++row; + if(row >= rows) + { + row = 0; + column = column + 1; + } + } } @@ -4809,9 +4877,6 @@ void HUD_Main (void) HUD_Configure_Frame(); - if(intermission == 2) // no hud during mapvote - hud_fade_alpha = 0; - // panels that we want to be active together with the scoreboard // they must fade only when the menu does if(scoreboard_fade_alpha == 1) @@ -4834,8 +4899,6 @@ void HUD_Main (void) hud_skin_prev = strzone(autocvar_hud_skin); } - current_player = player_localentnum; - // draw the dock if(autocvar_hud_dock != "" && autocvar_hud_dock != "0") { @@ -4855,11 +4918,11 @@ void HUD_Main (void) { string hud_dock_color = autocvar_hud_dock_color; if(hud_dock_color == "shirt") { - f = stof(getplayerkeyvalue(current_player - 1, "colors")); + f = stof(getplayerkeyvalue(current_player, "colors")); color = colormapPaletteColor(floor(f / 16), 0); } else if(hud_dock_color == "pants") { - f = stof(getplayerkeyvalue(current_player - 1, "colors")); + f = stof(getplayerkeyvalue(current_player, "colors")); color = colormapPaletteColor(f % 16, 1); } else @@ -4920,7 +4983,7 @@ void HUD_Main (void) } hud_draw_maximized = 0; - // draw panels in order specified by panel_order array + // draw panels in the order specified by panel_order array for(i = HUD_PANEL_NUM - 1; i >= 0; --i) (panel = hud_panel[panel_order[i]]).panel_draw();