1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 05:12:53 +08:00
osu-lazer/osu.Game/Users/UserCoverBackground.cs

53 lines
1.6 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
2019-03-10 06:58:14 +08:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2019-03-10 06:58:14 +08:00
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Users
{
2019-03-10 06:58:14 +08:00
public class UserCoverBackground : ModelBackedDrawable<User>
2018-04-13 17:19:50 +08:00
{
2019-03-10 06:58:14 +08:00
public User User
2018-04-13 17:19:50 +08:00
{
2019-03-10 06:58:14 +08:00
get => Model;
set => Model = value;
2018-04-13 17:19:50 +08:00
}
2019-03-10 06:58:14 +08:00
[Resolved]
private LargeTextureStore textures { get; set; }
2018-04-13 17:19:50 +08:00
2019-03-10 06:58:14 +08:00
protected override Drawable CreateDrawable(User user)
{
if (user == null)
{
return new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.1f), Color4.Black.Opacity(0.75f))
};
}
else
{
2019-04-04 06:24:42 +08:00
var sprite = new Sprite
2019-03-10 06:58:14 +08:00
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(user.CoverUrl),
FillMode = FillMode.Fill,
Anchor = Anchor.Centre,
2019-04-04 06:24:42 +08:00
Origin = Anchor.Centre
2019-03-10 06:58:14 +08:00
};
2019-04-04 06:24:42 +08:00
sprite.OnLoadComplete += d => d.FadeInFromZero(400);
return sprite;
2019-03-10 06:58:14 +08:00
}
2018-04-13 17:19:50 +08:00
}
}
}