mirror of
https://github.com/ppy/osu.git
synced 2026-06-04 13:44:26 +08:00
Merge pull request #32657 from bdach/ruleset-specific-user-tags
Add support for ruleset-specific user tags
This commit is contained in:
@@ -9,6 +9,8 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Screens.Ranking;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Ranking
|
||||
@@ -20,10 +22,6 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("set up working beatmap", () =>
|
||||
{
|
||||
Beatmap.Value.BeatmapInfo.OnlineID = 42;
|
||||
});
|
||||
AddStep("set up network requests", () =>
|
||||
{
|
||||
dummyAPI.HandleRequest = request =>
|
||||
@@ -40,6 +38,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
new APITag { Id = 2, Name = "alt", Description = "Colloquial term for maps which use rhythms that encourage the player to alternate notes. Typically distinct from burst or stream maps.", },
|
||||
new APITag { Id = 3, Name = "aim", Description = "Category for difficulty relating to cursor movement.", },
|
||||
new APITag { Id = 4, Name = "tap", Description = "Category for difficulty relating to tapping input.", },
|
||||
new APITag { Id = 5, Name = "mono-heavy", Description = "Features monos used in large amounts.", RulesetId = 1, },
|
||||
]
|
||||
}), 500);
|
||||
return true;
|
||||
@@ -67,19 +66,34 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
return false;
|
||||
};
|
||||
});
|
||||
AddStep("create control", () =>
|
||||
AddStep("show for osu! beatmap", () =>
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new UserTagControl(Beatmap.Value.BeatmapInfo)
|
||||
{
|
||||
Width = 500,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.BeatmapInfo.OnlineID = 42;
|
||||
Beatmap.Value = working;
|
||||
recreateControl();
|
||||
});
|
||||
AddStep("show for taiko beatmap", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new TaikoRuleset().RulesetInfo);
|
||||
working.BeatmapInfo.OnlineID = 44;
|
||||
Beatmap.Value = working;
|
||||
recreateControl();
|
||||
});
|
||||
}
|
||||
|
||||
private void recreateControl()
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new UserTagControl(Beatmap.Value.BeatmapInfo)
|
||||
{
|
||||
Width = 500,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
[JsonProperty("ruleset_id")]
|
||||
public int? RulesetId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,12 +148,14 @@ namespace osu.Game.Screens.Ranking
|
||||
if (allTags.Value == null || apiBeatmap.Value?.TopTags == null)
|
||||
return;
|
||||
|
||||
var allTagsById = allTags.Value.ToDictionary(t => t.Id);
|
||||
var relevantTagsById = allTags.Value
|
||||
.Where(tag => tag.RulesetId == null || tag.RulesetId == beatmapInfo.Ruleset.OnlineID)
|
||||
.ToDictionary(t => t.Id);
|
||||
var ownTagIds = apiBeatmap.Value.OwnTagIds?.ToHashSet() ?? new HashSet<long>();
|
||||
|
||||
foreach (var topTag in apiBeatmap.Value.TopTags)
|
||||
{
|
||||
if (allTagsById.Remove(topTag.TagId, out var tag))
|
||||
if (relevantTagsById.Remove(topTag.TagId, out var tag))
|
||||
{
|
||||
displayedTags.Add(new UserTag(tag)
|
||||
{
|
||||
@@ -163,7 +165,7 @@ namespace osu.Game.Screens.Ranking
|
||||
}
|
||||
}
|
||||
|
||||
extraTags.AddRange(allTagsById.Select(t => new UserTag(t.Value)));
|
||||
extraTags.AddRange(relevantTagsById.Select(t => new UserTag(t.Value)));
|
||||
|
||||
loadingLayer.Hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user