mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Apply most suggestions
This commit is contained in:
@ -1,30 +1,51 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Users
|
||||
{
|
||||
public class UserCoverBackground : Sprite
|
||||
public class UserCoverBackground : ModelBackedDrawable<User>
|
||||
{
|
||||
private readonly User user;
|
||||
|
||||
public UserCoverBackground(User user)
|
||||
public User User
|
||||
{
|
||||
this.user = user;
|
||||
get => Model;
|
||||
set => Model = value;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(LargeTextureStore textures)
|
||||
{
|
||||
if (textures == null)
|
||||
throw new ArgumentNullException(nameof(textures));
|
||||
[Resolved]
|
||||
private LargeTextureStore textures { get; set; }
|
||||
|
||||
if (!string.IsNullOrEmpty(user.CoverUrl))
|
||||
Texture = textures.Get(user.CoverUrl);
|
||||
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
|
||||
{
|
||||
return new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Texture = textures.Get(user.CoverUrl),
|
||||
FillMode = FillMode.Fill,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user