1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 22:35:23 +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;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -15,7 +16,7 @@ namespace osu.Game.Overlays
{ {
public class MusicController : OverlayContainer public class MusicController : OverlayContainer
{ {
private Sprite background; private Sprite backgroundSprite;
private Box progress; private Box progress;
private SpriteText title, artist; private SpriteText title, artist;
public override void Load(BaseGame game) public override void Load(BaseGame game)
@ -27,11 +28,7 @@ namespace osu.Game.Overlays
Masking = true; Masking = true;
Children = new Drawable[] Children = new Drawable[]
{ {
background = new Sprite backgroundSprite = getScaledSprite(game.Textures.Get(@"Backgrounds/bg4")),//placeholder
{
RelativeSizeAxes = Axes.Both,
Texture = game.Textures.Get(@"Backgrounds/bg4")//placeholder
},
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, 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 //placeholder for toggling
protected override void PopIn() => FadeIn(500); protected override void PopIn() => FadeIn(500);