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.

73 lines
1.8 KiB

  1. //========= Copyright � 1996-2008, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Client handler for instruction players how to play
  4. //
  5. //=============================================================================//
  6. #ifndef _C_KEYVALUE_SAVER_H_
  7. #define _C_KEYVALUE_SAVER_H_
  8. #include "GameEventListener.h"
  9. #include "keyvalues.h"
  10. typedef void (*KeyValueBuilder)( KeyValues* );
  11. struct KeyValueSaverData
  12. {
  13. char szFileName[ MAX_PATH ];
  14. bool bDirtySaveData;
  15. KeyValues *pKeyValues;
  16. KeyValueBuilder funcKeyValueBuilder;
  17. };
  18. class C_KeyValueSaver : public CAutoGameSystemPerFrame, public CGameEventListener
  19. {
  20. public:
  21. C_KeyValueSaver() : CAutoGameSystemPerFrame( "C_KeyValueSaver" )
  22. {
  23. m_nSplitScreenSlot = -1;
  24. }
  25. void SetSlot( int nSlot ) { m_nSplitScreenSlot = nSlot; }
  26. // Methods of IGameSystem
  27. virtual bool Init( void );
  28. virtual void Shutdown( void );
  29. virtual void Update( float frametime );
  30. // Methods of CGameEventListener
  31. virtual void FireGameEvent( IGameEvent *event );
  32. bool InitKeyValues( const char *pchFileName, KeyValueBuilder funcKeyValueBuilder );
  33. bool WriteDirtyKeyValues( const char *pchFileName, bool bForceWrite = false );
  34. KeyValues * GetKeyValues( const char *pchFileName, bool bForceReread = false );
  35. void MarkKeyValuesDirty( const char *pchFileName );
  36. private:
  37. bool ReadKeyValues( KeyValueSaverData *pKeyValueData );
  38. bool WriteDirtyKeyValues( KeyValueSaverData *pKeyValueData, bool bForceWrite = false );
  39. void WriteAllDirtyKeyValues( void );
  40. KeyValueSaverData * FindKeyValueData( const char *pchFileName );
  41. private:
  42. CUtlVector< KeyValueSaverData > m_KeyValueData;
  43. int m_nSplitScreenSlot;
  44. };
  45. C_KeyValueSaver &KeyValueSaver();
  46. // Merged from L4D but waiting on other code to be merged before this can compile
  47. void GameInstructor_Init();
  48. void GameInstructor_Shutdown();
  49. #endif // _C_KEYVALUE_SAVER_H_