X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=sbar.c;h=4b63ab8a649664a591ac6beb3cf4e6ac3e0319b4;hb=39810a7b640f01d94df16c2dae8335987e8d3f11;hp=33a39dcb81bfbfc6e4726a840ff6e74e4a9fc3e1;hpb=db5711bf43ecb6541984027329bd3ba6268b68b4;p=xonotic%2Fdarkplaces.git diff --git a/sbar.c b/sbar.c index 33a39dcb..4b63ab8a 100644 --- a/sbar.c +++ b/sbar.c @@ -96,6 +96,7 @@ cvar_t sbar_alpha_bg = {CVAR_SAVE, "sbar_alpha_bg", "0.4", "opacity value of the cvar_t sbar_alpha_fg = {CVAR_SAVE, "sbar_alpha_fg", "1", "opacity value of the statusbar weapon/item icons and numbers"}; cvar_t sbar_hudselector = {CVAR_SAVE, "sbar_hudselector", "0", "selects which of the builtin hud layouts to use (meaning is somewhat dependent on gamemode, so nexuiz has a very different set of hud layouts than quake for example)"}; cvar_t sbar_miniscoreboard_size = {CVAR_SAVE, "sbar_miniscoreboard_size", "-1", "sets the size of the mini deathmatch overlay in items, or disables it when set to 0, or sets it to a sane default when set to -1"}; +cvar_t sbar_flagstatus_right = {CVAR_SAVE, "sbar_flagstatus_right", "0", "moves Nexuiz flag status icons to the right"}; cvar_t cl_deathscoreboard = {0, "cl_deathscoreboard", "1", "shows scoreboard (+showscores) while dead"}; @@ -110,6 +111,8 @@ void Sbar_DeathmatchOverlay (void); void Sbar_IntermissionOverlay (void); void Sbar_FinaleOverlay (void); +void CL_VM_UpdateShowingScoresState (int showingscores); + /* =============== @@ -123,6 +126,7 @@ void Sbar_ShowScores (void) if (sb_showscores) return; sb_showscores = true; + CL_VM_UpdateShowingScoresState(sb_showscores); } /* @@ -135,6 +139,7 @@ Tab key up void Sbar_DontShowScores (void) { sb_showscores = false; + CL_VM_UpdateShowingScoresState(sb_showscores); } void sbar_start(void) @@ -380,6 +385,9 @@ void Sbar_Init (void) Cvar_RegisterVariable(&crosshair_color_alpha); Cvar_RegisterVariable(&crosshair_size); + if(gamemode == GAME_NEXUIZ) + Cvar_RegisterVariable(&sbar_flagstatus_right); // this cvar makes no sense in other games + R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap); } @@ -863,13 +871,15 @@ void Sbar_DrawInventory (void) // ammo counts for (i=0 ; i<4 ; i++) { - sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] ); + sprintf (num, "%4i",cl.stats[STAT_SHELLS+i] ); if (num[0] != ' ') - Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0'); + Sbar_DrawCharacter ( (6*i+0)*8 - 2, -24, 18 + num[0] - '0'); if (num[1] != ' ') - Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0'); + Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[1] - '0'); if (num[2] != ' ') - Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0'); + Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[2] - '0'); + if (num[3] != ' ') + Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[3] - '0'); } // items @@ -933,9 +943,9 @@ void Sbar_DrawFrags (void) s = &cl.scores[k]; // draw background - c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8]; + c = (unsigned char *)&palette_pantsscoreboard[(s->colors & 0xf0) >> 4]; DrawQ_Fill (sbar_x + x + 10, sbar_y - 23, 28, 4, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); - c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8]; + c = (unsigned char *)&palette_shirtscoreboard[s->colors & 0xf]; DrawQ_Fill (sbar_x + x + 10, sbar_y + 4 - 23, 28, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); // draw number @@ -977,9 +987,9 @@ void Sbar_DrawFace (void) s = &cl.scores[cl.viewentity - 1]; // draw background Sbar_DrawPic (112, 0, rsb_teambord); - c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8]; + c = (unsigned char *)&palette_pantsscoreboard[(s->colors & 0xf0) >> 4]; DrawQ_Fill (sbar_x + 113, vid_conheight.integer-SBAR_HEIGHT+3, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); - c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8]; + c = (unsigned char *)&palette_shirtscoreboard[s->colors & 0xf]; DrawQ_Fill (sbar_x + 113, vid_conheight.integer-SBAR_HEIGHT+12, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); // draw number @@ -1198,6 +1208,7 @@ void Sbar_Draw (void) int i; float fade; int redflag, blueflag; + float x; sbar_x = (vid_conwidth.integer - 320)/2; sbar_y = vid_conheight.integer - 24 - 16; @@ -1214,28 +1225,33 @@ void Sbar_Draw (void) // flag icons redflag = ((cl.stats[STAT_ITEMS]>>15) & 3); blueflag = ((cl.stats[STAT_ITEMS]>>17) & 3); + x = sbar_flagstatus_right.integer ? vid_conwidth.integer - 10 - sbar_x - 64 : 10 - sbar_x; if (redflag == 3 && blueflag == 3) { // The Impossible Combination[tm] // Can only happen in Key Hunt mode... - Sbar_DrawPic (10 - sbar_x, -179, sb_items[14]); + Sbar_DrawPic (x, -179, sb_items[14]); } else { if (redflag) - Sbar_DrawPic (10 - sbar_x, -109, sb_items[redflag+10]); + Sbar_DrawPic (x, -117, sb_items[redflag+10]); if (blueflag) - Sbar_DrawPic (10 - sbar_x, -169, sb_items[blueflag+14]); + Sbar_DrawPic (x, -177, sb_items[blueflag+14]); } // armor if (cl.stats[STAT_ARMOR] > 0) { Sbar_DrawStretchPic (0, 0, sb_armor[0], sbar_alpha_fg.value, 24, 24); - if(cl.stats[STAT_ARMOR] > 100) - Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,1,1,0,1,0); - else if(cl.stats[STAT_ARMOR] > 25) + if(cl.stats[STAT_ARMOR] > 200) + Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,0,1,0,1,0); + else if(cl.stats[STAT_ARMOR] > 100) + Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,0.2,1,0.2,1,0); + else if(cl.stats[STAT_ARMOR] > 50) Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,0.6,0.7,0.8,1,0); + else if(cl.stats[STAT_ARMOR] > 25) + Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,1,1,0.2,1,0); else Sbar_DrawXNum(24,0,cl.stats[STAT_ARMOR],3,24,0.7,0,0,1,0); } @@ -1244,10 +1260,14 @@ void Sbar_Draw (void) if (cl.stats[STAT_HEALTH] != 0) { Sbar_DrawStretchPic (112, 0, sb_health, sbar_alpha_fg.value, 24, 24); - if(cl.stats[STAT_HEALTH] > 100) - Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,1,1,0,1,0); - else if(cl.stats[STAT_HEALTH] > 25) + if(cl.stats[STAT_HEALTH] > 200) + Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,0,1,0,1,0); + else if(cl.stats[STAT_HEALTH] > 100) + Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,0.2,1,0.2,1,0); + else if(cl.stats[STAT_HEALTH] > 50) Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0); + else if(cl.stats[STAT_HEALTH] > 25) + Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,1,1,0.2,1,0); else Sbar_DrawXNum(136,0,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0); } @@ -1281,6 +1301,7 @@ void Sbar_Draw (void) int i; float fade; int redflag, blueflag; + float x; sbar_x = (vid_conwidth.integer - 640)/2; sbar_y = vid_conheight.integer - 47; @@ -1309,18 +1330,19 @@ void Sbar_Draw (void) // flag icons redflag = ((cl.stats[STAT_ITEMS]>>15) & 3); blueflag = ((cl.stats[STAT_ITEMS]>>17) & 3); + x = sbar_flagstatus_right.integer ? vid_conwidth.integer - 10 - sbar_x - 64 : 10 - sbar_x; if (redflag == 3 && blueflag == 3) { // The Impossible Combination[tm] // Can only happen in Key Hunt mode... - Sbar_DrawPic (10 - sbar_x, -179, sb_items[14]); + Sbar_DrawPic (x, -179, sb_items[14]); } else { if (redflag) - Sbar_DrawPic (10 - sbar_x, -109, sb_items[redflag+10]); + Sbar_DrawPic (x, -117, sb_items[redflag+10]); if (blueflag) - Sbar_DrawPic (10 - sbar_x, -169, sb_items[blueflag+14]); + Sbar_DrawPic (x, -177, sb_items[blueflag+14]); } // armor @@ -1542,16 +1564,15 @@ void Sbar_Draw (void) Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10); - } - - // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode - if ((!cl.islocalgame || cl.gametype != GAME_COOP)) - { - if (gamemode == GAME_TRANSFUSION) - Sbar_MiniDeathmatchOverlay (0, 0); - else - Sbar_MiniDeathmatchOverlay (sbar_x + 324, vid_conheight.integer - 8*8); - Sbar_Score(24); + // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode + if ((!cl.islocalgame || cl.gametype != GAME_COOP)) + { + if (gamemode == GAME_TRANSFUSION) + Sbar_MiniDeathmatchOverlay (0, 0); + else + Sbar_MiniDeathmatchOverlay (sbar_x + 324, vid_conheight.integer - 8*8); + Sbar_Score(24); + } } } } @@ -1598,9 +1619,14 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y) else { // draw colors behind score - c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8]; + // + // + // + // + // + c = (unsigned char *)&palette_pantsscoreboard[(s->colors & 0xf0) >> 4]; DrawQ_Fill(x + 14*8, y+1, 40, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); - c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8]; + c = (unsigned char *)&palette_shirtscoreboard[s->colors & 0xf]; DrawQ_Fill(x + 14*8, y+4, 40, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); // print the text //DrawQ_String(x, y, va("%c%4i %s", myself ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL, true); @@ -1622,9 +1648,9 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y) else { // draw colors behind score - c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8]; + c = (unsigned char *)&palette_pantsscoreboard[(s->colors & 0xf0) >> 4]; DrawQ_Fill(x + 9*8, y+1, 40, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); - c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8]; + c = (unsigned char *)&palette_shirtscoreboard[s->colors & 0xf]; DrawQ_Fill(x + 9*8, y+4, 40, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0); // print the text //DrawQ_String(x, y, va("%c%4i %s", myself ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL, true); @@ -1650,7 +1676,7 @@ void Sbar_DeathmatchOverlay (void) MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd); MSG_WriteString(&cls.netcon->message, "pings"); } - else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5 || cls.protocol == PROTOCOL_DARKPLACES6/* || cls.protocol == PROTOCOL_DARKPLACES7*/) + else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_NEHAHRABJP || cls.protocol == PROTOCOL_NEHAHRABJP2 || cls.protocol == PROTOCOL_NEHAHRABJP3 || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5 || cls.protocol == PROTOCOL_DARKPLACES6/* || cls.protocol == PROTOCOL_DARKPLACES7*/) { // these servers usually lack the pings command and so a less efficient "ping" command must be sent, which on modern DP servers will also reply with a pingplreport command after the ping listing static int ping_anyway_counter = 0; @@ -1855,7 +1881,7 @@ void Sbar_Score (int margin) for(i = 0; i < teamlines; ++i) { int cindex = teamcolorsort[i]->colors & 15; - unsigned char *c = (unsigned char *)&palette_complete[(cindex << 4) + 8]; + unsigned char *c = (unsigned char *)&palette_shirtscoreboard[cindex]; float cm = max(max(c[0], c[1]), c[2]); float cr = c[0] / cm; float cg = c[1] / cm; @@ -1968,9 +1994,7 @@ void Sbar_IntermissionOverlay (void) int dig; int num; - // LordHavoc: changed to draw the deathmatch overlays in any multiplayer mode - //if (cl.gametype == GAME_DEATHMATCH) - if (!cl.islocalgame) + if (cl.gametype == GAME_DEATHMATCH) { Sbar_DeathmatchOverlay (); return;