mirror of
https://github.com/SK-la/Ez2Lazer.git
synced 2026-03-13 11:20:28 +00:00
Merge pull request #36798 from bdach/tags-broken
Fix a bunch of breakage around user tags
This commit is contained in:
@@ -117,7 +117,21 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"owners")]
|
||||
public BeatmapOwner[] BeatmapOwners { get; set; } = Array.Empty<BeatmapOwner>();
|
||||
|
||||
public (APITag Tag, int VoteCount)[] GetTopUserTags()
|
||||
/// <summary>
|
||||
/// Minimum count of votes required to display a tag on the beatmap's page.
|
||||
/// Should match value specified web-side as https://github.com/ppy/osu-web/blob/cae2fdf03cfb8c30c8e332cfb142e03188ceffef/config/osu.php#L59.
|
||||
/// </summary>
|
||||
public const int MINIMUM_USER_TAG_VOTES_FOR_DISPLAY = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves top user tags for the beatmap, ordered in a way matching osu!web.
|
||||
/// Requires <see cref="BeatmapSet"/> to be populated.
|
||||
/// </summary>
|
||||
/// <param name="confirmedOnly">
|
||||
/// If <see langword="true"/>, only tags above <see cref="MINIMUM_USER_TAG_VOTES_FOR_DISPLAY"/> will be shown.
|
||||
/// If <see langword="false"/>, all tags regardless of vote count will be shown.
|
||||
/// </param>
|
||||
public (APITag Tag, int VoteCount)[] GetTopUserTags(bool confirmedOnly = true)
|
||||
{
|
||||
if (TopTags == null || TopTags.Length == 0 || BeatmapSet?.RelatedTags == null)
|
||||
return [];
|
||||
@@ -126,7 +140,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
|
||||
return TopTags
|
||||
.Select(t => (topTag: t, relatedTag: tagsById.GetValueOrDefault(t.TagId)))
|
||||
.Where(t => t.relatedTag != null)
|
||||
.Where(t => t.relatedTag != null && (!confirmedOnly || t.topTag.VoteCount >= MINIMUM_USER_TAG_VOTES_FOR_DISPLAY))
|
||||
// see https://github.com/ppy/osu-web/blob/bb3bd2e7c6f84f26066df5ea20a81c77ec9bb60a/resources/js/beatmapsets-show/controller.ts#L103-L106 for sort criteria
|
||||
.OrderByDescending(t => t.topTag.VoteCount)
|
||||
.ThenBy(t => t.relatedTag!.Name)
|
||||
|
||||
@@ -242,12 +242,14 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
BeatmapSet.BindValueChanged(setInfo =>
|
||||
{
|
||||
Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = setInfo.NewValue;
|
||||
cover.OnlineInfo = setInfo.NewValue;
|
||||
var newBeatmapSet = setInfo.NewValue;
|
||||
|
||||
Picker.BeatmapSet = rulesetSelector.BeatmapSet = author.BeatmapSet = beatmapAvailability.BeatmapSet = Details.BeatmapSet = newBeatmapSet;
|
||||
cover.OnlineInfo = newBeatmapSet;
|
||||
|
||||
downloadTracker?.RemoveAndDisposeImmediately();
|
||||
|
||||
if (setInfo.NewValue == null)
|
||||
if (newBeatmapSet == null)
|
||||
{
|
||||
onlineStatusPill.FadeTo(0.5f, 500, Easing.OutQuint);
|
||||
videoIconPill.Hide();
|
||||
@@ -261,7 +263,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
}
|
||||
else
|
||||
{
|
||||
downloadTracker = new BeatmapDownloadTracker(setInfo.NewValue);
|
||||
foreach (var beatmap in newBeatmapSet.Beatmaps)
|
||||
beatmap.BeatmapSet = newBeatmapSet;
|
||||
|
||||
downloadTracker = new BeatmapDownloadTracker(newBeatmapSet);
|
||||
downloadTracker.State.BindValueChanged(_ => updateDownloadButtons());
|
||||
AddInternal(downloadTracker);
|
||||
|
||||
@@ -269,18 +274,18 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
loading.Hide();
|
||||
|
||||
if (setInfo.NewValue.HasVideo)
|
||||
if (newBeatmapSet.HasVideo)
|
||||
videoIconPill.Show();
|
||||
else
|
||||
videoIconPill.Hide();
|
||||
|
||||
if (setInfo.NewValue.HasStoryboard)
|
||||
if (newBeatmapSet.HasStoryboard)
|
||||
storyboardIconPill.Show();
|
||||
else
|
||||
storyboardIconPill.Hide();
|
||||
|
||||
var titleText = new RomanisableString(setInfo.NewValue.TitleUnicode, setInfo.NewValue.Title);
|
||||
var artistText = new RomanisableString(setInfo.NewValue.ArtistUnicode, setInfo.NewValue.Artist);
|
||||
var titleText = new RomanisableString(newBeatmapSet.TitleUnicode, newBeatmapSet.Title);
|
||||
var artistText = new RomanisableString(newBeatmapSet.ArtistUnicode, newBeatmapSet.Artist);
|
||||
|
||||
title.Clear();
|
||||
artist.Clear();
|
||||
@@ -290,13 +295,13 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
title.AddArbitraryDrawable(Empty().With(d => d.Width = 5));
|
||||
title.AddArbitraryDrawable(externalLink = new ExternalLinkButton());
|
||||
|
||||
if (setInfo.NewValue.HasExplicitContent)
|
||||
if (newBeatmapSet.HasExplicitContent)
|
||||
{
|
||||
title.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
|
||||
title.AddArbitraryDrawable(new ExplicitContentBeatmapBadge());
|
||||
}
|
||||
|
||||
if (setInfo.NewValue.FeaturedInSpotlight)
|
||||
if (newBeatmapSet.FeaturedInSpotlight)
|
||||
{
|
||||
title.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
|
||||
title.AddArbitraryDrawable(new SpotlightBeatmapBadge());
|
||||
@@ -304,7 +309,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
artist.AddLink(artistText, LinkAction.SearchBeatmapSet, LocalisableString.Interpolate($@"artist=""""{artistText}"""""));
|
||||
|
||||
if (setInfo.NewValue.TrackId != null)
|
||||
if (newBeatmapSet.TrackId != null)
|
||||
{
|
||||
artist.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
|
||||
artist.AddArbitraryDrawable(new FeaturedArtistBeatmapBadge());
|
||||
|
||||
@@ -13,6 +13,7 @@ using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
@@ -20,12 +21,6 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
public partial class DrawableUserTag : OsuAnimatedButton
|
||||
{
|
||||
/// <summary>
|
||||
/// Minimum count of votes required to display a tag on the beatmap's page.
|
||||
/// Should match value specified web-side as https://github.com/ppy/osu-web/blob/cae2fdf03cfb8c30c8e332cfb142e03188ceffef/config/osu.php#L59.
|
||||
/// </summary>
|
||||
public const int MIN_VOTES_DISPLAY = 5;
|
||||
|
||||
public readonly UserTag UserTag;
|
||||
|
||||
public Action<UserTag>? OnSelected { get; set; }
|
||||
@@ -160,7 +155,7 @@ namespace osu.Game.Screens.Ranking
|
||||
{
|
||||
voteCount.BindValueChanged(_ =>
|
||||
{
|
||||
confirmed.Value = voteCount.Value >= MIN_VOTES_DISPLAY;
|
||||
confirmed.Value = voteCount.Value >= APIBeatmap.MINIMUM_USER_TAG_VOTES_FOR_DISPLAY;
|
||||
}, true);
|
||||
voted.BindValueChanged(v =>
|
||||
{
|
||||
|
||||
@@ -70,7 +70,6 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private static void updateRealmBeatmapSet(Realm r, APIBeatmapSet onlineBeatmapSet)
|
||||
{
|
||||
var tagsById = (onlineBeatmapSet.RelatedTags ?? []).ToDictionary(t => t.Id);
|
||||
var onlineBeatmaps = onlineBeatmapSet.Beatmaps.ToDictionary(b => b.OnlineID);
|
||||
|
||||
var dbBeatmapSets = r.All<BeatmapSetInfo>().Where(b => b.OnlineID == onlineBeatmapSet.OnlineID);
|
||||
@@ -101,11 +100,10 @@ namespace osu.Game.Screens.Select
|
||||
if (dbBeatmap.MatchesOnlineVersion && dbBeatmap.Status != onlineBeatmap.Status)
|
||||
dbBeatmap.Status = onlineBeatmap.Status;
|
||||
|
||||
HashSet<string> userTags = onlineBeatmap.TopTags?
|
||||
.Select(t => (topTag: t, relatedTag: tagsById.GetValueOrDefault(t.TagId)))
|
||||
.Where(t => t.relatedTag != null)
|
||||
.Select(t => t.relatedTag!.Name)
|
||||
.ToHashSet() ?? [];
|
||||
onlineBeatmap.BeatmapSet = onlineBeatmapSet;
|
||||
HashSet<string> userTags = onlineBeatmap.GetTopUserTags(confirmedOnly: true)
|
||||
.Select(t => t.Tag.Name)
|
||||
.ToHashSet();
|
||||
|
||||
if (!userTags.SetEquals(dbBeatmap.Metadata.UserTags))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user