diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /app/legion/basemenu.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'app/legion/basemenu.cpp')
| -rw-r--r-- | app/legion/basemenu.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/app/legion/basemenu.cpp b/app/legion/basemenu.cpp new file mode 100644 index 0000000..1d8c9e9 --- /dev/null +++ b/app/legion/basemenu.cpp @@ -0,0 +1,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 ); +} + |