mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 01:37:46 +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()
|
private IEnumerable<BeatmapCardStatistic> createStatistics()
|
||||||
{
|
{
|
||||||
if (beatmapSet.HypeStatus != null)
|
var hypesStatistic = HypesStatistic.CreateFor(beatmapSet);
|
||||||
yield return new HypesStatistic(beatmapSet.HypeStatus);
|
if (hypesStatistic != null)
|
||||||
|
yield return hypesStatistic;
|
||||||
|
|
||||||
// web does not show nominations unless hypes are also present.
|
var nominationsStatistic = NominationsStatistic.CreateFor(beatmapSet);
|
||||||
// see: https://github.com/ppy/osu-web/blob/8ed7d071fd1d3eaa7e43cf0e4ff55ca2fef9c07c/resources/assets/lib/beatmapset-panel.tsx#L443
|
if (nominationsStatistic != null)
|
||||||
if (beatmapSet.HypeStatus != null && beatmapSet.NominationStatus != null)
|
yield return nominationsStatistic;
|
||||||
yield return new NominationsStatistic(beatmapSet.NominationStatus);
|
|
||||||
|
|
||||||
yield return new FavouritesStatistic(beatmapSet) { Current = favouriteState };
|
yield return new FavouritesStatistic(beatmapSet) { Current = favouriteState };
|
||||||
yield return new PlayCountStatistic(beatmapSet);
|
yield return new PlayCountStatistic(beatmapSet);
|
||||||
|
@ -409,13 +409,13 @@ namespace osu.Game.Beatmaps.Drawables.Cards
|
|||||||
|
|
||||||
statisticsContainer.Content[1][0] = withMargin(new PlayCountStatistic(beatmapSet));
|
statisticsContainer.Content[1][0] = withMargin(new PlayCountStatistic(beatmapSet));
|
||||||
|
|
||||||
if (beatmapSet.HypeStatus != null)
|
var hypesStatistic = HypesStatistic.CreateFor(beatmapSet);
|
||||||
statisticsContainer.Content[0][1] = withMargin(new HypesStatistic(beatmapSet.HypeStatus));
|
if (hypesStatistic != null)
|
||||||
|
statisticsContainer.Content[0][1] = withMargin(hypesStatistic);
|
||||||
|
|
||||||
// web does not show nominations unless hypes are also present.
|
var nominationsStatistic = NominationsStatistic.CreateFor(beatmapSet);
|
||||||
// see: https://github.com/ppy/osu-web/blob/8ed7d071fd1d3eaa7e43cf0e4ff55ca2fef9c07c/resources/assets/lib/beatmapset-panel.tsx#L443
|
if (nominationsStatistic != null)
|
||||||
if (beatmapSet.HypeStatus != null && beatmapSet.NominationStatus != null)
|
statisticsContainer.Content[1][1] = withMargin(nominationsStatistic);
|
||||||
statisticsContainer.Content[1][1] = withMargin(new NominationsStatistic(beatmapSet.NominationStatus));
|
|
||||||
|
|
||||||
var dateStatistic = BeatmapCardDateStatistic.CreateFor(beatmapSet);
|
var dateStatistic = BeatmapCardDateStatistic.CreateFor(beatmapSet);
|
||||||
if (dateStatistic != null)
|
if (dateStatistic != null)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
@ -12,11 +14,14 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Statistics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class HypesStatistic : BeatmapCardStatistic
|
public class HypesStatistic : BeatmapCardStatistic
|
||||||
{
|
{
|
||||||
public HypesStatistic(BeatmapSetHypeStatus hypeStatus)
|
private HypesStatistic(BeatmapSetHypeStatus hypeStatus)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.Bullhorn;
|
Icon = FontAwesome.Solid.Bullhorn;
|
||||||
Text = hypeStatus.Current.ToLocalisableString();
|
Text = hypeStatus.Current.ToLocalisableString();
|
||||||
TooltipText = BeatmapsStrings.HypeRequiredText(hypeStatus.Current.ToLocalisableString(), hypeStatus.Required.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.
|
// 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.
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
@ -12,11 +14,16 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Statistics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class NominationsStatistic : BeatmapCardStatistic
|
public class NominationsStatistic : BeatmapCardStatistic
|
||||||
{
|
{
|
||||||
public NominationsStatistic(BeatmapSetNominationStatus nominationStatus)
|
private NominationsStatistic(BeatmapSetNominationStatus nominationStatus)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.ThumbsUp;
|
Icon = FontAwesome.Solid.ThumbsUp;
|
||||||
Text = nominationStatus.Current.ToLocalisableString();
|
Text = nominationStatus.Current.ToLocalisableString();
|
||||||
TooltipText = BeatmapsStrings.NominationsRequiredText(nominationStatus.Current.ToLocalisableString(), nominationStatus.Required.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