From: terencehill Date: Sat, 4 Dec 2010 17:47:04 +0000 (+0100) Subject: Merge notes, PLEASE READ: X-Git-Tag: xonotic-v0.5.0~373 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=ab52427d751a4d99e55504aadae01a2d3526dd36 Merge notes, PLEASE READ: I kept these 2 changes of mine: - draw_ButtonPicture algorithm to draw progressbars as it's better than current algorithm (it uses drawsetcliparea but still stretches the image borders, which is bad) - consecutive numbers for *_baralign and *_iconalign because there's no gain jumping a number (see code: mod operation is not used at all) and they're potentially confusing (I had troubles handling these weird values (the cvar description was wrong... :( ), that's why I made this change) Merge branch 'master' into terencehill/newpanelhud Conflicts: qcsrc/client/hud.qc --- ab52427d751a4d99e55504aadae01a2d3526dd36 diff --cc hud_luminos.cfg index 45e7231194,8a946578f7..ace033c41a --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@@ -68,9 -72,12 +72,12 @@@ seta hud_panel_powerups_bg_alpha " seta hud_panel_powerups_bg_border "" seta hud_panel_powerups_bg_padding "" seta hud_panel_powerups_flip "1" -seta hud_panel_powerups_iconalign "4" -seta hud_panel_powerups_baralign "4" +seta hud_panel_powerups_iconalign "3" +seta hud_panel_powerups_baralign "3" seta hud_panel_powerups_progressbar "1" + seta hud_panel_powerups_progressbar_strength "progressbar" + seta hud_panel_powerups_progressbar_shield "progressbar" + seta hud_panel_powerups_text "1" seta hud_panel_healtharmor 1 seta hud_panel_healtharmor_pos "0.330000 0.920000" @@@ -82,9 -89,12 +89,12 @@@ seta hud_panel_healtharmor_bg_alpha " seta hud_panel_healtharmor_bg_border "" seta hud_panel_healtharmor_bg_padding "" seta hud_panel_healtharmor_flip "0" -seta hud_panel_healtharmor_iconalign "4" -seta hud_panel_healtharmor_baralign "4" +seta hud_panel_healtharmor_iconalign "3" +seta hud_panel_healtharmor_baralign "3" seta hud_panel_healtharmor_progressbar "1" + seta hud_panel_healtharmor_progressbar_health "progressbar" + seta hud_panel_healtharmor_progressbar_armor "progressbar" + seta hud_panel_healtharmor_text "1" seta hud_panel_notify 1 seta hud_panel_notify_pos "0.660000 0.730000" diff --cc qcsrc/client/hud.qc index bf08ad33de,398df4f016..ff28378412 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@@ -553,48 -566,25 +566,47 @@@ if(highlightedPanel_prev == active_pane HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\ } ENDS_WITH_CURLY_BRACE -void HUD_Panel_DrawProgressBar(vector pos, vector mySize, string pic, float vertical, float barflip, float x, vector color, float alpha, float drawflag) +//basically the same code of draw_ButtonPicture and draw_VertButtonPicture for the menu - void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, float lenght_ratio, float vertical, float right_align, vector theColor, float theAlpha, float drawflag) ++void HUD_Panel_DrawProgressBar(vector theOrigin, vector theSize, string pic, float lenght_ratio, float vertical, float right_align, vector theColor, float theAlpha, float drawflag) { - if(!alpha || x == 0) + if(lenght_ratio <= 0 || !theAlpha) return; + if(lenght_ratio > 1) + lenght_ratio = 1; - string pic; - x = bound(0, x, 1); - + vector square; + vector width, height; if(vertical) { - pic = strcat(hud_skin_path, "/statusbar_vertical"); + pic = strcat(hud_skin_path, "/", pic, "_vertical"); if(precache_pic(pic) == "") { pic = "gfx/hud/default/statusbar_vertical"; } - if(barflip) - drawsetcliparea(pos_x, pos_y + mySize_y * (1 - x), mySize_x, mySize_y * x); - else - drawsetcliparea(pos_x, pos_y, mySize_x, mySize_y * x); + if (right_align) + theOrigin_y += (1 - lenght_ratio) * theSize_y; + theSize_y *= lenght_ratio; + + vector bH; + width = eX * theSize_x; + height = eY * theSize_y; + if(theSize_y <= theSize_x * 2) + { + // button not high enough + // draw just upper and lower part then + square = eY * theSize_y * 0.5; + bH = eY * (0.25 * theSize_y / (theSize_x * 2)); + drawsubpic(theOrigin, square + width, pic, '0 0 0', eX + bH, theColor, theAlpha, drawflag); + drawsubpic(theOrigin + square, square + width, pic, eY - bH, eX + bH, theColor, theAlpha, drawflag); + } + else + { + square = eY * theSize_x; + drawsubpic(theOrigin, width + square, pic, '0 0 0', '1 0.25 0', theColor, theAlpha, drawflag); + drawsubpic(theOrigin + square, theSize - 2 * square, pic, '0 0.25 0', '1 0.5 0', theColor, theAlpha, drawflag); + drawsubpic(theOrigin + height - square, width + square, pic, '0 0.75 0', '1 0.25 0', theColor, theAlpha, drawflag); + } } else { - pic = strcat(hud_skin_path, "/statusbar"); + pic = strcat(hud_skin_path, "/", pic); if(precache_pic(pic) == "") { pic = "gfx/hud/default/statusbar"; } @@@ -1930,10 -1915,16 +1942,16 @@@ void DrawAmmoItem(vector myPos, vector if (currently_selected) drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - if(a > 0) - drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); - else // "ghost" ammo count - drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL); + if(a > 0 && cvar("hud_panel_ammo_progressbar")) - HUD_Panel_DrawProgressBar(myPos + eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, mySize - eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, cvar_string("hud_panel_ammo_progressbar_name"), 0, 0, min(1, a/cvar("hud_panel_ammo_maxammo")), color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(myPos + eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, mySize - eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, cvar_string("hud_panel_ammo_progressbar_name"), 0, 0, a/cvar("hud_panel_ammo_maxammo"), color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL); + + if(cvar("hud_panel_ammo_text")) + { + if(a > 0) + drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); + else // "ghost" ammo count + drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL); + } if(a > 0) drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL); else // "ghost" ammo icon @@@ -2149,15 -2119,18 +2167,17 @@@ void HUD_Powerups(void) mySize -= '2 2 0' * panel_bg_padding; } -- vector barpos, barsize; ++ vector barsize; vector picpos; vector numpos; string leftname, rightname; + string leftprogressname, rightprogressname; float leftcnt, rightcnt; float leftexact, rightexact; - float flip = cvar("hud_panel_powerups_flip"); - if (flip) { + if (cvar("hud_panel_powerups_flip")) { leftname = "strength"; + leftprogressname = cvar_string("hud_panel_powerups_progressbar_strength"); leftcnt = ceil(strength_time); leftexact = strength_time; @@@ -2176,64 -2152,174 +2199,80 @@@ drawfont = hud_bigfont; float baralign = cvar("hud_panel_powerups_baralign"); - float barflip; float iconalign = cvar("hud_panel_powerups_iconalign"); float progressbar = cvar("hud_panel_powerups_progressbar"); - if (mySize_x/mySize_y > 4) + float panel_ar = mySize_x/mySize_y; + float is_vertical = (panel_ar < 1); + if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1)) { + barsize = eX * 0.5 * mySize_x + eY * mySize_y; if(leftcnt) { - if(baralign == 1 || baralign == 3) { // right align - barpos = pos + eX * 0.5 * mySize_x; - barflip = 1; - } else { // left align - barpos = pos; - barflip = 0; - } - if(progressbar) { HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); - } - if(cvar("hud_panel_powerups_text")) - { - if(leftcnt > 1) - DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1); - if(leftcnt <= 5) - DrawNumIcon_expanding(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); - } - } - - if(rightcnt) - { - if(baralign == 0 || baralign == 3) { // left align - barpos = pos; - barflip = 0; - } else { // right align - barpos = pos + eX * 0.5 * mySize_x; - barflip = 1; - } - - if(progressbar) - { - HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); + } + if(cvar("hud_panel_powerups_text")) + { - if(rightcnt > 1) - DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1); - if(rightcnt <= 5) - DrawNumIcon_expanding(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); - } - } - } - else if (mySize_x/mySize_y > 1.5) - { - barsize = eX * mySize_x + eY * 0.5 * mySize_y; - if(leftcnt) - { - barpos = pos; - if(baralign == 1 || baralign == 3) { // right/down align - barflip = 1; - } else { // left/up align - barflip = 0; - } - - if(progressbar) - { - HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); ++ if(leftcnt > 1) ++ DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1); ++ if(leftcnt <= 5) ++ DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); } - if(leftcnt > 1) - DrawNumIcon(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1); - if(leftcnt <= 5) - DrawNumIcon_expanding(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); - if(cvar("hud_panel_powerups_text")) - { - if(leftcnt > 1) - DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1); - if(leftcnt <= 5) - DrawNumIcon_expanding(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); - } } if(rightcnt) { - barpos = pos + eY * 0.5 * mySize_y; - if(baralign == 0 || baralign == 3) { // left align - barflip = 0; - } else { // right align - barflip = 1; - } - ++ pos_x += barsize_x; if(progressbar) { HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); + } + if(cvar("hud_panel_powerups_text")) + { - if(rightcnt > 1) - DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1); - if(rightcnt <= 5) - DrawNumIcon_expanding(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); - } ++ if(rightcnt > 1) ++ DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1); ++ if(rightcnt <= 5) ++ DrawNumIcon_expanding(pos, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); + } - if(rightcnt > 1) - DrawNumIcon(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1); - if(rightcnt <= 5) - DrawNumIcon_expanding(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); } } else { - barsize = eX * 0.5 * mySize_x + eY * mySize_y; ++ barsize = eX * mySize_x + eY * 0.5 * mySize_y; if(leftcnt) { - barpos = pos; - if(baralign == 1 || baralign == 3) { // down align - barflip = 1; - } else { // up align - barflip = 0; - } - - if(iconalign == 1 || iconalign == 3) { // down align - picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x); - numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x; - } else { // up align - picpos = pos + eX * 0.05 * mySize_x; - numpos = pos + eY * 0.4 * mySize_x; - } - if(progressbar) { HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 1, barflip, min(1, leftcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); + } + if(cvar("hud_panel_powerups_text")) + { - if(leftcnt <= 5) - drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1)); - if(leftcnt > 1) - drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - } ++ if(leftcnt > 1) ++ DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1); ++ if(leftcnt <= 5) ++ DrawNumIcon_expanding(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); + } - if(leftcnt > 1) - DrawNumIcon(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1); - if(leftcnt <= 5) - DrawNumIcon_expanding(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1)); } if(rightcnt) { - barpos = pos + eX * 0.5 * mySize_x; - if(baralign == 0 || baralign == 3) { // down align - barflip = 1; - } else { // up align - barflip = 0; - } - - if(iconalign == 0 || iconalign == 3) { // up align - picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x; - numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x; - } else { // down align - picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x) + eX * 0.5 * mySize_x; - numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x; - } - ++ pos_y += barsize_y; if(progressbar) { HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 1, barflip, min(1, rightcnt/30), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL); + } + if(cvar("hud_panel_powerups_text")) + { - if(rightcnt <= 5) - drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1)); - if(rightcnt > 1) - drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); - } ++ if(rightcnt > 1) ++ DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1); ++ if(rightcnt <= 5) ++ DrawNumIcon_expanding(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); + } - if(rightcnt > 1) - DrawNumIcon(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1); - if(rightcnt <= 5) - DrawNumIcon_expanding(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1)); } } drawfont = hud_font; @@@ -2277,8 -2360,9 +2316,8 @@@ void HUD_HealthArmor(void if(health <= 0) return; -- vector barpos, barsize; - vector picpos; - vector numpos; ++ vector barsize; + vector picpos, numpos; drawfont = hud_bigfont; float baralign = cvar("hud_panel_healtharmor_baralign"); @@@ -2292,6 -2379,11 +2334,7 @@@ float x; x = floor(v_x + 1); + float maxtotal = maxhealth + maxarmor; - - barpos = pos; - barsize = mySize; - string biggercount; if(v_z) // NOT fully armored { @@@ -2299,9 -2391,10 +2342,10 @@@ if(progressbar) { HUD_Panel_GetProgressBarColor(health); - HUD_Panel_DrawProgressBar(pos, mySize, x/400, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, cvar_string("hud_panel_healtharmor_progressbar_health"), 0, mod(baralign, 2), x/maxtotal, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, cvar_string("hud_panel_healtharmor_progressbar_health"), x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } if(armor) + if(cvar("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); } else @@@ -2310,27 -2403,37 +2354,32 @@@ if(progressbar) { HUD_Panel_GetProgressBarColor(armor); - HUD_Panel_DrawProgressBar(pos, mySize, x/400, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, cvar_string("hud_panel_healtharmor_progressbar_armor"), 0, mod(baralign, 2), x/maxtotal, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, cvar_string("hud_panel_healtharmor_progressbar_armor"), x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } if(health) + if(cvar("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); } - DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, 2 * 200), 1); + if(cvar("hud_panel_healtharmor_text")) - DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, maxtotal), 1); ++ DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1); - // fuel if(fuel) { - barpos = pos; - barsize = eX * mySize_x + eY * 0.2 * mySize_y; HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.2 * mySize_y, fuel/100, 0, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * 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), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } } else { string leftname, rightname; + string leftprogressname, rightprogressname; float leftcnt, rightcnt; + float leftmax, rightmax; float leftactive, rightactive; float leftalpha, rightalpha; - float flip = cvar("hud_panel_healtharmor_flip"); - float barflip; - if (flip) { // old style layout with armor left/top of health + if (cvar("hud_panel_healtharmor_flip")) { // layout with armor left/top of health leftname = "armor"; + leftprogressname = cvar_string("hud_panel_healtharmor_progressbar_armor"); leftcnt = armor; if(leftcnt) leftactive = 1; @@@ -2351,20 -2460,75 +2406,23 @@@ if(rightcnt) rightactive = 1; rightalpha = min((armor+10)/55, 1); + rightmax = maxarmor; } - if (mySize_x/mySize_y > 4) + float panel_ar = mySize_x/mySize_y; + float is_vertical = (panel_ar < 1); + if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1)) { + barsize = eX * 0.5 * mySize_x + eY * mySize_y; if(leftactive) { - barpos = pos; - if(baralign == 1 || baralign == 3) { // right align - barflip = 1; - } else { // left align - barflip = 0; - } - - if(progressbar) - { - HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } - if(cvar("hud_panel_healtharmor_text")) - DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1); - } - - if(rightactive) - { - barpos = pos + eX * 0.5 * mySize_x; - if(baralign == 0 || baralign == 3) { // left align - barflip = 0; - } else { // right align - barflip = 1; - } - - if(progressbar) - { - HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - } - if(cvar("hud_panel_healtharmor_text")) - DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1); - } - - if(fuel) - { - barpos = pos; - barsize = eX * mySize_x + eY * 0.2 * mySize_y; - HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); - } - } - else if (mySize_x/mySize_y > 1.5) - { - barsize = eX * mySize_x + eY * 0.5 * mySize_y; - if(leftactive) - { - barpos = pos; - if(baralign == 1 || baralign == 3) { // right align - barflip = 1; - } else { // left align - barflip = 0; - } - if(progressbar) { HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 0, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - DrawNumIcon(pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1); - if(cvar("hud_panel_healtharmor_text")) - DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, leftmax), 1); ++ if(cvar("hud_panel_healtharmor_text")) ++ DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1); } if(rightactive) @@@ -2372,31 -2536,57 +2430,34 @@@ if(progressbar) { HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 0, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, barsize, rightprogressname, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - DrawNumIcon(pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1); - if(cvar("hud_panel_healtharmor_text")) - DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, rightmax), 1); ++ if(cvar("hud_panel_healtharmor_text")) ++ DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1); } if(fuel) { - barpos = pos; - barsize = eX * mySize_x + eY * 0.2 * mySize_y; - HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 0, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_GetProgressBarColor(fuel); + if (is_vertical) //if vertical always halve x to not cover too much numbers with 3 digits + mySize_x *= 0.2 * 0.5 / 2; + else + mySize_y *= 0.2; - HUD_Panel_DrawProgressBar(pos, mySize, fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } } else { + barsize = eX * 0.5 * mySize_x + eY * mySize_y; if(leftactive) { - barpos = pos; - if(baralign == 1 || baralign == 3) { // right align - barflip = 1; - } else { // left align - barflip = 0; - } - - if(iconalign == 1 || iconalign == 3) { // down align - picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x); - numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x; - } else { // up align - picpos = pos + eX * 0.05 * mySize_x; - numpos = pos + eY * 0.4 * mySize_x; - } - if(progressbar) { HUD_Panel_GetProgressBarColorForString(leftname); - HUD_Panel_DrawProgressBar(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, leftprogressname, 1, barflip, min(1, leftcnt/leftmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - DrawNumIcon(pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1); - if(cvar("hud_panel_healtharmor_text")) - { - drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(numpos, ftos(leftcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(leftcnt, leftmax), panel_fg_alpha, DRAWFLAG_NORMAL); - } ++ if(cvar("hud_panel_healtharmor_text")) ++ DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1); } if(rightactive) @@@ -2404,19 -2594,36 +2465,20 @@@ if(progressbar) { HUD_Panel_GetProgressBarColorForString(rightname); - HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - HUD_Panel_DrawProgressBar(barpos, barsize, rightprogressname, 1, barflip, min(1, rightcnt/rightmax), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, barsize, rightprogressname, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } - DrawNumIcon(pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1); - if(cvar("hud_panel_healtharmor_text")) - { - drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL); - drawstring_aspect(numpos, ftos(rightcnt), eX * 0.5 * mySize_x + eY * 0.25 * mySize_x, HUD_Get_Num_Color(rightcnt, rightmax), panel_fg_alpha, DRAWFLAG_NORMAL); - } ++ if(cvar("hud_panel_healtharmor_text")) ++ DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1); } if(fuel) { - barpos = pos; - barsize = eX * 0.05 * mySize_x + eY * mySize_y; - HUD_Panel_GetProgressBarColor(fuel); - HUD_Panel_DrawProgressBar(barpos, barsize, "progressbar", 1, mod(baralign, 2), min(1, fuel/100), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); + HUD_Panel_GetProgressBarColor(fuel); + if (is_vertical) //if vertical always halve x to not cover numbers with 3 digits + mySize_x *= 0.2 / 2; + else + mySize_y *= 0.2 * 0.5; - HUD_Panel_DrawProgressBar(pos, mySize, fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, "progressbar", fuel/100, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL); } } } @@@ -4300,13 -4433,17 +4420,11 @@@ void HUD_Mod_NexBall(vector pos, vecto p = 2 - p; //Draw the filling - vector barsize; -- float vertical; + HUD_Panel_GetProgressBarColor(nexball); if(mySize_x > mySize_y) - HUD_Panel_DrawProgressBar(pos, mySize, p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - { - vertical = 0; - } ++ HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 0, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); else - HUD_Panel_DrawProgressBar(pos, mySize, p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); - { - vertical = 1; - } - HUD_Panel_GetProgressBarColor(nexball); - HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", vertical, 0, p, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", p, 1, 0, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); } if (stat_items & IT_KEY1) @@@ -4977,19 -5119,10 +5097,19 @@@ void HUD_ShowAcceleration(void rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1); } + mySize_x = vid_conwidth/2; + mySize_y = sz; + pos_y = cvar("cl_showacceleration_position") * vid_conheight - sz/2; if (acceleration > 0) - HUD_Panel_DrawProgressBar(pos, eX * (vid_conwidth - pos_x) + eY * sz, "statusbar", 0, 0, acceleration * scale, rgb, alpha * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + { + pos_x = mySize_x; - HUD_Panel_DrawProgressBar(pos, mySize, acceleration * scale, 0, 0, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", acceleration * scale, 0, 0, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); + } else - HUD_Panel_DrawProgressBar(eY * pos_y, eX * pos_x + eY * sz, "statusbar", 0, 1, -acceleration * scale, rgb, alpha * autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL); + { + //pos_x = 0; - HUD_Panel_DrawProgressBar(pos, mySize, -acceleration * scale, 0, 1, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); ++ HUD_Panel_DrawProgressBar(pos, mySize, "statusbar", -acceleration * scale, 0, 1, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); + } } void HUD_Reset (void)