AssetImporter.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/Resource/JSONFile.h>
  10. #include <Atomic/Scene/Node.h>
  11. using namespace Atomic;
  12. namespace ToolCore
  13. {
  14. class Asset;
  15. /// deals with .asset files
  16. class AssetImporter : public Object
  17. {
  18. friend class Asset;
  19. OBJECT(AssetImporter);
  20. public:
  21. /// Construct.
  22. AssetImporter(Context* context, Asset* asset);
  23. virtual ~AssetImporter();
  24. // load .asset
  25. bool LoadSettings(JSONValue& root);
  26. // save .asset
  27. bool SaveSettings(JSONValue& root);
  28. virtual void SetDefaults();
  29. virtual bool Preload() { return true; }
  30. Asset* GetAsset() { return asset_; }
  31. virtual Resource* GetResource(const String& typeName = String::EMPTY) { return 0; }
  32. bool RequiresCacheFile() const { return requiresCacheFile_; }
  33. /// Instantiate a node from the asset
  34. virtual Node* InstantiateNode(Node* parent, const String& name) { return 0; }
  35. virtual bool Rename(const String& newName);
  36. virtual bool Move(const String& newPath);
  37. protected:
  38. virtual bool Import() { return true; }
  39. WeakPtr<Asset> asset_;
  40. bool requiresCacheFile_;
  41. virtual bool LoadSettingsInternal(JSONValue& jsonRoot);
  42. virtual bool SaveSettingsInternal(JSONValue& jsonRoot);
  43. };
  44. }