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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef TF_CONTROLS_H
#define TF_CONTROLS_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/IScheme.h>
#include <vgui/KeyCode.h>
#include <KeyValues.h>
#include <vgui/IVGui.h>
#include <vgui_controls/ScrollBar.h>
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/Label.h>
#include <vgui_controls/RichText.h>
#include "utlvector.h"
#include "vgui_controls/PHandle.h"
#include <vgui_controls/Tooltip.h>
#include "econ_controls.h"
#include "sc_hinticon.h"
#if defined( TF_CLIENT_DLL )
#include "tf_shareddefs.h"
#include "tf_imagepanel.h"
#endif
#include <vgui_controls/Frame.h>
#include <../common/GameUI/scriptobject.h>
#include <vgui/KeyCode.h>
#include <vgui_controls/Tooltip.h>
#include <vgui_controls/CheckButton.h>
wchar_t* LocalizeNumberWithToken( const char* pszLocToken, int nValue );
//-----------------------------------------------------------------------------
// Purpose: Xbox-specific panel that displays button icons text labels
//-----------------------------------------------------------------------------
class CTFFooter : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CTFFooter, vgui::EditablePanel );
public:
CTFFooter( Panel *parent, const char *panelName );
virtual ~CTFFooter();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void ApplySettings( KeyValues *pResourceData );
virtual void Paint( void );
virtual void PaintBackground( void );
void ShowButtonLabel( const char *name, bool show = true );
void AddNewButtonLabel( const char *name, const char *text, const char *icon );
void ClearButtons();
private:
struct FooterButton_t
{
bool bVisible;
char name[MAX_PATH];
wchar_t text[MAX_PATH];
wchar_t icon[3]; // icon can be one or two characters
};
CUtlVector< FooterButton_t* > m_Buttons;
bool m_bPaintBackground; // fill the background?
int m_nButtonGap; // space between buttons
int m_FooterTall; // height of the footer
int m_ButtonOffsetFromTop; // how far below the top the buttons should be drawn
int m_ButtonSeparator; // space between the button icon and text
int m_TextAdjust; // extra adjustment for the text (vertically)...text is centered on the button icon and then this value is applied
bool m_bCenterHorizontal; // center buttons horizontally?
int m_ButtonPinRight; // if not centered, this is the distance from the right margin that we use to start drawing buttons (right to left)
char m_szTextFont[64]; // font for the button text
char m_szButtonFont[64]; // font for the button icon
char m_szFGColor[64]; // foreground color (text)
char m_szBGColor[64]; // background color (fill color)
vgui::HFont m_hButtonFont;
vgui::HFont m_hTextFont;
};
//-----------------------------------------------------------------------------
// Purpose: Tooltip for the main menu. Isn't a panel, it just wraps the
// show/hide/position handling for the embedded panel.
//-----------------------------------------------------------------------------
class CMainMenuToolTip : public vgui::BaseTooltip
{
DECLARE_CLASS_SIMPLE( CMainMenuToolTip, vgui::BaseTooltip );
public:
CMainMenuToolTip(vgui::Panel *parent, const char *text = NULL) : vgui::BaseTooltip( parent, text )
{
m_pEmbeddedPanel = NULL;
}
virtual ~CMainMenuToolTip() {}
virtual void SetText(const char *text);
const char *GetText() { return NULL; }
virtual void HideTooltip();
virtual void PerformLayout();
void SetEmbeddedPanel( vgui::EditablePanel *pPanel )
{
m_pEmbeddedPanel = pPanel;
}
protected:
vgui::EditablePanel *m_pEmbeddedPanel;
};
//-----------------------------------------------------------------------------
// Purpose: Simple TF-styled text tooltip
//-----------------------------------------------------------------------------
class CTFTextToolTip : public CMainMenuToolTip
{
DECLARE_CLASS_SIMPLE( CTFTextToolTip, CMainMenuToolTip );
public:
CTFTextToolTip(vgui::Panel *parent, const char *text = NULL) : CMainMenuToolTip( parent, text )
{
}
virtual void PerformLayout();
virtual void PositionWindow( vgui::Panel *pTipPanel );
virtual void SetText(const char *text)
{
_isDirty = true;
BaseClass::SetText( text );
}
};
//-----------------------------------------------------------------------------
// Purpose: Displays a TF specific list of options
// This is essentially a TF-styled version of the GameUI Advanced Multiplayer Options Dialog
//-----------------------------------------------------------------------------
class CTFAdvancedOptionsDialog : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CTFAdvancedOptionsDialog, vgui::EditablePanel );
public:
CTFAdvancedOptionsDialog(vgui::Panel *parent);
~CTFAdvancedOptionsDialog();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void ApplySettings( KeyValues *pResourceData );
void Deploy( void );
private:
void CreateControls();
void DestroyControls();
void GatherCurrentValues();
void SaveValues();
virtual void OnCommand( const char *command );
virtual void OnClose();
virtual void OnKeyCodeTyped(vgui::KeyCode code);
virtual void OnKeyCodePressed(vgui::KeyCode code);
private:
CInfoDescription *m_pDescription;
mpcontrol_t *m_pList;
vgui::PanelListPanel *m_pListPanel;
CTFTextToolTip *m_pToolTip;
vgui::EditablePanel *m_pToolTipEmbeddedPanel;
CPanelAnimationVarAliasType( int, m_iControlW, "control_w", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iControlH, "control_h", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iSliderW, "slider_w", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iSliderH, "slider_h", "0", "proportional_int" );
};
//-----------------------------------------------------------------------------
// Purpose: Scrollable panel where you can define children within the .res file
//-----------------------------------------------------------------------------
class CExScrollingEditablePanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CExScrollingEditablePanel, vgui::EditablePanel );
public:
CExScrollingEditablePanel( Panel *pParent, const char *pszName );
virtual ~CExScrollingEditablePanel();
virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
virtual void PerformLayout() OVERRIDE;
virtual void OnSizeChanged( int newWide, int newTall ) OVERRIDE;
MESSAGE_FUNC( OnScrollBarSliderMoved, "ScrollBarSliderMoved" );
virtual void OnMouseWheeled( int delta ) OVERRIDE; // respond to mouse wheel events
void ResetScrollAmount() { m_nLastScrollValue = 0; m_pScrollBar->SetValue(0); }
protected:
void ShiftChildren( int nDistance );
vgui::ScrollBar *m_pScrollBar;
int m_nLastScrollValue;
bool m_bUseMouseWheelToScroll;
CPanelAnimationVarAliasType( int, m_iScrollStep, "scroll_step", "10", "proportional_xpos" );
CPanelAnimationVarAliasType( int, m_iBottomBuffer, "bottom_buffer", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_bRestrictWidth, "restrict_width", "1", "proportional_int" );
};
//-----------------------------------------------------------------------------
// An extension of CExScrollingEditablePanel where panels can be added to form
// a list.
//-----------------------------------------------------------------------------
class CScrollableList : public CExScrollingEditablePanel
{
DECLARE_CLASS_SIMPLE( CScrollableList, CExScrollingEditablePanel );
public:
CScrollableList( Panel* pParent, const char* pszName )
: CExScrollingEditablePanel( pParent, pszName )
{}
virtual ~CScrollableList();
virtual void PerformLayout() OVERRIDE;
void AddPanel( Panel* pPanel, int nGap );
void ClearAutoLayoutPanels();
private:
struct LayoutInfo_t
{
Panel* m_pPanel;
int m_nGap;
};
CUtlVector< LayoutInfo_t > m_vecAutoLayoutPanels;
};
//-----------------------------------------------------------------------------
// A checkbox where keyvalue data can be stored and retrieved (typically in OnCheckButtonChecked)
// so that you don't need a pointer to the checkbox in order to determine WHICH
// checkbox got checked.
//-----------------------------------------------------------------------------
class CExCheckButton : public vgui::CheckButton
{
DECLARE_CLASS_SIMPLE( CExCheckButton, vgui::CheckButton );
public:
CExCheckButton( Panel* pParent, const char* pszName )
: BaseClass( pParent, pszName, NULL )
, m_pKVData( NULL )
{}
virtual ~CExCheckButton()
{
if ( m_pKVData )
m_pKVData->deleteThis();
}
void SetData( KeyValues* pKVData )
{
if ( m_pKVData )
{
m_pKVData->deleteThis();
m_pKVData = NULL;
}
m_pKVData = pKVData;
}
KeyValues* GetData() const
{
return m_pKVData;
}
private:
KeyValues *m_pKVData;
};
class CExpandablePanel : public vgui::EditablePanel
{
DECLARE_CLASS_SIMPLE( CExpandablePanel, vgui::EditablePanel );
public:
CExpandablePanel( Panel* pParent, const char* pszName );
virtual void OnCommand( const char *command ) OVERRIDE;
virtual void OnThink() OVERRIDE;
virtual void OnToggleCollapse( bool bIsExpanded ) {}
void SetCollapsed( bool bCollapsed );
void ToggleCollapse();
bool BIsExpanded() const { return m_bExpanded; }
void SetExpandedHeight( int nNewHeight );
float GetPercentAnimated() const;
protected:
CPanelAnimationVarAliasType( float, m_flResizeTime, "resize_time", "0.4", "float" );
CPanelAnimationVarAliasType( int, m_nCollapsedHeight, "collapsed_height", "17", "proportional_int" );
CPanelAnimationVarAliasType( int, m_nExpandedHeight, "expanded_height", "50", "proportional_int" );
private:
bool m_bExpanded;
float m_flAnimEndTime;
};
#endif // TF_CONTROLS_H
|