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

Update user profile overlay to show more than one tournament banner

This commit is contained in:
Salman Ahmed 2023-10-29 01:44:21 +03:00
parent ec9ae12bbd
commit 922ad80cfc
2 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,7 @@
// 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.Linq;
using System.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -11,7 +12,7 @@ using osu.Game.Overlays.Profile.Header.Components;
namespace osu.Game.Overlays.Profile.Header
{
public partial class BannerHeaderContainer : CompositeDrawable
public partial class BannerHeaderContainer : FillFlowContainer
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
@ -19,9 +20,9 @@ namespace osu.Game.Overlays.Profile.Header
private void load()
{
Alpha = 0;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fit;
FillAspectRatio = 1000 / 60f;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
}
protected override void LoadComplete()
@ -40,13 +41,13 @@ namespace osu.Game.Overlays.Profile.Header
ClearInternal();
var banner = user?.TournamentBanner;
var banners = user?.TournamentBanners;
if (banner != null)
if (banners?.Length > 0)
{
Show();
LoadComponentAsync(new DrawableTournamentBanner(banner), AddInternal, cancellationTokenSource.Token);
LoadComponentsAsync(banners.Select(b => new DrawableTournamentBanner(b)), AddRangeInternal, cancellationTokenSource.Token);
}
else
{

View File

@ -15,12 +15,13 @@ namespace osu.Game.Overlays.Profile.Header.Components
[LongRunningLoad]
public partial class DrawableTournamentBanner : OsuClickableContainer
{
private const float banner_aspect_ratio = 60 / 1000f;
private readonly TournamentBanner banner;
public DrawableTournamentBanner(TournamentBanner banner)
{
this.banner = banner;
RelativeSizeAxes = Axes.Both;
RelativeSizeAxes = Axes.X;
}
[BackgroundDependencyLoader]
@ -41,6 +42,12 @@ namespace osu.Game.Overlays.Profile.Header.Components
this.FadeInFromZero(200);
}
protected override void Update()
{
base.Update();
Height = DrawWidth * banner_aspect_ratio;
}
public override LocalisableString TooltipText => "view in browser";
}
}