Add specific messaging for when there's no background stack available

This commit is contained in:
Dean Herbert
2021-01-06 18:19:03 +09:00
parent 550ef3f133
commit 07cff70387

View File

@ -125,6 +125,7 @@ namespace osu.Game.Screens
private BackgroundScreen background; private BackgroundScreen background;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
[CanBeNull]
private BackgroundScreenStack backgroundStack { get; set; } private BackgroundScreenStack backgroundStack { get; set; }
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
@ -152,8 +153,11 @@ namespace osu.Game.Screens
/// <param name="action">The operation to perform.</param> /// <param name="action">The operation to perform.</param>
public void ApplyToBackground(Action<BackgroundScreen> action) public void ApplyToBackground(Action<BackgroundScreen> action)
{ {
if (backgroundStack == null)
throw new InvalidOperationException("Attempted to apply to background without a background stack being available.");
if (background == null) if (background == null)
throw new InvalidOperationException("Attempted to apply to background before screen is pushed"); throw new InvalidOperationException("Attempted to apply to background before screen is pushed.");
background.ApplyToBackground(action); background.ApplyToBackground(action);
} }