mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Merge pull request #23808 from peppy/working-beatmap-get-background
Refactor `IWorkingBeatmap.Background` to `GetBackground()`
This commit is contained in:
commit
281aae91ec
@ -231,7 +231,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
public override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace osu.Game.Tests.Editing.Checks
|
||||
|
||||
var mock = new Mock<IWorkingBeatmap>();
|
||||
mock.SetupGet(w => w.Beatmap).Returns(beatmap);
|
||||
mock.SetupGet(w => w.Background).Returns(background);
|
||||
mock.Setup(w => w.GetBackground()).Returns(background);
|
||||
mock.Setup(w => w.GetStream(It.IsAny<string>())).Returns(stream);
|
||||
|
||||
return mock;
|
||||
|
@ -286,7 +286,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
protected override Texture GetBackground() => renderer.CreateTexture(1, 1);
|
||||
public override Texture GetBackground() => renderer.CreateTexture(1, 1);
|
||||
}
|
||||
|
||||
private partial class TestWorkingBeatmapWithStoryboard : TestWorkingBeatmap
|
||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Tests
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
|
||||
protected override Texture GetBackground() => null;
|
||||
public override Texture GetBackground() => null;
|
||||
|
||||
protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(firstAudioFile));
|
||||
|
||||
|
@ -23,8 +23,9 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
if (working.Background != null)
|
||||
Texture = working.Background;
|
||||
var background = working.GetBackground();
|
||||
if (background != null)
|
||||
Texture = background;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override IBeatmap GetBeatmap() => new Beatmap();
|
||||
|
||||
protected override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4");
|
||||
public override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4");
|
||||
|
||||
protected override Track GetBeatmapTrack() => GetVirtualTrack();
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
public override Texture GetBackground() => throw new NotImplementedException();
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
protected internal override ISkin GetSkin() => throw new NotImplementedException();
|
||||
public override Stream GetStream(string storagePath) => throw new NotImplementedException();
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Retrieves the background for this <see cref="IWorkingBeatmap"/>.
|
||||
/// </summary>
|
||||
Texture Background { get; }
|
||||
Texture GetBackground();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="Waveform"/> for the <see cref="Track"/> of this <see cref="IWorkingBeatmap"/>.
|
||||
|
@ -34,8 +34,6 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public Storyboard Storyboard => storyboard.Value;
|
||||
|
||||
public Texture Background => GetBackground(); // Texture uses ref counting, so we want to return a new instance every usage.
|
||||
|
||||
public ISkin Skin => skin.Value;
|
||||
|
||||
private AudioManager audioManager { get; }
|
||||
@ -67,7 +65,7 @@ namespace osu.Game.Beatmaps
|
||||
protected virtual Storyboard GetStoryboard() => new Storyboard { BeatmapInfo = BeatmapInfo };
|
||||
|
||||
protected abstract IBeatmap GetBeatmap();
|
||||
protected abstract Texture GetBackground();
|
||||
public abstract Texture GetBackground();
|
||||
protected abstract Track GetBeatmapTrack();
|
||||
|
||||
/// <summary>
|
||||
|
@ -160,7 +160,7 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
}
|
||||
|
||||
protected override Texture GetBackground()
|
||||
public override Texture GetBackground()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Metadata?.BackgroundFile))
|
||||
return null;
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore textures)
|
||||
{
|
||||
Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
|
||||
Sprite.Texture = Beatmap?.GetBackground() ?? textures.Get(fallbackTextureName);
|
||||
}
|
||||
|
||||
public override bool Equals(Background other)
|
||||
|
@ -415,7 +415,7 @@ namespace osu.Game.Overlays
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore textures)
|
||||
{
|
||||
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
||||
sprite.Texture = beatmap?.GetBackground() ?? textures.Get(@"Backgrounds/bg4");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Edit.Checks
|
||||
if (backgroundFile == null)
|
||||
yield break;
|
||||
|
||||
var texture = context.WorkingBeatmap.Background;
|
||||
var texture = context.WorkingBeatmap.GetBackground();
|
||||
if (texture == null)
|
||||
yield break;
|
||||
|
||||
|
@ -204,7 +204,7 @@ namespace osu.Game.Screens.Edit
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
public override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Screens.OnlinePlay.Components
|
||||
if (Beatmap?.BeatmapSet is IBeatmapSetOnlineInfo online)
|
||||
texture = textures.Get(online.Covers.Cover);
|
||||
|
||||
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.Background;
|
||||
Sprite.Texture = texture ?? beatmaps.DefaultBeatmap.GetBackground();
|
||||
}
|
||||
|
||||
public override bool Equals(Background? other)
|
||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
|
||||
new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = beatmap.Background,
|
||||
Texture = beatmap.GetBackground(),
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
|
@ -226,7 +226,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
protected override IBeatmap GetBeatmap() => gameplayBeatmap;
|
||||
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
public override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
|
@ -232,7 +232,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
|
||||
protected override Texture GetBackground() => throw new NotImplementedException();
|
||||
public override Texture GetBackground() => throw new NotImplementedException();
|
||||
|
||||
protected override Track GetBeatmapTrack() => throw new NotImplementedException();
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
|
||||
public override Stream? GetStream(string storagePath) => null;
|
||||
|
||||
protected override Texture? GetBackground() => null;
|
||||
public override Texture? GetBackground() => null;
|
||||
|
||||
protected override Track? GetBeatmapTrack() => null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user