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.

84 lines
3.7 KiB

  1. //====== Copyright �, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Defines gc-specific convars that integrate their AppIDs so that
  4. // two GC's in the same shell don' overwrite each other
  5. //
  6. //=============================================================================
  7. #ifndef GCCONVAR_H
  8. #define GCCONVAR_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/convar.h"
  13. //-----------------------------------------------------------------------------
  14. // Purpose: GC specifc ConVar
  15. //-----------------------------------------------------------------------------
  16. class GCConVar : public ConVar
  17. {
  18. public:
  19. GCConVar( const char *pName, const char *pDefaultValue, int flags = 0)
  20. : ConVar( pName, pDefaultValue, flags) {}
  21. GCConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString )
  22. : ConVar( pName, pDefaultValue, flags, pHelpString ) {}
  23. GCConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax )
  24. : ConVar( pName, pDefaultValue, flags, pHelpString, bMin, fMin, bMax, fMax ) {}
  25. GCConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString, FnChangeCallback_t callback )
  26. : ConVar( pName, pDefaultValue, flags, pHelpString, callback ) {}
  27. GCConVar( const char *pName, const char *pDefaultValue, int flags, const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax, FnChangeCallback_t callback )
  28. : ConVar( pName, pDefaultValue, flags, pHelpString, bMin, fMin, bMax, fMax, callback ) {}
  29. virtual const char *GetName( void ) const;
  30. const char *GetBaseName() const { GetName(); return m_pchBaseName; } // returns the name without the appID suffix
  31. protected:
  32. mutable CUtlString m_strGCName;
  33. mutable const char *m_pchBaseName;
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose: GC specific ConCommand
  37. //-----------------------------------------------------------------------------
  38. class GCConCommand : public ConCommand
  39. {
  40. public:
  41. GCConCommand( const char *pName, FnCommandCallbackV1_t callback, const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 )
  42. : ConCommand( pName, callback, pHelpString, flags, completionFunc ) {}
  43. GCConCommand( const char *pName, FnCommandCallback_t callback, const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 )
  44. : ConCommand( pName, callback, pHelpString, flags, completionFunc ) {}
  45. GCConCommand( const char *pName, ICommandCallback *pCallback, const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 )
  46. : ConCommand( pName, pCallback, pHelpString, flags, pCommandCompletionCallback ) {}
  47. virtual const char *GetName( void ) const;
  48. const char *GetBaseName() const { GetName(); return m_pchBaseName; } // returns the name without the appID suffix
  49. protected:
  50. mutable CUtlString m_strGCName;
  51. mutable const char *m_pchBaseName;
  52. };
  53. #define GC_CON_COMMAND( name, description ) \
  54. static void name( const CCommand &args ); \
  55. static GCConCommand name##_command( #name, name, description ); \
  56. static void name( const CCommand &args )
  57. #define AUTO_CONFIRM_CON_COMMAND() \
  58. { \
  59. static RTime32 rtimeLastRan = 0; \
  60. if ( CRTime::RTime32TimeCur() - rtimeLastRan > 3 ) \
  61. { \
  62. rtimeLastRan = CRTime::RTime32TimeCur(); \
  63. EmitInfo( SPEW_CONSOLE, SPEW_ALWAYS, LOG_ALWAYS, "Auto-confirm: Please repeat command within 3 seconds to confirm.\n" ); \
  64. return; \
  65. } \
  66. else \
  67. { \
  68. rtimeLastRan = 0; \
  69. } \
  70. }
  71. #endif