2020-08-01 19:23:33 +00:00
//-------------------------------------------------------------------------
/*
Copyright ( C ) 2010 - 2019 EDuke32 developers and contributors
Copyright ( C ) 2019 Nuke . YKT
This file is part of NBlood .
NBlood is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License version 2
as published by the Free Software Foundation .
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 . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*/
//-------------------------------------------------------------------------
# include "ns.h" // Must come before everything else!
# include <stdlib.h>
# include <string.h>
# include "compat.h"
# include "build.h"
# include "v_font.h"
2020-12-09 14:56:32 +00:00
# include "blood.h"
2020-08-01 19:23:33 +00:00
# include "zstring.h"
2020-10-04 16:31:48 +00:00
# include "razemenu.h"
2020-08-01 19:23:33 +00:00
# include "gstrings.h"
# include "v_2ddrawer.h"
# include "v_video.h"
# include "v_font.h"
2020-08-02 06:39:51 +00:00
# include "statusbar.h"
2020-09-06 18:49:43 +00:00
# include "automap.h"
2020-10-04 16:31:48 +00:00
# include "v_draw.h"
2020-11-22 12:28:20 +00:00
# include "gamecvars.h"
2020-08-01 19:23:33 +00:00
CVARD ( Bool , hud_powerupduration , true , CVAR_ARCHIVE /*|CVAR_FRONTEND_BLOOD*/ , " enable/disable displaying the remaining seconds for power-ups " )
BEGIN_BLD_NS
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
static int gPackIcons [ 5 ] = {
2020-08-01 19:23:33 +00:00
2569 , 2564 , 2566 , 2568 , 2560
} ;
struct PACKICON2 {
short nTile ;
int nScale ;
int nYOffs ;
} ;
PACKICON2 gPackIcons2 [ ] = {
{ 519 , ( int ) ( 65536 * 0.5 ) , 0 } ,
{ 830 , ( int ) ( 65536 * 0.3 ) , 0 } ,
{ 760 , ( int ) ( 65536 * 0.6 ) , 0 } ,
{ 839 , ( int ) ( 65536 * 0.5 ) , - 4 } ,
{ 827 , ( int ) ( 65536 * 0.4 ) , 0 } ,
} ;
struct AMMOICON {
short nTile ;
int nScale ;
int nYOffs ;
} ;
2020-08-02 06:39:51 +00:00
static AMMOICON gAmmoIcons [ ] = {
2020-08-01 19:23:33 +00:00
{ - 1 , 0 , 0 } ,
{ 816 , ( int ) ( 65536 * 0.5 ) , 0 } ,
{ 619 , ( int ) ( 65536 * 0.8 ) , 0 } ,
{ 817 , ( int ) ( 65536 * 0.7 ) , 3 } ,
{ 801 , ( int ) ( 65536 * 0.5 ) , - 6 } ,
{ 589 , ( int ) ( 65536 * 0.7 ) , 2 } ,
{ 618 , ( int ) ( 65536 * 0.5 ) , 4 } ,
{ 548 , ( int ) ( 65536 * 0.3 ) , - 6 } ,
{ 820 , ( int ) ( 65536 * 0.3 ) , - 6 } ,
{ 525 , ( int ) ( 65536 * 0.6 ) , - 6 } ,
{ 811 , ( int ) ( 65536 * 0.5 ) , 2 } ,
{ 810 , ( int ) ( 65536 * 0.45 ) , 2 } ,
} ;
struct POWERUPDISPLAY
{
int nTile ;
float nScaleRatio ;
int yOffset ;
int remainingDuration ;
} ;
2020-08-02 06:39:51 +00:00
2020-10-28 18:27:12 +00:00
class DBloodStatusBar : public DBaseStatusBar
2020-08-01 19:23:33 +00:00
{
2020-10-28 18:27:12 +00:00
DECLARE_CLASS ( DBloodStatusBar , DBaseStatusBar )
2020-08-02 06:39:51 +00:00
enum NewRSFlags
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
RS_CENTERBOTTOM = 16384 ,
} ;
2020-08-02 11:35:34 +00:00
2020-10-28 19:04:53 +00:00
TObjPtr < DHUDFont * > smallf , tinyf ;
2020-08-02 11:35:34 +00:00
public :
DBloodStatusBar ( )
{
2020-10-28 19:04:53 +00:00
smallf = Create < DHUDFont > ( SmallFont , 0 , Off , 0 , 0 ) ;
tinyf = Create < DHUDFont > ( gFont [ 4 ] , 4 , CellRight , 0 , 0 ) ;
2020-08-02 11:35:34 +00:00
}
private :
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-02 11:35:34 +00:00
void DrawStatSprite ( int nTile , double x , double y , int nShade = 0 , int nPalette = 0 , unsigned int nStat = 0 , int nScale = 65536 , ERenderStyle style = STYLE_Normal , int align = DI_SCREEN_AUTO )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
int flags = align | ( ( nStat & RS_CENTERBOTTOM ) ? DI_ITEM_CENTER_BOTTOM : ( nStat & RS_TOPLEFT ) ? DI_ITEM_LEFT_TOP : DI_ITEM_RELCENTER ) ;
2020-08-02 06:39:51 +00:00
double alpha = 1. ;
double scale = nScale / 65536. ;
2021-05-02 22:15:40 +00:00
DrawGraphic ( tileGetTexture ( nTile , true ) , x , y , flags , alpha , - 1 , - 1 , scale , scale , STYLE_Translucent , shadeToLight ( nShade ) , TRANSLATION ( Translation_Remap , nPalette ) , style ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-02 11:35:34 +00:00
void DrawStatMaskedSprite ( int nTile , double x , double y , int nShade = 0 , int nPalette = 0 , unsigned int nStat = 0 , int nScale = 65536 , int align = DI_SCREEN_AUTO )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatSprite ( nTile , x , y , nShade , nPalette , nStat , nScale , STYLE_Translucent , align ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-02 11:35:34 +00:00
void DrawStatNumber ( const char * pFormat , int nNumber , int nTile , double x , double y , int nShade , int nPalette , unsigned int nStat = 0 , int nScale = 65536 , int align = 0 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
double width = ( tileWidth ( nTile ) + 1 ) * ( nScale / 65536. ) ;
char tempbuf [ 80 ] ;
mysnprintf ( tempbuf , 80 , pFormat , nNumber ) ;
2020-08-02 11:35:34 +00:00
x + = 0.5 ;
y + = 0.5 ; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem.
2020-08-02 06:39:51 +00:00
for ( unsigned int i = 0 ; tempbuf [ i ] ; i + + , x + = width )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( tempbuf [ i ] = = ' ' ) continue ;
2020-08-02 11:35:34 +00:00
DrawStatSprite ( nTile + tempbuf [ i ] - ' 0 ' , x , y , nShade , nPalette , nStat , nScale , STYLE_Translucent , align ) ;
2020-08-01 19:23:33 +00:00
}
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
2020-08-28 01:38:56 +00:00
//
//
//
//---------------------------------------------------------------------------
void DrawCharArray ( const char * string , int nTile , double x , double y , int nShade , int nPalette , unsigned int nStat = 0 , int nScale = 65536 , int align = 0 )
{
double width = ( tileWidth ( nTile ) + 1 ) * ( nScale / 65536. ) ;
x + = 0.5 ;
y + = 0.5 ; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem.
for ( unsigned int i = 0 ; string [ i ] ; i + + , x + = width )
{
// Hackasaurus rex to give me a slash when drawing the weapon count of a reloadable gun.
if ( string [ i ] = = 47 & & nTile = = kSBarNumberAmmo )
{
2020-09-01 22:45:27 +00:00
DrawStatSprite ( 9280 , x , y , nShade , nPalette , nStat , nScale , STYLE_Translucent , align ) ;
2020-08-28 01:38:56 +00:00
}
else
{
DrawStatSprite ( nTile + string [ i ] - ' 0 ' , x , y , nShade , nPalette , nStat , nScale , STYLE_Translucent , align ) ;
}
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-02 06:39:51 +00:00
void TileHGauge ( int nTile , double x , double y , int nMult , int nDiv , int nStat = 0 , int nScale = 65536 )
2020-08-01 19:23:33 +00:00
{
2020-11-22 23:18:07 +00:00
int w = tileWidth ( nTile ) ;
2021-01-04 11:36:54 +00:00
int bx = scale ( MulScale ( w , nScale , 16 ) , nMult , nDiv ) + x ;
2020-11-22 23:18:07 +00:00
double scale = double ( bx - x ) / w ;
2020-08-10 21:06:24 +00:00
double sc = nScale / 65536. ;
2021-05-02 22:15:40 +00:00
DrawGraphic ( tileGetTexture ( nTile , true ) , x , y , DI_ITEM_LEFT_TOP , 1. , - 1 , - 1 , sc , sc , STYLE_Translucent , 0xffffffff , 0 , scale ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-02 11:35:34 +00:00
void PrintLevelStats ( PLAYER * pPlayer , int bottomy )
2020-08-01 19:23:33 +00:00
{
2020-08-24 21:59:09 +00:00
FLevelStats stats { } ;
stats . fontscale = 1. ;
stats . spacing = SmallFont - > GetHeight ( ) + 1 ;
stats . screenbottomspace = bottomy ;
stats . font = SmallFont ;
stats . letterColor = CR_DARKRED ;
stats . standardColor = CR_DARKGRAY ;
2021-04-28 22:56:36 +00:00
stats . time = gFrameCount / GameTicRate ;
2020-08-24 21:59:09 +00:00
2020-08-24 17:47:09 +00:00
if ( automapMode = = am_full )
{
2020-09-29 20:20:25 +00:00
bool textfont = am_textfont ;
2020-08-24 21:59:09 +00:00
if ( ! am_textfont )
2020-09-29 20:20:25 +00:00
{
// For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it.
auto p = GStrings [ " REQUIRED_CHARACTERS " ] ;
if ( p & & * p ) textfont = true ;
}
if ( ! textfont )
2020-08-24 21:59:09 +00:00
{
stats . font = SmallFont2 ;
stats . spacing = 6 ;
}
if ( hud_size < = Hud_StbarOverlay ) stats . screenbottomspace = 56 ;
2020-10-28 18:27:12 +00:00
DBaseStatusBar : : PrintAutomapInfo ( stats , textfont ) ;
2020-08-24 17:47:09 +00:00
}
if ( automapMode = = am_off & & hud_stats )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
stats . completeColor = CR_DARKGREEN ;
2020-08-02 06:39:51 +00:00
2020-09-01 19:27:32 +00:00
stats . kills = gKillMgr . Kills ;
stats . maxkills = gKillMgr . TotalKills ;
2020-08-02 11:35:34 +00:00
stats . frags = gGameOptions . nGameType = = 3 ? pPlayer - > fragCount : - 1 ;
2020-11-26 06:48:34 +00:00
stats . secrets = gSecretMgr . Founds ;
stats . supersecrets = gSecretMgr . Super ;
stats . maxsecrets = max ( gSecretMgr . Founds , gSecretMgr . Total ) ; // If we found more than there are, increase the total. Some levels have a bugged counter.
2021-05-01 18:08:51 +00:00
stats . time = Scale ( PlayClock , 1000 , 120 ) ;
2020-08-02 06:39:51 +00:00
2020-10-28 18:27:12 +00:00
DBaseStatusBar : : PrintLevelStats ( stats ) ;
2020-08-02 11:35:34 +00:00
}
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
2020-11-23 06:49:36 +00:00
//
2020-08-02 06:39:51 +00:00
//
//---------------------------------------------------------------------------
2020-11-23 06:49:36 +00:00
enum { nPowerUps = 11 } ;
2020-08-02 06:39:51 +00:00
void sortPowerUps ( POWERUPDISPLAY * powerups ) {
2020-11-23 06:49:36 +00:00
for ( int i = 1 ; i < nPowerUps ; i + + )
2020-08-01 19:23:33 +00:00
{
2020-11-23 06:49:36 +00:00
for ( int j = 0 ; j < nPowerUps - i ; j + + )
2020-08-02 06:39:51 +00:00
{
if ( powerups [ j ] . remainingDuration > powerups [ j + 1 ] . remainingDuration )
{
POWERUPDISPLAY temp = powerups [ j ] ;
powerups [ j ] = powerups [ j + 1 ] ;
powerups [ j + 1 ] = temp ;
}
}
2020-08-01 19:23:33 +00:00
}
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
void viewDrawPowerUps ( PLAYER * pPlayer )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( ! hud_powerupduration )
return ;
2020-11-23 06:49:36 +00:00
POWERUPDISPLAY powerups [ nPowerUps ] ;
powerups [ 0 ] = { gPowerUpInfo [ kPwUpShadowCloak ] . picnum , 0.4f , 0 , pPlayer - > pwUpTime [ kPwUpShadowCloak ] } ; // Invisibility
powerups [ 1 ] = { gPowerUpInfo [ kPwUpReflectShots ] . picnum , 0.4f , 5 , pPlayer - > pwUpTime [ kPwUpReflectShots ] } ; // Reflects enemy shots
powerups [ 2 ] = { gPowerUpInfo [ kPwUpDeathMask ] . picnum , 0.3f , 9 , pPlayer - > pwUpTime [ kPwUpDeathMask ] } ; // Invulnerability
powerups [ 3 ] = { gPowerUpInfo [ kPwUpTwoGuns ] . picnum , 0.3f , 5 , pPlayer - > pwUpTime [ kPwUpTwoGuns ] } ; // Guns Akimbo
powerups [ 4 ] = { gPowerUpInfo [ kPwUpShadowCloakUseless ] . picnum , 0.4f , 9 , pPlayer - > pwUpTime [ kPwUpShadowCloakUseless ] } ; // Does nothing, only appears at near the end of Cryptic Passage's Lost Monastery (CP04)
// Not in official maps, but custom maps can use them
powerups [ 5 ] = { gPowerUpInfo [ kPwUpFeatherFall ] . picnum , 0.3f , 7 , pPlayer - > pwUpTime [ kPwUpFeatherFall ] } ; // Makes player immune to fall damage
powerups [ 6 ] = { gPowerUpInfo [ kPwUpGasMask ] . picnum , 0.4f , 4 , pPlayer - > pwUpTime [ kPwUpGasMask ] } ; // Makes player immune to choke damage
powerups [ 7 ] = { gPowerUpInfo [ kPwUpDoppleganger ] . picnum , 0.5f , 5 , pPlayer - > pwUpTime [ kPwUpDoppleganger ] } ; // Works in multiplayer, it swaps player's team colors, so enemy team player thinks it's a team mate
powerups [ 8 ] = { gPowerUpInfo [ kPwUpAsbestArmor ] . picnum , 0.3f , 9 , pPlayer - > pwUpTime [ kPwUpAsbestArmor ] } ; // Makes player immune to fire damage and draws HUD
powerups [ 9 ] = { gPowerUpInfo [ kPwUpGrowShroom ] . picnum , 0.4f , 4 , pPlayer - > pwUpTime [ kPwUpGrowShroom ] } ; // Grows player size, works only if gModernMap == true
powerups [ 10 ] = { gPowerUpInfo [ kPwUpShrinkShroom ] . picnum , 0.4f , 4 , pPlayer - > pwUpTime [ kPwUpShrinkShroom ] } ; // Shrinks player size, works only if gModernMap == true
2020-08-02 06:39:51 +00:00
sortPowerUps ( powerups ) ;
const int warningTime = 5 ;
const int x = 15 ;
2020-08-02 11:35:34 +00:00
int y = - 50 ;
2020-11-23 06:49:36 +00:00
for ( int i = 0 ; i < nPowerUps ; i + + )
2020-08-02 06:39:51 +00:00
{
if ( powerups [ i ] . remainingDuration )
{
int remainingSeconds = powerups [ i ] . remainingDuration / 100 ;
2021-02-18 10:46:36 +00:00
if ( remainingSeconds > warningTime | | ( PlayClock & 32 ) )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( powerups [ i ] . nTile , x , y + powerups [ i ] . yOffset , 0 , 0 , 256 , ( int ) ( 65536 * powerups [ i ] . nScaleRatio ) , DI_SCREEN_LEFT_CENTER ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %d " , remainingSeconds , kSBarNumberInv , x + 15 , y , 0 , remainingSeconds > warningTime ? 0 : 2 , 256 , 65536 * 0.5 , DI_SCREEN_LEFT_CENTER ) ;
2020-08-02 06:39:51 +00:00
y + = 20 ;
}
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void drawInventory ( PLAYER * pPlayer , int x , int y )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
int packs [ 5 ] ;
2020-08-02 15:45:03 +00:00
if ( pPlayer - > packItemTime )
2020-08-02 06:39:51 +00:00
{
int nPacks = 0 ;
int width = 0 ;
for ( int i = 0 ; i < 5 ; i + + )
{
2020-08-02 15:45:03 +00:00
if ( pPlayer - > packSlots [ i ] . curAmount )
2020-08-02 06:39:51 +00:00
{
packs [ nPacks + + ] = i ;
2020-11-22 23:18:07 +00:00
width + = tileWidth ( gPackIcons [ i ] ) + 1 ;
2020-08-02 06:39:51 +00:00
}
}
width / = 2 ;
x - = width ;
for ( int i = 0 ; i < nPacks ; i + + )
{
int nPack = packs [ i ] ;
2020-08-02 11:35:34 +00:00
DrawStatSprite ( 2568 , x + 1 , y - 8 ) ;
DrawStatSprite ( 2568 , x + 1 , y - 6 ) ;
DrawStatSprite ( gPackIcons [ nPack ] , x + 1 , y + 1 ) ;
2020-08-02 06:39:51 +00:00
if ( nPack = = pPlayer - > packItemId )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2559 , x + 1 , y + 1 ) ;
2020-08-02 06:39:51 +00:00
int nShade ;
if ( pPlayer - > packSlots [ nPack ] . isActive )
nShade = 4 ;
else
nShade = 24 ;
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , pPlayer - > packSlots [ nPack ] . curAmount , 2250 , x - 4 , y - 13 , nShade , 0 ) ;
2020-11-22 23:18:07 +00:00
x + = tileWidth ( gPackIcons [ nPack ] ) + 1 ;
2020-08-02 06:39:51 +00:00
}
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-01 19:23:33 +00:00
2020-08-02 11:35:34 +00:00
void DrawPackItemInStatusBar ( PLAYER * pPlayer , int x , int y , int x2 , int y2 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
auto id = pPlayer - > packItemId ;
//id = 0;
if ( id < 0 ) return ;
2020-08-01 19:23:33 +00:00
2020-08-02 11:35:34 +00:00
DrawStatSprite ( gPackIcons [ id ] , x , y , 0 , 0 ) ;
DrawStatNumber ( " %3d " , pPlayer - > packSlots [ id ] . curAmount , 2250 , x2 , y2 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
void DrawPackItemInStatusBar2 ( PLAYER * pPlayer , int x , int y , int x2 , int y2 , int nStat , int nScale )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( pPlayer - > packItemId < 0 ) return ;
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( gPackIcons2 [ pPlayer - > packItemId ] . nTile , x , y + gPackIcons2 [ pPlayer - > packItemId ] . nYOffs , 0 , 0 , nStat , gPackIcons2 [ pPlayer - > packItemId ] . nScale ) ;
DrawStatNumber ( " %3d " , pPlayer - > packSlots [ pPlayer - > packItemId ] . curAmount , kSBarNumberInv , x2 , y2 , 0 , 0 , nStat , nScale ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPlayerSlots ( void )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
for ( int nRows = ( gNetPlayers - 1 ) / 4 ; nRows > = 0 ; nRows - - )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
for ( int nCol = 0 ; nCol < 4 ; nCol + + )
{
2020-08-02 11:35:34 +00:00
DrawStatSprite ( 2229 , - 120 + nCol * 80 , 4 + nRows * 9 , 16 , 0 , 0 , 65536 , STYLE_Normal , DI_SCREEN_CENTER_TOP ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void viewDrawPlayerFrags ( void )
{
FString gTempStr ;
viewDrawPlayerSlots ( ) ;
for ( int i = 0 , p = connecthead ; p > = 0 ; i + + , p = connectpoint2 [ p ] )
{
2020-08-02 11:35:34 +00:00
int x = - 160 + 80 * ( i & 3 ) ;
2020-08-02 06:39:51 +00:00
int y = 9 * ( i / 4 ) ;
int col = gPlayer [ p ] . teamId & 3 ;
2020-11-22 12:28:20 +00:00
const char * name = PlayerName ( p ) ;
2020-11-22 12:34:05 +00:00
gTempStr . Format ( " %s " , name ) ;
2020-08-02 11:35:34 +00:00
int color = CR_UNDEFINED ; // todo: remap the colors. (11+col)
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , tinyf , gTempStr , x + 4 , y , DI_SCREEN_CENTER_TOP , color , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-02 06:39:51 +00:00
gTempStr . Format ( " %2d " , gPlayer [ p ] . fragCount ) ;
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , tinyf , gTempStr , x + 76 , y , DI_SCREEN_CENTER_TOP , color , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-01 19:23:33 +00:00
}
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
void viewDrawPlayerFlags ( void )
{
FString gTempStr ;
viewDrawPlayerSlots ( ) ;
for ( int i = 0 , p = connecthead ; p > = 0 ; i + + , p = connectpoint2 [ p ] )
{
2020-08-02 11:35:34 +00:00
int x = - 160 + 80 * ( i & 3 ) ;
2020-08-02 06:39:51 +00:00
int y = 9 * ( i / 4 ) ;
int col = gPlayer [ p ] . teamId & 3 ;
2020-11-22 12:28:20 +00:00
const char * name = PlayerName ( p ) ;
2020-11-22 12:34:05 +00:00
gTempStr . Format ( " %s " , name ) ;
2020-08-02 06:39:51 +00:00
gTempStr . ToUpper ( ) ;
2020-08-02 11:35:34 +00:00
int color = CR_UNDEFINED ; // todo: remap the colors.
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , tinyf , gTempStr , x + 4 , y , DI_SCREEN_CENTER_TOP , color , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-01 19:23:33 +00:00
2020-08-02 11:35:34 +00:00
gTempStr = " F " ;
2020-08-02 06:39:51 +00:00
x + = 76 ;
if ( gPlayer [ p ] . hasFlag & 2 )
{
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , tinyf , gTempStr , x , y , DI_SCREEN_CENTER_TOP , CR_GREEN /*12*/ , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-02 06:39:51 +00:00
x - = 6 ;
}
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
if ( gPlayer [ p ] . hasFlag & 1 )
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , tinyf , gTempStr , x , y , DI_SCREEN_CENTER_TOP , CR_RED /*11*/ , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-02 06:39:51 +00:00
}
}
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-09-01 18:14:15 +00:00
void viewDrawCtfHudVanilla ( )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
FString gTempStr ;
int x = 1 , y = 1 ;
2021-02-18 10:46:36 +00:00
if ( team_ticker [ 0 ] = = 0 | | ( PlayClock & 8 ) )
2020-08-02 06:39:51 +00:00
{
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , smallf , GStrings ( " TXT_COLOR_BLUE " ) , x , y , 0 , CR_LIGHTBLUE , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-11-22 12:16:58 +00:00
gTempStr . Format ( " %-3d " , team_score [ 0 ] ) ;
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , smallf , gTempStr , x , y + 10 , 0 , CR_LIGHTBLUE , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-02 11:35:34 +00:00
x = - 2 ;
2021-02-18 10:46:36 +00:00
if ( team_ticker [ 1 ] = = 0 | | ( PlayClock & 8 ) )
2020-08-02 06:39:51 +00:00
{
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , smallf , GStrings ( " TXT_COLOR_RED " ) , x , y , DI_TEXT_ALIGN_RIGHT , CR_BRICK , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-11-22 12:16:58 +00:00
gTempStr . Format ( " %3d " , team_score [ 1 ] ) ;
2020-10-28 19:04:53 +00:00
SBar_DrawString ( this , smallf , gTempStr , x , y + 10 , DI_TEXT_ALIGN_RIGHT , CR_BRICK , 1. , - 1 , - 1 , 1 , 1 ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-08-01 19:23:33 +00:00
2020-09-01 18:14:15 +00:00
void flashTeamScore ( int team , bool show )
2020-08-01 19:23:33 +00:00
{
2020-10-11 10:38:17 +00:00
assert ( 0 = = team | | 1 = = team ) ; // 0: blue, 1: red
2020-08-02 06:39:51 +00:00
2021-02-18 10:46:36 +00:00
if ( team_ticker [ team ] = = 0 | | ( PlayClock & 8 ) )
2020-08-01 19:23:33 +00:00
{
2020-09-01 18:14:15 +00:00
if ( show )
2020-11-22 12:16:58 +00:00
DrawStatNumber ( " %d " , team_score [ team ] , kSBarNumberInv , - 30 , team ? 25 : - 10 , 0 , team ? 2 : 10 , 512 , 65536 * 0.75 , DI_SCREEN_RIGHT_CENTER ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
2020-09-01 18:14:15 +00:00
void viewDrawCtfHud ( )
2020-08-02 06:39:51 +00:00
{
2020-08-16 00:55:50 +00:00
if ( hud_size = = Hud_Nothing )
2020-08-01 19:23:33 +00:00
{
2020-09-01 18:14:15 +00:00
flashTeamScore ( 0 , false ) ;
flashTeamScore ( 1 , false ) ;
2020-08-02 06:39:51 +00:00
return ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
bool blueFlagTaken = false ;
bool redFlagTaken = false ;
int blueFlagCarrierColor = 0 ;
int redFlagCarrierColor = 0 ;
for ( int i = 0 , p = connecthead ; p > = 0 ; i + + , p = connectpoint2 [ p ] )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( ( gPlayer [ p ] . hasFlag & 1 ) ! = 0 )
{
blueFlagTaken = true ;
blueFlagCarrierColor = gPlayer [ p ] . teamId & 3 ;
}
if ( ( gPlayer [ p ] . hasFlag & 2 ) ! = 0 )
{
redFlagTaken = true ;
redFlagCarrierColor = gPlayer [ p ] . teamId & 3 ;
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
bool meHaveBlueFlag = gMe - > hasFlag & 1 ;
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( meHaveBlueFlag ? 3558 : 3559 , 0 , 75 - 100 , 0 , 10 , 512 , 65536 * 0.35 , DI_SCREEN_RIGHT_CENTER ) ;
2020-08-02 06:39:51 +00:00
if ( gBlueFlagDropped )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2332 , 305 - 320 , 83 - 100 , 0 , 10 , 512 , 65536 , DI_SCREEN_RIGHT_CENTER ) ;
2020-08-02 06:39:51 +00:00
else if ( blueFlagTaken )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 4097 , 307 - 320 , 77 - 100 , 0 , blueFlagCarrierColor ? 2 : 10 , 512 , 65536 , DI_SCREEN_RIGHT_CENTER ) ;
2020-09-01 18:14:15 +00:00
flashTeamScore ( 0 , true ) ;
2020-08-02 06:39:51 +00:00
bool meHaveRedFlag = gMe - > hasFlag & 2 ;
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( meHaveRedFlag ? 3558 : 3559 , 0 , 10 , 0 , 2 , 512 , 65536 * 0.35 , DI_SCREEN_RIGHT_CENTER ) ;
2020-08-02 06:39:51 +00:00
if ( gRedFlagDropped )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2332 , 305 - 320 , 17 , 0 , 2 , 512 , 65536 , DI_SCREEN_RIGHT_CENTER ) ;
2020-08-02 06:39:51 +00:00
else if ( redFlagTaken )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 4097 , 307 - 320 , 11 , 0 , redFlagCarrierColor ? 2 : 10 , 512 , 65536 , DI_SCREEN_RIGHT_CENTER ) ;
2020-09-01 18:14:15 +00:00
flashTeamScore ( 1 , true ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawStatusBar ( int nPalette )
{
2020-11-22 23:18:07 +00:00
BeginStatusBar ( 320 , 200 , tileHeight ( 2200 ) ) ;
2020-08-02 06:39:51 +00:00
PLAYER * pPlayer = gView ;
XSPRITE * pXSprite = pPlayer - > pXSprite ;
DrawStatMaskedSprite ( 2200 , 160 , 200 , 0 , nPalette , RS_CENTERBOTTOM ) ;
DrawPackItemInStatusBar ( pPlayer , 265 , 186 , 260 , 172 ) ;
2020-08-02 11:35:34 +00:00
2021-02-18 10:46:36 +00:00
if ( pXSprite - > health > = 16 | | ( PlayClock & 16 ) | | pXSprite - > health = = 0 )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , pXSprite - > health > > 4 , 2190 , 86 , 183 , 0 , 0 ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
if ( pPlayer - > curWeapon & & pPlayer - > weaponAmmo ! = - 1 )
{
int num = pPlayer - > ammoCount [ pPlayer - > weaponAmmo ] ;
if ( pPlayer - > weaponAmmo = = 6 )
num / = 10 ;
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , num , 2240 , 216 , 183 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
for ( int i = 9 ; i > = 1 ; i - - )
{
int x = 135 + ( ( i - 1 ) / 3 ) * 23 ;
int y = 182 + ( ( i - 1 ) % 3 ) * 6 ;
int num = pPlayer - > ammoCount [ i ] ;
if ( i = = 6 )
num / = 10 ;
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , num , 2230 , x , y , i = = pPlayer - > weaponAmmo ? - 128 : 32 , 10 ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %2d " , pPlayer - > ammoCount [ 10 ] , 2230 , 291 , 194 , pPlayer - > weaponAmmo = = 10 ? - 128 : 32 , 10 ) ;
DrawStatNumber ( " %2d " , pPlayer - > ammoCount [ 11 ] , 2230 , 309 , 194 , pPlayer - > weaponAmmo = = 11 ? - 128 : 32 , 10 ) ;
2020-08-02 06:39:51 +00:00
if ( pPlayer - > armor [ 1 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2207 , 44 , 174 , pPlayer - > armor [ 1 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 1 ] > > 4 , 2230 , 50 , 177 , 0 , 0 ) ;
2020-08-02 06:39:51 +00:00
}
if ( pPlayer - > armor [ 0 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2209 , 44 , 182 , pPlayer - > armor [ 0 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 0 ] > > 4 , 2230 , 50 , 185 , 0 , 0 ) ;
2020-08-02 06:39:51 +00:00
}
if ( pPlayer - > armor [ 2 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2208 , 44 , 190 , pPlayer - > armor [ 2 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 2 ] > > 4 , 2230 , 50 , 193 , 0 , 0 ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
for ( int i = 0 ; i < 6 ; i + + )
{
2020-08-02 06:39:51 +00:00
int nTile = 2220 + i ;
2020-08-02 11:35:34 +00:00
double x = 73.5 + ( i & 1 ) * 173 ;
double y = 171.5 + ( i > > 1 ) * 11 ;
2020-08-01 19:23:33 +00:00
if ( pPlayer - > hasKey [ i + 1 ] )
2020-08-02 11:35:34 +00:00
DrawStatSprite ( nTile , x , y ) ;
2020-08-02 06:39:51 +00:00
else
2020-08-02 11:35:34 +00:00
DrawStatSprite ( nTile , x , y , 40 , 5 ) ;
2020-08-01 19:23:33 +00:00
}
2021-04-04 07:35:05 +00:00
DrawStatMaskedSprite ( 2202 , 118.5 , 185.5 , /*pPlayer->isRunning ? 16 :*/ 40 ) ;
DrawStatMaskedSprite ( 2202 , 201.5 , 185.5 , /*pPlayer->isRunning ? 16 :*/ 40 ) ;
2020-08-01 19:23:33 +00:00
if ( pPlayer - > throwPower )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2260 , 124 , 175.5 , pPlayer - > throwPower , 65536 ) ;
2020-08-02 06:39:51 +00:00
}
2020-11-22 23:18:07 +00:00
drawInventory ( pPlayer , 166 , 200 - tileHeight ( 2200 ) ) ;
2020-08-02 11:35:34 +00:00
// Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already.
2021-02-27 11:33:47 +00:00
PrintLevelStats ( pPlayer , ( hud_statscale < = 0.501f | | hud_scalefactor < 0.7 ) & & double ( twod - > GetWidth ( ) ) / twod - > GetHeight ( ) > 1.6 ? 28 : 56 ) ;
2020-08-02 11:35:34 +00:00
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawHUD1 ( int nPalette )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
PLAYER * pPlayer = gView ;
XSPRITE * pXSprite = pPlayer - > pXSprite ;
2020-08-02 11:35:34 +00:00
BeginHUD ( 320 , 200 , 1 ) ;
DrawStatSprite ( 2201 , 34 , 187 - 200 , 16 , nPalette ) ;
2021-02-18 10:46:36 +00:00
if ( pXSprite - > health > = 16 | | ( PlayClock & 16 ) | | pXSprite - > health = = 0 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , pXSprite - > health > > 4 , 2190 , 8 , 183 - 200 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
if ( pPlayer - > curWeapon & & pPlayer - > weaponAmmo ! = - 1 )
{
int num = pPlayer - > ammoCount [ pPlayer - > weaponAmmo ] ;
if ( pPlayer - > weaponAmmo = = 6 )
num / = 10 ;
2020-08-02 11:35:34 +00:00
DrawStatNumber ( " %3d " , num , 2240 , 42 , 183 - 200 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 11:35:34 +00:00
DrawStatSprite ( 2173 , 284 - 320 , 187 - 200 , 16 , nPalette ) ;
2020-08-01 19:23:33 +00:00
if ( pPlayer - > armor [ 1 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2207 , 250 - 320 , 175 - 200 , pPlayer - > armor [ 1 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 1 ] > > 4 , 2230 , 255 - 320 , 178 - 200 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
if ( pPlayer - > armor [ 0 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2209 , 250 - 320 , 183 - 200 , pPlayer - > armor [ 0 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 0 ] > > 4 , 2230 , 255 - 320 , 186 - 200 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
if ( pPlayer - > armor [ 2 ] )
{
2020-08-02 11:35:34 +00:00
TileHGauge ( 2208 , 250 - 320 , 191 - 200 , pPlayer - > armor [ 2 ] , 3200 ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 2 ] > > 4 , 2230 , 255 - 320 , 194 - 200 , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-10 21:06:24 +00:00
2020-08-02 11:35:34 +00:00
DrawPackItemInStatusBar ( pPlayer , 286 - 320 , 186 - 200 , 302 - 320 , 183 - 200 ) ;
2020-08-01 19:23:33 +00:00
for ( int i = 0 ; i < 6 ; i + + )
{
int nTile = 2220 + i ;
2020-08-02 11:35:34 +00:00
int x ;
int y = - 6 ;
2020-08-01 19:23:33 +00:00
if ( i & 1 )
{
2020-08-02 11:35:34 +00:00
x = - ( 78 + ( i > > 1 ) * 10 ) ;
2020-08-01 19:23:33 +00:00
}
else
{
x = 73 + ( i > > 1 ) * 10 ;
}
if ( pPlayer - > hasKey [ i + 1 ] )
2020-08-02 11:35:34 +00:00
DrawStatSprite ( nTile , x , y , 0 , 0 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 11:35:34 +00:00
PrintLevelStats ( pPlayer , 28 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void DrawHUD2 ( )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
PLAYER * pPlayer = gView ;
XSPRITE * pXSprite = pPlayer - > pXSprite ;
2020-08-02 11:35:34 +00:00
BeginHUD ( 320 , 200 , 1 ) ;
DrawStatMaskedSprite ( 2169 , 12 , 195 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.56 ) ) ;
DrawStatNumber ( " %d " , pXSprite - > health > > 4 , kSBarNumberHealth , 28 , 187 - 200 , 0 , 0 , 256 ) ;
2020-08-02 06:39:51 +00:00
if ( pPlayer - > armor [ 1 ] )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2578 , 70 , 186 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.5 ) ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 1 ] > > 4 , kSBarNumberArmor2 , 83 , 187 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.65 ) ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
if ( pPlayer - > armor [ 0 ] )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2586 , 112 , 195 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.5 ) ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 0 ] > > 4 , kSBarNumberArmor1 , 125 , 187 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.65 ) ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
if ( pPlayer - > armor [ 2 ] )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2602 , 155 , 196 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.5 ) ) ;
DrawStatNumber ( " %3d " , pPlayer - > armor [ 2 ] > > 4 , kSBarNumberArmor3 , 170 , 187 - 200 , 0 , 0 , 256 , ( int ) ( 65536 * 0.65 ) ) ;
2020-08-01 19:23:33 +00:00
}
2020-09-02 09:13:30 +00:00
DrawPackItemInStatusBar2 ( pPlayer , 216 - 320 , 194 - 200 , 231 - 320 , 187 - 200 , 512 , ( int ) ( 65536 * 0.7 ) ) ;
2020-08-02 06:39:51 +00:00
if ( pPlayer - > curWeapon & & pPlayer - > weaponAmmo ! = - 1 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
int num = pPlayer - > ammoCount [ pPlayer - > weaponAmmo ] ;
if ( pPlayer - > weaponAmmo = = 6 )
num / = 10 ;
if ( ( unsigned int ) gAmmoIcons [ pPlayer - > weaponAmmo ] . nTile < kMaxTiles )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( gAmmoIcons [ pPlayer - > weaponAmmo ] . nTile , 304 - 320 , - 8 + gAmmoIcons [ pPlayer - > weaponAmmo ] . nYOffs ,
2020-08-02 06:39:51 +00:00
0 , 0 , 512 , gAmmoIcons [ pPlayer - > weaponAmmo ] . nScale ) ;
2020-08-28 01:38:56 +00:00
2020-08-28 04:50:35 +00:00
bool reloadableWeapon = pPlayer - > curWeapon = = 3 & & ! powerupCheck ( pPlayer , kPwUpTwoGuns ) ;
if ( ! reloadableWeapon | | ( reloadableWeapon & & ! cl_showmagamt ) )
2020-08-28 01:38:56 +00:00
{
DrawStatNumber ( " %3d " , num , kSBarNumberAmmo , 267 - 320 , 187 - 200 , 0 , 0 , 512 ) ;
}
else
{
FString format ;
2020-08-28 04:50:35 +00:00
short clip = CalcMagazineAmount ( num , 2 , pPlayer - > weaponState = = 1 ) ;
2020-09-02 09:42:16 +00:00
short total = num - clip ;
2020-08-28 01:38:56 +00:00
format . Format ( " %d/%d " , clip , num - clip ) ;
2020-09-02 09:42:16 +00:00
DrawCharArray ( format . GetChars ( ) , kSBarNumberAmmo , ( total < 10 ? 267 : 258 ) - 320 , 187 - 200 , 0 , 0 , 512 ) ;
2020-08-28 01:38:56 +00:00
}
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
for ( int i = 0 ; i < 6 ; i + + )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( pPlayer - > hasKey [ i + 1 ] )
2020-08-02 11:35:34 +00:00
DrawStatMaskedSprite ( 2552 + i , - 60 + 10 * i , 170 - 200 , 0 , 0 , 0 , ( int ) ( 65536 * 0.25 ) ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
2020-08-02 11:35:34 +00:00
BeginStatusBar ( 320 , 200 , 28 ) ;
2020-08-02 06:39:51 +00:00
if ( pPlayer - > throwPower )
2020-08-10 21:06:24 +00:00
TileHGauge ( 2260 , 124 , 175 , pPlayer - > throwPower , 65536 ) ;
2020-08-01 19:23:33 +00:00
else
2020-11-22 23:18:07 +00:00
drawInventory ( pPlayer , 166 , 200 - tileHeight ( 2201 ) / 2 - 30 ) ;
2020-08-02 11:35:34 +00:00
PrintLevelStats ( pPlayer , 28 ) ;
2020-08-02 06:39:51 +00:00
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
public :
2020-09-01 18:14:15 +00:00
void UpdateStatusBar ( )
2020-08-02 06:39:51 +00:00
{
PLAYER * pPlayer = gView ;
XSPRITE * pXSprite = pPlayer - > pXSprite ;
int nPalette = 0 ;
if ( gGameOptions . nGameType = = 3 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
if ( pPlayer - > teamId & 1 )
nPalette = 7 ;
else
nPalette = 10 ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 06:39:51 +00:00
2020-08-16 00:55:50 +00:00
if ( hud_size = = Hud_full )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
DrawHUD2 ( ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-16 00:55:50 +00:00
else if ( hud_size > Hud_Stbar )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
BeginStatusBar ( 320 , 200 , 28 ) ;
2020-08-02 06:39:51 +00:00
if ( pPlayer - > throwPower )
2020-08-02 11:53:14 +00:00
TileHGauge ( 2260 , 124 , 175 , pPlayer - > throwPower , 65536 ) ;
2020-12-10 18:02:09 +00:00
else if ( hud_size > Hud_StbarOverlay )
2020-11-22 23:18:07 +00:00
drawInventory ( pPlayer , 166 , 200 - tileHeight ( 2201 ) / 2 ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-16 00:55:50 +00:00
if ( hud_size = = Hud_Mini )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
DrawHUD1 ( nPalette ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-16 00:55:50 +00:00
else if ( hud_size < = Hud_StbarOverlay )
2020-08-01 19:23:33 +00:00
{
2020-08-02 06:39:51 +00:00
DrawStatusBar ( nPalette ) ;
2020-08-01 19:23:33 +00:00
}
2020-08-02 11:35:34 +00:00
// All remaining parts must be done with HUD alignment rules, even when showing a status bar.
BeginHUD ( 320 , 200 , 1 ) ;
viewDrawPowerUps ( pPlayer ) ;
2020-08-01 19:23:33 +00:00
2020-08-02 11:35:34 +00:00
if ( gGameOptions . nGameType > = 1 )
2020-08-01 19:23:33 +00:00
{
2020-08-02 11:35:34 +00:00
if ( gGameOptions . nGameType = = 3 )
2020-08-02 06:39:51 +00:00
{
2020-08-02 11:35:34 +00:00
if ( VanillaMode ( ) )
{
2020-09-01 18:14:15 +00:00
viewDrawCtfHudVanilla ( ) ;
2020-08-02 11:35:34 +00:00
}
else
{
2020-09-01 18:14:15 +00:00
viewDrawCtfHud ( ) ;
2020-08-02 11:35:34 +00:00
viewDrawPlayerFlags ( ) ;
}
2020-08-02 06:39:51 +00:00
}
else
{
2020-08-02 11:35:34 +00:00
viewDrawPlayerFrags ( ) ;
2020-08-02 06:39:51 +00:00
}
2020-08-01 19:23:33 +00:00
}
}
2020-08-02 06:39:51 +00:00
} ;
2020-10-28 18:27:12 +00:00
IMPLEMENT_CLASS ( DBloodStatusBar , false , false )
2020-08-02 16:02:13 +00:00
static void UpdateFrame ( void )
{
auto tex = tileGetTexture ( kBackTile ) ;
2021-02-27 11:33:47 +00:00
int width = twod - > GetWidth ( ) ;
int height = twod - > GetHeight ( ) ;
2020-08-02 16:02:13 +00:00
2021-02-27 11:33:47 +00:00
twod - > AddFlatFill ( 0 , 0 , width , windowxy1 . y - 3 , tex ) ;
twod - > AddFlatFill ( 0 , windowxy2 . y + 4 , width , height , tex ) ;
2020-08-16 00:55:50 +00:00
twod - > AddFlatFill ( 0 , windowxy1 . y - 3 , windowxy1 . x - 3 , windowxy2 . y + 4 , tex ) ;
2021-02-27 11:33:47 +00:00
twod - > AddFlatFill ( windowxy2 . x + 4 , windowxy1 . y - 3 , width , windowxy2 . y + 4 , tex ) ;
2020-08-02 16:02:13 +00:00
2020-08-16 00:55:50 +00:00
twod - > AddFlatFill ( windowxy1 . x - 3 , windowxy1 . y - 3 , windowxy1 . x , windowxy2 . y + 1 , tex , 0 , 1 , 0xff545454 ) ;
twod - > AddFlatFill ( windowxy1 . x , windowxy1 . y - 3 , windowxy2 . x + 4 , windowxy1 . y , tex , 0 , 1 , 0xff545454 ) ;
twod - > AddFlatFill ( windowxy2 . x + 1 , windowxy1 . y , windowxy2 . x + 4 , windowxy2 . y + 4 , tex , 0 , 1 , 0xff2a2a2a ) ;
twod - > AddFlatFill ( windowxy1 . x - 3 , windowxy2 . y + 1 , windowxy2 . x + 1 , windowxy2 . y + 4 , tex , 0 , 1 , 0xff2a2a2a ) ;
2020-08-02 16:02:13 +00:00
}
2020-09-01 18:14:15 +00:00
void UpdateStatusBar ( )
2020-08-02 06:39:51 +00:00
{
2020-08-24 17:47:09 +00:00
if ( automapMode = = am_off & & hud_size < = Hud_Stbar )
2020-08-02 16:02:13 +00:00
{
UpdateFrame ( ) ;
}
2020-10-28 18:27:12 +00:00
StatusBar - > UpdateStatusBar ( ) ;
2020-08-01 19:23:33 +00:00
}
END_BLD_NS