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.

67 lines
2.1 KiB

  1. //====== Copyright �, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: motd: Handles a list of message of the day entries
  4. //
  5. //=============================================================================
  6. #ifndef MOTD_H
  7. #define MOTD_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "keyvalues.h"
  12. #include "language.h"
  13. //-----------------------------------------------------------------------------
  14. // CMOTDEntryDefinition
  15. //-----------------------------------------------------------------------------
  16. class CMOTDEntryDefinition
  17. {
  18. public:
  19. CMOTDEntryDefinition( void );
  20. ~CMOTDEntryDefinition( void ) { }
  21. bool BInitFromKV( KeyValues *pKVMOTD, CUtlVector<CUtlString> *pVecErrors = NULL );
  22. const char *GetName( void ) { return m_pKVMOTD ? m_pKVMOTD->GetName() : "Unknown Entry"; }
  23. const char *GetTitle( ELanguage eLang );
  24. const char *GetText( ELanguage eLang );
  25. const char *GetURL( void ) { return m_pKVMOTD ? m_pKVMOTD->GetString("url","") : NULL; }
  26. const char *GetPostTimeStr( void ) { return m_pKVMOTD ? m_pKVMOTD->GetString("time") : NULL; }
  27. // Post time is the time displayed on the client screen for this post
  28. const RTime32 GetPostTime( void ) const { return m_PostTime; }
  29. // Change time is the time at which we last changed this post. If we change wording on
  30. // a post, we need to know that the change should be sent to clients when they log on afterwards.
  31. const RTime32 GetChangedTime( void ) const { return m_ChangedTime; }
  32. private:
  33. KeyValues *m_pKVMOTD;
  34. RTime32 m_PostTime;
  35. RTime32 m_ChangedTime;
  36. };
  37. //-----------------------------------------------------------------------------
  38. // CMOTDMgr
  39. //-----------------------------------------------------------------------------
  40. class CMOTDManager
  41. {
  42. public:
  43. // MOTD handling
  44. bool BInitMOTDEntries( KeyValues *pKVMOTDEntries, CUtlVector<CUtlString> *pVecErrors );
  45. int GetNumMOTDAfter( RTime32 iTime );
  46. CMOTDEntryDefinition *GetNextMOTDAfter( RTime32 iTime );
  47. int GetNumMOTDs( void ) { return m_vecMOTDEntries.Count(); }
  48. CMOTDEntryDefinition *GetMOTDByIndex( int iIndex );
  49. private:
  50. // Contains the list of MOTD entries.
  51. CUtlVector< CMOTDEntryDefinition > m_vecMOTDEntries;
  52. };
  53. #endif // MOTD_H