Răsfoiți Sursa

Added various missing menu bar items

BearishSun 10 ani în urmă
părinte
comite
e9f413f71b

+ 12 - 20
BansheeEditor/Include/BsGUISceneTreeView.h

@@ -101,6 +101,18 @@ namespace BansheeEngine
 		 */
 		void ping(const HSceneObject& object);
 
+		/** @copydoc GUITreeView::duplicateSelection */
+		void duplicateSelection() override;
+
+		/** @copydoc GUITreeView::copySelection */
+		void copySelection() override;
+		
+		/** @copydoc GUITreeView::cutSelection */
+		void cutSelection() override;
+
+		/** @copydoc GUITreeView::paste */
+		void paste() override;
+
 		/** Triggered whenever the selection changes. Call getSelection() to retrieve new selection. */
 		Event<void()> onSelectionChanged; 
 
@@ -202,26 +214,6 @@ namespace BansheeEngine
 		 */
 		SceneTreeElement* findTreeElement(const HSceneObject& so);
 
-		/**
-		 * @copydoc	GUITreeView::duplicateSelection
-		 */
-		void duplicateSelection() override;
-
-		/**
-		 * @copydoc	GUITreeView::copySelection
-		 */
-		void copySelection() override;
-		
-		/**
-		 * @copydoc	GUITreeView::cutSelection
-		 */
-		void cutSelection() override;
-
-		/**
-		 * @copydoc	GUITreeView::paste
-		 */
-		void paste() override;
-
 		/**
 		 * @brief	Creates a new scene object as a child of the currently selected object (if any).
 		 */

+ 17 - 30
BansheeEditor/Include/BsGUITreeView.h

@@ -99,14 +99,26 @@ namespace BansheeEngine
 		};
 
 	public:
-		/**
-		 * Returns type name of the GUI element used for finding GUI element styles. 
-		 */
+		/** Returns type name of the GUI element used for finding GUI element styles. */
 		static const String& getGUITypeName();
 
+		/** Deletes all currently selected elements. */
+		void deleteSelection();
+
+		/** Duplicates the currently selected entries. */
+		virtual void duplicateSelection() { }
+
+		/**	Marks the current selection for copying. */
+		virtual void copySelection() { }
+		
+		/**	Marks the current selection for cutting. */
+		virtual void cutSelection() { }
+
+		/**	Pastes a set of entries previously marked for cut or copy. */
+		virtual void paste() { }
+
 		/**
-		 * @brief	Updates tree view if dirty, among other operations.
-		 *			Must be called every frame. 
+		 * Updates tree view if dirty, among other operations. Must be called every frame. 
 		 *
 		 * @note	Internal method.
 		 */
@@ -264,11 +276,6 @@ namespace BansheeEngine
 		 */
 		void renameSelected();
 
-		/**
-		 * @brief	Deletes all currently selected elements.
-		 */
-		void deleteSelection();
-
 		/**
 		 * @brief	Expands all parents of the provided TreeElement making it interactable.
 		 */
@@ -284,26 +291,6 @@ namespace BansheeEngine
 		 */
 		void collapseElement(TreeElement* element);
 
-		/**
-		 * @brief	Duplicates the currently selected entries.
-		 */
-		virtual void duplicateSelection() { }
-
-		/**
-		 * @brief	Marks the current selection for copying.
-		 */
-		virtual void copySelection() { }
-		
-		/**
-		 * @brief	Marks the current selection for cutting.
-		 */
-		virtual void cutSelection() { }
-
-		/**
-		 * @brief	Pastes a set of entries previously marked for cut or copy.
-		 */
-		virtual void paste() { }
-
 		/**
 		 * @brief	Rebuilds the needed GUI elements for the provided TreeElement.
 		 */

+ 55 - 0
MBansheeEditor/GUI/GUISceneTreeView.cs

@@ -42,6 +42,46 @@ namespace BansheeEditor
             Internal_Update(mCachedPtr);
         }
 
+        /// <summary>
+        /// Cuts the currently selected scene object.
+        /// </summary>
+        public void CutSelection()
+        {
+            Internal_CutSelection(mCachedPtr);
+        }
+
+        /// <summary>
+        /// Copies the currently selected scene object.
+        /// </summary>
+        public void CopySelection()
+        {
+            Internal_CopySelection(mCachedPtr);
+        }
+
+        /// <summary>
+        /// Pastes the scene object(s) that were previously cut or copied.
+        /// </summary>
+        public void PasteToSelection()
+        {
+            Internal_PasteToSelection(mCachedPtr);
+        }
+
+        /// <summary>
+        /// Deletes currently selected scene objects.
+        /// </summary>
+        public void DeleteSelection()
+        {
+            Internal_DeleteSelection(mCachedPtr);
+        }
+
+        /// <summary>
+        /// Duplicates currently selected scene objects.
+        /// </summary>
+        public void DuplicateSelection()
+        {
+            Internal_DuplicateSelection(mCachedPtr);
+        }
+
         /// <summary>
         /// Triggered by the runtime when the scene is modified from the native scene tree view.
         /// </summary>
@@ -109,5 +149,20 @@ namespace BansheeEditor
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_Update(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CutSelection(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CopySelection(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_PasteToSelection(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DeleteSelection(IntPtr thisPtr);
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_DuplicateSelection(IntPtr thisPtr);
     }
 }

+ 81 - 41
MBansheeEditor/HierarchyWindow.cs

@@ -1,41 +1,81 @@
-using BansheeEngine;
-
-namespace BansheeEditor
-{
-    /// <summary>
-    /// Editor window that displays the scene hierarchy tree view, displaying all scene objects in the current scene.
-    /// </summary>
-    public class HierarchyWindow : EditorWindow
-    {
-        private GUISceneTreeView treeView;
-
-        /// <summary>
-        /// Opens the hierarchy window.
-        /// </summary>
-        [MenuItem("Windows/Hierarchy", ButtonModifier.CtrlAlt, ButtonCode.H, 6000)]
-        private static void OpenHierarchyWindow()
-        {
-            OpenWindow<HierarchyWindow>();
-        }
-
-        /// <inheritdoc/>
-        protected override LocString GetDisplayName()
-        {
-            return new LocEdString("Hierarchy");
-        }
-
-        private void OnInitialize()
-        {
-            GUIScrollArea scrollArea = new GUIScrollArea();
-            GUI.AddElement(scrollArea);
-
-            treeView = new GUISceneTreeView();
-            scrollArea.Layout.AddElement(treeView);
-        }
-
-        private void OnEditorUpdate()
-        {
-            treeView.Update();
-        }
-    }
-}
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /// <summary>
+    /// Editor window that displays the scene hierarchy tree view, displaying all scene objects in the current scene.
+    /// </summary>
+    public class HierarchyWindow : EditorWindow
+    {
+        private GUISceneTreeView treeView;
+
+        /// <summary>
+        /// Opens the hierarchy window.
+        /// </summary>
+        [MenuItem("Windows/Hierarchy", ButtonModifier.CtrlAlt, ButtonCode.H, 6000)]
+        private static void OpenHierarchyWindow()
+        {
+            OpenWindow<HierarchyWindow>();
+        }
+
+        /// <inheritdoc/>
+        protected override LocString GetDisplayName()
+        {
+            return new LocEdString("Hierarchy");
+        }
+
+        /// <summary>
+        /// Cuts the currently selected scene object.
+        /// </summary>
+        public void CutSelection()
+        {
+            treeView.CutSelection();
+        }
+
+        /// <summary>
+        /// Copies the currently selected scene object.
+        /// </summary>
+        public void CopySelection()
+        {
+            treeView.CopySelection();
+        }
+
+        /// <summary>
+        /// Pastes the scene object(s) that were previously cut or copied.
+        /// </summary>
+        public void PasteToSelection()
+        {
+            treeView.PasteToSelection();
+        }
+
+        /// <summary>
+        /// Deletes currently selected scene objects.
+        /// </summary>
+        public void DeleteSelection()
+        {
+            treeView.DeleteSelection();
+        }
+
+        /// <summary>
+        /// Duplicates currently selected scene objects.
+        /// </summary>
+        public void DuplicateSelection()
+        {
+            treeView.DuplicateSelection();
+        }
+
+        private void OnInitialize()
+        {
+            GUIScrollArea scrollArea = new GUIScrollArea();
+            GUI.AddElement(scrollArea);
+
+            treeView = new GUISceneTreeView();
+            scrollArea.Layout.AddElement(treeView);
+        }
+
+        private void OnEditorUpdate()
+        {
+            treeView.Update();
+        }
+    }
+}

+ 144 - 0
MBansheeEditor/MenuItems.cs

@@ -252,5 +252,149 @@ namespace BansheeEditor
             Selection.SceneObject = so;
             EditorApplication.SetSceneDirty();
         }
+
+        /// <summary>
+        /// Applies changes from the prefab instance to the prefab resource.
+        /// </summary>
+        [MenuItem("Scene Objects/Apply prefab", 8025, true)]
+        private static void ApplyPrefab()
+        {
+            SceneObject so = Selection.SceneObject;
+            if (so == null)
+                return;
+
+            PrefabUtility.ApplyPrefab(so);
+        }
+
+        /// <summary>
+        /// Reverts a prefab instance to the original state of its prefab.
+        /// </summary>
+        [MenuItem("Scene Objects/Revert to prefab", 8024)]
+        private static void RevertToPrefab()
+        {
+            SceneObject so = Selection.SceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.RecordSO(so, true, "Reverting \"" + so.Name + "\" to prefab.");
+
+            PrefabUtility.RevertPrefab(so);
+            EditorApplication.SetSceneDirty();
+        }
+
+        /// <summary>
+        /// Breaks a link between a prefab and its instance.
+        /// </summary>
+        [MenuItem("Scene Objects/Break prefab link", 8023)]
+        private static void BreakPrefabLink()
+        {
+            SceneObject so = Selection.SceneObject;
+            if (so == null)
+                return;
+
+            UndoRedo.BreakPrefab(so, "Breaking prefab link for " + so.Name);
+            EditorApplication.SetSceneDirty();
+        }
+
+        /// <summary>
+        /// Cuts the currently selected scene object or resource.
+        /// </summary>
+        [MenuItem("Edit/Cut", 9450, true)]
+        public static void Cut()
+        {
+            if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
+            {
+                HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
+                if (win != null)
+                    win.CutSelection();
+            }
+            else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
+            {
+                LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+                if (win != null)
+                    win.CutSelection();
+            }
+        }
+
+        /// <summary>
+        /// Copies the currently selected scene object or resource.
+        /// </summary>
+        [MenuItem("Edit/Copy", 9449)]
+        public static void Copy()
+        {
+            if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
+            {
+                HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
+                if (win != null)
+                    win.CopySelection();
+            }
+            else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
+            {
+                LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+                if (win != null)
+                    win.CopySelection();
+            }
+        }
+
+        /// <summary>
+        /// Pastes the scene objects or resources that were previously cut or copied.
+        /// </summary>
+        [MenuItem("Edit/Paste", 9448)]
+        public static void Paste()
+        {
+            // TODO - This is slightly wrong in case both windows have something in their paste buffer (unify them?)
+
+            {
+                HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
+                if (win != null)
+                    win.PasteToSelection();
+            }
+
+            {
+                LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+                if (win != null)
+                    win.PasteToSelection();
+            }
+        }
+
+        /// <summary>
+        /// Deletes currently selected scene objects or resources.
+        /// </summary>
+        [MenuItem("Edit/Delete", 9447)]
+        public static void Delete()
+        {
+            if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
+            {
+                HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
+                if (win != null)
+                    win.DeleteSelection();
+            }
+            else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
+            {
+                LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+                if (win != null)
+                    win.DeleteSelection();
+            }
+        }
+
+        /// <summary>
+        /// Duplicates currently selected scene objects or resources.
+        /// </summary>
+        [MenuItem("Edit/Duplicate", 9446)]
+        public static void Duplicate()
+        {
+            if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
+            {
+                HierarchyWindow win = EditorWindow.GetWindow<HierarchyWindow>();
+                if (win != null)
+                    win.DuplicateSelection();
+            }
+            else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
+            {
+                LibraryWindow win = EditorWindow.GetWindow<LibraryWindow>();
+                if (win != null)
+                    win.DuplicateSelection();
+            }
+        }
     }
 }

+ 44 - 0
MBansheeEditor/Scene/SceneWindow.cs

@@ -111,6 +111,50 @@ namespace BansheeEditor
                 window.cameraController.FrameSelected();
         }
 
+        /// <summary>
+        /// Switches the active tool to the view tool.
+        /// </summary>
+        [MenuItem("Tools/View", ButtonModifier.Ctrl, ButtonCode.Q, 9274, true)]
+        private static void SetViewTool()
+        {
+            SceneWindow window = GetWindow<SceneWindow>();
+            if (window != null)
+                window.OnSceneToolButtonClicked(SceneViewTool.View);
+        }
+
+        /// <summary>
+        /// Switches the active tool to the move tool.
+        /// </summary>
+        [MenuItem("Tools/Move", ButtonModifier.Ctrl, ButtonCode.W, 9273)]
+        private static void SetMoveTool()
+        {
+            SceneWindow window = GetWindow<SceneWindow>();
+            if (window != null)
+                window.OnSceneToolButtonClicked(SceneViewTool.Move);
+        }
+
+        /// <summary>
+        /// Switches the active tool to the rotate tool.
+        /// </summary>
+        [MenuItem("Tools/Rotate", ButtonModifier.Ctrl, ButtonCode.E, 9272)]
+        private static void SetRotateTool()
+        {
+            SceneWindow window = GetWindow<SceneWindow>();
+            if (window != null)
+                window.OnSceneToolButtonClicked(SceneViewTool.Rotate);
+        }
+
+        /// <summary>
+        /// Switches the active tool to the scale tool.
+        /// </summary>
+        [MenuItem("Tools/Scale", ButtonModifier.Ctrl, ButtonCode.R, 9271)]
+        private static void SetScaleTool()
+        {
+            SceneWindow window = GetWindow<SceneWindow>();
+            if (window != null)
+                window.OnSceneToolButtonClicked(SceneViewTool.Scale);
+        }
+
         /// <inheritdoc/>
         protected override LocString GetDisplayName()
         {

+ 1 - 1
MBansheeEditor/UndoRedo.cs

@@ -34,7 +34,7 @@ namespace BansheeEditor
         /// <summary>
         /// Executes the last command on the redo stack (last command we called undo on), re-applying its operation.
         /// </summary>
-        [MenuItem("Edit/Redo", 9499, true)]
+        [MenuItem("Edit/Redo", 9499)]
         [ToolbarItem("Redo", ToolbarIcon.Redo, "Redo (Ctrl + Y)", 1899)]
         public static void Redo()
         {

+ 5 - 0
SBansheeEditor/Include/BsScriptGUISceneTreeView.h

@@ -29,6 +29,11 @@ namespace BansheeEngine
 		/************************************************************************/
 		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
 		static void internal_update(ScriptGUISceneTreeView* thisPtr);
+		static void internal_cutSelection(ScriptGUISceneTreeView* thisPtr);
+		static void internal_copySelection(ScriptGUISceneTreeView* thisPtr);
+		static void internal_pasteToSelection(ScriptGUISceneTreeView* thisPtr);
+		static void internal_duplicateSelection(ScriptGUISceneTreeView* thisPtr);
+		static void internal_deleteSelection(ScriptGUISceneTreeView* thisPtr);
 
 		typedef void(__stdcall *OnModifiedThunkDef) (MonoObject*, MonoException**);
 		typedef void(__stdcall *OnResourceDroppedThunkDef) (MonoObject*, MonoObject*, MonoArray*, MonoException**);

+ 35 - 0
SBansheeEditor/Source/BsScriptGUISceneTreeView.cpp

@@ -34,6 +34,11 @@ namespace BansheeEngine
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUISceneTreeView::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_Update", &ScriptGUISceneTreeView::internal_update);
+		metaData.scriptClass->addInternalCall("Internal_CutSelection", &ScriptGUISceneTreeView::internal_cutSelection);
+		metaData.scriptClass->addInternalCall("Internal_CopySelection", &ScriptGUISceneTreeView::internal_copySelection);
+		metaData.scriptClass->addInternalCall("Internal_PasteToSelection", &ScriptGUISceneTreeView::internal_pasteToSelection);
+		metaData.scriptClass->addInternalCall("Internal_DuplicateSelection", &ScriptGUISceneTreeView::internal_duplicateSelection);
+		metaData.scriptClass->addInternalCall("Internal_DeleteSelection", &ScriptGUISceneTreeView::internal_deleteSelection);
 
 		onModifiedThunk = (OnModifiedThunkDef)metaData.scriptClass->getMethod("Internal_DoOnModified", 0)->getThunk();
 		onResourceDroppedThunk = (OnResourceDroppedThunkDef)metaData.scriptClass->getMethod("Internal_DoOnResourceDropped", 2)->getThunk();
@@ -84,4 +89,34 @@ namespace BansheeEngine
 		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
 		treeView->_update();
 	}
+
+	void ScriptGUISceneTreeView::internal_cutSelection(ScriptGUISceneTreeView* thisPtr)
+	{
+		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
+		treeView->cutSelection();
+	}
+
+	void ScriptGUISceneTreeView::internal_copySelection(ScriptGUISceneTreeView* thisPtr)
+	{
+		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
+		treeView->copySelection();
+	}
+
+	void ScriptGUISceneTreeView::internal_pasteToSelection(ScriptGUISceneTreeView* thisPtr)
+	{
+		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
+		treeView->paste();
+	}
+
+	void ScriptGUISceneTreeView::internal_duplicateSelection(ScriptGUISceneTreeView* thisPtr)
+	{
+		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
+		treeView->duplicateSelection();
+	}
+
+	void ScriptGUISceneTreeView::internal_deleteSelection(ScriptGUISceneTreeView* thisPtr)
+	{
+		GUISceneTreeView* treeView = static_cast<GUISceneTreeView*>(thisPtr->getGUIElement());
+		treeView->deleteSelection();
+	}
 }