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.

72 lines
1.6 KiB

  1. //=========== (C) Copyright Valve, L.L.C. All rights reserved. ===========
  2. #include "cbase.h"
  3. #include "ui_nugget.h"
  4. #include "vstdlib/iprocessutils.h"
  5. #include "../uigamedata.h"
  6. class CUiNuggetApplication : public CUiNuggetBase
  7. {
  8. DECLARE_NUGGET_FN_MAP( CUiNuggetApplication, CUiNuggetBase );
  9. NUGGET_FN( Quit )
  10. {
  11. // We need to quit the app
  12. if ( IsPC() )
  13. {
  14. engine->ClientCmd( "quit" );
  15. }
  16. // X360 can quit in demo mode
  17. if ( IsGameConsole() )
  18. {
  19. engine->ExecuteClientCmd( "demo_exit" );
  20. }
  21. return NULL;
  22. }
  23. NUGGET_FN( ResumeGame )
  24. {
  25. engine->ClientCmd("gameui_hide");
  26. return NULL;
  27. }
  28. NUGGET_FN( ExitToMainMenu )
  29. {
  30. engine->ExecuteClientCmd( "gameui_hide" );
  31. if ( IMatchSession *pMatchSession = g_pMatchFramework->GetMatchSession() )
  32. {
  33. // Closing an active session results in disconnecting from the game.
  34. g_pMatchFramework->CloseSession();
  35. }
  36. else
  37. {
  38. // On PC people can be playing via console bypassing matchmaking
  39. // and required session settings, so to leave game duplicate
  40. // session closure with an extra "disconnect" command.
  41. engine->ExecuteClientCmd( "disconnect" );
  42. }
  43. engine->ExecuteClientCmd( "gameui_activate" );
  44. return NULL;
  45. }
  46. NUGGET_FN( SteamOverlayCommand )
  47. {
  48. #ifndef _GAMECONSOLE
  49. BaseModUI::CUIGameData::Get()->ExecuteOverlayCommand( args->GetString( "command" ) );
  50. #endif
  51. return NULL;
  52. }
  53. NUGGET_FN( LaunchExternalApp )
  54. {
  55. int nExitCode = g_pProcessUtils ? g_pProcessUtils->SimpleRunProcess( args->GetString( "command" ) ) : -1;
  56. return new KeyValues( "", "code", nExitCode );
  57. }
  58. };
  59. UI_NUGGET_FACTORY_SINGLETON( CUiNuggetApplication, "app" );