mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 09:37:23 +08:00
Merge pull request #22049 from Feodor0090/editor-bg-refresh
Refresh background on file change in editor
This commit is contained in:
commit
1b735d0970
@ -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)
|
private void switchBackground(BeatmapBackground b)
|
||||||
{
|
{
|
||||||
float newDepth = 0;
|
float newDepth = 0;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -16,25 +14,28 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
{
|
{
|
||||||
internal partial class ResourcesSection : SetupSection
|
internal partial class ResourcesSection : SetupSection
|
||||||
{
|
{
|
||||||
private LabelledFileChooser audioTrackChooser;
|
private LabelledFileChooser audioTrackChooser = null!;
|
||||||
private LabelledFileChooser backgroundChooser;
|
private LabelledFileChooser backgroundChooser = null!;
|
||||||
|
|
||||||
public override LocalisableString Title => EditorSetupStrings.ResourcesHeader;
|
public override LocalisableString Title => EditorSetupStrings.ResourcesHeader;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private MusicController music { get; set; }
|
private MusicController music { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private BeatmapManager beatmaps { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<WorkingBeatmap> working { get; set; }
|
private IBindable<WorkingBeatmap> working { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorBeatmap editorBeatmap { get; set; }
|
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SetupScreenHeader header { get; set; }
|
private Editor? editor { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SetupScreenHeader header { get; set; } = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -93,6 +94,8 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
working.Value.Metadata.BackgroundFile = destination.Name;
|
working.Value.Metadata.BackgroundFile = destination.Name;
|
||||||
header.Background.UpdateBackground();
|
header.Background.UpdateBackground();
|
||||||
|
|
||||||
|
editor?.ApplyToBackground(bg => bg.RefreshBackground());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,17 +128,17 @@ namespace osu.Game.Screens.Edit.Setup
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void backgroundChanged(ValueChangedEvent<FileInfo> file)
|
private void backgroundChanged(ValueChangedEvent<FileInfo?> file)
|
||||||
{
|
{
|
||||||
if (!ChangeBackgroundImage(file.NewValue))
|
if (file.NewValue == null || !ChangeBackgroundImage(file.NewValue))
|
||||||
backgroundChooser.Current.Value = file.OldValue;
|
backgroundChooser.Current.Value = file.OldValue;
|
||||||
|
|
||||||
updatePlaceholderText();
|
updatePlaceholderText();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void audioTrackChanged(ValueChangedEvent<FileInfo> file)
|
private void audioTrackChanged(ValueChangedEvent<FileInfo?> file)
|
||||||
{
|
{
|
||||||
if (!ChangeAudioTrack(file.NewValue))
|
if (file.NewValue == null || !ChangeAudioTrack(file.NewValue))
|
||||||
audioTrackChooser.Current.Value = file.OldValue;
|
audioTrackChooser.Current.Value = file.OldValue;
|
||||||
|
|
||||||
updatePlaceholderText();
|
updatePlaceholderText();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user