1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00
osu-lazer/osu.Game/Graphics/Backgrounds/Background.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2018-08-27 16:26:44 +08:00
using System.Threading.Tasks;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK.Graphics;
using osu.Game.Graphics.Textures;
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,
Colour = Color4.DarkGray,
FillMode = FillMode.Fill,
});
}
[BackgroundDependencyLoader]
2018-08-27 16:26:44 +08:00
private async Task load(LargeTextureStore textures)
2018-04-13 17:19:50 +08:00
{
if (!string.IsNullOrEmpty(textureName))
2018-08-27 16:26:44 +08:00
Sprite.Texture = await textures.GetAsync(textureName);
2018-04-13 17:19:50 +08:00
}
}
}