//========= Copyright © 1996-2005, 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 "c_baseobject.h" #include "fmtstr.h" #include "tf_gamerules.h" #include "tf_hud_statpanel.h" #include "view.h" #include "ivieweffects.h" #include "viewrender.h" // 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!" 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 *pPanel = GET_HUDELEMENT( CTFFreezePanel ); if ( pPanel ) { if ( pPanel->IsHoldingAfterScreenShot() ) return true; } return false; } DECLARE_BUILD_FACTORY( CTFFreezePanelHealth ); //----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- CTFFreezePanel::CTFFreezePanel( const char *pElementName ) : EditablePanel( NULL, "FreezePanel" ), CHudElement( pElementName ) { 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; } //----------------------------------------------------------------------------- // 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" ); Hide(); CHudElement::Init(); } //----------------------------------------------------------------------------- // Purpose: Applies scheme settings //----------------------------------------------------------------------------- void CTFFreezePanel::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); LoadControlSettings( "resource/UI/FreezePanel_Basic.res" ); m_pBasePanel = dynamic_cast( FindChildByName("FreezePanelBase") ); Assert( m_pBasePanel ); if ( m_pBasePanel ) { m_pFreezeLabel = dynamic_cast