Explorar el Código

C# DialogBox class ready to use
Bugfixes:
- Fixed an issue if an editor window is spawned in another window's update() method
- Fixed mouse input so it is properly registered when over a non-client area (WARNING: Previously I had explicitly blocked this input but I no longer know why)

Marko Pintera hace 10 años
padre
commit
09ea24b888

+ 0 - 6
BansheeCore/Source/Win32/BsWin32Platform.cpp

@@ -978,9 +978,6 @@ namespace BansheeEngine
 					mData->mIsTrackingMouse = true;
 				}
 
-				if(uMsg == WM_NCMOUSEMOVE)
-					return true;
-
 				Vector2I intMousePos;
 				OSPointerButtonStates btnStates;
 				
@@ -1083,15 +1080,12 @@ namespace BansheeEngine
 				break;
 			}
 		case WM_BS_SETCAPTURE:
-			LOGWRN("SET CAPTURE");
 			SetCapture(hWnd);
 			break;
 		case WM_BS_RELEASECAPTURE:
-			LOGWRN("RELEASE CAPTURE");
 			ReleaseCapture();
 			break;
 		case WM_CAPTURECHANGED:
-			LOGWRN("CAPTURE CHANGED");
 			if(!onMouseCaptureChanged.empty())
 				onMouseCaptureChanged();
 			return 0;

+ 2 - 0
BansheeEditor/Include/BsEditorWindowManager.h

@@ -25,5 +25,7 @@ namespace BansheeEngine
 
 		Vector<EditorWindowBase*> mEditorWindows;
 		Vector<EditorWindowBase*> mScheduledForDestruction;
+
+		Vector<EditorWindowBase*> mEditorWindowsSnapshot;
 	};
 }

+ 3 - 1
BansheeEditor/Source/BsEditorWindowManager.cpp

@@ -73,9 +73,11 @@ namespace BansheeEngine
 
 		mScheduledForDestruction.clear();
 
+		// Make a copy since other editors might be opened/closed from editor update() methods
+		mEditorWindowsSnapshot = mEditorWindows; 
 		mMainWindow->update();
 
-		for(auto& window : mEditorWindows)
+		for (auto& window : mEditorWindowsSnapshot)
 		{
 			window->update();
 		}

+ 1 - 1
MBansheeEditor/DebugWindow.cs

@@ -74,7 +74,7 @@ namespace BansheeEditor
             debugSlowDown = true;
         }
 
-        void EditorUpdate()
+        void OnEditorUpdate()
         {
             //if (debugSlowDown)
             //    Thread.Sleep(5000);

+ 28 - 26
MBansheeEditor/DialogBox.cs

@@ -35,6 +35,7 @@ namespace BansheeEditor
 
         private GUILabel messageLabel;
         private ResultType result = ResultType.None;
+        private bool constructed;
 
         public ResultType Result
         {
@@ -43,40 +44,39 @@ namespace BansheeEditor
 
         public static DialogBox Open(LocString title, LocString message, Type type, Action<ResultType> resultCallback = null)
         {
-            DialogBox instance = new DialogBox();
-
-            instance.Width = 250;
-            instance.Height = 150;
-
-            instance.Title = title;
-            instance.type = type;
-            instance.resultCallback = resultCallback;
-
-            return instance;
+            return new DialogBox(title, message, type, resultCallback);
         }
 
-        private void Initialize(LocString title, LocString message, Type type, Action<ResultType> resultCallback)
+        protected DialogBox(LocString title, LocString message, Type type, Action<ResultType> resultCallback)
+            : base(false)
         {
-            Width = 250;
-            Height = 150;
+            this.resultCallback = resultCallback;
+            this.type = type;
+
+            constructed = true;
+            SetupGUI();
 
             Title = title;
             messageLabel.SetContent(message);
-            this.resultCallback = resultCallback;
-            this.type = type;
-        }
 
-        protected DialogBox()
-            : base(false)
-        { }
+            Width = 280;
+            Height = messageLabel.Bounds.height + 60;
+        }
 
         private void OnInitialize()
         {
-            messageLabel = new GUILabel("");
+            if (constructed)
+                SetupGUI();
+        }
+
+        private void SetupGUI()
+        {
+            messageLabel = new GUILabel("", EditorStyles.MultiLineLabel,
+                GUIOption.FixedWidth(260), GUIOption.FlexibleHeight(0, 600));
 
             GUILayoutY layoutY = GUI.AddLayoutY();
 
-            layoutY.AddFlexibleSpace();
+            layoutY.AddSpace(10);
             GUILayoutX messageLayout = layoutY.AddLayoutX();
             messageLayout.AddFlexibleSpace();
             messageLayout.AddElement(messageLabel);
@@ -90,12 +90,12 @@ namespace BansheeEditor
             switch (type)
             {
                 case Type.OK:
-                {
-                    GUIButton okBtn = new GUIButton("OK");
-                    okBtn.OnClick += () => ButtonClicked(ResultType.OK);
+                    {
+                        GUIButton okBtn = new GUIButton("OK");
+                        okBtn.OnClick += () => ButtonClicked(ResultType.OK);
 
-                    btnLayout.AddElement(okBtn);
-                }
+                        btnLayout.AddElement(okBtn);
+                    }
                     break;
                 case Type.OKCancel:
                     {
@@ -202,6 +202,8 @@ namespace BansheeEditor
 
             if (resultCallback != null)
                 resultCallback(result);
+
+            Close();
         }
     }
 }

+ 1 - 1
MBansheeEditor/EditorApplication.cs

@@ -136,7 +136,7 @@ namespace BansheeEditor
             ProjectLibrary.Refresh(path);
         }
 
-        internal void EditorUpdate()
+        internal void OnEditorUpdate()
         {
             ProjectLibrary.Update();
 

+ 1 - 1
MBansheeEditor/Inspector/InspectorWindow.cs

@@ -57,7 +57,7 @@ namespace BansheeEditor
             inspectorData.inspector.SetVisible(expanded);
         }
 
-        private void EditorUpdate()
+        private void OnEditorUpdate()
         {
             for (int i = 0; i < inspectorData.Count; i++)
             {

+ 2 - 2
MBansheeEditor/Program.cs

@@ -31,9 +31,9 @@ namespace BansheeEditor
             //dbgStyle.textColor = newColor;
         }
 
-        static void EditorUpdate()
+        static void OnEditorUpdate()
         {
-            app.EditorUpdate();
+            app.OnEditorUpdate();
         }
     }
 

+ 1 - 1
MBansheeEditor/ProjectWindow.cs

@@ -896,7 +896,7 @@ namespace BansheeEditor
             return destination + extension;
         }
 
-        private void EditorUpdate()
+        private void OnEditorUpdate()
         {
             bool isRenameInProgress = inProgressRenameElement != null;
 

+ 1 - 1
MBansheeEditor/Scene/SceneWindow.cs

@@ -140,7 +140,7 @@ namespace BansheeEditor
             return false;
         }
 
-        private void EditorUpdate()
+        private void OnEditorUpdate()
         {
             // Refresh GUI buttons if needed (in case someones changes the values from script)
             if (editorSettingsHash != EditorSettings.Hash)

+ 1 - 1
SBansheeEditor/Source/BsEditorScriptManager.cpp

@@ -106,7 +106,7 @@ namespace BansheeEngine
 		// TODO - Load Editor script assembly (gEditorApplication.getEditorScriptAssemblyPath())
 
 		mProgramEdClass = mEditorAssembly->getClass("BansheeEditor", "Program");
-		mUpdateMethod = mProgramEdClass->getMethod("EditorUpdate");
+		mUpdateMethod = mProgramEdClass->getMethod("OnEditorUpdate");
 
 		ScriptEditorWindow::clearRegisteredEditorWindow();
 		ScriptEditorWindow::registerManagedEditorWindows();

+ 1 - 1
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -375,7 +375,7 @@ namespace BansheeEngine
 
 	void ScriptEditorWidget::reloadMonoTypes(MonoClass* windowClass)
 	{
-		MonoMethod* updateMethod = windowClass->getMethod("EditorUpdate", 0);
+		MonoMethod* updateMethod = windowClass->getMethod("OnEditorUpdate", 0);
 
 		if (updateMethod != nullptr)
 			mUpdateThunk = (UpdateThunkDef)updateMethod->getThunk();

+ 5 - 5
TODO.txt

@@ -6,6 +6,8 @@ Assembly refresh
 When serializing Camera I cannot save the reference to RenderTexture. Make it a Resource?
 Possibly set up automatic refresh in debug mode after initialization? As an ad-hoc unit test
 
+Modal windows are set up as persistent but I don't serialize their internal data anywhere
+
 ----------------------------------------------------------------------
 C# Material/Shader:
 
@@ -25,14 +27,13 @@ return them in checkForModifications?
 ----------------------------------------------------------------------
 Project window
 
+Test rename & delete
+
 Later:
  - Hook up ping effect so it triggers when I select a resource or sceneobject
   - Add ping to SceneTreeView
  - Consider delaying search until user stops pressing keys (so not to have thousands of search results in the initial stages)
  - Save & restore scroll position when Refresh happens
- - F2 and context menu for renaming assets (or when clicking on a solo selected asset)
-   - Also make sure the names contain only valid path characters
- - Delete with a dialog box to confirm
  - Center labels and add a couple of pixels border from the selection rectangle
 
 ----------------------------------------------------------------------
@@ -56,8 +57,7 @@ Resources
 ----------------------------------------------------------------------
 Simple stuff
 
-C#:
-Dialog.Show(title, text, btn1 text, btn1 callback, btn2 text, btn2 callback, btn3 text, btn3 callback)
+When cursor moves from input box to title bar it remains an input cursor (assuming this is because the non-client area)
 
 Other simple stuff:
  - Inject an icon into an .exe (Win32 specific)