Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix C# editor dialogs #82683

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 24 additions & 18 deletions modules/mono/editor/GodotTools/GodotTools/Build/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,50 +206,56 @@ private static bool BuildProjectBlocking(BuildInfo buildInfo)
if (!File.Exists(buildInfo.Project))
return true; // No project to build.

using var pr = new EditorProgress("dotnet_build_project", "Building .NET project...", 1);

pr.Step("Building project", 0);
bool success;
using (var pr = new EditorProgress("dotnet_build_project", "Building .NET project...", 1))
{
pr.Step("Building project", 0);
success = Build(buildInfo);
}

if (!Build(buildInfo))
if (!success)
{
ShowBuildErrorDialog("Failed to build project");
return false;
}

return true;
return success;
}

private static bool CleanProjectBlocking(BuildInfo buildInfo)
{
if (!File.Exists(buildInfo.Project))
return true; // No project to clean.

using var pr = new EditorProgress("dotnet_clean_project", "Cleaning .NET project...", 1);

pr.Step("Cleaning project", 0);
bool success;
using (var pr = new EditorProgress("dotnet_clean_project", "Cleaning .NET project...", 1))
{
pr.Step("Cleaning project", 0);
success = Build(buildInfo);
}

if (!Build(buildInfo))
if (!success)
{
ShowBuildErrorDialog("Failed to clean project");
return false;
}

return true;
return success;
}

private static bool PublishProjectBlocking(BuildInfo buildInfo)
{
using var pr = new EditorProgress("dotnet_publish_project", "Publishing .NET project...", 1);

pr.Step("Running dotnet publish", 0);
bool success;
using (var pr = new EditorProgress("dotnet_publish_project", "Publishing .NET project...", 1))
{
pr.Step("Running dotnet publish", 0);
success = Publish(buildInfo);
}

if (!Publish(buildInfo))
if (!success)
{
ShowBuildErrorDialog("Failed to publish .NET project");
return false;
}

return true;
return success;
}

private static BuildInfo CreateBuildInfo(
Expand Down
28 changes: 15 additions & 13 deletions modules/mono/editor/GodotTools/GodotTools/GodotSharpEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private bool CreateProjectSolutionIfNeeded()

private bool CreateProjectSolution()
{
string errorMessage = null;
using (var pr = new EditorProgress("create_csharp_solution", "Generating solution...".TTR(), 2))
{
pr.Step("Generating C# project...".TTR());
Expand Down Expand Up @@ -96,22 +97,23 @@ private bool CreateProjectSolution()
}
catch (IOException e)
{
ShowErrorDialog("Failed to save solution. Exception message: ".TTR() + e.Message);
return false;
errorMessage = "Failed to save solution. Exception message: ".TTR() + e.Message;
}

pr.Step("Done".TTR());

// Here, after all calls to progress_task_step
CallDeferred(nameof(_ShowDotnetFeatures));
}
else
{
ShowErrorDialog("Failed to create C# project.".TTR());
errorMessage = "Failed to create C# project.".TTR();
}
}

return true;
if (!string.IsNullOrEmpty(errorMessage))
{
ShowErrorDialog(errorMessage);
return false;
}

_ShowDotnetFeatures();
return true;
}

private void _ShowDotnetFeatures()
Expand Down Expand Up @@ -161,14 +163,14 @@ public void ShowErrorDialog(string message, string title = "Error")
{
_errorDialog.Title = title;
_errorDialog.DialogText = message;
_errorDialog.PopupCentered();
EditorInterface.Singleton.PopupDialogCentered(_errorDialog);
}

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();
EditorInterface.Singleton.PopupDialogCentered(_confirmCreateSlnDialog);
}

private static string _vsCodePath = string.Empty;
Expand Down Expand Up @@ -483,11 +485,11 @@ public override void _EnablePlugin()
_editorSettings = EditorInterface.Singleton.GetEditorSettings();

_errorDialog = new AcceptDialog();
editorBaseControl.AddChild(_errorDialog);
_errorDialog.SetUnparentWhenInvisible(true);

_confirmCreateSlnDialog = new ConfirmationDialog();
_confirmCreateSlnDialog.SetUnparentWhenInvisible(true);
_confirmCreateSlnDialog.Confirmed += () => CreateProjectSolution();
editorBaseControl.AddChild(_confirmCreateSlnDialog);

MSBuildPanel = new MSBuildPanel();
MSBuildPanel.BuildStateChanged += BuildStateChanged;
Expand Down