initial
This commit is contained in:
405
game/client/cstrike15/VGUI/counterstrikeviewport.cpp
Normal file
405
game/client/cstrike15/VGUI/counterstrikeviewport.cpp
Normal file
@@ -0,0 +1,405 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client DLL VGUI2 Viewport
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "cbase.h"
|
||||
|
||||
// vgui panel includes
|
||||
#include <vgui_controls/Panel.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <keyvalues.h>
|
||||
#include <vgui/Cursor.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/IVGui.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/vgui.h>
|
||||
|
||||
// client dll/engine defines
|
||||
#include "hud.h"
|
||||
#include <voice_status.h>
|
||||
|
||||
// cstrike specific dialogs
|
||||
#include "clientmode_csnormal.h"
|
||||
#include "IGameUIFuncs.h"
|
||||
|
||||
// viewport definitions
|
||||
#include <baseviewport.h>
|
||||
#include "counterstrikeviewport.h"
|
||||
#include "cs_gamerules.h"
|
||||
// #include "c_user_message_register.h"
|
||||
#include "vguicenterprint.h"
|
||||
#include "text_message.h"
|
||||
|
||||
#include "teammenu_scaleform.h"
|
||||
#include "chooseclass_scaleform.h"
|
||||
#include "Scaleform/HUD/sfhudinfopanel.h"
|
||||
#include "Scaleform/HUD/sfhudwinpanel.h"
|
||||
#include "Scaleform/loadingscreen_scaleform.h"
|
||||
|
||||
#if defined( CSTRIKE15 )
|
||||
#include "basepanel.h"
|
||||
#endif
|
||||
|
||||
static void OpenPanelWithCheck( const char *panelToOpen, const char *panelToCheck )
|
||||
{
|
||||
IViewPortPanel *checkPanel = GetViewPortInterface()->FindPanelByName( panelToCheck );
|
||||
if ( !checkPanel || !checkPanel->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( panelToOpen, true );
|
||||
}
|
||||
}
|
||||
|
||||
void PrintBuyTimeOverMessage( void )
|
||||
{
|
||||
CHudElement *pElement = GetHud().FindElement( "SFHudInfoPanel" );
|
||||
if ( pElement )
|
||||
{
|
||||
|
||||
char strBuyTime[16];
|
||||
int nBuyTime = ( int )CSGameRules()->GetBuyTimeLength();
|
||||
Q_snprintf( strBuyTime, sizeof( strBuyTime ), "%d", nBuyTime );
|
||||
|
||||
wchar_t buffer[128];
|
||||
wchar_t buytime[16];
|
||||
g_pVGuiLocalize->ConvertANSIToUnicode( strBuyTime, buytime, sizeof( buytime ) );
|
||||
|
||||
if ( nBuyTime == 0 )
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof( buffer ), g_pVGuiLocalize->Find( "#SFUI_BuyMenu_YoureOutOfTime" ), 0 );
|
||||
else
|
||||
g_pVGuiLocalize->ConstructString( buffer, sizeof( buffer ), g_pVGuiLocalize->Find( "#SFUI_BuyMenu_OutOfTime" ), 1, buytime );
|
||||
|
||||
((SFHudInfoPanel *)pElement)->SetPriorityText( buffer );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CON_COMMAND_F( teammenu, "Show team selection window", FCVAR_SERVER_CAN_EXECUTE )
|
||||
{
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if( pPlayer && pPlayer->CanShowTeamMenu() )
|
||||
{
|
||||
( ( CounterStrikeViewport * )GetViewPortInterface() )->SetChoseTeamAndClass( true );
|
||||
GetViewPortInterface()->ShowPanel( PANEL_TEAM, true );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CON_COMMAND_F( buymenu, "Show or hide main buy menu", FCVAR_SERVER_CAN_EXECUTE )
|
||||
{
|
||||
bool bShowIt = true;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( args.ArgC() == 2 )
|
||||
{
|
||||
bShowIt = atoi( args[ 1 ] ) == 1;
|
||||
}
|
||||
|
||||
if( pPlayer && bShowIt )
|
||||
{
|
||||
if ( pPlayer->m_lifeState != LIFE_ALIVE && pPlayer->State_Get() != STATE_ACTIVE )
|
||||
return;
|
||||
|
||||
extern ConVar mp_buy_anywhere;
|
||||
extern ConVar mp_buy_during_immunity;
|
||||
static ConVarRef sv_buy_status_override_ref( "sv_buy_status_override" );
|
||||
// UNUSED: int nGuardianTeam = CSGameRules()->IsHostageRescueMap() ? TEAM_TERRORIST : TEAM_CT;
|
||||
|
||||
if ( CSGameRules()->IsPlayingCooperativeGametype() )
|
||||
{
|
||||
if ( CSGameRules()->IsWarmupPeriod() == false &&
|
||||
CSGameRules()->m_flGuardianBuyUntilTime < gpGlobals->curtime )
|
||||
{
|
||||
int nTeam = CSGameRules()->IsHostageRescueMap() ? TEAM_TERRORIST : TEAM_CT;
|
||||
int iBuyStatus = sv_buy_status_override_ref.GetInt();
|
||||
if ( iBuyStatus > 0 && (( nTeam == TEAM_CT && iBuyStatus != 1 ) || ( nTeam == TEAM_TERRORIST && iBuyStatus != 2 )) )
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuy" );
|
||||
else
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuyTilNextWave" );
|
||||
}
|
||||
else
|
||||
{
|
||||
CSGameRules()->OpenBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
}
|
||||
else if ( CSGameRules()->IsPlayingCoopMission() && sv_buy_status_override_ref.GetInt() == 3 )
|
||||
{
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_CantBuy" );
|
||||
}
|
||||
else if ( !pPlayer->IsInBuyPeriod() )
|
||||
{
|
||||
PrintBuyTimeOverMessage();
|
||||
}
|
||||
else if ( !pPlayer->IsInBuyZone() )
|
||||
{
|
||||
GetCenterPrint()->Print( "#SFUI_BuyMenu_NotInBuyZone" );
|
||||
}
|
||||
else
|
||||
{
|
||||
CSGameRules()->OpenBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
}
|
||||
else if( pPlayer && !bShowIt )
|
||||
{
|
||||
// Hide the menu
|
||||
CSGameRules()->CloseBuyMenu( pPlayer->GetUserID() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//CON_COMMAND_F( spec_help, "Show spectator help screen", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
//{
|
||||
// if ( GetViewPortInterface() )
|
||||
// GetViewPortInterface()->ShowPanel( PANEL_INFO, true );
|
||||
//}
|
||||
|
||||
CON_COMMAND_F( spec_menu, "Activates spectator menu", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
bool bShowIt = true;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer && !pPlayer->IsObserver() )
|
||||
return;
|
||||
|
||||
if ( args.ArgC() == 2 )
|
||||
{
|
||||
bShowIt = atoi( args[ 1 ] ) == 1;
|
||||
}
|
||||
|
||||
if ( GetViewPortInterface() )
|
||||
GetViewPortInterface()->ShowPanel( PANEL_SPECMENU, bShowIt );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( spec_gui, "Shows or hides the spectator bar", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
bool bShowIt = true;
|
||||
|
||||
C_CSPlayer *pPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
if ( pPlayer && !pPlayer->IsObserver() )
|
||||
return;
|
||||
|
||||
if ( args.ArgC() == 2 )
|
||||
{
|
||||
bShowIt = atoi( args[ 1 ] ) == 1;
|
||||
}
|
||||
|
||||
if ( bShowIt && GetViewPortInterface() && GetViewPortInterface()->GetActivePanel() )
|
||||
{
|
||||
// if the team screen is up, it takes precedence - don't show the spectator GUI
|
||||
if ( !V_strcmp( GetViewPortInterface()->GetActivePanel()->GetName(), PANEL_TEAM ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( GetViewPortInterface() )
|
||||
GetViewPortInterface()->ShowPanel( PANEL_SPECGUI, bShowIt );
|
||||
}
|
||||
|
||||
CON_COMMAND_F( togglescores, "Toggles score panel", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !GetViewPortInterface() )
|
||||
return;
|
||||
|
||||
IViewPortPanel *scoreboard = GetViewPortInterface()->FindPanelByName( PANEL_SCOREBOARD );
|
||||
|
||||
if ( !scoreboard )
|
||||
return;
|
||||
|
||||
if ( scoreboard->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, false );
|
||||
GetClientVoiceMgr()->StopSquelchMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Disallow bringing the Scoreboard up while we are paused
|
||||
if ( BasePanel() && BasePanel()->IsScaleformPauseMenuActive() )
|
||||
return;
|
||||
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, true );
|
||||
}
|
||||
}
|
||||
|
||||
CON_COMMAND_F( hidescores, "Forcibly hide score panel", FCVAR_CLIENTCMD_CAN_EXECUTE )
|
||||
{
|
||||
if ( !GetViewPortInterface() )
|
||||
return;
|
||||
|
||||
IViewPortPanel *scoreboard = GetViewPortInterface()->FindPanelByName( PANEL_SCOREBOARD );
|
||||
|
||||
if ( !scoreboard )
|
||||
return;
|
||||
|
||||
if ( scoreboard->IsVisible() )
|
||||
{
|
||||
GetViewPortInterface()->ShowPanel( scoreboard, false );
|
||||
GetClientVoiceMgr()->StopSquelchMode();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: called when the VGUI subsystem starts up
|
||||
// Creates the sub panels and initialises them
|
||||
//-----------------------------------------------------------------------------
|
||||
void CounterStrikeViewport::Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager )
|
||||
{
|
||||
BaseClass::Start( pGameUIFuncs, pGameEventManager );
|
||||
SetChoseTeamAndClass( false );
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
ListenForGameEvent( "cs_win_panel_match" );
|
||||
|
||||
GetHud().InitColors( pScheme );
|
||||
|
||||
SetPaintBackgroundEnabled( false );
|
||||
}
|
||||
|
||||
|
||||
IViewPortPanel* CounterStrikeViewport::CreatePanelByName( const char *szPanelName )
|
||||
{
|
||||
IViewPortPanel* newpanel = NULL;
|
||||
|
||||
// overwrite MOD specific panel creation
|
||||
|
||||
if ( Q_strcmp( PANEL_TEAM, szPanelName ) == 0 )
|
||||
{
|
||||
newpanel = new CCSTeamMenuScaleform( this );
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// create a generic base panel, don't add twice
|
||||
newpanel = BaseClass::CreatePanelByName( szPanelName );
|
||||
}
|
||||
|
||||
return newpanel;
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::CreateDefaultPanels( void )
|
||||
{
|
||||
AddNewPanel( CreatePanelByName( PANEL_TEAM ), "PANEL_TEAM" );
|
||||
|
||||
AddNewPanel( CreatePanelByName( PANEL_BUY ), "PANEL_BUY" );
|
||||
|
||||
BaseClass::CreateDefaultPanels();
|
||||
}
|
||||
|
||||
int CounterStrikeViewport::GetDeathMessageStartHeight( void )
|
||||
{
|
||||
int x = YRES( 2 );
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::FireGameEvent( IGameEvent * event )
|
||||
{
|
||||
const char * type = event->GetName();
|
||||
|
||||
if ( Q_strcmp( type, "game_newmap" ) == 0 || Q_strcmp( type, "cs_win_panel_match" ) == 0 )
|
||||
{
|
||||
SetChoseTeamAndClass( false );
|
||||
}
|
||||
|
||||
BaseClass::FireGameEvent( event );
|
||||
}
|
||||
|
||||
void CounterStrikeViewport::UpdateAllPanels( void )
|
||||
{
|
||||
bool bSomethingIsVisible = false;
|
||||
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( vgui::ipanel()->GetMessageContextId( GetVPanel() ) );
|
||||
|
||||
for ( int i = 0; i < m_UnorderedPanels.Count(); ++i )
|
||||
{
|
||||
IViewPortPanel *p = m_UnorderedPanels[i];
|
||||
|
||||
if ( p->IsVisible() )
|
||||
{
|
||||
bSomethingIsVisible = true;
|
||||
p->Update();
|
||||
if ( m_pActivePanel == NULL )
|
||||
{
|
||||
// if a visible panel exists, then there should be an activePanel.
|
||||
m_pActivePanel = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// see if we need to show a special ui instead of the hud
|
||||
// [jason] Do not rearrange viewport panels while the Pause menu is opened - it takes precedence over all viewports
|
||||
if ( !bSomethingIsVisible && !BasePanel()->IsScaleformPauseMenuActive() )
|
||||
{
|
||||
C_CSPlayer *pCSPlayer = C_CSPlayer::GetLocalCSPlayer();
|
||||
|
||||
const char* UIToShow = NULL;
|
||||
|
||||
if ( !pCSPlayer )
|
||||
{
|
||||
UIToShow = PANEL_SPECGUI;
|
||||
}
|
||||
else if ( pCSPlayer->GetObserverMode() != OBS_MODE_NONE )
|
||||
{
|
||||
if ( pCSPlayer->State_Get() != STATE_PICKINGTEAM && ( pCSPlayer->GetTeamNumber() == TEAM_UNASSIGNED ) && !pCSPlayer->IsHLTV() )
|
||||
{
|
||||
// not a member of a team and not a spectator. show the team select screen.
|
||||
if ( !CLoadingScreenScaleform::IsOpen() &&
|
||||
( (GetActivePanel() && !V_strcmp( GetActivePanel()->GetName(), PANEL_TEAM )) || !GetActivePanel() ) )
|
||||
{
|
||||
// don't show the team panel if the team panel is already up
|
||||
UIToShow = PANEL_TEAM;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SFHudWinPanel * pWinPanel = GET_HUDELEMENT( SFHudWinPanel );
|
||||
if ( pWinPanel && !pWinPanel->IsVisible() )
|
||||
{
|
||||
UIToShow = PANEL_SPECGUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( UIToShow )
|
||||
{
|
||||
ShowPanel( UIToShow, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==========================
|
||||
HUD_ChatInputPosition
|
||||
|
||||
Sets the location of the input for chat text
|
||||
==========================
|
||||
*/
|
||||
//MIKETODO: positioning of chat text ( and other engine output )
|
||||
/*
|
||||
#include "Exports.h"
|
||||
|
||||
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y )
|
||||
{
|
||||
RecClChatInputPosition( x, y );
|
||||
if ( GetViewPortInterface() )
|
||||
{
|
||||
GetViewPortInterface()->ChatInputPosition( x, y );
|
||||
}
|
||||
}
|
||||
|
||||
EXPOSE_SINGLE_INTERFACE( CounterStrikeViewport, IClientVGUI, CLIENTVGUI_INTERFACE_VERSION );
|
||||
*/
|
||||
86
game/client/cstrike15/VGUI/counterstrikeviewport.h
Normal file
86
game/client/cstrike15/VGUI/counterstrikeviewport.h
Normal file
@@ -0,0 +1,86 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef COUNTERSTRIKEVIEWPORT_H
|
||||
#define COUNTERSTRIKEVIEWPORT_H
|
||||
|
||||
#include "cs_shareddefs.h"
|
||||
#include "baseviewport.h"
|
||||
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Panel;
|
||||
class Label;
|
||||
class CBitmapImagePanel;
|
||||
}
|
||||
|
||||
class CCSTeamMenu;
|
||||
class CCSClassMenu;
|
||||
class CCSSpectatorGUI;
|
||||
class CCSClientScoreBoard;
|
||||
class CBuyMenu;
|
||||
class CCSClientScoreBoardDialog;
|
||||
|
||||
void PrintBuyTimeOverMessage( void );
|
||||
|
||||
//==============================================================================
|
||||
class CounterStrikeViewport : public CBaseViewport
|
||||
{
|
||||
|
||||
private:
|
||||
DECLARE_CLASS_SIMPLE( CounterStrikeViewport, CBaseViewport );
|
||||
|
||||
public:
|
||||
|
||||
IViewPortPanel* CreatePanelByName( const char *szPanelName );
|
||||
void CreateDefaultPanels( void );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Start( IGameUIFuncs *pGameUIFuncs, IGameEventManager2 * pGameEventManager );
|
||||
|
||||
int GetDeathMessageStartHeight( void );
|
||||
|
||||
virtual void ShowBackGround( bool bShow )
|
||||
{
|
||||
m_pBackGround->SetVisible( false ); // CS:S menus paint their own backgrounds...
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [mhansen] We want to let the team screen know if this is the first time
|
||||
// we chose a team so we can decide what the "back" action is
|
||||
//=============================================================================
|
||||
bool GetChoseTeamAndClass() { return m_bChoseTeamAndClass; }
|
||||
void SetChoseTeamAndClass( bool chose ) { m_bChoseTeamAndClass = chose; }
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
virtual void FireGameEvent( IGameEvent * event );
|
||||
|
||||
virtual void UpdateAllPanels( void );
|
||||
|
||||
|
||||
|
||||
private:
|
||||
void CenterWindow( vgui::Frame *win );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [mhansen] We want to let the team screen know if this is the first time
|
||||
// we chose a team so we can decide what the "back" action is
|
||||
//=============================================================================
|
||||
bool m_bChoseTeamAndClass;
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
};
|
||||
|
||||
|
||||
#endif // COUNTERSTRIKEVIEWPORT_H
|
||||
398
game/client/cstrike15/VGUI/cstrikeloadout.h
Normal file
398
game/client/cstrike15/VGUI/cstrikeloadout.h
Normal file
@@ -0,0 +1,398 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CSLOADOUT_H
|
||||
#define CSLOADOUT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
const int cMaxEquipment = 6; // if this # changes, bump version # cl_titledataversionblock3 and loadoutData in TitleData1 block for title data storageCCSSteamStats::SyncCSLoadoutsToTitleData
|
||||
const int cMaxLoadouts = 4; // if this # changes, bump version # cl_titledataversionblock3 and loadoutData in TitleData1 block for title data storageCCSSteamStats::SyncCSLoadoutsToTitleData
|
||||
|
||||
class CCSEquipmentLoadout
|
||||
{
|
||||
public:
|
||||
CCSEquipmentLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
SetEquipmentID( WEAPON_NONE );
|
||||
}
|
||||
|
||||
CCSEquipmentLoadout& operator=( const CCSEquipmentLoadout& in_rhs )
|
||||
{
|
||||
m_EquipmentID = in_rhs.m_EquipmentID;
|
||||
m_EquipmentPos = in_rhs.m_EquipmentPos;
|
||||
m_Quantity = in_rhs.m_Quantity;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
return ( ( GetEquipmentID() == WEAPON_NONE ) || ( GetQuantity() == 0 ) );
|
||||
}
|
||||
|
||||
CSWeaponID GetEquipmentID() const
|
||||
{
|
||||
return m_EquipmentID;
|
||||
}
|
||||
|
||||
void SetEquipmentID( CSWeaponID newid )
|
||||
{
|
||||
m_EquipmentID = newid;
|
||||
|
||||
if ( newid == WEAPON_NONE )
|
||||
{
|
||||
m_Quantity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int GetEquipmentPos() const
|
||||
{
|
||||
return m_EquipmentPos;
|
||||
}
|
||||
|
||||
void SetEquipmentPos( int pos )
|
||||
{
|
||||
m_EquipmentPos = pos;
|
||||
}
|
||||
|
||||
int GetQuantity() const
|
||||
{
|
||||
return m_Quantity;
|
||||
}
|
||||
|
||||
void SetQuantity( int value )
|
||||
{
|
||||
m_Quantity = value;
|
||||
|
||||
if ( !m_Quantity )
|
||||
{
|
||||
m_EquipmentID = WEAPON_NONE;
|
||||
m_EquipmentPos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSWeaponID m_EquipmentID;
|
||||
int m_EquipmentPos;
|
||||
int m_Quantity;
|
||||
|
||||
};
|
||||
|
||||
inline const bool operator==( const CCSEquipmentLoadout& me, const CCSEquipmentLoadout& them )
|
||||
{
|
||||
return ( ( me.GetEquipmentID() == them.GetEquipmentID() ) && ( me.GetQuantity() == them.GetQuantity() ) );
|
||||
}
|
||||
|
||||
inline const bool operator!=( const CCSEquipmentLoadout& me, const CCSEquipmentLoadout& them )
|
||||
{
|
||||
return !( me == them );
|
||||
}
|
||||
|
||||
class CCSLoadout
|
||||
{
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
HAS_TASER = 0x1,
|
||||
HAS_BOMB = 0x2,
|
||||
HAS_DEFUSE = 0x4,
|
||||
};
|
||||
|
||||
bool GetFlag( uint8 flag ) const
|
||||
{
|
||||
return ( m_flags & flag ) != 0;
|
||||
}
|
||||
|
||||
void SetFlag( uint8 flag, bool setIt )
|
||||
{
|
||||
m_flags &= ~flag;
|
||||
if ( setIt )
|
||||
m_flags |= flag;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
CCSLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
m_primaryWeaponID = WEAPON_NONE;
|
||||
m_secondaryWeaponID = WEAPON_NONE;
|
||||
m_primaryWeaponItemPos = 0;
|
||||
m_secondaryWeaponItemPos = 0;
|
||||
m_flags = 0;
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
m_EquipmentArray[i].ClearLoadout();
|
||||
}
|
||||
}
|
||||
|
||||
CCSLoadout& operator=( const CCSLoadout& in_rhs )
|
||||
{
|
||||
m_primaryWeaponID = in_rhs.m_primaryWeaponID;
|
||||
m_secondaryWeaponID = in_rhs.m_secondaryWeaponID;
|
||||
m_primaryWeaponItemPos = in_rhs.m_primaryWeaponItemPos;
|
||||
m_secondaryWeaponItemPos = in_rhs.m_secondaryWeaponItemPos;
|
||||
m_flags = in_rhs.m_flags;
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
m_EquipmentArray[i] = in_rhs.m_EquipmentArray[i];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const CCSLoadout& in_rhs ) const
|
||||
{
|
||||
if ( m_primaryWeaponID != in_rhs.m_primaryWeaponID )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_secondaryWeaponID != in_rhs.m_secondaryWeaponID )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_flags != in_rhs.m_flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( m_EquipmentArray[i].GetEquipmentID() != WEAPON_NONE )
|
||||
{
|
||||
bool bMatch = false;
|
||||
for ( int j = 0; j < cMaxEquipment; j++ )
|
||||
{
|
||||
if ( in_rhs.m_EquipmentArray[j] == m_EquipmentArray[i] )
|
||||
bMatch = true;
|
||||
}
|
||||
|
||||
if ( bMatch == false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( in_rhs.m_EquipmentArray[i].GetEquipmentID() != WEAPON_NONE )
|
||||
{
|
||||
bool bMatch = false;
|
||||
for ( int j = 0; j < cMaxEquipment; j++ )
|
||||
{
|
||||
if ( m_EquipmentArray[j] == in_rhs.m_EquipmentArray[i] )
|
||||
bMatch = true;
|
||||
}
|
||||
|
||||
if ( bMatch == false )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=( const CCSLoadout& in_rhs ) const
|
||||
{
|
||||
return !( *this == in_rhs );
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
{
|
||||
if ( m_primaryWeaponID != WEAPON_NONE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_secondaryWeaponID != WEAPON_NONE )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < cMaxEquipment; i++ )
|
||||
{
|
||||
if ( !m_EquipmentArray[i].isEmpty() )
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( m_flags )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CountUniqueEquipment( void ) const
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
for ( result = 0; result < cMaxEquipment; result++ )
|
||||
{
|
||||
if ( m_EquipmentArray[result].isEmpty() )
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool GetHasTaser( void ) const
|
||||
{
|
||||
return GetFlag( HAS_TASER );
|
||||
}
|
||||
|
||||
void SetHasTaser( bool value )
|
||||
{
|
||||
SetFlag( HAS_TASER, value );
|
||||
}
|
||||
|
||||
bool GetHasBomb( void ) const
|
||||
{
|
||||
return GetFlag( HAS_BOMB );
|
||||
}
|
||||
|
||||
void SetHasBomb( bool value )
|
||||
{
|
||||
SetFlag( HAS_BOMB, value );
|
||||
}
|
||||
|
||||
bool GetHasDefuser( void ) const
|
||||
{
|
||||
return GetFlag( HAS_DEFUSE );
|
||||
}
|
||||
|
||||
void SetHasDefuser( bool value )
|
||||
{
|
||||
SetFlag( HAS_DEFUSE, value );
|
||||
}
|
||||
|
||||
CSWeaponID ReportFirstWeapon( void )
|
||||
{
|
||||
if ( m_primaryWeaponID )
|
||||
return m_primaryWeaponID;
|
||||
else if ( m_secondaryWeaponID )
|
||||
return m_secondaryWeaponID;
|
||||
else if ( GetHasTaser() )
|
||||
return WEAPON_TASER;
|
||||
else
|
||||
return m_EquipmentArray[0].GetEquipmentID();
|
||||
}
|
||||
|
||||
// Data fields
|
||||
CSWeaponID m_primaryWeaponID;
|
||||
CSWeaponID m_secondaryWeaponID;
|
||||
int m_primaryWeaponItemPos;
|
||||
int m_secondaryWeaponItemPos;
|
||||
CCSEquipmentLoadout m_EquipmentArray[cMaxEquipment];
|
||||
uint8 m_flags;
|
||||
};
|
||||
|
||||
class CCSBuyMenuLoadout
|
||||
{
|
||||
|
||||
public:
|
||||
CCSBuyMenuLoadout()
|
||||
{
|
||||
ClearLoadout();
|
||||
}
|
||||
|
||||
void ClearLoadout( void )
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
m_WeaponID[ i ] = WEAPON_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
CCSBuyMenuLoadout& operator=( const CCSBuyMenuLoadout& in_rhs )
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
m_WeaponID[ i ] = in_rhs.m_WeaponID[ i ];
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==( const CCSBuyMenuLoadout& in_rhs ) const
|
||||
{
|
||||
for ( int i = 0; i < ARRAYSIZE( m_WeaponID ); i++ )
|
||||
{
|
||||
if ( m_WeaponID[ i ] != in_rhs.m_WeaponID[ i ] )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool operator!=( const CCSBuyMenuLoadout& in_rhs ) const
|
||||
{
|
||||
return !( *this == in_rhs );
|
||||
}
|
||||
|
||||
CEconItemView * GetWeaponView( loadout_positions_t pos, int nTeamNumber ) const;
|
||||
|
||||
// Data fields
|
||||
itemid_t m_WeaponID[ LOADOUT_POSITION_COUNT ];
|
||||
};
|
||||
|
||||
inline CEconItemView * CCSBuyMenuLoadout::GetWeaponView( loadout_positions_t pos, int nTeamNumber ) const
|
||||
{
|
||||
int nPos = pos;
|
||||
|
||||
|
||||
if ( ( nPos < 0 ) || ( nPos >= LOADOUT_POSITION_COUNT ) )
|
||||
return NULL;
|
||||
|
||||
if ( !CSInventoryManager() || !CSInventoryManager()->GetLocalCSInventory() )
|
||||
return NULL;
|
||||
|
||||
if ( m_WeaponID[ nPos ] == INVALID_ITEM_ID )
|
||||
return NULL;
|
||||
|
||||
CEconItemView * pItemView = CSInventoryManager()->GetLocalCSInventory()->GetInventoryItemByItemID( m_WeaponID[ nPos ] );
|
||||
|
||||
if ( pItemView && pItemView->IsValid() )
|
||||
{
|
||||
return pItemView;
|
||||
}
|
||||
else if ( CombinedItemIdIsDefIndexAndPaint( m_WeaponID[ nPos ] ) )
|
||||
{
|
||||
return CSInventoryManager()->FindOrCreateReferenceEconItem( m_WeaponID[ nPos ] );
|
||||
}
|
||||
else if ( CEconItemView * pItemView = CSInventoryManager()->GetItemInLoadoutForTeam( nTeamNumber, nPos ) )
|
||||
{
|
||||
return pItemView;
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern CCSLoadout* GetBuyMenuLoadoutData( int in_teamID );
|
||||
|
||||
#endif //CSLOADOUT_H
|
||||
Reference in New Issue
Block a user