BsProjectResourceMeta.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Reflection/BsIReflectable.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Library
  9. * @{
  10. */
  11. /** Different icon sizes for project resource preview icons. */
  12. struct BS_SCRIPT_EXPORT(pl:true,api:bed) ProjectResourceIcons
  13. {
  14. HTexture icon16;
  15. HTexture icon32;
  16. HTexture icon48;
  17. HTexture icon64;
  18. HTexture icon96;
  19. HTexture icon128;
  20. HTexture icon192;
  21. HTexture icon256;
  22. };
  23. /** Contains meta-data for a resource stored in the ProjectLibrary. */
  24. class BS_ED_EXPORT ProjectResourceMeta : public IReflectable
  25. {
  26. private:
  27. struct ConstructPrivately {};
  28. public:
  29. explicit ProjectResourceMeta(const ConstructPrivately&);
  30. /**
  31. * Creates a new project library resource meta-data entry.
  32. *
  33. * @param[in] name Name of the resource, unique within the file containing the resource.
  34. * @param[in] uuid UUID of the resource.
  35. * @param[in] typeId RTTI type id of the resource.
  36. * @param[in] previewIcons A set of icons used for displaying a preview of the resource's contents.
  37. * @param[in] resourceMetaData Non-project library specific meta-data.
  38. * @return New project library resource meta data instance.
  39. */
  40. static SPtr<ProjectResourceMeta> create(const String& name, const UUID& uuid, UINT32 typeId,
  41. const ProjectResourceIcons& previewIcons, const SPtr<ResourceMetaData>& resourceMetaData);
  42. /** Returns the name of the resource, unique within the file containing the resource. */
  43. String getUniqueName() const;
  44. /** Returns the UUID of the resource this meta data belongs to. */
  45. const UUID& getUUID() const { return mUUID; }
  46. /** Returns the non-project library specific meta-data. */
  47. SPtr<ResourceMetaData> getResourceMetaData() const { return mResourceMeta; }
  48. /** Returns the RTTI type ID of the resource this object is referencing. */
  49. UINT32 getTypeID() const { return mTypeId; }
  50. /** @copydoc setPreviewIcons() */
  51. const ProjectResourceIcons& getPreviewIcons() const { return mPreviewIcons; }
  52. /* A set of icons used for displaying a preview of the resource's contents. */
  53. void setPreviewIcons(const ProjectResourceIcons& icons) { mPreviewIcons = icons; }
  54. /**
  55. * Returns additional data attached to the resource meta by the user. This is non-specific data and can contain
  56. * anything the user requires.
  57. */
  58. SPtr<IReflectable> getUserData() const { return mUserData; }
  59. private:
  60. friend class ProjectLibrary;
  61. WString mName;
  62. UUID mUUID;
  63. SPtr<ResourceMetaData> mResourceMeta;
  64. UINT32 mTypeId = 0;
  65. ProjectResourceIcons mPreviewIcons;
  66. SPtr<IReflectable> mUserData;
  67. /************************************************************************/
  68. /* RTTI */
  69. /************************************************************************/
  70. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  71. static SPtr<ProjectResourceMeta> createEmpty();
  72. public:
  73. friend class ProjectResourceMetaRTTI;
  74. static RTTITypeBase* getRTTIStatic();
  75. RTTITypeBase* getRTTI() const override;
  76. };
  77. /**
  78. * Contains meta-data for a file stored in the ProjectLibrary. A single file meta-data can contain one or multiple
  79. * ProjectResourceMeta instances.
  80. */
  81. class BS_ED_EXPORT ProjectFileMeta : public IReflectable
  82. {
  83. private:
  84. struct ConstructPrivately {};
  85. public:
  86. explicit ProjectFileMeta(const ConstructPrivately&);
  87. /**
  88. * Creates a new project library file meta-data entry.
  89. *
  90. * @param[in] importOptions Import options used for importing the resource.
  91. * @return New project library file meta data instance.
  92. */
  93. static SPtr<ProjectFileMeta> create(const SPtr<ImportOptions>& importOptions);
  94. /** Registers a new resource in the file meta-data. */
  95. void add(const SPtr<ProjectResourceMeta>& resourceMeta);
  96. /**
  97. * Registers an inactive resource in the file meta-data. Inactive meta-data is stored for resources that used
  98. * to exist, but do not exist currently, in order to restore their handles if they get restored at a later date.
  99. */
  100. void addInactive(const SPtr<ProjectResourceMeta>& resourceMeta);
  101. /** Returns meta-data for all active resources contained in the file represented by this meta-data object. */
  102. const Vector<SPtr<ProjectResourceMeta>>& getResourceMetaData() const { return mResourceMetaData; }
  103. /**
  104. * Returns meta-data for all resources (both active and inactive) contained in the file represented by this
  105. * meta-data object.
  106. */
  107. Vector<SPtr<ProjectResourceMeta>> getAllResourceMetaData() const;
  108. /**
  109. * Removes all resource meta-data stored by this object. This includes meta-data for both active and inactive
  110. * resources.
  111. */
  112. void clearResourceMetaData();
  113. /** Returns the import options used for importing the resource this object is referencing. */
  114. const SPtr<ImportOptions>& getImportOptions() const { return mImportOptions; }
  115. /** Checks should this resource always be included in the build, regardless if it's being referenced or not. */
  116. bool getIncludeInBuild() const { return mIncludeInBuild; }
  117. /** Determines if this resource will always be included in the build, regardless if it's being referenced or not. */
  118. void setIncludeInBuild(bool include) { mIncludeInBuild = include; }
  119. /** Checks does the file contain a resource with the specified type id. */
  120. bool hasTypeId(UINT32 typeId) const;
  121. /** Checks does the file contain a resource with the specified UUID. */
  122. bool hasUUID(const UUID& uuid) const;
  123. private:
  124. friend class ProjectLibrary;
  125. Vector<SPtr<ProjectResourceMeta>> mResourceMetaData;
  126. Vector<SPtr<ProjectResourceMeta>> mInactiveResourceMetaData;
  127. SPtr<ImportOptions> mImportOptions;
  128. bool mIncludeInBuild;
  129. /************************************************************************/
  130. /* RTTI */
  131. /************************************************************************/
  132. /** Creates a new empty meta-data instance. Used only for serialization purposes. */
  133. static SPtr<ProjectFileMeta> createEmpty();
  134. public:
  135. friend class ProjectFileMetaRTTI;
  136. static RTTITypeBase* getRTTIStatic();
  137. RTTITypeBase* getRTTI() const override;
  138. };
  139. /** @} */
  140. }