1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 11:42:56 +08:00

Refresh background on file change in editor

This commit is contained in:
ansel 2023-01-06 19:26:30 +03:00
parent 98483d2a1b
commit 9364c7775d
2 changed files with 17 additions and 0 deletions

View File

@ -99,6 +99,18 @@ namespace osu.Game.Screens.Backgrounds
}
}
/// <summary>
/// Reloads beatmap's background.
/// </summary>
public void RefreshBackground()
{
Schedule(() =>
{
cancellationSource?.Cancel();
LoadComponentAsync(new BeatmapBackground(beatmap), switchBackground, (cancellationSource = new CancellationTokenSource()).Token);
});
}
private void switchBackground(BeatmapBackground b)
{
float newDepth = 0;

View File

@ -33,6 +33,9 @@ namespace osu.Game.Screens.Edit.Setup
[Resolved]
private EditorBeatmap editorBeatmap { get; set; }
[Resolved]
private Editor editor { get; set; }
[Resolved]
private SetupScreenHeader header { get; set; }
@ -93,6 +96,8 @@ namespace osu.Game.Screens.Edit.Setup
working.Value.Metadata.BackgroundFile = destination.Name;
header.Background.UpdateBackground();
editor.ApplyToBackground(bg => bg.RefreshBackground());
return true;
}