Просмотр исходного кода

Saving a scene properly re-loads the scene
Automatically loading the scene properly displays the scene in the status bar
Added collaborators to the About Box
Fixed start-up issues with ProgressBar window since the change when OnInitialize is triggered
Modal windows can now be closed by hitting the X button

BearishSun 10 лет назад
Родитель
Сommit
8cc7fecd61

+ 5 - 1
BansheeEditor/Source/BsModalWindow.cpp

@@ -121,8 +121,12 @@ namespace BansheeEngine
 		mContents->setWidth(getWidth() - 2);
 		mContents->setWidth(getWidth() - 2);
 		mContents->setHeight(getHeight() - 2 - getTitleBarHeight());
 		mContents->setHeight(getHeight() - 2 - getTitleBarHeight());
 
 
+		UINT32 captionWidth = getWidth() - 2;
+		if (mCloseButton != nullptr)
+			captionWidth = mCloseButton->getGlobalBounds().x;
+
 		Vector<Rect2I> captionAreas;
 		Vector<Rect2I> captionAreas;
-		captionAreas.push_back(Rect2I(1, 1, getWidth() - 2, getTitleBarHeight()));
+		captionAreas.push_back(Rect2I(1, 1, captionWidth, getTitleBarHeight()));
 
 
 		Platform::setCaptionNonClientAreas(*mRenderWindow->getCore().get(), captionAreas);
 		Platform::setCaptionNonClientAreas(*mRenderWindow->getCore().get(), captionAreas);
 	}
 	}

+ 3 - 1
BansheeEngine/Include/BsGUIToggle.h

@@ -96,8 +96,10 @@ namespace BansheeEngine
 		/**
 		/**
 		 * @brief	Creates a toggle group that you may provide to GUIToggle upon construction. Toggles sharing the
 		 * @brief	Creates a toggle group that you may provide to GUIToggle upon construction. Toggles sharing the
 		 *			same group will only have a single element active at a time.
 		 *			same group will only have a single element active at a time.
+		 *
+		 * @param	allowAllOff	If true all of the toggle buttons can be turned off, if false one will always be turned on.
 		 */
 		 */
-		static std::shared_ptr<GUIToggleGroup> createToggleGroup();
+		static std::shared_ptr<GUIToggleGroup> createToggleGroup(bool allowAllOff = false);
 
 
 		/**
 		/**
 		 * @brief	Checks the toggle, making it active.
 		 * @brief	Checks the toggle, making it active.

+ 2 - 1
BansheeEngine/Include/BsGUIToggleGroup.h

@@ -30,7 +30,7 @@ namespace BansheeEngine
 	private:
 	private:
 		friend class GUIToggle;
 		friend class GUIToggle;
 
 
-		GUIToggleGroup() {}
+		GUIToggleGroup(bool allowAllOff);
 
 
 		/**
 		/**
 		 * @brief	Initializes the toggle group. To be called right after construction.
 		 * @brief	Initializes the toggle group. To be called right after construction.
@@ -38,6 +38,7 @@ namespace BansheeEngine
 		void initialize(const std::shared_ptr<GUIToggleGroup>& sharedPtr);
 		void initialize(const std::shared_ptr<GUIToggleGroup>& sharedPtr);
 
 
 		Vector<GUIToggle*> mButtons;
 		Vector<GUIToggle*> mButtons;
+		bool mAllowAllOff;
 		std::weak_ptr<GUIToggleGroup> mThis;
 		std::weak_ptr<GUIToggleGroup> mThis;
 	};
 	};
 }
 }

+ 4 - 4
BansheeEngine/Source/BsGUIToggle.cpp

@@ -75,9 +75,9 @@ namespace BansheeEngine
 		return new (bs_alloc<GUIToggle>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, toggleGroup, GUIDimensions::create(options));
 		return new (bs_alloc<GUIToggle>()) GUIToggle(getStyleName<GUIToggle>(styleName), content, toggleGroup, GUIDimensions::create(options));
 	}
 	}
 
 
-	std::shared_ptr<GUIToggleGroup> GUIToggle::createToggleGroup()
+	std::shared_ptr<GUIToggleGroup> GUIToggle::createToggleGroup(bool allowAllOff)
 	{
 	{
-		std::shared_ptr<GUIToggleGroup> toggleGroup = std::shared_ptr<GUIToggleGroup>(new GUIToggleGroup());
+		std::shared_ptr<GUIToggleGroup> toggleGroup = std::shared_ptr<GUIToggleGroup>(new GUIToggleGroup(allowAllOff));
 		toggleGroup->initialize(toggleGroup);
 		toggleGroup->initialize(toggleGroup);
 
 
 		return toggleGroup;
 		return toggleGroup;
@@ -105,7 +105,7 @@ namespace BansheeEngine
 
 
 			}
 			}
 
 
-			if(!isToggled)
+			if(!isToggled && !toggleGroup->mAllowAllOff)
 				toggleOn();
 				toggleOn();
 		}
 		}
 	}
 	}
@@ -156,7 +156,7 @@ namespace BansheeEngine
 		else
 		else
 			canBeToggledOff = true;
 			canBeToggledOff = true;
 
 
-		if(canBeToggledOff)
+		if (canBeToggledOff || mToggleGroup->mAllowAllOff)
 		{
 		{
 			mIsToggled = false;
 			mIsToggled = false;
 
 

+ 4 - 0
BansheeEngine/Source/BsGUIToggleGroup.cpp

@@ -3,6 +3,10 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
+	GUIToggleGroup::GUIToggleGroup(bool allowAllOff)
+		:mAllowAllOff(allowAllOff)
+	{ }
+
 	GUIToggleGroup::~GUIToggleGroup()
 	GUIToggleGroup::~GUIToggleGroup()
 	{
 	{
 		for(auto& button : mButtons)
 		for(auto& button : mButtons)

+ 32 - 5
MBansheeEditor/AboutBox.cs

@@ -29,7 +29,7 @@ namespace BansheeEditor
         {
         {
             Title = "About";
             Title = "About";
             Width = 400;
             Width = 400;
-            Height = 350;
+            Height = 400;
         }
         }
 
 
         private void OnInitialize()
         private void OnInitialize()
@@ -46,9 +46,11 @@ namespace BansheeEditor
             GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150));
             GUILabel linkedInTitle = new GUILabel(new LocEdString("LinkedIn"), GUIOption.FixedWidth(150));
             GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile"));
             GUIButton linkedInBtn = new GUIButton(new LocEdString("Profile"));
 
 
-            GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author contact"), EditorStyles.Foldout);
-            GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), EditorStyles.Foldout);
-            GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), EditorStyles.Foldout);
+            GUIToggleGroup foldoutGroup = new GUIToggleGroup(true);
+            GUIToggle contactFoldout = new GUIToggle(new LocEdString("Author contact"), foldoutGroup, EditorStyles.Foldout);
+            GUIToggle thirdPartyFoldout = new GUIToggle(new LocEdString("Used third party libraries"), foldoutGroup, EditorStyles.Foldout);
+            GUIToggle noticesFoldout = new GUIToggle(new LocEdString("Third party notices"), foldoutGroup, EditorStyles.Foldout);
+            GUIToggle collaboratorsFoldout = new GUIToggle(new LocEdString("Collaborators"), foldoutGroup, EditorStyles.Foldout);
 
 
             GUILabel freeTypeNotice = new GUILabel(new LocEdString(
             GUILabel freeTypeNotice = new GUILabel(new LocEdString(
                         "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " +
                         "Portions of this software are copyright (C) 2015 The FreeType Project (www.freetype.org). " +
@@ -106,10 +108,19 @@ namespace BansheeEditor
             noticesLayout.AddElement(freeTypeNotice);
             noticesLayout.AddElement(freeTypeNotice);
             noticesLayout.AddSpace(10);
             noticesLayout.AddSpace(10);
             noticesLayout.AddElement(fbxSdkNotice);
             noticesLayout.AddElement(fbxSdkNotice);
+
+            mainLayout.AddSpace(5);
+            mainLayout.AddElement(collaboratorsFoldout);
+            GUILayoutY collaboratorsLayout = mainLayout.AddLayoutY();
+            CreateCollaboratorGUI(collaboratorsLayout, "Danijel Ribic", "Logo, UI icons, 3D models & textures");
+
             mainLayout.AddFlexibleSpace();
             mainLayout.AddFlexibleSpace();
 
 
             contactLayout.Active = false;
             contactLayout.Active = false;
-            contactFoldout.OnToggled += x => contactLayout.Active = x;
+            contactFoldout.OnToggled += x =>
+            {
+                contactLayout.Active = x;
+            };
 
 
             thirdPartyLayout.Active = false;
             thirdPartyLayout.Active = false;
             thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x;
             thirdPartyFoldout.OnToggled += x => thirdPartyLayout.Active = x;
@@ -117,6 +128,9 @@ namespace BansheeEditor
             noticesLayout.Active = false;
             noticesLayout.Active = false;
             noticesFoldout.OnToggled += x => noticesLayout.Active = x;
             noticesFoldout.OnToggled += x => noticesLayout.Active = x;
 
 
+            collaboratorsLayout.Active = false;
+            collaboratorsFoldout.OnToggled += x => collaboratorsLayout.Active = x;
+
             emailLabel.Text = "[email protected]";
             emailLabel.Text = "[email protected]";
             linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); };
             linkedInBtn.OnClick += () => { System.Diagnostics.Process.Start("http://hr.linkedin.com/in/markopintera"); };
         }
         }
@@ -142,6 +156,19 @@ namespace BansheeEditor
             licenseBtn.OnClick += () => { System.Diagnostics.Process.Start(licensePath); };
             licenseBtn.OnClick += () => { System.Diagnostics.Process.Start(licensePath); };
         }
         }
 
 
+        private void CreateCollaboratorGUI(GUILayoutY layout, string name, string area)
+        {
+            GUILabel nameLabel = new GUILabel(new LocEdString(name), GUIOption.FixedWidth(150));
+            GUILabel areaLabel = new GUILabel(new LocEdString(area), GUIOption.FixedWidth(220));
+
+            GUILayoutX horzLayout = layout.AddLayoutX();
+            horzLayout.AddSpace(10);
+            horzLayout.AddElement(nameLabel);
+            horzLayout.AddSpace(10);
+            horzLayout.AddElement(areaLabel);
+            horzLayout.AddSpace(10);
+        }
+
         private void OnEditorUpdate()
         private void OnEditorUpdate()
         {
         {
             emailLabel.Text = "[email protected]";
             emailLabel.Text = "[email protected]";

+ 4 - 0
MBansheeEditor/EditorApplication.cs

@@ -286,6 +286,7 @@ namespace BansheeEditor
         public static void SaveScene(string path)
         public static void SaveScene(string path)
         {
         {
             Internal_SaveScene(path);
             Internal_SaveScene(path);
+            ProjectLibrary.Refresh(true);
             SetSceneDirty(false);
             SetSceneDirty(false);
         }
         }
 
 
@@ -469,7 +470,10 @@ namespace BansheeEditor
             monitor.OnModified += OnAssetModified;
             monitor.OnModified += OnAssetModified;
 
 
             if (!string.IsNullOrWhiteSpace(ProjectSettings.LastOpenScene))
             if (!string.IsNullOrWhiteSpace(ProjectSettings.LastOpenScene))
+            {
                 Scene.Load(ProjectSettings.LastOpenScene);
                 Scene.Load(ProjectSettings.LastOpenScene);
+                SetSceneDirty(false);
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>

+ 38 - 24
MBansheeEditor/ProgressBar.cs

@@ -13,12 +13,24 @@ namespace BansheeEditor
         private GUIProgressBar progressBar;
         private GUIProgressBar progressBar;
         private GUILabel messageLabel;
         private GUILabel messageLabel;
 
 
+        private LocString message;
+        private float percent = 0.0f;
+
+        /// <summary>
+        /// Determines the message displayed above the progress bar.
+        /// </summary>
+        public LocString Message
+        {
+            set { messageLabel.SetContent(value); message = value; }
+            get { return message; }
+        }
+
         /// <summary>
         /// <summary>
         /// Determines size of the filled portion of the progress bar, in range [0, 1].
         /// Determines size of the filled portion of the progress bar, in range [0, 1].
         /// </summary>
         /// </summary>
         public float Percent
         public float Percent
         {
         {
-            set { progressBar.Percent = value; }
+            set { progressBar.Percent = value; percent = value; }
             get { return progressBar.Percent; }
             get { return progressBar.Percent; }
         }
         }
 
 
@@ -41,25 +53,13 @@ namespace BansheeEditor
         public static void Show(LocString title, LocString message, float percent)
         public static void Show(LocString title, LocString message, float percent)
         {
         {
             if (instance == null)
             if (instance == null)
-                instance = new ProgressBar();
-
-            instance.Initialize(title, message, percent);
-        }
-
-        /// <summary>
-        /// Initializes the progress bar window. Must be called after construction and before use.
-        /// </summary>
-        /// <param name="title">Text to show in the title.</param>
-        /// <param name="message">Message to show above the progress bar.</param>
-        /// <param name="percent">Initial value to show the progress as, in range [0, 1].</param>
-        private void Initialize(LocString title, LocString message, float percent)
-        {
-            Width = 350;
-            Height = 75;
-
-            Title = title;
-            Percent = percent;
-            messageLabel.SetContent(message);
+                instance = new ProgressBar(title, message, percent);
+            else
+            {
+                instance.Title = title;
+                instance.Message = message;
+                instance.Percent = percent;
+            }
         }
         }
 
 
         /// <summary>
         /// <summary>
@@ -74,11 +74,22 @@ namespace BansheeEditor
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Creates a new uninitialized progress bar.
+        /// Creates a new progress bar window.
         /// </summary>
         /// </summary>
-        protected ProgressBar()
-            :base(false)
-        { }
+        /// <param name="title">Text to show in the title.</param>
+        /// <param name="message">Message to show above the progress bar.</param>
+        /// <param name="percent">Initial value to show the progress as, in range [0, 1].</param>
+        protected ProgressBar(LocString title, LocString message, float percent)
+            : base(false)
+        {
+            Width = 350;
+            Height = 75;
+
+            Title = title;
+
+            this.message = message;
+            this.percent = percent;
+        }
 
 
         private void OnInitialize()
         private void OnInitialize()
         {
         {
@@ -101,6 +112,9 @@ namespace BansheeEditor
             barLayout.AddSpace(30);
             barLayout.AddSpace(30);
 
 
             layoutY.AddFlexibleSpace();
             layoutY.AddFlexibleSpace();
+
+            Percent = percent;
+            messageLabel.SetContent(message);
         }
         }
     }
     }
 }
 }

+ 20 - 5
MBansheeEditor/ProjectLibrary.cs

@@ -43,13 +43,28 @@ namespace BansheeEditor
         /// <summary>
         /// <summary>
         /// Checks the project library folder for any modifications and reimports the required resources.
         /// Checks the project library folder for any modifications and reimports the required resources.
         /// </summary>
         /// </summary>
-        public static void Refresh()
+        /// <param name="synchronous">If true this method will block until the project library has done refreshing, 
+        ///                           otherwise the refresh will happen over the course of this and next frames.</param>
+        public static void Refresh(bool synchronous = false)
         {
         {
-            string[] modifiedPaths = Internal_Refresh(ResourceFolder, false);
-            foreach (var modifiedPath in modifiedPaths)
+            string[] modifiedPaths = Internal_Refresh(ResourceFolder, synchronous);
+
+            if (!synchronous)
             {
             {
-                if (queuedForImport.Add(modifiedPath))
-                    totalFilesToImport++;
+                foreach (var modifiedPath in modifiedPaths)
+                {
+                    if (queuedForImport.Add(modifiedPath))
+                        totalFilesToImport++;
+                }
+            }
+            else
+            {
+                foreach (var path in queuedForImport)
+                    Internal_Refresh(path, true);
+
+                queuedForImport.Clear();
+                numImportedFiles = 0;
+                totalFilesToImport = 0;
             }
             }
         }
         }
 
 

+ 5 - 3
MBansheeEngine/GUI/GUIToggleGroup.cs

@@ -11,12 +11,14 @@ namespace BansheeEngine
         /// <summary>
         /// <summary>
         /// Creates a new toggle group.
         /// Creates a new toggle group.
         /// </summary>
         /// </summary>
-        public GUIToggleGroup()
+        /// <param name="allowAllOff">If true all of the toggle buttons can be turned off, if false one will always be
+        ///                           turned on.</param>
+        public GUIToggleGroup(bool allowAllOff = false)
         {
         {
-            Internal_CreateInstance(this);
+            Internal_CreateInstance(this, allowAllOff);
         }
         }
 
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateInstance(GUIToggleGroup instance);
+        private static extern void Internal_CreateInstance(GUIToggleGroup instance, bool allowAllOff);
     }
     }
 }
 }

+ 1 - 1
SBansheeEngine/Include/BsScriptGUIToggleGroup.h

@@ -26,6 +26,6 @@ namespace BansheeEngine
 		/************************************************************************/
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
 		/************************************************************************/
-		static void internal_createInstance(MonoObject* instance);
+		static void internal_createInstance(MonoObject* instance, bool allowAllOff);
 	};
 	};
 }
 }

+ 2 - 2
SBansheeEngine/Source/BsScriptGUIToggleGroup.cpp

@@ -20,9 +20,9 @@ namespace BansheeEngine
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIToggleGroup::internal_createInstance);
 		metaData.scriptClass->addInternalCall("Internal_CreateInstance", &ScriptGUIToggleGroup::internal_createInstance);
 	}
 	}
 
 
-	void ScriptGUIToggleGroup::internal_createInstance(MonoObject* instance)
+	void ScriptGUIToggleGroup::internal_createInstance(MonoObject* instance, bool allowAllOff)
 	{
 	{
-		std::shared_ptr<GUIToggleGroup> toggleGroup = GUIToggle::createToggleGroup();
+		std::shared_ptr<GUIToggleGroup> toggleGroup = GUIToggle::createToggleGroup(allowAllOff);
 
 
 		ScriptGUIToggleGroup* nativeInstance = new (bs_alloc<ScriptGUIToggleGroup>()) ScriptGUIToggleGroup(instance, toggleGroup);
 		ScriptGUIToggleGroup* nativeInstance = new (bs_alloc<ScriptGUIToggleGroup>()) ScriptGUIToggleGroup(instance, toggleGroup);
 	}
 	}