Explorar o código

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

C#: Always show "Create C# solution" option
Rémi Verschelde %!s(int64=2) %!d(string=hai) anos
pai
achega
526f115752
Modificáronse 1 ficheiros con 25 adicións e 5 borrados
  1. 25 5
      modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs

+ 25 - 5
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;