Pārlūkot izejas kodu

Fixed shutdown so that all managed objects are unloaded before various script manager they may reference are shutdown
Added C# Hierarchy Window (WIP)
Fixed an issue when script is trying to access editor window that is currently being dragged and has no GUI parent
Fixed title bar tab closing so close method isn't called twice
Fixed MenuBarManager so it doesn't try to access editor window manager after it was destroyed
Cleanup of some debug code and menu bar

Marko Pintera 10 gadi atpakaļ
vecāks
revīzija
2f97794d25

+ 1 - 1
BansheeCore/Include/BsCoreApplication.h

@@ -90,7 +90,7 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	Module::onStartUp
 		 */
-		virtual void onStartUp();
+		virtual void onStartUp() override;
 
 		/**
 		 * @brief	Called for each iteration of the main loop. Called before any game objects or plugins are updated.

+ 2 - 2
BansheeEditor/Include/BsEditorApplication.h

@@ -37,8 +37,8 @@ namespace BansheeEngine
 		EditorSettingsPtr getEditorSettings() const { return mEditorSettings; }
 
 	private:
-		virtual void onStartUp();
-		virtual void onShutDown();
+		virtual void onStartUp() override;
+		virtual void onShutDown() override;
 		virtual void preUpdate() override;
 		virtual void postUpdate() override;
 

+ 1 - 1
BansheeEditor/Include/BsGUISceneTreeView.h

@@ -16,7 +16,7 @@ namespace BansheeEngine
 		HSceneObject* objects;
 	};
 
-	class GUISceneTreeView : public GUITreeView
+	class BS_ED_EXPORT GUISceneTreeView : public GUITreeView
 	{
 		struct SceneTreeElement : public GUITreeView::TreeElement
 		{

+ 1 - 1
BansheeEditor/Include/BsGUITreeView.h

@@ -7,7 +7,7 @@
 
 namespace BansheeEngine
 {
-	class GUITreeView : public GUIElementContainer
+	class BS_ED_EXPORT GUITreeView : public GUIElementContainer
 	{
 	protected:
 		enum class ScrollState

+ 16 - 22
BansheeEditor/Source/BsEditorApplication.cpp

@@ -71,25 +71,6 @@ namespace BansheeEngine
 
 	EditorApplication::~EditorApplication()
 	{
-		BuildManager::instance().save(BUILD_DATA_PATH);
-
-		CodeEditorManager::shutDown();
-		BuildManager::shutDown();
-		GizmoManager::shutDown();
-		Selection::shutDown();
-		ScenePicking::shutDown();
-
-		saveWidgetLayout(EditorWidgetManager::instance().getLayout());
-		// TODO - Save project settings
-
-		DropDownWindowManager::shutDown();
-		EditorWidgetManager::shutDown();
-		EditorWindowManager::shutDown();
-		UndoRedo::shutDown();
-
-		// We purposely don't unload this plugin, it needs to be unloaded after
-		// all mono assemblies have been unloaded (since their finalizers will call
-		// into the plugin). So we leave it to be unloaded automatically on app exit
 		shutdownPlugin(mSBansheeEditorPlugin);
 
 		/************************************************************************/
@@ -226,13 +207,26 @@ namespace BansheeEngine
 		/************************************************************************/
 		/* 							END DEBUG CODE                      		*/
 		/************************************************************************/
-
-		DbgEditorWidget1::open(); // DEBUG ONLY
-		DbgEditorWidget2::open(); // DEBUG ONLY
 	}
 
 	void EditorApplication::onShutDown()
 	{
+		BuildManager::instance().save(BUILD_DATA_PATH);
+
+		CodeEditorManager::shutDown();
+		BuildManager::shutDown();
+		GizmoManager::shutDown();
+		Selection::shutDown();
+		ScenePicking::shutDown();
+
+		saveWidgetLayout(EditorWidgetManager::instance().getLayout());
+		// TODO - Save project settings
+
+		DropDownWindowManager::shutDown();
+		EditorWidgetManager::shutDown();
+		EditorWindowManager::shutDown();
+		UndoRedo::shutDown();
+
 		Application::onShutDown();
 	}
 

+ 6 - 0
BansheeEditor/Source/BsEditorWidget.cpp

@@ -84,6 +84,9 @@ namespace BansheeEngine
 
 	Vector2I EditorWidgetBase::screenToWidgetPos(const Vector2I& screenPos) const
 	{
+		if (mParent == nullptr)
+			return screenPos;
+
 		EditorWindowBase* parentEditorWindow = mParent->getParentWindow();
 		RenderWindowPtr parentRenderWindow = parentEditorWindow->getRenderWindow();
 
@@ -96,6 +99,9 @@ namespace BansheeEngine
 
 	Vector2I EditorWidgetBase::widgetToScreenPos(const Vector2I& widgetPos) const
 	{
+		if (mParent == nullptr)
+			return widgetPos;
+
 		EditorWindowBase* parentEditorWindow = mParent->getParentWindow();
 		RenderWindowPtr parentRenderWindow = parentEditorWindow->getRenderWindow();
 

+ 0 - 3
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -212,9 +212,6 @@ namespace BansheeEngine
 	{
 		EditorWidgetBase* widget = mWidgets[uniqueIdx];
 		widget->close();
-
-		if(!onWidgetClosed.empty())
-			onWidgetClosed();
 	}
 
 	void EditorWidgetContainer::tabDraggedOff(UINT32 uniqueIdx)

+ 1 - 24
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -40,30 +40,7 @@ namespace BansheeEngine
 		mMenuBar->addMenuItem(L"File/New project", nullptr, 100);
 		mMenuBar->addMenuItem(L"File/Open project", nullptr, 100);
 		mMenuBar->addSeparator(L"File", 99);
-		mMenuBar->addMenuItem(L"File/Recent projects", nullptr, 98);
-		mMenuBar->addMenuItem(L"File/Recent projects/Project A", nullptr);
-		mMenuBar->addMenuItem(L"File/Recent projects/Project B", nullptr);
-		mMenuBar->addMenuItem(L"File/Recent projects/Project C", nullptr);
-		mMenuBar->addSeparator(L"File", 97);
-		mMenuBar->addMenuItem(L"File/Exit", nullptr, 96);
-		mMenuBar->addMenuItem(L"Window/Scene", nullptr);
-
-		//GameObjectHandle<TestTextSprite> textSprite = mSceneObject->addComponent<TestTextSprite>(mCamera->getViewport().get());
-
-		//textSprite->init(sceneCamera, "Testing in a new row, does this work?", sceneRenderTarget);
-
-		//DrawHelper2D::instance().drawQuad(sceneCamera, FRect(0.0f, 0.2f, 0.75f, 0.5f), Color::White, DebugDrawCoordType::Normalized, 250.0f);
-		//DrawHelper2D::instance().drawQuad(sceneCamera, FRect(50.0f, 50.0f, 100.0f, 50.0f), Color::Blue, DebugDrawCoordType::Pixel, 250.0f);
-
-		//DrawHelper2D::instance().drawLine_Pixel(sceneCamera, Vector2(0, 0), Vector2(20, 20), Color::Blue, DebugDrawCoordType::Pixel, 250.0f);
-
-		//DrawHelper2D::instance().drawLine_AA(sceneCamera, Vector2(100, 10), Vector2(120, 40), 1.0f, 1.0f, Color::Blue, DebugDrawCoordType::Pixel, 250.0f);
-
-		AABox dbgBox(Vector3(-300, -200, 1000), Vector3(300, 300, 1500));
-		//DrawHelper3D::instance().drawAABox(sceneCamera, dbgBox, Color::Green, 250.0f);
-
-		//mProfilerOverlay = mSceneObject->addComponent<ProfilerOverlay>(sceneCamera->getViewport());
-		//mProfilerOverlay->show(ProfilerOverlayType::CPUSamples);
+		mMenuBar->addMenuItem(L"File/Exit", nullptr, 98);
 
 		TestSuitePtr testSuite = TestSuite::create<EditorTestSuite>();
 		testSuite->run(ExceptionTestOutput());

+ 6 - 1
BansheeEngine/Include/BsApplication.h

@@ -73,7 +73,12 @@ namespace BansheeEngine
 		/**
 		 * @copydoc	Module::onStartUp
 		 */
-		virtual void onStartUp();
+		virtual void onStartUp() override;
+
+		/**
+		 * @copydoc	Module::onShutDown
+		 */
+		virtual void onShutDown() override;
 
 		/**
 		 * @copydoc	CoreApplication::postUpdate.

+ 20 - 12
BansheeEngine/Source/BsApplication.cpp

@@ -44,18 +44,6 @@ namespace BansheeEngine
 
 	Application::~Application()
 	{
-		// Need to clear all objects before I unload any plugins, as they
-		// could have allocated parts or all of those objects.
-		SceneManager::instance().clearScene(); 
-
-#if BS_VER == BS_VER_DEV
-		shutdownPlugin(mSBansheeEnginePlugin);
-		unloadPlugin(mSBansheeEnginePlugin);
-
-		shutdownPlugin(mMonoPlugin);
-		unloadPlugin(mMonoPlugin);
-#endif
-
 		// Cleanup any new objects queued for destruction by unloaded scripts
 		gCoreThread().update();
 		gCoreThread().submitAccessors(true);
@@ -98,6 +86,26 @@ namespace BansheeEngine
 		Cursor::instance().setCursor(CursorType::Arrow);
 	}
 
+	void Application::onShutDown()
+	{
+		// Need to clear all objects before I unload any plugins, as they
+		// could have allocated parts or all of those objects.
+		SceneManager::instance().clearScene();
+
+		// These plugins must be unloaded before any other script plugins, because
+		// they will cause finalizers to trigger and various modules those finalizers
+		// might reference must still be active
+#if BS_VER == BS_VER_DEV
+		shutdownPlugin(mSBansheeEnginePlugin);
+		unloadPlugin(mSBansheeEnginePlugin);
+
+		shutdownPlugin(mMonoPlugin);
+		unloadPlugin(mMonoPlugin);
+#endif
+
+		CoreApplication::onShutDown();
+	}
+
 	void Application::startUp(RENDER_WINDOW_DESC& primaryWindowDesc, RenderSystemPlugin renderSystem, RendererPlugin renderer)
 	{
 		CoreApplication::startUp<Application>(primaryWindowDesc, renderSystem, renderer);

+ 0 - 6
MBansheeEditor/DebugWindow.cs

@@ -38,12 +38,6 @@ namespace BansheeEditor
             overlay.AddElement(testExplicitBtn);
         }
 
-        [MenuItem("Window/Test", ButtonModifier.ShiftAlt, ButtonCode.A)]
-        private static void TestMenuItem()
-        {
-            ColorPicker.Show();
-        }
-
         void RefreshAssembly_OnClick()
         {
             Internal_RefreshAssembly();

+ 0 - 2
MBansheeEditor/EditorApplication.cs

@@ -75,7 +75,6 @@ namespace BansheeEditor
 
         private InspectorWindow inspector;
         private SceneWindow scene;
-        private DebugWindow debug;
 
         private FolderMonitor monitor;
 
@@ -106,7 +105,6 @@ namespace BansheeEditor
             // Open windows
             inspector = EditorWindow.OpenWindow<InspectorWindow>();
             scene = EditorWindow.OpenWindow<SceneWindow>();
-            debug = EditorWindow.OpenWindow<DebugWindow>();
 
             ProjectLibrary.Refresh();
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);

+ 22 - 0
MBansheeEditor/GUI/GUISceneTreeView.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Runtime.CompilerServices;
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    public sealed class GUISceneTreeView : GUIElement
+    {
+        public GUISceneTreeView(string style = "", params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, style, options);
+        }
+
+        public GUISceneTreeView(params GUIOption[] options)
+        {
+            Internal_CreateInstance(this, "", options);
+        }
+
+        [MethodImpl(MethodImplOptions.InternalCall)]
+        private static extern void Internal_CreateInstance(GUISceneTreeView instance, string style, GUIOption[] options);
+    }
+}

+ 22 - 0
MBansheeEditor/HierarchyWindow.cs

@@ -0,0 +1,22 @@
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    public class HierarchyWindow : EditorWindow
+    {
+        [MenuItem("Windows/Hierarchy", ButtonModifier.CtrlAlt, ButtonCode.H)]
+        private static void OpenHierarchyWindow()
+        {
+            OpenWindow<HierarchyWindow>();
+        }
+
+        private void OnInitialize()
+        {
+            GUIScrollArea scrollArea = new GUIScrollArea();
+            GUI.AddElement(scrollArea);
+
+            GUISceneTreeView treeView = new GUISceneTreeView();
+            scrollArea.Layout.AddElement(treeView);
+        }
+    }
+}

+ 6 - 0
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -18,6 +18,12 @@ namespace BansheeEditor
         private GUIScrollArea inspectorScrollArea;
         private GUILayout inspectorLayout;
 
+        [MenuItem("Windows/Inspector", ButtonModifier.CtrlAlt, ButtonCode.I)]
+        private static void OpenHierarchyWindow()
+        {
+            OpenWindow<HierarchyWindow>();
+        }
+
         internal void SetObjectToInspect(SceneObject so)
         {
             Clear();

+ 2 - 0
MBansheeEditor/MBansheeEditor.csproj

@@ -56,6 +56,8 @@
     <Compile Include="DragDrop.cs" />
     <Compile Include="DropDownWindow.cs" />
     <Compile Include="FolderMonitor.cs" />
+    <Compile Include="GUI\GUISceneTreeView.cs" />
+    <Compile Include="HierarchyWindow.cs" />
     <Compile Include="ProjectDropTarget.cs" />
     <Compile Include="OSDropTarget.cs" />
     <Compile Include="EditorApplication.cs" />

+ 1 - 1
MBansheeEditor/ProjectWindow.cs

@@ -381,7 +381,7 @@ namespace BansheeEditor
             set { viewType = value; Refresh(); }
         }
 
-        [MenuItem("Windows/Project", ButtonModifier.Ctrl, ButtonCode.P)]
+        [MenuItem("Windows/Project", ButtonModifier.CtrlAlt, ButtonCode.P)]
         private static void OpenProjectWindow()
         {
             OpenWindow<ProjectWindow>();

+ 6 - 0
MBansheeEditor/Scene/SceneWindow.cs

@@ -52,6 +52,12 @@ namespace BansheeEditor
         internal SceneWindow()
         { }
 
+        [MenuItem("Windows/Scene", ButtonModifier.CtrlAlt, ButtonCode.S)]
+        private static void OpenSceneWindow()
+        {
+            OpenWindow<SceneWindow>();
+        }
+
         private void OnInitialize()
         {
             mainLayout = GUI.AddLayoutY();

+ 18 - 0
SBansheeEditor/Include/BsScriptGUISceneTreeView.h

@@ -0,0 +1,18 @@
+#pragma once
+
+#include "BsScriptEditorPrerequisites.h"
+#include "BsScriptGUIElement.h"
+
+namespace BansheeEngine
+{
+	class BS_SCR_BED_EXPORT ScriptGUISceneTreeView : public TScriptGUIElement<ScriptGUISceneTreeView>
+	{
+	public:
+		SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "GUISceneTreeView")
+
+	private:
+		static void internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions);
+
+		ScriptGUISceneTreeView(MonoObject* instance, GUISceneTreeView* treeView);
+	};
+}

+ 2 - 0
SBansheeEditor/SBansheeEditor.vcxproj

@@ -242,6 +242,7 @@
     <ClInclude Include="Include\BsScriptDragDropManager.h" />
     <ClInclude Include="Include\BsScriptDropDownWindow.h" />
     <ClInclude Include="Include\BsScriptFolderMonitor.h" />
+    <ClInclude Include="Include\BsScriptGUISceneTreeView.h" />
     <ClInclude Include="Include\BsScriptOSDropTarget.h" />
     <ClInclude Include="Include\BsScriptEditorApplication.h" />
     <ClInclude Include="Include\BsScriptEditorBuiltin.h" />
@@ -288,6 +289,7 @@
     <ClCompile Include="Source\BsScriptBrowseDialog.cpp" />
     <ClCompile Include="Source\BsScriptDropDownWindow.cpp" />
     <ClCompile Include="Source\BsScriptFolderMonitor.cpp" />
+    <ClCompile Include="Source\BsScriptGUISceneTreeView.cpp" />
     <ClCompile Include="Source\BsScriptOSDropTarget.cpp" />
     <ClCompile Include="Source\BsScriptEditorApplication.cpp" />
     <ClCompile Include="Source\BsScriptEditorBuiltin.cpp" />

+ 6 - 0
SBansheeEditor/SBansheeEditor.vcxproj.filters

@@ -147,6 +147,9 @@
     <ClInclude Include="Include\BsScriptFolderMonitor.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsScriptGUISceneTreeView.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsScriptEditorPlugin.cpp">
@@ -281,5 +284,8 @@
     <ClCompile Include="Source\BsScriptFolderMonitor.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsScriptGUISceneTreeView.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 0 - 2
SBansheeEditor/Source/BsMenuItemManager.cpp

@@ -27,8 +27,6 @@ namespace BansheeEngine
 	MenuItemManager::~MenuItemManager()
 	{
 		mDomainLoadedConn.disconnect();
-
-		clearMenuItems();
 	}
 
 	void MenuItemManager::clearMenuItems()

+ 37 - 0
SBansheeEditor/Source/BsScriptGUISceneTreeView.cpp

@@ -0,0 +1,37 @@
+#include "BsScriptGUISceneTreeView.h"
+#include "BsScriptMeta.h"
+#include "BsMonoClass.h"
+#include "BsMonoManager.h"
+#include "BsMonoUtil.h"
+#include "BsGUISceneTreeView.h"
+#include "BsGUIOptions.h"
+
+using namespace std::placeholders;
+
+namespace BansheeEngine
+{
+	ScriptGUISceneTreeView::ScriptGUISceneTreeView(MonoObject* instance, GUISceneTreeView* treeView)
+		:TScriptGUIElement(instance, treeView)
+	{
+
+	}
+
+	void ScriptGUISceneTreeView::initRuntimeData()
+	{
+		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUISceneTreeView::internal_createInstance);
+	}
+
+	void ScriptGUISceneTreeView::internal_createInstance(MonoObject* instance, MonoString* style, MonoArray* guiOptions)
+	{
+		GUIOptions options;
+
+		UINT32 arrayLen = (UINT32)mono_array_length(guiOptions);
+		for (UINT32 i = 0; i < arrayLen; i++)
+			options.addOption(mono_array_get(guiOptions, GUIOption, i));
+
+		String styleName = toString(MonoUtil::monoToWString(style));
+
+		GUISceneTreeView* treeView = GUISceneTreeView::create(options);
+		ScriptGUISceneTreeView* nativeInstance = new (bs_alloc<ScriptGUISceneTreeView>()) ScriptGUISceneTreeView(instance, treeView);
+	}
+}

+ 16 - 0
TODO.txt

@@ -24,6 +24,22 @@ ProjectLibrary import
 I'm not sure if queued dependencies are handled properly. They're handled on an internal ProjectLibrary loop but perhaps I should
 return them in checkForModifications?
 
+----------------------------------------------------------------------
+Polish stage 1
+
+Scene tree view in hierarchy window doesn't render
+When elements are docked in the main window the menu bar drop down appears behind them
+Click on empty part of the menu bar doesn't close the menu bar (ignoring NC area clicks?)
+Attempting to dock a window that is not in focus will start drag instead (NC area incorrectly set up?)
+Docking problem: When I dock three windows next to each other, e.g. Hierarchy|Scene|Inspector and then try to dock another
+ so it splits space with Hierarchy vertically the dock area appears over both hierarchy and scene, and the when docked it looks wrong
+Decent looking default layout
+Fix shutdown
+Fix DX11 (and possibly DX9) rendering
+Missing Inspector values (name + transform fields)
+Fix handles
+Moving the title bar tab and then dropping it closes the window (possibly only happens when there is just one tab)
+
 ----------------------------------------------------------------------
 Project window