1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

Basic avatar HUD implementation

This commit is contained in:
Ryuki 2022-09-17 21:09:34 +02:00
parent ea0a995cc9
commit c1077d909c
No known key found for this signature in database
GPG Key ID: A353889EAEACBF49

View File

@ -0,0 +1,50 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Skinning;
using osu.Game.Users.Drawables;
using osuTK;
namespace osu.Game.Screens.Play.HUD
{
public class SkinnableAvatar : CompositeDrawable, ISkinnableDrawable
{
[SettingSource("Corner radius", "How much the edges should be rounded.")]
public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0)
{
MinValue = 0,
MaxValue = 100,
Precision = 0.01f
};
[Resolved]
private GameplayState gameplayState { get; set; } = null!;
private readonly UpdateableAvatar avatar;
public SkinnableAvatar()
{
Size = new Vector2(128f);
InternalChild = avatar = new UpdateableAvatar(isInteractive: false)
{
RelativeSizeAxes = Axes.Both,
Masking = true
};
}
protected override void LoadComplete()
{
base.LoadComplete();
avatar.User = gameplayState.Score.ScoreInfo.User;
CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue);
}
public bool UsesFixedAnchor { get; set; }
}
}