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.

133 lines
5.2 KiB

  1. #ifndef ECONITEMDESCRIPTION_H
  2. #define ECONITEMDESCRIPTION_H
  3. #ifdef _WIN32
  4. #pragma once
  5. #endif
  6. #include "localization_provider.h" // needed for locchar_t type
  7. class IEconItemInterface;
  8. namespace GCSDK
  9. {
  10. class CSharedObjectTypeCache;
  11. }
  12. //-----------------------------------------------------------------------------
  13. // Purpose: Generate a description block for an IEconItemInterface. What the
  14. // client does with the description is anyone's guess, but this will
  15. // generate a block of UTF16 lines of text with meta/color data that
  16. // can be used for whatever.
  17. //-----------------------------------------------------------------------------
  18. enum EDescriptionLineMetaFlags
  19. {
  20. kDescLineFlag_Name = 0x0001, // the item name (can be renamed by user)
  21. kDescLineFlag_Type = 0x0002, // the item type (ie., "Level 5 Rocket Launcher")
  22. kDescLineFlag_Desc = 0x0004, // base item description (description from the item definition, level, etc.)
  23. kDescLineFlag_Attribute = 0x0008, // some sort of gameplay-affecting attribute
  24. kDescLineFlag_Misc = 0x0010, // not an attribute, not name/level
  25. kDescLineFlag_Empty = 0x0020, // line with no content that needs to be displayed; meant for spacing
  26. kDescLineFlag_Set = 0x0040, // this line is associated with item sets somehow
  27. kDescLineFlag_LimitedUse = 0x0080, // this is a limited use item
  28. kDescLineFlag_SetName = 0x0100, // this line is the title for an item set
  29. kDescLineFlag_Scorecard = 0x0200,
  30. kDescLineFlag_LootList = 0x0400, // this line belongs to a lootlist block
  31. kDescLineFlag_OwnerOnly = 0x0800, // this line must be only shown for owner of the item
  32. kDescLineFlag_DetailedInfo = 0x1000, // this line is detailed info like mission xp
  33. kDescLineFlag_NameUncustomized = 0x2000, // the item name (not customized)
  34. kDescLineFlagSet_DisplayInAttributeBlock = ~(kDescLineFlag_Name | kDescLineFlag_Type),
  35. };
  36. struct econ_item_description_line_t
  37. {
  38. attrib_colors_t eColor; // desired color type for this line -- will likely be looked up either in VGUI or in the schema
  39. uint32 unMetaType; // type information for this line -- "item name"? "item level"?; etc.; can be game-specific
  40. CUtlConstStringBase<locchar_t> sText; // actual text for this, post-localization
  41. itemid_t un64FauxItemId; // defindex and paint encoded as an itemid.
  42. bool bOwned; // a way to keep track of set/collection item presence
  43. };
  44. class IEconItemDescription
  45. {
  46. public:
  47. // This may yield on the GC and should never yield on the client.
  48. static void YieldingFillOutEconItemDescription( IEconItemDescription *out_pDescription, CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem );
  49. public:
  50. IEconItemDescription() { }
  51. virtual ~IEconItemDescription() { }
  52. uint32 GetLineCount() const { return m_vecDescLines.Count(); }
  53. const econ_item_description_line_t& GetLine( int i ) const { return m_vecDescLines[i]; }
  54. // Finds and returns the first line with *all* of the passed in search flags. Will return NULL if a line
  55. // will all of the flags cannot be found.
  56. const econ_item_description_line_t *GetFirstLineWithMetaType( uint32 unMetaTypeSearchFlags ) const;
  57. private:
  58. // When generating an item description, this is guaranteed to be called once and only once before GenerateDescription()
  59. // is called. Any data that may yield but will be needed somewhere deep inside GenerateDescription() should be determined
  60. // and cached off here.
  61. virtual void YieldingCacheDescriptionData( CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem ) { }
  62. // Take the properties off our pEconItem, and anything that we calculated in YieldingCacheDescriptionData() above and
  63. // fill out all of our description lines.
  64. virtual void GenerateDescriptionLines( CLocalizationProvider *pLocalizationProvider, const IEconItemInterface *pEconItem ) = 0;
  65. protected:
  66. CUtlVector<econ_item_description_line_t> m_vecDescLines;
  67. };
  68. #if defined( TF_DLL ) || defined( TF_CLIENT_DLL ) || defined( TF_GC_DLL )
  69. #define PROJECT_TF
  70. #endif
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. class CSteamAccountIDAttributeCollector : public IEconItemAttributeIterator
  75. {
  76. public:
  77. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, attrib_value_t value ) OVERRIDE
  78. {
  79. if ( pAttrDef->GetDescriptionFormat() == ATTDESCFORM_VALUE_IS_ACCOUNT_ID )
  80. {
  81. m_vecSteamAccountIDs.AddToTail( value );
  82. }
  83. return true;
  84. }
  85. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, float value ) OVERRIDE
  86. {
  87. // Intentionally ignore.
  88. return true;
  89. }
  90. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const CAttribute_String& value ) OVERRIDE
  91. {
  92. // Intentionally ignore.
  93. return true;
  94. }
  95. virtual bool OnIterateAttributeValue( const CEconItemAttributeDefinition *pAttrDef, const Vector& value ) OVERRIDE
  96. {
  97. // Intentionally ignore.
  98. return true;
  99. }
  100. // Data access.
  101. const CUtlVector<uint32>& GetAccountIDs()
  102. {
  103. return m_vecSteamAccountIDs;
  104. }
  105. private:
  106. CUtlVector<uint32> m_vecSteamAccountIDs;
  107. };
  108. #endif // ECONITEMDESCRIPTION_H