1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 08:13:15 +08:00
This commit is contained in:
Maciej 2016-11-07 04:20:17 +01:00
parent 384bb32a81
commit 39c0d89cdf
3 changed files with 3 additions and 22 deletions

View File

@ -2,7 +2,6 @@
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE //Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework; using osu.Framework;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics.Background; using osu.Game.Graphics.Background;
namespace osu.Game.GameModes.Backgrounds namespace osu.Game.GameModes.Backgrounds
@ -10,22 +9,16 @@ namespace osu.Game.GameModes.Backgrounds
public class BackgroundModeCustom : BackgroundMode public class BackgroundModeCustom : BackgroundMode
{ {
private readonly string textureName; private readonly string textureName;
private readonly Texture texture;
public BackgroundModeCustom(string textureName) public BackgroundModeCustom(string textureName)
{ {
this.textureName = textureName; this.textureName = textureName;
} }
public BackgroundModeCustom(Texture texture)
{
this.texture = texture;
}
protected override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Add((texture != null) ? new Background(texture) : new Background(textureName)); Add(new Background(textureName));
} }
public override bool Equals(BackgroundMode other) public override bool Equals(BackgroundMode other)

View File

@ -20,8 +20,7 @@ namespace osu.Game.GameModes.Play
{ {
const bool autoplay = false; const bool autoplay = false;
private BackgroundMode background; protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
protected override BackgroundMode CreateBackground() => background;
public BeatmapInfo BeatmapInfo; public BeatmapInfo BeatmapInfo;
@ -50,9 +49,6 @@ namespace osu.Game.GameModes.Play
AudioTrack track = Beatmap.Track; AudioTrack track = Beatmap.Track;
if (Beatmap.Background != null)
background = new BackgroundModeCustom(Beatmap.Background);
if (track != null) if (track != null)
{ {
game.Audio.Track.SetExclusive(track); game.Audio.Track.SetExclusive(track);

View File

@ -18,7 +18,6 @@ namespace osu.Game.Graphics.Background
{ {
protected Sprite BackgroundSprite; protected Sprite BackgroundSprite;
Texture texture;
string textureName; string textureName;
public Background(string textureName = @"Backgrounds/bg1") public Background(string textureName = @"Backgrounds/bg1")
@ -28,20 +27,13 @@ namespace osu.Game.Graphics.Background
Depth = float.MinValue; Depth = float.MinValue;
} }
public Background(Texture texture)
{
this.texture = texture;
RelativeSizeAxes = Axes.Both;
Depth = float.MinValue;
}
protected override void Load(BaseGame game) protected override void Load(BaseGame game)
{ {
base.Load(game); base.Load(game);
Add(BackgroundSprite = new Sprite Add(BackgroundSprite = new Sprite
{ {
Texture = texture != null ? texture : game.Textures.Get(textureName), Texture = game.Textures.Get(textureName),
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Colour = Color4.DarkGray Colour = Color4.DarkGray