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.

106 lines
3.0 KiB

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