AssetDatabase.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 ReimportAllAssets();
  31. void GetFolderAssets(String folder, PODVector<Asset*>& assets) const;
  32. String GetResourceImporterName(const String& resourceTypeName);
  33. void GetAssetsByImporterType(StringHash type, const String& resourceType, PODVector<Asset*>& assets) const;
  34. void GetDirtyAssets(PODVector<Asset*>& assets);
  35. String GetDotAssetFilename(const String& path);
  36. private:
  37. void HandleProjectLoaded(StringHash eventType, VariantMap& eventData);
  38. void HandleProjectUnloaded(StringHash eventType, VariantMap& eventData);
  39. void HandleFileChanged(StringHash eventType, VariantMap& eventData);
  40. void HandleResourceLoadFailed(StringHash eventType, VariantMap& eventData);
  41. void AddAsset(SharedPtr<Asset>& asset);
  42. void PruneOrphanedDotAssetFiles();
  43. void Import(const String& path);
  44. bool ImportDirtyAssets();
  45. void PreloadAssets();
  46. SharedPtr<Project> project_;
  47. List<SharedPtr<Asset>> assets_;
  48. HashMap<StringHash, String> resourceTypeToImporterType_;
  49. /// Hash value of times, so we don't spam import errors
  50. HashMap<StringHash, unsigned> assetImportErrorTimes_;
  51. Vector<String> usedGUID_;
  52. };
  53. }