Răsfoiți Sursa

Added proper names for C# editor windows

Marko Pintera 10 ani în urmă
părinte
comite
10657f775c

+ 1 - 0
BansheeEditor/Include/BsEditorWidgetContainer.h

@@ -29,6 +29,7 @@ namespace BansheeEngine
 		Vector<Rect2I> getDraggableAreas() const;
 
 		void update();
+		void refreshWidgetNames();
 
 		void _notifyWidgetDestroyed(EditorWidgetBase* widget);
 

+ 1 - 0
BansheeEditor/Include/BsGUITabbedTitleBar.h

@@ -25,6 +25,7 @@ namespace BansheeEngine
 		void setActive(UINT32 uniqueIdx);
 		UINT32 getTabIdx(UINT32 position) const;
 		UINT32 getNumTabs() const { return (UINT32)mTabButtons.size(); }
+		void updateTabName(UINT32 uniqueIdx, const HString& name);
 
 		Vector<Rect2I> calcDraggableAreas(INT32 x, INT32 y, UINT32 width, UINT32 height) const;
 

+ 3 - 3
BansheeEditor/Source/BsEditorApplication.cpp

@@ -138,9 +138,9 @@ namespace BansheeEngine
 		MainEditorWindow* mainWindow = MainEditorWindow::create(getPrimaryWindow());
 		loadPlugin("SBansheeEditor", &mSBansheeEditorPlugin); // Managed part of the editor
 
-		//EditorWidgetLayoutPtr layout = loadWidgetLayout();
-		//if (layout != nullptr)
-		//	EditorWidgetManager::instance().setLayout(layout);
+		EditorWidgetLayoutPtr layout = loadWidgetLayout();
+		if (layout != nullptr)
+			EditorWidgetManager::instance().setLayout(layout);
 
 		BuildManager::instance().load(BUILD_DATA_PATH);
 

+ 9 - 0
BansheeEditor/Source/BsEditorWidgetContainer.cpp

@@ -51,6 +51,15 @@ namespace BansheeEngine
 		}
 	}
 
+	void EditorWidgetContainer::refreshWidgetNames()
+	{
+		for (auto& curWidget : mWidgets)
+		{
+			INT32 tabIdx = curWidget.first;
+			mTitleBar->updateTabName((UINT32)tabIdx, curWidget.second->getDisplayName());
+		}
+	}
+
 	void EditorWidgetContainer::add(EditorWidgetBase& widget)
 	{
 		insert((UINT32)mWidgets.size(), widget);

+ 10 - 0
BansheeEditor/Source/BsGUITabbedTitleBar.cpp

@@ -114,6 +114,16 @@ namespace BansheeEngine
 		mTabButtons.erase(mTabButtons.begin() + idx);
 	}
 
+	void GUITabbedTitleBar::updateTabName(UINT32 uniqueIdx, const HString& name)
+	{
+		INT32 idx = uniqueIdxToSeqIdx(uniqueIdx);
+		if (idx == -1)
+			return;
+
+		idx = (INT32)Math::clamp((UINT32)idx, 0U, (UINT32)mTabButtons.size() - 1);
+		mTabButtons[idx]->setContent(GUIContent(name));
+	}
+
 	void GUITabbedTitleBar::setActive(UINT32 uniqueIdx)
 	{
 		mTabButtons[uniqueIdxToSeqIdx(uniqueIdx)]->toggleOn();

+ 5 - 0
MBansheeEditor/EditorWindow.cs

@@ -47,6 +47,11 @@ namespace BansheeEditor
             
         }
 
+        protected virtual LocString GetDisplayName()
+        {
+            return GetType().Name;
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern EditorWindow Internal_CreateOrGetInstance(string ns, string typeName);
 

+ 5 - 0
MBansheeEditor/HierarchyWindow.cs

@@ -12,6 +12,11 @@ namespace BansheeEditor
             OpenWindow<HierarchyWindow>();
         }
 
+        protected override LocString GetDisplayName()
+        {
+            return "Hierarchy";
+        }
+
         private void OnInitialize()
         {
             GUIScrollArea scrollArea = new GUIScrollArea();

+ 7 - 2
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -33,9 +33,14 @@ namespace BansheeEditor
         private GUIFloatField soScaleZ;
 
         [MenuItem("Windows/Inspector", ButtonModifier.CtrlAlt, ButtonCode.I)]
-        private static void OpenHierarchyWindow()
+        private static void OpenInspectorWindow()
         {
-            OpenWindow<HierarchyWindow>();
+            OpenWindow<InspectorWindow>();
+        }
+
+        protected override LocString GetDisplayName()
+        {
+            return "Inspector";
         }
 
         internal void SetObjectToInspect(SceneObject so)

+ 5 - 0
MBansheeEditor/ProjectWindow.cs

@@ -81,6 +81,11 @@ namespace BansheeEditor
             OpenWindow<ProjectWindow>();
         }
 
+        protected override LocString GetDisplayName()
+        {
+            return "Project";
+        }
+
         private void OnInitialize()
         {
             ProjectLibrary.OnEntryAdded += OnEntryChanged;

+ 5 - 0
MBansheeEditor/Scene/SceneWindow.cs

@@ -58,6 +58,11 @@ namespace BansheeEditor
             OpenWindow<SceneWindow>();
         }
 
+        protected override LocString GetDisplayName()
+        {
+            return "Scene";
+        }
+
         private void OnInitialize()
         {
             mainLayout = GUI.AddLayoutY();

+ 1 - 0
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -99,6 +99,7 @@ namespace BansheeEngine
 		OnDestroyThunkDef mOnDestroyThunk;
 		UpdateThunkDef mUpdateThunk;
 		MonoObject* mManagedInstance;
+		MonoMethod* mGetDisplayName;
 
 		ScriptEditorWindow* mScriptOwner;
 		ScriptGUILayout* mContentsPanel;

+ 18 - 2
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -11,6 +11,7 @@
 #include "BsMonoAssembly.h"
 #include "BsScriptObjectManager.h"
 #include "BsScriptGUILayout.h"
+#include "BsScriptHString.h"
 
 using namespace std::placeholders;
 
@@ -303,9 +304,22 @@ namespace BansheeEngine
 	ScriptEditorWidget::ScriptEditorWidget(const String& ns, const String& type, EditorWidgetContainer& parentContainer)
 		:EditorWidgetBase(HString(toWString(type)), ns + "." + type, parentContainer), mNamespace(ns), mTypename(type),
 		mUpdateThunk(nullptr), mManagedInstance(nullptr), mOnInitializeThunk(nullptr), mOnDestroyThunk(nullptr), 
-		mContentsPanel(nullptr), mScriptOwner(nullptr)
+		mContentsPanel(nullptr), mScriptOwner(nullptr), mGetDisplayName(nullptr)
 	{
-		createManagedInstance();
+		if(createManagedInstance())
+		{
+			if (mGetDisplayName != nullptr)
+			{
+				MonoObject* displayNameMono = mGetDisplayName->invokeVirtual(mManagedInstance, nullptr);
+				ScriptHString* scriptHString = ScriptHString::toNative(displayNameMono);
+
+				if (scriptHString != nullptr)
+				{
+					mDisplayName = HString(scriptHString->getInternalValue());
+					parentContainer.refreshWidgetNames();
+				}
+			}
+		}
 	}
 
 	ScriptEditorWidget::~ScriptEditorWidget()
@@ -391,5 +405,7 @@ namespace BansheeEngine
 
 		if (onDestroyMethod != nullptr)
 			mOnDestroyThunk = (OnDestroyThunkDef)onDestroyMethod->getThunk();
+
+		mGetDisplayName = windowClass->getMethod("GetDisplayName", 0);
 	}
 }

+ 0 - 3
TODO.txt

@@ -56,15 +56,12 @@ Code quality improvements:
 ----------------------------------------------------------------------
 Polish stage 1
 
-Handle cones are either inside out or have incorrect normals
-Re-enable widget layout loading
 Fix a crash when re-opening scene window
 Crash in DefaultHandleManager.PreInput when just flying around the scene while having a handle active and hovering over it a few times
 
 After undocking ProjectWindow the auto-scroll seems to be stuck in up position
 When selecting an gizmo icon the selection seems delayed and its gizmos flash for a frame before hiding (Can't reproduce atm but I saw it)
 Main window resize areas don't seem to be set up or work
-Make proper window names instead of InspectorWindow
 Decent looking default layout
 
 Fix handles