AssetDatabase.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. #pragma once
  8. #include <Atomic/Core/Object.h>
  9. #include <Atomic/Container/List.h>
  10. #include "Asset.h"
  11. using namespace Atomic;
  12. namespace ToolCore
  13. {
  14. class Project;
  15. class AssetDatabase : public Object
  16. {
  17. OBJECT(AssetDatabase);
  18. public:
  19. /// Construct.
  20. AssetDatabase(Context* context);
  21. virtual ~AssetDatabase();
  22. Asset* GetAssetByGUID(const String& guid);
  23. Asset* GetAssetByPath(const String& path);
  24. Asset* GetAssetByCachePath(const String& cachePath);
  25. String GenerateAssetGUID();
  26. void RegisterGUID(const String& guid);
  27. String GetCachePath();
  28. void DeleteAsset(Asset* asset);
  29. void Scan();
  30. void GetFolderAssets(String folder, PODVector<Asset*>& assets) const;
  31. String GetResourceImporterName(const String& resourceTypeName);
  32. void GetAssetsByImporterType(StringHash type, PODVector<Asset*>& assets) const;
  33. void GetDirtyAssets(PODVector<Asset*>& assets);
  34. String GetDotAssetFilename(const String& path);
  35. private:
  36. void HandleProjectLoaded(StringHash eventType, VariantMap& eventData);
  37. void HandleProjectUnloaded(StringHash eventType, VariantMap& eventData);
  38. void HandleFileChanged(StringHash eventType, VariantMap& eventData);
  39. void HandleResourceLoadFailed(StringHash eventType, VariantMap& eventData);
  40. void AddAsset(SharedPtr<Asset>& asset);
  41. void PruneOrphanedDotAssetFiles();
  42. void Import(const String& path);
  43. bool ImportDirtyAssets();
  44. void PreloadAssets();
  45. SharedPtr<Project> project_;
  46. List<SharedPtr<Asset>> assets_;
  47. HashMap<StringHash, String> resourceTypeToImporterType_;
  48. /// Hash value of times, so we don't spam import errors
  49. HashMap<StringHash, unsigned> assetImportErrorTimes_;
  50. Vector<String> usedGUID_;
  51. };
  52. }