2010-02-15 23:26:55 +00:00
/*
Copyright ( C ) 1996 - 2001 Id Software , Inc .
Copyright ( C ) 2002 - 2009 John Fitzgibbons and others
2014-09-22 08:55:46 +00:00
Copyright ( C ) 2010 - 2014 QuakeSpasm developers
2010-02-15 23:26:55 +00:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation ; either version 2
of the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
// sbar.c -- status bar code
# include "quakedef.h"
2017-09-17 02:12:53 +00:00
extern qboolean premul_hud ;
2011-10-19 20:10:49 +00:00
int sb_updates ; // if >= vid.numpages, no update needed
2010-02-15 23:26:55 +00:00
# define STAT_MINUS 10 // num frame for '-' stats digit
2011-10-19 20:10:49 +00:00
2010-02-15 23:26:55 +00:00
qpic_t * sb_nums [ 2 ] [ 11 ] ;
qpic_t * sb_colon , * sb_slash ;
qpic_t * sb_ibar ;
qpic_t * sb_sbar ;
qpic_t * sb_scorebar ;
2011-10-19 20:10:49 +00:00
qpic_t * sb_weapons [ 7 ] [ 8 ] ; // 0 is active, 1 is owned, 2-5 are flashes
qpic_t * sb_ammo [ 4 ] ;
2010-02-15 23:26:55 +00:00
qpic_t * sb_sigil [ 4 ] ;
qpic_t * sb_armor [ 3 ] ;
qpic_t * sb_items [ 32 ] ;
2011-10-19 20:10:49 +00:00
qpic_t * sb_faces [ 7 ] [ 2 ] ; // 0 is gibbed, 1 is dead, 2-6 are alive
2010-02-15 23:26:55 +00:00
// 0 is static, 1 is temporary animation
2011-10-19 20:10:49 +00:00
qpic_t * sb_face_invis ;
qpic_t * sb_face_quad ;
qpic_t * sb_face_invuln ;
qpic_t * sb_face_invis_invuln ;
2010-02-15 23:26:55 +00:00
qboolean sb_showscores ;
2011-10-19 20:10:49 +00:00
int sb_lines ; // scan lines to draw
2010-02-15 23:26:55 +00:00
2011-10-19 20:10:49 +00:00
qpic_t * rsb_invbar [ 2 ] ;
qpic_t * rsb_weapons [ 5 ] ;
qpic_t * rsb_items [ 2 ] ;
qpic_t * rsb_ammo [ 3 ] ;
qpic_t * rsb_teambord ; // PGM 01/19/97 - team color border
2010-02-15 23:26:55 +00:00
//MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
2011-10-19 20:10:49 +00:00
qpic_t * hsb_weapons [ 7 ] [ 5 ] ; // 0 is active, 1 is owned, 2-5 are flashes
2010-02-15 23:26:55 +00:00
//MED 01/04/97 added array to simplify weapon parsing
2011-10-19 20:10:49 +00:00
int hipweapons [ 4 ] = { HIT_LASER_CANNON_BIT , HIT_MJOLNIR_BIT , 4 , HIT_PROXIMITY_GUN_BIT } ;
2010-02-15 23:26:55 +00:00
//MED 01/04/97 added hipnotic items array
2011-10-19 20:10:49 +00:00
qpic_t * hsb_items [ 2 ] ;
2010-02-15 23:26:55 +00:00
2017-09-17 02:12:53 +00:00
//spike -- fix -game hipnotic by autodetecting hud types. the fte protocols will deal with the networking issue, other than demos, anyway
static int hudtype ;
# define hipnotic (hudtype==1)
# define rogue (hudtype==2)
2010-02-15 23:26:55 +00:00
void Sbar_MiniDeathmatchOverlay ( void ) ;
void Sbar_DeathmatchOverlay ( void ) ;
void M_DrawPic ( int x , int y , qpic_t * pic ) ;
2020-10-10 18:28:04 +00:00
qboolean Sbar_CSQCCommand ( void )
{
qboolean ret = false ;
if ( cl . qcvm . extfuncs . CSQC_ConsoleCommand )
{
PR_SwitchQCVM ( & cl . qcvm ) ;
G_INT ( OFS_PARM0 ) = PR_MakeTempString ( Cmd_Argv ( 0 ) ) ;
PR_ExecuteProgram ( cl . qcvm . extfuncs . CSQC_ConsoleCommand ) ;
ret = G_FLOAT ( OFS_RETURN ) ;
PR_SwitchQCVM ( NULL ) ;
}
return ret ;
}
2010-02-15 23:26:55 +00:00
/*
= = = = = = = = = = = = = = =
Sbar_ShowScores
Tab key down
= = = = = = = = = = = = = = =
*/
void Sbar_ShowScores ( void )
{
2020-10-10 18:28:04 +00:00
Sbar_CSQCCommand ( ) ;
2010-02-15 23:26:55 +00:00
if ( sb_showscores )
return ;
sb_showscores = true ;
sb_updates = 0 ;
}
/*
= = = = = = = = = = = = = = =
Sbar_DontShowScores
Tab key up
= = = = = = = = = = = = = = =
*/
void Sbar_DontShowScores ( void )
{
2020-10-10 18:28:04 +00:00
Sbar_CSQCCommand ( ) ;
2010-02-15 23:26:55 +00:00
sb_showscores = false ;
sb_updates = 0 ;
}
/*
= = = = = = = = = = = = = = =
Sbar_Changed
= = = = = = = = = = = = = = =
*/
void Sbar_Changed ( void )
{
sb_updates = 0 ; // update next frame
}
2017-09-17 02:12:53 +00:00
qpic_t * Sbar_CheckPicFromWad ( const char * name )
{
extern qpic_t * pic_nul ;
qpic_t * r ;
2020-02-29 02:12:10 +00:00
lumpinfo_t * info ;
2017-09-17 02:12:53 +00:00
if ( ! hudtype )
return pic_nul ; //one already failed, don't waste cpu
2020-02-29 02:12:10 +00:00
if ( ! W_GetLumpName ( name , & info ) )
2017-09-17 02:12:53 +00:00
r = pic_nul ;
else
r = Draw_PicFromWad ( name ) ;
if ( r = = pic_nul )
hudtype = 0 ;
return r ;
}
2010-02-15 23:26:55 +00:00
/*
= = = = = = = = = = = = = = =
Sbar_LoadPics - - johnfitz - - load all the sbar pics
= = = = = = = = = = = = = = =
*/
void Sbar_LoadPics ( void )
{
int i ;
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 10 ; i + + )
2010-02-15 23:26:55 +00:00
{
sb_nums [ 0 ] [ i ] = Draw_PicFromWad ( va ( " num_%i " , i ) ) ;
sb_nums [ 1 ] [ i ] = Draw_PicFromWad ( va ( " anum_%i " , i ) ) ;
}
sb_nums [ 0 ] [ 10 ] = Draw_PicFromWad ( " num_minus " ) ;
sb_nums [ 1 ] [ 10 ] = Draw_PicFromWad ( " anum_minus " ) ;
sb_colon = Draw_PicFromWad ( " num_colon " ) ;
sb_slash = Draw_PicFromWad ( " num_slash " ) ;
sb_weapons [ 0 ] [ 0 ] = Draw_PicFromWad ( " inv_shotgun " ) ;
sb_weapons [ 0 ] [ 1 ] = Draw_PicFromWad ( " inv_sshotgun " ) ;
sb_weapons [ 0 ] [ 2 ] = Draw_PicFromWad ( " inv_nailgun " ) ;
sb_weapons [ 0 ] [ 3 ] = Draw_PicFromWad ( " inv_snailgun " ) ;
sb_weapons [ 0 ] [ 4 ] = Draw_PicFromWad ( " inv_rlaunch " ) ;
sb_weapons [ 0 ] [ 5 ] = Draw_PicFromWad ( " inv_srlaunch " ) ;
sb_weapons [ 0 ] [ 6 ] = Draw_PicFromWad ( " inv_lightng " ) ;
sb_weapons [ 1 ] [ 0 ] = Draw_PicFromWad ( " inv2_shotgun " ) ;
sb_weapons [ 1 ] [ 1 ] = Draw_PicFromWad ( " inv2_sshotgun " ) ;
sb_weapons [ 1 ] [ 2 ] = Draw_PicFromWad ( " inv2_nailgun " ) ;
sb_weapons [ 1 ] [ 3 ] = Draw_PicFromWad ( " inv2_snailgun " ) ;
sb_weapons [ 1 ] [ 4 ] = Draw_PicFromWad ( " inv2_rlaunch " ) ;
sb_weapons [ 1 ] [ 5 ] = Draw_PicFromWad ( " inv2_srlaunch " ) ;
sb_weapons [ 1 ] [ 6 ] = Draw_PicFromWad ( " inv2_lightng " ) ;
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 5 ; i + + )
2010-02-15 23:26:55 +00:00
{
sb_weapons [ 2 + i ] [ 0 ] = Draw_PicFromWad ( va ( " inva%i_shotgun " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 1 ] = Draw_PicFromWad ( va ( " inva%i_sshotgun " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 2 ] = Draw_PicFromWad ( va ( " inva%i_nailgun " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 3 ] = Draw_PicFromWad ( va ( " inva%i_snailgun " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 4 ] = Draw_PicFromWad ( va ( " inva%i_rlaunch " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 5 ] = Draw_PicFromWad ( va ( " inva%i_srlaunch " , i + 1 ) ) ;
sb_weapons [ 2 + i ] [ 6 ] = Draw_PicFromWad ( va ( " inva%i_lightng " , i + 1 ) ) ;
}
sb_ammo [ 0 ] = Draw_PicFromWad ( " sb_shells " ) ;
sb_ammo [ 1 ] = Draw_PicFromWad ( " sb_nails " ) ;
sb_ammo [ 2 ] = Draw_PicFromWad ( " sb_rocket " ) ;
sb_ammo [ 3 ] = Draw_PicFromWad ( " sb_cells " ) ;
sb_armor [ 0 ] = Draw_PicFromWad ( " sb_armor1 " ) ;
sb_armor [ 1 ] = Draw_PicFromWad ( " sb_armor2 " ) ;
sb_armor [ 2 ] = Draw_PicFromWad ( " sb_armor3 " ) ;
sb_items [ 0 ] = Draw_PicFromWad ( " sb_key1 " ) ;
sb_items [ 1 ] = Draw_PicFromWad ( " sb_key2 " ) ;
sb_items [ 2 ] = Draw_PicFromWad ( " sb_invis " ) ;
sb_items [ 3 ] = Draw_PicFromWad ( " sb_invuln " ) ;
sb_items [ 4 ] = Draw_PicFromWad ( " sb_suit " ) ;
sb_items [ 5 ] = Draw_PicFromWad ( " sb_quad " ) ;
sb_sigil [ 0 ] = Draw_PicFromWad ( " sb_sigil1 " ) ;
sb_sigil [ 1 ] = Draw_PicFromWad ( " sb_sigil2 " ) ;
sb_sigil [ 2 ] = Draw_PicFromWad ( " sb_sigil3 " ) ;
sb_sigil [ 3 ] = Draw_PicFromWad ( " sb_sigil4 " ) ;
sb_faces [ 4 ] [ 0 ] = Draw_PicFromWad ( " face1 " ) ;
sb_faces [ 4 ] [ 1 ] = Draw_PicFromWad ( " face_p1 " ) ;
sb_faces [ 3 ] [ 0 ] = Draw_PicFromWad ( " face2 " ) ;
sb_faces [ 3 ] [ 1 ] = Draw_PicFromWad ( " face_p2 " ) ;
sb_faces [ 2 ] [ 0 ] = Draw_PicFromWad ( " face3 " ) ;
sb_faces [ 2 ] [ 1 ] = Draw_PicFromWad ( " face_p3 " ) ;
sb_faces [ 1 ] [ 0 ] = Draw_PicFromWad ( " face4 " ) ;
sb_faces [ 1 ] [ 1 ] = Draw_PicFromWad ( " face_p4 " ) ;
sb_faces [ 0 ] [ 0 ] = Draw_PicFromWad ( " face5 " ) ;
sb_faces [ 0 ] [ 1 ] = Draw_PicFromWad ( " face_p5 " ) ;
sb_face_invis = Draw_PicFromWad ( " face_invis " ) ;
sb_face_invuln = Draw_PicFromWad ( " face_invul2 " ) ;
sb_face_invis_invuln = Draw_PicFromWad ( " face_inv2 " ) ;
sb_face_quad = Draw_PicFromWad ( " face_quad " ) ;
2020-10-13 17:42:04 +00:00
sb_sbar = Draw_PicFromWad2 ( " sbar " , TEXPREF_PAD | TEXPREF_NOPICMIP ) ;
sb_ibar = Draw_PicFromWad2 ( " ibar " , TEXPREF_PAD | TEXPREF_NOPICMIP ) ;
2010-02-15 23:26:55 +00:00
sb_scorebar = Draw_PicFromWad ( " scorebar " ) ;
2017-09-17 02:12:53 +00:00
hudtype = 0 ;
2010-02-15 23:26:55 +00:00
//MED 01/04/97 added new hipnotic weapons
2017-09-17 02:12:53 +00:00
if ( ! hudtype )
2010-02-15 23:26:55 +00:00
{
2017-09-17 02:12:53 +00:00
hudtype = 1 ;
hsb_weapons [ 0 ] [ 0 ] = Sbar_CheckPicFromWad ( " inv_laser " ) ;
hsb_weapons [ 0 ] [ 1 ] = Sbar_CheckPicFromWad ( " inv_mjolnir " ) ;
hsb_weapons [ 0 ] [ 2 ] = Sbar_CheckPicFromWad ( " inv_gren_prox " ) ;
hsb_weapons [ 0 ] [ 3 ] = Sbar_CheckPicFromWad ( " inv_prox_gren " ) ;
hsb_weapons [ 0 ] [ 4 ] = Sbar_CheckPicFromWad ( " inv_prox " ) ;
hsb_weapons [ 1 ] [ 0 ] = Sbar_CheckPicFromWad ( " inv2_laser " ) ;
hsb_weapons [ 1 ] [ 1 ] = Sbar_CheckPicFromWad ( " inv2_mjolnir " ) ;
hsb_weapons [ 1 ] [ 2 ] = Sbar_CheckPicFromWad ( " inv2_gren_prox " ) ;
hsb_weapons [ 1 ] [ 3 ] = Sbar_CheckPicFromWad ( " inv2_prox_gren " ) ;
hsb_weapons [ 1 ] [ 4 ] = Sbar_CheckPicFromWad ( " inv2_prox " ) ;
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 5 ; i + + )
{
2017-09-17 02:12:53 +00:00
hsb_weapons [ 2 + i ] [ 0 ] = Sbar_CheckPicFromWad ( va ( " inva%i_laser " , i + 1 ) ) ;
hsb_weapons [ 2 + i ] [ 1 ] = Sbar_CheckPicFromWad ( va ( " inva%i_mjolnir " , i + 1 ) ) ;
hsb_weapons [ 2 + i ] [ 2 ] = Sbar_CheckPicFromWad ( va ( " inva%i_gren_prox " , i + 1 ) ) ;
hsb_weapons [ 2 + i ] [ 3 ] = Sbar_CheckPicFromWad ( va ( " inva%i_prox_gren " , i + 1 ) ) ;
hsb_weapons [ 2 + i ] [ 4 ] = Sbar_CheckPicFromWad ( va ( " inva%i_prox " , i + 1 ) ) ;
2011-10-19 20:10:49 +00:00
}
2017-09-17 02:12:53 +00:00
hsb_items [ 0 ] = Sbar_CheckPicFromWad ( " sb_wsuit " ) ;
hsb_items [ 1 ] = Sbar_CheckPicFromWad ( " sb_eshld " ) ;
2010-02-15 23:26:55 +00:00
}
2017-09-17 02:12:53 +00:00
if ( ! hudtype )
2010-02-15 23:26:55 +00:00
{
2017-09-17 02:12:53 +00:00
hudtype = 2 ;
rsb_invbar [ 0 ] = Sbar_CheckPicFromWad ( " r_invbar1 " ) ;
rsb_invbar [ 1 ] = Sbar_CheckPicFromWad ( " r_invbar2 " ) ;
2010-02-15 23:26:55 +00:00
2017-09-17 02:12:53 +00:00
rsb_weapons [ 0 ] = Sbar_CheckPicFromWad ( " r_lava " ) ;
rsb_weapons [ 1 ] = Sbar_CheckPicFromWad ( " r_superlava " ) ;
rsb_weapons [ 2 ] = Sbar_CheckPicFromWad ( " r_gren " ) ;
rsb_weapons [ 3 ] = Sbar_CheckPicFromWad ( " r_multirock " ) ;
rsb_weapons [ 4 ] = Sbar_CheckPicFromWad ( " r_plasma " ) ;
2010-02-15 23:26:55 +00:00
2017-09-17 02:12:53 +00:00
rsb_items [ 0 ] = Sbar_CheckPicFromWad ( " r_shield1 " ) ;
rsb_items [ 1 ] = Sbar_CheckPicFromWad ( " r_agrav1 " ) ;
2010-02-15 23:26:55 +00:00
// PGM 01/19/97 - team color border
2017-09-17 02:12:53 +00:00
rsb_teambord = Sbar_CheckPicFromWad ( " r_teambord " ) ;
2010-02-15 23:26:55 +00:00
// PGM 01/19/97 - team color border
2017-09-17 02:12:53 +00:00
rsb_ammo [ 0 ] = Sbar_CheckPicFromWad ( " r_ammolava " ) ;
rsb_ammo [ 1 ] = Sbar_CheckPicFromWad ( " r_ammomulti " ) ;
rsb_ammo [ 2 ] = Sbar_CheckPicFromWad ( " r_ammoplasma " ) ;
2010-02-15 23:26:55 +00:00
}
}
/*
= = = = = = = = = = = = = = =
Sbar_Init - - johnfitz - - rewritten
= = = = = = = = = = = = = = =
*/
void Sbar_Init ( void )
{
Cmd_AddCommand ( " +showscores " , Sbar_ShowScores ) ;
Cmd_AddCommand ( " -showscores " , Sbar_DontShowScores ) ;
Sbar_LoadPics ( ) ;
}
//=============================================================================
// drawing routines are relative to the status bar location
/*
= = = = = = = = = = = = =
Sbar_DrawPic - - johnfitz - - rewritten now that GL_SetCanvas is doing the work
= = = = = = = = = = = = =
*/
void Sbar_DrawPic ( int x , int y , qpic_t * pic )
{
Draw_Pic ( x , y + 24 , pic ) ;
}
/*
= = = = = = = = = = = = =
Sbar_DrawPicAlpha - - johnfitz
= = = = = = = = = = = = =
*/
chase.c, cl_input.c, cl_parse.c, client.h, common.c, common.h, console.h,
cvar.h, draw.h, gl_draw.c, gl_fog.c, gl_mesh.c, gl_model.c, gl_model.h,
gl_rmain.c, gl_rmisc.c, gl_screen.c, gl_sky.c, gl_texmgr.c, glquake.h,
host.c, keys.c, keys.h, main.c, menu.c, menu.h, pr_cmds.c, quakedef.h,
r_alias.c, r_brush.c, r_part.c, r_sprite.c, r_world.c, sbar.c, sbar.h,
screen.h, snd_dma.c, snd_mem.c, snd_mix.c, sv_main.c, sys_sdl.c, vid.h,
view.h, world.c, world.h: Loads of warning fixes about missing function
prototypes, missing parens around &, missing braces leading to ambiguous
else statements and unused and uninitialized variables. There are still a
couple of unitialised variables here and there, but not much. The warnings
about strict aliasing violations need taking care of.
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@21 af15c1b1-3010-417e-b628-4374ebc0bcbd
2010-02-16 12:01:07 +00:00
void Sbar_DrawPicAlpha ( int x , int y , qpic_t * pic , float alpha )
2010-02-15 23:26:55 +00:00
{
2017-09-17 02:12:53 +00:00
if ( premul_hud )
{
glColor4f ( alpha , alpha , alpha , alpha ) ;
Draw_Pic ( x , y + 24 , pic ) ;
glColor4f ( 1 , 1 , 1 , 1 ) ;
}
else
{
glDisable ( GL_ALPHA_TEST ) ;
glEnable ( GL_BLEND ) ;
glColor4f ( 1 , 1 , 1 , alpha ) ;
Draw_Pic ( x , y + 24 , pic ) ;
glColor4f ( 1 , 1 , 1 , 1 ) ; // ericw -- changed from glColor3f to work around intel 855 bug with "r_oldwater 0" and "scr_sbaralpha 0"
glDisable ( GL_BLEND ) ;
glEnable ( GL_ALPHA_TEST ) ;
}
2010-02-15 23:26:55 +00:00
}
/*
= = = = = = = = = = = = = = = =
Sbar_DrawCharacter - - johnfitz - - rewritten now that GL_SetCanvas is doing the work
= = = = = = = = = = = = = = = =
*/
void Sbar_DrawCharacter ( int x , int y , int num )
{
Draw_Character ( x , y + 24 , num ) ;
}
/*
= = = = = = = = = = = = = = = =
Sbar_DrawString - - johnfitz - - rewritten now that GL_SetCanvas is doing the work
= = = = = = = = = = = = = = = =
*/
2010-08-29 02:22:55 +00:00
void Sbar_DrawString ( int x , int y , const char * str )
2010-02-15 23:26:55 +00:00
{
Draw_String ( x , y + 24 , str ) ;
}
/*
= = = = = = = = = = = = = = =
Sbar_DrawScrollString - - johnfitz
scroll the string inside a glscissor region
= = = = = = = = = = = = = = =
*/
2010-08-29 02:22:55 +00:00
void Sbar_DrawScrollString ( int x , int y , int width , const char * str )
2010-02-15 23:26:55 +00:00
{
float scale ;
int len , ofs , left ;
2022-06-12 11:32:28 +00:00
scale = CLAMP ( 1.0f , scr_sbarscale . value , ( float ) glwidth / 320.0f ) ;
2010-02-15 23:26:55 +00:00
left = x * scale ;
if ( cl . gametype ! = GAME_DEATHMATCH )
left + = ( ( ( float ) glwidth - 320.0 * scale ) / 2 ) ;
glEnable ( GL_SCISSOR_TEST ) ;
glScissor ( left , 0 , width * scale , glheight ) ;
len = strlen ( str ) * 8 + 40 ;
ofs = ( ( int ) ( realtime * 30 ) ) % len ;
Sbar_DrawString ( x - ofs , y , str ) ;
Sbar_DrawCharacter ( x - ofs + len - 32 , y , ' / ' ) ;
Sbar_DrawCharacter ( x - ofs + len - 24 , y , ' / ' ) ;
Sbar_DrawCharacter ( x - ofs + len - 16 , y , ' / ' ) ;
Sbar_DrawString ( x - ofs + len , y , str ) ;
glDisable ( GL_SCISSOR_TEST ) ;
}
/*
= = = = = = = = = = = = =
Sbar_itoa
= = = = = = = = = = = = =
*/
int Sbar_itoa ( int num , char * buf )
{
char * str ;
2011-10-19 20:10:49 +00:00
int pow10 ;
int dig ;
2010-02-15 23:26:55 +00:00
str = buf ;
if ( num < 0 )
{
* str + + = ' - ' ;
num = - num ;
}
for ( pow10 = 10 ; num > = pow10 ; pow10 * = 10 )
2011-10-19 20:10:49 +00:00
;
2010-02-15 23:26:55 +00:00
do
{
pow10 / = 10 ;
dig = num / pow10 ;
* str + + = ' 0 ' + dig ;
num - = dig * pow10 ;
} while ( pow10 ! = 1 ) ;
* str = 0 ;
return str - buf ;
}
/*
= = = = = = = = = = = = =
Sbar_DrawNum
= = = = = = = = = = = = =
*/
void Sbar_DrawNum ( int x , int y , int num , int digits , int color )
{
2011-10-19 20:10:49 +00:00
char str [ 12 ] ;
char * ptr ;
int l , frame ;
2010-02-15 23:26:55 +00:00
2011-01-10 10:35:40 +00:00
num = q_min ( 999 , num ) ; //johnfitz -- cap high values rather than truncating number
2010-02-15 23:26:55 +00:00
l = Sbar_itoa ( num , str ) ;
ptr = str ;
if ( l > digits )
ptr + = ( l - digits ) ;
if ( l < digits )
x + = ( digits - l ) * 24 ;
while ( * ptr )
{
if ( * ptr = = ' - ' )
frame = STAT_MINUS ;
else
frame = * ptr - ' 0 ' ;
Sbar_DrawPic ( x , y , sb_nums [ color ] [ frame ] ) ; //johnfitz -- DrawTransPic is obsolete
x + = 24 ;
ptr + + ;
}
}
//=============================================================================
int fragsort [ MAX_SCOREBOARD ] ;
int scoreboardlines ;
/*
= = = = = = = = = = = = = = =
Sbar_SortFrags
= = = = = = = = = = = = = = =
*/
2023-07-07 09:01:30 +00:00
void Sbar_SortFrags ( qboolean ignorespecs )
2010-02-15 23:26:55 +00:00
{
int i , j , k ;
2023-07-07 09:01:30 +00:00
int w1 , w2 ;
2010-02-15 23:26:55 +00:00
// sort by frags
scoreboardlines = 0 ;
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < cl . maxclients ; i + + )
2010-02-15 23:26:55 +00:00
{
if ( cl . scores [ i ] . name [ 0 ] )
{
2023-07-07 09:01:30 +00:00
if ( cl . scores [ i ] . spectator = = 1 & & ignorespecs )
continue ;
2010-02-15 23:26:55 +00:00
fragsort [ scoreboardlines ] = i ;
scoreboardlines + + ;
}
}
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < scoreboardlines ; i + + )
{
for ( j = 0 ; j < scoreboardlines - 1 - i ; j + + )
2023-07-07 09:01:30 +00:00
{ //spike: adding this so spectators end up at the bottom.
w1 = cl . scores [ fragsort [ j + 0 ] ] . spectator ! = 1 , w2 = cl . scores [ fragsort [ j + 1 ] ] . spectator ! = 1 ; //sort by spectatorness...
if ( w1 = = w2 )
w1 = cl . scores [ fragsort [ j + 0 ] ] . frags , w2 = cl . scores [ fragsort [ j + 1 ] ] . frags ; //then by frags
if ( w1 < w2 )
2010-02-15 23:26:55 +00:00
{
k = fragsort [ j ] ;
fragsort [ j ] = fragsort [ j + 1 ] ;
fragsort [ j + 1 ] = k ;
}
2011-10-19 20:10:49 +00:00
}
}
2010-02-15 23:26:55 +00:00
}
int Sbar_ColorForMap ( int m )
{
return m < 128 ? m + 8 : m + 8 ;
}
/*
= = = = = = = = = = = = = = =
Sbar_SoloScoreboard - - johnfitz - - new layout
= = = = = = = = = = = = = = =
*/
void Sbar_SoloScoreboard ( void )
{
2010-02-16 14:21:11 +00:00
char str [ 256 ] ;
2011-10-19 20:10:49 +00:00
int minutes , seconds , tens , units ;
int len ;
2010-02-15 23:26:55 +00:00
sprintf ( str , " Kills: %i/%i " , cl . stats [ STAT_MONSTERS ] , cl . stats [ STAT_TOTALMONSTERS ] ) ;
Sbar_DrawString ( 8 , 12 , str ) ;
sprintf ( str , " Secrets: %i/%i " , cl . stats [ STAT_SECRETS ] , cl . stats [ STAT_TOTALSECRETS ] ) ;
Sbar_DrawString ( 312 - strlen ( str ) * 8 , 12 , str ) ;
2010-02-18 12:55:19 +00:00
if ( ! fitzmode )
{ /* QuakeSpasm customization: */
2011-12-27 13:15:31 +00:00
q_snprintf ( str , sizeof ( str ) , " skill %i " , ( int ) ( skill . value + 0.5 ) ) ;
2010-02-18 12:55:19 +00:00
Sbar_DrawString ( 160 - strlen ( str ) * 4 , 12 , str ) ;
2011-12-27 13:15:31 +00:00
q_snprintf ( str , sizeof ( str ) , " %s (%s) " , cl . levelname , cl . mapname ) ;
2010-02-18 12:55:19 +00:00
len = strlen ( str ) ;
if ( len > 40 )
Sbar_DrawScrollString ( 0 , 4 , 320 , str ) ;
else
Sbar_DrawString ( 160 - len * 4 , 4 , str ) ;
return ;
}
minutes = cl . time / 60 ;
seconds = cl . time - 60 * minutes ;
tens = seconds / 10 ;
units = seconds - 10 * tens ;
sprintf ( str , " %i:%i%i " , minutes , tens , units ) ;
2010-02-15 23:26:55 +00:00
Sbar_DrawString ( 160 - strlen ( str ) * 4 , 12 , str ) ;
2010-02-18 12:55:19 +00:00
len = strlen ( cl . levelname ) ;
2010-02-15 23:26:55 +00:00
if ( len > 40 )
2010-02-18 12:55:19 +00:00
Sbar_DrawScrollString ( 0 , 4 , 320 , cl . levelname ) ;
2010-02-15 23:26:55 +00:00
else
2010-02-18 12:55:19 +00:00
Sbar_DrawString ( 160 - len * 4 , 4 , cl . levelname ) ;
2010-02-15 23:26:55 +00:00
}
/*
= = = = = = = = = = = = = = =
Sbar_DrawScoreboard
= = = = = = = = = = = = = = =
*/
void Sbar_DrawScoreboard ( void )
{
Sbar_SoloScoreboard ( ) ;
if ( cl . gametype = = GAME_DEATHMATCH )
Sbar_DeathmatchOverlay ( ) ;
}
//=============================================================================
/*
= = = = = = = = = = = = = = =
Sbar_DrawInventory
= = = = = = = = = = = = = = =
*/
void Sbar_DrawInventory ( void )
{
Fixed -Wformat-length warning from experimental gcc-7:
sbar.c: In function 'Sbar_DrawInventory':
sbar.c:673:18: warning: '%3i' directive writing between 3 and 11 bytes into a region of size 6 [-Wformat-length=]
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~
sbar.c:673:17: note: directive argument in the range [-2147483648, 999]
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~~~
sbar.c:673:3: note: format output between 4 and 12 bytes into a destination of size 6
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1346 af15c1b1-3010-417e-b628-4374ebc0bcbd
2016-10-07 20:00:27 +00:00
int i , val ;
2010-02-15 23:26:55 +00:00
char num [ 6 ] ;
float time ;
2011-10-19 20:10:49 +00:00
int flashon ;
2010-02-15 23:26:55 +00:00
if ( rogue )
{
if ( cl . stats [ STAT_ACTIVEWEAPON ] > = RIT_LAVA_NAILGUN )
Sbar_DrawPicAlpha ( 0 , - 24 , rsb_invbar [ 0 ] , scr_sbaralpha . value ) ; //johnfitz -- scr_sbaralpha
else
Sbar_DrawPicAlpha ( 0 , - 24 , rsb_invbar [ 1 ] , scr_sbaralpha . value ) ; //johnfitz -- scr_sbaralpha
}
else
{
Sbar_DrawPicAlpha ( 0 , - 24 , sb_ibar , scr_sbaralpha . value ) ; //johnfitz -- scr_sbaralpha
}
// weapons
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 7 ; i + + )
2010-02-15 23:26:55 +00:00
{
if ( cl . items & ( IT_SHOTGUN < < i ) )
{
time = cl . item_gettime [ i ] ;
flashon = ( int ) ( ( cl . time - time ) * 10 ) ;
2023-07-06 05:33:47 +00:00
if ( flashon < 0 )
{ //wait what? it happened in the future? no no no!
time = 0 ;
cl . item_gettime [ i ] = cl . time ;
}
2010-02-15 23:26:55 +00:00
if ( flashon > = 10 )
{
if ( cl . stats [ STAT_ACTIVEWEAPON ] = = ( IT_SHOTGUN < < i ) )
flashon = 1 ;
else
flashon = 0 ;
}
else
flashon = ( flashon % 5 ) + 2 ;
2011-10-19 20:10:49 +00:00
Sbar_DrawPic ( i * 24 , - 16 , sb_weapons [ flashon ] [ i ] ) ;
2010-02-15 23:26:55 +00:00
if ( flashon > 1 )
sb_updates = 0 ; // force update to remove flash
}
}
// MED 01/04/97
// hipnotic weapons
2011-10-19 20:10:49 +00:00
if ( hipnotic )
{
int grenadeflashing = 0 ;
for ( i = 0 ; i < 4 ; i + + )
{
if ( cl . items & ( 1 < < hipweapons [ i ] ) )
{
time = cl . item_gettime [ hipweapons [ i ] ] ;
flashon = ( int ) ( ( cl . time - time ) * 10 ) ;
if ( flashon > = 10 )
{
if ( cl . stats [ STAT_ACTIVEWEAPON ] = = ( 1 < < hipweapons [ i ] ) )
flashon = 1 ;
else
flashon = 0 ;
}
else
flashon = ( flashon % 5 ) + 2 ;
// check grenade launcher
if ( i = = 2 )
{
if ( cl . items & HIT_PROXIMITY_GUN )
{
if ( flashon )
{
grenadeflashing = 1 ;
Sbar_DrawPic ( 96 , - 16 , hsb_weapons [ flashon ] [ 2 ] ) ;
}
}
}
else if ( i = = 3 )
{
if ( cl . items & ( IT_SHOTGUN < < 4 ) )
{
if ( flashon & & ! grenadeflashing )
{
Sbar_DrawPic ( 96 , - 16 , hsb_weapons [ flashon ] [ 3 ] ) ;
}
else if ( ! grenadeflashing )
{
Sbar_DrawPic ( 96 , - 16 , hsb_weapons [ 0 ] [ 3 ] ) ;
}
}
else
Sbar_DrawPic ( 96 , - 16 , hsb_weapons [ flashon ] [ 4 ] ) ;
}
else
Sbar_DrawPic ( 176 + ( i * 24 ) , - 16 , hsb_weapons [ flashon ] [ i ] ) ;
if ( flashon > 1 )
sb_updates = 0 ; // force update to remove flash
}
}
}
2010-02-15 23:26:55 +00:00
if ( rogue )
{
// check for powered up weapon.
if ( cl . stats [ STAT_ACTIVEWEAPON ] > = RIT_LAVA_NAILGUN )
{
for ( i = 0 ; i < 5 ; i + + )
{
if ( cl . stats [ STAT_ACTIVEWEAPON ] = = ( RIT_LAVA_NAILGUN < < i ) )
{
Sbar_DrawPic ( ( i + 2 ) * 24 , - 16 , rsb_weapons [ i ] ) ;
}
}
}
}
// ammo counts
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 4 ; i + + )
2010-02-15 23:26:55 +00:00
{
Fixed -Wformat-length warning from experimental gcc-7:
sbar.c: In function 'Sbar_DrawInventory':
sbar.c:673:18: warning: '%3i' directive writing between 3 and 11 bytes into a region of size 6 [-Wformat-length=]
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~
sbar.c:673:17: note: directive argument in the range [-2147483648, 999]
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~~~
sbar.c:673:3: note: format output between 4 and 12 bytes into a destination of size 6
sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1346 af15c1b1-3010-417e-b628-4374ebc0bcbd
2016-10-07 20:00:27 +00:00
val = cl . stats [ STAT_SHELLS + i ] ;
val = ( val < 0 ) ? 0 : q_min ( 999 , val ) ; //johnfitz -- cap displayed value to 999
sprintf ( num , " %3i " , val ) ;
2010-02-15 23:26:55 +00:00
if ( num [ 0 ] ! = ' ' )
Sbar_DrawCharacter ( ( 6 * i + 1 ) * 8 + 2 , - 24 , 18 + num [ 0 ] - ' 0 ' ) ;
if ( num [ 1 ] ! = ' ' )
Sbar_DrawCharacter ( ( 6 * i + 2 ) * 8 + 2 , - 24 , 18 + num [ 1 ] - ' 0 ' ) ;
if ( num [ 2 ] ! = ' ' )
Sbar_DrawCharacter ( ( 6 * i + 3 ) * 8 + 2 , - 24 , 18 + num [ 2 ] - ' 0 ' ) ;
}
flashon = 0 ;
2011-10-19 20:10:49 +00:00
// items
for ( i = 0 ; i < 6 ; i + + )
{
if ( cl . items & ( 1 < < ( 17 + i ) ) )
{
time = cl . item_gettime [ 17 + i ] ;
if ( time & & time > cl . time - 2 & & flashon )
{ // flash frame
sb_updates = 0 ;
}
else
{
//MED 01/04/97 changed keys
if ( ! hipnotic | | ( i > 1 ) )
{
Sbar_DrawPic ( 192 + i * 16 , - 16 , sb_items [ i ] ) ;
}
}
if ( time & & time > cl . time - 2 )
sb_updates = 0 ;
}
}
//MED 01/04/97 added hipnotic items
// hipnotic items
if ( hipnotic )
{
for ( i = 0 ; i < 2 ; i + + )
{
if ( cl . items & ( 1 < < ( 24 + i ) ) )
{
time = cl . item_gettime [ 24 + i ] ;
if ( time & & time > cl . time - 2 & & flashon )
{ // flash frame
sb_updates = 0 ;
}
else
{
Sbar_DrawPic ( 288 + i * 16 , - 16 , hsb_items [ i ] ) ;
}
if ( time & & time > cl . time - 2 )
sb_updates = 0 ;
}
}
}
2010-02-15 23:26:55 +00:00
if ( rogue )
{
// new rogue items
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 2 ; i + + )
2010-02-15 23:26:55 +00:00
{
if ( cl . items & ( 1 < < ( 29 + i ) ) )
{
time = cl . item_gettime [ 29 + i ] ;
2011-10-19 20:10:49 +00:00
if ( time & & time > cl . time - 2 & & flashon )
2010-02-15 23:26:55 +00:00
{ // flash frame
sb_updates = 0 ;
}
else
{
Sbar_DrawPic ( 288 + i * 16 , - 16 , rsb_items [ i ] ) ;
}
2011-10-19 20:10:49 +00:00
if ( time & & time > cl . time - 2 )
2010-02-15 23:26:55 +00:00
sb_updates = 0 ;
}
}
}
else
{
// sigils
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < 4 ; i + + )
2010-02-15 23:26:55 +00:00
{
if ( cl . items & ( 1 < < ( 28 + i ) ) )
{
time = cl . item_gettime [ 28 + i ] ;
2011-10-19 20:10:49 +00:00
if ( time & & time > cl . time - 2 & & flashon )
2010-02-15 23:26:55 +00:00
{ // flash frame
sb_updates = 0 ;
}
else
Sbar_DrawPic ( 320 - 32 + i * 8 , - 16 , sb_sigil [ i ] ) ;
2011-10-19 20:10:49 +00:00
if ( time & & time > cl . time - 2 )
2010-02-15 23:26:55 +00:00
sb_updates = 0 ;
}
}
}
}
//=============================================================================
/*
= = = = = = = = = = = = = = =
Sbar_DrawFrags - - johnfitz - - heavy revision
= = = = = = = = = = = = = = =
*/
void Sbar_DrawFrags ( void )
{
2021-09-11 03:07:03 +00:00
int numscores , i , x ;
2011-10-19 20:10:49 +00:00
char num [ 12 ] ;
2010-02-15 23:26:55 +00:00
scoreboard_t * s ;
2023-07-07 09:01:30 +00:00
Sbar_SortFrags ( true ) ;
2010-02-15 23:26:55 +00:00
// draw the text
2011-01-10 10:35:40 +00:00
numscores = q_min ( scoreboardlines , 4 ) ;
2010-02-15 23:26:55 +00:00
2011-10-19 20:10:49 +00:00
for ( i = 0 , x = 184 ; i < numscores ; i + + , x + = 32 )
2010-02-15 23:26:55 +00:00
{
s = & cl . scores [ fragsort [ i ] ] ;
if ( ! s - > name [ 0 ] )
continue ;
// top color
2021-09-11 03:07:03 +00:00
Draw_FillPlayer ( x + 10 , 1 , 28 , 4 , s - > shirt , 1 ) ;
2010-02-15 23:26:55 +00:00
// bottom color
2021-09-11 03:07:03 +00:00
Draw_FillPlayer ( x + 10 , 5 , 28 , 3 , s - > pants , 1 ) ;
2010-02-15 23:26:55 +00:00
// number
sprintf ( num , " %3i " , s - > frags ) ;
Sbar_DrawCharacter ( x + 12 , - 24 , num [ 0 ] ) ;
Sbar_DrawCharacter ( x + 20 , - 24 , num [ 1 ] ) ;
Sbar_DrawCharacter ( x + 28 , - 24 , num [ 2 ] ) ;
// brackets
if ( fragsort [ i ] = = cl . viewentity - 1 )
{
Sbar_DrawCharacter ( x + 6 , - 24 , 16 ) ;
Sbar_DrawCharacter ( x + 32 , - 24 , 17 ) ;
}
}
}
//=============================================================================
/*
= = = = = = = = = = = = = = =
Sbar_DrawFace
= = = = = = = = = = = = = = =
*/
void Sbar_DrawFace ( void )
{
2011-10-19 20:10:49 +00:00
int f , anim ;
2010-02-15 23:26:55 +00:00
// PGM 01/19/97 - team color drawing
// PGM 03/02/97 - fixed so color swatch only appears in CTF modes
if ( rogue & & ( cl . maxclients ! = 1 ) & & ( teamplay . value > 3 ) & & ( teamplay . value < 7 ) )
{
2011-10-19 20:10:49 +00:00
int xofs ;
char num [ 12 ] ;
2010-02-15 23:26:55 +00:00
scoreboard_t * s ;
s = & cl . scores [ cl . viewentity - 1 ] ;
// draw background
if ( cl . gametype = = GAME_DEATHMATCH )
xofs = 113 ;
else
xofs = ( ( vid . width - 320 ) > > 1 ) + 113 ;
Sbar_DrawPic ( 112 , 0 , rsb_teambord ) ;
2021-09-11 03:07:03 +00:00
Draw_FillPlayer ( xofs , /*vid.height-*/ 24 + 3 , 22 , 9 , s - > shirt , 1 ) ; //johnfitz -- sbar coords are now relative
Draw_FillPlayer ( xofs , /*vid.height-*/ 24 + 12 , 22 , 9 , s - > pants , 1 ) ; //johnfitz -- sbar coords are now relative
2010-02-15 23:26:55 +00:00
// draw number
f = s - > frags ;
sprintf ( num , " %3i " , f ) ;
2021-09-11 03:07:03 +00:00
if ( s - > shirt . type = = 1 & & s - > shirt . basic = = 0 ) //white team. FIXME: vanilla says top, but I suspect it should be the lower colour, as that's the actual team nq sees.
2010-02-15 23:26:55 +00:00
{
if ( num [ 0 ] ! = ' ' )
Sbar_DrawCharacter ( 113 , 3 , 18 + num [ 0 ] - ' 0 ' ) ;
if ( num [ 1 ] ! = ' ' )
Sbar_DrawCharacter ( 120 , 3 , 18 + num [ 1 ] - ' 0 ' ) ;
if ( num [ 2 ] ! = ' ' )
Sbar_DrawCharacter ( 127 , 3 , 18 + num [ 2 ] - ' 0 ' ) ;
}
else
{
2011-10-19 20:10:49 +00:00
Sbar_DrawCharacter ( 113 , 3 , num [ 0 ] ) ;
Sbar_DrawCharacter ( 120 , 3 , num [ 1 ] ) ;
Sbar_DrawCharacter ( 127 , 3 , num [ 2 ] ) ;
2010-02-15 23:26:55 +00:00
}
return ;
}
// PGM 01/19/97 - team color drawing
2011-10-19 20:10:49 +00:00
if ( ( cl . items & ( IT_INVISIBILITY | IT_INVULNERABILITY ) )
= = ( IT_INVISIBILITY | IT_INVULNERABILITY ) )
2010-02-15 23:26:55 +00:00
{
Sbar_DrawPic ( 112 , 0 , sb_face_invis_invuln ) ;
return ;
}
if ( cl . items & IT_QUAD )
{
Sbar_DrawPic ( 112 , 0 , sb_face_quad ) ;
return ;
}
if ( cl . items & IT_INVISIBILITY )
{
Sbar_DrawPic ( 112 , 0 , sb_face_invis ) ;
return ;
}
if ( cl . items & IT_INVULNERABILITY )
{
Sbar_DrawPic ( 112 , 0 , sb_face_invuln ) ;
return ;
}
if ( cl . stats [ STAT_HEALTH ] > = 100 )
f = 4 ;
else
f = cl . stats [ STAT_HEALTH ] / 20 ;
2011-10-19 20:10:49 +00:00
if ( f < 0 ) // in case we ever decide to draw when health <= 0
f = 0 ;
2010-02-15 23:26:55 +00:00
if ( cl . time < = cl . faceanimtime )
{
anim = 1 ;
sb_updates = 0 ; // make sure the anim gets drawn over
}
else
anim = 0 ;
Sbar_DrawPic ( 112 , 0 , sb_faces [ f ] [ anim ] ) ;
}
2017-09-17 02:12:53 +00:00
static void Sbar_Voice ( int y )
{
cvar_t snd_voip_showmeter ;
int loudness ;
snd_voip_showmeter . value = 1 ;
if ( ! snd_voip_showmeter . value )
return ;
loudness = S_Voip_Loudness ( snd_voip_showmeter . value > = 2 ) ;
if ( loudness > = 0 )
{
int cw = 8 ;
int w ;
int x = 160 ;
int s , i ;
float range = loudness / 100.0f ;
w = ( 5 + 16 + 1 ) * cw ;
x - = w / 2 ;
Draw_Character ( x , y , ' M ' ) ; x + = cw ;
Draw_Character ( x , y , ' i ' ) ; x + = cw ;
Draw_Character ( x , y , ' c ' ) ; x + = cw ;
x + = cw ;
Draw_Character ( x , y , 0xe080 ) ; x + = cw ;
for ( s = x , i = 0 ; i < 16 ; i + + , x + = cw )
Draw_Character ( x , y , 0xe081 ) ;
Draw_Character ( x , y , 0xe082 ) ;
Draw_Character ( s + ( x - s ) * range - cw / 2 , y , 0xe083 ) ;
}
}
2010-02-15 23:26:55 +00:00
/*
= = = = = = = = = = = = = = =
Sbar_Draw
= = = = = = = = = = = = = = =
*/
void Sbar_Draw ( void )
{
float w ; //johnfitz
if ( scr_con_current = = vid . height )
return ; // console is full screen
2020-09-04 10:44:49 +00:00
if ( cl . qcvm . extfuncs . CSQC_DrawHud & & ! qcvm )
2018-05-01 00:35:14 +00:00
{
qboolean deathmatchoverlay = false ;
float s = CLAMP ( 1.0 , scr_sbarscale . value , ( float ) glwidth / 320.0 ) ;
sb_updates + + ;
GL_SetCanvas ( CANVAS_CSQC ) ; //johnfitz
glEnable ( GL_BLEND ) ; //in the finest tradition of glquake, we litter gl state calls all over the place. yay state trackers.
glDisable ( GL_ALPHA_TEST ) ; //in the finest tradition of glquake, we litter gl state calls all over the place. yay state trackers.
glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_MODULATE ) ;
PR_SwitchQCVM ( & cl . qcvm ) ;
2022-07-19 21:36:57 +00:00
pr_global_struct - > time = qcvm - > time ;
pr_global_struct - > frametime = qcvm - > frametime ;
2018-05-01 00:35:14 +00:00
if ( qcvm - > extglobals . cltime )
* qcvm - > extglobals . cltime = realtime ;
2021-03-18 09:04:08 +00:00
if ( qcvm - > extglobals . clframetime )
* qcvm - > extglobals . clframetime = host_frametime ;
2018-05-01 00:35:14 +00:00
if ( qcvm - > extglobals . player_localentnum )
* qcvm - > extglobals . player_localentnum = cl . viewentity ;
2023-07-07 09:01:30 +00:00
Sbar_SortFrags ( false ) ;
2018-05-01 00:35:14 +00:00
G_VECTORSET ( OFS_PARM0 , vid . width / s , vid . height / s , 0 ) ;
G_FLOAT ( OFS_PARM1 ) = sb_showscores ;
PR_ExecuteProgram ( cl . qcvm . extfuncs . CSQC_DrawHud ) ;
if ( cl . qcvm . extfuncs . CSQC_DrawScores )
{
G_VECTORSET ( OFS_PARM0 , vid . width / s , vid . height / s , 0 ) ;
G_FLOAT ( OFS_PARM1 ) = sb_showscores ;
if ( key_dest ! = key_menu )
PR_ExecuteProgram ( cl . qcvm . extfuncs . CSQC_DrawScores ) ;
}
else
deathmatchoverlay = ( sb_showscores | | cl . stats [ STAT_HEALTH ] < = 0 ) ;
PR_SwitchQCVM ( NULL ) ;
glDisable ( GL_BLEND ) ;
glEnable ( GL_ALPHA_TEST ) ;
glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_REPLACE ) ; //back to ignoring vertex colours.
glDisable ( GL_SCISSOR_TEST ) ;
glColor3f ( 1 , 1 , 1 ) ;
if ( deathmatchoverlay & & cl . gametype = = GAME_DEATHMATCH )
{
GL_SetCanvas ( CANVAS_SBAR ) ;
Sbar_DeathmatchOverlay ( ) ;
}
return ;
}
2010-02-15 23:26:55 +00:00
if ( cl . intermission )
return ; //johnfitz -- never draw sbar during intermission
2015-02-04 03:57:06 +00:00
if ( sb_updates > = vid . numpages & & ! gl_clear . value & & scr_sbaralpha . value > = 1 //johnfitz -- gl_clear, scr_sbaralpha
& & ! ( gl_glsl_gamma_able & & vid_gamma . value ! = 1 ) ) //ericw -- must draw sbar every frame if doing glsl gamma
2010-02-15 23:26:55 +00:00
return ;
sb_updates + + ;
GL_SetCanvas ( CANVAS_DEFAULT ) ; //johnfitz
2017-09-17 02:12:53 +00:00
if ( sb_lines > 24 )
Sbar_Voice ( - 32 ) ;
else if ( sb_lines > 0 )
Sbar_Voice ( - 8 ) ;
else
Sbar_Voice ( 16 ) ;
2010-02-15 23:26:55 +00:00
//johnfitz -- don't waste fillrate by clearing the area behind the sbar
w = CLAMP ( 320.0f , scr_sbarscale . value * 320.0f , ( float ) glwidth ) ;
if ( sb_lines & & glwidth > w )
{
if ( scr_sbaralpha . value < 1 )
Draw_TileClear ( 0 , glheight - sb_lines , glwidth , sb_lines ) ;
if ( cl . gametype = = GAME_DEATHMATCH )
Draw_TileClear ( w , glheight - sb_lines , glwidth - w , sb_lines ) ;
else
{
Draw_TileClear ( 0 , glheight - sb_lines , ( glwidth - w ) / 2.0f , sb_lines ) ;
Draw_TileClear ( ( glwidth - w ) / 2.0f + w , glheight - sb_lines , ( glwidth - w ) / 2.0f , sb_lines ) ;
}
}
//johnfitz
GL_SetCanvas ( CANVAS_SBAR ) ; //johnfitz
if ( scr_viewsize . value < 110 ) //johnfitz -- check viewsize instead of sb_lines
{
Sbar_DrawInventory ( ) ;
if ( cl . maxclients ! = 1 )
Sbar_DrawFrags ( ) ;
}
if ( sb_showscores | | cl . stats [ STAT_HEALTH ] < = 0 )
{
Sbar_DrawPicAlpha ( 0 , 0 , sb_scorebar , scr_sbaralpha . value ) ; //johnfitz -- scr_sbaralpha
Sbar_DrawScoreboard ( ) ;
sb_updates = 0 ;
}
else if ( scr_viewsize . value < 120 ) //johnfitz -- check viewsize instead of sb_lines
{
Sbar_DrawPicAlpha ( 0 , 0 , sb_sbar , scr_sbaralpha . value ) ; //johnfitz -- scr_sbaralpha
// keys (hipnotic only)
//MED 01/04/97 moved keys here so they would not be overwritten
if ( hipnotic )
{
2011-10-19 20:10:49 +00:00
if ( cl . items & IT_KEY1 )
Sbar_DrawPic ( 209 , 3 , sb_items [ 0 ] ) ;
if ( cl . items & IT_KEY2 )
Sbar_DrawPic ( 209 , 12 , sb_items [ 1 ] ) ;
2010-02-15 23:26:55 +00:00
}
2011-10-19 20:10:49 +00:00
// armor
2010-02-15 23:26:55 +00:00
if ( cl . items & IT_INVULNERABILITY )
{
Sbar_DrawNum ( 24 , 0 , 666 , 3 , 1 ) ;
Sbar_DrawPic ( 0 , 0 , draw_disc ) ;
}
else
{
if ( rogue )
{
Sbar_DrawNum ( 24 , 0 , cl . stats [ STAT_ARMOR ] , 3 ,
cl . stats [ STAT_ARMOR ] < = 25 ) ;
if ( cl . items & RIT_ARMOR3 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 2 ] ) ;
else if ( cl . items & RIT_ARMOR2 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 1 ] ) ;
else if ( cl . items & RIT_ARMOR1 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 0 ] ) ;
}
else
{
Sbar_DrawNum ( 24 , 0 , cl . stats [ STAT_ARMOR ] , 3
, cl . stats [ STAT_ARMOR ] < = 25 ) ;
if ( cl . items & IT_ARMOR3 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 2 ] ) ;
else if ( cl . items & IT_ARMOR2 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 1 ] ) ;
else if ( cl . items & IT_ARMOR1 )
Sbar_DrawPic ( 0 , 0 , sb_armor [ 0 ] ) ;
}
}
// face
Sbar_DrawFace ( ) ;
// health
Sbar_DrawNum ( 136 , 0 , cl . stats [ STAT_HEALTH ] , 3
, cl . stats [ STAT_HEALTH ] < = 25 ) ;
// ammo icon
if ( rogue )
{
if ( cl . items & RIT_SHELLS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 0 ] ) ;
else if ( cl . items & RIT_NAILS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 1 ] ) ;
else if ( cl . items & RIT_ROCKETS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 2 ] ) ;
else if ( cl . items & RIT_CELLS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 3 ] ) ;
else if ( cl . items & RIT_LAVA_NAILS )
Sbar_DrawPic ( 224 , 0 , rsb_ammo [ 0 ] ) ;
else if ( cl . items & RIT_PLASMA_AMMO )
Sbar_DrawPic ( 224 , 0 , rsb_ammo [ 1 ] ) ;
else if ( cl . items & RIT_MULTI_ROCKETS )
Sbar_DrawPic ( 224 , 0 , rsb_ammo [ 2 ] ) ;
}
else
{
if ( cl . items & IT_SHELLS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 0 ] ) ;
else if ( cl . items & IT_NAILS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 1 ] ) ;
else if ( cl . items & IT_ROCKETS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 2 ] ) ;
else if ( cl . items & IT_CELLS )
Sbar_DrawPic ( 224 , 0 , sb_ammo [ 3 ] ) ;
}
Sbar_DrawNum ( 248 , 0 , cl . stats [ STAT_AMMO ] , 3 ,
cl . stats [ STAT_AMMO ] < = 10 ) ;
}
//johnfitz -- removed the vid.width > 320 check here
if ( cl . gametype = = GAME_DEATHMATCH )
Sbar_MiniDeathmatchOverlay ( ) ;
}
//=============================================================================
/*
= = = = = = = = = = = = = = = = = =
Sbar_IntermissionNumber
= = = = = = = = = = = = = = = = = =
*/
void Sbar_IntermissionNumber ( int x , int y , int num , int digits , int color )
{
2011-10-19 20:10:49 +00:00
char str [ 12 ] ;
char * ptr ;
int l , frame ;
2010-02-15 23:26:55 +00:00
l = Sbar_itoa ( num , str ) ;
ptr = str ;
if ( l > digits )
ptr + = ( l - digits ) ;
if ( l < digits )
x + = ( digits - l ) * 24 ;
while ( * ptr )
{
if ( * ptr = = ' - ' )
frame = STAT_MINUS ;
else
frame = * ptr - ' 0 ' ;
Draw_Pic ( x , y , sb_nums [ color ] [ frame ] ) ; //johnfitz -- stretched menus
x + = 24 ;
ptr + + ;
}
}
/*
= = = = = = = = = = = = = = = = = =
Sbar_DeathmatchOverlay
= = = = = = = = = = = = = = = = = =
*/
void Sbar_DeathmatchOverlay ( void )
{
2011-10-19 20:10:49 +00:00
qpic_t * pic ;
int i , k , l ;
int x , y , f ;
char num [ 12 ] ;
2010-02-15 23:26:55 +00:00
scoreboard_t * s ;
GL_SetCanvas ( CANVAS_MENU ) ; //johnfitz
pic = Draw_CachePic ( " gfx/ranking.lmp " ) ;
M_DrawPic ( ( 320 - pic - > width ) / 2 , 8 , pic ) ;
// scores
2023-07-07 09:01:30 +00:00
Sbar_SortFrags ( false ) ;
2010-02-15 23:26:55 +00:00
// draw the text
l = scoreboardlines ;
x = 80 ; //johnfitz -- simplified becuase some positioning is handled elsewhere
y = 40 ;
2011-10-19 20:10:49 +00:00
for ( i = 0 ; i < l ; i + + )
2010-02-15 23:26:55 +00:00
{
k = fragsort [ i ] ;
s = & cl . scores [ k ] ;
if ( ! s - > name [ 0 ] )
continue ;
// draw background
2017-09-17 02:12:53 +00:00
if ( S_Voip_Speaking ( k ) ) //spike -- display an underlay for people who are speaking
Draw_Fill ( x , y , 320 - x * 2 , 8 , ( ( k + 1 ) = = cl . viewentity ) ? 75 : 73 , 1 ) ;
2023-07-07 09:01:30 +00:00
else
Draw_Fill ( x , y , 320 - x * 2 , 8 , 0 , 0.3 ) ; //or darken it for readability. noisy backgrounds make text hard to read.
2017-09-17 02:12:53 +00:00
2023-07-07 09:01:30 +00:00
if ( s - > spectator = = 1 ) //2 is 'spectator-with-scores' (temporarily inactive players).
{
M_PrintWhite ( x , y , " spect " ) ;
}
else
{
Draw_FillPlayer ( x , y , 40 , 4 , s - > shirt , 1 ) ; //johnfitz -- stretched overlays
Draw_FillPlayer ( x , y + 4 , 40 , 4 , s - > pants , 1 ) ; //johnfitz -- stretched overlays
2010-02-15 23:26:55 +00:00
2023-07-07 09:01:30 +00:00
// draw number
f = s - > frags ;
sprintf ( num , " %3i " , f ) ;
2010-02-15 23:26:55 +00:00
2023-07-07 09:01:30 +00:00
Draw_Character ( x + 8 , y , num [ 0 ] ) ; //johnfitz -- stretched overlays
Draw_Character ( x + 16 , y , num [ 1 ] ) ; //johnfitz -- stretched overlays
Draw_Character ( x + 24 , y , num [ 2 ] ) ; //johnfitz -- stretched overlays
2010-02-15 23:26:55 +00:00
2023-07-07 09:01:30 +00:00
if ( k = = cl . viewentity - 1 )
Draw_Character ( x - 8 , y , 12 ) ; //johnfitz -- stretched overlays
}
2010-02-15 23:26:55 +00:00
#if 0
{
int total ;
int n , minutes , tens , units ;
// draw time
total = cl . completed_time - s - > entertime ;
minutes = ( int ) total / 60 ;
n = total - minutes * 60 ;
tens = n / 10 ;
units = n % 10 ;
sprintf ( num , " %3i:%i%i " , minutes , tens , units ) ;
M_Print ( x + 48 , y , num ) ; //johnfitz -- was Draw_String, changed for stretched overlays
}
# endif
2017-09-17 02:12:53 +00:00
sprintf ( num , " %4i " , s - > ping ) ;
2023-07-07 09:01:30 +00:00
M_PrintWhite ( x - 8 * 5 , y , num ) ;
2017-09-17 02:12:53 +00:00
2010-02-15 23:26:55 +00:00
// draw name
M_Print ( x + 64 , y , s - > name ) ; //johnfitz -- was Draw_String, changed for stretched overlays
y + = 10 ;
}
GL_SetCanvas ( CANVAS_SBAR ) ; //johnfitz
2017-09-17 02:12:53 +00:00
if ( ! cls . message . cursize & & cl . expectingpingtimes < realtime )
{
cl . expectingpingtimes = realtime + 5 ;
MSG_WriteByte ( & cls . message , clc_stringcmd ) ;
MSG_WriteString ( & cls . message , " ping " ) ;
}
2010-02-15 23:26:55 +00:00
}
/*
= = = = = = = = = = = = = = = = = =
Sbar_MiniDeathmatchOverlay
= = = = = = = = = = = = = = = = = =
*/
void Sbar_MiniDeathmatchOverlay ( void )
{
2021-09-11 03:07:03 +00:00
int i , k , x , y , f , numlines ;
2011-10-19 20:10:49 +00:00
char num [ 12 ] ;
float scale ; //johnfitz
2010-02-15 23:26:55 +00:00
scoreboard_t * s ;
2022-06-12 11:32:28 +00:00
scale = CLAMP ( 1.0f , scr_sbarscale . value , ( float ) glwidth / 320.0f ) ; //johnfitz
2010-02-15 23:26:55 +00:00
//MAX_SCOREBOARDNAME = 32, so total width for this overlay plus sbar is 632, but we can cut off some i guess
if ( glwidth / scale < 512 | | scr_viewsize . value > = 120 ) //johnfitz -- test should consider scr_sbarscale
return ;
// scores
2023-07-07 09:01:30 +00:00
Sbar_SortFrags ( true ) ;
2010-02-15 23:26:55 +00:00
// draw the text
numlines = ( scr_viewsize . value > = 110 ) ? 3 : 6 ; //johnfitz
//find us
for ( i = 0 ; i < scoreboardlines ; i + + )
if ( fragsort [ i ] = = cl . viewentity - 1 )
break ;
2011-10-19 20:10:49 +00:00
if ( i = = scoreboardlines ) // we're not there
i = 0 ;
else // figure out start
i = i - numlines / 2 ;
if ( i > scoreboardlines - numlines )
i = scoreboardlines - numlines ;
if ( i < 0 )
i = 0 ;
2010-02-15 23:26:55 +00:00
x = 324 ;
y = ( scr_viewsize . value > = 110 ) ? 24 : 0 ; //johnfitz -- start at the right place
for ( ; i < scoreboardlines & & y < = 48 ; i + + , y + = 8 ) //johnfitz -- change y init, test, inc
{
k = fragsort [ i ] ;
s = & cl . scores [ k ] ;
if ( ! s - > name [ 0 ] )
continue ;
// colors
2021-09-11 03:07:03 +00:00
Draw_FillPlayer ( x , y + 1 , 40 , 4 , s - > shirt , 1 ) ;
Draw_FillPlayer ( x , y + 5 , 40 , 3 , s - > pants , 1 ) ;
2010-02-15 23:26:55 +00:00
// number
f = s - > frags ;
sprintf ( num , " %3i " , f ) ;
2011-10-19 20:10:49 +00:00
Draw_Character ( x + 8 , y , num [ 0 ] ) ;
Draw_Character ( x + 16 , y , num [ 1 ] ) ;
Draw_Character ( x + 24 , y , num [ 2 ] ) ;
2010-02-15 23:26:55 +00:00
// brackets
if ( k = = cl . viewentity - 1 )
{
2011-10-19 20:10:49 +00:00
Draw_Character ( x , y , 16 ) ;
Draw_Character ( x + 32 , y , 17 ) ;
2010-02-15 23:26:55 +00:00
}
// name
Draw_String ( x + 48 , y , s - > name ) ;
}
}
/*
= = = = = = = = = = = = = = = = = =
Sbar_IntermissionOverlay
= = = = = = = = = = = = = = = = = =
*/
void Sbar_IntermissionOverlay ( void )
{
qpic_t * pic ;
2011-10-19 20:10:49 +00:00
int dig ;
int num ;
2010-02-15 23:26:55 +00:00
2020-09-04 10:44:49 +00:00
if ( cl . qcvm . extfuncs . CSQC_DrawScores & & ! qcvm )
2018-05-01 00:35:14 +00:00
{
float s = CLAMP ( 1.0 , scr_sbarscale . value , ( float ) glwidth / 320.0 ) ;
GL_SetCanvas ( CANVAS_CSQC ) ;
glEnable ( GL_BLEND ) ;
glDisable ( GL_ALPHA_TEST ) ;
glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_MODULATE ) ;
PR_SwitchQCVM ( & cl . qcvm ) ;
if ( qcvm - > extglobals . cltime )
* qcvm - > extglobals . cltime = realtime ;
2021-03-18 09:04:08 +00:00
if ( qcvm - > extglobals . clframetime )
* qcvm - > extglobals . clframetime = host_frametime ;
2018-05-01 00:35:14 +00:00
if ( qcvm - > extglobals . player_localentnum )
* qcvm - > extglobals . player_localentnum = cl . viewentity ;
if ( qcvm - > extglobals . intermission )
* qcvm - > extglobals . intermission = cl . intermission ;
if ( qcvm - > extglobals . intermission_time )
* qcvm - > extglobals . intermission_time = cl . completed_time ;
pr_global_struct - > time = cl . time ;
2021-03-18 09:04:08 +00:00
pr_global_struct - > frametime = host_frametime ;
2023-07-07 09:01:30 +00:00
Sbar_SortFrags ( false ) ;
2018-05-01 00:35:14 +00:00
G_VECTORSET ( OFS_PARM0 , vid . width / s , vid . height / s , 0 ) ;
G_FLOAT ( OFS_PARM1 ) = sb_showscores ;
PR_ExecuteProgram ( cl . qcvm . extfuncs . CSQC_DrawScores ) ;
PR_SwitchQCVM ( NULL ) ;
glDisable ( GL_BLEND ) ;
glEnable ( GL_ALPHA_TEST ) ;
glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_REPLACE ) ;
glDisable ( GL_SCISSOR_TEST ) ;
glColor3f ( 1 , 1 , 1 ) ;
return ;
}
2010-02-15 23:26:55 +00:00
if ( cl . gametype = = GAME_DEATHMATCH )
{
Sbar_DeathmatchOverlay ( ) ;
return ;
}
GL_SetCanvas ( CANVAS_MENU ) ; //johnfitz
pic = Draw_CachePic ( " gfx/complete.lmp " ) ;
Draw_Pic ( 64 , 24 , pic ) ;
pic = Draw_CachePic ( " gfx/inter.lmp " ) ;
Draw_Pic ( 0 , 56 , pic ) ;
dig = cl . completed_time / 60 ;
Sbar_IntermissionNumber ( 152 , 64 , dig , 3 , 0 ) ; //johnfitz -- was 160
num = cl . completed_time - dig * 60 ;
Draw_Pic ( 224 , 64 , sb_colon ) ; //johnfitz -- was 234
Draw_Pic ( 240 , 64 , sb_nums [ 0 ] [ num / 10 ] ) ; //johnfitz -- was 246
Draw_Pic ( 264 , 64 , sb_nums [ 0 ] [ num % 10 ] ) ; //johnfitz -- was 266
Sbar_IntermissionNumber ( 152 , 104 , cl . stats [ STAT_SECRETS ] , 3 , 0 ) ; //johnfitz -- was 160
Draw_Pic ( 224 , 104 , sb_slash ) ; //johnfitz -- was 232
Sbar_IntermissionNumber ( 240 , 104 , cl . stats [ STAT_TOTALSECRETS ] , 3 , 0 ) ; //johnfitz -- was 248
Sbar_IntermissionNumber ( 152 , 144 , cl . stats [ STAT_MONSTERS ] , 3 , 0 ) ; //johnfitz -- was 160
Draw_Pic ( 224 , 144 , sb_slash ) ; //johnfitz -- was 232
Sbar_IntermissionNumber ( 240 , 144 , cl . stats [ STAT_TOTALMONSTERS ] , 3 , 0 ) ; //johnfitz -- was 248
}
/*
= = = = = = = = = = = = = = = = = =
Sbar_FinaleOverlay
= = = = = = = = = = = = = = = = = =
*/
void Sbar_FinaleOverlay ( void )
{
qpic_t * pic ;
GL_SetCanvas ( CANVAS_MENU ) ; //johnfitz
pic = Draw_CachePic ( " gfx/finale.lmp " ) ;
Draw_Pic ( ( 320 - pic - > width ) / 2 , 16 , pic ) ; //johnfitz -- stretched menus
}
2011-10-19 20:10:49 +00:00