Browse Source

WIP project window

Marko Pintera 10 years ago
parent
commit
200ca8179a

+ 1 - 1
BansheeEditor/Include/BsBuiltinEditorResources.h

@@ -316,7 +316,6 @@ namespace BansheeEngine
 		static const WString TreeViewExpandButtonOnNormal;
 		static const WString TreeViewExpandButtonOnNormal;
 		static const WString TreeViewExpandButtonOnHover;
 		static const WString TreeViewExpandButtonOnHover;
 
 
-		static const WString TreeViewSelectionBackground;
 		static const WString TreeViewHighlightBackground;
 		static const WString TreeViewHighlightBackground;
 		static const WString TreeViewEditBox;
 		static const WString TreeViewEditBox;
 
 
@@ -331,6 +330,7 @@ namespace BansheeEngine
 		static const WString ProgressBarBgTex;
 		static const WString ProgressBarBgTex;
 
 
 		static const WString SelectionAreaTex;
 		static const WString SelectionAreaTex;
+		static const WString SelectionBgTex;
 
 
 		static const WString TextureDropTex;
 		static const WString TextureDropTex;
 		static const WString TextureDropOnTex;
 		static const WString TextureDropOnTex;

+ 16 - 2
BansheeEditor/Source/BsBuiltinEditorResources.cpp

@@ -208,7 +208,6 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::TreeViewExpandButtonOnNormal = L"TreeViewExpandButtonOnNormal.psd";
 	const WString BuiltinEditorResources::TreeViewExpandButtonOnNormal = L"TreeViewExpandButtonOnNormal.psd";
 	const WString BuiltinEditorResources::TreeViewExpandButtonOnHover = L"TreeViewExpandButtonOnHover.psd";
 	const WString BuiltinEditorResources::TreeViewExpandButtonOnHover = L"TreeViewExpandButtonOnHover.psd";
 
 
-	const WString BuiltinEditorResources::TreeViewSelectionBackground = L"TreeViewSelectionBackground.psd";
 	const WString BuiltinEditorResources::TreeViewHighlightBackground = L"TreeViewHighlightBackground.psd";
 	const WString BuiltinEditorResources::TreeViewHighlightBackground = L"TreeViewHighlightBackground.psd";
 	const WString BuiltinEditorResources::TreeViewEditBox = L"TreeViewEditBox.psd";
 	const WString BuiltinEditorResources::TreeViewEditBox = L"TreeViewEditBox.psd";
 	const WString BuiltinEditorResources::TreeViewElementHighlight = L"TreeViewElementHighlight.psd";
 	const WString BuiltinEditorResources::TreeViewElementHighlight = L"TreeViewElementHighlight.psd";
@@ -222,6 +221,7 @@ namespace BansheeEngine
 	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
 	const WString BuiltinEditorResources::ProgressBarBgTex = L"ProgressBarBg.psd";
 
 
 	const WString BuiltinEditorResources::SelectionAreaTex = L"SelectionHighlight.psd";
 	const WString BuiltinEditorResources::SelectionAreaTex = L"SelectionHighlight.psd";
+	const WString BuiltinEditorResources::SelectionBgTex = L"SelectionBg.psd";
 
 
 	const WString BuiltinEditorResources::TextureDropTex = L"TextureDrop.psd";
 	const WString BuiltinEditorResources::TextureDropTex = L"TextureDrop.psd";
 	const WString BuiltinEditorResources::TextureDropOnTex = L"TextureDropOn.psd";
 	const WString BuiltinEditorResources::TextureDropOnTex = L"TextureDropOn.psd";
@@ -920,7 +920,7 @@ namespace BansheeEngine
 
 
 		// Selection background
 		// Selection background
 		GUIElementStyle treeViewSelBackgroundStyle;
 		GUIElementStyle treeViewSelBackgroundStyle;
-		treeViewSelBackgroundStyle.normal.texture = getGUITexture(TreeViewSelectionBackground);
+		treeViewSelBackgroundStyle.normal.texture = getGUITexture(SelectionBgTex);
 		treeViewSelBackgroundStyle.fixedHeight = false;
 		treeViewSelBackgroundStyle.fixedHeight = false;
 		treeViewSelBackgroundStyle.fixedWidth = false;
 		treeViewSelBackgroundStyle.fixedWidth = false;
 		treeViewSelBackgroundStyle.height = 2;
 		treeViewSelBackgroundStyle.height = 2;
@@ -1391,6 +1391,20 @@ namespace BansheeEngine
 
 
 		skin->setStyle("SelectionArea", selectionAreaStyle);
 		skin->setStyle("SelectionArea", selectionAreaStyle);
 
 
+		// Selectable label
+		GUIElementStyle selectableLabelStyle;
+		selectableLabelStyle.normalOn.texture = getGUITexture(SelectionBgTex);
+		selectableLabelStyle.hoverOn.texture = selectableLabelStyle.normalOn.texture;
+		selectableLabelStyle.activeOn.texture = selectableLabelStyle.normalOn.texture;
+		selectableLabelStyle.fixedHeight = true;
+		selectableLabelStyle.height = 11;
+		selectableLabelStyle.minWidth = 10;
+		selectableLabelStyle.font = font;
+		selectableLabelStyle.fontSize = DefaultFontSize;
+		selectableLabelStyle.textHorzAlign = THA_Center;
+
+		skin->setStyle("SelectableLabel", selectableLabelStyle);
+
 		return skin;
 		return skin;
 	}
 	}
 
 

+ 0 - 2
BansheeEditor/Source/BsMainEditorWindow.cpp

@@ -26,8 +26,6 @@ namespace BansheeEngine
 
 
 		updateAreas();
 		updateAreas();
 
 
-		mMenuBar->addMenuItem(L"File/New project", nullptr, 100);
-		mMenuBar->addMenuItem(L"File/Open project", nullptr, 100);
 		mMenuBar->addSeparator(L"File", 0);
 		mMenuBar->addSeparator(L"File", 0);
 		mMenuBar->addMenuItem(L"File/Exit", nullptr, 0);
 		mMenuBar->addMenuItem(L"File/Exit", nullptr, 0);
 
 

+ 84 - 1
MBansheeEditor/EditorApplication.cs

@@ -1,6 +1,7 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Runtime.CompilerServices;
 using System.Runtime.CompilerServices;
+using System.IO;
 using BansheeEngine;
 using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
@@ -111,7 +112,7 @@ namespace BansheeEditor
             }
             }
 
 
             if (!IsProjectLoaded)
             if (!IsProjectLoaded)
-                ProjectWindow.Show();
+                ProjectWindow.Open();
         }
         }
 
 
         private static void OnAssetModified(string path)
         private static void OnAssetModified(string path)
@@ -198,16 +199,98 @@ namespace BansheeEditor
                 continueLoad(path);
                 continueLoad(path);
         }
         }
 
 
+        public static bool IsValidProject(string path)
+        {
+            return Internal_IsValidProject(path);
+        }
+
+        [MenuItem("File/Create Project", 0)]
+        public static void CreateProject()
+        {
+            string projectPath = EditorSettings.LastOpenProject;
+            if (!Directory.Exists(projectPath))
+                projectPath = Directory.GetCurrentDirectory();
+
+            string selectedPath;
+            if (BrowseDialog.OpenFolder(projectPath, "", out selectedPath))
+            {
+                CreateProject(selectedPath);
+                LoadProject(selectedPath);
+            }
+        }
+
+        public static void CreateProject(string path)
+        {
+            // TODO
+        }
+
+        [MenuItem("File/Load Project", 0)]
+        public static void BrowseForProject()
+        {
+            string projectPath = EditorSettings.LastOpenProject;
+            if (!Directory.Exists(projectPath))
+                projectPath = Directory.GetCurrentDirectory();
+
+            string selectedPath;
+            if (BrowseDialog.OpenFolder(projectPath, "", out selectedPath))
+                LoadProject(selectedPath);
+        }
+
+        [MenuItem("File/Save Project", 0)]
+        public static void SaveProject()
+        {
+            // TODO
+        }
+
         public static void LoadProject(string path)
         public static void LoadProject(string path)
         {
         {
+            if (IsProjectLoaded && path == ProjectPath)
+                return;
+
             if (Internal_IsValidProject(path))
             if (Internal_IsValidProject(path))
             {
             {
                 Debug.LogWarning("Provided path: \"" + path + "\" is not a valid project.");
                 Debug.LogWarning("Provided path: \"" + path + "\" is not a valid project.");
                 return;
                 return;
             }
             }
 
 
+            if (IsProjectLoaded)
+                UnloadProject();
+
             Internal_LoadProject(path);
             Internal_LoadProject(path);
 
 
+            if (IsProjectLoaded)
+            {
+                RecentProject[] recentProjects = EditorSettings.RecentProjects;
+                bool foundPath = false;
+                for (int i = 0; i < recentProjects.Length; i++)
+                {
+                    if (PathEx.Compare(recentProjects[i].path, path))
+                    {
+                        recentProjects[i].accessTimestamp = (ulong)DateTime.Now.Ticks;
+                        EditorSettings.RecentProjects = recentProjects;
+                        foundPath = true;
+                        break;
+                    }
+                }
+
+                if (!foundPath)
+                {
+                    List<RecentProject> extendedRecentProjects = new List<RecentProject>();
+                    extendedRecentProjects.AddRange(recentProjects);
+
+                    RecentProject newProject = new RecentProject();
+                    newProject.path = path;
+                    newProject.accessTimestamp = (ulong) DateTime.Now.Ticks;
+
+                    extendedRecentProjects.Add(newProject);
+
+                    EditorSettings.RecentProjects = extendedRecentProjects.ToArray();
+                }
+
+                EditorSettings.LastOpenProject = ProjectPath;
+                EditorSettings.Save();
+            }
+
             ProjectLibrary.Refresh();
             ProjectLibrary.Refresh();
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor = new FolderMonitor(ProjectLibrary.ResourceFolder);
             monitor.OnAdded += OnAssetModified;
             monitor.OnAdded += OnAssetModified;

+ 1 - 0
MBansheeEditor/EditorStyles.cs

@@ -19,5 +19,6 @@ namespace BansheeEditor
         public const string ColorSliderVert = "ColorSliderVert";
         public const string ColorSliderVert = "ColorSliderVert";
         public const string ColorSlider2DHandle = "ColorSlider2DHandle";
         public const string ColorSlider2DHandle = "ColorSlider2DHandle";
         public const string SelectionArea = "SelectionArea";
         public const string SelectionArea = "SelectionArea";
+        public const string SelectableLabel = "SelectableLabel";
     }
     }
 }
 }

+ 4 - 4
MBansheeEditor/LibraryWindow.cs

@@ -1714,16 +1714,16 @@ namespace BansheeEditor
             switch (activeType)
             switch (activeType)
             {
             {
                 case ProjectViewType.List16:
                 case ProjectViewType.List16:
-                    list16.ToggleOn();
+                    list16.Value = true;
                     break;
                     break;
                 case ProjectViewType.Grid32:
                 case ProjectViewType.Grid32:
-                    grid32.ToggleOn();
+                    grid32.Value = true;
                     break;
                     break;
                 case ProjectViewType.Grid48:
                 case ProjectViewType.Grid48:
-                    grid48.ToggleOn();
+                    grid48.Value = true;
                     break;
                     break;
                 case ProjectViewType.Grid64:
                 case ProjectViewType.Grid64:
-                    grid64.ToggleOn();
+                    grid64.Value = true;
                     break;
                     break;
             }
             }
 
 

+ 166 - 0
MBansheeEditor/ProjectWindow.cs

@@ -1,12 +1,178 @@
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using BansheeEngine;
 
 
 namespace BansheeEditor
 namespace BansheeEditor
 {
 {
     public class ProjectWindow : ModalWindow
     public class ProjectWindow : ModalWindow
     {
     {
+        private GUITextField projectInputBox;
+        private GUIScrollArea recentProjectsArea;
+        private GUIToggle autoLoadToggle;
+
+        public static ProjectWindow Open()
+        {
+            return new ProjectWindow();
+        }
+
+        protected ProjectWindow()
+            : base(false)
+        {
+            Title = "Project Manager";
+
+            Width = 500;
+            Height = 350;
+        }
+
+        private void OnInitialize()
+        {
+            GUILayout vertLayout = GUI.AddLayoutY();
+            GUILayout firstRow = vertLayout.AddLayoutX();
+            GUILayout secondRow = vertLayout.AddLayoutX();
+            GUILayout thirdRow = vertLayout.AddLayoutX();
+
+            projectInputBox = new GUITextField(new LocEdString("Project path"), 70);
+            projectInputBox.Value = EditorSettings.LastOpenProject;
+
+            GUIButton openBtn = new GUIButton(new LocEdString("Open"));
+            openBtn.OnClick += OpenProject;
+
+            firstRow.AddElement(projectInputBox);
+            firstRow.AddElement(openBtn);
+
+            recentProjectsArea = new GUIScrollArea();
+            secondRow.AddElement(recentProjectsArea);
+
+            GUILayout browseBtnLayout = secondRow.AddLayoutY();
+            GUIButton browseBtn = new GUIButton(new LocEdString("Browse"));
+            browseBtn.OnClick += BrowseClicked;
+            browseBtnLayout.AddElement(browseBtn);
+            browseBtnLayout.AddFlexibleSpace();
+
+            autoLoadToggle = new GUIToggle("");
+            autoLoadToggle.Value = EditorSettings.AutoLoadLastProject;
+
+            GUILabel autoLoadLabel = new GUILabel(new LocEdString("Automatically load last open project"));
+
+            GUIButton createBtn = new GUIButton(new LocEdString("Create"));
+            createBtn.OnClick += CreateClicked;
+
+            thirdRow.AddElement(autoLoadToggle);
+            thirdRow.AddElement(autoLoadLabel);
+            thirdRow.AddFlexibleSpace();
+            thirdRow.AddElement(createBtn);
+
+            RefreshRecentProjects();
+        }
+
+        void OpenProject()
+        {
+            string projectPath = projectInputBox.Value;
+
+            if (EditorApplication.IsValidProject(projectPath))
+            {
+                EditorSettings.AutoLoadLastProject = autoLoadToggle.Value;
+
+                Close();
+                EditorApplication.LoadProject(projectPath);
+            }
+            else
+            {
+                // Remove invalid project from recent projects list
+                RecentProject[] recentProjects = EditorSettings.RecentProjects;
+                bool foundPath = false;
+                for (int i = 0; i < recentProjects.Length; i++)
+                {
+                    if (PathEx.Compare(recentProjects[i].path, projectPath))
+                    {
+                        RecentProject[] newRecentProjects = new RecentProject[recentProjects.Length - 1];
+                        int idx = 0;
+                        for (int j = 0; j < recentProjects.Length; j++)
+                        {
+                            if (i == j)
+                                continue;
+
+                            newRecentProjects[idx] = recentProjects[j];
+                            idx++;
+                        }
+
+                        EditorSettings.RecentProjects = newRecentProjects;
+                        EditorSettings.Save();
+
+                        break;
+                    }
+                }
+
+                // Warn user
+                LocString message = new LocEdString("Provided project path \"") + projectPath +
+                                    new LocEdString("\" doesn't contain a valid project.");
+
+                DialogBox.Open(new LocEdString("Error"), message, DialogBox.Type.OK);
+            }
+        }
+
+        void BrowseClicked()
+        {
+            string projectPath = projectInputBox.Value;
+            if (!Directory.Exists(projectPath))
+                projectPath = Directory.GetCurrentDirectory();
+
+            string selectedPath;
+            if (BrowseDialog.OpenFolder(projectPath, "", out selectedPath))
+                projectInputBox.Value = selectedPath;
+        }
+
+        void CreateClicked()
+        {
+            string projectPath = projectInputBox.Value;
+            if (!Directory.Exists(projectPath))
+                projectPath = Directory.GetCurrentDirectory();
+
+            string selectedPath;
+            if (BrowseDialog.OpenFolder(projectPath, "", out selectedPath))
+            {
+                projectInputBox.Value = selectedPath;
+
+                EditorApplication.CreateProject(selectedPath);
+                OpenProject();
+            }
+        }
+
+        private void RefreshRecentProjects()
+        {
+            GUILayout scrollLayout = recentProjectsArea.Layout;
+            while(scrollLayout.GetNumChildren() > 0)
+                scrollLayout.GetChild(0).Destroy();
+
+            RecentProject[] recentProjects = EditorSettings.RecentProjects;
+            Array.Sort(recentProjects, (a, b) => a.accessTimestamp.CompareTo(b.accessTimestamp));
+
+            GUIToggleGroup grp = new GUIToggleGroup();
+            for (int i = 0; i < recentProjects.Length; i++)
+            {
+                string projectPath = recentProjects[i].path;
+
+                GUIToggle entryBtn = new GUIToggle(projectPath, grp, EditorStyles.SelectableLabel);
+                entryBtn.OnClick += () => OnEntryClicked(projectPath);
+                entryBtn.OnDoubleClick += () => OnEntryDoubleClicked(projectPath);
+
+                scrollLayout.AddElement(entryBtn);
+            }
+        }
+
+        void OnEntryClicked(string path)
+        {
+            projectInputBox.Value = path;
+        }
+
+        void OnEntryDoubleClicked(string path)
+        {
+            projectInputBox.Value = path;
+            OpenProject();
+        }
     }
     }
 }
 }

+ 12 - 12
MBansheeEditor/Scene/SceneWindow.cs

@@ -409,50 +409,50 @@ namespace BansheeEditor
             switch (EditorApplication.ActiveSceneTool)
             switch (EditorApplication.ActiveSceneTool)
             {
             {
                 case SceneViewTool.View:
                 case SceneViewTool.View:
-                    viewButton.ToggleOn();
+                    viewButton.Value = true;
                     break;
                     break;
                 case SceneViewTool.Move:
                 case SceneViewTool.Move:
-                    moveButton.ToggleOn();
+                    moveButton.Value = true;
                     break;
                     break;
                 case SceneViewTool.Rotate:
                 case SceneViewTool.Rotate:
-                    rotateButton.ToggleOn();
+                    rotateButton.Value = true;
                     break;
                     break;
                 case SceneViewTool.Scale:
                 case SceneViewTool.Scale:
-                    scaleButton.ToggleOn();
+                    scaleButton.Value = true;
                     break;
                     break;
             }
             }
 
 
             switch (EditorApplication.ActiveCoordinateMode)
             switch (EditorApplication.ActiveCoordinateMode)
             {
             {
                 case HandleCoordinateMode.Local:
                 case HandleCoordinateMode.Local:
-                    localCoordButton.ToggleOn();
+                    localCoordButton.Value = true;
                     break;
                     break;
                 case HandleCoordinateMode.World:
                 case HandleCoordinateMode.World:
-                    worldCoordButton.ToggleOn();
+                    worldCoordButton.Value = true;
                     break;
                     break;
             }
             }
 
 
             switch (EditorApplication.ActivePivotMode)
             switch (EditorApplication.ActivePivotMode)
             {
             {
                 case HandlePivotMode.Center:
                 case HandlePivotMode.Center:
-                    centerButton.ToggleOn();
+                    centerButton.Value = true;
                     break;
                     break;
                 case HandlePivotMode.Pivot:
                 case HandlePivotMode.Pivot:
-                    pivotButton.ToggleOn();
+                    pivotButton.Value = true;
                     break;
                     break;
             }
             }
 
 
             if (Handles.MoveHandleSnapActive)
             if (Handles.MoveHandleSnapActive)
-                moveSnapButton.ToggleOn();
+                moveSnapButton.Value = true;
             else
             else
-                moveSnapButton.ToggleOff();
+                moveSnapButton.Value = false;
 
 
             moveSnapInput.Value = Handles.MoveSnapAmount;
             moveSnapInput.Value = Handles.MoveSnapAmount;
 
 
             if (Handles.RotateHandleSnapActive)
             if (Handles.RotateHandleSnapActive)
-                rotateSnapButton.ToggleOn();
+                rotateSnapButton.Value = true;
             else
             else
-                rotateSnapButton.ToggleOff();
+                rotateSnapButton.Value = false;
 
 
             moveSnapInput.Value = Handles.RotateSnapAmount.Degrees;
             moveSnapInput.Value = Handles.RotateSnapAmount.Degrees;
         }
         }

+ 16 - 12
MBansheeEngine/GUI/GUIToggle.cs

@@ -9,11 +9,19 @@ namespace BansheeEngine
         public delegate void OnHoverDelegate();
         public delegate void OnHoverDelegate();
         public delegate void OnOutDelegate();
         public delegate void OnOutDelegate();
         public delegate void OnToggleDelegate(bool toggled);
         public delegate void OnToggleDelegate(bool toggled);
+        public delegate void OnDoubleClickDelegate();
 
 
         public event OnClickDelegate OnClick;
         public event OnClickDelegate OnClick;
         public event OnHoverDelegate OnHover;
         public event OnHoverDelegate OnHover;
         public event OnOutDelegate OnOut;
         public event OnOutDelegate OnOut;
         public event OnToggleDelegate OnToggled;
         public event OnToggleDelegate OnToggled;
+        public event OnDoubleClickDelegate OnDoubleClick;
+
+        public bool Value
+        {
+            get { return Internal_GetValue(mCachedPtr); }
+            set { Internal_SetValue(mCachedPtr, value); }
+        }
 
 
         public GUIToggle(GUIContent content, GUIToggleGroup toggleGroup, string style, params GUIOption[] options)
         public GUIToggle(GUIContent content, GUIToggleGroup toggleGroup, string style, params GUIOption[] options)
         {
         {
@@ -50,16 +58,6 @@ namespace BansheeEngine
             Internal_SetContent(mCachedPtr, content);
             Internal_SetContent(mCachedPtr, content);
         }
         }
 
 
-        public void ToggleOn()
-        {
-            Internal_ToggleOn(mCachedPtr);
-        }
-
-        public void ToggleOff()
-        {
-            Internal_ToggleOff(mCachedPtr);
-        }
-
         public void SetTint(Color color)
         public void SetTint(Color color)
         {
         {
             Internal_SetTint(mCachedPtr, color);
             Internal_SetTint(mCachedPtr, color);
@@ -89,6 +87,12 @@ namespace BansheeEngine
                 OnToggled(toggled);
                 OnToggled(toggled);
         }
         }
 
 
+        private void DoOnDoubleClick()
+        {
+            if (OnDoubleClick != null)
+                OnDoubleClick();
+        }
+
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_CreateInstance(GUIToggle instance, GUIContent content,
         private static extern void Internal_CreateInstance(GUIToggle instance, GUIContent content,
             GUIToggleGroup toggleGroup, string style, GUIOption[] options);
             GUIToggleGroup toggleGroup, string style, GUIOption[] options);
@@ -97,10 +101,10 @@ namespace BansheeEngine
         private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
         private static extern void Internal_SetContent(IntPtr nativeInstance, GUIContent content);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_ToggleOn(IntPtr nativeInstance);
+        private static extern bool Internal_GetValue(IntPtr nativeInstance);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_ToggleOff(IntPtr nativeInstance);
+        private static extern void Internal_SetValue(IntPtr nativeInstance, bool value);
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);
         private static extern void Internal_SetTint(IntPtr nativeInstance, Color color);

+ 9 - 2
SBansheeEngine/Include/BsScriptGUIToggle.h

@@ -36,24 +36,31 @@ namespace BansheeEngine
 		 */
 		 */
 		static void onToggled(MonoObject* instance, bool toggled);
 		static void onToggled(MonoObject* instance, bool toggled);
 
 
+		/**
+		 * @brief	Triggers when the native toggle button is double-clicked.
+		 */
+		static void onDoubleClick(MonoObject* instance);
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
 		/************************************************************************/
 		static void internal_createInstance(MonoObject* instance, MonoObject* content,
 		static void internal_createInstance(MonoObject* instance, MonoObject* content,
 			MonoObject* toggleGroup, MonoString* style, MonoArray* guiOptions);
 			MonoObject* toggleGroup, MonoString* style, MonoArray* guiOptions);
 		static void internal_setContent(ScriptGUIToggle* nativeInstance, MonoObject* content);
 		static void internal_setContent(ScriptGUIToggle* nativeInstance, MonoObject* content);
-		static void internal_toggleOn(ScriptGUIToggle* nativeInstance);
-		static void internal_toggleOff(ScriptGUIToggle* nativeInstance);
+		static bool internal_getValue(ScriptGUIToggle* nativeInstance);
+		static void internal_setValue(ScriptGUIToggle* nativeInstance, bool value);
 		static void internal_setTint(ScriptGUIToggle* nativeInstance, Color color);
 		static void internal_setTint(ScriptGUIToggle* nativeInstance, Color color);
 
 
 		typedef void (__stdcall *OnClickThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnClickThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnHoverThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnHoverThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnOutThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnOutThunkDef) (MonoObject*, MonoException**);
 		typedef void (__stdcall *OnToggledThunkDef) (MonoObject*, bool toggled, MonoException**);
 		typedef void (__stdcall *OnToggledThunkDef) (MonoObject*, bool toggled, MonoException**);
+		typedef void(__stdcall *OnDoubleClickThunkDef) (MonoObject*, MonoException**);
 
 
 		static OnClickThunkDef onClickThunk;
 		static OnClickThunkDef onClickThunk;
 		static OnHoverThunkDef onHoverThunk;
 		static OnHoverThunkDef onHoverThunk;
 		static OnOutThunkDef onOutThunk;
 		static OnOutThunkDef onOutThunk;
 		static OnToggledThunkDef onToggledThunk;
 		static OnToggledThunkDef onToggledThunk;
+		static OnDoubleClickThunkDef onDoubleClickThunk;
 	};
 	};
 }
 }

+ 18 - 6
SBansheeEngine/Source/BsScriptGUIToggle.cpp

@@ -24,6 +24,7 @@ namespace BansheeEngine
 	ScriptGUIToggle::OnHoverThunkDef ScriptGUIToggle::onHoverThunk;
 	ScriptGUIToggle::OnHoverThunkDef ScriptGUIToggle::onHoverThunk;
 	ScriptGUIToggle::OnOutThunkDef ScriptGUIToggle::onOutThunk;
 	ScriptGUIToggle::OnOutThunkDef ScriptGUIToggle::onOutThunk;
 	ScriptGUIToggle::OnToggledThunkDef ScriptGUIToggle::onToggledThunk;
 	ScriptGUIToggle::OnToggledThunkDef ScriptGUIToggle::onToggledThunk;
+	ScriptGUIToggle::OnDoubleClickThunkDef ScriptGUIToggle::onDoubleClickThunk;
 
 
 	ScriptGUIToggle::ScriptGUIToggle(MonoObject* instance, GUIToggle* toggle)
 	ScriptGUIToggle::ScriptGUIToggle(MonoObject* instance, GUIToggle* toggle)
 		:TScriptGUIElement(instance, toggle)
 		:TScriptGUIElement(instance, toggle)
@@ -35,14 +36,15 @@ namespace BansheeEngine
 	{
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIToggle::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIToggle::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_SetContent", &ScriptGUIToggle::internal_setContent);
 		metaData.scriptClass->addInternalCall("Internal_SetContent", &ScriptGUIToggle::internal_setContent);
-		metaData.scriptClass->addInternalCall("Internal_ToggleOn", &ScriptGUIToggle::internal_toggleOn);
-		metaData.scriptClass->addInternalCall("Internal_ToggleOff", &ScriptGUIToggle::internal_toggleOff);
+		metaData.scriptClass->addInternalCall("Internal_GetValue", &ScriptGUIToggle::internal_getValue);
+		metaData.scriptClass->addInternalCall("Internal_SetValue", &ScriptGUIToggle::internal_setValue);
 		metaData.scriptClass->addInternalCall("Internal_SetTint", &ScriptGUIToggle::internal_setTint);
 		metaData.scriptClass->addInternalCall("Internal_SetTint", &ScriptGUIToggle::internal_setTint);
 
 
 		onClickThunk = (OnClickThunkDef)metaData.scriptClass->getMethod("DoOnClick")->getThunk();
 		onClickThunk = (OnClickThunkDef)metaData.scriptClass->getMethod("DoOnClick")->getThunk();
 		onHoverThunk = (OnHoverThunkDef)metaData.scriptClass->getMethod("DoOnHover")->getThunk();
 		onHoverThunk = (OnHoverThunkDef)metaData.scriptClass->getMethod("DoOnHover")->getThunk();
 		onOutThunk = (OnOutThunkDef)metaData.scriptClass->getMethod("DoOnOut")->getThunk();
 		onOutThunk = (OnOutThunkDef)metaData.scriptClass->getMethod("DoOnOut")->getThunk();
 		onToggledThunk = (OnToggledThunkDef)metaData.scriptClass->getMethod("DoOnToggled", 1)->getThunk();
 		onToggledThunk = (OnToggledThunkDef)metaData.scriptClass->getMethod("DoOnToggled", 1)->getThunk();
+		onDoubleClickThunk = (OnDoubleClickThunkDef)metaData.scriptClass->getMethod("DoOnDoubleClick")->getThunk();
 	}
 	}
 
 
 	void ScriptGUIToggle::internal_createInstance(MonoObject* instance, MonoObject* content, 
 	void ScriptGUIToggle::internal_createInstance(MonoObject* instance, MonoObject* content, 
@@ -69,6 +71,7 @@ namespace BansheeEngine
 		guiToggle->onHover.connect(std::bind(&ScriptGUIToggle::onHover, instance));
 		guiToggle->onHover.connect(std::bind(&ScriptGUIToggle::onHover, instance));
 		guiToggle->onOut.connect(std::bind(&ScriptGUIToggle::onOut, instance));
 		guiToggle->onOut.connect(std::bind(&ScriptGUIToggle::onOut, instance));
 		guiToggle->onToggled.connect(std::bind(&ScriptGUIToggle::onToggled, instance, std::placeholders::_1));
 		guiToggle->onToggled.connect(std::bind(&ScriptGUIToggle::onToggled, instance, std::placeholders::_1));
+		guiToggle->onDoubleClick.connect(std::bind(&ScriptGUIToggle::onDoubleClick, instance));
 
 
 		ScriptGUIToggle* nativeInstance = new (bs_alloc<ScriptGUIToggle>()) ScriptGUIToggle(instance, guiToggle);
 		ScriptGUIToggle* nativeInstance = new (bs_alloc<ScriptGUIToggle>()) ScriptGUIToggle(instance, guiToggle);
 	}
 	}
@@ -81,16 +84,20 @@ namespace BansheeEngine
 		toggle->setContent(nativeContent);
 		toggle->setContent(nativeContent);
 	}
 	}
 
 
-	void ScriptGUIToggle::internal_toggleOn(ScriptGUIToggle* nativeInstance)
+	bool ScriptGUIToggle::internal_getValue(ScriptGUIToggle* nativeInstance)
 	{
 	{
 		GUIToggle* toggle = (GUIToggle*)nativeInstance->getGUIElement();
 		GUIToggle* toggle = (GUIToggle*)nativeInstance->getGUIElement();
-		toggle->toggleOn();
+		return toggle->isToggled();
 	}
 	}
 
 
-	void ScriptGUIToggle::internal_toggleOff(ScriptGUIToggle* nativeInstance)
+	void ScriptGUIToggle::internal_setValue(ScriptGUIToggle* nativeInstance, bool value)
 	{
 	{
 		GUIToggle* toggle = (GUIToggle*)nativeInstance->getGUIElement();
 		GUIToggle* toggle = (GUIToggle*)nativeInstance->getGUIElement();
-		toggle->toggleOff();
+
+		if (value)
+			toggle->toggleOn();
+		else
+			toggle->toggleOff();
 	}
 	}
 
 
 	void ScriptGUIToggle::internal_setTint(ScriptGUIToggle* nativeInstance, Color color)
 	void ScriptGUIToggle::internal_setTint(ScriptGUIToggle* nativeInstance, Color color)
@@ -118,4 +125,9 @@ namespace BansheeEngine
 	{
 	{
 		MonoUtil::invokeThunk(onToggledThunk, instance, toggled);
 		MonoUtil::invokeThunk(onToggledThunk, instance, toggled);
 	}
 	}
+
+	void ScriptGUIToggle::onDoubleClick(MonoObject* instance)
+	{
+		MonoUtil::invokeThunk(onDoubleClickThunk, instance);
+	}
 }
 }

+ 4 - 19
TODO.txt

@@ -56,27 +56,12 @@ Move data folder within current repo
  - Store default layout asset in Data/Editor folder
  - Store default layout asset in Data/Editor folder
  - Store data generated by editor runtime at Data/Runtime
  - Store data generated by editor runtime at Data/Runtime
 
 
-Add Create Project & Open Project entries in main menu
-Store last open project location, should the last project be loaded by default, and a list of all known projects (listed by last opened date)
-(Store last open level too in ProjectSettings)
-ProjectWindow
- - Show this on start-up if last open project is empty or load last project is off
-  - Main editor window should show up but nothing should be loaded in it 
-    (see how to handle that best? - isProjectLoaded() and have ProjectLibrary and similar check for that)
-  - Contains an input box for project to open
-  - Below it is a scroll are with a list of most recent projects, selecting one changes the value in input box, double-clicking opens that project
-  - To the right is a Browse button that allows you to find an existing project
-    - When selected call a method CheckIfValidProject that confirms selected folder exists and has all the proper files, throw warning otherwise
-      - Do this when opening a project from the most recent list as well, if it fails remove it from most recent list
-    - Browsed to project is added to the most recent list and opened, if valid
-  - Below browse is Load button that loads the project currently in the input box (with the check above)
-  - On the bottom below Load is Create button that allows you to choose a folder in which to create a new project
-
-When creating a new project:
+EditorApplication.SaveProject not implemented
+ - Separate Unload project into Save & Unload
+
+EditorApplication.CreateProject not implemented
  - Copy default layout from Data/Editor to the project folder
  - Copy default layout from Data/Editor to the project folder
  - Create Resources & Internal folders
  - Create Resources & Internal folders
- - Unload the current project (clear scene, clear project library)
- - Refresh project library so it points to new location
 
 
 TODO - On project unload and load I need to trigger assembly reload
 TODO - On project unload and load I need to trigger assembly reload
 TODO - Test if project loading/unloading/reloading works
 TODO - Test if project loading/unloading/reloading works