Explorar el Código

C# multi-dimensional array serialization works

Marko Pintera hace 11 años
padre
commit
9534d239c7

+ 1 - 1
MBansheeEngine/DbgComponent.cs

@@ -11,6 +11,6 @@ namespace BansheeEngine
         public DbgSerzObj complex = new DbgSerzObj();
         public DbgComponent2 otherComponent;
         public SceneObject otherSO;
-        public int[] zeArray;
+        public int[,,] zeArray;
     }
 }

+ 3 - 3
MBansheeEngine/Program.cs

@@ -22,15 +22,15 @@ namespace BansheeEngine
             dbgComponent.complex.anotherValue = "AnotherValue";
             dbgComponent.otherComponent = dbgComponent2;
             dbgComponent.otherSO = otherSO;
-            dbgComponent.zeArray = new int[5];
-            dbgComponent.zeArray[4] = 129;
+            dbgComponent.zeArray = new int[5,6,7];
+            dbgComponent.zeArray[4,1,3] = 129;
 
             dbgTestComponentClone(so);
 
             for (int i = 0; i < so.GetNumChildren(); i++)
             {
                 SceneObject childSO = so.GetChild(i);
-                reportDbgValue(childSO.GetComponent<DbgComponent>().otherComponent.a2, childSO.GetComponent<DbgComponent>().zeArray[4], typeof(DbgComponent));
+                reportDbgValue(childSO.GetComponent<DbgComponent>().otherComponent.a2, childSO.GetComponent<DbgComponent>().zeArray[4, 1, 3], typeof(DbgComponent));
             }
 
             //Color newColor = Color.red;

+ 9 - 5
SBansheeEngine/Source/BsScriptSerializableArray.cpp

@@ -49,10 +49,10 @@ namespace BansheeEngine
 
 	void ScriptSerializableArray::serializeManagedInstance()
 	{
-		UINT32 totalNumElements = 0;
+		UINT32 totalNumElements = 1;
 		for(auto& numElems : mNumElements)
 		{
-			totalNumElements += numElems;
+			totalNumElements *= numElems;
 		}
 
 		mArrayEntries.resize(totalNumElements);
@@ -124,14 +124,18 @@ namespace BansheeEngine
 
 	UINT32 ScriptSerializableArray::toSequentialIdx(const CM::Vector<CM::UINT32>::type& idx) const
 	{
-		// TODO - Never actually tested if it works, IDX calculation might work differently
-		if(idx.size() != (UINT32)mNumElements.size())
+		UINT32 mNumDims = (UINT32)mNumElements.size();
+
+		if(idx.size() != mNumDims)
 			CM_EXCEPT(InvalidParametersException, "Provided index doesn't have the correct number of dimensions");
 
+		if(mNumElements.size() == 0)
+			return 0;
+
 		UINT32 curIdx = 0;
 		UINT32 prevDimensionSize = 1;
 		
-		for(UINT32 i = 0; i < (UINT32)mNumElements.size(); i++)
+		for(INT32 i = mNumDims - 1; i >= 0; i--)
 		{
 			curIdx += idx[i] * prevDimensionSize;
 

+ 0 - 50
TODOEditor.txt

@@ -1,50 +0,0 @@
-TODO for next few days:
- - Layout manager that saves/restores user layout
-   - Keeps position, size ands possibly docking information for every window
-     (Main window probably needs to be handled specially)
-   - At startup all windows register with it
-   - Calling restore() will place all windows in proper positions
-   - It will also set up hooks to those windows so it gets updates when they get moved/sized/docked
- - Project create/Project open window
-   - Shows at the start of the editor
-   - Also has hooks directly from File menu (Create project, Open project)
- - EditorPrefs class
-   - Stores all of editor preferences, including layout information
-   - Also keeps a list of all known projects
- - Menu bar:
-   - File->Create project, File->Open project
-   - Windows menu with a list of all windows
-     - List gets populated easily so people can write plugin windows
-	  - Plugin windows should possibly also be able to assign themselves to other Menu item than Windows
- - Docking system
-   - All open windows can be docked/unocked
-   - Their layout data gets saved
-   - The way I handle editor windows at the moment is pretty weird with alot of custom handling for resize/move
-     - Attempt to get rid of that or at least dont use it until I have window look more fleshed out
-	 - Look at QSizeGrip for resizing
-	 - QStackWidget (or QStackLayout) for stacking and tabbed windows
- - Make sure entire interface is skinnable
- - Create a generic "Prefs" system that supports arrays and loading/saving to ini files
-   - Using EditorPrefs is too cumbersome and it won't allow extensions to use it anyway
-
-
-Dock overlay widget colors need to be customizable
-
-Unique IDs for windows. Currently I don't guarantee IDs will be the same if user adds a window before I restore them from file.
-
-When restoring windows what happens why I try to restore an unloaded plugin?
- - A NullWindow?
-
- After I undock a window it needs to return itself to the default size
-  - Allow widgets to specify default size
-
-
-  WindowDockManager
- Checks if we're mousing over any dock widgets
- If not it checks if we're mousing over DynamicTabBar (in any open window)
-   If we are it gets the polygons from DynamicTabBar and renders them
-   Also gets the current polygon and highlights it
-   Upon mouse release it find exactly at what index the mouse was released and adds the widget to the tab bar
-
-   getWindowAtPosition doesn't consider if two or more windows are overlapping. It should return the front most
-Dragging window around occludes possible dock points. I need to make the window less visible while dragging.