Merge pull request #113115 from KoBeWi/Buildock

Change MSBuildPanel to EditorDock
This commit is contained in:
Rémi Verschelde
2025-11-27 09:55:55 +01:00
6 changed files with 39 additions and 27 deletions

View File

@ -67,6 +67,12 @@
Closes the dock, making its tab hidden. Closes the dock, making its tab hidden.
</description> </description>
</method> </method>
<method name="make_visible">
<return type="void" />
<description>
Focuses the dock's tab (or window if it's floating). If the dock was closed, it will be opened. If it's a bottom dock, makes the bottom panel visible.
</description>
</method>
<method name="open"> <method name="open">
<return type="void" /> <return type="void" />
<description> <description>

View File

@ -41,6 +41,7 @@ void EditorDock::_set_default_slot_bind(EditorPlugin::DockSlot p_slot) {
void EditorDock::_bind_methods() { void EditorDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("open"), &EditorDock::open); ClassDB::bind_method(D_METHOD("open"), &EditorDock::open);
ClassDB::bind_method(D_METHOD("make_visible"), &EditorDock::make_visible);
ClassDB::bind_method(D_METHOD("close"), &EditorDock::close); ClassDB::bind_method(D_METHOD("close"), &EditorDock::close);
ClassDB::bind_method(D_METHOD("set_title", "title"), &EditorDock::set_title); ClassDB::bind_method(D_METHOD("set_title", "title"), &EditorDock::set_title);
@ -108,6 +109,10 @@ void EditorDock::open() {
} }
} }
void EditorDock::make_visible() {
EditorDockManager::get_singleton()->focus_dock(this);
}
void EditorDock::close() { void EditorDock::close() {
if (is_open) { if (is_open) {
EditorDockManager::get_singleton()->close_dock(this); EditorDockManager::get_singleton()->close_dock(this);

View File

@ -87,6 +87,7 @@ public:
EditorDock(); EditorDock();
void open(); void open();
void make_visible();
void close(); void close();
void set_title(const String &p_title); void set_title(const String &p_title);

View File

@ -52,7 +52,7 @@ namespace GodotTools.Build
{ {
var plugin = GodotSharpEditor.Instance; var plugin = GodotSharpEditor.Instance;
plugin.ShowErrorDialog(message, "Build error"); plugin.ShowErrorDialog(message, "Build error");
plugin.MakeBottomPanelItemVisible(plugin.MSBuildPanel); plugin.MSBuildPanel.MakeVisible();
} }
private static string GetLogFilePath(BuildInfo buildInfo) private static string GetLogFilePath(BuildInfo buildInfo)

View File

@ -7,11 +7,8 @@ using File = GodotTools.Utils.File;
namespace GodotTools.Build namespace GodotTools.Build
{ {
public partial class MSBuildPanel : MarginContainer, ISerializationListener public partial class MSBuildPanel : EditorDock, ISerializationListener
{ {
[Signal]
public delegate void BuildStateChangedEventHandler();
#nullable disable #nullable disable
private MenuButton _buildMenuButton; private MenuButton _buildMenuButton;
private Button _openLogsFolderButton; private Button _openLogsFolderButton;
@ -27,21 +24,23 @@ namespace GodotTools.Build
private readonly object _pendingBuildLogTextLock = new object(); private readonly object _pendingBuildLogTextLock = new object();
private string _pendingBuildLogText = string.Empty; private string _pendingBuildLogText = string.Empty;
public Texture2D? GetBuildStateIcon() public void UpdateBuildStateIcon()
{ {
Texture2D? icon = null;
if (IsBuildingOngoing) if (IsBuildingOngoing)
return GetThemeIcon("Stop", "EditorIcons"); icon = GetThemeIcon("Stop", "EditorIcons");
if (_problemsView.WarningCount > 0 && _problemsView.ErrorCount > 0) if (_problemsView.WarningCount > 0 && _problemsView.ErrorCount > 0)
return GetThemeIcon("ErrorWarning", "EditorIcons"); icon = GetThemeIcon("ErrorWarning", "EditorIcons");
if (_problemsView.WarningCount > 0) if (_problemsView.WarningCount > 0)
return GetThemeIcon("Warning", "EditorIcons"); icon = GetThemeIcon("Warning", "EditorIcons");
if (_problemsView.ErrorCount > 0) if (_problemsView.ErrorCount > 0)
return GetThemeIcon("Error", "EditorIcons"); icon = GetThemeIcon("Error", "EditorIcons");
return null; DockIcon = icon;
ForceShowIcon = icon != null;
} }
private enum BuildMenuOptions private enum BuildMenuOptions
@ -142,7 +141,7 @@ namespace GodotTools.Build
_problemsView.SetDiagnostics(new[] { diagnostic }); _problemsView.SetDiagnostics(new[] { diagnostic });
EmitSignal(SignalName.BuildStateChanged); UpdateBuildStateIcon();
} }
private void BuildStarted(BuildInfo buildInfo) private void BuildStarted(BuildInfo buildInfo)
@ -156,7 +155,7 @@ namespace GodotTools.Build
_problemsView.UpdateProblemsView(); _problemsView.UpdateProblemsView();
EmitSignal(SignalName.BuildStateChanged); UpdateBuildStateIcon();
} }
private void BuildFinished(BuildResult result) private void BuildFinished(BuildResult result)
@ -169,7 +168,7 @@ namespace GodotTools.Build
_problemsView.UpdateProblemsView(); _problemsView.UpdateProblemsView();
EmitSignal(SignalName.BuildStateChanged); UpdateBuildStateIcon();
} }
private void UpdateBuildLogText() private void UpdateBuildLogText()
@ -201,6 +200,17 @@ namespace GodotTools.Build
} }
} }
public MSBuildPanel()
{
Name = "MSBuild".TTR();
IconName = "BuildCSharp";
DefaultSlot = EditorPlugin.DockSlot.Bottom;
AvailableLayouts = DockLayout.Horizontal | DockLayout.Floating;
Global = false;
Transient = true;
ClipContents = false;
}
public override void _Ready() public override void _Ready()
{ {
base._Ready(); base._Ready();

View File

@ -118,7 +118,7 @@ namespace GodotTools
private void _ShowDotnetFeatures() private void _ShowDotnetFeatures()
{ {
_bottomPanelBtn.Show(); MSBuildPanel.Open();
_toolBarBuildButton.Show(); _toolBarBuildButton.Show();
} }
@ -456,12 +456,6 @@ namespace GodotTools
} }
} }
private void BuildStateChanged()
{
if (_bottomPanelBtn != null)
_bottomPanelBtn.Icon = MSBuildPanel.GetBuildStateIcon();
}
public override void _EnablePlugin() public override void _EnablePlugin()
{ {
base._EnablePlugin(); base._EnablePlugin();
@ -511,8 +505,7 @@ namespace GodotTools
_confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution(); _confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution();
MSBuildPanel = new MSBuildPanel(); MSBuildPanel = new MSBuildPanel();
MSBuildPanel.BuildStateChanged += BuildStateChanged; AddDock(MSBuildPanel);
_bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());
AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" }); AddChild(new HotReloadAssemblyWatcher { Name = "HotReloadAssemblyWatcher" });
@ -546,7 +539,7 @@ namespace GodotTools
} }
else else
{ {
_bottomPanelBtn.Hide(); MSBuildPanel.Close();
_toolBarBuildButton.Hide(); _toolBarBuildButton.Hide();
} }
_menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
@ -657,9 +650,6 @@ namespace GodotTools
base._DisablePlugin(); base._DisablePlugin();
_editorSettings.SettingsChanged -= OnSettingsChanged; _editorSettings.SettingsChanged -= OnSettingsChanged;
// Custom signals aren't automatically disconnected currently.
MSBuildPanel.BuildStateChanged -= BuildStateChanged;
} }
public override void _ExitTree() public override void _ExitTree()