summaryrefslogtreecommitdiff
path: root/game/client/tf/vgui/class_loadout_panel.h
blob: 894b0e6629911c2a1281eab81fa1450711bd654f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef CLASS_LOADOUT_PANEL_H
#define CLASS_LOADOUT_PANEL_H
#ifdef _WIN32
#pragma once
#endif

#include "base_loadout_panel.h"
#include "tf_playermodelpanel.h"
#include "item_selection_panel.h"
#include <../common/GameUI/cvarslider.h>
#include <vgui/VGUI.h>
#include "vgui_controls/CheckButton.h"

#define NUM_ITEM_PANELS_IN_LOADOUT		CLASS_LOADOUT_POSITION_COUNT

class CLoadoutPresetPanel;

class CLoadoutItemOptionsPanel : public vgui::EditablePanel
{
	DECLARE_CLASS_SIMPLE( CLoadoutItemOptionsPanel, vgui::EditablePanel );
public:
	CLoadoutItemOptionsPanel( Panel *parent, const char *pName );
	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual void PerformLayout( void );

	virtual void OnCommand( const char *command );
	virtual void OnMessage( const KeyValues* pParams, vgui::VPANEL hFromPanel );

	void SetItemSlot( loadout_positions_t eItemSlot, int iClassIndex );
	loadout_positions_t GetItemSlot() const { return m_eItemSlot; }
	void UpdateItemOptionsUI();

private:

	void AddControlsParticleEffect( void ) const;
	void AddControlsSetStyle( void ) const;
	CEconItemView* GetItem( void ) const;

	class vgui::PanelListPanel	*m_pListPanel;
	CCvarSlider					*m_pHatParticleSlider;
	CExButton					*m_pSetStyleButton;
	vgui::CheckButton			*m_pHatParticleUseHeadButton;

	int						m_iCurrentClassIndex;
	loadout_positions_t		m_eItemSlot;
};


//-----------------------------------------------------------------------------
// A loadout screen that handles modifying the loadout of a specific class
//-----------------------------------------------------------------------------
class CClassLoadoutPanel : public CBaseLoadoutPanel
{
	DECLARE_CLASS_SIMPLE( CClassLoadoutPanel, CBaseLoadoutPanel );
public:
	CClassLoadoutPanel( vgui::Panel *parent );
	~CClassLoadoutPanel();

	virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
	virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
	virtual void PerformLayout( void );
	virtual void FireGameEvent( IGameEvent *event );

	virtual void AddNewItemPanel( int iPanelIndex ) OVERRIDE;
	virtual void UpdateModelPanels( void );
	virtual int	 GetNumItemPanels( void ) { return NUM_ITEM_PANELS_IN_LOADOUT; };
	virtual void OnShowPanel( bool bVisible, bool bReturningFromArmory );
	virtual void PostShowPanel( bool bVisible );
	virtual void OnKeyCodePressed( vgui::KeyCode code ) OVERRIDE;
	virtual void OnNavigateTo( const char* panelName ) OVERRIDE;
	virtual void OnNavigateFrom( const char* panelName ) OVERRIDE;

	void		 SetClass( int iClass );
	void		 SetTeam( int iTeam );

	int			 GetNumRelevantSlots() const;
	CEconItemView	*GetItemInSlot( int iSlot );

	MESSAGE_FUNC_PTR( OnItemPanelMouseReleased, "ItemPanelMouseReleased", panel );
	MESSAGE_FUNC_PARAMS( OnSelectionReturned, "SelectionReturned", data );
	MESSAGE_FUNC( OnCancelSelection, "CancelSelection" );
	MESSAGE_FUNC( OnClosing, "Closing" );
	virtual void OnCommand( const char *command );
	virtual void OnMessage( const KeyValues* pParams, vgui::VPANEL hFromPanel );

	void		SetSelectionPanel( CEquipSlotItemSelectionPanel *pPanel ) { m_pSelectionPanel = pPanel; }
	void		UpdatePassiveAttributes( void );

	bool		IsInSelectionPanel() const	{ return m_pSelectionPanel != NULL; }
	CEquipSlotItemSelectionPanel	*GetItemSelectionPanel() { return m_pSelectionPanel; }

	bool		IsEditingTauntSlots() const { return m_bInTauntLoadoutMode; }

	enum classloadoutpage_t
	{
		CHARACTER_LOADOUT_PAGE,
		TAUNT_LOADOUT_PAGE
	};
	void			SetLoadoutPage( classloadoutpage_t loadoutPage );

protected:
	virtual void	SetBorderForItem( CItemModelPanel *pItemPanel, bool bMouseOver );
	void			AddAttribPassiveText( const class CEconAttributeDescription& AttrDesc, INOUT_Z_CAP(iNumPassiveChars) wchar_t *out_wszPassiveDesc, int iNumPassiveChars );
	void			RespawnPlayer();
	virtual void	ApplyKVsToItemPanels( void ) OVERRIDE;
	void			ClearItemOptionsMenu( void );
	void			SetOptionsButtonText( int nIndex, const char* pszText );
	static bool		AnyOptionsAvailableForItem( const CEconItemView *pItem );

	int						m_iCurrentClassIndex;
	int						m_iCurrentTeamIndex;
	int						m_iCurrentSlotIndex;
	bool					m_bLoadoutHasChanged;
	bool					m_bInTauntLoadoutMode;
	CTFPlayerModelPanel		*m_pPlayerModelPanel;
	CEquipSlotItemSelectionPanel	*m_pSelectionPanel;
	vgui::Label				*m_pTauntHintLabel;
	CExLabel				*m_pTauntLabel;
	CExLabel				*m_pTauntCaratLabel;
	CExLabel				*m_pPassiveAttribsLabel;
	Panel					*m_pTopLinePanel;

	CExButton				*m_pBuildablesButton;
	CExImageButton			*m_pCharacterLoadoutButton;
	CExImageButton			*m_pTauntLoadoutButton;

	CLoadoutPresetPanel		*m_pLoadoutPresetPanel;

	CExplanationPopup		*m_pPresetsExplanationPopup;
	CExplanationPopup		*m_pTauntsExplanationPopup;

	KeyValues				*m_pItemOptionPanelKVs;
	CUtlVector< CExButton * > m_vecItemOptionButtons;
	CLoadoutItemOptionsPanel *m_pItemOptionPanel;

private:
	void UpdatePageButtonColor( CExImageButton *pPageButton, bool bIsActive );

	enum PageButtonColors_t
	{
		LOADED = 0, NOTLOADED,
		FG = 0, BG,
		DEFAULT = 0, ARMED, DEPRESSED
	};
	Color					m_aDefaultColors[2][2][3];	// [LOADED|NOTLOADED][FG|BG][DEFAULT|ARMED|DEPRESSED]
};

extern CClassLoadoutPanel *g_pClassLoadoutPanel;

#endif // CLASS_LOADOUT_PANEL_H