diff options
author | Raul Santos <raulsntos@gmail.com> | 2023-02-25 03:56:26 +0100 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-03-13 14:50:57 +0100 |
commit | 1640b1a150f51a132c53b6b4b3fabad0f1f21325 (patch) | |
tree | 7dc2d0fefb55718963a3aceb67c20298e6081ba9 | |
parent | 093d2371380970016e3477f7ae041299e0e0d553 (diff) |
C#: Always show "Create C# solution" option
Prevents ending up with an empty C# menu.
The option to create the C# solution no longer disappears, to avoid confusing users.
If an user tries to use it when a C# solution already exists they are warned that it will override their sln and csproj files.
(cherry picked from commit a1a2fc22558af4b368a6f8a7686399cb0a19f220)
-rw-r--r-- | modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs index c267d32f5a..f50803af95 100644 --- a/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs +++ b/modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs @@ -35,6 +35,7 @@ namespace GodotTools private PopupMenu _menuPopup; private AcceptDialog _errorDialog; + private ConfirmationDialog _confirmCreateSlnDialog; private Button _bottomPanelBtn; private Button _toolBarBuildButton; @@ -99,7 +100,7 @@ namespace GodotTools pr.Step("Done".TTR()); // Here, after all calls to progress_task_step - CallDeferred(nameof(_RemoveCreateSlnMenuOption)); + CallDeferred(nameof(_ShowDotnetFeatures)); } else { @@ -110,9 +111,8 @@ namespace GodotTools } } - private void _RemoveCreateSlnMenuOption() + private void _ShowDotnetFeatures() { - _menuPopup.RemoveItem(_menuPopup.GetItemIndex((int)MenuOptions.CreateSln)); _bottomPanelBtn.Show(); _toolBarBuildButton.Show(); } @@ -122,8 +122,17 @@ namespace GodotTools switch ((MenuOptions)id) { case MenuOptions.CreateSln: - CreateProjectSolution(); + { + if (File.Exists(GodotSharpDirs.ProjectSlnPath) || File.Exists(GodotSharpDirs.ProjectCsProjPath)) + { + ShowConfirmCreateSlnDialog(); + } + else + { + CreateProjectSolution(); + } break; + } case MenuOptions.SetupGodotNugetFallbackFolder: { try @@ -169,6 +178,13 @@ namespace GodotTools _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 readonly string[] VsCodeNames = @@ -420,6 +436,10 @@ namespace GodotTools _errorDialog = new AcceptDialog(); editorBaseControl.AddChild(_errorDialog); + _confirmCreateSlnDialog = new ConfirmationDialog(); + _confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution(); + editorBaseControl.AddChild(_confirmCreateSlnDialog); + MSBuildPanel = new MSBuildPanel(); MSBuildPanel.Ready += () => MSBuildPanel.BuildOutputView.BuildStateChanged += BuildStateChanged; @@ -453,8 +473,8 @@ namespace GodotTools { _bottomPanelBtn.Hide(); _toolBarBuildButton.Hide(); - _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); } + _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln); _menuPopup.IdPressed += _MenuOptionPressed; |