Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.8 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #include "gameconsoledialog.h"
  8. #include "gameui_interface.h"
  9. #include "vgui/IInput.h"
  10. #include "vgui/ISurface.h"
  11. #include "vgui/KeyCode.h"
  12. #include "IGameUIFuncs.h"
  13. #include "CegClientWrapper.h"
  14. #include "gameconsole.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. using namespace vgui;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Constructor
  20. //-----------------------------------------------------------------------------
  21. CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false )
  22. {
  23. AddActionSignalTarget( this );
  24. }
  25. //-----------------------------------------------------------------------------
  26. // Purpose: generic vgui command handler
  27. //-----------------------------------------------------------------------------
  28. void CGameConsoleDialog::OnCommand(const char *command)
  29. {
  30. if ( !Q_stricmp( command, "Close" ) )
  31. {
  32. if ( GameUI().IsInBackgroundLevel() )
  33. {
  34. // Tell the engine we've hid the console, so that it unpauses the game
  35. // even though we're still sitting at the menu.
  36. engine->ClientCmd_Unrestricted( "unpause" );
  37. }
  38. }
  39. BaseClass::OnCommand(command);
  40. }
  41. //-----------------------------------------------------------------------------
  42. // HACK: Allow F key bindings to operate even when typing in the text entry field
  43. //-----------------------------------------------------------------------------
  44. CEG_NOINLINE void CGameConsoleDialog::OnKeyCodeTyped(KeyCode code)
  45. {
  46. BaseClass::OnKeyCodeTyped(code);
  47. // check for processing
  48. if ( m_pConsolePanel->TextEntryHasFocus() )
  49. {
  50. // HACK: Allow F key bindings to operate even here
  51. if ( code >= KEY_F1 && code <= KEY_F12 )
  52. {
  53. // See if there is a binding for the FKey
  54. const char *binding = gameuifuncs->GetBindingForButtonCode( code );
  55. if ( binding && binding[0] )
  56. {
  57. // submit the entry as a console commmand
  58. char szCommand[256];
  59. Q_strncpy( szCommand, binding, sizeof( szCommand ) );
  60. engine->ClientCmd_Unrestricted( szCommand, true );
  61. }
  62. }
  63. }
  64. CEG_PROTECT_VIRTUAL_FUNCTION( CGameConsoleDialog_OnKeyCodeTyped );
  65. }
  66. //-----------------------------------------------------------------------------
  67. // Submits a command
  68. //-----------------------------------------------------------------------------
  69. void CGameConsoleDialog::OnCommandSubmitted( const char *pCommand )
  70. {
  71. engine->ClientCmd_Unrestricted( pCommand, true );
  72. }
  73. //-----------------------------------------------------------------------------
  74. // Submits a command
  75. //-----------------------------------------------------------------------------
  76. void CGameConsoleDialog::OnClosedByHittingTilde()
  77. {
  78. GameConsole().HideImmediately();
  79. }