Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Online/TestSceneUserProfileHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ public void TestProfileCoverExpanded()
{
AddStep("Set cover to expanded", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, true));
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
AddUntilStep("Cover is expanded", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.GreaterThan(0));
AddUntilStep("Cover is expanded", () => header.ChildrenOfType<CoverBackground>().Single().Height, () => Is.GreaterThan(0));
}

[Test]
public void TestProfileCoverCollapsed()
{
AddStep("Set cover to collapsed", () => configManager.SetValue(OsuSetting.ProfileCoverExpanded, false));
AddStep("Show example user", () => header.User.Value = new UserProfileData(TestSceneUserProfileOverlay.TEST_USER, new OsuRuleset().RulesetInfo));
AddUntilStep("Cover is collapsed", () => header.ChildrenOfType<UserCoverBackground>().Single().Height, () => Is.EqualTo(0));
AddUntilStep("Cover is collapsed", () => header.ChildrenOfType<CoverBackground>().Single().Height, () => Is.EqualTo(0));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tournament/Models/TournamentUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class TournamentUser : IUser
/// <summary>
/// A URL to the player's profile cover.
/// </summary>
public string CoverUrl { get; set; } = string.Empty;
public string? CoverUrl { get; set; } = string.Empty;

public APIUser ToAPIUser()
{
Expand Down
5 changes: 4 additions & 1 deletion osu.Game/Online/API/Requests/Responses/APIUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace osu.Game.Online.API.Requests.Responses
{
[JsonObject(MemberSerialization.OptIn)]
public class APIUser : IEquatable<APIUser>, IUser
public class APIUser : IEquatable<APIUser>, IUser, IHasCover
{
/// <summary>
/// A user ID which can be used to represent any system user which is not attached to a user profile.
Expand Down Expand Up @@ -75,14 +75,17 @@ public string CoverUrl
}

[JsonProperty(@"cover")]
[CanBeNull]
public UserCover Cover;

public class UserCover
{
[JsonProperty(@"custom_url")]
[CanBeNull]
public string CustomUrl;

[JsonProperty(@"url")]
[CanBeNull]
public string Url;

[JsonProperty(@"id")]
Expand Down
6 changes: 3 additions & 3 deletions osu.Game/Overlays/Profile/Header/TopHeaderContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public partial class TopHeaderContainer : CompositeDrawable
[Resolved]
private RankingsOverlay? rankingsOverlay { get; set; }

private UserCoverBackground cover = null!;
private CoverBackground cover = null!;
private SupporterIcon supporterTag = null!;
private UpdateableAvatar avatar = null!;
private OsuSpriteText usernameText = null!;
Expand Down Expand Up @@ -241,7 +241,7 @@ private void updateUser(UserProfileData? data)
{
var user = data?.User;

cover.User = user;
cover.Item = user;
avatar.User = user;
usernameText.Text = user?.Username ?? string.Empty;
openUserExternally.Link = $@"{api.Endpoints.WebsiteUrl}/users/{user?.Id ?? 0}";
Expand Down Expand Up @@ -277,7 +277,7 @@ private void updateCoverState()
flow.TransformTo(nameof(flow.Spacing), new Vector2(expanded ? 20f : 10f), transition_duration, Easing.OutQuint);
}

private partial class ProfileCoverBackground : UserCoverBackground
private partial class ProfileCoverBackground : CoverBackground
{
protected override double LoadDelay => 0;

Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/OnlinePlay/Matchmaking/Match/PlayerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ private void load(AudioManager audio)
RelativeSizeAxes = Axes.Both,
Colour = colourProvider?.Background5 ?? colours.Gray1
},
background = new UserCoverBackground
background = new CoverBackground
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = colours.Gray7,
User = User
Item = User
},
new Container
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Bindable<MultiplayerRoomUser> Current

private SpriteIcon crown = null!;

private UserCoverBackground userCover = null!;
private CoverBackground userCover = null!;
private UpdateableAvatar userAvatar = null!;
private UpdateableFlag userFlag = null!;
private OsuSpriteText username = null!;
Expand Down Expand Up @@ -119,7 +119,7 @@ private void load()
RelativeSizeAxes = Axes.Both,
Colour = backgroundColour
},
userCover = new UserCoverBackground
userCover = new CoverBackground
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Expand Down Expand Up @@ -240,7 +240,7 @@ private void updateUser()
{
var user = current.Value.User;

userCover.User = user;
userCover.Item = user;
userAvatar.User = user;
userFlag.CountryCode = user?.CountryCode ?? default;
teamFlagContainer.Child = new UpdateableTeamFlag(user?.Team)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ private void load()
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex("444")
},
new UserCoverBackground
new CoverBackground
{
RelativeSizeAxes = Axes.Both,
User = score.User,
Item = score.User,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
},
new FillFlowContainer
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/Ranking/ScorePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ private void load(AudioManager audio)
Children = new[]
{
middleLayerBackground = new Box { RelativeSizeAxes = Axes.Both },
new UserCoverBackground
new CoverBackground
{
RelativeSizeAxes = Axes.Both,
User = Score.User,
Item = Score.User,
Colour = ColourInfo.GradientVertical(Color4.White.Opacity(0.5f), Color4Extensions.FromHex("#444").Opacity(0))
}
}
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Screens/SelectV2/BeatmapLeaderboardScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ private void load()
RelativeSizeAxes = Axes.Both,
Colour = foregroundColour
},
new UserCoverBackground
new CoverBackground
{
RelativeSizeAxes = Axes.Both,
User = Score.User,
Item = Score.User,
Shear = sheared ? -OsuGame.SHEAR : Vector2.Zero,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Online.API.Requests.Responses;
using osuTK.Graphics;

namespace osu.Game.Users
{
public partial class UserCoverBackground : ModelBackedDrawable<APIUser?>
public partial class CoverBackground : ModelBackedDrawable<IHasCover?>
{
public APIUser? User
public IHasCover? Item
{
get => Model;
set => Model = value;
}

protected override Drawable CreateDrawable(APIUser? user) => new Cover(user);
protected override Drawable CreateDrawable(IHasCover? item) => new Cover(item);

protected override double LoadDelay => 300;

Expand All @@ -41,19 +40,19 @@ protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> cr
[LongRunningLoad]
private partial class Cover : CompositeDrawable
{
private readonly APIUser? user;
private readonly IHasCover? item;

public Cover(APIUser? user)
public Cover(IHasCover? item)
{
this.user = user;
this.item = item;

RelativeSizeAxes = Axes.Both;
}

[BackgroundDependencyLoader]
private void load(LargeTextureStore textures)
{
if (user == null)
if (item == null)
{
InternalChild = new Box
{
Expand All @@ -66,7 +65,7 @@ private void load(LargeTextureStore textures)
InternalChild = new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(user.CoverUrl),
Texture = textures.Get(item.CoverUrl),
FillMode = FillMode.Fill,
Anchor = Anchor.Centre,
Origin = Anchor.Centre
Expand Down
10 changes: 10 additions & 0 deletions osu.Game/Users/IHasCover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

namespace osu.Game.Users
{
public interface IHasCover
{
string? CoverUrl { get; }
}
}
4 changes: 2 additions & 2 deletions osu.Game/Users/UserPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ private void load()
/// <summary>
/// Panel background container. Can be null if a panel doesn't want a background under it's layout
/// </summary>
protected virtual Drawable? CreateBackground() => Background = new UserCoverBackground
protected virtual Drawable? CreateBackground() => Background = new CoverBackground
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
User = User
Item = User
};

protected OsuSpriteText CreateUsername() => new OsuSpriteText
Expand Down
4 changes: 2 additions & 2 deletions osu.Game/Users/UserRankPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ protected override Drawable CreateLayout()
Masking = true,
Children = new Drawable[]
{
new UserCoverBackground
new CoverBackground
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
User = User,
Item = User,
Alpha = 0.3f
},
new GridContainer
Expand Down