diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/dod/dod_hud_playerstatuspanel.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/client/dod/dod_hud_playerstatuspanel.cpp')
| -rw-r--r-- | game/client/dod/dod_hud_playerstatuspanel.cpp | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/game/client/dod/dod_hud_playerstatuspanel.cpp b/game/client/dod/dod_hud_playerstatuspanel.cpp new file mode 100644 index 0000000..5419869 --- /dev/null +++ b/game/client/dod/dod_hud_playerstatuspanel.cpp @@ -0,0 +1,184 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "hudelement.h" +#include <vgui_controls/EditablePanel.h> +#include <vgui_controls/ImagePanel.h> +#include <vgui/ISurface.h> +#include "c_dod_player.h" +#include "clientmode_dod.h" + +#include "dodcornercutpanel.h" + +#include "c_dod_objective_resource.h" +#include "c_dod_playerresource.h" + +#include "dod_hud_playerstatus_ammo.h" +#include "dod_hud_playerstatus_health.h" +#include "dod_hud_playerstatus_weapon.h" +#include "dod_hud_playerstatus_stamina.h" +#include "dod_hud_playerstatus_mgheat.h" +#include "dod_hud_playerstatus_fireselect.h" +#include "dod_hud_playerstatus_tnt.h" + +class CDoDHudPlayerStatusPanel : public CHudElement, public vgui::EditablePanel +{ +public: + DECLARE_CLASS_SIMPLE( CDoDHudPlayerStatusPanel, vgui::EditablePanel ); + + CDoDHudPlayerStatusPanel( const char *pElementName ); + + virtual void Init(); + virtual void OnThink(); + virtual void PerformLayout(); + virtual void ApplySchemeSettings( IScheme *pScheme ); + +private: + + CDoDCutEditablePanel *m_pMainBar; + ImagePanel *m_pAlliesIcon; + ImagePanel *m_pAxisIcon; + CDoDHudAmmo *m_pAmmoStatus; + CDoDHudHealth *m_pHealthStatus; + CDoDHudCurrentWeapon *m_pCurrentWeapon; + CDoDHudStamina *m_pStamina; + CDoDHudMGHeat *m_pMGHeat; + CDoDHudFireSelect *m_pFireSelect; + CDoDHudTNT *m_pTNT; +}; + +DECLARE_HUDELEMENT( CDoDHudPlayerStatusPanel ); + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CDoDHudPlayerStatusPanel::CDoDHudPlayerStatusPanel( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudPlayerStatusPanel" ) +{ + SetParent( g_pClientMode->GetViewport() ); + + m_pMainBar = new CDoDCutEditablePanel( this, "PlayerStatusMainBackground" ); + m_pAlliesIcon = new ImagePanel( this, "PlayerStatusAlliesIcon" ); + m_pAxisIcon = new ImagePanel( this, "PlayerStatusAxisIcon" ); + m_pAmmoStatus = new CDoDHudAmmo( this, "PlayerStatusAmmo" ); + m_pCurrentWeapon = new CDoDHudCurrentWeapon( this, "PlayerStatusCurrentWeapon" ); + m_pHealthStatus = new CDoDHudHealth( this, "PlayerStatusHealth" ); + m_pStamina = new CDoDHudStamina( this, "PlayerStatusStamina" ); + m_pMGHeat = new CDoDHudMGHeat( this, "PlayerStatusMGHeat" ); + m_pFireSelect = new CDoDHudFireSelect( this, "PlayerStatusFireSelect" ); + m_pTNT = new CDoDHudTNT( this, "PlayerStatusTNT" ); +} + +void CDoDHudPlayerStatusPanel::ApplySchemeSettings( IScheme *pScheme ) +{ + // load control settings... + LoadControlSettings( "resource/UI/HudPlayerStatusPanel.res" ); + + BaseClass::ApplySchemeSettings( pScheme ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDHudPlayerStatusPanel::Init() +{ + if ( m_pMainBar ) + { + m_pMainBar->SetVisible( true ); + } + + if ( m_pStamina ) + { + m_pStamina->SetVisible( true ); + } + + if ( m_pAlliesIcon ) + { + m_pAlliesIcon->SetVisible( false ); + } + + if ( m_pAxisIcon ) + { + m_pAxisIcon->SetVisible( false ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDHudPlayerStatusPanel::PerformLayout() +{ + BaseClass::PerformLayout(); + + int x, y, w, t; + GetBounds( x, y, w, t ); + + if ( w != ScreenWidth() ) + { + // doing this because of the 16:9 and 16:10 resolutions (VGUI doesn't scale properly for them) + SetBounds( x, y, ScreenWidth(), t ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CDoDHudPlayerStatusPanel::OnThink() +{ + BaseClass::OnThink(); + + C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer(); + + if ( pPlayer ) + { + // turn off the panel and children if the player is dead + if ( !pPlayer->IsAlive() ) + { + if ( IsVisible() ) + { + SetVisible( false ); + } + return; + } + else + { + if ( !IsVisible() ) + { + SetVisible( true ); + } + } + + // set our team icon + int nTeam = pPlayer->GetTeamNumber(); + + switch( nTeam ) + { + case TEAM_AXIS: + if ( m_pAlliesIcon && m_pAlliesIcon->IsVisible() ) + { + m_pAlliesIcon->SetVisible( false ); + } + if ( m_pAxisIcon && !m_pAxisIcon->IsVisible() ) + { + m_pAxisIcon->SetVisible( true ); + } + break; + case TEAM_ALLIES: + default: + if ( m_pAlliesIcon && !m_pAlliesIcon->IsVisible() ) + { + m_pAlliesIcon->SetVisible( true ); + } + if ( m_pAxisIcon && m_pAxisIcon->IsVisible() ) + { + m_pAxisIcon->SetVisible( false ); + } + break; + } + } +} + + |