mirror of
https://github.com/ppy/osu.git
synced 2025-03-23 02:57:25 +08:00
Share hype/nomination statistic show logic
This commit is contained in:
parent
883fcf2604
commit
3fa45479b0
@ -380,13 +380,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
private IEnumerable<BeatmapCardStatistic> createStatistics()
|
||||
{
|
||||
if (beatmapSet.HypeStatus != null)
|
||||
yield return new HypesStatistic(beatmapSet.HypeStatus);
|
||||
var hypesStatistic = HypesStatistic.CreateFor(beatmapSet);
|
||||
if (hypesStatistic != null)
|
||||
yield return hypesStatistic;
|
||||
|
||||
// web does not show nominations unless hypes are also present.
|
||||
// see: https://github.com/ppy/osu-web/blob/8ed7d071fd1d3eaa7e43cf0e4ff55ca2fef9c07c/resources/assets/lib/beatmapset-panel.tsx#L443
|
||||
if (beatmapSet.HypeStatus != null && beatmapSet.NominationStatus != null)
|
||||
yield return new NominationsStatistic(beatmapSet.NominationStatus);
|
||||
var nominationsStatistic = NominationsStatistic.CreateFor(beatmapSet);
|
||||
if (nominationsStatistic != null)
|
||||
yield return nominationsStatistic;
|
||||
|
||||
yield return new FavouritesStatistic(beatmapSet) { Current = favouriteState };
|
||||
yield return new PlayCountStatistic(beatmapSet);
|
||||
|
@ -409,13 +409,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
||||
|
||||
statisticsContainer.Content[1][0] = withMargin(new PlayCountStatistic(beatmapSet));
|
||||
|
||||
if (beatmapSet.HypeStatus != null)
|
||||
statisticsContainer.Content[0][1] = withMargin(new HypesStatistic(beatmapSet.HypeStatus));
|
||||
var hypesStatistic = HypesStatistic.CreateFor(beatmapSet);
|
||||
if (hypesStatistic != null)
|
||||
statisticsContainer.Content[0][1] = withMargin(hypesStatistic);
|
||||
|
||||
// web does not show nominations unless hypes are also present.
|
||||
// see: https://github.com/ppy/osu-web/blob/8ed7d071fd1d3eaa7e43cf0e4ff55ca2fef9c07c/resources/assets/lib/beatmapset-panel.tsx#L443
|
||||
if (beatmapSet.HypeStatus != null && beatmapSet.NominationStatus != null)
|
||||
statisticsContainer.Content[1][1] = withMargin(new NominationsStatistic(beatmapSet.NominationStatus));
|
||||
var nominationsStatistic = NominationsStatistic.CreateFor(beatmapSet);
|
||||
if (nominationsStatistic != null)
|
||||
statisticsContainer.Content[1][1] = withMargin(nominationsStatistic);
|
||||
|
||||
var dateStatistic = BeatmapCardDateStatistic.CreateFor(beatmapSet);
|
||||
if (dateStatistic != null)
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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 enable
|
||||
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
@ -12,11 +14,14 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Statistics
|
||||
/// </summary>
|
||||
public class HypesStatistic : BeatmapCardStatistic
|
||||
{
|
||||
public HypesStatistic(BeatmapSetHypeStatus hypeStatus)
|
||||
private HypesStatistic(BeatmapSetHypeStatus hypeStatus)
|
||||
{
|
||||
Icon = FontAwesome.Solid.Bullhorn;
|
||||
Text = hypeStatus.Current.ToLocalisableString();
|
||||
TooltipText = BeatmapsStrings.HypeRequiredText(hypeStatus.Current.ToLocalisableString(), hypeStatus.Required.ToLocalisableString());
|
||||
}
|
||||
|
||||
public static HypesStatistic? CreateFor(IBeatmapSetOnlineInfo beatmapSetOnlineInfo)
|
||||
=> beatmapSetOnlineInfo.HypeStatus == null ? null : new HypesStatistic(beatmapSetOnlineInfo.HypeStatus);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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 enable
|
||||
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
@ -12,11 +14,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Statistics
|
||||
/// </summary>
|
||||
public class NominationsStatistic : BeatmapCardStatistic
|
||||
{
|
||||
public NominationsStatistic(BeatmapSetNominationStatus nominationStatus)
|
||||
private NominationsStatistic(BeatmapSetNominationStatus nominationStatus)
|
||||
{
|
||||
Icon = FontAwesome.Solid.ThumbsUp;
|
||||
Text = nominationStatus.Current.ToLocalisableString();
|
||||
TooltipText = BeatmapsStrings.NominationsRequiredText(nominationStatus.Current.ToLocalisableString(), nominationStatus.Required.ToLocalisableString());
|
||||
}
|
||||
|
||||
public static NominationsStatistic? CreateFor(IBeatmapSetOnlineInfo beatmapSetOnlineInfo)
|
||||
// web does not show nominations unless hypes are also present.
|
||||
// see: https://github.com/ppy/osu-web/blob/8ed7d071fd1d3eaa7e43cf0e4ff55ca2fef9c07c/resources/assets/lib/beatmapset-panel.tsx#L443
|
||||
=> beatmapSetOnlineInfo.HypeStatus == null || beatmapSetOnlineInfo.NominationStatus == null ? null : new NominationsStatistic(beatmapSetOnlineInfo.NominationStatus);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user