mirror of
https://github.com/ENSL/NS.git
synced 2024-11-22 20:51:35 +00:00
90ebbdda23
- add network rate presets - add cl_intensityalt for alternative gamma ramp in env_gamma map entities - separate welder flickering dynamic light setting - crosshair updates
507 lines
11 KiB
C++
507 lines
11 KiB
C++
#ifndef CHUDMISC_H
|
|
#define CHUDMISC_H
|
|
|
|
#define RGB_YELLOWISH 0x00FFA000 //255,160,0
|
|
#define RGB_REDISH 0x00FF1010 //255,160,0
|
|
#define RGB_GREENISH 0x0000A000 //0,160,0
|
|
#define RGB_MARINE_BLUE 0x000099FF //0 153 255
|
|
#define RGB_MARINE_SELECTED 0x006EE6FF //110, 230, 255
|
|
#define RGB_MARINE_PARASITED 0x00E3F03D //227, 240, 61
|
|
|
|
|
|
#ifndef _WIN32
|
|
#define _cdecl
|
|
#else
|
|
#undef _cdecl
|
|
#endif
|
|
|
|
#include "wrect.h"
|
|
#include "cl_dll.h"
|
|
#include "ammo.h"
|
|
#include "teamconst.h"
|
|
|
|
#define DHN_DRAWZERO 1
|
|
#define DHN_2DIGITS 2
|
|
#define DHN_3DIGITS 4
|
|
#define MIN_ALPHA 100
|
|
|
|
#define HUDELEM_ACTIVE 1
|
|
|
|
typedef struct {
|
|
int x, y;
|
|
} POSITION;
|
|
|
|
typedef struct {
|
|
unsigned char r,g,b,a;
|
|
} RGBA;
|
|
|
|
typedef struct cvar_s cvar_t;
|
|
|
|
|
|
#define HUD_ACTIVE 1
|
|
#define HUD_INTERMISSION 2
|
|
|
|
#define MAX_PLAYER_NAME_LENGTH 32
|
|
|
|
#define MAX_MOTD_LENGTH 1536
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudBase
|
|
{
|
|
public:
|
|
POSITION m_pos;
|
|
int m_type;
|
|
int m_iFlags; // active, moving,
|
|
virtual ~CHudBase() {}
|
|
virtual int Init( void ) {return 0;}
|
|
virtual int VidInit( void ) {return 0;}
|
|
virtual int Draw(float flTime) {return 0;}
|
|
virtual void Think(void) {return;}
|
|
virtual void Reset(void) {return;}
|
|
virtual void InitHUDData( void ) {} // called every time a server is connected to
|
|
|
|
};
|
|
|
|
struct HUDLIST {
|
|
CHudBase *p;
|
|
HUDLIST *pNext;
|
|
};
|
|
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
#include "voice_status.h"
|
|
#include "hud_spectator.h"
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudAmmo: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
void Think(void);
|
|
void Reset(void);
|
|
int DrawWList(float flTime);
|
|
int MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf);
|
|
int MsgFunc_WeaponList(const char *pszName, int iSize, void *pbuf);
|
|
int MsgFunc_AmmoX(const char *pszName, int iSize, void *pbuf);
|
|
int MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_WeapPickup( const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_ItemPickup( const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf );
|
|
|
|
void SlotInput( int iSlot );
|
|
void _cdecl UserCmd_Slot1( void );
|
|
void _cdecl UserCmd_Slot2( void );
|
|
void _cdecl UserCmd_Slot3( void );
|
|
void _cdecl UserCmd_Slot4( void );
|
|
void _cdecl UserCmd_Slot5( void );
|
|
void _cdecl UserCmd_Slot6( void );
|
|
void _cdecl UserCmd_Slot7( void );
|
|
void _cdecl UserCmd_Slot8( void );
|
|
void _cdecl UserCmd_Slot9( void );
|
|
void _cdecl UserCmd_Slot10( void );
|
|
void _cdecl UserCmd_Close( void );
|
|
void _cdecl UserCmd_NextWeapon( void );
|
|
void _cdecl UserCmd_PrevWeapon( void );
|
|
|
|
void SetCurrentClip(int inClip);
|
|
private:
|
|
float m_fFade;
|
|
RGBA m_rgba;
|
|
WEAPON *m_pWeapon;
|
|
int m_HUD_bucket0;
|
|
int m_HUD_selection;
|
|
int m_customCrosshair;
|
|
int m_crossLastWeapId;
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudAmmoSecondary: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
void Reset( void );
|
|
int Draw(float flTime);
|
|
|
|
int MsgFunc_SecAmmoVal( const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_SecAmmoIcon( const char *pszName, int iSize, void *pbuf );
|
|
|
|
private:
|
|
enum {
|
|
MAX_SEC_AMMO_VALUES = 4
|
|
};
|
|
|
|
int m_HUD_ammoicon; // sprite indices
|
|
int m_iAmmoAmounts[MAX_SEC_AMMO_VALUES];
|
|
float m_fFade;
|
|
};
|
|
|
|
|
|
#include "health.h"
|
|
|
|
|
|
#define FADE_TIME 100
|
|
|
|
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudGeiger: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
int MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf);
|
|
|
|
private:
|
|
int m_iGeigerRange;
|
|
|
|
};
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudTrain: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
int MsgFunc_Train(const char *pszName, int iSize, void *pbuf);
|
|
|
|
private:
|
|
AVHHSPRITE m_hSprite;
|
|
int m_iPos;
|
|
|
|
};
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudStatusBar : public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw( float flTime );
|
|
const char* GetStatusString() const;
|
|
void Reset( void );
|
|
void ParseStatusString( int line_num );
|
|
|
|
int MsgFunc_StatusText( const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_StatusValue( const char *pszName, int iSize, void *pbuf );
|
|
|
|
protected:
|
|
void ReparseStringIfNeeded();
|
|
|
|
enum {
|
|
MAX_STATUSTEXT_LENGTH = 128,
|
|
MAX_STATUSBAR_VALUES = 8,
|
|
MAX_STATUSBAR_LINES = 2,
|
|
};
|
|
|
|
char m_szStatusText[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // a text string describing how the status bar is to be drawn
|
|
char m_szStatusBar[MAX_STATUSBAR_LINES][MAX_STATUSTEXT_LENGTH]; // the constructed bar that is drawn
|
|
int m_iStatusValues[MAX_STATUSBAR_VALUES]; // an array of values for use in the status bar
|
|
|
|
int m_bReparseString; // set to TRUE whenever the m_szStatusBar needs to be recalculated
|
|
|
|
// an array of colors...one color for each line
|
|
float *m_pflNameColors[MAX_STATUSBAR_LINES];
|
|
};
|
|
|
|
class ScoreboardIcon;
|
|
// : 0001073
|
|
#define CUSTOM_ICON_LENGTH 32
|
|
|
|
struct extra_player_info_t
|
|
{
|
|
short score;
|
|
short lastScore;
|
|
float timeOfLastScoreChange;
|
|
short frags;
|
|
short deaths;
|
|
short playerclass;
|
|
short extra;
|
|
short auth;
|
|
short teamnumber;
|
|
char teamname[MAX_TEAM_NAME];
|
|
char customicon[CUSTOM_ICON_LENGTH + 3]; //last 3 characters is the color.
|
|
short health;
|
|
ScoreboardIcon* icon;
|
|
};
|
|
|
|
struct team_info_t
|
|
{
|
|
char name[MAX_TEAM_NAME];
|
|
short score;
|
|
short frags;
|
|
short deaths;
|
|
short ping;
|
|
short packetloss;
|
|
short ownteam;
|
|
short players;
|
|
int already_drawn;
|
|
int scores_overriden;
|
|
int teamnumber;
|
|
};
|
|
|
|
extern hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
|
|
extern extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
|
|
extern team_info_t g_TeamInfo[MAX_TEAMS+1];
|
|
extern int g_IsSpectator[MAX_PLAYERS+1];
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudDeathNotice : public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
void InitHUDData( void );
|
|
int VidInit( void );
|
|
int Draw( float flTime );
|
|
int MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbuf );
|
|
|
|
private:
|
|
int m_HUD_d_skull; // sprite index of skull icon
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudMenu : public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
void InitHUDData( void );
|
|
int VidInit( void );
|
|
void Reset( void );
|
|
int Draw( float flTime );
|
|
int MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf );
|
|
|
|
void SelectMenuItem( int menu_item );
|
|
|
|
int m_fMenuDisplayed;
|
|
int m_bitsValidSlots;
|
|
float m_flShutoffTime;
|
|
int m_fWaitingForMore;
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudSayText : public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
void InitHUDData( void );
|
|
int VidInit( void );
|
|
int Draw( float flTime );
|
|
int MsgFunc_SayText( const char *pszName, int iSize, void *pbuf );
|
|
void SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex = -1 );
|
|
void EnsureTextFitsInOneLineAndWrapIfHaveTo( int line );
|
|
friend class CHud;
|
|
friend class CHudSpectator;
|
|
|
|
private:
|
|
|
|
struct cvar_s * m_HUD_saytext;
|
|
struct cvar_s * m_HUD_saytext_time;
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudBattery: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
int MsgFunc_Battery(const char *pszName, int iSize, void *pbuf );
|
|
|
|
private:
|
|
AVHHSPRITE m_hSprite1;
|
|
AVHHSPRITE m_hSprite2;
|
|
wrect_t *m_prc1;
|
|
wrect_t *m_prc2;
|
|
int m_iBat;
|
|
float m_fFade;
|
|
int m_iHeight; // width of the battery innards
|
|
};
|
|
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudFlashlight: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
void Reset( void );
|
|
int MsgFunc_Flashlight(const char *pszName, int iSize, void *pbuf );
|
|
int MsgFunc_FlashBat(const char *pszName, int iSize, void *pbuf );
|
|
|
|
private:
|
|
AVHHSPRITE m_hSprite1;
|
|
AVHHSPRITE m_hSprite2;
|
|
AVHHSPRITE m_hBeam;
|
|
wrect_t *m_prc1;
|
|
wrect_t *m_prc2;
|
|
wrect_t *m_prcBeam;
|
|
float m_flBat;
|
|
int m_iBat;
|
|
int m_fOn;
|
|
float m_fFade;
|
|
int m_iWidth; // width of the battery innards
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
const int maxHUDMessages = 16;
|
|
struct message_parms_t
|
|
{
|
|
client_textmessage_t *pMessage;
|
|
float time;
|
|
int x, y;
|
|
int totalWidth, totalHeight;
|
|
int width;
|
|
int lines;
|
|
int lineLength;
|
|
int length;
|
|
int r, g, b;
|
|
int text;
|
|
int fadeBlend;
|
|
float charTime;
|
|
float fadeTime;
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
class CHudTextMessage: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size );
|
|
static char *BufferedLocaliseTextString( const char *msg );
|
|
char *LookupString( const char *msg_name, int *msg_dest = NULL );
|
|
int MsgFunc_TextMsg(const char *pszName, int iSize, void *pbuf);
|
|
};
|
|
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
|
|
class CHudMessage: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
int Draw(float flTime);
|
|
int MsgFunc_HudText(const char *pszName, int iSize, void *pbuf);
|
|
int MsgFunc_HudText2(const char *pszName, int iSize, void *pbuf);
|
|
int MsgFunc_GameTitle(const char *pszName, int iSize, void *pbuf);
|
|
|
|
float FadeBlend( float fadein, float fadeout, float hold, float localTime );
|
|
int XPosition( float x, int width, int lineWidth );
|
|
int YPosition( float y, int height );
|
|
|
|
void MessageAddPlayerID(const char* pName, bool inEnemy);
|
|
|
|
void MessageAdd( const char *pName, float time );
|
|
bool MessageRemove( const char *pName );
|
|
void MessageDrawScan( client_textmessage_t *pMessage, float time );
|
|
void MessageScanStart( void );
|
|
void MessageScanNextChar( void );
|
|
void Reset( void );
|
|
|
|
private:
|
|
bool DrawMessage(client_textmessage_t* inMessage, float inStartTime, float inCurrentTime);
|
|
void SetPlayerIDPosition();
|
|
|
|
client_textmessage_t *m_pMessages[maxHUDMessages];
|
|
float m_startTime[maxHUDMessages];
|
|
message_parms_t m_parms;
|
|
float m_gameTitleTime;
|
|
client_textmessage_t *m_pGameTitle;
|
|
|
|
client_textmessage_t mPlayerIDMessage;
|
|
float mPlayerIDTime;
|
|
char* mPlayerID;
|
|
|
|
int m_HUD_title_life;
|
|
int m_HUD_title_half;
|
|
};
|
|
|
|
//
|
|
//-----------------------------------------------------
|
|
//
|
|
#define MAX_SPRITE_NAME_LENGTH 24
|
|
|
|
class CHudStatusIcons: public CHudBase
|
|
{
|
|
public:
|
|
int Init( void );
|
|
int VidInit( void );
|
|
void Reset( void );
|
|
int Draw(float flTime);
|
|
|
|
enum {
|
|
MAX_ICONSPRITENAME_LENGTH = MAX_SPRITE_NAME_LENGTH,
|
|
MAX_ICONSPRITES = 4,
|
|
};
|
|
|
|
|
|
//had to make these public so CHud could access them (to enable concussion icon)
|
|
//could use a friend declaration instead...
|
|
void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue );
|
|
void DisableIcon( char *pszIconName );
|
|
|
|
private:
|
|
|
|
typedef struct
|
|
{
|
|
char szSpriteName[MAX_ICONSPRITENAME_LENGTH];
|
|
AVHHSPRITE spr;
|
|
wrect_t rc;
|
|
unsigned char r, g, b;
|
|
} icon_sprite_t;
|
|
|
|
icon_sprite_t m_IconList[MAX_ICONSPRITES];
|
|
|
|
};
|
|
|
|
typedef struct cvar_s cvar_t;
|
|
|
|
#endif
|