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. String GetCachePath() const;
  24. unsigned GetTimestamp() const { return timestamp_; }
  25. const StringHash GetImporterType() { return importer_.Null() ? String::EMPTY : importer_->GetType(); }
  26. const String& GetImporterTypeName() { return importer_.Null() ? String::EMPTY : importer_->GetTypeName(); }
  27. AssetImporter* GetImporter() { return importer_; }
  28. Asset* GetParent();
  29. void SetDirty(bool dirty) { dirty_ = dirty; }
  30. bool IsDirty() const { return dirty_; }
  31. // get the .asset filename
  32. String GetDotAssetFilename();
  33. bool IsFolder() const { return isFolder_; }
  34. // load .asset
  35. bool Load();
  36. // save .asset
  37. bool Save();
  38. private:
  39. bool CreateImporter();
  40. bool CheckCacheFile();
  41. String guid_;
  42. // can change
  43. String path_;
  44. String name_;
  45. unsigned timestamp_;
  46. bool dirty_;
  47. bool isFolder_;
  48. SharedPtr<JSONFile> json_;
  49. SharedPtr<AssetImporter> importer_;
  50. };
  51. }