JSONImporter.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #include <Atomic/IO/Log.h>
  8. #include <Atomic/IO/File.h>
  9. #include <Atomic/Resource/ResourceCache.h>
  10. #include <Atomic/Resource/Image.h>
  11. #include <AtomicJS/Javascript/JSComponentFile.h>
  12. #include "Asset.h"
  13. #include "AssetDatabase.h"
  14. #include "JSONImporter.h"
  15. namespace ToolCore
  16. {
  17. JSONImporter::JSONImporter(Context* context, Asset *asset) : AssetImporter(context, asset)
  18. {
  19. requiresCacheFile_ = false;
  20. }
  21. JSONImporter::~JSONImporter()
  22. {
  23. }
  24. void JSONImporter::SetDefaults()
  25. {
  26. AssetImporter::SetDefaults();
  27. }
  28. bool JSONImporter::Import()
  29. {
  30. return true;
  31. }
  32. bool JSONImporter::LoadSettingsInternal(JSONValue& jsonRoot)
  33. {
  34. if (!AssetImporter::LoadSettingsInternal(jsonRoot))
  35. return false;
  36. JSONValue import = jsonRoot.Get("JSONImporter");
  37. return true;
  38. }
  39. bool JSONImporter::SaveSettingsInternal(JSONValue& jsonRoot)
  40. {
  41. if (!AssetImporter::SaveSettingsInternal(jsonRoot))
  42. return false;
  43. JSONValue import;
  44. jsonRoot.Set("JSONImporter", import);
  45. return true;
  46. }
  47. Resource* JSONImporter::GetResource(const String& typeName)
  48. {
  49. ResourceCache* cache = GetSubsystem<ResourceCache>();
  50. JSONFile* jsfile = cache->GetResource<JSONFile>(asset_->GetPath());
  51. return jsfile;
  52. }
  53. }