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.

99 lines
2.9 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 "LoadingDialog.h"
  13. #include "igameuifuncs.h"
  14. // memdbgon must be the last include file in a .cpp file!!!
  15. #include "tier0/memdbgon.h"
  16. using namespace vgui;
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Constructor
  19. //-----------------------------------------------------------------------------
  20. CGameConsoleDialog::CGameConsoleDialog() : BaseClass( NULL, "GameConsole", false )
  21. {
  22. AddActionSignalTarget( this );
  23. }
  24. //-----------------------------------------------------------------------------
  25. // Purpose: generic vgui command handler
  26. //-----------------------------------------------------------------------------
  27. void CGameConsoleDialog::OnCommand(const char *command)
  28. {
  29. if ( !Q_stricmp( command, "Close" ) )
  30. {
  31. if ( GameUI().IsInBackgroundLevel() )
  32. {
  33. // Tell the engine we've hid the console, so that it unpauses the game
  34. // even though we're still sitting at the menu.
  35. engine->ClientCmd_Unrestricted( "unpause" );
  36. }
  37. }
  38. BaseClass::OnCommand(command);
  39. }
  40. //-----------------------------------------------------------------------------
  41. // HACK: Allow F key bindings to operate even when typing in the text entry field
  42. //-----------------------------------------------------------------------------
  43. void CGameConsoleDialog::OnKeyCodeTyped(KeyCode code)
  44. {
  45. BaseClass::OnKeyCodeTyped(code);
  46. // check for processing
  47. if ( m_pConsolePanel->TextEntryHasFocus() )
  48. {
  49. // HACK: Allow F key bindings to operate even here
  50. if ( code >= KEY_F1 && code <= KEY_F12 )
  51. {
  52. // See if there is a binding for the FKey
  53. const char *binding = gameuifuncs->GetBindingForButtonCode( code );
  54. if ( binding && binding[0] )
  55. {
  56. // submit the entry as a console commmand
  57. char szCommand[256];
  58. Q_strncpy( szCommand, binding, sizeof( szCommand ) );
  59. engine->ClientCmd_Unrestricted( szCommand );
  60. }
  61. }
  62. }
  63. }
  64. //-----------------------------------------------------------------------------
  65. // Submits a command
  66. //-----------------------------------------------------------------------------
  67. void CGameConsoleDialog::OnCommandSubmitted( const char *pCommand )
  68. {
  69. engine->ClientCmd_Unrestricted( pCommand );
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Submits a command
  73. //-----------------------------------------------------------------------------
  74. void CGameConsoleDialog::OnClosedByHittingTilde()
  75. {
  76. if ( !LoadingDialog() )
  77. {
  78. GameUI().HideGameUI();
  79. }
  80. else
  81. {
  82. vgui::surface()->RestrictPaintToSinglePanel( LoadingDialog()->GetVPanel() );
  83. }
  84. }