2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-09-30 17:45:55 +08:00
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-09-30 17:45:55 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-11-23 10:59:50 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-09-30 17:45:55 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using OpenTK.Graphics;
|
2017-12-31 05:40:28 +08:00
|
|
|
|
using osu.Game.Graphics.Textures;
|
2016-09-30 17:45:55 +08:00
|
|
|
|
|
2016-11-23 10:59:50 +08:00
|
|
|
|
namespace osu.Game.Graphics.Backgrounds
|
2016-09-30 17:45:55 +08:00
|
|
|
|
{
|
2016-11-20 00:39:43 +08:00
|
|
|
|
public class Background : BufferedContainer
|
2016-09-30 17:45:55 +08:00
|
|
|
|
{
|
2016-11-20 00:39:43 +08:00
|
|
|
|
public Sprite Sprite;
|
2016-09-30 17:45:55 +08:00
|
|
|
|
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly string textureName;
|
2016-10-05 15:35:10 +08:00
|
|
|
|
|
2016-11-20 00:39:43 +08:00
|
|
|
|
public Background(string textureName = @"")
|
2016-10-01 17:40:14 +08:00
|
|
|
|
{
|
2017-02-14 15:13:25 +08:00
|
|
|
|
CacheDrawnFrameBuffer = true;
|
|
|
|
|
|
2016-10-05 15:35:10 +08:00
|
|
|
|
this.textureName = textureName;
|
2016-10-01 17:40:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
2016-11-20 00:39:43 +08:00
|
|
|
|
Add(Sprite = new Sprite
|
2016-09-30 17:45:55 +08:00
|
|
|
|
{
|
2017-06-28 17:24:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-09-30 17:45:55 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2016-11-23 12:18:22 +08:00
|
|
|
|
Colour = Color4.DarkGray,
|
|
|
|
|
FillMode = FillMode.Fill,
|
2016-09-30 17:45:55 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-13 01:34:36 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-12-31 05:40:28 +08:00
|
|
|
|
private void load(LargeTextureStore textures)
|
2016-11-13 01:34:36 +08:00
|
|
|
|
{
|
2016-11-20 00:39:43 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(textureName))
|
|
|
|
|
Sprite.Texture = textures.Get(textureName);
|
2016-11-13 01:34:36 +08:00
|
|
|
|
}
|
2016-09-30 17:45:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|