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.

91 lines
2.5 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "commentaryexplanationdialog.h"
  7. #include "basepanel.h"
  8. #include "convar.h"
  9. #include "engineinterface.h"
  10. #include "gameui_interface.h"
  11. #include "vgui/ISurface.h"
  12. #include "vgui/IInput.h"
  13. #include <stdio.h>
  14. using namespace vgui;
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose:
  19. //-----------------------------------------------------------------------------
  20. CCommentaryExplanationDialog::CCommentaryExplanationDialog(vgui::Panel *parent, char *pszFinishCommand) : BaseClass(parent, "CommentaryExplanationDialog")
  21. {
  22. SetDeleteSelfOnClose(true);
  23. SetSizeable( false );
  24. input()->SetAppModalSurface(GetVPanel());
  25. LoadControlSettings("Resource/CommentaryExplanationDialog.res");
  26. MoveToCenterOfScreen();
  27. GameUI().PreventEngineHideGameUI();
  28. // Save off the finish command
  29. Q_snprintf( m_pszFinishCommand, sizeof( m_pszFinishCommand ), "%s", pszFinishCommand );
  30. }
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. CCommentaryExplanationDialog::~CCommentaryExplanationDialog()
  35. {
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. //-----------------------------------------------------------------------------
  40. void CCommentaryExplanationDialog::OnKeyCodePressed(KeyCode code)
  41. {
  42. if (code == KEY_ESCAPE)
  43. {
  44. Close();
  45. }
  46. else
  47. {
  48. BaseClass::OnKeyCodePressed(code);
  49. }
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: handles button commands
  53. //-----------------------------------------------------------------------------
  54. void CCommentaryExplanationDialog::OnCommand( const char *command )
  55. {
  56. if ( !stricmp( command, "ok" ) )
  57. {
  58. Close();
  59. BasePanel()->FadeToBlackAndRunEngineCommand( m_pszFinishCommand );
  60. }
  61. else if ( !stricmp( command, "cancel" ) || !stricmp( command, "close" ) )
  62. {
  63. Close();
  64. }
  65. else
  66. {
  67. BaseClass::OnCommand( command );
  68. }
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. //-----------------------------------------------------------------------------
  73. void CCommentaryExplanationDialog::OnClose( void )
  74. {
  75. BaseClass::OnClose();
  76. GameUI().AllowEngineHideGameUI();
  77. }