Team Fortress 2 Source Code as on 22/4/2020
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.

62 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Enables sending of notifications (custom messages of various kinds) to the client
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_NOTIFICATION_H
  8. #define TF_NOTIFICATION_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "gcsdk/protobufsharedobject.h"
  13. #include "tf_gcmessages.h"
  14. #ifdef GC
  15. #include "tf_gc.h"
  16. #endif
  17. //---------------------------------------------------------------------------------
  18. // Purpose: Send a notification to the client
  19. //---------------------------------------------------------------------------------
  20. // LOCALIZED NOTIFICATIONS
  21. //
  22. // Some types of notification are on-the-fly localized. These notifications are stored in the database as unlocalized
  23. // strings (#TF_Foo), but on-the-fly localized when loaded as a shared-object. Clients only see the final localized
  24. // version. BLocalizeAndMaybeDirty() will update the localization for a newer language.
  25. class CTFNotification : public GCSDK::CProtoBufSharedObject< CMsgGCNotification, k_EEconTypeNotification >
  26. {
  27. public:
  28. // If using this form, ensure you call BLocalize after filling fields for localized types.
  29. #ifdef GC
  30. CTFNotification();
  31. CTFNotification( CMsgGCNotification msg, const char *pUnlocalizedString, ELanguage eLang );
  32. DECLARE_CLASS_MEMPOOL( CTFNotification );
  33. // For on-the-fly localized notification types, update the localization to this language now. If true, object
  34. // changed. See LOCALIZED NOTIFICATIONS above.
  35. //
  36. // !! Caller is responsible for dirtying and sending network updates if this results in a change.
  37. bool BLocalize( ELanguage eLang );
  38. virtual bool BYieldingAddInsertToTransaction( GCSDK::CSQLAccess & sqlAccess );
  39. virtual bool BYieldingAddWriteToTransaction( GCSDK::CSQLAccess & sqlAccess, const CUtlVector< int > &fields );
  40. virtual bool BYieldingAddRemoveToTransaction( GCSDK::CSQLAccess & sqlAccess );
  41. void WriteToRecord( CSchNotification *pNotification ) const;
  42. void ReadFromRecord( const CSchNotification & pNotification );
  43. private:
  44. // For notifications that are on-the-fly localized, this holds the localization token (which is stored in the DB),
  45. // whereas the in-memory object is a localized representation.
  46. CUtlString m_strUnlocalizedString;
  47. ELanguage m_eLocalizedToLanguage;
  48. #endif // GC
  49. };
  50. #endif // TF_NOTIFICATION_H