Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
FluorescentCIAAfricanAmerican committed Apr 22, 2020
0 parents commit 3bf9df6
Show file tree
Hide file tree
Showing 15,370 changed files with 5,489,726 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
95 changes: 95 additions & 0 deletions app/legion/basemenu.cpp
Original file line number Diff line number Diff line change
@@ -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 );
}

39 changes: 39 additions & 0 deletions app/legion/basemenu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Base class menus should all inherit from
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//

#ifndef BASEMENU_H
#define BASEMENU_H

#ifdef _WIN32
#pragma once
#endif

#include "vgui_controls/frame.h"
#include "vgui/keycode.h"


//-----------------------------------------------------------------------------
// Constructor, destructor
//-----------------------------------------------------------------------------
class CBaseMenu : public vgui::Frame
{
DECLARE_CLASS_SIMPLE( CBaseMenu, vgui::Frame );

public:
CBaseMenu( vgui::Panel *pParent, const char *pPanelName );
virtual ~CBaseMenu();

// Commands
virtual void OnCommand( const char *pCommand );
virtual void OnKeyCodeTyped( vgui::KeyCode code );

private:
};

#endif // BASEMENU_H

Loading

0 comments on commit 3bf9df6

Please sign in to comment.