Display a non-parallax background at the appropriate size when storyboards do not replace it.

This commit is contained in:
Damnae
2017-09-15 11:23:37 +02:00
parent f5368505ab
commit 757a159516
7 changed files with 36 additions and 6 deletions

View File

@ -5,6 +5,7 @@ using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.IO;
@ -14,6 +15,13 @@ namespace osu.Game.Storyboards.Drawables
{
public Storyboard Storyboard { get; private set; }
private readonly Background background;
public Texture BackgroundTexture
{
get { return background.Texture; }
set { background.Texture = value; }
}
private readonly Container<DrawableStoryboardLayer> content;
protected override Container<DrawableStoryboardLayer> Content => content;
@ -43,6 +51,11 @@ namespace osu.Game.Storyboards.Drawables
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
AddInternal(background = new Background
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
AddInternal(content = new Container<DrawableStoryboardLayer>
{
Size = new Vector2(640, 480),
@ -65,5 +78,10 @@ namespace osu.Game.Storyboards.Drawables
foreach (var layer in Children)
layer.Enabled = passing ? layer.Layer.EnabledWhenPassing : layer.Layer.EnabledWhenFailing;
}
private class Background : Sprite
{
protected override Vector2 DrawScale => Texture != null ? new Vector2(Parent.DrawHeight / Texture.DisplayHeight) : base.DrawScale;
}
}
}