osu/osu.Game/Graphics/Backgrounds/Background.cs

42 lines
1.1 KiB
C#
Raw Normal View History

// 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.
2018-04-13 09:19:50 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Graphics.Backgrounds
{
public class Background : BufferedContainer
{
public Sprite Sprite;
private readonly string textureName;
public Background(string textureName = @"")
{
CacheDrawnFrameBuffer = true;
this.textureName = textureName;
RelativeSizeAxes = Axes.Both;
Add(Sprite = new Sprite
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FillMode = FillMode.Fill,
});
}
[BackgroundDependencyLoader]
2018-08-30 22:04:40 +00:00
private void load(LargeTextureStore textures)
2018-04-13 09:19:50 +00:00
{
if (!string.IsNullOrEmpty(textureName))
2018-08-30 22:04:40 +00:00
Sprite.Texture = textures.Get(textureName);
2018-04-13 09:19:50 +00:00
}
}
}