From 425c23fea1712f2fa576cc48559c5dc0ed40b79b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 5 Aug 2021 18:56:55 +0200 Subject: [PATCH] Rename NewWindowMethod to NewWindowLocation and add handling for new asset windows too #577 --- Source/Editor/GUI/Docking/DockWindow.cs | 2 +- Source/Editor/Modules/ContentEditingModule.cs | 44 +++++++++++-------- Source/Editor/Options/InterfaceOptions.cs | 4 +- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Source/Editor/GUI/Docking/DockWindow.cs b/Source/Editor/GUI/Docking/DockWindow.cs index 0d58c00a5..257518ecf 100644 --- a/Source/Editor/GUI/Docking/DockWindow.cs +++ b/Source/Editor/GUI/Docking/DockWindow.cs @@ -241,7 +241,7 @@ namespace FlaxEditor.GUI.Docking /// public void FocusOrShow() { - FocusOrShow((DockState)Editor.Instance.Options.Options.Interface.NewWindowMethod); + FocusOrShow((DockState)Editor.Instance.Options.Options.Interface.NewWindowLocation); } /// diff --git a/Source/Editor/Modules/ContentEditingModule.cs b/Source/Editor/Modules/ContentEditingModule.cs index 6d0299a43..563143fc5 100644 --- a/Source/Editor/Modules/ContentEditingModule.cs +++ b/Source/Editor/Modules/ContentEditingModule.cs @@ -2,9 +2,9 @@ using System; using FlaxEditor.Content; +using FlaxEditor.GUI.Docking; using FlaxEditor.Windows; using FlaxEngine; -using DockState = FlaxEditor.GUI.Docking.DockState; namespace FlaxEditor.Modules { @@ -42,7 +42,6 @@ namespace FlaxEditor.Modules var proxy = Editor.ContentDatabase.GetProxy(item); if (proxy == null) { - // Error Editor.Log("Missing content proxy object for " + item); return null; } @@ -58,24 +57,31 @@ namespace FlaxEditor.Modules } if (window != null && !disableAutoShow) { - // Check if there is a floating window that has the same size - Vector2 defaultSize = window.DefaultSize; - for (var i = 0; i < Editor.UI.MasterPanel.FloatingPanels.Count; i++) + var newLocation = (DockState)Editor.Options.Options.Interface.NewWindowLocation; + if (newLocation == DockState.Float) { - var win = Editor.UI.MasterPanel.FloatingPanels[i]; - - // Check if size is similar - if (Vector2.Abs(win.Size - defaultSize).LengthSquared < 100) + // Check if there is a floating window that has the same size + Vector2 defaultSize = window.DefaultSize; + for (var i = 0; i < Editor.UI.MasterPanel.FloatingPanels.Count; i++) { - // Dock - window.Show(DockState.DockFill, win); - window.Focus(); - return window; - } - } + var win = Editor.UI.MasterPanel.FloatingPanels[i]; - // Show floating - window.ShowFloating(defaultSize); + // Check if size is similar + if (Vector2.Abs(win.Size - defaultSize).LengthSquared < 100) + { + // Dock + window.Show(DockState.DockFill, win); + window.Focus(); + return window; + } + } + + window.ShowFloating(defaultSize); + } + else + { + window.Show(newLocation); + } } return window; @@ -122,7 +128,7 @@ namespace FlaxEditor.Modules if (item is NewItem ni) { if (!ni.Proxy.IsFileNameValid(shortName)) - { + { hint = "Name does not follow " + ni.Proxy.Name + " name restrictions !"; return false; } @@ -131,7 +137,7 @@ namespace FlaxEditor.Modules { var proxy = Editor.ContentDatabase.GetProxy(item); if (proxy != null && !proxy.IsFileNameValid(shortName)) - { + { hint = "Name does not follow " + proxy.Name + " name restrictions !"; return false; } diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index eb0e0e762..c17260055 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -110,8 +110,8 @@ namespace FlaxEditor.Options /// Gets or sets the method window opening. /// [DefaultValue(DockStateProxy.Float)] - [EditorDisplay("Interface", "Define The Opening Window Method"), EditorOrder(150), Tooltip("Define the opening method for new windows, open in a new tab by default.")] - public DockStateProxy NewWindowMethod { get; set; } = DockStateProxy.Float; + [EditorDisplay("Interface", "New Window Location"), EditorOrder(150), Tooltip("Define the opening method for new windows, open in a new tab by default.")] + public DockStateProxy NewWindowLocation { get; set; } = DockStateProxy.Float; /// /// Gets or sets the timestamps prefix mode for debug log messages.