2022-09-17 19:09:34 +00:00
|
|
|
// 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;
|
2023-03-05 23:10:42 +00:00
|
|
|
using osu.Game.Localisation.SkinComponents;
|
2023-03-07 18:43:52 +00:00
|
|
|
using osu.Game.Overlays.Settings;
|
2022-09-17 19:09:34 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osu.Game.Users.Drawables;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Play.HUD
|
|
|
|
{
|
2023-03-05 23:09:02 +00:00
|
|
|
public partial class PlayerAvatar : CompositeDrawable, ISerialisableDrawable
|
2022-09-17 19:09:34 +00:00
|
|
|
{
|
2023-03-07 18:43:52 +00:00
|
|
|
[SettingSource(typeof(SkinnableComponentStrings), nameof(SkinnableComponentStrings.CornerRadius), nameof(SkinnableComponentStrings.CornerRadiusDescription),
|
|
|
|
SettingControlType = typeof(SettingsPercentageSlider<float>))]
|
2023-03-06 20:11:52 +00:00
|
|
|
public new BindableFloat CornerRadius { get; set; } = new BindableFloat(0.25f)
|
2022-09-17 19:09:34 +00:00
|
|
|
{
|
|
|
|
MinValue = 0,
|
2023-03-06 20:11:52 +00:00
|
|
|
MaxValue = 0.5f,
|
2022-09-17 19:09:34 +00:00
|
|
|
Precision = 0.01f
|
|
|
|
};
|
|
|
|
|
|
|
|
private readonly UpdateableAvatar avatar;
|
|
|
|
|
2023-03-07 08:00:10 +00:00
|
|
|
private const float default_size = 80f;
|
|
|
|
|
2023-03-05 23:09:02 +00:00
|
|
|
public PlayerAvatar()
|
2022-09-17 19:09:34 +00:00
|
|
|
{
|
2023-03-07 08:00:10 +00:00
|
|
|
Size = new Vector2(default_size);
|
|
|
|
|
2022-09-17 19:09:34 +00:00
|
|
|
InternalChild = avatar = new UpdateableAvatar(isInteractive: false)
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Masking = true
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-03-07 08:39:21 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(GameplayState gameplayState)
|
|
|
|
{
|
|
|
|
avatar.User = gameplayState.Score.ScoreInfo.User;
|
|
|
|
}
|
|
|
|
|
2022-09-17 19:09:34 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2023-03-07 08:00:10 +00:00
|
|
|
CornerRadius.BindValueChanged(e => avatar.CornerRadius = e.NewValue * default_size, true);
|
2022-09-17 19:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool UsesFixedAnchor { get; set; }
|
|
|
|
}
|
|
|
|
}
|