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

View File

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