handle build animation on run failure

This commit is contained in:
Matt Parker
2026-01-18 19:20:16 +10:00
parent fe91d5e81a
commit 11686e79ba
3 changed files with 26 additions and 5 deletions

View File

@@ -42,9 +42,10 @@ public partial class RunService(ILogger<RunService> 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);

View File

@@ -135,6 +135,7 @@ public class SharpIdeProjectModel : ISharpIdeNode, IExpandableSharpIdeNode, IChi
public bool OpenInRunPanel { get; set; }
public Channel<byte[]>? RunningOutputChannel { get; set; }
public EventWrapper<Task> ProjectRunFailed { get; } = new(() => Task.CompletedTask);
public EventWrapper<Task> ProjectStartedRunning { get; } = new(() => Task.CompletedTask);
public EventWrapper<Task> ProjectStoppedRunning { get; } = new(() => Task.CompletedTask);

View File

@@ -30,6 +30,19 @@ public partial class RunMenuItem : HBoxContainer
_buildAnimationPlayer = GetNode<AnimationPlayer>("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);
}
}