aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/hud_posture.cpp
diff options
context:
space:
mode:
authorJørgen P. Tjernø <[email protected]>2013-12-02 19:31:46 -0800
committerJørgen P. Tjernø <[email protected]>2013-12-02 19:46:31 -0800
commitf56bb35301836e56582a575a75864392a0177875 (patch)
treede61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/hud_posture.cpp
parentMark some more files as text. (diff)
downloadsource-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz
source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/hud_posture.cpp')
-rw-r--r--mp/src/game/client/hud_posture.cpp390
1 files changed, 195 insertions, 195 deletions
diff --git a/mp/src/game/client/hud_posture.cpp b/mp/src/game/client/hud_posture.cpp
index 8321ea8d..0e76cf27 100644
--- a/mp/src/game/client/hud_posture.cpp
+++ b/mp/src/game/client/hud_posture.cpp
@@ -1,195 +1,195 @@
-//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#include "cbase.h"
-#include "hud.h"
-#include "hudelement.h"
-#include "hud_numericdisplay.h"
-#include "hud_macros.h"
-#include "iclientmode.h"
-#include <vgui_controls/AnimationController.h>
-#include <vgui/ISurface.h>
-#include <vgui/ILocalize.h>
-#include <vgui_controls/Panel.h>
-#include <vgui/IVGui.h>
-
-
-using namespace vgui;
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-#define HUD_POSTURE_UPDATES_PER_SECOND 10
-#define HUD_POSTURE_FADE_TIME 0.4f
-#define CROUCHING_CHARACTER_INDEX 92 // index of the crouching dude in the TTF font
-
-//-----------------------------------------------------------------------------
-// Purpose: Shows the sprint power bar
-//-----------------------------------------------------------------------------
-class CHudPosture : public CHudElement, public vgui::Panel
-{
- DECLARE_CLASS_SIMPLE( CHudPosture, vgui::Panel );
-
-public:
- CHudPosture( const char *pElementName );
- bool ShouldDraw( void );
-
-#ifdef _X360 // if not xbox 360, don't waste code space on this
- virtual void Init( void );
- virtual void Reset( void );
- virtual void OnTick( void );
-
-protected:
- virtual void Paint();
-
- float m_duckTimeout; /// HUD_POSTURE_FADE_TIME after the last known time the player was ducking
-
-private:
-
- CPanelAnimationVar( vgui::HFont, m_hFont, "Font", "WeaponIconsSmall" );
- CPanelAnimationVarAliasType( float, m_IconX, "icon_xpos", "4", "proportional_float" );
- CPanelAnimationVarAliasType( float, m_IconY, "icon_ypos", "4", "proportional_float" );
-
- enum { NOT_FADING,
- FADING_UP,
- FADING_DOWN
- } m_kIsFading;
-#endif
-};
-
-
-DECLARE_HUDELEMENT( CHudPosture );
-
-
-namespace
-{
- // Don't pass a null pPlayer. Doesn't check for it.
- inline bool PlayerIsDucking(C_BasePlayer *pPlayer)
- {
- return pPlayer->m_Local.m_bDucked && // crouching
- pPlayer->GetGroundEntity() != NULL ; // but not jumping
- }
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Constructor
-//-----------------------------------------------------------------------------
-CHudPosture::CHudPosture( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudPosture" )
-{
- vgui::Panel *pParent = g_pClientMode->GetViewport();
- SetParent( pParent );
-
- SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
-
- if( IsX360() )
- {
- vgui::ivgui()->AddTickSignal( GetVPanel(), (1000/HUD_POSTURE_UPDATES_PER_SECOND) );
- }
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Save CPU cycles by letting the HUD system early cull
-// costly traversal. Called per frame, return true if thinking and
-// painting need to occur.
-//-----------------------------------------------------------------------------
-bool CHudPosture::ShouldDraw()
-{
-#ifdef _X360
- return ( m_duckTimeout >= gpGlobals->curtime &&
- CHudElement::ShouldDraw() );
-#else
- return false;
-#endif
-}
-
-#ifdef _X360
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-void CHudPosture::Init( void )
-{
- m_duckTimeout = 0.0f;
- m_kIsFading = NOT_FADING;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-void CHudPosture::Reset( void )
-{
- Init();
-}
-
-void CHudPosture::OnTick( void )
-{
- C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
- if (!pPlayer)
- return;
-
- if ( PlayerIsDucking(pPlayer) )
- {
- m_duckTimeout = gpGlobals->curtime + HUD_POSTURE_FADE_TIME; // kick the timer forward
- if (GetAlpha() < 255)
- {
- // if not fully faded in, and not fading in, start fading in.
- if (m_kIsFading != FADING_UP)
- {
- m_kIsFading = FADING_UP;
- GetAnimationController()->RunAnimationCommand( this, "alpha", 255, 0, HUD_POSTURE_FADE_TIME, vgui::AnimationController::INTERPOLATOR_SIMPLESPLINE );
- }
- }
- else
- {
- m_kIsFading = NOT_FADING;
- }
- }
- else // player is not ducking
- {
- if (GetAlpha() > 0)
- {
- // if not faded out or fading out, fade out.
- if (m_kIsFading != FADING_DOWN)
- {
- m_kIsFading = FADING_DOWN;
- GetAnimationController()->RunAnimationCommand( this, "alpha", 0, 0, HUD_POSTURE_FADE_TIME, vgui::AnimationController::INTERPOLATOR_SIMPLESPLINE );
- }
- }
- else
- {
- m_kIsFading = NOT_FADING;
- }
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: draws the posture elements we want.
-//-----------------------------------------------------------------------------
-void CHudPosture::Paint()
-{
- C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
- if ( !pPlayer )
- return;
-
- SetPaintBackgroundEnabled( true );
-
- Color clr;
- clr = gHUD.m_clrNormal;
- clr[3] = 255;
-
- // Pick the duck character
- wchar_t duck_char = CROUCHING_CHARACTER_INDEX;
-
- surface()->DrawSetTextFont( m_hFont );
- surface()->DrawSetTextColor( clr );
- surface()->DrawSetTextPos( m_IconX, m_IconY );
- surface()->DrawUnicodeChar( duck_char );
-}
-
-#endif
-
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "hud.h"
+#include "hudelement.h"
+#include "hud_numericdisplay.h"
+#include "hud_macros.h"
+#include "iclientmode.h"
+#include <vgui_controls/AnimationController.h>
+#include <vgui/ISurface.h>
+#include <vgui/ILocalize.h>
+#include <vgui_controls/Panel.h>
+#include <vgui/IVGui.h>
+
+
+using namespace vgui;
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+#define HUD_POSTURE_UPDATES_PER_SECOND 10
+#define HUD_POSTURE_FADE_TIME 0.4f
+#define CROUCHING_CHARACTER_INDEX 92 // index of the crouching dude in the TTF font
+
+//-----------------------------------------------------------------------------
+// Purpose: Shows the sprint power bar
+//-----------------------------------------------------------------------------
+class CHudPosture : public CHudElement, public vgui::Panel
+{
+ DECLARE_CLASS_SIMPLE( CHudPosture, vgui::Panel );
+
+public:
+ CHudPosture( const char *pElementName );
+ bool ShouldDraw( void );
+
+#ifdef _X360 // if not xbox 360, don't waste code space on this
+ virtual void Init( void );
+ virtual void Reset( void );
+ virtual void OnTick( void );
+
+protected:
+ virtual void Paint();
+
+ float m_duckTimeout; /// HUD_POSTURE_FADE_TIME after the last known time the player was ducking
+
+private:
+
+ CPanelAnimationVar( vgui::HFont, m_hFont, "Font", "WeaponIconsSmall" );
+ CPanelAnimationVarAliasType( float, m_IconX, "icon_xpos", "4", "proportional_float" );
+ CPanelAnimationVarAliasType( float, m_IconY, "icon_ypos", "4", "proportional_float" );
+
+ enum { NOT_FADING,
+ FADING_UP,
+ FADING_DOWN
+ } m_kIsFading;
+#endif
+};
+
+
+DECLARE_HUDELEMENT( CHudPosture );
+
+
+namespace
+{
+ // Don't pass a null pPlayer. Doesn't check for it.
+ inline bool PlayerIsDucking(C_BasePlayer *pPlayer)
+ {
+ return pPlayer->m_Local.m_bDucked && // crouching
+ pPlayer->GetGroundEntity() != NULL ; // but not jumping
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+CHudPosture::CHudPosture( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudPosture" )
+{
+ vgui::Panel *pParent = g_pClientMode->GetViewport();
+ SetParent( pParent );
+
+ SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
+
+ if( IsX360() )
+ {
+ vgui::ivgui()->AddTickSignal( GetVPanel(), (1000/HUD_POSTURE_UPDATES_PER_SECOND) );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Save CPU cycles by letting the HUD system early cull
+// costly traversal. Called per frame, return true if thinking and
+// painting need to occur.
+//-----------------------------------------------------------------------------
+bool CHudPosture::ShouldDraw()
+{
+#ifdef _X360
+ return ( m_duckTimeout >= gpGlobals->curtime &&
+ CHudElement::ShouldDraw() );
+#else
+ return false;
+#endif
+}
+
+#ifdef _X360
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHudPosture::Init( void )
+{
+ m_duckTimeout = 0.0f;
+ m_kIsFading = NOT_FADING;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHudPosture::Reset( void )
+{
+ Init();
+}
+
+void CHudPosture::OnTick( void )
+{
+ C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
+ if (!pPlayer)
+ return;
+
+ if ( PlayerIsDucking(pPlayer) )
+ {
+ m_duckTimeout = gpGlobals->curtime + HUD_POSTURE_FADE_TIME; // kick the timer forward
+ if (GetAlpha() < 255)
+ {
+ // if not fully faded in, and not fading in, start fading in.
+ if (m_kIsFading != FADING_UP)
+ {
+ m_kIsFading = FADING_UP;
+ GetAnimationController()->RunAnimationCommand( this, "alpha", 255, 0, HUD_POSTURE_FADE_TIME, vgui::AnimationController::INTERPOLATOR_SIMPLESPLINE );
+ }
+ }
+ else
+ {
+ m_kIsFading = NOT_FADING;
+ }
+ }
+ else // player is not ducking
+ {
+ if (GetAlpha() > 0)
+ {
+ // if not faded out or fading out, fade out.
+ if (m_kIsFading != FADING_DOWN)
+ {
+ m_kIsFading = FADING_DOWN;
+ GetAnimationController()->RunAnimationCommand( this, "alpha", 0, 0, HUD_POSTURE_FADE_TIME, vgui::AnimationController::INTERPOLATOR_SIMPLESPLINE );
+ }
+ }
+ else
+ {
+ m_kIsFading = NOT_FADING;
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: draws the posture elements we want.
+//-----------------------------------------------------------------------------
+void CHudPosture::Paint()
+{
+ C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
+ if ( !pPlayer )
+ return;
+
+ SetPaintBackgroundEnabled( true );
+
+ Color clr;
+ clr = gHUD.m_clrNormal;
+ clr[3] = 255;
+
+ // Pick the duck character
+ wchar_t duck_char = CROUCHING_CHARACTER_INDEX;
+
+ surface()->DrawSetTextFont( m_hFont );
+ surface()->DrawSetTextColor( clr );
+ surface()->DrawSetTextPos( m_IconX, m_IconY );
+ surface()->DrawUnicodeChar( duck_char );
+}
+
+#endif
+