mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Background scale.
This commit is contained in:
parent
b0d72c5f84
commit
303bd41765
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user