2020-11-21 08:18:24 +08: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.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Users;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections
|
|
|
|
|
{
|
|
|
|
|
public abstract class ProfileSubsection : FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
protected readonly Bindable<User> User = new Bindable<User>();
|
|
|
|
|
|
|
|
|
|
protected OsuSpriteText Missing { get; private set; }
|
|
|
|
|
|
|
|
|
|
private readonly string headerText;
|
|
|
|
|
private readonly string missingText;
|
|
|
|
|
private readonly CounterVisibilityState counterVisibilityState;
|
|
|
|
|
|
|
|
|
|
private ProfileSubsectionHeader header;
|
|
|
|
|
|
|
|
|
|
protected ProfileSubsection(Bindable<User> user, string headerText = "", string missingText = "", CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
|
|
|
|
|
{
|
|
|
|
|
this.headerText = headerText;
|
|
|
|
|
this.missingText = missingText;
|
|
|
|
|
this.counterVisibilityState = counterVisibilityState;
|
|
|
|
|
User.BindTo(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-11-22 03:49:56 +08:00
|
|
|
|
private void load()
|
2020-11-21 08:18:24 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
header = new ProfileSubsectionHeader(headerText, counterVisibilityState)
|
|
|
|
|
{
|
|
|
|
|
Alpha = string.IsNullOrEmpty(headerText) ? 0 : 1
|
|
|
|
|
},
|
|
|
|
|
CreateContent(),
|
|
|
|
|
Missing = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Font = OsuFont.GetFont(size: 15),
|
|
|
|
|
Text = missingText,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
User.BindValueChanged(OnUserChanged, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NotNull]
|
|
|
|
|
protected abstract Drawable CreateContent();
|
|
|
|
|
|
|
|
|
|
protected virtual void OnUserChanged(ValueChangedEvent<User> e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void SetCount(int value) => header.Current.Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|