Asset.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. Asset* GetParent();
  30. void SetDirty(bool dirty) { dirty_ = dirty; }
  31. bool IsDirty() const { return dirty_; }
  32. // get the .asset filename
  33. String GetDotAssetFilename();
  34. bool IsFolder() const { return isFolder_; }
  35. // load .asset
  36. bool Load();
  37. // save .asset
  38. bool Save();
  39. private:
  40. bool CreateImporter();
  41. bool CheckCacheFile();
  42. String guid_;
  43. // can change
  44. String path_;
  45. String name_;
  46. bool dirty_;
  47. bool isFolder_;
  48. SharedPtr<JSONFile> json_;
  49. SharedPtr<AssetImporter> importer_;
  50. };
  51. }