Sfoglia il codice sorgente

Resource drag and drop now works with path instead of UUIDs so that folders may be dragged as well
Fixed an exception when closing a modal window

Marko Pintera 10 anni fa
parent
commit
20fa7504ed

+ 1 - 1
BansheeEditor/Include/BsGUIResourceTreeView.h

@@ -10,7 +10,7 @@ namespace BansheeEngine
 {
 {
 	struct DraggedResources
 	struct DraggedResources
 	{
 	{
-		Vector<String> resourceUUIDs;
+		Vector<Path> resourcePaths;
 	};
 	};
 
 
 	class GUIResourceTreeView : public GUITreeView
 	class GUIResourceTreeView : public GUITreeView

+ 1 - 1
BansheeEditor/Include/BsGUISceneTreeView.h

@@ -7,7 +7,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	struct DraggedSceneObjects
+	struct BS_ED_EXPORT DraggedSceneObjects
 	{
 	{
 		DraggedSceneObjects(UINT32 numObjects);
 		DraggedSceneObjects(UINT32 numObjects);
 		~DraggedSceneObjects();
 		~DraggedSceneObjects();

+ 1 - 4
BansheeEditor/Source/BsGUIResourceTreeView.cpp

@@ -397,10 +397,7 @@ namespace BansheeEngine
 		{
 		{
 			ResourceTreeElement* resourceTreeElement = static_cast<ResourceTreeElement*>(selectedElement.element);
 			ResourceTreeElement* resourceTreeElement = static_cast<ResourceTreeElement*>(selectedElement.element);
 			internalDraggedResources->resourcePaths[cnt] = resourceTreeElement->mFullPath; 
 			internalDraggedResources->resourcePaths[cnt] = resourceTreeElement->mFullPath; 
-
-			String uuid;
-			if(gResources().getUUIDFromFilePath(internalDraggedResources->resourcePaths[cnt], uuid))
-				draggedResources->resourceUUIDs.push_back(uuid);
+			draggedResources->resourcePaths.push_back(internalDraggedResources->resourcePaths[cnt]);
 
 
 			cnt++;
 			cnt++;
 		}
 		}

+ 0 - 4
MBansheeEditor/ModalWindow.cs

@@ -56,7 +56,6 @@ namespace BansheeEditor
         private void OnDestroyInternal()
         private void OnDestroyInternal()
         {
         {
             GUI.Destroy();
             GUI.Destroy();
-            Internal_DestroyGUIPanel(mCachedPtr, GUI);
         }
         }
 
 
         protected virtual void OnWindowResized(int width, int height)
         protected virtual void OnWindowResized(int width, int height)
@@ -86,9 +85,6 @@ namespace BansheeEditor
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
         private static extern void Internal_InitializeGUIPanel(IntPtr nativeInstance, GUIPanel panel);
 
 
-        [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_DestroyGUIPanel(IntPtr nativeInstance, GUIPanel panel);
-
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
         private static extern int Internal_GetWidth(IntPtr nativeInstance);
 
 

+ 4 - 0
SBansheeEditor/Include/BsScriptDragDropManager.h

@@ -3,6 +3,7 @@
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptEditorPrerequisites.h"
 #include "BsScriptObject.h"
 #include "BsScriptObject.h"
 #include "BsDragAndDropManager.h"
 #include "BsDragAndDropManager.h"
+#include "BsPath.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -17,6 +18,9 @@ namespace BansheeEngine
 	private:
 	private:
 		ScriptDragDrop(MonoObject* instance);
 		ScriptDragDrop(MonoObject* instance);
 
 
+		static void sceneObjectDragDropFinalize(bool processed);
+		static void resourceDragDropFinalize(bool processed);
+
 		static bool internal_IsDragInProgress();
 		static bool internal_IsDragInProgress();
 		static bool internal_IsDropInProgress();
 		static bool internal_IsDropInProgress();
 		static MonoObject* internal_GetData();
 		static MonoObject* internal_GetData();

+ 6 - 2
SBansheeEditor/Source/BsGUIResourceField.cpp

@@ -212,7 +212,7 @@ namespace BansheeEngine
 	void GUIResourceField::dataDropped(void* data)
 	void GUIResourceField::dataDropped(void* data)
 	{
 	{
 		DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(data);
 		DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(data);
-		UINT32 numResources = (UINT32)draggedResources->resourceUUIDs.size();
+		UINT32 numResources = (UINT32)draggedResources->resourcePaths.size();
 
 
 		if (numResources <= 0)
 		if (numResources <= 0)
 			return;
 			return;
@@ -221,7 +221,11 @@ namespace BansheeEngine
 
 
 		for (UINT32 i = 0; i < numResources; i++)
 		for (UINT32 i = 0; i < numResources; i++)
 		{
 		{
-			String uuid = draggedResources->resourceUUIDs[i];
+			Path path = draggedResources->resourcePaths[i];
+
+			String uuid;
+			if (!gResources().getUUIDFromFilePath(draggedResources->resourcePaths[i], uuid))
+				continue;
 
 
 			ProjectResourceMetaPtr meta = ProjectLibrary::instance().findResourceMeta(uuid);
 			ProjectResourceMetaPtr meta = ProjectLibrary::instance().findResourceMeta(uuid);
 			if (meta == nullptr)
 			if (meta == nullptr)

+ 19 - 4
SBansheeEditor/Source/BsScriptDragDropManager.cpp

@@ -53,13 +53,29 @@ namespace BansheeEngine
 			idx++;
 			idx++;
 		}
 		}
 
 
-		DragAndDropManager::instance().startDrag((UINT32)DragAndDropType::SceneObject, draggedSceneObjects, nullptr, false);
+		DragAndDropManager::instance().startDrag((UINT32)DragAndDropType::SceneObject, draggedSceneObjects, 
+			&ScriptDragDrop::sceneObjectDragDropFinalize, false);
 	}
 	}
 
 
 	void ScriptDragDrop::internal_StartResourceDrag(ScriptResourceDragDropData* value)
 	void ScriptDragDrop::internal_StartResourceDrag(ScriptResourceDragDropData* value)
 	{
 	{
-		// TODO
+		DraggedResources* draggedResources = bs_new<DraggedResources>();
+		draggedResources->resourcePaths = value->getPaths();
 
 
+		DragAndDropManager::instance().startDrag((UINT32)DragAndDropType::Resources, draggedResources, 
+			&ScriptDragDrop::resourceDragDropFinalize, false);
+	}
+
+	void ScriptDragDrop::sceneObjectDragDropFinalize(bool processed)
+	{
+		DraggedSceneObjects* draggedSceneObjects = reinterpret_cast<DraggedSceneObjects*>(DragAndDropManager::instance().getDragData());
+		bs_delete(draggedSceneObjects);
+	}
+
+	void ScriptDragDrop::resourceDragDropFinalize(bool processed)
+	{
+		DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(DragAndDropManager::instance().getDragData());
+		bs_delete(draggedResources);
 	}
 	}
 
 
 	ScriptSceneObjectDragDropData::ScriptSceneObjectDragDropData(MonoObject* instance, const Vector<HSceneObject>& sceneObjects)
 	ScriptSceneObjectDragDropData::ScriptSceneObjectDragDropData(MonoObject* instance, const Vector<HSceneObject>& sceneObjects)
@@ -238,8 +254,7 @@ namespace BansheeEngine
 		{
 		{
 			DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(DragAndDropManager::instance().getDragData());
 			DraggedResources* draggedResources = reinterpret_cast<DraggedResources*>(DragAndDropManager::instance().getDragData());
 
 
-			// TODO - When dragging resources I also need to support dragging of resource folders, which isn't supported by this system
-
+			mDroppedPaths = draggedResources->resourcePaths;
 			mIsDropInProgress = true;
 			mIsDropInProgress = true;
 			mDropType = ScriptDragDropType::Resource;
 			mDropType = ScriptDragDropType::Resource;
 			mDroppedFrameIdx = Time::instance().getFrameNumber();
 			mDroppedFrameIdx = Time::instance().getFrameNumber();

+ 39 - 27
TODO.txt

@@ -1,11 +1,13 @@
 --------- ALL LONG TERM TASKS / FIXES BELONG TO GOOGLE DOCS: ImplementationTODO OR PossibleImprovements ----------
 --------- ALL LONG TERM TASKS / FIXES BELONG TO GOOGLE DOCS: ImplementationTODO OR PossibleImprovements ----------
 
 
-<<<<<Assembly refresh>>>>>
+----------------------------------------------------------------------
+Assembly refresh
 
 
 When serializing Camera I cannot save the reference to RenderTexture. Make it a Resource?
 When serializing Camera I cannot save the reference to RenderTexture. Make it a Resource?
 Possibly set up automatic refresh in debug mode after initialization? As an ad-hoc unit test
 Possibly set up automatic refresh in debug mode after initialization? As an ad-hoc unit test
 
 
-<<<<<Simple stuff>>>>>>
+----------------------------------------------------------------------
+Simple stuff
 
 
 C#:
 C#:
 Dialog.Show(title, text, btn1 text, btn1 callback, btn2 text, btn2 callback, btn3 text, btn3 callback)
 Dialog.Show(title, text, btn1 text, btn1 callback, btn2 text, btn2 callback, btn3 text, btn3 callback)
@@ -13,10 +15,12 @@ Dialog.Show(title, text, btn1 text, btn1 callback, btn2 text, btn2 callback, btn
 ColorPicker
 ColorPicker
  - Sliders don't show up
  - Sliders don't show up
 
 
-Got a crash on shutdown that was caused by locking a mutex in an Event destructor. Event was Platform::onMouseCaptureChanged. 
-Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.
+Other simple stuff:
+ - VS integration (open VS project on doubleclick, generate project files, open on specific line)
+ - C# wrapper for GUISkin (and a way to assign the current skin to a window)
 
 
-<<<<<<Handles>>>>>>>>
+----------------------------------------------------------------------
+Handles
 
 
 When scaling using center make sure to offset the object before scale
 When scaling using center make sure to offset the object before scale
 Handles should probably not having shading, or have better shading.
 Handles should probably not having shading, or have better shading.
@@ -28,15 +32,42 @@ Rotate handle:
 
 
 Ideally free scale handle indicator should always render and be interactable and never be hidden by axis scale indicators (Not high priority)
 Ideally free scale handle indicator should always render and be interactable and never be hidden by axis scale indicators (Not high priority)
 
 
-<<<<Multi-resource saving>>>>:
+----------------------------------------------------------------------
+Scene View
+
+IMPROVE SceneGrid LOOK - Use the shader created in Unity
+
+AFTER I have scene widget in C#:
+ - Test custom handles from C#
+ - Test handle snapping
+
+Need a way to drag and drop items from Scene tree view to Scene view
+ - When dragging a mesh it should by default create a SceneObject with a renderable
+ - I might want a C# DragAndDrop class? It can contain Resource or SceneObject only for now, similar to Selection
+
+----------------------------------------------------------------------
+Other
+
+Got a crash on shutdown that was caused by locking a mutex in an Event destructor. Event was Platform::onMouseCaptureChanged. 
+Issue happened when I closed the app via the X button (if that's relevant). It doesn't seem to happen always.
+
+Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it.
+ - These methods are called often and cause allocations whenever they are.
+
+Add ProjectWindow and HierarchyWindow to C#
+ - Make TreeViews a C# element?
+Set up a default layout and save it
+
+----------------------------------------------------------------------
+Multi-resource saving
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Modify Font so it doesn't contain a texture, but instead keeps a handle to it
  - Register it in its meta file
  - Register it in its meta file
  - When saving such a resource with dependencies save the contained files to a sub-directory with the same name as top level resource
  - When saving such a resource with dependencies save the contained files to a sub-directory with the same name as top level resource
    - If it already exists in the manifest at a different location do it anyway, keep the other copy as-is in case user wanted it that way
    - If it already exists in the manifest at a different location do it anyway, keep the other copy as-is in case user wanted it that way
    - I'm not sure whether to do this for all Resource::save calls or only ones originating from ProjectLIbrary?
    - I'm not sure whether to do this for all Resource::save calls or only ones originating from ProjectLIbrary?
 
 
-Other:
-Window resize end callback
+----------------------------------------------------------------------
+Mono notes
 
 
 I can get mono errors by checking g_print calls in goutput.c
 I can get mono errors by checking g_print calls in goutput.c
  - Calling thunks incorrectly can cause those weird errors with no real callstack
  - Calling thunks incorrectly can cause those weird errors with no real callstack
@@ -51,25 +82,6 @@ Mono cannot marshal structures? Taken from their documentation:
  Internal calls do not provide support for marshalling structures. This means that any API calls that take a structure 
  Internal calls do not provide support for marshalling structures. This means that any API calls that take a structure 
  (excluding the system types like int32, int64, etc) must be passed as a pointer, in C# this means passing the value as a "ref" or "out" parameter.
  (excluding the system types like int32, int64, etc) must be passed as a pointer, in C# this means passing the value as a "ref" or "out" parameter.
 
 
-Create a stack allocatable custom vector implementation and make getResourceDependencies and getCoreDependencies use it.
- - These methods are called often and cause allocations whenever they are.
-
-C# SceneView:
-Test new Scene window and fix every issue
-Add ProjectWindow and HierarchyWindow to C#
- - Make TreeViews a C# element?
-Set up a default layout and save it
-
-Need a way to drag and drop items from Scene tree view to Scene view
- - When dragging a mesh it should by default create a SceneObject with a renderable
- - I might want a C# DragAndDrop class? It can contain Resource or SceneObject only for now, similar to Selection
-
-AFTER I have scene widget in C#:
- - Test custom handles from C#
- - Test handle snapping
-
-IMPROVE SceneGrid LOOK - Use the shader created in Unity
-
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 SelectionRenderer
 SelectionRenderer