2
0
Эх сурвалжийг харах

Some work on Script EditorWindow & Mono custom attributes

Marko Pintera 11 жил өмнө
parent
commit
4846055a38
41 өөрчлөгдсөн 128 нэмэгдсэн , 98 устгасан
  1. 2 1
      BansheeMono/Include/BsMonoAssembly.h
  2. 2 0
      BansheeMono/Include/BsMonoClass.h
  3. 3 0
      BansheeMono/Include/BsMonoField.h
  4. 5 1
      BansheeMono/Include/BsMonoManager.h
  5. 27 8
      BansheeMono/Source/BsMonoAssembly.cpp
  6. 29 0
      BansheeMono/Source/BsMonoField.cpp
  7. 13 6
      BansheeMono/Source/BsMonoManager.cpp
  8. 2 44
      EditorWindowDock.txt
  9. 0 0
      MBansheeEngine/GUI/GUI.cs
  10. 0 0
      MBansheeEngine/GUI/GUIArea.cs
  11. 0 0
      MBansheeEngine/GUI/GUIBase.cs
  12. 0 0
      MBansheeEngine/GUI/GUIButton.cs
  13. 0 0
      MBansheeEngine/GUI/GUIContent.cs
  14. 0 0
      MBansheeEngine/GUI/GUIElement.cs
  15. 0 0
      MBansheeEngine/GUI/GUIElementStateStyle.cs
  16. 0 0
      MBansheeEngine/GUI/GUIElementStyle.cs
  17. 0 0
      MBansheeEngine/GUI/GUILabel.cs
  18. 0 0
      MBansheeEngine/GUI/GUILayout.cs
  19. 0 0
      MBansheeEngine/GUI/GUILayoutX.cs
  20. 0 0
      MBansheeEngine/GUI/GUILayoutY.cs
  21. 0 0
      MBansheeEngine/GUI/GUIListBox.cs
  22. 0 0
      MBansheeEngine/GUI/GUIOption.cs
  23. 0 0
      MBansheeEngine/GUI/GUIScrollArea.cs
  24. 0 0
      MBansheeEngine/GUI/GUISkin.cs
  25. 0 0
      MBansheeEngine/GUI/GUISpace.cs
  26. 0 0
      MBansheeEngine/GUI/GUITextBox.cs
  27. 0 0
      MBansheeEngine/GUI/GUITexture.cs
  28. 0 0
      MBansheeEngine/GUI/GUIToggle.cs
  29. 0 0
      MBansheeEngine/GUI/GUIToggleGroup.cs
  30. 28 28
      MBansheeEngine/MBansheeEngine.csproj
  31. 0 0
      MBansheeEngine/Math/MathEx.cs
  32. 0 0
      MBansheeEngine/Math/Matrix3.cs
  33. 0 0
      MBansheeEngine/Math/Matrix4.cs
  34. 0 0
      MBansheeEngine/Math/Quaternion.cs
  35. 0 0
      MBansheeEngine/Math/Vector2.cs
  36. 0 0
      MBansheeEngine/Math/Vector3.cs
  37. 0 0
      MBansheeEngine/Math/Vector4.cs
  38. 1 1
      SBansheeEditor/Include/BsScriptEditorGUI.h
  39. 1 1
      SBansheeEditor/Include/BsScriptEditorPrerequisites.h
  40. 3 1
      SBansheeEditor/Include/BsScriptEditorWindow.h
  41. 12 7
      SBansheeEditor/Source/BsScriptEditorWindow.cpp

+ 2 - 1
BansheeMono/Include/BsMonoAssembly.h

@@ -29,7 +29,8 @@ namespace BansheeEngine
 	public:
 	public:
 		~MonoAssembly();
 		~MonoAssembly();
 
 
-		MonoClass* getClass(const CM::String& namespaceName, const CM::String& name);
+		MonoClass* getClass(const CM::String& namespaceName, const CM::String& name) const;
+		CM::Vector<MonoClass*>::type getAllClasses() const;
 
 
 	private:
 	private:
 		friend class MonoManager;
 		friend class MonoManager;

+ 2 - 0
BansheeMono/Include/BsMonoClass.h

@@ -37,6 +37,8 @@ namespace BansheeEngine
 		MonoObject* invokeMethod(const CM::String& name, MonoObject* instance = nullptr, void** params = nullptr, CM::UINT32 numParams = 0);
 		MonoObject* invokeMethod(const CM::String& name, MonoObject* instance = nullptr, void** params = nullptr, CM::UINT32 numParams = 0);
 		void addInternalCall(const CM::String& name, const void* method);
 		void addInternalCall(const CM::String& name, const void* method);
 
 
+		::MonoClass* _getInternalClass() const { return mClass; }
+
 		MonoObject* createInstance() const;
 		MonoObject* createInstance() const;
 	private:
 	private:
 		friend class MonoAssembly;
 		friend class MonoAssembly;

+ 3 - 0
BansheeMono/Include/BsMonoField.h

@@ -12,6 +12,9 @@ namespace BansheeEngine
 		void* getValue(MonoObject* instance);
 		void* getValue(MonoObject* instance);
 		void setValue(MonoObject* instance, void* value);
 		void setValue(MonoObject* instance, void* value);
 
 
+		bool hasAttribute(MonoClass* monoClass);
+		MonoObject* getAttribute(MonoClass* monoClass);
+
 	private:
 	private:
 		friend class MonoClass;
 		friend class MonoClass;
 
 

+ 5 - 1
BansheeMono/Include/BsMonoManager.h

@@ -19,7 +19,10 @@ namespace BansheeEngine
 		MonoAssembly& loadAssembly(const CM::String& path, const CM::String& name, const CM::String& entryPoint = CM::StringUtil::BLANK);
 		MonoAssembly& loadAssembly(const CM::String& path, const CM::String& name, const CM::String& entryPoint = CM::StringUtil::BLANK);
 		void unloadAssembly(MonoAssembly& assembly);
 		void unloadAssembly(MonoAssembly& assembly);
 
 
-		MonoObject* createInstance(const CM::String& ns, const CM::String& typeName);
+		/**
+		 * @brief	Searches all loaded assemblies for the specified class.
+		 */
+		MonoClass* findClass(const CM::String& ns, const CM::String& typeName);
 
 
 		/**
 		/**
 		 * @brief	Returns the type name of the provided object, with namespace.
 		 * @brief	Returns the type name of the provided object, with namespace.
@@ -29,6 +32,7 @@ namespace BansheeEngine
 		CM::String getTypeName(MonoObject* obj);
 		CM::String getTypeName(MonoObject* obj);
 
 
 		MonoDomain* getDomain() const { return mDomain; }
 		MonoDomain* getDomain() const { return mDomain; }
+		MonoAssembly* getAssembly(const CM::String& name) const;
 
 
 		static void registerScriptType(ScriptMeta* metaData);
 		static void registerScriptType(ScriptMeta* metaData);
 	private:
 	private:

+ 27 - 8
BansheeMono/Source/BsMonoAssembly.cpp

@@ -6,6 +6,7 @@
 #include "CmException.h"
 #include "CmException.h"
 
 
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/tokentype.h>
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 
 
@@ -57,6 +58,21 @@ namespace BansheeEngine
 			CM_EXCEPT(InvalidParametersException, "Cannot get script assembly image.");
 			CM_EXCEPT(InvalidParametersException, "Cannot get script assembly image.");
 		}
 		}
 
 
+		// Load all classes
+		int numRows = mono_image_get_table_rows (mMonoImage, MONO_TABLE_TYPEDEF);
+
+		for(int i = 1; i < numRows; i++)
+		{
+			::MonoClass* monoClass = mono_class_get (mMonoImage, i | MONO_TOKEN_TYPE_DEF);
+
+			String ns = mono_class_get_namespace(monoClass);
+			String type = mono_class_get_name(monoClass);
+
+			String fullClassName = ns + "." + type;
+			MonoClass* newClass = new (cm_alloc<MonoClass>()) MonoClass(fullClassName, monoClass, this);
+			mClasses[ClassId(ns, type)] = newClass;
+		}
+
 		mIsLoaded = true;
 		mIsLoaded = true;
 	}
 	}
 
 
@@ -94,7 +110,7 @@ namespace BansheeEngine
 		}
 		}
 	}
 	}
 
 
-	MonoClass* MonoAssembly::getClass(const String& namespaceName, const String& name)
+	MonoClass* MonoAssembly::getClass(const String& namespaceName, const String& name) const
 	{
 	{
 		if(!mIsLoaded)
 		if(!mIsLoaded)
 			CM_EXCEPT(InvalidStateException, "Trying to use an unloaded assembly.");
 			CM_EXCEPT(InvalidStateException, "Trying to use an unloaded assembly.");
@@ -105,14 +121,17 @@ namespace BansheeEngine
 		if(iterFind != mClasses.end())
 		if(iterFind != mClasses.end())
 			return iterFind->second;
 			return iterFind->second;
 
 
-		::MonoClass* monoClass = mono_class_from_name(mMonoImage, namespaceName.c_str(), name.c_str());
-		if(monoClass == nullptr)
-			return nullptr;
+		return nullptr;
+	}
+
+	CM::Vector<MonoClass*>::type MonoAssembly::getAllClasses() const
+	{
+		CM::Vector<MonoClass*>::type classes;
+		classes.reserve(classes.size());
 
 
-		String fullClassName = namespaceName + "." + name;
-		MonoClass* newClass = new (cm_alloc<MonoClass>()) MonoClass(fullClassName, monoClass, this);
-		mClasses[classId] = newClass;
+		for(auto& curClass : mClasses)
+			classes.push_back(curClass.second);
 
 
-		return newClass;
+		return classes;
 	}
 	}
 }
 }

+ 29 - 0
BansheeMono/Source/BsMonoField.cpp

@@ -1,4 +1,5 @@
 #include "BsMonoField.h"
 #include "BsMonoField.h"
+#include "BsMonoClass.h"
 
 
 using namespace CamelotFramework;
 using namespace CamelotFramework;
 
 
@@ -21,4 +22,32 @@ namespace BansheeEngine
 	{
 	{
 		mono_field_set_value(instance, mField, &value);
 		mono_field_set_value(instance, mField, &value);
 	}
 	}
+
+	bool MonoField::hasAttribute(MonoClass* monoClass)
+	{
+		// TODO - Consider caching custom attributes or just initializing them all at load
+
+		::MonoClass* parentClass = mono_field_get_parent(mField);
+		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, mField);
+
+		bool hasAttr = mono_custom_attrs_has_attr(attrInfo, monoClass->_getInternalClass());
+
+		mono_custom_attrs_free(attrInfo);
+
+		return hasAttr;
+	}
+
+	MonoObject* MonoField::getAttribute(MonoClass* monoClass)
+	{
+		// TODO - Consider caching custom attributes or just initializing them all at load
+
+		::MonoClass* parentClass = mono_field_get_parent(mField);
+		MonoCustomAttrInfo* attrInfo = mono_custom_attrs_from_field(parentClass, mField);
+
+		MonoObject* foundAttr = mono_custom_attrs_get_attr(attrInfo, monoClass->_getInternalClass());
+
+		mono_custom_attrs_free(attrInfo);
+
+		return foundAttr;
+	}
 }
 }

+ 13 - 6
BansheeMono/Source/BsMonoManager.cpp

@@ -97,25 +97,32 @@ namespace BansheeEngine
 			mono_assembly_close(monoAssembly);
 			mono_assembly_close(monoAssembly);
 	}
 	}
 
 
+	MonoAssembly* MonoManager::getAssembly(const CM::String& name) const
+	{
+		auto iterFind = mAssemblies.find(name);
+
+		if(iterFind != mAssemblies.end())
+			return iterFind->second;
+
+		return nullptr;
+	}
+
 	void MonoManager::registerScriptType(ScriptMeta* metaData)
 	void MonoManager::registerScriptType(ScriptMeta* metaData)
 	{
 	{
 		Vector<ScriptMeta*>::type& mMetas = getTypesToInitialize()[metaData->assembly];
 		Vector<ScriptMeta*>::type& mMetas = getTypesToInitialize()[metaData->assembly];
 		mMetas.push_back(metaData);
 		mMetas.push_back(metaData);
 	}
 	}
 
 
-	MonoObject* MonoManager::createInstance(const CM::String& ns, const CM::String& typeName)
+	MonoClass* MonoManager::findClass(const CM::String& ns, const CM::String& typeName)
 	{
 	{
 		MonoClass* monoClass = nullptr;
 		MonoClass* monoClass = nullptr;
 		for(auto& assembly : mAssemblies)
 		for(auto& assembly : mAssemblies)
 		{
 		{
 			monoClass = assembly.second->getClass(ns, typeName);
 			monoClass = assembly.second->getClass(ns, typeName);
 			if(monoClass != nullptr)
 			if(monoClass != nullptr)
-				break;
+				return monoClass;
 		}
 		}
 
 
-		if(monoClass != nullptr)
-			return monoClass->createInstance();
-
 		return nullptr;
 		return nullptr;
 	}
 	}
 
 
@@ -126,6 +133,6 @@ namespace BansheeEngine
 
 
 		::MonoClass* monoClass = mono_object_get_class(obj);
 		::MonoClass* monoClass = mono_object_get_class(obj);
 
 
-		return String(mono_class_get_namespace(monoClass)) + "::" + String(mono_class_get_name(monoClass));
+		return String(mono_class_get_namespace(monoClass)) + "." + String(mono_class_get_name(monoClass));
 	}
 	}
 }
 }

+ 2 - 44
EditorWindowDock.txt

@@ -9,6 +9,8 @@ Polish TOOD:
 ------------------------
 ------------------------
 Layout saving/loading:
 Layout saving/loading:
 TODO:
 TODO:
+ EditorWindow creation from Scripts is currently disabled as I need to export EditorWidget classes
+   - I will probably want to move BansheeEditor stuff into its own BansheeEditor .dll (need it for singleton instantiation as well)
  Register a bunch of duplicate widgets and open and dock them
  Register a bunch of duplicate widgets and open and dock them
  C# EditorWindows
  C# EditorWindows
 
 
@@ -16,47 +18,3 @@ TODO:
 
 
 Other things to remember:
 Other things to remember:
  - Possibly add a way to have hidden widgets in the EditorWidgetContainer (like side-bars that pop on mouse over in Visual Studio)
  - Possibly add a way to have hidden widgets in the EditorWidgetContainer (like side-bars that pop on mouse over in Visual Studio)
-
- ------------------------
-
- EditorWindow enumeraton in C#: - HOWEVER I think it's almost certainly better do just use C# reflection. I don't see any advantages
- to doing it in C++.
-
- To get all classes in a mono image:
-MonoClass*
-mono_assembly_get_classes (MonoAssembly *assembly, gpointer *iter)
-{
-	MonoImage *image;
-	int num_types;
-	gssize *index;
-
-	if (!iter)
-		return NULL;
-
-	index = (gssize *) iter;
-
-	/* skip the <Module> */
-	if (!*index)
-		*index = 1;
-
-	image = mono_assembly_get_image (assembly);
-	num_types = mono_image_get_table_rows (image, MONO_TABLE_TYPEDEF);
-
-	if (*index < num_types) {
-		(*index)++;
-		return mono_class_get (image, *index | MONO_TOKEN_TYPE_DEF);
-	} else {
-		*index = 0;
-		return NULL;
-	}
-}
-
-More info on how to potentially access other properties, here: http://docs.go-mono.com/?link=xhtml%3adeploy%2fmono-api-metadata.html
-
-
-To get class hierarchy:
- mono_class_get_parent to get parent class (does this mean base class?)
- mono_class_is_assignable_from potentially
- mono_class_is_subclass_of
-
-Attributes: Very much undocumented but a lot of stuff here relates to attributes: http://docs.go-mono.com/?link=xhtml%3adeploy%2fmono-api-reflection.html

+ 0 - 0
MBansheeEngine/GUI.cs → MBansheeEngine/GUI/GUI.cs


+ 0 - 0
MBansheeEngine/GUIArea.cs → MBansheeEngine/GUI/GUIArea.cs


+ 0 - 0
MBansheeEngine/GUIBase.cs → MBansheeEngine/GUI/GUIBase.cs


+ 0 - 0
MBansheeEngine/GUIButton.cs → MBansheeEngine/GUI/GUIButton.cs


+ 0 - 0
MBansheeEngine/GUIContent.cs → MBansheeEngine/GUI/GUIContent.cs


+ 0 - 0
MBansheeEngine/GUIElement.cs → MBansheeEngine/GUI/GUIElement.cs


+ 0 - 0
MBansheeEngine/GUIElementStateStyle.cs → MBansheeEngine/GUI/GUIElementStateStyle.cs


+ 0 - 0
MBansheeEngine/GUIElementStyle.cs → MBansheeEngine/GUI/GUIElementStyle.cs


+ 0 - 0
MBansheeEngine/GUILabel.cs → MBansheeEngine/GUI/GUILabel.cs


+ 0 - 0
MBansheeEngine/GUILayout.cs → MBansheeEngine/GUI/GUILayout.cs


+ 0 - 0
MBansheeEngine/GUILayoutX.cs → MBansheeEngine/GUI/GUILayoutX.cs


+ 0 - 0
MBansheeEngine/GUILayoutY.cs → MBansheeEngine/GUI/GUILayoutY.cs


+ 0 - 0
MBansheeEngine/GUIListBox.cs → MBansheeEngine/GUI/GUIListBox.cs


+ 0 - 0
MBansheeEngine/GUIOption.cs → MBansheeEngine/GUI/GUIOption.cs


+ 0 - 0
MBansheeEngine/GUIScrollArea.cs → MBansheeEngine/GUI/GUIScrollArea.cs


+ 0 - 0
MBansheeEngine/GUISkin.cs → MBansheeEngine/GUI/GUISkin.cs


+ 0 - 0
MBansheeEngine/GUISpace.cs → MBansheeEngine/GUI/GUISpace.cs


+ 0 - 0
MBansheeEngine/GUITextBox.cs → MBansheeEngine/GUI/GUITextBox.cs


+ 0 - 0
MBansheeEngine/GUITexture.cs → MBansheeEngine/GUI/GUITexture.cs


+ 0 - 0
MBansheeEngine/GUIToggle.cs → MBansheeEngine/GUI/GUIToggle.cs


+ 0 - 0
MBansheeEngine/GUIToggleGroup.cs → MBansheeEngine/GUI/GUIToggleGroup.cs


+ 28 - 28
MBansheeEngine/MBansheeEngine.csproj

@@ -45,43 +45,43 @@
     <Compile Include="BuiltinResources.cs" />
     <Compile Include="BuiltinResources.cs" />
     <Compile Include="Color.cs" />
     <Compile Include="Color.cs" />
     <Compile Include="Font.cs" />
     <Compile Include="Font.cs" />
-    <Compile Include="GUI.cs" />
-    <Compile Include="GUIArea.cs" />
-    <Compile Include="GUIBase.cs" />
-    <Compile Include="GUIButton.cs" />
-    <Compile Include="GUIContent.cs" />
-    <Compile Include="GUIElement.cs" />
-    <Compile Include="GUIElementStateStyle.cs" />
-    <Compile Include="GUIElementStyle.cs" />
-    <Compile Include="GUIListBox.cs" />
-    <Compile Include="GUIScrollArea.cs" />
-    <Compile Include="GUITextBox.cs" />
-    <Compile Include="GUILabel.cs" />
-    <Compile Include="GUILayout.cs" />
-    <Compile Include="GUILayoutX.cs" />
-    <Compile Include="GUILayoutY.cs" />
-    <Compile Include="GUIOption.cs" />
-    <Compile Include="GUISkin.cs" />
-    <Compile Include="GUISpace.cs" />
-    <Compile Include="GUITexture.cs" />
-    <Compile Include="GUIToggle.cs" />
-    <Compile Include="GUIToggleGroup.cs" />
+    <Compile Include="GUI\GUI.cs" />
+    <Compile Include="GUI\GUIArea.cs" />
+    <Compile Include="GUI\GUIBase.cs" />
+    <Compile Include="GUI\GUIButton.cs" />
+    <Compile Include="GUI\GUIContent.cs" />
+    <Compile Include="GUI\GUIElement.cs" />
+    <Compile Include="GUI\GUIElementStateStyle.cs" />
+    <Compile Include="GUI\GUIElementStyle.cs" />
+    <Compile Include="GUI\GUIListBox.cs" />
+    <Compile Include="GUI\GUIScrollArea.cs" />
+    <Compile Include="GUI\GUITextBox.cs" />
+    <Compile Include="GUI\GUILabel.cs" />
+    <Compile Include="GUI\GUILayout.cs" />
+    <Compile Include="GUI\GUILayoutX.cs" />
+    <Compile Include="GUI\GUILayoutY.cs" />
+    <Compile Include="GUI\GUIOption.cs" />
+    <Compile Include="GUI\GUISkin.cs" />
+    <Compile Include="GUI\GUISpace.cs" />
+    <Compile Include="GUI\GUITexture.cs" />
+    <Compile Include="GUI\GUIToggle.cs" />
+    <Compile Include="GUI\GUIToggleGroup.cs" />
     <Compile Include="LocString.cs" />
     <Compile Include="LocString.cs" />
-    <Compile Include="MathEx.cs" />
-    <Compile Include="Matrix3.cs" />
-    <Compile Include="Matrix4.cs" />
+    <Compile Include="Math\MathEx.cs" />
+    <Compile Include="Math\Matrix3.cs" />
+    <Compile Include="Math\Matrix4.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Quaternion.cs" />
+    <Compile Include="Math\Quaternion.cs" />
     <Compile Include="Resource.cs" />
     <Compile Include="Resource.cs" />
     <Compile Include="ScriptObject.cs" />
     <Compile Include="ScriptObject.cs" />
     <Compile Include="SpriteTexture.cs" />
     <Compile Include="SpriteTexture.cs" />
     <Compile Include="StringTable.cs" />
     <Compile Include="StringTable.cs" />
     <Compile Include="Texture2D.cs" />
     <Compile Include="Texture2D.cs" />
     <Compile Include="TextureFormat.cs" />
     <Compile Include="TextureFormat.cs" />
-    <Compile Include="Vector2.cs" />
-    <Compile Include="Vector3.cs" />
-    <Compile Include="Vector4.cs" />
+    <Compile Include="Math\Vector2.cs" />
+    <Compile Include="Math\Vector3.cs" />
+    <Compile Include="Math\Vector4.cs" />
   </ItemGroup>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 0 - 0
MBansheeEngine/MathEx.cs → MBansheeEngine/Math/MathEx.cs


+ 0 - 0
MBansheeEngine/Matrix3.cs → MBansheeEngine/Math/Matrix3.cs


+ 0 - 0
MBansheeEngine/Matrix4.cs → MBansheeEngine/Math/Matrix4.cs


+ 0 - 0
MBansheeEngine/Quaternion.cs → MBansheeEngine/Math/Quaternion.cs


+ 0 - 0
MBansheeEngine/Vector2.cs → MBansheeEngine/Math/Vector2.cs


+ 0 - 0
MBansheeEngine/Vector3.cs → MBansheeEngine/Math/Vector3.cs


+ 0 - 0
MBansheeEngine/Vector4.cs → MBansheeEngine/Math/Vector4.cs


+ 1 - 1
SBansheeEditor/Include/BsScriptEditorGUI.h

@@ -11,7 +11,7 @@ namespace BansheeEditor
 	public:
 	public:
 		static void initMetaData();
 		static void initMetaData();
 
 
-		virtual GUIWidget& getWidget() const;
+		virtual BS::GUIWidget& getWidget() const;
 	private:
 	private:
 		ScriptEditorGUI(ScriptEditorWindow* parentWindow);
 		ScriptEditorGUI(ScriptEditorWindow* parentWindow);
 
 

+ 1 - 1
SBansheeEditor/Include/BsScriptEditorPrerequisites.h

@@ -21,5 +21,5 @@
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
-	class ScriptModalWindow;
+	class ScriptEditorWindow;
 }
 }

+ 3 - 1
SBansheeEditor/Include/BsScriptEditorWindow.h

@@ -8,13 +8,15 @@ namespace BansheeEditor
 	class BS_SCR_BED_EXPORT ScriptEditorWindow : public BansheeEngine::ScriptObject<ScriptEditorWindow>
 	class BS_SCR_BED_EXPORT ScriptEditorWindow : public BansheeEngine::ScriptObject<ScriptEditorWindow>
 	{
 	{
 	public:
 	public:
+		~ScriptEditorWindow();
+
 		static void initMetaData();
 		static void initMetaData();
 
 
 		EditorWidgetBase* getEditorWidget() const { return mWidget; }
 		EditorWidgetBase* getEditorWidget() const { return mWidget; }
 
 
+		static void registerManagedEditorWindows();
 	private:
 	private:
 		ScriptEditorWindow(const CM::String& windowName);
 		ScriptEditorWindow(const CM::String& windowName);
-		~ScriptEditorWindow();
 
 
 		static MonoObject* internal_createOrGetInstance(MonoString* ns, MonoString* typeName);
 		static MonoObject* internal_createOrGetInstance(MonoString* ns, MonoString* typeName);
 		static void internal_createInstance(MonoObject* instance);
 		static void internal_createInstance(MonoObject* instance);

+ 12 - 7
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -17,13 +17,13 @@ namespace BansheeEditor
 	ScriptEditorWindow::ScriptEditorWindow(const CM::String& windowName)
 	ScriptEditorWindow::ScriptEditorWindow(const CM::String& windowName)
 		:mWidget(nullptr)
 		:mWidget(nullptr)
 	{
 	{
-		mWidget = EditorWidgetManager::instance().open(windowName);
+		//mWidget = EditorWidgetManager::instance().open(windowName);
 	}
 	}
 
 
 	ScriptEditorWindow::~ScriptEditorWindow()
 	ScriptEditorWindow::~ScriptEditorWindow()
 	{
 	{
-		if(mWidget != nullptr)
-			mWidget->close();
+		//if(mWidget != nullptr)
+		//	mWidget->close();
 	}
 	}
 
 
 	void ScriptEditorWindow::initMetaData()
 	void ScriptEditorWindow::initMetaData()
@@ -44,17 +44,17 @@ namespace BansheeEditor
 	{
 	{
 		String strTypeName = toString(MonoUtil::monoToWString(typeName));
 		String strTypeName = toString(MonoUtil::monoToWString(typeName));
 		String strNamespace = toString(MonoUtil::monoToWString(ns));
 		String strNamespace = toString(MonoUtil::monoToWString(ns));
-		String fullName = strNamespace + "::" + strTypeName;
+		String fullName = strNamespace + "." + strTypeName;
 
 
 		auto findIter = OpenScriptEditorWindows.find(fullName);
 		auto findIter = OpenScriptEditorWindows.find(fullName);
 		if(findIter != OpenScriptEditorWindows.end())
 		if(findIter != OpenScriptEditorWindows.end())
 			return findIter->second->mManagedInstance;
 			return findIter->second->mManagedInstance;
 
 
-		MonoObject* instance = MonoManager::instance().createInstance(strNamespace, strTypeName);
-		if(instance == nullptr)
+		BS::MonoClass* monoClass = MonoManager::instance().findClass(strNamespace, strTypeName);
+		if(monoClass == nullptr)
 			CM_EXCEPT(InvalidParametersException, "Provided name is not a valid type name \"" + fullName + "\"");
 			CM_EXCEPT(InvalidParametersException, "Provided name is not a valid type name \"" + fullName + "\"");
 
 
-		return instance;
+		return monoClass->createInstance();
 	}
 	}
 
 
 	void ScriptEditorWindow::internal_createInstance(MonoObject* instance)
 	void ScriptEditorWindow::internal_createInstance(MonoObject* instance)
@@ -72,4 +72,9 @@ namespace BansheeEditor
 		nativeInstance->destroyInstance();
 		nativeInstance->destroyInstance();
 		cm_delete(nativeInstance);
 		cm_delete(nativeInstance);
 	}
 	}
+
+	void ScriptEditorWindow::registerManagedEditorWindows()
+	{
+		// TODO
+	}
 }
 }