From: MirceaKitsune Date: Mon, 18 Jul 2011 16:20:39 +0000 (+0300) Subject: Value based color for the stomach board capacity indicator X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0175fc75a7eed8c56bb4d3e8e6332b583d2c30c0;p=voretournament%2Fvoretournament.git Value based color for the stomach board capacity indicator --- diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 5f15dfee..cb86bf75 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -122,39 +122,39 @@ void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, fl drawstring(pos, final_num, vsize, rgb, alpha, dflags); } -void Sbar_DrawXNum_Colored (vector pos, float x, float lettersize, float alpha) +vector Sbar_NumColor (float x, float center) { - if(x > 200) { + if(x > center*2) { color_x = 0; color_y = 1; color_z = 0; } - else if(x > 150) { - color_x = 0.4 - (x-150)*0.02 * 0.4; //red value between 0.4 -> 0 - color_y = 0.9 + (x-150)*0.02 * 0.1; // green value between 0.9 -> 1 + else if(x > center*1.5) { + color_x = 0.4 - (x-center*1.5)*0.02 * 0.4; //red value between 0.4 -> 0 + color_y = 0.9 + (x-center*1.5)*0.02 * 0.1; // green value between 0.9 -> 1 color_z = 0; } - else if(x > 100) { - color_x = 1 - (x-100)*0.02 * 0.6; //red value between 1 -> 0.4 - color_y = 1 - (x-100)*0.02 * 0.1; // green value between 1 -> 0.9 - color_z = 1 - (x-100)*0.02; // blue value between 1 -> 0 + else if(x > center*1) { + color_x = 1 - (x-center*1)*0.02 * 0.6; //red value between 1 -> 0.4 + color_y = 1 - (x-center*1)*0.02 * 0.1; // green value between 1 -> 0.9 + color_z = 1 - (x-center*1)*0.02; // blue value between 1 -> 0 } - else if(x > 50) { + else if(x > center*0.5) { color_x = 1; color_y = 1; - color_z = 0.2 + (x-50)*0.02 * 0.8; // blue value between 0.2 -> 1 + color_z = 0.2 + (x-center*0.5)*0.02 * 0.8; // blue value between 0.2 -> 1 } - else if(x > 20) { + else if(x > center*0.25) { color_x = 1; - color_y = (x-20)*90/27/100; // green value between 0 -> 1 - color_z = (x-20)*90/27/100 * 0.2; // blue value between 0 -> 0.2 + color_y = (x-center*0.25)*90/27/100; // green value between 0 -> 1 + color_z = (x-center*0.25)*90/27/100 * 0.2; // blue value between 0 -> 0.2 } else { color_x = 1; color_y = 0; color_z = 0; } - Sbar_DrawXNum(pos, x, 3, 0, lettersize, color, alpha, DRAWFLAG_NORMAL); + return color; } void Cmd_Sbar_SetFields(float argc); @@ -3032,17 +3032,18 @@ void Sbar_Draw (void) stomach_maxload = getstati(STAT_VORE_MAXLOAD); vector status_pos; - string status_text; + string status_text, status_color; float status_size; + status_color = rgb_to_hexcolor(Sbar_NumColor(stomach_maxload, cvar("g_balance_vore_load_pred_capacity"))); if(stomach_load) { - status_text = strcat(ftos(stomach_load), "^8/^7", ftos(stomach_maxload), "%"); + status_text = strcat(ftos(stomach_load), "^8/", status_color, ftos(stomach_maxload), "%"); status_pos = bottomleft - '-44 168 0'; status_size = 16; } else { - status_text = strcat(ftos(stomach_maxload), "%"); + status_text = strcat(status_color, ftos(stomach_maxload), "%"); status_pos = bottomleft - '-44 170 0'; status_size = 20; } @@ -3119,14 +3120,14 @@ void Sbar_Draw (void) { drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5; - Sbar_DrawXNum_Colored(armor_pos, x, 12, sbar_alpha_fg); + Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x, 100), sbar_alpha_fg, DRAWFLAG_NORMAL); } // health x = health; drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5; - Sbar_DrawXNum_Colored(health_pos, x, 22, sbar_alpha_fg); + Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x, 100), sbar_alpha_fg, DRAWFLAG_NORMAL); // ammo pos_x = bottom_x + 140;