Преглед изворни кода

Display material name in material inspector, add some missing ambient TypeScript decl, support files changing from underneath AssetDatabase

Josh Engebretson пре 10 година
родитељ
комит
3e73fd49c4

+ 2 - 0
Script/AtomicEditor/ui/inspector/MaterialInspector.ts

@@ -380,6 +380,8 @@ class MaterialInspector extends ScriptWidget {
         lp.width = 140;
         field.layoutParams = lp;
 
+        field.text = material.name;
+
         var texture = material.getTexture(Atomic.TU_DIFFUSE);
 
         if (texture)

+ 6 - 1
Script/Packages/Atomic/Scene.json

@@ -37,7 +37,12 @@
 			"getChildrenWithName(name:string, recursive?:boolean):Node[];",
 			"getChildrenWithComponent(componentType:string, recursive?:boolean):Node[];",
 			"getComponents(componentType?:string, recursive?:boolean):Component[];",
-			"getChildAtIndex(index:number):Node;"
+			"getChildAtIndex(index:number):Node;",
+			"createJSComponent(name:string, args?:{});",
+			"getJSComponent(name:string):JSComponent;"
+		],
+		"Scene" : [
+			"getMainCamera():Camera;"
 		]
 	}
 

+ 3 - 0
Script/TypeScript/Atomic.d.ts

@@ -1799,6 +1799,8 @@ declare module Atomic {
       getChildrenWithComponent(componentType:string, recursive?:boolean):Node[];
       getComponents(componentType?:string, recursive?:boolean):Component[];
       getChildAtIndex(index:number):Node;
+      createJSComponent(name:string, args?:{});
+      getJSComponent(name:string):JSComponent;
 
    }
 
@@ -1936,6 +1938,7 @@ declare module Atomic {
       getVarNamesAttr(): string;
       // Prepare network update by comparing attributes and marking replication states dirty as necessary.
       prepareNetworkUpdate(): void;
+      getMainCamera():Camera;
 
    }
 

+ 2 - 0
Source/AtomicEditor/Editors/ResourceEditor.cpp

@@ -95,6 +95,7 @@ ResourceEditor::~ResourceEditor()
 
 void ResourceEditor::HandleFileChanged(StringHash eventType, VariantMap& eventData)
 {
+    /*
     using namespace FileChanged;
     const String& fileName = eventData[P_FILENAME].GetString();
     const String& resourceName = eventData[P_RESOURCENAME].GetString();
@@ -105,6 +106,7 @@ void ResourceEditor::HandleFileChanged(StringHash eventType, VariantMap& eventDa
         if (!fs->FileExists(fullpath_))
             Close();
     }
+    */
 }
 
 void ResourceEditor::Close(bool navigateToAvailableResource)

+ 12 - 2
Source/ToolCore/Assets/Asset.cpp

@@ -62,7 +62,7 @@ String Asset::GetRelativePath()
 
 bool Asset::CheckCacheFile()
 {
-    if (importer_.Null() || !importer_->RequiresCacheFile())
+    if (importer_.Null())
         return true;
 
     FileSystem* fs = GetSubsystem<FileSystem>();
@@ -71,8 +71,18 @@ bool Asset::CheckCacheFile()
 
     String cacheFile = cachePath + guid_;
 
-    if (!fs->FileExists(cacheFile) || fs->GetLastModifiedTime(cacheFile) < fs->GetLastModifiedTime(path_))
+    unsigned modifiedTime = fs->GetLastModifiedTime(path_);
+
+    if (importer_->RequiresCacheFile()) {
+
+        if (!fs->FileExists(cacheFile) || fs->GetLastModifiedTime(cacheFile) < modifiedTime)
+            return false;
+    }
+
+    if (fs->GetLastModifiedTime(GetDotAssetFilename()) < modifiedTime)
+    {
         return false;
+    }
 
     return true;
 }

+ 38 - 0
Source/ToolCore/Assets/AssetDatabase.cpp

@@ -6,6 +6,7 @@
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/Math/Random.h>
 
+#include <Atomic/Resource/ResourceEvents.h>
 #include <Atomic/Resource/ResourceCache.h>
 
 #include "../ToolEvents.h"
@@ -22,6 +23,7 @@ AssetDatabase::AssetDatabase(Context* context) : Object(context)
 {
     SubscribeToEvent(E_PROJECTLOADED, HANDLER(AssetDatabase, HandleProjectLoaded));
     SubscribeToEvent(E_PROJECTUNLOADED, HANDLER(AssetDatabase, HandleProjectUnloaded));
+    SubscribeToEvent(E_FILECHANGED, HANDLER(AssetDatabase, HandleFileChanged));
 }
 
 AssetDatabase::~AssetDatabase()
@@ -413,5 +415,41 @@ void AssetDatabase::HandleProjectUnloaded(StringHash eventType, VariantMap& even
     project_ = 0;
 }
 
+void AssetDatabase::HandleFileChanged(StringHash eventType, VariantMap& eventData)
+{
+    using namespace FileChanged;
+    const String& fullPath = eventData[P_FILENAME].GetString();
+
+    FileSystem* fs = GetSubsystem<FileSystem>();
+
+    String pathName, fileName, ext;
+
+    SplitPath(fullPath, pathName, fileName, ext);
+
+    Asset* asset = GetAssetByPath(fullPath);
+
+    if (!asset && fs->FileExists(fullPath))
+    {
+        Scan();
+        return;
+    }
+
+    if (asset)
+    {
+        if(!fs->FileExists(fullPath))
+        {
+            DeleteAsset(asset);
+        }
+        else
+        {
+            asset->SetDirty(true);
+            Scan();
+        }
+
+    }
+
+
+}
+
 
 }

+ 1 - 0
Source/ToolCore/Assets/AssetDatabase.h

@@ -46,6 +46,7 @@ private:
 
     void HandleProjectLoaded(StringHash eventType, VariantMap& eventData);
     void HandleProjectUnloaded(StringHash eventType, VariantMap& eventData);
+    void HandleFileChanged(StringHash eventType, VariantMap& eventData);
 
     void AddAsset(SharedPtr<Asset>& asset);