|
|
@ -27,6 +27,10 @@ |
|
|
|
DECLARE_MESSAGE( m_Message, HudText ) |
|
|
|
DECLARE_MESSAGE( m_Message, HudText ) |
|
|
|
DECLARE_MESSAGE( m_Message, GameTitle ) |
|
|
|
DECLARE_MESSAGE( m_Message, GameTitle ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1 Global client_textmessage_t for custom messages that aren't in the titles.txt
|
|
|
|
|
|
|
|
client_textmessage_t g_pCustomMessage; |
|
|
|
|
|
|
|
char *g_pCustomName = "Custom"; |
|
|
|
|
|
|
|
char g_pCustomText[1024]; |
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::Init( void ) |
|
|
|
int CHudMessage::Init( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -38,7 +42,7 @@ int CHudMessage::Init(void) |
|
|
|
Reset(); |
|
|
|
Reset(); |
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::VidInit( void ) |
|
|
|
int CHudMessage::VidInit( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -46,8 +50,7 @@ int CHudMessage::VidInit( void ) |
|
|
|
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); |
|
|
|
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); |
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CHudMessage::Reset( void ) |
|
|
|
void CHudMessage::Reset( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -58,7 +61,6 @@ void CHudMessage::Reset( void ) |
|
|
|
m_pGameTitle = NULL; |
|
|
|
m_pGameTitle = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime ) |
|
|
|
float CHudMessage::FadeBlend( float fadein, float fadeout, float hold, float localTime ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
float fadeTime = fadein + hold; |
|
|
|
float fadeTime = fadein + hold; |
|
|
@ -109,7 +111,6 @@ int CHudMessage::XPosition( float x, int width, int totalWidth ) |
|
|
|
return xPos; |
|
|
|
return xPos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::YPosition( float y, int height ) |
|
|
|
int CHudMessage::YPosition( float y, int height ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int yPos; |
|
|
|
int yPos; |
|
|
@ -133,10 +134,9 @@ int CHudMessage::YPosition( float y, int height ) |
|
|
|
return yPos; |
|
|
|
return yPos; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CHudMessage::MessageScanNextChar( void ) |
|
|
|
void CHudMessage::MessageScanNextChar( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int srcRed, srcGreen, srcBlue, destRed, destGreen, destBlue; |
|
|
|
int srcRed, srcGreen, srcBlue, destRed = 0, destGreen = 0, destBlue = 0; |
|
|
|
int blend; |
|
|
|
int blend; |
|
|
|
|
|
|
|
|
|
|
|
srcRed = m_parms.pMessage->r1; |
|
|
|
srcRed = m_parms.pMessage->r1; |
|
|
@ -152,7 +152,6 @@ void CHudMessage::MessageScanNextChar( void ) |
|
|
|
destRed = destGreen = destBlue = 0; |
|
|
|
destRed = destGreen = destBlue = 0; |
|
|
|
blend = m_parms.fadeBlend; |
|
|
|
blend = m_parms.fadeBlend; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
m_parms.charTime += m_parms.pMessage->fadein; |
|
|
|
m_parms.charTime += m_parms.pMessage->fadein; |
|
|
|
if( m_parms.charTime > m_parms.time ) |
|
|
|
if( m_parms.charTime > m_parms.time ) |
|
|
@ -197,7 +196,6 @@ void CHudMessage::MessageScanNextChar( void ) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CHudMessage::MessageScanStart( void ) |
|
|
|
void CHudMessage::MessageScanStart( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch( m_parms.pMessage->effect ) |
|
|
|
switch( m_parms.pMessage->effect ) |
|
|
@ -226,7 +224,6 @@ void CHudMessage::MessageScanStart( void ) |
|
|
|
if( m_parms.pMessage->effect == 1 && ( rand() % 100 ) < 10 ) |
|
|
|
if( m_parms.pMessage->effect == 1 && ( rand() % 100 ) < 10 ) |
|
|
|
m_parms.charTime = 1; |
|
|
|
m_parms.charTime = 1; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 2: |
|
|
|
case 2: |
|
|
|
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime; |
|
|
|
m_parms.fadeTime = (m_parms.pMessage->fadein * m_parms.length) + m_parms.pMessage->holdtime; |
|
|
|
|
|
|
|
|
|
|
@ -270,7 +267,6 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) |
|
|
|
m_parms.length = length; |
|
|
|
m_parms.length = length; |
|
|
|
m_parms.totalHeight = ( m_parms.lines * gHUD.m_scrinfo.iCharHeight ); |
|
|
|
m_parms.totalHeight = ( m_parms.lines * gHUD.m_scrinfo.iCharHeight ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight ); |
|
|
|
m_parms.y = YPosition( pMessage->y, m_parms.totalHeight ); |
|
|
|
pText = pMessage->pMessage; |
|
|
|
pText = pMessage->pMessage; |
|
|
|
|
|
|
|
|
|
|
@ -310,7 +306,6 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::Draw( float fTime ) |
|
|
|
int CHudMessage::Draw( float fTime ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i, drawn; |
|
|
|
int i, drawn; |
|
|
@ -341,7 +336,6 @@ int CHudMessage::Draw( float fTime ) |
|
|
|
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth ); |
|
|
|
int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth ); |
|
|
|
int y = YPosition( m_pGameTitle->y, fullHeight ); |
|
|
|
int y = YPosition( m_pGameTitle->y, fullHeight ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SPR_Set( gHUD.GetSprite( m_HUD_title_half ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); |
|
|
|
SPR_Set( gHUD.GetSprite( m_HUD_title_half ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); |
|
|
|
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_title_half ) ); |
|
|
|
SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_title_half ) ); |
|
|
|
|
|
|
|
|
|
|
@ -412,22 +406,69 @@ int CHudMessage::Draw( float fTime ) |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CHudMessage::MessageAdd( const char *pName, float time ) |
|
|
|
void CHudMessage::MessageAdd( const char *pName, float time ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i, j; |
|
|
|
|
|
|
|
client_textmessage_t *tempMessage; |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < maxHUDMessages; i++ ) |
|
|
|
for( i = 0; i < maxHUDMessages; i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( !m_pMessages[i] ) |
|
|
|
if( !m_pMessages[i] ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_pMessages[i] = TextMessageGet( pName ); |
|
|
|
// Trim off a leading # if it's there
|
|
|
|
m_startTime[i] = time; |
|
|
|
if( pName[0] == '#' ) |
|
|
|
|
|
|
|
tempMessage = TextMessageGet( pName + 1 ); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
tempMessage = TextMessageGet( pName ); |
|
|
|
|
|
|
|
// If we couldnt find it in the titles.txt, just create it
|
|
|
|
|
|
|
|
if( !tempMessage ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
g_pCustomMessage.effect = 2; |
|
|
|
|
|
|
|
g_pCustomMessage.r1 = g_pCustomMessage.g1 = g_pCustomMessage.b1 = g_pCustomMessage.a1 = 100; |
|
|
|
|
|
|
|
g_pCustomMessage.r2 = 240; |
|
|
|
|
|
|
|
g_pCustomMessage.g2 = 110; |
|
|
|
|
|
|
|
g_pCustomMessage.b2 = 0; |
|
|
|
|
|
|
|
g_pCustomMessage.a2 = 0; |
|
|
|
|
|
|
|
g_pCustomMessage.x = -1; // Centered
|
|
|
|
|
|
|
|
g_pCustomMessage.y = 0.7; |
|
|
|
|
|
|
|
g_pCustomMessage.fadein = 0.01; |
|
|
|
|
|
|
|
g_pCustomMessage.fadeout = 1.5; |
|
|
|
|
|
|
|
g_pCustomMessage.fxtime = 0.25; |
|
|
|
|
|
|
|
g_pCustomMessage.holdtime = 5; |
|
|
|
|
|
|
|
g_pCustomMessage.pName = g_pCustomName; |
|
|
|
|
|
|
|
strcpy( g_pCustomText, pName ); |
|
|
|
|
|
|
|
g_pCustomMessage.pMessage = g_pCustomText; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tempMessage = &g_pCustomMessage; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( j = 0; j < maxHUDMessages; j++ ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( m_pMessages[j] ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// is this message already in the list
|
|
|
|
|
|
|
|
if( !strcmp( tempMessage->pMessage, m_pMessages[j]->pMessage ) ) |
|
|
|
|
|
|
|
{ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get rid of any other messages in same location (only one displays at a time)
|
|
|
|
|
|
|
|
if( fabs( tempMessage->y - m_pMessages[j]->y ) < 0.0001 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( fabs( tempMessage->x - m_pMessages[j]->x ) < 0.0001 ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_pMessages[j] = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_pMessages[i] = tempMessage; |
|
|
|
|
|
|
|
m_startTime[i] = time; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) |
|
|
|
int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -436,6 +477,7 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) |
|
|
|
char *pString = READ_STRING(); |
|
|
|
char *pString = READ_STRING(); |
|
|
|
|
|
|
|
|
|
|
|
MessageAdd( pString, gHUD.m_flTime ); |
|
|
|
MessageAdd( pString, gHUD.m_flTime ); |
|
|
|
|
|
|
|
|
|
|
|
// Remember the time -- to fix up level transitions
|
|
|
|
// Remember the time -- to fix up level transitions
|
|
|
|
m_parms.time = gHUD.m_flTime; |
|
|
|
m_parms.time = gHUD.m_flTime; |
|
|
|
|
|
|
|
|
|
|
@ -446,7 +488,6 @@ int CHudMessage::MsgFunc_HudText( const char *pszName, int iSize, void *pbuf ) |
|
|
|
return 1; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf ) |
|
|
|
int CHudMessage::MsgFunc_GameTitle( const char *pszName, int iSize, void *pbuf ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_pGameTitle = TextMessageGet( "GAMETITLE" ); |
|
|
|
m_pGameTitle = TextMessageGet( "GAMETITLE" ); |
|
|
|