1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge branch 'master' into fix-player-loader-logo-drag

This commit is contained in:
Salman Ahmed 2023-01-08 21:48:07 +03:00 committed by GitHub
commit f2609820c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 13 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

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -16,25 +14,28 @@ namespace osu.Game.Screens.Edit.Setup
{
internal partial class ResourcesSection : SetupSection
{
private LabelledFileChooser audioTrackChooser;
private LabelledFileChooser backgroundChooser;
private LabelledFileChooser audioTrackChooser = null!;
private LabelledFileChooser backgroundChooser = null!;
public override LocalisableString Title => EditorSetupStrings.ResourcesHeader;
[Resolved]
private MusicController music { get; set; }
private MusicController music { get; set; } = null!;
[Resolved]
private BeatmapManager beatmaps { get; set; }
private BeatmapManager beatmaps { get; set; } = null!;
[Resolved]
private IBindable<WorkingBeatmap> working { get; set; }
private IBindable<WorkingBeatmap> working { get; set; } = null!;
[Resolved]
private EditorBeatmap editorBeatmap { get; set; }
private EditorBeatmap editorBeatmap { get; set; } = null!;
[Resolved]
private SetupScreenHeader header { get; set; }
private Editor? editor { get; set; }
[Resolved]
private SetupScreenHeader header { get; set; } = null!;
[BackgroundDependencyLoader]
private void load()
@ -93,6 +94,8 @@ namespace osu.Game.Screens.Edit.Setup
working.Value.Metadata.BackgroundFile = destination.Name;
header.Background.UpdateBackground();
editor?.ApplyToBackground(bg => bg.RefreshBackground());
return true;
}
@ -125,17 +128,17 @@ namespace osu.Game.Screens.Edit.Setup
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;
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;
updatePlaceholderText();