Browse Source

Rework cinematic bars code.

noffice
Andrey Akhmichin 5 years ago
parent
commit
0027e80073
  1. 2
      cl_dll/CMakeLists.txt
  2. 2
      cl_dll/hud.cpp
  3. 23
      cl_dll/hud.h
  4. 9
      cl_dll/message.cpp
  5. 123
      cl_dll/noffice/cinematic.cpp
  6. 1
      cl_dll/tri.cpp
  7. 9
      dlls/maprules.cpp
  8. 40
      dlls/player.cpp
  9. 1
      dlls/player.h
  10. 2
      dlls/triggers.cpp

2
cl_dll/CMakeLists.txt

@ -52,9 +52,9 @@ endif()
set (CLDLL_SOURCES set (CLDLL_SOURCES
noffice/pain.cpp
noffice/cinematic.cpp noffice/cinematic.cpp
noffice/deathvision.cpp noffice/deathvision.cpp
noffice/pain.cpp
ev_hldm.cpp ev_hldm.cpp
hl/hl_baseentity.cpp hl/hl_baseentity.cpp
hl/hl_events.cpp hl/hl_events.cpp

2
cl_dll/hud.cpp

@ -232,7 +232,6 @@ void CHud::Init( void )
m_AmmoSecondary.Init(); m_AmmoSecondary.Init();
m_TextMessage.Init(); m_TextMessage.Init();
m_StatusIcons.Init(); m_StatusIcons.Init();
m_Cinematic.Init();
m_DeathVision.Init(); m_DeathVision.Init();
m_MOTD.Init(); m_MOTD.Init();
m_Scoreboard.Init(); m_Scoreboard.Init();
@ -415,7 +414,6 @@ void CHud::VidInit( void )
m_AmmoSecondary.VidInit(); m_AmmoSecondary.VidInit();
m_TextMessage.VidInit(); m_TextMessage.VidInit();
m_StatusIcons.VidInit(); m_StatusIcons.VidInit();
m_Cinematic.VidInit();
m_DeathVision.VidInit(); m_DeathVision.VidInit();
m_Scoreboard.VidInit(); m_Scoreboard.VidInit();
m_MOTD.VidInit(); m_MOTD.VidInit();

23
cl_dll/hud.h

@ -510,6 +510,7 @@ public:
void MessageScanStart( void ); void MessageScanStart( void );
void MessageScanNextChar( void ); void MessageScanNextChar( void );
void Reset( void ); void Reset( void );
void DrawCinematic( void );
private: private:
client_textmessage_t *m_pMessages[maxHUDMessages]; client_textmessage_t *m_pMessages[maxHUDMessages];
@ -520,6 +521,8 @@ private:
int m_HUD_title_life; int m_HUD_title_life;
int m_HUD_title_half; int m_HUD_title_half;
HSPRITE m_hSprite;
struct model_s *m_hSpriteModel;
}; };
// //
@ -559,25 +562,6 @@ private:
icon_sprite_t m_IconList[MAX_ICONSPRITES]; icon_sprite_t m_IconList[MAX_ICONSPRITES];
}; };
//
//-----------------------------------------------------
//
class CHudCinematic : public CHudBase
{
public:
int Init( void );
int VidInit( void );
int Draw( float flTime );
int MsgFunc_Cinematic( const char *pszName, int iSize, void *pbuf );
void DrawCinematic( void );
private:
HSPRITE m_hSprite;
float m_flCineTime;
};
// //
//----------------------------------------------------- //-----------------------------------------------------
// //
@ -672,7 +656,6 @@ public:
CHudAmmoSecondary m_AmmoSecondary; CHudAmmoSecondary m_AmmoSecondary;
CHudTextMessage m_TextMessage; CHudTextMessage m_TextMessage;
CHudStatusIcons m_StatusIcons; CHudStatusIcons m_StatusIcons;
CHudCinematic m_Cinematic;
CHudDeathVision m_DeathVision; CHudDeathVision m_DeathVision;
CHudScoreboard m_Scoreboard; CHudScoreboard m_Scoreboard;
CHudMOTD m_MOTD; CHudMOTD m_MOTD;

9
cl_dll/message.cpp

@ -46,8 +46,8 @@ int CHudMessage::Init( void )
int CHudMessage::VidInit( void ) int CHudMessage::VidInit( void )
{ {
m_HUD_title_half = gHUD.GetSpriteIndex( "title_half" ); m_HUD_title_half = gHUD.GetSpriteIndex( "wide_bar_a" );
m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); m_HUD_title_life = gHUD.GetSpriteIndex( "wide_bar_b" );
return 1; return 1;
} }
@ -329,7 +329,7 @@ int CHudMessage::Draw( float fTime )
else else
{ {
brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime ); brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime );
/*
int halfWidth = gHUD.GetSpriteRect( m_HUD_title_half ).right - gHUD.GetSpriteRect( m_HUD_title_half ).left; int halfWidth = gHUD.GetSpriteRect( m_HUD_title_half ).right - gHUD.GetSpriteRect( m_HUD_title_half ).left;
int fullWidth = halfWidth + gHUD.GetSpriteRect( m_HUD_title_life ).right - gHUD.GetSpriteRect( m_HUD_title_life ).left; int fullWidth = halfWidth + gHUD.GetSpriteRect( m_HUD_title_life ).right - gHUD.GetSpriteRect( m_HUD_title_life ).left;
int fullHeight = gHUD.GetSpriteRect( m_HUD_title_half ).bottom - gHUD.GetSpriteRect( m_HUD_title_half ).top; int fullHeight = gHUD.GetSpriteRect( m_HUD_title_half ).bottom - gHUD.GetSpriteRect( m_HUD_title_half ).top;
@ -342,7 +342,8 @@ int CHudMessage::Draw( float fTime )
SPR_Set( gHUD.GetSprite( m_HUD_title_life ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 ); SPR_Set( gHUD.GetSprite( m_HUD_title_life ), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect( m_HUD_title_life ) ); SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect( m_HUD_title_life ) );
*/
DrawCinematic();
drawn = 1; drawn = 1;
} }
} }

123
cl_dll/noffice/cinematic.cpp

@ -13,9 +13,9 @@
* *
****/ ****/
// //
// Geiger.cpp // cinematic.cpp
// //
// implementation of CHudAmmo class // implementation of CHudCinematic class
// //
#include "hud.h" #include "hud.h"
@ -30,110 +30,37 @@
#include "parsemsg.h" #include "parsemsg.h"
void CHudMessage::DrawCinematic()
DECLARE_MESSAGE(m_Cinematic, Cinematic)
int CHudCinematic::Init(void)
{
HOOK_MESSAGE(Cinematic);
m_iFlags = 0;
m_hSprite = 0;
m_flCineTime = 0;
gHUD.AddHudElem(this);
return 1;
};
int CHudCinematic::VidInit(void)
{
m_flCineTime = 0;
m_iFlags = 0;
m_hSprite = SPR_Load( "sprites/wide_bar.spr" );
return 1;
};
int CHudCinematic::MsgFunc_Cinematic(const char *pszName, int iSize, void *pbuf)
{
m_iFlags |= HUD_ACTIVE;
BEGIN_READ(pbuf, iSize);
m_flCineTime = READ_BYTE();
m_flCineTime = m_flCineTime + gEngfuncs.GetClientTime();
return 1;
}
int CHudCinematic::Draw(float flTime)
{
if (gHUD.m_iHideHUDDisplay & HIDEHUD_ALL)
return 1;
if (!(m_iFlags & HUD_ACTIVE))
return 1;
#if 0
// Height for a single bar.
int barHeight = ScreenHeight / 6;
// Draw upper dark bar.
gEngfuncs.pfnFillRGBA(0, 0, ScreenWidth, barHeight, 40, 40, 40, 255);
// Draw lower dark bar.
gEngfuncs.pfnFillRGBABlend(0, ScreenHeight - barHeight, ScreenWidth, barHeight, 0, 0, 0, 225);
#endif
return 1;
}
void CHudCinematic::DrawCinematic(void)
{ {
if (gHUD.m_iHideHUDDisplay & HIDEHUD_ALL) if( !m_hSprite )
return;
if (!(m_iFlags & HUD_ACTIVE))
return;
if (m_flCineTime <= gEngfuncs.GetClientTime())
{ {
m_iFlags &= ~HUD_ACTIVE; m_hSprite = SPR_Load( "sprites/wide_bar.spr" );
m_flCineTime = 0; m_hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hSprite );
return;
} }
if (!m_hSprite) gEngfuncs.pTriAPI->RenderMode( kRenderTransAlpha );
m_hSprite = SPR_Load("sprites/wide_bar.spr"); gEngfuncs.pTriAPI->SpriteTexture( m_hSpriteModel, 0 );
gEngfuncs.pTriAPI->Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
struct model_s * hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer(m_hSprite); // top right
gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 1.0f );
gEngfuncs.pTriAPI->Vertex3f( 0, 0, 0 );
gEngfuncs.pTriAPI->RenderMode(kRenderTransAlpha); // top left
gEngfuncs.pTriAPI->CullFace(TRI_NONE); gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f );
gEngfuncs.pTriAPI->SpriteTexture(hSpriteModel, 0); gEngfuncs.pTriAPI->Vertex3f( 0, ScreenHeight, 0 );
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
//top left // bottom left
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f); gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f );
gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); gEngfuncs.pTriAPI->Vertex3f( ScreenWidth, ScreenHeight, 0 );
//bottom left // bottom right
gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f); gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f );
gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 0); gEngfuncs.pTriAPI->Vertex3f( ScreenWidth, 0, 0 );
//bottom right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 1.0f);
gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, ScreenHeight, 0);
//top right
gEngfuncs.pTriAPI->TexCoord2f(1.0f, 0.0f);
gEngfuncs.pTriAPI->Vertex3f(ScreenWidth, 0, 0);
gEngfuncs.pTriAPI->End(); //end our list of vertexes gEngfuncs.pTriAPI->End(); //end our list of vertexes
gEngfuncs.pTriAPI->RenderMode(kRenderNormal); //return to normal gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); //return to normal
return;
} }

1
cl_dll/tri.cpp

@ -134,5 +134,4 @@ void HUD_DrawOrthoTriangles( void )
{ {
gHUD.m_Health.DrawPain2(); gHUD.m_Health.DrawPain2();
gHUD.m_DeathVision.DrawDeathVision(); gHUD.m_DeathVision.DrawDeathVision();
gHUD.m_Cinematic.DrawCinematic();
} }

9
dlls/maprules.cpp

@ -205,8 +205,6 @@ void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT
// Flag: All players SF_ENVTEXT_ALLPLAYERS // Flag: All players SF_ENVTEXT_ALLPLAYERS
// //
extern int gmsgCinematic;
#define SF_ENVTEXT_ALLPLAYERS 0x0001 #define SF_ENVTEXT_ALLPLAYERS 0x0001
class CGameText : public CRulePointEntity class CGameText : public CRulePointEntity
@ -310,13 +308,6 @@ void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
if( !CanFireForActivator( pActivator ) ) if( !CanFireForActivator( pActivator ) )
return; return;
if( ( FStrEq( STRING( gpGlobals->mapname ), "trn1" ) && FStrEq( STRING( pev->targetname ), "6months" ) ) || // training level.
( FStrEq( STRING( gpGlobals->mapname ), "f14" ) && FStrEq( STRING( pev->targetname ), "present" ) ) ) // start level.
{
// Center text on cinematics.
m_textParms.x = m_textParms.y = -1;
}
if( MessageToAll() ) if( MessageToAll() )
{ {
UTIL_HudMessageAll( m_textParms, MessageGet() ); UTIL_HudMessageAll( m_textParms, MessageGet() );

40
dlls/player.cpp

@ -121,7 +121,6 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] =
DEFINE_FIELD( CBasePlayer, m_flStaminaStart, FIELD_TIME ), DEFINE_FIELD( CBasePlayer, m_flStaminaStart, FIELD_TIME ),
DEFINE_FIELD( CBasePlayer, m_iStaminaLevel, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayer, m_iStaminaLevel, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayer, m_bCinematicCompleted, FIELD_BOOLEAN ),
//DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games
//DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games
@ -192,7 +191,6 @@ int gmsgBhopcap = 0;
int gmsgStatusText = 0; int gmsgStatusText = 0;
int gmsgStatusValue = 0; int gmsgStatusValue = 0;
int gmsgCinematic = 0;
int gmsgDeathVision = 0; int gmsgDeathVision = 0;
void LinkUserMessages( void ) void LinkUserMessages( void )
@ -242,7 +240,6 @@ void LinkUserMessages( void )
gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 );
gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 );
gmsgCinematic = REG_USER_MSG( "Cinematic", 1 );
gmsgDeathVision = REG_USER_MSG( "DeathVision", 1 ); gmsgDeathVision = REG_USER_MSG( "DeathVision", 1 );
} }
@ -2804,7 +2801,6 @@ void CBasePlayer::Spawn( void )
m_iAutoWepSwitch = 1; m_iAutoWepSwitch = 1;
m_flStaminaStart = 0; m_flStaminaStart = 0;
m_iStaminaLevel = 100; m_iStaminaLevel = 100;
m_bCinematicCompleted = FALSE;
g_pGameRules->PlayerSpawn( this ); g_pGameRules->PlayerSpawn( this );
} }
@ -2931,8 +2927,6 @@ int CBasePlayer::Restore( CRestore &restore )
// Barring that, we clear it out here instead of using the incorrect restored time value. // Barring that, we clear it out here instead of using the incorrect restored time value.
m_flNextAttack = UTIL_WeaponTimeBase(); m_flNextAttack = UTIL_WeaponTimeBase();
#endif #endif
// Do not draw cinematic after loading.
m_bCinematicCompleted = TRUE;
return status; return status;
} }
@ -3833,38 +3827,10 @@ void CBasePlayer::UpdateClientData( void )
// HACKHACK -- send the message to display the game title // HACKHACK -- send the message to display the game title
if( gDisplayTitle ) if( gDisplayTitle )
{ {
if( !m_bCinematicCompleted ) MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, pev );
{ WRITE_BYTE( 0 );
// ========================================== MESSAGE_END();
// Code changes for- Night at the Office:
// ==========================================
//
// -Cinematic bars. Changed the game title code to display widescreen bars,
// used in the opening of the main game. The bars are active while player
// is stuck into position, to give a cinematic feel to the opening sequence.
// So the player wont think he is genuinely stuck into the environment.
int duration = 0;
// training level.
if( FStrEq( STRING( gpGlobals->mapname ), "trn1" ) )
{
duration = 34;
}
// start level.
else if( FStrEq( STRING( gpGlobals->mapname ), "f14" ) )
{
duration = 41;
}
// Tell client to show cinematic bars.
MESSAGE_BEGIN( MSG_ONE, gmsgCinematic, NULL, pev );
WRITE_BYTE( duration );
MESSAGE_END();
// Only do this once.
m_bCinematicCompleted = TRUE;
}
gDisplayTitle = 0; gDisplayTitle = 0;
} }

1
dlls/player.h

@ -329,7 +329,6 @@ public:
void UpdateStamina( void ); void UpdateStamina( void );
int m_iStaminaLevel; int m_iStaminaLevel;
float m_flStaminaStart; float m_flStaminaStart;
BOOL m_bCinematicCompleted;
Vector m_vecLastViewAngles; Vector m_vecLastViewAngles;

2
dlls/triggers.cpp

@ -37,8 +37,6 @@
extern DLL_GLOBAL BOOL g_fGameOver; extern DLL_GLOBAL BOOL g_fGameOver;
extern int gmsgCinematic;
extern void SetMovedir(entvars_t* pev); extern void SetMovedir(entvars_t* pev);
extern Vector VecBModelOrigin( entvars_t* pevBModel ); extern Vector VecBModelOrigin( entvars_t* pevBModel );

Loading…
Cancel
Save