forked from nillerusr/source-engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGameConsoleDialog.cpp
More file actions
101 lines (86 loc) · 2.91 KB
/
GameConsoleDialog.cpp
File metadata and controls
101 lines (86 loc) · 2.91 KB
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#include "GameConsoleDialog.h"
#include "GameUI_Interface.h"
#include "vgui/IInput.h"
#include "vgui/ISurface.h"
#include "vgui/KeyCode.h"
#include "LoadingDialog.h"
#include "IGameUIFuncs.h"
#include "tier0/icommandline.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false )
{
if( NeedProportional() ) SetProportional(true);
AddActionSignalTarget( this );
}
//-----------------------------------------------------------------------------
// Purpose: generic vgui command handler
//-----------------------------------------------------------------------------
void CGameConsoleDialog::OnCommand(const char *command)
{
if ( !Q_stricmp( command, "Close" ) )
{
if ( GameUI().IsInBackgroundLevel() )
{
// Tell the engine we've hid the console, so that it unpauses the game
// even though we're still sitting at the menu.
engine->ClientCmd_Unrestricted( "unpause" );
}
}
BaseClass::OnCommand(command);
}
//-----------------------------------------------------------------------------
// HACK: Allow F key bindings to operate even when typing in the text entry field
//-----------------------------------------------------------------------------
void CGameConsoleDialog::OnKeyCodeTyped(KeyCode code)
{
BaseClass::OnKeyCodeTyped(code);
// check for processing
if ( m_pConsolePanel->TextEntryHasFocus() )
{
// HACK: Allow F key bindings to operate even here
if ( code >= KEY_F1 && code <= KEY_F12 )
{
// See if there is a binding for the FKey
const char *binding = gameuifuncs->GetBindingForButtonCode( code );
if ( binding && binding[0] )
{
// submit the entry as a console commmand
char szCommand[256];
Q_strncpy( szCommand, binding, sizeof( szCommand ) );
engine->ClientCmd_Unrestricted( szCommand );
}
}
}
}
//-----------------------------------------------------------------------------
// Submits a command
//-----------------------------------------------------------------------------
void CGameConsoleDialog::OnCommandSubmitted( const char *pCommand )
{
engine->ClientCmd_Unrestricted( pCommand );
}
//-----------------------------------------------------------------------------
// Submits a command
//-----------------------------------------------------------------------------
void CGameConsoleDialog::OnClosedByHittingTilde()
{
if ( !LoadingDialog() )
{
GameUI().HideGameUI();
}
else
{
vgui::surface()->RestrictPaintToSinglePanel( LoadingDialog()->GetVPanel() );
}
}