//========= Copyright Valve Corporation, All rights reserved. ============// // // Purpose: // // $NoKeywords: $ //=============================================================================// #include "cbase.h" #include "tf_hud_freezepanel.h" #include "vgui_controls/AnimationController.h" #include "iclientmode.h" #include "c_tf_player.h" #include "c_tf_playerresource.h" #include #include #include #include #include "c_baseobject.h" #include "fmtstr.h" #include "tf_gamerules.h" #include "tf_hud_statpanel.h" #include "view.h" #include "ivieweffects.h" #include "viewrender.h" #include "c_obj_sentrygun.h" #include "NextBot/C_NextBot.h" #include "halloween/c_headless_hatman.h" #include "halloween/c_eyeball_boss.h" #include "halloween/c_merasmus.h" #include "tf_wardata.h" #if defined( REPLAY_ENABLED ) #include "replay/ireplaysystem.h" #include "replay/ireplaymanager.h" #include "replay/replay.h" #include "replay/screenshot.h" #include "replay/ireplayscreenshotmanager.h" #include "replay/vgui/replayreminderpanel.h" #endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" DECLARE_HUDELEMENT_DEPTH( CTFFreezePanel, 1 ); #define CALLOUT_WIDE (XRES(100)) #define CALLOUT_TALL (XRES(50)) extern float g_flFreezeFlash; #define FREEZECAM_SCREENSHOT_STRING "is looking good!" extern ConVar hud_freezecamhide; bool IsTakingAFreezecamScreenshot( void ) { // Don't draw in freezecam, or when the game's not running C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); bool bInFreezeCam = ( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); if ( bInFreezeCam == true && engine->IsTakingScreenshot() ) return true; CTFFreezePanel *pFreezePanel = CTFFreezePanel::Instance(); if ( pFreezePanel ) { if ( pFreezePanel->IsHoldingAfterScreenShot() ) return true; } return false; } DECLARE_BUILD_FACTORY( CTFFreezePanelHealth ); //----------------------------------------------------------------------------- CTFFreezePanel *CTFFreezePanel::s_pFreezePanel = NULL; //----------------------------------------------------------------------------- CTFFreezePanel *CTFFreezePanel::Instance() { return s_pFreezePanel; } //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- CTFFreezePanel::CTFFreezePanel( const char *pElementName ) : EditablePanel( NULL, "FreezePanel" ), CHudElement( pElementName ) { AssertMsg( !s_pFreezePanel, "There can be only one." ); s_pFreezePanel = this; vgui::Panel *pParent = g_pClientMode->GetViewport(); SetParent( pParent ); SetVisible( false ); SetScheme( "ClientScheme" ); m_iKillerIndex = 0; m_iShowNemesisPanel = SHOW_NO_NEMESIS; m_iYBase = -1; m_flShowCalloutsAt = 0; m_iBasePanelOriginalX = -1; m_iBasePanelOriginalY = -1; m_pItemPanel = new CItemModelPanel( this, "itempanel" ) ; m_iItemPanelOriginalX = -1; m_iItemPanelOriginalY = -1; #if defined( REPLAY_ENABLED ) m_pSaveReplayPanel = GET_HUDELEMENT( CReplayReminderPanel ); // Use the HUD's instance #endif m_strCurrentFreezeCamResFile = GetResFilename(); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFFreezePanel::Reset() { Hide(); if ( m_pKillerHealth ) { m_pKillerHealth->Reset(); } } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFFreezePanel::Init() { // listen for events ListenForGameEvent( "show_freezepanel" ); ListenForGameEvent( "hide_freezepanel" ); ListenForGameEvent( "freezecam_started" ); ListenForGameEvent( "player_death" ); ListenForGameEvent( "teamplay_win_panel" ); ListenForGameEvent( "training_complete" ); Hide(); CHudElement::Init(); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFFreezePanel::SendTauntAcknowledgement( const char *pszCommand, int iGibs ) { C_TFPlayer *pKiller = ToTFPlayer( UTIL_PlayerByIndex( GetSpectatorTarget() ) ); if ( pKiller && pKiller->m_Shared.InCond( TF_COND_TAUNTING ) ) { CTFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( pPlayer ) { KeyValues *kv = new KeyValues( "FreezeCamTaunt" ); kv->SetInt( "achiever", pKiller->GetUserID() ); kv->SetString( "command", pszCommand ); kv->SetInt( "gibs", iGibs ); engine->ServerCmdKeyValues( kv ); } } } //----------------------------------------------------------------------------- // Purpose: Applies scheme settings //----------------------------------------------------------------------------- void CTFFreezePanel::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); Assert( !m_strCurrentFreezeCamResFile.IsEmpty() ); LoadControlSettings( m_strCurrentFreezeCamResFile.String() ); m_pBasePanel = dynamic_cast( FindChildByName("FreezePanelBase") ); Assert( m_pBasePanel ); if ( m_pBasePanel ) { m_pFreezeLabel = dynamic_cast