2023-02-01 07:02:59 +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.
|
|
|
|
|
2023-10-29 06:44:21 +08:00
|
|
|
using System.Linq;
|
2023-02-01 07:02:59 +08:00
|
|
|
using System.Threading;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
using osu.Game.Overlays.Profile.Header.Components;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Header
|
|
|
|
{
|
2023-10-29 06:44:21 +08:00
|
|
|
public partial class BannerHeaderContainer : FillFlowContainer
|
2023-02-01 07:02:59 +08:00
|
|
|
{
|
|
|
|
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Alpha = 0;
|
2023-10-29 06:44:21 +08:00
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
Direction = FillDirection.Vertical;
|
2023-02-01 07:02:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
User.BindValueChanged(u => updateDisplay(u.NewValue?.User), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private CancellationTokenSource? cancellationTokenSource;
|
|
|
|
|
|
|
|
private void updateDisplay(APIUser? user)
|
|
|
|
{
|
|
|
|
cancellationTokenSource?.Cancel();
|
|
|
|
cancellationTokenSource = new CancellationTokenSource();
|
|
|
|
|
|
|
|
ClearInternal();
|
|
|
|
|
2023-10-29 06:44:21 +08:00
|
|
|
var banners = user?.TournamentBanners;
|
2023-02-01 07:02:59 +08:00
|
|
|
|
2023-10-29 06:44:21 +08:00
|
|
|
if (banners?.Length > 0)
|
2023-02-01 07:02:59 +08:00
|
|
|
{
|
|
|
|
Show();
|
|
|
|
|
2023-10-29 06:44:21 +08:00
|
|
|
LoadComponentsAsync(banners.Select(b => new DrawableTournamentBanner(b)), AddRangeInternal, cancellationTokenSource.Token);
|
2023-02-01 07:02:59 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
cancellationTokenSource?.Cancel();
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|