1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 02:07:34 +08:00

Background scale.

This commit is contained in:
Huo Yaoyuan 2016-10-24 13:13:49 +08:00
parent b0d72c5f84
commit 303bd41765

View File

@ -8,6 +8,7 @@ using osu.Framework;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Game.Graphics;
@ -15,7 +16,7 @@ namespace osu.Game.Overlays
{
public class MusicController : OverlayContainer
{
private Sprite background;
private Sprite backgroundSprite;
private Box progress;
private SpriteText title, artist;
public override void Load(BaseGame game)
@ -27,11 +28,7 @@ namespace osu.Game.Overlays
Masking = true;
Children = new Drawable[]
{
background = new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = game.Textures.Get(@"Backgrounds/bg4")//placeholder
},
backgroundSprite = getScaledSprite(game.Textures.Get(@"Backgrounds/bg4")),//placeholder
new Box
{
RelativeSizeAxes = Axes.Both,
@ -107,6 +104,19 @@ namespace osu.Game.Overlays
};
}
private Sprite getScaledSprite(Texture background)
{
Sprite scaledSprite = new Sprite
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Texture = background,
Depth = float.MinValue
};
scaledSprite.Scale = new Vector2(Math.Max(DrawSize.X / scaledSprite.DrawSize.X, DrawSize.Y / scaledSprite.DrawSize.Y));
return scaledSprite;
}
//placeholder for toggling
protected override void PopIn() => FadeIn(500);