source-engine/game/client/tf2base/tf_hud_building_status.h
2022-08-10 19:52:28 +03:00

346 lines
9.5 KiB
C++

//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef TF_HUD_BUILDING_STATUS_H
#define TF_HUD_BUILDING_STATUS_H
#ifdef _WIN32
#pragma once
#endif
#include "hudelement.h"
#include "tf_controls.h"
#include <vgui_controls/EditablePanel.h>
#include <vgui/IScheme.h>
#include <vgui_controls/ProgressBar.h>
#include "utlpriorityqueue.h"
class C_BaseObject;
class CIconPanel;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingHealthBar : public vgui::ProgressBar
{
DECLARE_CLASS_SIMPLE( CBuildingHealthBar, vgui::ProgressBar );
public:
CBuildingHealthBar(Panel *parent, const char *panelName);
virtual void Paint();
virtual void PaintBackground();
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
private:
Color m_cHealthColor;
Color m_cLowHealthColor;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusAlertTray : public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CBuildingStatusAlertTray, vgui::Panel );
public:
CBuildingStatusAlertTray(Panel *parent, const char *panelName);
void ApplySettings( KeyValues *inResourceData );
virtual void Paint( void );
virtual void PaintBackground( void );
void LevelInit( void );
void ShowTray( void );
void HideTray( void );
bool IsTrayOut( void ) { return m_bIsTrayOut; }
void SetAlertType( BuildingHudAlert_t alertLevel );
float GetPercentDeployed( void ) { return m_flAlertDeployedPercent; }
BuildingHudAlert_t GetAlertType( void ) { return m_lastAlertType; }
private:
bool m_bIsTrayOut;
bool m_bUseTallImage;
CHudTexture *m_pAlertPanelHudTexture;
IMaterial *m_pAlertPanelMaterial;
BuildingHudAlert_t m_lastAlertType;
CPanelAnimationVar( float, m_flAlertDeployedPercent, "deployed", "0.0" );
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem, vgui::EditablePanel );
public:
// actual panel constructor
CBuildingStatusItem( Panel *parent, const char *szLayout, int iObjectType );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void Paint( void );
virtual void PaintBackground( void );
virtual void OnTick( void );
virtual void PerformLayout( void );
virtual void LevelInit( void );
bool HasBeenPositioned() const { return bPositioned; }
void SetPositioned(bool val) { bPositioned = val; }
int GetRepresentativeObjectType();
C_BaseObject *GetRepresentativeObject();
virtual int GetObjectPriority();
virtual const char *GetBackgroundImage( void );
virtual const char *GetInactiveBackgroundImage( void );
vgui::EditablePanel *GetBuiltPanel() { return m_pBuiltPanel; }
vgui::EditablePanel *GetNotBuiltPanel() { return m_pNotBuiltPanel; }
vgui::EditablePanel *GetBuildingPanel() { return m_pBuildingPanel; }
vgui::EditablePanel *GetRunningPanel() { return m_pRunningPanel; }
virtual bool IsRealObject( void ) { return true; }
void SetObject( C_BaseObject *pObj );
bool IsActive( void ) { return m_bActive; }
private:
bool bPositioned; // false if we have not yet faded in and been positioned
char m_szLayout[128];
int m_iObjectType;
bool m_bActive;
// Two main subpanels
vgui::EditablePanel *m_pNotBuiltPanel;
vgui::EditablePanel *m_pBuiltPanel;
// Subpanels of the m_pBuiltPanel
vgui::EditablePanel *m_pBuildingPanel; // subpanel shown while building
vgui::EditablePanel *m_pRunningPanel; // subpanel shown while built and running
vgui::ProgressBar *m_pHealthBar; // health bar element
CHandle<C_BaseObject> m_pObject; // pointer to the object we represent
// Alert side panel
CBuildingStatusAlertTray *m_pAlertTray;
CIconPanel *m_pWrenchIcon;
CIconPanel *m_pSapperIcon;
// children of buildingPanel
vgui::ContinuousProgressBar *m_pBuildingProgress;
// elements that are always on
// background
CIconPanel *m_pBackground;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem_SentryGun : public CBuildingStatusItem
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem_SentryGun, CBuildingStatusItem );
public:
CBuildingStatusItem_SentryGun( Panel *parent );
virtual void OnTick( void );
virtual void PerformLayout( void );
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
virtual const char *GetBackgroundImage( void );
virtual const char *GetInactiveBackgroundImage( void );
private:
CIconPanel *m_pSentryIcons[3];
CTFLabel *m_pRocketsLabel;
CTFLabel *m_pUpgradeLabel;
CTFLabel *m_pKillsLabel;
vgui::ContinuousProgressBar *m_pShellsProgress;
vgui::ContinuousProgressBar *m_pRocketsProgress;
vgui::ContinuousProgressBar *m_pUpgradeProgress;
int m_iUpgradeLevel;
// Kills
int m_iKills;
// Ammo
bool m_bLowShells;
bool m_bLowRockets;
Color m_cLowAmmoColor;
Color m_cNormalAmmoColor;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem_Dispenser : public CBuildingStatusItem
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem_Dispenser, CBuildingStatusItem );
public:
CBuildingStatusItem_Dispenser( Panel *parent );
virtual void PerformLayout( void );
private:
// ammo
vgui::ContinuousProgressBar *m_pAmmoProgress;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem_TeleporterEntrance : public CBuildingStatusItem
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem_TeleporterEntrance, CBuildingStatusItem );
public:
CBuildingStatusItem_TeleporterEntrance( Panel *parent );
virtual void OnTick( void );
virtual void PerformLayout( void );
private:
// 2 subpanels
vgui::EditablePanel *m_pChargingPanel;
vgui::EditablePanel *m_pFullyChargedPanel;
// children of m_pChargingPanel
vgui::ContinuousProgressBar *m_pRechargeTimer;
// local state
int m_iTeleporterState;
int m_iTimesUsed;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem_TeleporterExit : public CBuildingStatusItem
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem_TeleporterExit, CBuildingStatusItem );
public:
CBuildingStatusItem_TeleporterExit( Panel *parent );
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBuildingStatusItem_Sapper : public CBuildingStatusItem
{
DECLARE_CLASS_SIMPLE( CBuildingStatusItem_Sapper, CBuildingStatusItem );
public:
CBuildingStatusItem_Sapper( Panel *parent );
virtual void PerformLayout( void );
private:
// Health of target building
vgui::ContinuousProgressBar *m_pTargetHealthBar;
// image of target building
CIconPanel *m_pTargetIcon;
int m_iTargetType;
};
//-----------------------------------------------------------------------------
// Purpose: Container panel for object status panels
//-----------------------------------------------------------------------------
class CHudBuildingStatusContainer : public CHudElement, public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CHudBuildingStatusContainer, vgui::Panel );
public:
CHudBuildingStatusContainer( const char *pElementName );
virtual bool ShouldDraw( void );
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
virtual void OnTick( void );
virtual void LevelInit( void );
void AddBuildingPanel( int iBuildingType );
CBuildingStatusItem *CreateItemPanel( int iObjectType );
void UpdateAllBuildings( void );
void OnBuildingChanged( int iBuildingType, bool bBuildingIsDead );
void RepositionObjectPanels();
void FireGameEvent( IGameEvent *event );
void RecalculateAlertState( void );
private:
// a list of CBuildingStatusItems that we're showing
CUtlPriorityQueue< CBuildingStatusItem * > m_BuildingPanels;
BuildingHudAlert_t m_AlertLevel;
float m_flNextBeep;
int m_iNumBeepsToBeep;
};
//-----------------------------------------------------------------------------
// Purpose: Separate panels for spy
//-----------------------------------------------------------------------------
class CHudBuildingStatusContainer_Spy : public CHudBuildingStatusContainer
{
DECLARE_CLASS_SIMPLE( CHudBuildingStatusContainer_Spy, CHudBuildingStatusContainer );
public:
CHudBuildingStatusContainer_Spy( const char *pElementName );
virtual bool ShouldDraw( void );
};
//-----------------------------------------------------------------------------
// Purpose: Separate panels for engineer
//-----------------------------------------------------------------------------
class CHudBuildingStatusContainer_Engineer : public CHudBuildingStatusContainer
{
DECLARE_CLASS_SIMPLE( CHudBuildingStatusContainer_Engineer, CHudBuildingStatusContainer );
public:
CHudBuildingStatusContainer_Engineer( const char *pElementName );
virtual bool ShouldDraw( void );
};
#endif //TF_HUD_BUILDING_STATUS_H