Browse Source

Scene import

Josh Engebretson 10 years ago
parent
commit
f8371d6e2e

+ 5 - 2
Data/AtomicEditor/Resources/EditorData/AtomicEditor/typescript/ui/ProjectFrame.ts

@@ -66,6 +66,7 @@ class ProjectFrame extends ScriptWidget {
                 }
 
                 var asset = db.getAssetByGUID(id);
+
                 if (asset) {
 
                   if (asset.isFolder()) {
@@ -73,11 +74,13 @@ class ProjectFrame extends ScriptWidget {
                     this.folderList.selectItemByID(id);
                     this.refreshContent(asset);
 
-                  }
+                  } else {
 
-                }
+                    this.sendEvent("EditResource", { "path": asset.path });
 
+                  }
 
+                }
 
             }
 

+ 11 - 1
Source/ToolCore/Assets/Asset.cpp

@@ -3,6 +3,7 @@
 
 #include "ModelImporter.h"
 #include "FolderImporter.h"
+#include "SceneImporter.h"
 #include "Asset.h"
 
 namespace ToolCore
@@ -30,7 +31,7 @@ bool Asset::Import()
     return importer_->Import(guid_);
 }
 
-void Asset::SetPath(const String& path)
+bool Asset::SetPath(const String& path)
 {
     FileSystem* fs = GetSubsystem<FileSystem>();
 
@@ -54,8 +55,17 @@ void Asset::SetPath(const String& path)
                 name_ = GetFileName(path);
                 importer_ = new ModelImporter(context_);
             }
+            else if (ext == ".scene")
+            {
+                name_ = GetFileName(path);
+                importer_ = new SceneImporter(context_);
+            }
+
         }
 
+        if (importer_.Null())
+            return false;
+
         String assetPath = path + ".asset";
 
         if (fs->FileExists(assetPath))

+ 1 - 1
Source/ToolCore/Assets/Asset.h

@@ -26,7 +26,7 @@ public:
     const String& GetName() { return name_; }
 
     const String& GetPath() const { return path_; }
-    void SetPath(const String& path);
+    bool SetPath(const String& path);
 
     void SetDirty(bool dirty) { dirty_ = dirty; }
     bool IsDirty() const { return dirty_; }

+ 60 - 0
Source/ToolCore/Assets/SceneImporter.cpp

@@ -0,0 +1,60 @@
+
+#include "Asset.h"
+#include "AssetDatabase.h"
+#include "SceneImporter.h"
+
+namespace ToolCore
+{
+
+SceneImporter::SceneImporter(Context* context) : AssetImporter(context)
+{
+
+}
+
+SceneImporter::~SceneImporter()
+{
+
+}
+
+void SceneImporter::SetDefaults()
+{
+    AssetImporter::SetDefaults();
+}
+
+bool SceneImporter::Import(const String& guid)
+{
+    AssetDatabase* db = GetSubsystem<AssetDatabase>();
+    Asset* asset = db->GetAssetByGUID(guid);
+
+    if (!asset)
+        return false;
+
+    return true;
+}
+
+bool SceneImporter::LoadInternal()
+{
+    if (!AssetImporter::LoadInternal())
+        return false;
+
+    JSONValue root = json_->GetRoot();
+
+    JSONValue import = root.GetChild("SceneImporter", JSON_OBJECT);
+
+    return true;
+}
+
+bool SceneImporter::SaveInternal()
+{
+    if (!AssetImporter::SaveInternal())
+        return false;
+
+    JSONValue root = json_->GetRoot();
+
+    JSONValue import = root.CreateChild("SceneImporter");
+
+    return true;
+}
+
+
+}

+ 29 - 0
Source/ToolCore/Assets/SceneImporter.h

@@ -0,0 +1,29 @@
+
+#pragma once
+
+#include "AssetImporter.h"
+
+namespace ToolCore
+{
+
+class SceneImporter : public AssetImporter
+{
+    OBJECT(SceneImporter);
+
+public:
+    /// Construct.
+    SceneImporter(Context* context);
+    virtual ~SceneImporter();
+
+    virtual void SetDefaults();
+
+    bool Import(const String& guid);
+
+protected:
+
+    virtual bool LoadInternal();
+    virtual bool SaveInternal();
+
+};
+
+}