From 0027e80073393f555f7ab6add0c83616db2ca4b0 Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Fri, 1 May 2020 14:30:07 +0500 Subject: [PATCH] Rework cinematic bars code. --- cl_dll/CMakeLists.txt | 2 +- cl_dll/hud.cpp | 2 - cl_dll/hud.h | 23 +------ cl_dll/message.cpp | 9 +-- cl_dll/noffice/cinematic.cpp | 123 +++++++---------------------------- cl_dll/tri.cpp | 1 - dlls/maprules.cpp | 9 --- dlls/player.cpp | 40 +----------- dlls/player.h | 1 - dlls/triggers.cpp | 2 - 10 files changed, 37 insertions(+), 175 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index ec0875e0..e43a2688 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -52,9 +52,9 @@ endif() set (CLDLL_SOURCES - noffice/pain.cpp noffice/cinematic.cpp noffice/deathvision.cpp + noffice/pain.cpp ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index e4334b60..0947cb1e 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -232,7 +232,6 @@ void CHud::Init( void ) m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); - m_Cinematic.Init(); m_DeathVision.Init(); m_MOTD.Init(); m_Scoreboard.Init(); @@ -415,7 +414,6 @@ void CHud::VidInit( void ) m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); - m_Cinematic.VidInit(); m_DeathVision.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 6ccc7f32..3518cc25 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -510,6 +510,7 @@ public: void MessageScanStart( void ); void MessageScanNextChar( void ); void Reset( void ); + void DrawCinematic( void ); private: client_textmessage_t *m_pMessages[maxHUDMessages]; @@ -520,6 +521,8 @@ private: int m_HUD_title_life; 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]; }; -// -//----------------------------------------------------- -// -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; CHudTextMessage m_TextMessage; CHudStatusIcons m_StatusIcons; - CHudCinematic m_Cinematic; CHudDeathVision m_DeathVision; CHudScoreboard m_Scoreboard; CHudMOTD m_MOTD; diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index 29834a13..4a3f24df 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -46,8 +46,8 @@ int CHudMessage::Init( void ) int CHudMessage::VidInit( void ) { - m_HUD_title_half = gHUD.GetSpriteIndex( "title_half" ); - m_HUD_title_life = gHUD.GetSpriteIndex( "title_life" ); + m_HUD_title_half = gHUD.GetSpriteIndex( "wide_bar_a" ); + m_HUD_title_life = gHUD.GetSpriteIndex( "wide_bar_b" ); return 1; } @@ -329,7 +329,7 @@ int CHudMessage::Draw( float fTime ) else { 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 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; @@ -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_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect( m_HUD_title_life ) ); - +*/ + DrawCinematic(); drawn = 1; } } diff --git a/cl_dll/noffice/cinematic.cpp b/cl_dll/noffice/cinematic.cpp index 96ff73ed..a9763d00 100644 --- a/cl_dll/noffice/cinematic.cpp +++ b/cl_dll/noffice/cinematic.cpp @@ -13,9 +13,9 @@ * ****/ // -// Geiger.cpp +// cinematic.cpp // -// implementation of CHudAmmo class +// implementation of CHudCinematic class // #include "hud.h" @@ -30,110 +30,37 @@ #include "parsemsg.h" - -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) +void CHudMessage::DrawCinematic() { - if (gHUD.m_iHideHUDDisplay & HIDEHUD_ALL) - return; - - if (!(m_iFlags & HUD_ACTIVE)) - return; - - if (m_flCineTime <= gEngfuncs.GetClientTime()) + if( !m_hSprite ) { - m_iFlags &= ~HUD_ACTIVE; - m_flCineTime = 0; - - return; + m_hSprite = SPR_Load( "sprites/wide_bar.spr" ); + m_hSpriteModel = (struct model_s *)gEngfuncs.GetSpritePointer( m_hSprite ); } - if (!m_hSprite) - m_hSprite = SPR_Load("sprites/wide_bar.spr"); + gEngfuncs.pTriAPI->RenderMode( kRenderTransAlpha ); + 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); - gEngfuncs.pTriAPI->CullFace(TRI_NONE); - gEngfuncs.pTriAPI->SpriteTexture(hSpriteModel, 0); - gEngfuncs.pTriAPI->Begin(TRI_QUADS); + // top left + gEngfuncs.pTriAPI->TexCoord2f( 0.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( 0, ScreenHeight, 0 ); - //top left - gEngfuncs.pTriAPI->TexCoord2f(0.0f, 0.0f); - gEngfuncs.pTriAPI->Vertex3f(0, 0, 0); + // bottom left + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 0.0f ); + gEngfuncs.pTriAPI->Vertex3f( ScreenWidth, ScreenHeight, 0 ); - //bottom left - gEngfuncs.pTriAPI->TexCoord2f(0.0f, 1.0f); - gEngfuncs.pTriAPI->Vertex3f(0, ScreenHeight, 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); + // bottom right + gEngfuncs.pTriAPI->TexCoord2f( 1.0f, 1.0f ); + gEngfuncs.pTriAPI->Vertex3f( ScreenWidth, 0, 0 ); gEngfuncs.pTriAPI->End(); //end our list of vertexes - gEngfuncs.pTriAPI->RenderMode(kRenderNormal); //return to normal - - return; + gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); //return to normal } + diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 68e841ee..e9f806ea 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -134,5 +134,4 @@ void HUD_DrawOrthoTriangles( void ) { gHUD.m_Health.DrawPain2(); gHUD.m_DeathVision.DrawDeathVision(); - gHUD.m_Cinematic.DrawCinematic(); } diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 72531915..519f7d2a 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -205,8 +205,6 @@ void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT // Flag: All players SF_ENVTEXT_ALLPLAYERS // -extern int gmsgCinematic; - #define SF_ENVTEXT_ALLPLAYERS 0x0001 class CGameText : public CRulePointEntity @@ -310,13 +308,6 @@ void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use if( !CanFireForActivator( pActivator ) ) 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() ) { UTIL_HudMessageAll( m_textParms, MessageGet() ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 473290e7..be56c7d1 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -121,7 +121,6 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD( CBasePlayer, m_flStaminaStart, FIELD_TIME ), 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_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games @@ -192,7 +191,6 @@ int gmsgBhopcap = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; -int gmsgCinematic = 0; int gmsgDeathVision = 0; void LinkUserMessages( void ) @@ -242,7 +240,6 @@ void LinkUserMessages( void ) gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); - gmsgCinematic = REG_USER_MSG( "Cinematic", 1 ); gmsgDeathVision = REG_USER_MSG( "DeathVision", 1 ); } @@ -2804,7 +2801,6 @@ void CBasePlayer::Spawn( void ) m_iAutoWepSwitch = 1; m_flStaminaStart = 0; m_iStaminaLevel = 100; - m_bCinematicCompleted = FALSE; 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. m_flNextAttack = UTIL_WeaponTimeBase(); #endif - // Do not draw cinematic after loading. - m_bCinematicCompleted = TRUE; return status; } @@ -3833,38 +3827,10 @@ void CBasePlayer::UpdateClientData( void ) // HACKHACK -- send the message to display the game title if( gDisplayTitle ) { - if( !m_bCinematicCompleted ) - { - // ========================================== - // 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(); + MESSAGE_BEGIN( MSG_ONE, gmsgShowGameTitle, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); - // Only do this once. - m_bCinematicCompleted = TRUE; - } gDisplayTitle = 0; } diff --git a/dlls/player.h b/dlls/player.h index cba5c646..4cd45953 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -329,7 +329,6 @@ public: void UpdateStamina( void ); int m_iStaminaLevel; float m_flStaminaStart; - BOOL m_bCinematicCompleted; Vector m_vecLastViewAngles; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index f7c9381f..4bbf0295 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -37,8 +37,6 @@ extern DLL_GLOBAL BOOL g_fGameOver; -extern int gmsgCinematic; - extern void SetMovedir(entvars_t* pev); extern Vector VecBModelOrigin( entvars_t* pevBModel );