X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2Fhud.qc;h=0852aa6fbad3ae119369ad706ea1c507757bf67a;hb=5ff550251ade0f555e545b1466ac39b5b318dacf;hp=a7283782612620abea5ea5812b3391109d2f1b9c;hpb=b1c5ff13032731b85d6272beee3541b297495b3b;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index a7283782..0852aa6f 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -1684,17 +1684,50 @@ void Sbar_Portrait() { // draws the portrait, using the values set in Ent_ReadPortrait - vector left; + // make the portrait slide in and out of the left edge + float fade_time; + float fade1_start, fade1_end, fade2_start, fade2_end; + float fade_in, fade_out; + + fade_time = cvar("sbar_portrait_time") * bound(0, cvar("sbar_portrait_fade"), 0.5); + + fade1_start = portrait_time + cvar("sbar_portrait_time") - fade_time; + fade1_end = portrait_time + cvar("sbar_portrait_time"); + fade2_start = portrait_time; + fade2_end = portrait_time + fade_time; + + fade_in = bound(0, (time / fade1_end - 1) / (fade1_start / fade1_end - 1), 1); + fade_out = 1 - bound(0, (time / fade2_end - 1) / (fade2_start / fade2_end - 1), 1); + + vector left, fade_pos; left_x = 0; left_y = vid_conheight / 2; + fade_pos_x = -130 * fade_in * fade_out; if(!cvar("sbar_portrait")) return; if(portrait_time + cvar("sbar_portrait_time") >= time) { - drawpic(left + '10 -80 0', portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - drawcolorcodedstring(left + '10 80 0', portrait_name, '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + if(portrait_image && portrait_name) // prevent using bad strings + { + drawpic(left - '120 80 0' - fade_pos, portrait_image, '120 160 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + drawcolorcodedstring(left - '120 -80 0' - fade_pos, textShortenToWidth(portrait_name, 120, '12 12 0', stringwidth_colors), '12 12 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + } + else + { + // free unused strings from memory + if(portrait_image) + { + strunzone(portrait_image); + portrait_image = string_null; + } + if(portrait_name) + { + strunzone(portrait_name); + portrait_name = string_null; + } } } @@ -1982,6 +2015,10 @@ void Sbar_Status() health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5; Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + // if we are dead, we can skip the HUD from here + if(health <= 0) + return; + // ammo pos_x = bottom_x + 140; pos_y = bottom_y - 20; @@ -3085,6 +3122,7 @@ void Sbar_Draw (void) Sbar_DrawScoreboard(); Sbar_Score(); Sbar_Timer(); + Sbar_Portrait(); if(getstati(STAT_VORE_EATEN)) Sbar_Status(); @@ -3114,6 +3152,7 @@ void Sbar_Draw (void) drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_fail", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_fail_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL); power_boot = time + g_power_reboot; + Sbar_Portrait(); // draw the portrait still return; // skip drawing the HUD } else if(time <= power_boot) @@ -3121,6 +3160,7 @@ void Sbar_Draw (void) // subsystems are rebooting drawpic(warn_pos - '128 0 0', "gfx/hud/sb_power_reboot", '256 256 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); drawpic(warn_pos - '16 0 0' + '0 150 0', "gfx/hud/sb_power_reboot_icon", '32 32 0', '1 1 1', sbar_alpha_fg * (0.5 + sin(time * 5) / 2), DRAWFLAG_NORMAL); + Sbar_Portrait(); // draw the portrait still return; // skip drawing the HUD } } @@ -3171,7 +3211,7 @@ void Sbar_Draw (void) status_pos = bottomleft - '-43 168 0'; status_size = 16; } - else if(g_healthsize_center >= 0) // no point in showing it otherwise + else { status_text = strcat(status_color, ftos(stomach_maxload)); status_pos = bottomleft - '-43 170 0'; @@ -3584,12 +3624,11 @@ void Ent_ReadPortrait() pl_skin = ReadByte(); pl_name = ReadString(); - // updating an existent portrait - if(portrait_time) - { + // update existing portraits + if(portrait_name) strunzone(portrait_name); + if(portrait_image) strunzone(portrait_image); - } portrait_time = time; portrait_name = strzone(pl_name);