Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pp and playtime to the UserRankPanel #27147

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
10 changes: 6 additions & 4 deletions osu.Game.Tests/Visual/Online/TestSceneUserPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void SetUp() => Schedule(() =>
CountryCode = CountryCode.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
Statistics = new UserStatistics { GlobalRank = 12345, CountryRank = 1234 }
}) { Width = 300 },
}) { Width = 360 },
new UserRankPanel(new APIUser
{
Username = @"peppy",
Expand All @@ -107,7 +107,7 @@ public void SetUp() => Schedule(() =>
CountryCode = CountryCode.AU,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
Statistics = new UserStatistics { GlobalRank = null, CountryRank = null }
}) { Width = 300 }
}) { Width = 360 }
}
};

Expand Down Expand Up @@ -165,8 +165,10 @@ public void TestUserStatisticsChange()
{
API.UpdateStatistics(new UserStatistics
{
GlobalRank = RNG.Next(100000),
CountryRank = RNG.Next(100000)
GlobalRank = RNG.Next(10_000_000),
CountryRank = RNG.Next(10_000_000),
PlayTime = RNG.Next(0, 100_000_000),
PP = RNG.Next(0, 30000)
});
});
AddStep("set statistics to empty", () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public void TestLogin()
Mode = @"osu",
Data = Enumerable.Range(2345, 45).Concat(Enumerable.Range(2109, 40)).ToArray()
},
PlayTime = 10_000_000
},
TournamentBanners = new[]
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/LoginOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void load()
{
new OsuContextMenuContainer
{
Width = 360,
Width = 400,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
Expand Down
8 changes: 4 additions & 4 deletions osu.Game/Overlays/Profile/Header/Components/MainDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public partial class MainDetails : CompositeDrawable
private ProfileValueDisplay detailGlobalRank = null!;
private ProfileValueDisplay detailCountryRank = null!;
private RankGraph rankGraph = null!;
private TotalPlayTime timeInfo = null!;

public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();

Expand Down Expand Up @@ -97,10 +98,7 @@ private void load()
{
Title = "pp",
},
new TotalPlayTime
{
User = { BindTarget = User }
},
timeInfo = new TotalPlayTime()
}
},
new FillFlowContainer
Expand Down Expand Up @@ -153,6 +151,8 @@ private void updateDisplay(UserProfileData? data)
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";

rankGraph.Statistics.Value = user?.Statistics;

timeInfo.UserStatistics.Value = user?.Statistics;
}

private partial class ScoreRankInfo : CompositeDrawable
Expand Down
9 changes: 5 additions & 4 deletions osu.Game/Overlays/Profile/Header/Components/TotalPlayTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Users;

namespace osu.Game.Overlays.Profile.Header.Components
{
public partial class TotalPlayTime : CompositeDrawable
{
public readonly Bindable<UserProfileData?> User = new Bindable<UserProfileData?>();
public readonly Bindable<UserStatistics?> UserStatistics = new Bindable<UserStatistics?>();

private ProfileValueDisplay info = null!;

Expand All @@ -29,12 +30,12 @@ private void load()
ContentTooltipText = "0 hours",
};

User.BindValueChanged(updateTime, true);
UserStatistics.BindValueChanged(updateTime, true);
}

private void updateTime(ValueChangedEvent<UserProfileData?> user)
private void updateTime(ValueChangedEvent<UserStatistics?> statistics)
{
int? playTime = user.NewValue?.User.Statistics?.PlayTime;
int? playTime = statistics.NewValue?.PlayTime;
info.ContentTooltipText = (playTime ?? 0) / 3600 + " hours";
info.Content = formatTime(playTime);
}
Expand Down
20 changes: 17 additions & 3 deletions osu.Game/Users/UserRankPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public partial class UserRankPanel : UserPanel

private ProfileValueDisplay globalRankDisplay = null!;
private ProfileValueDisplay countryRankDisplay = null!;
private ProfileValueDisplay ppDisplay = null!;

private readonly IBindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();

Expand All @@ -49,6 +50,7 @@ private void load()
{
globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-";
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
ppDisplay.Content = stats.NewValue?.PP?.ToLocalisableString("#,##0") ?? "0";
}, true);
}

Expand Down Expand Up @@ -152,27 +154,39 @@ protected override Drawable CreateLayout()
Margin = new MarginPadding { Top = main_content_height },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding { Left = 80, Vertical = padding },
Padding = new MarginPadding { Left = 80, Right = padding, Vertical = padding },
ColumnDimensions = new[]
{
new Dimension(),
new Dimension()
},
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize), new Dimension(GridSizeMode.AutoSize) },
Content = new[]
{
new Drawable[]
{
globalRankDisplay = new ProfileValueDisplay(true)
{
Title = UsersStrings.ShowRankGlobalSimple,
Margin = new MarginPadding { Bottom = padding }
// TODO: implement highest rank tooltip
// `RankHighest` resides in `APIUser`, but `api.LocalUser` doesn't update
// maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value
},
countryRankDisplay = new ProfileValueDisplay(true)
{
Title = UsersStrings.ShowRankCountrySimple,
Title = UsersStrings.ShowRankCountrySimple
}
},
new Drawable[]
{
ppDisplay = new ProfileValueDisplay
{
Title = "pp"
},
new TotalPlayTime
{
UserStatistics = { BindTarget = statistics }
}
}
}
Expand Down
Loading