Bladeren bron

Folder monitor now works properly after assembly refresh
Folder monitor ignores hidden files
Project library now properly checks if a resource is out of date

BearishSun 10 jaren geleden
bovenliggende
commit
7b1e1aa99c

+ 11 - 22
BansheeCore/Source/Win32/BsWin32FolderMonitor.cpp

@@ -130,7 +130,6 @@ namespace BansheeEngine
 		WString getFileName() const;
 		WString getFileName() const;
 		WString getFileNameWithPath(const Path& rootPath) const;
 		WString getFileNameWithPath(const Path& rootPath) const;
 
 
-	
 	protected:
 	protected:
 		UINT8* mBuffer;
 		UINT8* mBuffer;
 		DWORD mBufferSize;
 		DWORD mBufferSize;
@@ -581,39 +580,29 @@ namespace BansheeEngine
 
 
 		do
 		do
 		{
 		{
+			WString fullPath = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor);
+
+			// Ignore notifications about hidden files
+			if ((GetFileAttributesW(fullPath.c_str()) & FILE_ATTRIBUTE_HIDDEN) != 0)
+				continue;
+
 			switch(notifyInfo.getAction())
 			switch(notifyInfo.getAction())
 			{
 			{
 			case FILE_ACTION_ADDED:
 			case FILE_ACTION_ADDED:
-				{
-					WString fileName = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor); 
-					mActions.push_back(FileAction::createAdded(fileName));
-				}
+					mActions.push_back(FileAction::createAdded(fullPath));
 				break;
 				break;
 			case FILE_ACTION_REMOVED:
 			case FILE_ACTION_REMOVED:
-				{
-					WString fileName = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor); 
-					mActions.push_back(FileAction::createRemoved(fileName));
-				}
+					mActions.push_back(FileAction::createRemoved(fullPath));
 				break;
 				break;
 			case FILE_ACTION_MODIFIED:
 			case FILE_ACTION_MODIFIED:
-				{
-					WString fileName = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor); 
-					mActions.push_back(FileAction::createModified(fileName));
-				}
+					mActions.push_back(FileAction::createModified(fullPath));
 				break;
 				break;
 			case FILE_ACTION_RENAMED_OLD_NAME:
 			case FILE_ACTION_RENAMED_OLD_NAME:
-				{
-					WString fileName = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor);
-					watchInfo.mCachedOldFileName = fileName;
-				}
+					watchInfo.mCachedOldFileName = fullPath;
 				break;
 				break;
 			case FILE_ACTION_RENAMED_NEW_NAME:
 			case FILE_ACTION_RENAMED_NEW_NAME:
-				{
-					WString fileName = notifyInfo.getFileNameWithPath(watchInfo.mFolderToMonitor);
-					mActions.push_back(FileAction::createRenamed(watchInfo.mCachedOldFileName, fileName));
-				}
+					mActions.push_back(FileAction::createRenamed(watchInfo.mCachedOldFileName, fullPath));
 				break;
 				break;
-
 			}
 			}
     
     
 		} while(notifyInfo.getNext());
 		} while(notifyInfo.getNext());

+ 3 - 3
BansheeEditor/Source/BsEditorApplication.cpp

@@ -235,11 +235,11 @@ namespace BansheeEngine
 		buildDataPath.append(BUILD_DATA_PATH);
 		buildDataPath.append(BUILD_DATA_PATH);
 
 
 		BuildManager::instance().load(buildDataPath);
 		BuildManager::instance().load(buildDataPath);
-
-		// Do this before restoring windows and loading library to ensure types are loaded
-		ScriptManager::instance().reload();
 		gProjectLibrary().loadLibrary();
 		gProjectLibrary().loadLibrary();
 
 
+		// Do this before restoring windows to ensure types are loaded
+		ScriptManager::instance().reload();
+		
 		EditorWidgetLayoutPtr layout = loadWidgetLayout();
 		EditorWidgetLayoutPtr layout = loadWidgetLayout();
 		if (layout != nullptr)
 		if (layout != nullptr)
 			EditorWidgetManager::instance().setLayout(layout);
 			EditorWidgetManager::instance().setLayout(layout);

+ 4 - 4
BansheeEditor/Source/BsProjectLibrary.cpp

@@ -480,14 +480,14 @@ namespace BansheeEngine
 		if(resource->meta == nullptr)
 		if(resource->meta == nullptr)
 			return false;
 			return false;
 
 
-		Path path;
-		if(!mResourceManifest->uuidToFilePath(resource->meta->getUUID(), path))
+		Path internalPath;
+		if(!mResourceManifest->uuidToFilePath(resource->meta->getUUID(), internalPath))
 			return false;
 			return false;
 
 
-		if(!FileSystem::isFile(path))
+		if(!FileSystem::isFile(internalPath))
 			return false;
 			return false;
 
 
-		std::time_t lastModifiedTime = FileSystem::getLastModifiedTime(path);
+		std::time_t lastModifiedTime = FileSystem::getLastModifiedTime(resource->path);
 		return lastModifiedTime <= resource->lastUpdateTime;
 		return lastModifiedTime <= resource->lastUpdateTime;
 	}
 	}
 
 

+ 8 - 0
MBansheeEditor/EditorApplication.cs

@@ -167,6 +167,14 @@ namespace BansheeEditor
             inputConfig.RegisterButton(SceneWindow.RotateToolBinding, ButtonCode.E);
             inputConfig.RegisterButton(SceneWindow.RotateToolBinding, ButtonCode.E);
             inputConfig.RegisterButton(SceneWindow.ScaleToolBinding, ButtonCode.R);
             inputConfig.RegisterButton(SceneWindow.ScaleToolBinding, ButtonCode.R);
             inputConfig.RegisterButton(SceneWindow.DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);
             inputConfig.RegisterButton(SceneWindow.DuplicateBinding, ButtonCode.D, ButtonModifier.Ctrl);
+
+            if (IsProjectLoaded)
+            {
+                monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
+                monitor.OnAdded += OnAssetModified;
+                monitor.OnRemoved += OnAssetModified;
+                monitor.OnModified += OnAssetModified;
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 1 - 1
SBansheeEngine/Source/BsScriptMaterial.cpp

@@ -16,7 +16,7 @@ namespace BansheeEngine
 	ScriptMaterial::ScriptMaterial(MonoObject* instance, const HMaterial& material)
 	ScriptMaterial::ScriptMaterial(MonoObject* instance, const HMaterial& material)
 		:TScriptResource(instance, material)
 		:TScriptResource(instance, material)
 	{
 	{
-
+		int a = 5;
 	}
 	}
 
 
 	void ScriptMaterial::initRuntimeData()
 	void ScriptMaterial::initRuntimeData()