mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge pull request #29714 from Crystallized21/total-participation-tooltip
Add Total Participation stat to users profile Daily Challenge Tooltip
This commit is contained in:
commit
4a6266efcf
@ -66,8 +66,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestPlayCountRankingTier()
|
public void TestPlayCountRankingTier()
|
||||||
{
|
{
|
||||||
AddAssert("1 before silver", () => DailyChallengeStatsDisplay.TierForPlayCount(30) == RankingTier.Bronze);
|
AddAssert("1 before silver", () => DailyChallengeStatsTooltip.TierForPlayCount(30) == RankingTier.Bronze);
|
||||||
AddAssert("first silver", () => DailyChallengeStatsDisplay.TierForPlayCount(31) == RankingTier.Silver);
|
AddAssert("first silver", () => DailyChallengeStatsTooltip.TierForPlayCount(31) == RankingTier.Silver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// 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;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
@ -14,7 +13,6 @@ using osu.Game.Graphics.Containers;
|
|||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Scoring;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Header.Components
|
namespace osu.Game.Overlays.Profile.Header.Components
|
||||||
{
|
{
|
||||||
@ -99,7 +97,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
if (User.Value == null || User.Value.Ruleset.OnlineID != 0)
|
if (User.Value == null)
|
||||||
{
|
{
|
||||||
Hide();
|
Hide();
|
||||||
return;
|
return;
|
||||||
@ -107,19 +105,20 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
APIUserDailyChallengeStatistics stats = User.Value.User.DailyChallengeStatistics;
|
APIUserDailyChallengeStatistics stats = User.Value.User.DailyChallengeStatistics;
|
||||||
|
|
||||||
|
if (stats.PlayCount == 0)
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0"));
|
dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0"));
|
||||||
dailyPlayCount.Colour = colours.ForRankingTier(TierForPlayCount(stats.PlayCount));
|
dailyPlayCount.Colour = colours.ForRankingTier(DailyChallengeStatsTooltip.TierForPlayCount(stats.PlayCount));
|
||||||
|
|
||||||
TooltipContent = new DailyChallengeTooltipData(colourProvider, stats);
|
TooltipContent = new DailyChallengeTooltipData(colourProvider, stats);
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rounding up is needed here to ensure the overlay shows the same colour as osu-web for the play count.
|
|
||||||
// This is because, for example, 31 / 3 > 10 in JavaScript because floats are used, while here it would
|
|
||||||
// get truncated to 10 with an integer division and show a lower tier.
|
|
||||||
public static RankingTier TierForPlayCount(int playCount) => DailyChallengeStatsTooltip.TierForDaily((int)Math.Ceiling(playCount / 3.0d));
|
|
||||||
|
|
||||||
public ITooltip<DailyChallengeTooltipData> GetCustomTooltip() => new DailyChallengeStatsTooltip();
|
public ITooltip<DailyChallengeTooltipData> GetCustomTooltip() => new DailyChallengeStatsTooltip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
@ -26,6 +27,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
{
|
{
|
||||||
private StreakPiece currentDaily = null!;
|
private StreakPiece currentDaily = null!;
|
||||||
private StreakPiece currentWeekly = null!;
|
private StreakPiece currentWeekly = null!;
|
||||||
|
private StreakPiece totalParticipation = null!;
|
||||||
private StatisticsPiece bestDaily = null!;
|
private StatisticsPiece bestDaily = null!;
|
||||||
private StatisticsPiece bestWeekly = null!;
|
private StatisticsPiece bestWeekly = null!;
|
||||||
private StatisticsPiece topTen = null!;
|
private StatisticsPiece topTen = null!;
|
||||||
@ -80,6 +82,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
Spacing = new Vector2(30f),
|
Spacing = new Vector2(30f),
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
|
totalParticipation = new StreakPiece(UsersStrings.ShowDailyChallengePlaycount),
|
||||||
currentDaily = new StreakPiece(UsersStrings.ShowDailyChallengeDailyStreakCurrent),
|
currentDaily = new StreakPiece(UsersStrings.ShowDailyChallengeDailyStreakCurrent),
|
||||||
currentWeekly = new StreakPiece(UsersStrings.ShowDailyChallengeWeeklyStreakCurrent),
|
currentWeekly = new StreakPiece(UsersStrings.ShowDailyChallengeWeeklyStreakCurrent),
|
||||||
}
|
}
|
||||||
@ -113,6 +116,9 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
background.Colour = colourProvider.Background4;
|
background.Colour = colourProvider.Background4;
|
||||||
topBackground.Colour = colourProvider.Background5;
|
topBackground.Colour = colourProvider.Background5;
|
||||||
|
|
||||||
|
totalParticipation.Value = DailyChallengeStatsDisplayStrings.UnitDay(statistics.PlayCount.ToLocalisableString(@"N0"));
|
||||||
|
totalParticipation.ValueColour = colours.ForRankingTier(TierForPlayCount(statistics.PlayCount));
|
||||||
|
|
||||||
currentDaily.Value = DailyChallengeStatsDisplayStrings.UnitDay(content.Statistics.DailyStreakCurrent.ToLocalisableString(@"N0"));
|
currentDaily.Value = DailyChallengeStatsDisplayStrings.UnitDay(content.Statistics.DailyStreakCurrent.ToLocalisableString(@"N0"));
|
||||||
currentDaily.ValueColour = colours.ForRankingTier(TierForDaily(statistics.DailyStreakCurrent));
|
currentDaily.ValueColour = colours.ForRankingTier(TierForDaily(statistics.DailyStreakCurrent));
|
||||||
|
|
||||||
@ -132,7 +138,13 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
topFifty.ValueColour = colourProvider.Content2;
|
topFifty.ValueColour = colourProvider.Content2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reference: https://github.com/ppy/osu-web/blob/8206e0e91eeea80ccf92f0586561346dd40e085e/resources/js/profile-page/daily-challenge.tsx#L13-L43
|
// reference: https://github.com/ppy/osu-web/blob/adf1e94754ba9625b85eba795f4a310caf169eec/resources/js/profile-page/daily-challenge.tsx#L13-L47
|
||||||
|
|
||||||
|
// Rounding up is needed here to ensure the overlay shows the same colour as osu-web for the play count.
|
||||||
|
// This is because, for example, 31 / 3 > 10 in JavaScript because floats are used, while here it would
|
||||||
|
// get truncated to 10 with an integer division and show a lower tier.
|
||||||
|
public static RankingTier TierForPlayCount(int playCount) => TierForDaily((int)Math.Ceiling(playCount / 3.0d));
|
||||||
|
|
||||||
public static RankingTier TierForDaily(int daily)
|
public static RankingTier TierForDaily(int daily)
|
||||||
{
|
{
|
||||||
if (daily > 360)
|
if (daily > 360)
|
||||||
|
Loading…
Reference in New Issue
Block a user