X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=sbar.c;h=af976c77c6631df558b2767f0574a337e300fc3c;hb=fc83bfe29745415b7ab325a045d637d901450b22;hp=f98d4de46ab15aa9be912bbbbf5c4ba465be7cd2;hpb=6b1d3ecfd70b811e74100db71cbd5b433579cca2;p=xonotic%2Fdarkplaces.git diff --git a/sbar.c b/sbar.c index f98d4de4..af976c77 100644 --- a/sbar.c +++ b/sbar.c @@ -122,14 +122,11 @@ void sbar_start(void) int i; numsbarpics = 0; - + sb_disc = Sbar_NewPic("gfx/disc"); for (i = 0;i < 10;i++) - { sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i)); - sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i)); - } sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus"); sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus"); @@ -137,19 +134,19 @@ void sbar_start(void) sb_colon = Sbar_NewPic ("gfx/num_colon"); sb_slash = Sbar_NewPic ("gfx/num_slash"); - //AK NEX uses its own hud + //AK NX uses its own hud if(gamemode == GAME_NEXUIZ) { sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells"); sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets"); sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket"); sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells"); - + sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo"); sb_items[3] = Sbar_NewPic ("gfx/sb_invinc"); sb_items[4] = Sbar_NewPic ("gfx/sb_energy"); sb_items[5] = Sbar_NewPic ("gfx/sb_str"); - + sb_sbar = Sbar_NewPic("gfx/sbar"); sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay"); @@ -157,7 +154,7 @@ void sbar_start(void) sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i)); return; - } + } sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun"); sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun"); @@ -365,6 +362,39 @@ void Sbar_DrawNum (int x, int y, int num, int digits, int color) Sbar_DrawPic (x, y, sb_nums[color][frame]); x += 24; + + ptr++; + } +} + +/* +============= +Sbar_DrawXNum +============= +*/ + +void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags) +{ + char str[32], *ptr; + int l, frame; + + l = sprintf(str, "%i", num); + ptr = str; + if (l > digits) + ptr += (l-digits); + if (l < digits) + x += (digits-l) * lettersize; + + while (*ptr) + { + if (*ptr == '-') + frame = STAT_MINUS; + else + frame = *ptr -'0'; + + DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a,flags); + x += lettersize; + ptr++; } } @@ -821,7 +851,7 @@ void Sbar_Draw (void) { if (scr_con_current == vid.conheight) return; // console is full screen - + if (cl.intermission == 1) { Sbar_IntermissionOverlay(); @@ -837,45 +867,60 @@ void Sbar_Draw (void) { sbar_y = vid.conheight - 47; sbar_x = (vid.conwidth - 640)/2; - - if (sb_lines > 24) - Sbar_DrawFrags (); - + + if (sb_lines) + { + Sbar_DrawInventory(); + if (!cl.islocalgame) + Sbar_DrawFrags (); + } + if (sb_showscores || cl.stats[STAT_HEALTH] <= 0) { - if (gamemode != GAME_GOODVSBAD2) - Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4); + Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4); Sbar_DrawScoreboard (); } else if (sb_lines) { Sbar_DrawPic (0, 0, sb_sbar); - + // special items if (cl.items & IT_INVULNERABILITY) { - Sbar_DrawNum (24, 0, 666, 3, 1); + Sbar_DrawNum (36, 0, 666, 3, 1); Sbar_DrawPic (0, 0, sb_disc); } // armor - Sbar_DrawNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25); - + Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0); + // health - Sbar_DrawNum ((154-3*24), 12, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25); - - if (cl.items & NEX_IT_SHELLS) - Sbar_DrawPic (519, 0, sb_ammo[0]); - else if (cl.items & NEX_IT_BULLETS) - Sbar_DrawPic (519, 0, sb_ammo[1]); - else if (cl.items & NEX_IT_ROCKETS) - Sbar_DrawPic (519, 0, sb_ammo[2]); - else if (cl.items & NEX_IT_CELLS) - Sbar_DrawPic (519, 0, sb_ammo[3]); - - Sbar_DrawNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10); + if(cl.stats[STAT_HEALTH] > 100) + Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0); + else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5) + Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0); + else + Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0); + + // AK dont draw ammo for the laser + if(cl.stats[STAT_ACTIVEWEAPON] != 12) + { + if (cl.items & NEX_IT_SHELLS) + Sbar_DrawPic (519, 0, sb_ammo[0]); + else if (cl.items & NEX_IT_BULLETS) + Sbar_DrawPic (519, 0, sb_ammo[1]); + else if (cl.items & NEX_IT_ROCKETS) + Sbar_DrawPic (519, 0, sb_ammo[2]); + else if (cl.items & NEX_IT_CELLS) + Sbar_DrawPic (519, 0, sb_ammo[3]); + + if(cl.stats[STAT_AMMO] <= 10) + Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0); + else + Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0); + + } - //Sbar_DrawAlphaPic(0,0,sb_sbar_overlay,0.5); DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE); } } @@ -988,7 +1033,6 @@ void Sbar_Draw (void) } } - if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH) Sbar_MiniDeathmatchOverlay (); @@ -1051,8 +1095,13 @@ void Sbar_MiniDeathmatchOverlay (void) int i, x, y, numlines; // decide where to print - x = 324; - y = vid.conheight - sb_lines; + x = 0; + // AK Nex wants its scores on the upper left + if(gamemode == GAME_NEXUIZ) + y = 0; + else + y = vid.conheight - sb_lines; + numlines = (vid.conheight - y) / 8; // give up if there isn't room if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)