X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=e1c95025892e272c556f33edbc86275df630a21a;hp=9399af83b1b57f1b81d8a641a3f6617f2deae11c;hb=20256058c4de97b81ee5aaedaa383a99010752f0;hpb=38ec1ced498dbd79153c50b73f0a3df4455919f4 diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 9399af83b..e1c950258 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -264,8 +264,8 @@ HUD panels // draw the background/borders #define HUD_Panel_DrawBg(theAlpha)\ -if(panel_bg != "0" && panel_bg != "")\ - draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, 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)) +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)) //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) @@ -489,7 +489,6 @@ void HUD_Weapons(void) // update generic hud functions HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); draw_beginBoldFont(); @@ -945,7 +944,7 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s void HUD_Ammo(void) { - if(hud != HUD_NORMAL) return; + if(hud != HUD_NORMAL) return; if(!autocvar__hud_configure) { if(!autocvar_hud_panel_ammo) return; @@ -953,7 +952,6 @@ void HUD_Ammo(void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); draw_beginBoldFont(); @@ -968,6 +966,7 @@ void HUD_Ammo(void) mySize -= '2 2 0' * panel_bg_padding; } + const float AMMO_COUNT = 4; float rows = 0, columns, row, column; vector ammo_size; if (autocvar_hud_panel_ammo_onlycurrent) @@ -1159,7 +1158,6 @@ void HUD_Powerups(void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); draw_beginBoldFont(); @@ -1281,10 +1279,7 @@ void HUD_Powerups(void) const float maxshield = 30; float shield = ceil(shield_time); if(autocvar_hud_panel_powerups_progressbar) - { - HUD_Panel_GetProgressBarColor(shield); - HUD_Panel_DrawProgressBar(pos + shield_offset, mySize, autocvar_hud_panel_powerups_progressbar_shield, shield/maxshield, is_vertical, shield_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + 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) @@ -1299,10 +1294,7 @@ void HUD_Powerups(void) const float maxstrength = 30; float strength = ceil(strength_time); if(autocvar_hud_panel_powerups_progressbar) - { - HUD_Panel_GetProgressBarColor(strength); - HUD_Panel_DrawProgressBar(pos + strength_offset, mySize, autocvar_hud_panel_powerups_progressbar_strength, strength/maxstrength, is_vertical, strength_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + 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); if(autocvar_hud_panel_powerups_text) { if(strength > 1) @@ -1317,10 +1309,7 @@ void HUD_Powerups(void) const float maxsuperweapons = 30; float superweapons = ceil(superweapons_time); if(autocvar_hud_panel_powerups_progressbar) - { - HUD_Panel_GetProgressBarColor(superweapons); - HUD_Panel_DrawProgressBar(pos + superweapons_offset, mySize, autocvar_hud_panel_powerups_progressbar_superweapons, superweapons/maxsuperweapons, is_vertical, superweapons_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + 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) { if(superweapons > 1) @@ -1400,7 +1389,6 @@ void HUD_HealthArmor(void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -1431,10 +1419,7 @@ void HUD_HealthArmor(void) { biggercount = "health"; if(autocvar_hud_panel_healtharmor_progressbar) - { - HUD_Panel_GetProgressBarColor(health); - HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); if(armor) if(autocvar_hud_panel_healtharmor_text) drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL); @@ -1443,10 +1428,7 @@ void HUD_HealthArmor(void) { biggercount = "armor"; if(autocvar_hud_panel_healtharmor_progressbar) - { - HUD_Panel_GetProgressBarColor(armor); - HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } + HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); if(health) if(autocvar_hud_panel_healtharmor_text) drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); @@ -1455,10 +1437,7 @@ void HUD_HealthArmor(void) DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1); if(fuel) - { - HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); - } + HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, "progressbar", fuel/100, 0, (baralign == 1 || baralign == 3), autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } else { @@ -1505,7 +1484,6 @@ void HUD_HealthArmor(void) { if(autocvar_hud_panel_healtharmor_progressbar) { - HUD_Panel_GetProgressBarColor(health); float p_health, pain_health_alpha; p_health = health; pain_health_alpha = 1; @@ -1538,7 +1516,7 @@ void HUD_HealthArmor(void) if (time - health_damagetime < 1) { float health_damagealpha = 1 - (time - health_damagetime)*(time - health_damagetime); - HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, health_beforedamage/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * health_damagealpha, DRAWFLAG_NORMAL); } } prev_health = health; @@ -1551,7 +1529,7 @@ void HUD_HealthArmor(void) pain_health_alpha = BLINK_BASE + BLINK_FACTOR * cos(time * BLINK_FREQ); } } - HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos + health_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_health, p_health/maxhealth, is_vertical, health_baralign, autocvar_hud_progressbar_health_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * pain_health_alpha, DRAWFLAG_NORMAL); } if(autocvar_hud_panel_healtharmor_text) DrawNumIcon(pos + health_offset, mySize, health, "health", is_vertical, health_iconalign, HUD_Get_Num_Color(health, maxhealth), 1); @@ -1561,7 +1539,6 @@ void HUD_HealthArmor(void) { if(autocvar_hud_panel_healtharmor_progressbar) { - HUD_Panel_GetProgressBarColor(armor); float p_armor; p_armor = armor; if (autocvar_hud_panel_healtharmor_progressbar_gfx) @@ -1593,12 +1570,12 @@ void HUD_HealthArmor(void) if (time - armor_damagetime < 1) { float armor_damagealpha = 1 - (time - armor_damagetime)*(time - armor_damagetime); - HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, armor_beforedamage/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * armor_damagealpha, DRAWFLAG_NORMAL); } } prev_armor = armor; } - HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos + armor_offset, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, p_armor/maxarmor, is_vertical, armor_baralign, autocvar_hud_progressbar_armor_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } if(autocvar_hud_panel_healtharmor_text) DrawNumIcon(pos + armor_offset, mySize, armor, "armor", is_vertical, armor_iconalign, HUD_Get_Num_Color(armor, maxarmor), 1); @@ -1614,8 +1591,7 @@ void HUD_HealthArmor(void) mySize_x *= 2; //restore full panel size else if (panel_ar < 1/4) mySize_y *= 2; //restore full panel size - HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, fuel_baralign, autocvar_hud_progressbar_fuel_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } } } @@ -1625,149 +1601,154 @@ void HUD_HealthArmor(void) void HUD_Notify_Push(string icon, string attacker, string victim) { - if(icon != "") - { - --kn_index; - if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; } - notify_times[kn_index] = time; + if (icon == "") + return; + + ++notify_count; + --notify_index; - // icon - if(notify_icon[kn_index]) { strunzone(notify_icon[kn_index]); } - notify_icon[kn_index] = strzone(icon); + if (notify_index == -1) + notify_index = NOTIFY_MAX_ENTRIES-1; - // attacker - if(notify_attackers[kn_index]) { strunzone(notify_attackers[kn_index]); } - notify_attackers[kn_index] = strzone(attacker); + // Free old strings + if (notify_attackers[notify_index]) + strunzone(notify_attackers[notify_index]); - // victim - if(notify_victims[kn_index]) { strunzone(notify_victims[kn_index]); } - notify_victims[kn_index] = strzone(victim); + if (notify_victims[notify_index]) + strunzone(notify_victims[notify_index]); + + if (notify_icons[notify_index]) + strunzone(notify_icons[notify_index]); + + // Allocate new strings + if (victim != "") + { + notify_attackers[notify_index] = strzone(attacker); + notify_victims[notify_index] = strzone(victim); } + else + { + // In case of a notification without a victim, the attacker + // is displayed on the victim's side. Instead of special + // treatment later on, we can simply switch them here. + notify_attackers[notify_index] = string_null; + notify_victims[notify_index] = strzone(attacker); + } + + notify_icons[notify_index] = strzone(icon); + notify_times[notify_index] = time; } void HUD_Notify(void) { - if(!autocvar__hud_configure) - { - if(!autocvar_hud_panel_notify) return; - } + if (!autocvar__hud_configure) + if (!autocvar_hud_panel_notify) + return; HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); - vector pos, mySize; - pos = panel_pos; - mySize = panel_size; - HUD_Panel_DrawBg(1); - if(panel_bg_padding) + + if (!autocvar__hud_configure) + if (notify_count == 0) + return; + + vector pos, size; + pos = panel_pos; + size = panel_size; + + if (panel_bg_padding) { - pos += '1 1 0' * panel_bg_padding; - mySize -= '2 2 0' * panel_bg_padding; + pos += '1 1 0' * panel_bg_padding; + size -= '2 2 0' * panel_bg_padding; } - float entries, height; - entries = bound(1, floor(KN_MAX_ENTRIES * mySize_y/mySize_x), KN_MAX_ENTRIES); - height = mySize_y/entries; + float fade_start = max(0, autocvar_hud_panel_notify_time); + float fade_time = max(0, autocvar_hud_panel_notify_fadetime); + float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect); - vector fontsize; - float fontheight = height * autocvar_hud_panel_notify_fontsize; - fontsize = '0.5 0.5 0' * fontheight; + float entry_count = bound(1, floor(NOTIFY_MAX_ENTRIES * size_y / size_x), NOTIFY_MAX_ENTRIES); + float entry_height = size_y / entry_count; - float a; - float when; - when = autocvar_hud_panel_notify_time; - float fadetime; - fadetime = autocvar_hud_panel_notify_fadetime; + float panel_width_half = size_x * 0.5; + float icon_width_half = entry_height * icon_aspect / 2; + float name_maxwidth = panel_width_half - icon_width_half - size_x * NOTIFY_ICON_MARGIN; - vector pos_attacker, pos_victim, pos_icon; - float width_attacker; + vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize; + vector icon_size = (eX * icon_aspect + eY) * entry_height; + vector icon_left = eX * (panel_width_half - icon_width_half); + vector attacker_right = eX * name_maxwidth; + vector victim_left = eX * (size_x - name_maxwidth); + + vector attacker_pos, victim_pos, icon_pos; string attacker, victim, icon; + float i, j, count, step, limit, alpha; - float i, j, step, limit; - if(autocvar_hud_panel_notify_flip) //order items from the top down + if (autocvar_hud_panel_notify_flip) { + // Order items from the top down i = 0; step = +1; - limit = entries; + limit = entry_count; } - else //order items from the bottom up + else { - i = entries - 1; + // Order items from the bottom up + i = entry_count - 1; step = -1; limit = -1; } - for(j = kn_index; i != limit; i += step, ++j) + for (j = notify_index, count = 0; i != limit; i += step, ++j, ++count) { if(autocvar__hud_configure) { - if (step == +1) - a = i; - else // inverse order - a = entries - 1 - i; - attacker = textShortenToWidth(sprintf(_("Player %d"), a+1), 0.48 * mySize_x - height, fontsize, stringwidth_colors); - victim = textShortenToWidth(sprintf(_("Player %d"), a+2), 0.48 * mySize_x - height, fontsize, stringwidth_colors); - icon = strcat("weapon", get_weaponinfo(WEP_FIRST + mod(floor(a*2.4), WEP_LAST)).netname); - a = bound(0, (when - a) / 4, 1); - goto hud_config_notifyprint; + attacker = sprintf(_("Player %d"), count + 1); + victim = sprintf(_("Player %d"), count + 2); + icon = strcat("weapon", get_weaponinfo(min(WEP_FIRST + count * 2, WEP_LAST)).netname); + alpha = bound(0, 1.2 - count / entry_count, 1); } else { - if (j == KN_MAX_ENTRIES) + if (j == NOTIFY_MAX_ENTRIES) j = 0; - if(notify_times[j] + when > time) - a = 1; - else if(fadetime) + if (notify_times[j] + fade_start > time) + alpha = 1; + else if (fade_time != 0) { - a = bound(0, (notify_times[j] + when + fadetime - time) / fadetime, 1); - if(!a) - { + alpha = bound(0, (notify_times[j] + fade_start + fade_time - time) / fade_time, 1); + if (alpha == 0) break; - } } else - { break; - } attacker = notify_attackers[j]; victim = notify_victims[j]; - icon = notify_icon[j]; + icon = notify_icons[j]; } - //type = notify_deathtype[j]; - //w = DEATH_WEAPONOF(type); - - if(icon != "") + if (icon != "" && victim != "") { - if((attacker != "") && (victim == "")) - { - // Y [used by] X - attacker = textShortenToWidth(attacker, 0.73 * mySize_x - height, fontsize, stringwidth_colors); - pos_attacker = pos + eX * (0.27 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - pos_icon = pos + eX * 0.25 * mySize_x - eX * height + eY * i * height; + vector name_top = eY * (i * entry_height + 0.5 * (entry_height - font_size_y)); - drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); - } - else if((attacker != "") && (victim != "")) + icon_pos = pos + icon_left + eY * i * entry_height; + drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL); + + victim = textShortenToWidth(victim, name_maxwidth, font_size, stringwidth_colors); + victim_pos = pos + victim_left + name_top; + drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); + + if (attacker != "") { - // X [did action to] Y - attacker = textShortenToWidth(attacker, 0.48 * mySize_x - height, fontsize, stringwidth_colors); - victim = textShortenToWidth(victim, 0.48 * mySize_x - height, fontsize, stringwidth_colors); -:hud_config_notifyprint - width_attacker = stringwidth(attacker, TRUE, fontsize); - pos_attacker = pos + eX * (0.48 * mySize_x - height - width_attacker) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - pos_victim = pos + eX * (0.52 * mySize_x + height) + eY * ((0.5 * fontsize_y + i * height) + (0.5 * (height - fontheight))); - pos_icon = pos + eX * 0.5 * mySize_x - eX * height + eY * i * height; - - drawpic_aspect_skin(pos_icon, icon, '2 1 0' * height, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(pos_attacker, attacker, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); - drawcolorcodedstring(pos_victim, victim, fontsize, panel_fg_alpha * a, DRAWFLAG_NORMAL); + attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors); + attacker_pos = pos + attacker_right - eX * stringwidth(attacker, TRUE, font_size) + name_top; + drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); } } } + + notify_count = count; } // Timer (#5) @@ -1790,7 +1771,6 @@ void HUD_Timer(void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); draw_beginBoldFont(); @@ -1854,11 +1834,15 @@ void HUD_Radar(void) { if (autocvar_hud_panel_radar == 0) return; if (autocvar_hud_panel_radar != 2 && !teamplay) return; + if(radar_panel_modified) + { + panel.update_time = time; // forces reload of panel attributes + radar_panel_modified = false; + } } } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); float f = 0; @@ -1870,8 +1854,15 @@ void HUD_Radar(void) 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 - if(precache_pic(panel_bg) == "") { panel_bg = "gfx/hud/default/border_default"; } // fallback + if(precache_pic(panel_bg) == "") + panel_bg = "gfx/hud/default/border_default"; // fallback + if(!radar_panel_modified && panel_bg != panel.current_panel_bg) + radar_panel_modified = true; + if(panel.current_panel_bg) + strunzone(panel.current_panel_bg); + panel.current_panel_bg = strzone(panel_bg); switch(hud_panel_radar_maximized_zoommode) { @@ -2020,7 +2011,7 @@ void HUD_Radar(void) // Score (#7) // void HUD_UpdatePlayerTeams(); -void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count) +void HUD_Score_Rankings(vector pos, vector mySize, entity me) { float score; entity tm = world, pl; @@ -2150,7 +2141,6 @@ void HUD_Score(void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -2211,7 +2201,7 @@ void HUD_Score(void) } else if (!teamplay) { // non-teamgames if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings) { - HUD_Score_Rankings(pos, mySize, me, 0); + HUD_Score_Rankings(pos, mySize, me); return; } // me vector := [team/connected frags id] @@ -2252,23 +2242,21 @@ void HUD_Score(void) drawstring_aspect(pos + eX * 0.75 * mySize_x, distribution_str, eX * 0.25 * mySize_x + eY * (1/3) * mySize_y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL); draw_endBoldFont(); } else { // teamgames - float scores_count = 0, row, column, rows = 0, columns = 0; + float row, column, rows = 0, columns = 0; local noref vector offset = '0 0 0'; vector score_pos, score_size; //for scores other than myteam - if (spectatee_status == -1 || autocvar_hud_panel_score_rankings) + if(autocvar_hud_panel_score_rankings) + { + HUD_Score_Rankings(pos, mySize, me); + return; + } + if(spectatee_status == -1) { - for(tm = teams.sort_next; tm, tm.team != NUM_SPECTATOR; tm = tm.sort_next) - ++scores_count; - if (autocvar_hud_panel_score_rankings) - { - HUD_Score_Rankings(pos, mySize, me, scores_count); - return; - } rows = mySize_y/mySize_x; - rows = bound(1, floor((sqrt(4 * (3/1) * rows * scores_count + rows * rows) + rows + 0.5) / 2), scores_count); + rows = bound(1, floor((sqrt(4 * (3/1) * rows * team_count + rows * rows) + rows + 0.5) / 2), team_count); // ^^^ ammo item aspect goes here - columns = ceil(scores_count/rows); + columns = ceil(team_count/rows); score_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); @@ -2345,7 +2333,6 @@ void HUD_RaceTimer (void) } HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); draw_beginBoldFont(); @@ -2546,7 +2533,6 @@ void HUD_Vote(void) return; HUD_Panel_UpdateCvars(); - HUD_Panel_ApplyFadeAlpha(); if(uid2name_dialog) { @@ -2697,11 +2683,6 @@ void DrawCAItem(vector myPos, vector mySize, float aspect_ratio, float layout, f void HUD_Mod_CA(vector myPos, vector mySize) { mod_active = 1; // required in each mod function that always shows something - entity tm; - float teams_count = 0; - for(tm = teams.sort_next; tm; tm = tm.sort_next) - if(tm.team != NUM_SPECTATOR) - ++teams_count; float layout; if(gametype == MAPINFO_TYPE_CA) @@ -2711,14 +2692,14 @@ void HUD_Mod_CA(vector myPos, vector mySize) float rows, columns, aspect_ratio; rows = mySize_y/mySize_x; aspect_ratio = (layout) ? 2 : 1; - rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count); - columns = ceil(teams_count/rows); + rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count); + columns = ceil(team_count/rows); int i; float row = 0, column = 0; vector pos, itemSize; itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); - for(i=0; i 1) p = 2 - p; - //Draw the filling - HUD_Panel_GetProgressBarColor(nexball); - if(mySize_x > mySize_y) - HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - else - HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", p, (mySize_x <= mySize_y), 0, autocvar_hud_progressbar_nexball_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } if (stat_items & IT_KEY1) @@ -3328,24 +3304,19 @@ void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float layout, void HUD_Mod_Dom(vector myPos, vector mySize) { mod_active = 1; // required in each mod function that always shows something - entity tm; - float teams_count = 0; - for(tm = teams.sort_next; tm; tm = tm.sort_next) - if(tm.team != NUM_SPECTATOR) - ++teams_count; float 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 * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count); - columns = ceil(teams_count/rows); + rows = bound(1, floor((sqrt((4 * aspect_ratio * team_count + rows) * rows) + rows + 0.5) / 2), team_count); + columns = ceil(team_count/rows); int i; float row = 0, column = 0; vector pos, itemSize; itemSize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); - for(i=0; i= 0.96 * vid_conheight) return; @@ -4397,6 +4372,66 @@ void HUD_CenterPrint (void) } } +// Buffs (#18) +// +void HUD_Buffs(void) +{ + float buffs = getstati(STAT_BUFFS, 0, 24); + if(!autocvar__hud_configure) + { + if(!autocvar_hud_panel_buffs) return; + if(spectatee_status == -1) return; + if(getstati(STAT_HEALTH) <= 0) return; + if(!buffs) return; + } + else + { + buffs = Buff_Type_first.items; // force first buff + } + + float 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) + { + ++b; + string o = strcat(rgb_to_hexcolor(Buff_Color(e.items)), Buff_PrettyName(e.items)); + if(s == "") + s = o; + else + s = strcat(s, " ", o); + } + + HUD_Panel_UpdateCvars(); + + draw_beginBoldFont(); + + 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; + //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); + drawcolorcodedstring_aspect(pos + buff_offset, s, mySize, panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); + } + + draw_endBoldFont(); +} + + /* ================== Main HUD system @@ -4424,21 +4459,13 @@ void HUD_Main (void) if(scoreboard_fade_alpha) hud_fade_alpha = (1 - scoreboard_fade_alpha); - if(autocvar__hud_configure) - if(isdemo()) - HUD_Configure_Exit_Force(); + HUD_Configure_Frame(); if(intermission == 2) // no hud during mapvote - { - if (autocvar__hud_configure) - HUD_Configure_Exit_Force(); hud_fade_alpha = 0; - } - else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0) - hud_fade_alpha = 1; // panels that we want to be active together with the scoreboard - // they must call HUD_Panel_ApplyFadeAlpha(); only when showing the menu + // they must fade only when the menu does if(scoreboard_fade_alpha == 1) { (panel = HUD_PANEL(CENTERPRINT)).panel_draw(); @@ -4459,24 +4486,6 @@ void HUD_Main (void) hud_skin_prev = strzone(autocvar_hud_skin); } - // HUD configure visible grid - if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha) - { - hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2); - hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2); - hud_configure_realGridSize_x = hud_configure_gridSize_x * vid_conwidth; - hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight; - vector s; - // x-axis - s = eX + eY * vid_conheight; - for(i = 1; i < 1/hud_configure_gridSize_x; ++i) - drawfill(eX * i * hud_configure_realGridSize_x, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); - // y-axis - s = eY + eX * vid_conwidth; - for(i = 1; i < 1/hud_configure_gridSize_y; ++i) - drawfill(eY * i * hud_configure_realGridSize_y, s, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL); - } - #ifdef COMPAT_XON050_ENGINE current_player = (spectatee_status > 0) ? spectatee_status : player_localentnum; #else @@ -4577,34 +4586,7 @@ void HUD_Main (void) if(autocvar__con_chat_maximized) (panel = HUD_PANEL(CHAT)).panel_draw(); - if(autocvar__hud_configure) - { - if(tab_panel) - { - panel = tab_panel; - HUD_Panel_UpdatePosSize() - drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL); - } - if(highlightedPanel) - { - panel = highlightedPanel; - HUD_Panel_UpdatePosSize() - HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha)); - } - if(!hud_configure_prev || hud_configure_prev == -1) - { - if(autocvar_hud_cursormode) { setcursormode(1); } - hudShiftState = 0; - for(i = HUD_PANEL_NUM - 1; i >= 0; --i) - hud_panel[panel_order[i]].update_time = time; - } - } - else if(hud_configure_prev && hud_configure_prev != -1 && autocvar_hud_cursormode) - setcursormode(0); + HUD_Configure_PostDraw(); hud_configure_prev = autocvar__hud_configure; - - if (!autocvar__hud_configure) // hud config mode disabled, enable normal theAlpha stuff again - if (menu_enabled) - menu_enabled = 0; }