mirror of
https://github.com/ppy/osu.git
synced 2024-11-16 09:17:48 +08:00
2c1a44da89
Due to varying expectations in handling of `Beatmap`. Some places allow or expect null and some don't. Needs to be looked at closer separately.
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
// 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 osu.Framework.Allocation;
|
|
using osu.Framework.Graphics.Textures;
|
|
using osu.Game.Beatmaps;
|
|
|
|
namespace osu.Game.Graphics.Backgrounds
|
|
{
|
|
public partial class BeatmapBackground : Background
|
|
{
|
|
public readonly WorkingBeatmap Beatmap;
|
|
|
|
private readonly string fallbackTextureName;
|
|
|
|
public BeatmapBackground(WorkingBeatmap beatmap, string fallbackTextureName = @"Backgrounds/bg1")
|
|
{
|
|
Beatmap = beatmap;
|
|
this.fallbackTextureName = fallbackTextureName;
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(LargeTextureStore textures)
|
|
{
|
|
Sprite.Texture = Beatmap?.GetBackground() ?? textures.Get(fallbackTextureName);
|
|
}
|
|
|
|
public override bool Equals(Background other)
|
|
{
|
|
if (ReferenceEquals(null, other)) return false;
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
return other.GetType() == GetType()
|
|
&& ((BeatmapBackground)other).Beatmap == Beatmap;
|
|
}
|
|
}
|
|
}
|