Browse Source

Add external resource path with top priority in the editor.

Lasse Öörni 11 years ago
parent
commit
ce33db54a2
1 changed files with 44 additions and 43 deletions
  1. 44 43
      Bin/Data/Scripts/Editor/EditorScene.as

+ 44 - 43
Bin/Data/Scripts/Editor/EditorScene.as

@@ -136,8 +136,9 @@ void SetResourcePath(String newPath, bool usePreferredDir = true, bool additive
             cache.RemoveResourceDir(sceneResourcePath);
     }
 
-    cache.AddResourceDir(newPath);
-    RebuildResourceDatabase();
+    // Add resource path as first priority so that it takes precedence over the default data paths
+    cache.AddResourceDir(newPath, 0);
+    RebuildResourceDatabase();
 
     if (!additive)
     {
@@ -261,10 +262,10 @@ bool SaveSceneWithExistingName()
 
 Node@ CreateNode(CreateMode mode)
 {
-    Node@ newNode = null;
-    if (editNode !is null)
+    Node@ newNode = null;
+    if (editNode !is null)
         newNode = editNode.CreateChild("", mode);
-    else
+    else
         newNode = editorScene.CreateChild("", mode);
     // Set the new node a certain distance from the camera
     newNode.position = GetNewNodePosition();
@@ -356,7 +357,7 @@ Node@ LoadNode(const String&in fileName, Node@ parent = null)
         FocusNode(newNode);
         instantiateFileName = fileName;
     }
-    return newNode;
+    return newNode;
 }
 
 Node@ InstantiateNodeFromFile(File@ file, const Vector3& position, const Quaternion& rotation, float scaleMod = 1.0f, Node@ parent = null, CreateMode mode = REPLICATED)
@@ -993,11 +994,11 @@ void AssignMaterial(StaticModel@ model, String materialPath)
     if (material is null)
         return;
 
-    ResourceRefList materials = model.GetAttribute("Material").GetResourceRefList();
-    Array<String> oldMaterials;
-    for(uint i = 0; i < materials.length; ++i)
-        oldMaterials.Push(materials.names[i]);
-
+    ResourceRefList materials = model.GetAttribute("Material").GetResourceRefList();
+    Array<String> oldMaterials;
+    for(uint i = 0; i < materials.length; ++i)
+        oldMaterials.Push(materials.names[i]);
+
     model.material = material;
 
     AssignMaterialAction action;
@@ -1005,8 +1006,8 @@ void AssignMaterial(StaticModel@ model, String materialPath)
     SaveEditAction(action);
     SetSceneModified();
     FocusComponent(model); 
-}
-
+}
+
 void UpdateSceneMru(String filename)
 {
     while (uiRecentScenes.Find(filename) > -1)
@@ -1037,8 +1038,8 @@ Drawable@ GetFirstDrawable(Node@ node)
     }
     
     return null;
-}
-
+}
+
 void AssignModel(StaticModel@ assignee, String modelPath)
 {
     Model@ model = cache.GetResource("Model", modelPath);
@@ -1054,31 +1055,31 @@ void AssignModel(StaticModel@ assignee, String modelPath)
     SetSceneModified();
     FocusComponent(assignee); 
 }
-
-void CreateModelWithStaticModel(String filepath, Node@ parent)
-{
-    if (parent is null)
-        return;
-
-    Model@ model = cache.GetResource("Model", filepath);
-    if (model is null)
-        return;
-
-    StaticModel@ staticModel = cast<StaticModel>(editNode.CreateComponent("StaticModel"));
-    staticModel.model = model;
-    CreateLoadedComponent(staticModel);
-}
-
-void CreateModelWithAnimatedModel(String filepath, Node@ parent)
-{
-    if (parent is null)
-        return;
-
-    Model@ model = cache.GetResource("Model", filepath);
-    if (model is null)
-        return;
-
-    AnimatedModel@ animatedModel = cast<StaticModel>(editNode.CreateComponent("AnimatedModel"));
-    animatedModel.model = model;
-    CreateLoadedComponent(animatedModel);
-}
+
+void CreateModelWithStaticModel(String filepath, Node@ parent)
+{
+    if (parent is null)
+        return;
+
+    Model@ model = cache.GetResource("Model", filepath);
+    if (model is null)
+        return;
+
+    StaticModel@ staticModel = cast<StaticModel>(editNode.CreateComponent("StaticModel"));
+    staticModel.model = model;
+    CreateLoadedComponent(staticModel);
+}
+
+void CreateModelWithAnimatedModel(String filepath, Node@ parent)
+{
+    if (parent is null)
+        return;
+
+    Model@ model = cache.GetResource("Model", filepath);
+    if (model is null)
+        return;
+
+    AnimatedModel@ animatedModel = cast<StaticModel>(editNode.CreateComponent("AnimatedModel"));
+    animatedModel.model = model;
+    CreateLoadedComponent(animatedModel);
+}