Add xmldoc and throw a local exception on null background

This commit is contained in:
Dean Herbert 2021-01-06 15:26:13 +09:00
parent 11a0c637bc
commit e9d4e4d1d5
2 changed files with 16 additions and 2 deletions

View File

@ -34,6 +34,10 @@ protected override bool OnKeyDown(KeyDownEvent e)
return false;
}
/// <summary>
/// Apply arbitrary changes to this background in a thread safe manner.
/// </summary>
/// <param name="action">The operation to perform.</param>
public void ApplyToBackground(Action<BackgroundScreen> action) => Schedule(() => action.Invoke(this));
protected override void Update()

View File

@ -115,8 +115,6 @@ private void createDependencies(IReadOnlyDependencyContainer dependencies)
Mods = screenDependencies.Mods;
}
public void ApplyToBackground(Action<BackgroundScreen> action) => background.ApplyToBackground(action);
/// <summary>
/// The background created and owned by this screen. May be null if the background didn't change.
/// </summary>
@ -148,6 +146,18 @@ private void load(OsuGame osu, AudioManager audio)
Activity.Value ??= InitialActivity;
}
/// <summary>
/// Apply arbitrary changes to the current background screen in a thread safe manner.
/// </summary>
/// <param name="action">The operation to perform.</param>
public void ApplyToBackground(Action<BackgroundScreen> action)
{
if (background == null)
throw new InvalidOperationException("Attempted to apply to background before screen is pushed");
background.ApplyToBackground(action);
}
public override void OnResuming(IScreen last)
{
if (PlayResumeSound)