Change MSBuildPanel to EditorDock

This commit is contained in:
kobewi
2025-11-24 17:38:24 +01:00
parent 4601c07d86
commit a07fcf5d05
6 changed files with 39 additions and 27 deletions

View File

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

View File

@ -7,11 +7,8 @@ using File = GodotTools.Utils.File;
namespace GodotTools.Build
{
public partial class MSBuildPanel : MarginContainer, ISerializationListener
public partial class MSBuildPanel : EditorDock, ISerializationListener
{
[Signal]
public delegate void BuildStateChangedEventHandler();
#nullable disable
private MenuButton _buildMenuButton;
private Button _openLogsFolderButton;
@ -27,21 +24,23 @@ namespace GodotTools.Build
private readonly object _pendingBuildLogTextLock = new object();
private string _pendingBuildLogText = string.Empty;
public Texture2D? GetBuildStateIcon()
public void UpdateBuildStateIcon()
{
Texture2D? icon = null;
if (IsBuildingOngoing)
return GetThemeIcon("Stop", "EditorIcons");
icon = GetThemeIcon("Stop", "EditorIcons");
if (_problemsView.WarningCount > 0 && _problemsView.ErrorCount > 0)
return GetThemeIcon("ErrorWarning", "EditorIcons");
icon = GetThemeIcon("ErrorWarning", "EditorIcons");
if (_problemsView.WarningCount > 0)
return GetThemeIcon("Warning", "EditorIcons");
icon = GetThemeIcon("Warning", "EditorIcons");
if (_problemsView.ErrorCount > 0)
return GetThemeIcon("Error", "EditorIcons");
icon = GetThemeIcon("Error", "EditorIcons");
return null;
DockIcon = icon;
ForceShowIcon = icon != null;
}
private enum BuildMenuOptions
@ -142,7 +141,7 @@ namespace GodotTools.Build
_problemsView.SetDiagnostics(new[] { diagnostic });
EmitSignal(SignalName.BuildStateChanged);
UpdateBuildStateIcon();
}
private void BuildStarted(BuildInfo buildInfo)
@ -156,7 +155,7 @@ namespace GodotTools.Build
_problemsView.UpdateProblemsView();
EmitSignal(SignalName.BuildStateChanged);
UpdateBuildStateIcon();
}
private void BuildFinished(BuildResult result)
@ -169,7 +168,7 @@ namespace GodotTools.Build
_problemsView.UpdateProblemsView();
EmitSignal(SignalName.BuildStateChanged);
UpdateBuildStateIcon();
}
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()
{
base._Ready();

View File

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