From 11686e79ba1831e97810dd1a0ca5506d4df756f3 Mon Sep 17 00:00:00 2001 From: Matt Parker <61717342+MattParkerDev@users.noreply.github.com> Date: Sun, 18 Jan 2026 19:20:16 +1000 Subject: [PATCH] handle build animation on run failure --- .../Features/Run/RunService.cs | 3 ++- .../VsPersistence/SharpIdeModels.cs | 1 + .../Features/Run/RunMenuItem.cs | 27 ++++++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/SharpIDE.Application/Features/Run/RunService.cs b/src/SharpIDE.Application/Features/Run/RunService.cs index c148279..fb0eb1b 100644 --- a/src/SharpIDE.Application/Features/Run/RunService.cs +++ b/src/SharpIDE.Application/Features/Run/RunService.cs @@ -42,9 +42,10 @@ public partial class RunService(ILogger logger, RoslynAnalysis rosly if (buildResult is not SharpIdeBuildResult.Success) { _logger.LogInformation("Build failed for project {ProjectName}. Aborting run/debug.", project.Name); + project.ProjectRunFailed.InvokeParallelFireAndForget(); return; } - + project.RunningCancellationTokenSource = new CancellationTokenSource(); var launchProfiles = await LaunchSettingsParser.GetLaunchSettingsProfiles(project); diff --git a/src/SharpIDE.Application/Features/SolutionDiscovery/VsPersistence/SharpIdeModels.cs b/src/SharpIDE.Application/Features/SolutionDiscovery/VsPersistence/SharpIdeModels.cs index 263bea4..2f14b75 100644 --- a/src/SharpIDE.Application/Features/SolutionDiscovery/VsPersistence/SharpIdeModels.cs +++ b/src/SharpIDE.Application/Features/SolutionDiscovery/VsPersistence/SharpIdeModels.cs @@ -135,6 +135,7 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi public bool OpenInRunPanel { get; set; } public Channel? RunningOutputChannel { get; set; } + public EventWrapper ProjectRunFailed { get; } = new(() => Task.CompletedTask); public EventWrapper ProjectStartedRunning { get; } = new(() => Task.CompletedTask); public EventWrapper ProjectStoppedRunning { get; } = new(() => Task.CompletedTask); diff --git a/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs b/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs index 1dc488b..cf16c24 100644 --- a/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs +++ b/src/SharpIDE.Godot/Features/Run/RunMenuItem.cs @@ -30,6 +30,19 @@ public partial class RunMenuItem : HBoxContainer _buildAnimationPlayer = GetNode("AnimationPlayer"); Project.ProjectStartedRunning.Subscribe(OnProjectStartedRunning); Project.ProjectStoppedRunning.Subscribe(OnProjectStoppedRunning); + Project.ProjectRunFailed.Subscribe(OnProjectRunFailed); + } + + private async Task OnProjectRunFailed() + { + await this.InvokeAsync(() => + { + _stopButton.Visible = false; + _debugButton.Visible = true; + _runButton.Visible = true; + _animatedTextureParentControl.Visible = false; + _buildAnimationPlayer.Stop(); + }); } private async Task OnProjectStoppedRunning() @@ -62,10 +75,7 @@ public partial class RunMenuItem : HBoxContainer private StringName _buildAnimationName = "BuildingAnimation"; private async void OnRunButtonPressed() { - _runButton.Visible = false; - _debugButton.Visible = false; - _animatedTextureParentControl.Visible = true; - _buildAnimationPlayer.Play(_buildAnimationName); + SetAttemptingRunState(); await _runService.RunProject(Project).ConfigureAwait(false); } @@ -76,6 +86,15 @@ public partial class RunMenuItem : HBoxContainer UseInMemorySharpDbg = Singletons.AppState.IdeSettings.DebuggerUseSharpDbg, DebuggerExecutablePath = Singletons.AppState.IdeSettings.DebuggerExecutablePath }; + SetAttemptingRunState(); await _runService.RunProject(Project, true, debuggerExecutableInfo).ConfigureAwait(false); } + + private void SetAttemptingRunState() + { + _runButton.Visible = false; + _debugButton.Visible = false; + _animatedTextureParentControl.Visible = true; + _buildAnimationPlayer.Play(_buildAnimationName); + } } \ No newline at end of file