1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 12:22:57 +08:00

Merge pull request #22206 from Joehuu/beatmap-set-converted-beatmaps

Add ability to view converted beatmaps on beatmap set overlay
This commit is contained in:
Bartłomiej Dach 2023-01-16 21:28:36 +01:00 committed by GitHub
commit d9d0df78bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 21 deletions

View File

@ -1,8 +1,6 @@
// 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 disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
@ -50,7 +48,7 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestBeatmapLink()
{
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value.OnlineID == requested_beatmap_id);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value?.OnlineID == requested_beatmap_id);
}
}
}

View File

@ -63,6 +63,9 @@ namespace osu.Game.Online.API.Requests.Responses
set => Length = TimeSpan.FromSeconds(value).TotalMilliseconds;
}
[JsonProperty(@"convert")]
public bool Convert { get; set; }
[JsonProperty(@"count_circles")]
public int CircleCount { get; set; }

View File

@ -125,6 +125,9 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty(@"beatmaps")]
public APIBeatmap[] Beatmaps { get; set; } = Array.Empty<APIBeatmap>();
[JsonProperty(@"converts")]
public APIBeatmap[]? Converts { get; set; }
private BeatmapMetadata metadata => new BeatmapMetadata
{
Title = Title,

View File

@ -1,8 +1,6 @@
// 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 disable
using System;
using System.Linq;
using osu.Framework;
@ -38,10 +36,10 @@ namespace osu.Game.Overlays.BeatmapSet
public readonly DifficultiesContainer Difficulties;
public readonly Bindable<APIBeatmap> Beatmap = new Bindable<APIBeatmap>();
private APIBeatmapSet beatmapSet;
public readonly Bindable<APIBeatmap?> Beatmap = new Bindable<APIBeatmap?>();
private APIBeatmapSet? beatmapSet;
public APIBeatmapSet BeatmapSet
public APIBeatmapSet? BeatmapSet
{
get => beatmapSet;
set
@ -142,7 +140,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; }
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
@ -168,10 +166,11 @@ namespace osu.Game.Overlays.BeatmapSet
if (BeatmapSet != null)
{
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps
Difficulties.ChildrenEnumerable = BeatmapSet.Beatmaps.Concat(BeatmapSet.Converts ?? Array.Empty<APIBeatmap>())
.Where(b => b.Ruleset.MatchesOnlineID(ruleset.Value))
.OrderBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b)
.OrderBy(b => !b.Convert)
.ThenBy(b => b.StarRating)
.Select(b => new DifficultySelectorButton(b, b.Convert ? new RulesetInfo { OnlineID = 0 } : null)
{
State = DifficultySelectorState.NotSelected,
OnHovered = beatmap =>
@ -199,9 +198,9 @@ namespace osu.Game.Overlays.BeatmapSet
updateDifficultyButtons();
}
private void showBeatmap(IBeatmapInfo beatmapInfo)
private void showBeatmap(IBeatmapInfo? beatmapInfo)
{
version.Text = beatmapInfo?.DifficultyName;
version.Text = beatmapInfo?.DifficultyName ?? string.Empty;
}
private void updateDifficultyButtons()
@ -211,7 +210,7 @@ namespace osu.Game.Overlays.BeatmapSet
public partial class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
{
public Action OnLostHover;
public Action? OnLostHover;
protected override void OnHoverLost(HoverLostEvent e)
{
@ -232,9 +231,9 @@ namespace osu.Game.Overlays.BeatmapSet
public readonly APIBeatmap Beatmap;
public Action<APIBeatmap> OnHovered;
public Action<APIBeatmap> OnClicked;
public event Action<DifficultySelectorState> StateChanged;
public Action<APIBeatmap>? OnHovered;
public Action<APIBeatmap>? OnClicked;
public event Action<DifficultySelectorState>? StateChanged;
private DifficultySelectorState state;
@ -255,7 +254,7 @@ namespace osu.Game.Overlays.BeatmapSet
}
}
public DifficultySelectorButton(APIBeatmap beatmapInfo)
public DifficultySelectorButton(APIBeatmap beatmapInfo, IRulesetInfo? ruleset)
{
Beatmap = beatmapInfo;
Size = new Vector2(size);
@ -274,7 +273,7 @@ namespace osu.Game.Overlays.BeatmapSet
Alpha = 0.5f
}
},
icon = new DifficultyIcon(beatmapInfo)
icon = new DifficultyIcon(beatmapInfo, ruleset)
{
ShowTooltip = false,
Current = { Value = new StarDifficulty(beatmapInfo.StarRating, 0) },

View File

@ -68,11 +68,12 @@ namespace osu.Game.Overlays.BeatmapSet
BeatmapSet.BindValueChanged(setInfo =>
{
int beatmapsCount = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.MatchesOnlineID(Value)) ?? 0;
int osuBeatmaps = setInfo.NewValue?.Beatmaps.Count(b => b.Ruleset.OnlineID == 0) ?? 0;
count.Text = beatmapsCount.ToString();
countContainer.FadeTo(beatmapsCount > 0 ? 1 : 0);
Enabled.Value = beatmapsCount > 0;
Enabled.Value = beatmapsCount > 0 || osuBeatmaps > 0;
}, true);
}
}