X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=data%2Fqcsrc%2Fclient%2Fsbar.qc;h=a8ba383336698978a9daaf9efd32e96a518bf2cd;hb=2a22fb7e4b83c62121f8fbb2038174ed368c7ca7;hp=7a3b08cd87494b40cdbd7b9a318f0a90d33cb363;hpb=cb278c3c6dd2f0b7e0431135cededcd155eb61a1;p=voretournament%2Fvoretournament.git diff --git a/data/qcsrc/client/sbar.qc b/data/qcsrc/client/sbar.qc index 7a3b08cd..a8ba3833 100644 --- a/data/qcsrc/client/sbar.qc +++ b/data/qcsrc/client/sbar.qc @@ -29,7 +29,7 @@ float ps_primary, ps_secondary; float ts_primary, ts_secondary; vector color; -float SCOREBOARD_OFFSET = 50; +float SCOREBOARD_OFFSET = cvar("sbar_scoreboard_offset"); void CSQC_kh_hudreset(); void CSQC_kh_hud(); @@ -716,18 +716,11 @@ string Sbar_GetField(entity pl, float field) string Sbar_GetStomachField(entity pl, float field) { - sbar_field_rgb = '1 1 1'; - sbar_field_icon0 = ""; - sbar_field_icon1 = ""; - sbar_field_icon2 = ""; - sbar_field_icon0_rgb = '1 1 1'; - sbar_field_icon1_rgb = '1 1 1'; - sbar_field_icon2_rgb = '1 1 1'; - sbar_field_icon0_alpha = 1; - sbar_field_icon1_alpha = 1; - sbar_field_icon2_alpha = 1; switch(field) { + case ST_HIGHLIGHT: + return ""; // the returned value is not used, we only need the field + case ST_NAME: return GetPlayerName(pl.sv_entnum); @@ -740,6 +733,18 @@ string Sbar_GetStomachField(entity pl, float field) //return "error"; } +string Sbar_GetStomachFieldPred(entity pl, float field) +{ + switch(field) + { + case STP_NAME: + return GetPlayerName(pl.sv_entnum); + default: + return "N/A"; + } + //return "error"; +} + float xmin, xmax, ymin, ymax, sbwidth; float sbar_fixscoreboardcolumnwidth_len; float sbar_fixscoreboardcolumnwidth_iconlen; @@ -949,24 +954,26 @@ void Sbar_PrintScoreboardItem(vector pos, entity pl, float is_self, float pl_num float fieldcounter; void Sbar_PrintStomachboardItem(vector pos, entity pl) { - vector tmp, rgb; - rgb = GetTeamRGB(pl.team); - string str; - float f, field; + // lists all players in the stomach - // Layout: - tmp_x = sbwidth; - tmp_y = sbar_fontsize_y * 1.25; - tmp_z = 0; + string str; + float f, field, field_number; + field_number = 3; // the number of components each row has - for(fieldcounter = 1; fieldcounter <= 2; ++fieldcounter) + for(fieldcounter = 1; fieldcounter <= field_number; ++fieldcounter) { field = -fieldcounter; - if(field == SP_SEPARATOR) - break; - str = Sbar_GetStomachField(pl, field); + // row highlighting + if(field == ST_HIGHLIGHT) + { + if(getstati(STAT_STOMACH_EATEN)) + drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color2")), cvar("sbar_stomachboard_highlight_alpha"), DRAWFLAG_NORMAL); + else + drawfill(pos - '0 0 0', '193 11 0', stov(cvar_string("sbar_stomachboard_color1")), cvar("sbar_stomachboard_highlight_alpha"), DRAWFLAG_NORMAL); + } + if(field == ST_NAME) { f = stof(getplayerkey(pl.sv_entnum, "colors")); drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); @@ -974,16 +981,47 @@ void Sbar_PrintStomachboardItem(vector pos, entity pl) drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL); pos_x += 24; - drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + drawcolorcodedstring(pos, textShortenToWidth(str, 138, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); } if(field == ST_HEALTH) - if(g_vore_showpreyhealth && stof(str)) { // only if player health is not 0 + if(g_vore_showpreyhealth) { pos_x += 138; - drawpic(pos, "gfx/hud/sb_health", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + if(pl.sv_entnum == player_localentnum - 1 || (spectatee_status && pl.sv_entnum == spectatee_status - 1)) + drawcolorcodedstring(pos, "self", '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + else + { + drawpic(pos, "gfx/hud/sb_health", '11 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + + pos_x += 9; + drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + } + } +} + +float fieldcounter2; +void Sbar_PrintStomachboardItemPred(vector pos, entity pl) +{ + // shows the name of our eater + + string str; + float f, field, field_number; + field_number = 1; // the number of components each row has + + for(fieldcounter2 = 1; fieldcounter2 <= field_number; ++fieldcounter2) + { + field = -fieldcounter2; + str = Sbar_GetStomachFieldPred(pl, field); + + if(field == STP_NAME) { + f = stof(getplayerkey(pl.sv_entnum, "colors")); + drawpic(pos, "gfx/sb_playercolor_base", '22 11 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + drawpic(pos, "gfx/sb_playercolor_shirt", '22 11 0', colormapPaletteColor(floor(f / 16), 0), sbar_alpha_fg, DRAWFLAG_NORMAL); + drawpic(pos, "gfx/sb_playercolor_pants", '22 11 0', colormapPaletteColor(mod(f, 16), 1), sbar_alpha_fg, DRAWFLAG_NORMAL); - pos_x += 9; - drawcolorcodedstring(pos, str, '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); + pos_x += 24; + drawcolorcodedstring(pos, textShortenToWidth(str, 122, '11 11 0', stringwidth_colors), '11 11 0', sbar_alpha_fg, DRAWFLAG_NORMAL); } } } @@ -2547,7 +2585,7 @@ float GetAmmoStat(float i) { switch(i) { - case 1: return STAT_FUEL; + case 0: return STAT_FUEL; default: return -1; } } @@ -2556,7 +2594,7 @@ float GetAmmoItemCode(float i) { switch(i) { - case 1: return IT_FUEL; + case 0: return IT_FUEL; default: return -1; } } @@ -2565,7 +2603,7 @@ string GetAmmoPicture(float i) { switch(i) { - case 1: return "gfx/hud/sb_fuel"; + case 0: return "gfx/hud/sb_fuel"; default: return ""; } } @@ -2589,6 +2627,30 @@ float vote_prev; // previous state of vote_active to check for a change float vote_alpha; float vote_change; // "time" when vote_active changed +vector stomachstatus_colorfade_current; +vector StomachStatus_ColorFade(vector target_color) +{ + local float step; + step = cvar("sbar_stomachboard_status_fade"); + + if(stomachstatus_colorfade_current_x >= target_color_x + step) + stomachstatus_colorfade_current_x -= step; + else if(stomachstatus_colorfade_current_x <= target_color_x - step) + stomachstatus_colorfade_current_x += step; + + if(stomachstatus_colorfade_current_y >= target_color_y + step) + stomachstatus_colorfade_current_y -= step; + else if(stomachstatus_colorfade_current_y <= target_color_y - step) + stomachstatus_colorfade_current_y += step; + + if(stomachstatus_colorfade_current_z >= target_color_z + step) + stomachstatus_colorfade_current_z -= step; + else if(stomachstatus_colorfade_current_z <= target_color_z - step) + stomachstatus_colorfade_current_z += step; + + return stomachstatus_colorfade_current; +} + void Sbar_Draw (void) { // vectors for top right, bottom right, bottom and bottom left corners @@ -2854,6 +2916,8 @@ void Sbar_Draw (void) Sbar_Timer(); Sbar_Reset(); + + StomachStatus_ColorFade('0 0 0'); } else { @@ -2871,7 +2935,8 @@ void Sbar_Draw (void) fade = 3.2 - 2 * (time - weapontime); fade = bound(0.7, fade, 1); - if (cvar("viewsize") <= 100 && vid_conwidth <= 1600) { + // draw the stomach board + if (cvar("viewsize") <= 100) { if (teamplay) drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color else { @@ -2883,12 +2948,25 @@ void Sbar_Draw (void) drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); } } + + if(getstati(STAT_STOMACH_EATEN)) + { + drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color2"))), cvar("sbar_stomachboard_status_alpha"), DRAWFLAG_NORMAL); + drawstring(bottomleft - '-80 172 0', "predator:", '10 10 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + else + { + drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', StomachStatus_ColorFade(stov(cvar_string("sbar_stomachboard_color1"))), cvar("sbar_stomachboard_status_alpha"), DRAWFLAG_NORMAL); + drawstring(bottomleft - '-80 172 0', "self:", '10 10 0', ' 1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + } + float stomach_load; stomach_load = getstati(STAT_STOMACH_LOAD); // shows the predator's stomach load when we are eaten, and ours otherwise Sbar_DrawXNum(bottomleft - '-18 170 0', bound(0, stomach_load, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL); drawstring(bottomleft - '-40 170 0', "/", '22 22 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); Sbar_DrawXNum(bottomleft - '-50 170 0', bound(0, g_balance_vore_swallow_limit, 9), 1, 0, 22, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL); + if(getstati(STAT_STOMACH_DIGESTING)) drawstring(bottomleft - '-76 142 0', "stomach digesting", '12 12 0', '1 0.5 0.5', sbar_alpha_fg, DRAWFLAG_NORMAL); else if(stomach_load == g_balance_vore_swallow_limit) @@ -2898,7 +2976,7 @@ void Sbar_Draw (void) else drawstring(bottomleft - '-76 142 0', "stomach has prey", '12 12 0', '0.75 1 0.75', sbar_alpha_fg, DRAWFLAG_NORMAL); - // draw the stomach board + // draw the stomach board player list entity pl; float f; @@ -2909,9 +2987,7 @@ void Sbar_Draw (void) continue; if(getstati(STAT_STOMACH_EATEN)) - { f = pl.pleater == getstati(STAT_STOMACH_EATEN); - } else { if(spectatee_status) @@ -2928,10 +3004,10 @@ void Sbar_Draw (void) if(getstati(STAT_STOMACH_EATEN)) if(pl.sv_entnum == getstati(STAT_STOMACH_EATEN) - 1) - Sbar_PrintStomachboardItem(pos - '-76 156 0', pl); + Sbar_PrintStomachboardItemPred(bottomleft - '-76 156 0', pl); } - if (cvar("viewsize") <= 100 && vid_conwidth <= 1600) { + if (cvar("viewsize") <= 100) { if (teamplay) drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color else { @@ -2954,18 +3030,36 @@ void Sbar_Draw (void) if(x < 10) health_pos_x -= 11; // always center Sbar_DrawXNum_Colored(health_pos, x, 22, sbar_alpha_fg); - // fuel ammo - a = getstati(GetAmmoStat(1)); // how much fuel do we have? + // ammo + pos_x = bottom_x + 140; + pos_y = bottom_y - 20; - if (a > 0) { // if we have fuel, draw the amount - float invincibility_time, dt; - invincibility_time = getstatf(STAT_INVINCIBLE_FINISHED); - dt = invincibility_time - time; - pos_x = bottom_x + 140; - pos_y = bottom_y - 20; - drawpic(pos - '98 18 0', GetAmmoPicture(1), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon + if(stat_items & IT_JETPACK && button_jetpack) + { + a = getstati(GetAmmoStat(0)); // how much fuel do we have? + drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); Sbar_DrawXNum(pos - '144 16 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL); } + else + { + float i; + for (i = 0; i < 1; ++i) + { + if (stat_items & GetAmmoItemCode(i)) + { + a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i? + drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + Sbar_DrawXNum(pos - '144 16 0', a, 3, 0, 16, '1 1 1', 0, 0, sbar_alpha_fg, DRAWFLAG_NORMAL); + } + } + } + + // weapon icon + entity e; + e = get_weaponinfo(activeweapon); + if (e && e.netname != "" && e.netname != "N/A") + drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); // draw scores and timer Sbar_Score();