X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=7acfacb8c428b99d8246db0b10b8f9a3c2db8335;hb=3b318c458364dbf74c3c814d2dbef8655b0d4810;hp=7b5ce7cd22871e7c27af58e2308864ceb93cfef7;hpb=22042893e4c8ce0f178043ace460c7831c3df4d2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 7b5ce7cd2..7acfacb8c 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -431,40 +431,58 @@ float GetAmmoTypeForWep(float i) void HUD_Weapons(void) { - float i, f, screen_ar; - float center_x, center_y; - if(hud != HUD_NORMAL) return; + // declarations + float weapons_stat = getstati(STAT_WEAPONS); + float i, f, a, j, factor; + float screen_ar, center_x, center_y; + float weapon_count, weapon_id, weapon_alpha; + float row, column, rows, columns; + float aspect = autocvar_hud_panel_weapons_aspect; + + float show_accuracy, panel_weapon_accuracy; + + float timeout = autocvar_hud_panel_weapons_timeout; + float timein_effect_length = (autocvar_hud_panel_weapons_timeout_effect ? 0.375 : 0); + float timeout_effect_length = (autocvar_hud_panel_weapons_timeout_effect ? 0.75 : 0); + + float ammo_type, ammo_full, ammo_alpha; + float barsize_x, barsize_y, baroffset_x, baroffset_y; + + float when = autocvar_hud_panel_weapons_complainbubble_time; + float fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime; + + vector weapon_pos, weapon_size; + vector old_panel_size; + vector color, ammo_color; + + // check to see if we want to continue + if(hud != HUD_NORMAL) { return; } + if(!autocvar__hud_configure) - { - if(!autocvar_hud_panel_weapons) return; - if(spectatee_status == -1) return; - } + if((!autocvar_hud_panel_weapons) || (spectatee_status == -1)) + return; + else if(timeout && time >= weapontime + timeout + timeout_effect_length) + { + weaponprevtime = time; + return; + } else hud_configure_active_panel = HUD_PANEL_WEAPONS; - float timeout = autocvar_hud_panel_weapons_timeout; - float timeout_effect_length, timein_effect_length; - if (autocvar_hud_panel_weapons_timeout_effect == 0) + // update generic hud functions + HUD_Panel_UpdateCvars(weapons); + HUD_Panel_ApplyFadeAlpha(); + + // calculate fading effect to weapon images for when the panel is idle + if(autocvar_hud_panel_weapons_fade) { - timeout_effect_length = 0; - timein_effect_length = 0; + weapon_alpha = 3.2 - 2 * (time - weapontime); + weapon_alpha = bound(0.7, weapon_alpha, 1) * panel_fg_alpha; } else - { - timeout_effect_length = 0.75; - timein_effect_length = 0.375; - } + weapon_alpha = panel_fg_alpha; - if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure) - { - weaponprevtime = time; - return; - } - - HUD_Panel_UpdateCvars(weapons); - HUD_Panel_ApplyFadeAlpha(); - - // TODO make this configurable + // figure out weapon order (how the weapons are sorted) // TODO make this configurable if(weaponorder_bypriority != autocvar_cl_weaponpriority || !weaponorder[0]) { float weapon_cnt; @@ -493,33 +511,34 @@ void HUD_Weapons(void) weaponorder_cmp_str = string_null; } - - float when, fadetime; - when = autocvar_hud_panel_weapons_complainbubble_time; - fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime; - float weapons_st = getstati(STAT_WEAPONS); - float weapon_count; + + // determine which weapons are going to be shown if (autocvar_hud_panel_weapons_onlyowned) { if(autocvar__hud_configure) { - if (weapons_st == 0) + if (weapons_stat == 0) // create some fake weapons anyway for(i = 0; i <= WEP_LAST-WEP_FIRST; i += floor((WEP_LAST-WEP_FIRST)/5)) - weapons_st |= power2of(i); + weapons_stat |= power2of(i); + if(menu_enabled != 2) HUD_Panel_DrawBg(1); // also draw the bg of the entire panel } - - vector old_panel_size; + + // do we own this weapon? for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i) - { - if(weapons_st & weaponorder[i].weapons) + if(weapons_stat & weaponorder[i].weapons) ++weapon_count; - } - if(!autocvar__hud_configure && (autocvar_hud_panel_weapons_complainbubble && time - complain_weapon_time < when + fadetime))// && complain_weapon >= 0 - ++weapon_count; - if (weapon_count == 0) - return; + + // add it anyway if weaponcomplain is shown + if((!autocvar__hud_configure) + && (autocvar_hud_panel_weapons_complainbubble + && time - complain_weapon_time < when + fadetime)) + ++weapon_count; + + // might as well commit suicide now, no reason to live ;) + if (weapon_count == 0) { return; } + // reduce size of the panel if (panel_size_y > panel_size_x) { @@ -537,126 +556,107 @@ void HUD_Weapons(void) else weapon_count = WEP_COUNT; - if (timeout && time >= weapontime + timeout && !autocvar__hud_configure) + // animation for fading in/out the panel respectively when not in use + if(!autocvar__hud_configure) { - f = (time - (weapontime + timeout)) / timeout_effect_length; - if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3) - { - panel_bg_alpha *= (1 - f); - panel_fg_alpha *= (1 - f); - } - if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3) + if (timeout && time >= weapontime + timeout) // apply timeout effect if needed { - f *= f; // for a cooler movement - 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 + f = (time - (weapontime + timeout)) / timeout_effect_length; + if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3) { - if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom - panel_pos_y += f * (vid_conheight - panel_pos_y); - else //left - panel_pos_x -= f * (panel_pos_x + panel_size_x); + panel_bg_alpha *= (1 - f); + panel_fg_alpha *= (1 - f); } - else //top right + if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3) { - if ((vid_conwidth - center_x)/center_y < screen_ar) //right - panel_pos_x += f * (vid_conwidth - panel_pos_x); - else //top - panel_pos_y -= f * (panel_pos_y + panel_size_y); + f *= f; // for a cooler movement + 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 + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom + panel_pos_y += f * (vid_conheight - panel_pos_y); + else //left + panel_pos_x -= f * (panel_pos_x + panel_size_x); + } + else //top right + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //right + panel_pos_x += f * (vid_conwidth - panel_pos_x); + else //top + panel_pos_y -= f * (panel_pos_y + panel_size_y); + } } + weaponprevtime = time - (1 - f) * timein_effect_length; } - weaponprevtime = time - (1 - f) * timein_effect_length; - } - else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure) - { - f = (time - weaponprevtime) / timein_effect_length; - if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3) - { - panel_bg_alpha *= (f); - panel_fg_alpha *= (f); - } - if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3) + else if (timeout && time < weaponprevtime + timein_effect_length) // apply timein effect if needed { - 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; - screen_ar = vid_conwidth/vid_conheight; - if (center_x/center_y < screen_ar) //bottom left + f = (time - weaponprevtime) / timein_effect_length; + if (autocvar_hud_panel_weapons_timeout_effect == 1 || autocvar_hud_panel_weapons_timeout_effect == 3) { - if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom - panel_pos_y += f * (vid_conheight - panel_pos_y); - else //left - panel_pos_x -= f * (panel_pos_x + panel_size_x); + panel_bg_alpha *= (f); + panel_fg_alpha *= (f); } - else //top right + if (autocvar_hud_panel_weapons_timeout_effect == 2 || autocvar_hud_panel_weapons_timeout_effect == 3) { - if ((vid_conwidth - center_x)/center_y < screen_ar) //right - panel_pos_x += f * (vid_conwidth - panel_pos_x); - else //top - panel_pos_y -= f * (panel_pos_y + panel_size_y); + 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; + screen_ar = vid_conwidth/vid_conheight; + if (center_x/center_y < screen_ar) //bottom left + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom + panel_pos_y += f * (vid_conheight - panel_pos_y); + else //left + panel_pos_x -= f * (panel_pos_x + panel_size_x); + } + else //top right + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //right + panel_pos_x += f * (vid_conwidth - panel_pos_x); + else //top + panel_pos_y -= f * (panel_pos_y + panel_size_y); + } } } } + // draw the background, then change the virtual size of it to better fit other items inside HUD_Panel_DrawBg(1); if(panel_bg_padding) { panel_pos += '1 1 0' * panel_bg_padding; - panel_size -= '2 2 0' * panel_bg_padding; + panel_size -= '1 1 0' * panel_bg_padding; } - float weapid, wpnalpha; - - if(autocvar_hud_panel_weapons_fade) - { - wpnalpha = 3.2 - 2 * (time - weapontime); - wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha; - } - else - wpnalpha = panel_fg_alpha; - - float rows, columns; - float aspect = autocvar_hud_panel_weapons_aspect; + // after the sizing and animations are done, update the other values 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); - float row, column; - - float a, type, fullammo; - - vector color; - vector wpnpos; - vector wpnsize; - - vector ammo_color; - float ammo_alpha; - wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows); - float barsize_x, barsize_y, baroffset_x, baroffset_y; + weapon_size = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows); + + // calculate position/size for visual bar displaying ammount of ammo status if (autocvar_hud_panel_weapons_ammo) { ammo_color = stov(autocvar_hud_panel_weapons_ammo_color); ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha; - - if(wpnsize_x/wpnsize_y > aspect) + if(weapon_size_x/weapon_size_y > aspect) { - barsize_x = aspect * wpnsize_y; - barsize_y = wpnsize_y; - baroffset_x = (wpnsize_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 * wpnsize_x; - barsize_x = wpnsize_x; - baroffset_y = (wpnsize_y - barsize_y) / 2; + barsize_y = 1/aspect * weapon_size_x; + barsize_x = weapon_size_x; + baroffset_y = (weapon_size_y - barsize_y) / 2; } } - float show_accuracy; - float weapon_stats; if(autocvar_hud_panel_weapons_accuracy && acc_levels) { show_accuracy = true; @@ -667,105 +667,117 @@ void HUD_Weapons(void) for(i = 0; i <= WEP_LAST-WEP_FIRST; ++i) { + // retrieve information about the current weapon to be drawn self = weaponorder[i]; - if (!self || self.impulse < 0) - continue; - if (autocvar_hud_panel_weapons_onlyowned) - if (!((weapons_st & self.weapons) || (self.weapon == complain_weapon && time - complain_weapon_time < when + fadetime && autocvar_hud_panel_weapons_complainbubble))) - continue; - wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y; - - weapid = self.impulse; + weapon_id = self.impulse; + + // skip if this weapon doesn't exist + if (!self || self.impulse < 0) { continue; } + + // skip this weapon if we don't own it (and onlyowned is enabled)-- or if weapons_complainbubble is showing for this weapon + if (autocvar_hud_panel_weapons_onlyowned + && !((weapons_stat & self.weapons) + || (self.weapon == complain_weapon + && time - complain_weapon_time < when + fadetime + && autocvar_hud_panel_weapons_complainbubble))) + continue; + + // figure out the drawing position of weapon + weapon_pos = (panel_pos + + eX * column * weapon_size_x + + eY * row * weapon_size_y); // draw background behind currently selected weapon if(self.weapon == switchweapon) - drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(weapon_pos, "weapon_current_bg", weapon_size, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL); // draw the weapon accuracy if(show_accuracy) { - weapon_stats = weapon_accuracy[self.weapon-WEP_FIRST]; - if(weapon_stats >= 0) + panel_weapon_accuracy = weapon_accuracy[self.weapon-WEP_FIRST]; + if(panel_weapon_accuracy >= 0) { - // find the max level lower than weapon_stats - float j; + // find the max level lower than weapon_accuracy j = acc_levels-1; - while ( j && weapon_stats < acc_lev[j] ) + while ( j && panel_weapon_accuracy < acc_lev[j] ) --j; - // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j - float factor; - factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]); + // inject color j+1 in color j, how much depending on how much weapon_accuracy is higher than level j + factor = (panel_weapon_accuracy - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]); color = acc_col[j]; color = color + factor * (acc_col[j+1] - color); - drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(weapon_pos, "weapon_accuracy", weapon_size, color, panel_fg_alpha, DRAWFLAG_NORMAL); } } - // draw the weapon icon - if(weapons_st & self.weapons) + // drawing all the weapon items + if(weapons_stat & self.weapons) { - drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL); - - if(autocvar_hud_panel_weapons_label == 1) // weapon number - drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - else if(autocvar_hud_panel_weapons_label == 2) // bind - drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + // draw the weapon image + drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL); + // draw weapon label string + switch(autocvar_hud_panel_weapons_label) + { + case 1: // weapon number + drawstring(weapon_pos, ftos(weapon_id), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + break; + + case 2: // bind + drawstring(weapon_pos, getcommandkey(ftos(weapon_id), strcat("impulse ", ftos(weapon_id))), '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + break; + + case 3: // weapon name + drawstring(weapon_pos, self.netname, '1 1 0' * 0.5 * weapon_size_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + break; + + default: // nothing + break; + } + // draw ammo status bar if(autocvar_hud_panel_weapons_ammo && self.weapon != WEP_TUBA && self.weapon != WEP_LASER && self.weapon != WEP_PORTO) { a = 0; - type = GetAmmoTypeForWep(self.weapon); - if(type != -1) - a = getstati(GetAmmoStat(type)); // how much ammo do we have? + ammo_type = GetAmmoTypeForWep(self.weapon); + if(ammo_type != -1) + a = getstati(GetAmmoStat(ammo_type)); // how much ammo do we have? if(a > 0) { - switch(type) { - case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break; - case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break; - case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break; - case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break; - case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break; - default: fullammo = 60; + switch(ammo_type) { + case 0: ammo_full = autocvar_hud_panel_weapons_ammo_full_shells; break; + case 1: ammo_full = autocvar_hud_panel_weapons_ammo_full_nails; break; + case 2: ammo_full = autocvar_hud_panel_weapons_ammo_full_rockets; break; + case 3: ammo_full = autocvar_hud_panel_weapons_ammo_full_cells; break; + case 4: ammo_full = autocvar_hud_panel_weapons_ammo_full_fuel; break; + default: ammo_full = 60; } drawsetcliparea( - wpnpos_x + baroffset_x, - wpnpos_y + baroffset_y, - barsize_x * bound(0, a/fullammo, 1), + weapon_pos_x + baroffset_x, + weapon_pos_y + baroffset_y, + barsize_x * bound(0, a/ammo_full, 1), barsize_y); - drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, ammo_color, ammo_alpha, DRAWFLAG_NORMAL); + drawpic_aspect_skin(weapon_pos, "weapon_ammo", weapon_size, ammo_color, ammo_alpha, DRAWFLAG_NORMAL); drawresetcliparea(); } } } - - // draw a "ghost weapon icon" if you don't have the weapon - else + else // draw a "ghost weapon icon" if you don't have the weapon { - drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); + drawpic_aspect_skin(weapon_pos, strcat("weapon", self.netname), weapon_size, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL); } - + // draw the complain message if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble) { if(fadetime) - { - if(complain_weapon_time + when > time) - a = 1; - else - a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1); - } + a = ((complain_weapon_time + when > time) ? 1 : bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1)); else - { - if(complain_weapon_time + when > time) - a = 1; - else - a = 0; - } + a = ((complain_weapon_time + when > time) ? 1 : 0); + string s; if(complain_weapon_type == 0) { @@ -781,10 +793,11 @@ void HUD_Weapons(void) color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable); } float padding = autocvar_hud_panel_weapons_complainbubble_padding; - drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); + drawpic_aspect_skin(weapon_pos + '1 1 0' * padding, "weapon_complainbubble", weapon_size - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring_aspect(weapon_pos + '1 1 0' * padding, s, weapon_size - '2 2 0' * padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL); } + // continue with new position for the next weapon ++row; if(row >= rows) { @@ -792,7 +805,6 @@ void HUD_Weapons(void) ++column; } } - } // Ammo (#1) @@ -1789,10 +1801,55 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s else print (sprintf(_("^1%s^1 is now conserved for centuries to come\n"), s1)); } - } else if(type == DEATH_TURRET) { + } else if(DEATH_ISTURRET(type)) { HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC); if(alsoprint) - print (sprintf(_("^1%s^1 was mowed down by a turret \n"), s1)); + { + if(gentle) + print (sprintf(_("^1%s^1 ran into a turret\n"), s1)); + else + { + switch(type) + { + case DEATH_TURRET_EWHEEL: + print (sprintf(_("^1%s^1 was laserd down by a eWheel turret \n"), s1)); + break; + case DEATH_TURRET_FLAC: + print (sprintf(_("^1%s^1 got caught in the flac \n"), s1)); + break; + case DEATH_TURRET_MACHINEGUN: + print (sprintf(_("^1%s^1 was riddeld full of riddled by a machinegun turret \n"), s1)); + break; + case DEATH_TURRET_WALKER_GUN: + print (sprintf(_("^1%s^1 got served a led enrichment by a walker turret \n"), s1)); + break; + case DEATH_TURRET_WALKER_MEELE: + print (sprintf(_("^1%s^1 was impaled by a walker turret \n"), s1)); + break; + case DEATH_TURRET_WALKER_ROCKET: + print (sprintf(_("^1%s^1 was rocketed to hell by a walker turret \n"), s1)); + break; + case DEATH_TURRET_HELLION: + print (sprintf(_("^1%s^1 was blasted away hellion turret \n"), s1)); + break; + case DEATH_TURRET_HK: + print (sprintf(_("^1%s^1 could not hide from the hunter turret \n"), s1)); + break; + case DEATH_TURRET_MLRS: + print (sprintf(_("^1%s^1 got turned into smoldering gibs by a mlrs turret \n"), s1)); + break; + case DEATH_TURRET_PLASMA: + print (sprintf(_("^1%s^1 got served some superheated plasma from a plasma turret \n"), s1)); + break; + case DEATH_TURRET_PHASER: + print (sprintf(_("^1%s^1 was phased out \n"), s1)); + break; + case DEATH_TURRET_TESLA: + print (sprintf(_("^1%s^1 was electrocuted by a tesla turret \n"), s1)); + break; + } + } + } } else if (type == DEATH_CUSTOM) { HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM); if(alsoprint) @@ -2339,14 +2396,34 @@ void HUD_Radar(void) { if (!autocvar__hud_configure) { - if (autocvar_hud_panel_radar == 0) return; - if (autocvar_hud_panel_radar != 2 && !teamplay) return; + if (hud_panel_radar_maximized) + { + if (!hud_draw_maximized) return; + } + else + { + if (autocvar_hud_panel_radar == 0) return; + if (autocvar_hud_panel_radar != 2 && !teamplay) return; + } } else hud_configure_active_panel = HUD_PANEL_RADAR; HUD_Panel_UpdateCvars(radar); HUD_Panel_ApplyFadeAlpha(); + + 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_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 + } + vector pos, mySize; pos = panel_pos; mySize = panel_size; @@ -2358,8 +2435,8 @@ void HUD_Radar(void) mySize -= '2 2 0' * panel_bg_padding; } - local float color2; - local entity tm; + float color2; + entity tm; float scale2d, normalsize, bigsize; float f; @@ -2471,15 +2548,15 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count) entity tm, pl; #define SCOREPANEL_MAX_ENTRIES 6 #define SCOREPANEL_ASPECTRATIO 2 - const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES); - const vector fontsize = '1 1 0' * (mySize_y/entries); + float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES); + vector fontsize = '1 1 0' * (mySize_y/entries); vector rgb, score_color; rgb = '1 1 1'; score_color = '1 1 1'; - const float name_size = mySize_x*0.75; - const float spacing_size = mySize_x*0.04; + float name_size = mySize_x*0.75; + float spacing_size = mySize_x*0.04; const float highlight_alpha = 0.2; float i, me_printed, first_pl; string s; @@ -2929,7 +3006,7 @@ float vote_change; // "time" when vote_active changed void HUD_VoteWindow(void) { - if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE)) + if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE || (serverflags & SERVERFLAG_PLAYERSTATS))) { vote_active = 1; if (autocvar__hud_configure) @@ -2939,7 +3016,9 @@ void HUD_VoteWindow(void) print(_("^1You must answer before entering hud configure mode\n")); cvar_set("_hud_configure", "0"); } - vote_called_vote = strzone(_("^2Name ^7instead of \"^1Unregistered player^7\" in stats")); + if(vote_called_vote) + strunzone(vote_called_vote); + vote_called_vote = strzone(_("^2Name ^7instead of \"^1Anonymous player^7\" in stats")); uid2name_dialog = 1; } @@ -3847,6 +3926,8 @@ void HUD_Chat(void) cvar_set("con_chatrect", "0"); return; } + if(autocvar__con_chat_maximized) + if(!hud_draw_maximized) return; } else hud_configure_active_panel = HUD_PANEL_CHAT; @@ -4277,7 +4358,7 @@ void HUD_Physics(void) speed_baralign = (autocvar_hud_panel_physics_baralign == 2); acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3); } - if (autocvar_hud_panel_physics_acceleration_progressbar_mode == 0) + if (autocvar_hud_panel_physics_acceleration_mode == 0) acceleration_baralign = 3; //override hud_panel_physics_baralign value for acceleration //draw speed @@ -4400,7 +4481,6 @@ float centerprint_msgID[CENTERPRINT_MAX_MSGS]; float centerprint_time[CENTERPRINT_MAX_MSGS]; float centerprint_expire_time[CENTERPRINT_MAX_MSGS]; float centerprint_countdown_num[CENTERPRINT_MAX_MSGS]; -float centerprint_fadetime; float centerprint_showing; void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num) @@ -4433,8 +4513,6 @@ void centerprint_generic(float new_id, string strMessage, float duration, float if (!centerprint_showing) centerprint_showing = TRUE; - centerprint_fadetime = bound(0, autocvar_hud_panel_centerprint_fadetime, 1); - for (i=0, j=cpm_index; i time + centerprint_fadetime || centerprint_expire_time[j] < time) - centerprint_expire_time[j] = time + centerprint_fadetime; + centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out); + if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time) + centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out); return; } break; // found a msg with the same id, at position j @@ -4537,9 +4615,14 @@ void HUD_CenterPrint (void) if (scoreboard_bottom >= 0.96 * vid_conheight) return; vector target_pos; + target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x); - panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha); - panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom); + + 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); + } } HUD_Panel_DrawBg(1); @@ -4589,22 +4672,32 @@ void HUD_CenterPrint (void) else continue; } - if (centerprint_time[j] < 0 || centerprint_expire_time[j] - centerprint_fadetime > time) - { - a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / centerprint_fadetime, 1); - sz = 0.8 + a * (1 - 0.8); - } + + // fade the centerprint in/out + if (centerprint_time[j] < 0 || centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) + a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1); else if (centerprint_expire_time[j] > time) + a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out); + + // set the size from fading in/out before subsequent fading + sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize); + + // also fade it based on positioning + if(autocvar_hud_panel_centerprint_fade_subsequent) { - a = (centerprint_expire_time[j] - time) / centerprint_fadetime; - sz = 0.8 + a * (1 - 0.8); + a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half alpha + a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower alpha even more for each message } - + + // finally set the size based on the new alpha from subsequent fading + sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize)); drawfontscale = sz * '1 1 0'; + if (centerprint_countdown_num[j]) n = tokenizebyseparator(sprintf(centerprint_messages[j], centerprint_countdown_num[j]), "\n"); else n = tokenizebyseparator(centerprint_messages[j], "\n"); + if (autocvar_hud_panel_centerprint_flip) { // check if the message can be entirely shown @@ -4618,12 +4711,6 @@ void HUD_CenterPrint (void) pos_y -= fontsize_y; else pos_y -= fontsize_y * CENTERPRINT_SPACING/2; - // NOTE: uncommented so as to not reject messages whenever they are "too large" -- This just continues drawing it anyway. - //if (pos_y < panel_pos_y) // check if the next line can be shown - //{ - // drawfontscale = '1 1 0'; - // return; - //} } } current_msg_pos_y = pos_y; // save starting pos (first line) of the current message @@ -4645,12 +4732,6 @@ void HUD_CenterPrint (void) } else pos_y += fontsize_y * CENTERPRINT_SPACING/2; - // NOTE: uncommented so as to not reject messages whenever they are "too large" -- This just continues drawing it anyway. - //if (!autocvar_hud_panel_centerprint_flip && pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown - //{ - // drawfontscale = '1 1 0'; - // return; - //} } } msg_size = pos_y - msg_size; @@ -4658,13 +4739,25 @@ void HUD_CenterPrint (void) { pos_y = current_msg_pos_y - 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(a)); + pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz)); + + if (pos_y < panel_pos_y) // check if the next message can be shown + { + drawfontscale = '1 1 0'; + return; + } } else { pos_y += 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(a)); + pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(sz)); + + if(pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next message can be shown + { + drawfontscale = '1 1 0'; + return; + } } } drawfontscale = '1 1 0'; @@ -4872,15 +4965,17 @@ void HUD_Main (void) } } + hud_draw_maximized = 0; // draw panels in order specified by panel_order array - for(i = HUD_PANEL_NUM - 1; i >= 0; --i) { - if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice! - HUD_DrawPanel(panel_order[i]); - } + for(i = HUD_PANEL_NUM - 1; i >= 0; --i) + HUD_DrawPanel(panel_order[i]); - // draw chat panel on top if it is maximized + hud_draw_maximized = 1; // panels that may be maximized must check this var + // draw maximized panels on top + if(hud_panel_radar_maximized) + HUD_Radar(); if(autocvar__con_chat_maximized) - HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT); + HUD_Chat(); if(autocvar__hud_configure) {