Asset.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include <Atomic/Core/Object.h>
  3. #include "AssetImporter.h"
  4. using namespace Atomic;
  5. namespace ToolCore
  6. {
  7. #define ASSET_VERSION 1
  8. class Asset : public Object
  9. {
  10. friend class AssetDatabase;
  11. OBJECT(Asset);
  12. public:
  13. /// Construct.
  14. Asset(Context* context);
  15. virtual ~Asset();
  16. bool Import();
  17. bool Preload();
  18. // the .fbx, .png, etc path, attempts to load .asset, creates missing .asset
  19. bool SetPath(const String& path);
  20. const String& GetGUID() const { return guid_; }
  21. const String& GetName() const { return name_; }
  22. const String& GetPath() const { return path_; }
  23. /// Get the path relative to project
  24. String GetRelativePath();
  25. String GetCachePath() const;
  26. const StringHash GetImporterType() { return importer_.Null() ? String::EMPTY : importer_->GetType(); }
  27. const String& GetImporterTypeName() { return importer_.Null() ? String::EMPTY : importer_->GetTypeName(); }
  28. AssetImporter* GetImporter() { return importer_; }
  29. void PostImportError(const String& message);
  30. Asset* GetParent();
  31. void SetDirty(bool dirty) { dirty_ = dirty; }
  32. bool IsDirty() const { return dirty_; }
  33. // get the .asset filename
  34. String GetDotAssetFilename();
  35. bool IsFolder() const { return isFolder_; }
  36. // load .asset
  37. bool Load();
  38. // save .asset
  39. bool Save();
  40. private:
  41. bool CreateImporter();
  42. bool CheckCacheFile();
  43. String guid_;
  44. // can change
  45. String path_;
  46. String name_;
  47. bool dirty_;
  48. bool isFolder_;
  49. SharedPtr<JSONFile> json_;
  50. SharedPtr<AssetImporter> importer_;
  51. };
  52. }