1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 09:03:00 +08:00

Substitute APIUser for UserProfile in overlay

This commit is contained in:
Bartłomiej Dach 2022-12-30 14:56:19 +01:00
parent 608d8ee7d4
commit d7294ac3e6
No known key found for this signature in database
34 changed files with 130 additions and 129 deletions

View File

@ -9,6 +9,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Profile;
using osu.Game.Overlays.Profile.Sections;
namespace osu.Game.Tests.Visual.Online
@ -37,8 +38,8 @@ namespace osu.Game.Tests.Visual.Online
Child = section = new HistoricalSection(),
});
AddStep("Show peppy", () => section.User.Value = new APIUser { Id = 2 });
AddStep("Show WubWoofWolf", () => section.User.Value = new APIUser { Id = 39828 });
AddStep("Show peppy", () => section.UserProfile.Value = new UserProfile(new APIUser { Id = 2 }));
AddStep("Show WubWoofWolf", () => section.UserProfile.Value = new UserProfile(new APIUser { Id = 39828 }));
}
}
}

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using osu.Game.Overlays.Profile.Sections.Historical;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -14,6 +12,7 @@ using System.Linq;
using osu.Framework.Testing;
using osu.Framework.Graphics.Shapes;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile;
namespace osu.Game.Tests.Visual.Online
{
@ -22,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Red);
private readonly Bindable<APIUser> user = new Bindable<APIUser>();
private readonly Bindable<UserProfile?> user = new Bindable<UserProfile?>();
private readonly PlayHistorySubsection section;
public TestScenePlayHistorySubsection()
@ -45,49 +44,49 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestNullValues()
{
AddStep("Load user", () => user.Value = user_with_null_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_null_values));
AddAssert("Section is hidden", () => section.Alpha == 0);
}
[Test]
public void TestEmptyValues()
{
AddStep("Load user", () => user.Value = user_with_empty_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_empty_values));
AddAssert("Section is hidden", () => section.Alpha == 0);
}
[Test]
public void TestOneValue()
{
AddStep("Load user", () => user.Value = user_with_one_value);
AddStep("Load user", () => user.Value = new UserProfile(user_with_one_value));
AddAssert("Section is hidden", () => section.Alpha == 0);
}
[Test]
public void TestTwoValues()
{
AddStep("Load user", () => user.Value = user_with_two_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_two_values));
AddAssert("Section is visible", () => section.Alpha == 1);
}
[Test]
public void TestConstantValues()
{
AddStep("Load user", () => user.Value = user_with_constant_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_constant_values));
AddAssert("Section is visible", () => section.Alpha == 1);
}
[Test]
public void TestConstantZeroValues()
{
AddStep("Load user", () => user.Value = user_with_zero_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_zero_values));
AddAssert("Section is visible", () => section.Alpha == 1);
}
[Test]
public void TestFilledValues()
{
AddStep("Load user", () => user.Value = user_with_filled_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_filled_values));
AddAssert("Section is visible", () => section.Alpha == 1);
AddAssert("Array length is the same", () => user_with_filled_values.MonthlyPlayCounts.Length == getChartValuesLength());
}
@ -95,7 +94,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestMissingValues()
{
AddStep("Load user", () => user.Value = user_with_missing_values);
AddStep("Load user", () => user.Value = new UserProfile(user_with_missing_values));
AddAssert("Section is visible", () => section.Alpha == 1);
AddAssert("Array length is 7", () => getChartValuesLength() == 7);
}

View File

@ -29,33 +29,33 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestBasic()
{
AddStep("Show example user", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);
AddStep("Show example user", () => header.UserProfile.Value = new UserProfile(TestSceneUserProfileOverlay.TEST_USER));
}
[Test]
public void TestOnlineState()
{
AddStep("Show online user", () => header.User.Value = new APIUser
AddStep("Show online user", () => header.UserProfile.Value = new UserProfile(new APIUser
{
Id = 1001,
Username = "IAmOnline",
LastVisit = DateTimeOffset.Now,
IsOnline = true,
});
}));
AddStep("Show offline user", () => header.User.Value = new APIUser
AddStep("Show offline user", () => header.UserProfile.Value = new UserProfile(new APIUser
{
Id = 1002,
Username = "IAmOffline",
LastVisit = DateTimeOffset.Now.AddDays(-10),
IsOnline = false,
});
}));
}
[Test]
public void TestRankedState()
{
AddStep("Show ranked user", () => header.User.Value = new APIUser
AddStep("Show ranked user", () => header.UserProfile.Value = new UserProfile(new APIUser
{
Id = 2001,
Username = "RankedUser",
@ -70,9 +70,9 @@ namespace osu.Game.Tests.Visual.Online
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
},
}
});
}));
AddStep("Show unranked user", () => header.User.Value = new APIUser
AddStep("Show unranked user", () => header.UserProfile.Value = new UserProfile(new APIUser
{
Id = 2002,
Username = "UnrankedUser",
@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Online
Data = Enumerable.Range(2345, 85).ToArray()
},
}
});
}));
}
}
}

View File

@ -10,6 +10,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Profile;
using osu.Game.Overlays.Profile.Sections;
namespace osu.Game.Tests.Visual.Online
@ -44,7 +45,7 @@ namespace osu.Game.Tests.Visual.Online
}
});
AddStep("Show cookiezi", () => ranks.User.Value = new APIUser { Id = 124493 });
AddStep("Show cookiezi", () => ranks.UserProfile.Value = new UserProfile(new APIUser { Id = 124493 }));
}
}
}

View File

@ -23,7 +23,7 @@ namespace osu.Game.Overlays.Profile.Header
{
public partial class BottomHeaderContainer : CompositeDrawable
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
private LinkFlowContainer topLinkContainer = null!;
private LinkFlowContainer bottomLinkContainer = null!;
@ -73,7 +73,7 @@ namespace osu.Game.Overlays.Profile.Header
}
};
User.BindValueChanged(user => updateDisplay(user.NewValue));
UserProfile.BindValueChanged(user => updateDisplay(user.NewValue?.User));
}
private void updateDisplay(APIUser? user)

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Header
public partial class CentreHeaderContainer : CompositeDrawable
{
public readonly BindableBool DetailsVisible = new BindableBool(true);
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
private OverlinedInfoContainer hiddenDetailGlobal = null!;
private OverlinedInfoContainer hiddenDetailCountry = null!;
@ -53,15 +53,15 @@ namespace osu.Game.Overlays.Profile.Header
{
new FollowersButton
{
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
},
new MappingSubscribersButton
{
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
},
new MessageUserButton
{
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
},
}
},
@ -92,7 +92,7 @@ namespace osu.Game.Overlays.Profile.Header
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Size = new Vector2(40),
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
},
expandedDetailContainer = new Container
{
@ -104,7 +104,7 @@ namespace osu.Game.Overlays.Profile.Header
Child = new LevelProgressBar
{
RelativeSizeAxes = Axes.Both,
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
}
},
hiddenDetailContainer = new FillFlowContainer
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Profile.Header
expandedDetailContainer.FadeTo(visible.NewValue ? 1 : 0, 200, Easing.OutQuint);
});
User.BindValueChanged(user => updateDisplay(user.NewValue));
UserProfile.BindValueChanged(userProfile => updateDisplay(userProfile.NewValue?.User));
}
private void updateDisplay(APIUser? user)

View File

@ -5,14 +5,13 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class FollowersButton : ProfileHeaderStatisticsButton
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public override LocalisableString TooltipText => FriendsStrings.ButtonsDisabled;
@ -22,7 +21,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private void load()
{
// todo: when friending/unfriending is implemented, the APIAccess.Friends list should be updated accordingly.
User.BindValueChanged(user => SetValue(user.NewValue?.FollowerCount ?? 0), true);
UserProfile.BindValueChanged(user => SetValue(user.NewValue?.User.FollowerCount ?? 0), true);
}
}
}

View File

@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class LevelBadge : CompositeDrawable, IHasTooltip
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public LocalisableString TooltipText { get; private set; }
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
};
User.BindValueChanged(user => updateLevel(user.NewValue));
UserProfile.BindValueChanged(user => updateLevel(user.NewValue?.User));
}
private void updateLevel(APIUser? user)

View File

@ -19,7 +19,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class LevelProgressBar : CompositeDrawable, IHasTooltip
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public LocalisableString TooltipText { get; }
@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
}
};
User.BindValueChanged(user => updateProgress(user.NewValue));
UserProfile.BindValueChanged(user => updateProgress(user.NewValue?.User));
}
private void updateProgress(APIUser? user)

View File

@ -5,14 +5,13 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class MappingSubscribersButton : ProfileHeaderStatisticsButton
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public override LocalisableString TooltipText => FollowsStrings.MappingFollowers;
@ -21,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
[BackgroundDependencyLoader]
private void load()
{
User.BindValueChanged(user => SetValue(user.NewValue?.MappingFollowerCount ?? 0), true);
UserProfile.BindValueChanged(user => SetValue(user.NewValue?.User.MappingFollowerCount ?? 0), true);
}
}
}

View File

@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
using osuTK;
@ -16,7 +15,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class MessageUserButton : ProfileHeaderButton
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public override LocalisableString TooltipText => UsersStrings.CardSendMessage;
@ -49,12 +48,16 @@ namespace osu.Game.Overlays.Profile.Header.Components
{
if (!Content.IsPresent) return;
channelManager?.OpenPrivateChannel(User.Value);
channelManager?.OpenPrivateChannel(UserProfile.Value?.User);
userOverlay?.Hide();
chatOverlay?.Show();
};
User.ValueChanged += e => Content.Alpha = e.NewValue != null && !e.NewValue.PMFriendsOnly && apiProvider.LocalUser.Value.Id != e.NewValue.Id ? 1 : 0;
UserProfile.ValueChanged += e =>
{
var user = e.NewValue?.User;
Content.Alpha = user != null && !user.PMFriendsOnly && apiProvider.LocalUser.Value.Id != user.Id ? 1 : 0;
};
}
}
}

View File

@ -7,14 +7,13 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class OverlinedTotalPlayTime : CompositeDrawable, IHasTooltip
{
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
public LocalisableString TooltipText { get; set; }
@ -36,13 +35,14 @@ namespace osu.Game.Overlays.Profile.Header.Components
LineColour = colourProvider.Highlight1,
};
User.BindValueChanged(updateTime, true);
UserProfile.BindValueChanged(updateTime, true);
}
private void updateTime(ValueChangedEvent<APIUser?> user)
private void updateTime(ValueChangedEvent<UserProfile?> userProfile)
{
TooltipText = (user.NewValue?.Statistics?.PlayTime ?? 0) / 3600 + " hours";
info.Content = formatTime(user.NewValue?.Statistics?.PlayTime);
int? playTime = userProfile.NewValue?.User.Statistics?.PlayTime;
TooltipText = (playTime ?? 0) / 3600 + " hours";
info.Content = formatTime(playTime);
}
private string formatTime(int? secondsNull)

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Resources.Localisation.Web;
@ -30,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Header
private FillFlowContainer? fillFlow;
private RankGraph rankGraph = null!;
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
private bool expanded = true;
@ -61,7 +60,7 @@ namespace osu.Game.Overlays.Profile.Header
{
AutoSizeAxes = Axes.Y;
User.ValueChanged += e => updateDisplay(e.NewValue);
UserProfile.ValueChanged += e => updateDisplay(e.NewValue);
InternalChildren = new Drawable[]
{
@ -99,7 +98,7 @@ namespace osu.Game.Overlays.Profile.Header
{
new OverlinedTotalPlayTime
{
User = { BindTarget = User }
UserProfile = { BindTarget = UserProfile }
},
medalInfo = new OverlinedInfoContainer
{
@ -171,8 +170,10 @@ namespace osu.Game.Overlays.Profile.Header
};
}
private void updateDisplay(APIUser? user)
private void updateDisplay(UserProfile? userProfile)
{
var user = userProfile?.User;
medalInfo.Content = user?.Achievements?.Length.ToString() ?? "0";
ppInfo.Content = user?.Statistics?.PP?.ToLocalisableString("#,##0") ?? (LocalisableString)"0";

View File

@ -20,14 +20,14 @@ namespace osu.Game.Overlays.Profile.Header
{
private FillFlowContainer badgeFlowContainer = null!;
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Alpha = 0;
AutoSizeAxes = Axes.Y;
User.ValueChanged += e => updateDisplay(e.NewValue);
UserProfile.ValueChanged += e => updateDisplay(e.NewValue?.User);
InternalChildren = new Drawable[]
{

View File

@ -15,7 +15,6 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header.Components;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users.Drawables;
@ -27,7 +26,7 @@ namespace osu.Game.Overlays.Profile.Header
{
private const float avatar_size = 110;
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
[Resolved]
private IAPIProvider api { get; set; } = null!;
@ -171,11 +170,13 @@ namespace osu.Game.Overlays.Profile.Header
}
};
User.BindValueChanged(user => updateUser(user.NewValue));
UserProfile.BindValueChanged(user => updateUser(user.NewValue));
}
private void updateUser(APIUser? user)
private void updateUser(UserProfile? userProfile)
{
var user = userProfile?.User;
avatar.User = user;
usernameText.Text = user?.Username ?? string.Empty;
openUserExternally.Link = $@"{api.WebsiteRootUrl}/users/{user?.Id ?? 0}";

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile.Header;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;
@ -20,7 +19,7 @@ namespace osu.Game.Overlays.Profile
{
private UserCoverBackground coverContainer = null!;
public Bindable<APIUser?> User = new Bindable<APIUser?>();
public Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
private CentreHeaderContainer centreHeaderContainer;
private DetailHeaderContainer detailHeaderContainer;
@ -29,7 +28,7 @@ namespace osu.Game.Overlays.Profile
{
ContentSidePadding = UserProfileOverlay.CONTENT_X_MARGIN;
User.ValueChanged += e => updateDisplay(e.NewValue);
UserProfile.ValueChanged += e => updateDisplay(e.NewValue);
TabControl.AddItem(LayoutStrings.HeaderUsersShow);
@ -73,34 +72,34 @@ namespace osu.Game.Overlays.Profile
new TopHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
UserProfile = { BindTarget = UserProfile },
},
centreHeaderContainer = new CentreHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
UserProfile = { BindTarget = UserProfile },
},
detailHeaderContainer = new DetailHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
UserProfile = { BindTarget = UserProfile },
},
new MedalHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
UserProfile = { BindTarget = UserProfile },
},
new BottomHeaderContainer
{
RelativeSizeAxes = Axes.X,
User = { BindTarget = User },
UserProfile = { BindTarget = UserProfile },
},
}
};
protected override OverlayTitle CreateTitle() => new ProfileHeaderTitle();
private void updateDisplay(APIUser? user) => coverContainer.User = user;
private void updateDisplay(UserProfile? userProfile) => coverContainer.User = userProfile?.User;
private partial class ProfileHeaderTitle : OverlayTitle
{

View File

@ -13,7 +13,6 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Profile
{
@ -29,7 +28,7 @@ namespace osu.Game.Overlays.Profile
protected override Container<Drawable> Content => content;
public readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
public readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
protected ProfileSection()
{

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
protected override int InitialItemsCount => type == BeatmapSetType.Graveyard ? 2 : 6;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<APIUser?> user, LocalisableString headerText)
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<UserProfile?> user, LocalisableString headerText)
: base(user, headerText)
{
this.type = type;

View File

@ -18,13 +18,13 @@ namespace osu.Game.Overlays.Profile.Sections
{
Children = new[]
{
new PaginatedBeatmapContainer(BeatmapSetType.Favourite, User, UsersStrings.ShowExtraBeatmapsFavouriteTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Ranked, User, UsersStrings.ShowExtraBeatmapsRankedTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Loved, User, UsersStrings.ShowExtraBeatmapsLovedTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Guest, User, UsersStrings.ShowExtraBeatmapsGuestTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Pending, User, UsersStrings.ShowExtraBeatmapsPendingTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, UsersStrings.ShowExtraBeatmapsGraveyardTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Nominated, User, UsersStrings.ShowExtraBeatmapsNominatedTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Favourite, UserProfile, UsersStrings.ShowExtraBeatmapsFavouriteTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Ranked, UserProfile, UsersStrings.ShowExtraBeatmapsRankedTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Loved, UserProfile, UsersStrings.ShowExtraBeatmapsLovedTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Guest, UserProfile, UsersStrings.ShowExtraBeatmapsGuestTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Pending, UserProfile, UsersStrings.ShowExtraBeatmapsPendingTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, UserProfile, UsersStrings.ShowExtraBeatmapsGraveyardTitle),
new PaginatedBeatmapContainer(BeatmapSetType.Nominated, UserProfile, UsersStrings.ShowExtraBeatmapsNominatedTitle),
};
}
}

View File

@ -20,8 +20,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
/// </summary>
protected abstract LocalisableString GraphCounterName { get; }
protected ChartProfileSubsection(Bindable<APIUser?> user, LocalisableString headerText)
: base(user, headerText)
protected ChartProfileSubsection(Bindable<UserProfile?> userProfile, LocalisableString headerText)
: base(userProfile, headerText)
{
}
@ -41,12 +41,12 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(onUserChanged, true);
UserProfile.BindValueChanged(onUserChanged, true);
}
private void onUserChanged(ValueChangedEvent<APIUser?> e)
private void onUserChanged(ValueChangedEvent<UserProfile?> e)
{
var values = GetValues(e.NewValue);
var values = GetValues(e.NewValue?.User);
if (values == null || values.Length <= 1)
{

View File

@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public partial class PaginatedMostPlayedBeatmapContainer : PaginatedProfileSubsection<APIUserMostPlayedBeatmap>
{
public PaginatedMostPlayedBeatmapContainer(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalMostPlayedTitle)
public PaginatedMostPlayedBeatmapContainer(Bindable<UserProfile?> userProfile)
: base(userProfile, UsersStrings.ShowExtraHistoricalMostPlayedTitle)
{
}

View File

@ -12,8 +12,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalMonthlyPlaycountsCountLabel;
public PlayHistorySubsection(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalMonthlyPlaycountsTitle)
public PlayHistorySubsection(Bindable<UserProfile?> userProfile)
: base(userProfile, UsersStrings.ShowExtraHistoricalMonthlyPlaycountsTitle)
{
}

View File

@ -12,8 +12,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
protected override LocalisableString GraphCounterName => UsersStrings.ShowExtraHistoricalReplaysWatchedCountsCountLabel;
public ReplaysSubsection(Bindable<APIUser?> user)
: base(user, UsersStrings.ShowExtraHistoricalReplaysWatchedCountsTitle)
public ReplaysSubsection(Bindable<UserProfile?> userProfile)
: base(userProfile, UsersStrings.ShowExtraHistoricalReplaysWatchedCountsTitle)
{
}

View File

@ -20,10 +20,10 @@ namespace osu.Game.Overlays.Profile.Sections
{
Children = new Drawable[]
{
new PlayHistorySubsection(User),
new PaginatedMostPlayedBeatmapContainer(User),
new PaginatedScoreContainer(ScoreType.Recent, User, UsersStrings.ShowExtraHistoricalRecentPlaysTitle),
new ReplaysSubsection(User)
new PlayHistorySubsection(UserProfile),
new PaginatedMostPlayedBeatmapContainer(UserProfile),
new PaginatedScoreContainer(ScoreType.Recent, UserProfile, UsersStrings.ShowExtraHistoricalRecentPlaysTitle),
new ReplaysSubsection(UserProfile)
};
}
}

View File

@ -14,17 +14,16 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Game.Resources.Localisation.Web;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public partial class KudosuInfo : Container
{
private readonly Bindable<APIUser?> user = new Bindable<APIUser?>();
private readonly Bindable<UserProfile?> userProfile = new Bindable<UserProfile?>();
public KudosuInfo(Bindable<APIUser?> user)
public KudosuInfo(Bindable<UserProfile?> userProfile)
{
this.user.BindTo(user);
this.userProfile.BindTo(userProfile);
CountSection total;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -32,7 +31,7 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
CornerRadius = 3;
Child = total = new CountTotal();
this.user.ValueChanged += u => total.Count = u.NewValue?.Kudosu.Total ?? 0;
this.userProfile.ValueChanged += u => total.Count = u.NewValue?.User.Kudosu.Total ?? 0;
}
protected override bool OnClick(ClickEvent e) => true;

View File

@ -14,8 +14,8 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
public partial class PaginatedKudosuHistoryContainer : PaginatedProfileSubsection<APIKudosuHistory>
{
public PaginatedKudosuHistoryContainer(Bindable<APIUser?> user)
: base(user, missingText: UsersStrings.ShowExtraKudosuEntryEmpty)
public PaginatedKudosuHistoryContainer(Bindable<UserProfile?> userProfile)
: base(userProfile, missingText: UsersStrings.ShowExtraKudosuEntryEmpty)
{
}

View File

@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Profile.Sections
{
Children = new Drawable[]
{
new KudosuInfo(User),
new PaginatedKudosuHistoryContainer(User),
new KudosuInfo(UserProfile),
new PaginatedKudosuHistoryContainer(UserProfile),
};
}
}

View File

@ -46,8 +46,8 @@ namespace osu.Game.Overlays.Profile.Sections
private OsuSpriteText missing = null!;
private readonly LocalisableString? missingText;
protected PaginatedProfileSubsection(Bindable<APIUser?> user, LocalisableString? headerText = null, LocalisableString? missingText = null)
: base(user, headerText, CounterVisibilityState.AlwaysVisible)
protected PaginatedProfileSubsection(Bindable<UserProfile?> userProfile, LocalisableString? headerText = null, LocalisableString? missingText = null)
: base(userProfile, headerText, CounterVisibilityState.AlwaysVisible)
{
this.missingText = missingText;
}
@ -89,10 +89,10 @@ namespace osu.Game.Overlays.Profile.Sections
protected override void LoadComplete()
{
base.LoadComplete();
User.BindValueChanged(onUserChanged, true);
UserProfile.BindValueChanged(onUserChanged, true);
}
private void onUserChanged(ValueChangedEvent<APIUser?> e)
private void onUserChanged(ValueChangedEvent<UserProfile?> e)
{
loadCancellation?.Cancel();
retrievalRequest?.Cancel();
@ -100,23 +100,23 @@ namespace osu.Game.Overlays.Profile.Sections
CurrentPage = null;
ItemsContainer.Clear();
if (e.NewValue != null)
if (e.NewValue?.User != null)
{
showMore();
SetCount(GetCount(e.NewValue));
SetCount(GetCount(e.NewValue.User));
}
}
private void showMore()
{
if (User.Value == null)
if (UserProfile.Value?.User == null)
return;
loadCancellation = new CancellationTokenSource();
CurrentPage = CurrentPage?.TakeNext(ItemsPerPage) ?? new PaginationParameters(InitialItemsCount);
retrievalRequest = CreateRequest(User.Value, CurrentPage.Value);
retrievalRequest = CreateRequest(UserProfile.Value.User, CurrentPage.Value);
retrievalRequest.Success += items => UpdateItems(items, loadCancellation);
api.Queue(retrievalRequest);

View File

@ -6,24 +6,23 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Profile.Sections
{
public abstract partial class ProfileSubsection : FillFlowContainer
{
protected readonly Bindable<APIUser?> User = new Bindable<APIUser?>();
protected readonly Bindable<UserProfile?> UserProfile = new Bindable<UserProfile?>();
private readonly LocalisableString headerText;
private readonly CounterVisibilityState counterVisibilityState;
private ProfileSubsectionHeader header = null!;
protected ProfileSubsection(Bindable<APIUser?> user, LocalisableString? headerText = null, CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
protected ProfileSubsection(Bindable<UserProfile?> userProfile, LocalisableString? headerText = null, CounterVisibilityState counterVisibilityState = CounterVisibilityState.AlwaysHidden)
{
this.headerText = headerText ?? string.Empty;
this.counterVisibilityState = counterVisibilityState;
User.BindTo(user);
UserProfile.BindTo(userProfile);
}
[BackgroundDependencyLoader]

View File

@ -19,8 +19,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
private readonly ScoreType type;
public PaginatedScoreContainer(ScoreType type, Bindable<APIUser?> user, LocalisableString headerText)
: base(user, headerText)
public PaginatedScoreContainer(ScoreType type, Bindable<UserProfile?> userProfile, LocalisableString headerText)
: base(userProfile, headerText)
{
this.type = type;
}

View File

@ -18,9 +18,9 @@ namespace osu.Game.Overlays.Profile.Sections
{
Children = new[]
{
new PaginatedScoreContainer(ScoreType.Pinned, User, UsersStrings.ShowExtraTopRanksPinnedTitle),
new PaginatedScoreContainer(ScoreType.Best, User, UsersStrings.ShowExtraTopRanksBestTitle),
new PaginatedScoreContainer(ScoreType.Firsts, User, UsersStrings.ShowExtraTopRanksFirstTitle)
new PaginatedScoreContainer(ScoreType.Pinned, UserProfile, UsersStrings.ShowExtraTopRanksPinnedTitle),
new PaginatedScoreContainer(ScoreType.Best, UserProfile, UsersStrings.ShowExtraTopRanksBestTitle),
new PaginatedScoreContainer(ScoreType.Firsts, UserProfile, UsersStrings.ShowExtraTopRanksFirstTitle)
};
}
}

View File

@ -16,8 +16,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
{
public partial class PaginatedRecentActivityContainer : PaginatedProfileSubsection<APIRecentActivity>
{
public PaginatedRecentActivityContainer(Bindable<APIUser?> user)
: base(user, missingText: EventsStrings.Empty)
public PaginatedRecentActivityContainer(Bindable<UserProfile?> userProfile)
: base(userProfile, missingText: EventsStrings.Empty)
{
}

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays.Profile.Sections
{
Children = new[]
{
new PaginatedRecentActivityContainer(User),
new PaginatedRecentActivityContainer(UserProfile),
};
}
}

View File

@ -47,7 +47,7 @@ namespace osu.Game.Overlays
Show();
if (user.OnlineID == Header?.User.Value?.Id)
if (user.OnlineID == Header?.UserProfile.Value?.User.Id)
return;
if (sectionsContainer != null)
@ -134,7 +134,8 @@ namespace osu.Game.Overlays
{
Debug.Assert(sections != null && sectionsContainer != null && tabs != null);
Header.User.Value = user;
var userProfile = new UserProfile(user);
Header.UserProfile.Value = userProfile;
if (user.ProfileOrder != null)
{
@ -144,7 +145,7 @@ namespace osu.Game.Overlays
if (sec != null)
{
sec.User.Value = user;
sec.UserProfile.Value = userProfile;
sectionsContainer.Add(sec);
tabs.AddItem(sec);