Merge pull request #73904 from raulsntos/dotnet/tools-popup

C#: Always show "Create C# solution" option
This commit is contained in:
Rémi Verschelde 2023-03-02 11:22:59 +01:00
commit 526f115752
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -35,6 +35,7 @@ namespace GodotTools
private PopupMenu _menuPopup; private PopupMenu _menuPopup;
private AcceptDialog _errorDialog; private AcceptDialog _errorDialog;
private ConfirmationDialog _confirmCreateSlnDialog;
private Button _bottomPanelBtn; private Button _bottomPanelBtn;
private Button _toolBarBuildButton; private Button _toolBarBuildButton;
@ -99,7 +100,7 @@ namespace GodotTools
pr.Step("Done".TTR()); pr.Step("Done".TTR());
// Here, after all calls to progress_task_step // Here, after all calls to progress_task_step
CallDeferred(nameof(_RemoveCreateSlnMenuOption)); CallDeferred(nameof(_ShowDotnetFeatures));
} }
else else
{ {
@ -110,9 +111,8 @@ namespace GodotTools
} }
} }
private void _RemoveCreateSlnMenuOption() private void _ShowDotnetFeatures()
{ {
_menuPopup.RemoveItem(_menuPopup.GetItemIndex((int)MenuOptions.CreateSln));
_bottomPanelBtn.Show(); _bottomPanelBtn.Show();
_toolBarBuildButton.Show(); _toolBarBuildButton.Show();
} }
@ -122,8 +122,17 @@ namespace GodotTools
switch ((MenuOptions)id) switch ((MenuOptions)id)
{ {
case MenuOptions.CreateSln: case MenuOptions.CreateSln:
CreateProjectSolution(); {
if (File.Exists(GodotSharpDirs.ProjectSlnPath) || File.Exists(GodotSharpDirs.ProjectCsProjPath))
{
ShowConfirmCreateSlnDialog();
}
else
{
CreateProjectSolution();
}
break; break;
}
case MenuOptions.SetupGodotNugetFallbackFolder: case MenuOptions.SetupGodotNugetFallbackFolder:
{ {
try try
@ -169,6 +178,13 @@ namespace GodotTools
_errorDialog.PopupCentered(); _errorDialog.PopupCentered();
} }
public void ShowConfirmCreateSlnDialog()
{
_confirmCreateSlnDialog.Title = "C# solution already exists. This will override the existing C# project file, any manual changes will be lost.".TTR();
_confirmCreateSlnDialog.DialogText = "Create C# solution".TTR();
_confirmCreateSlnDialog.PopupCentered();
}
private static string _vsCodePath = string.Empty; private static string _vsCodePath = string.Empty;
private static readonly string[] VsCodeNames = private static readonly string[] VsCodeNames =
@ -420,6 +436,10 @@ namespace GodotTools
_errorDialog = new AcceptDialog(); _errorDialog = new AcceptDialog();
editorBaseControl.AddChild(_errorDialog); editorBaseControl.AddChild(_errorDialog);
_confirmCreateSlnDialog = new ConfirmationDialog();
_confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution();
editorBaseControl.AddChild(_confirmCreateSlnDialog);
MSBuildPanel = new MSBuildPanel(); MSBuildPanel = new MSBuildPanel();
MSBuildPanel.Ready += () => MSBuildPanel.Ready += () =>
MSBuildPanel.BuildOutputView.BuildStateChanged += BuildStateChanged; MSBuildPanel.BuildOutputView.BuildStateChanged += BuildStateChanged;
@ -453,8 +473,8 @@ namespace GodotTools
{ {
_bottomPanelBtn.Hide(); _bottomPanelBtn.Hide();
_toolBarBuildButton.Hide(); _toolBarBuildButton.Hide();
_menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
} }
_menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
_menuPopup.IdPressed += _MenuOptionPressed; _menuPopup.IdPressed += _MenuOptionPressed;