blob: 1d8c9e9b2755520f65a41332e40740b31abe7027 (
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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Base class menus should all inherit from
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//
#include "basemenu.h"
#include "menumanager.h"
#include <ctype.h>
#include "vgui/iinput.h"
//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
CBaseMenu::CBaseMenu( vgui::Panel *pParent, const char *pPanelName ) :
BaseClass( pParent, pPanelName )
{
SetKeyBoardInputEnabled( true );
SetMouseInputEnabled( true );
SetSizeable( false );
SetMoveable( false );
}
CBaseMenu::~CBaseMenu()
{
}
void CBaseMenu::OnKeyCodeTyped( vgui::KeyCode code )
{
BaseClass::OnKeyCodeTyped( code );
bool shift = (vgui::input()->IsKeyDown(vgui::KEY_LSHIFT) || vgui::input()->IsKeyDown(vgui::KEY_RSHIFT));
bool ctrl = (vgui::input()->IsKeyDown(vgui::KEY_LCONTROL) || vgui::input()->IsKeyDown(vgui::KEY_RCONTROL));
bool alt = (vgui::input()->IsKeyDown(vgui::KEY_LALT) || vgui::input()->IsKeyDown(vgui::KEY_RALT));
if ( ctrl && shift && alt && code == vgui::KEY_B)
{
// enable build mode
ActivateBuildMode();
}
}
//-----------------------------------------------------------------------------
// Commands
//-----------------------------------------------------------------------------
void CBaseMenu::OnCommand( const char *pCommand )
{
if ( !Q_stricmp( pCommand, "quit" ) )
{
IGameManager::Stop();
return;
}
if ( !Q_stricmp( pCommand, "popmenu" ) )
{
g_pMenuManager->PopMenu();
return;
}
if ( !Q_stricmp( pCommand, "popallmenus" ) )
{
g_pMenuManager->PopAllMenus();
return;
}
if ( !Q_strnicmp( pCommand, "pushmenu ", 9 ) )
{
const char *pMenuName = pCommand + 9;
while( isspace(*pMenuName) )
{
++pMenuName;
}
g_pMenuManager->PushMenu( pMenuName );
return;
}
if ( !Q_strnicmp( pCommand, "switchmenu ", 11 ) )
{
const char *pMenuName = pCommand + 11;
while( isspace(*pMenuName) )
{
++pMenuName;
}
g_pMenuManager->SwitchToMenu( pMenuName );
return;
}
BaseClass::OnCommand( pCommand );
}
|