diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index ccfe1501bd..c4a8db92ed 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -57,10 +57,11 @@ namespace osu.Game.Rulesets.Mania.Beatmaps public static int GetColumnCount(LegacyBeatmapConversionDifficultyInfo difficulty) { - if (new ManiaRuleset().RulesetInfo.Equals(difficulty.SourceRuleset)) - return GetColumnCountForNonConvert(difficulty); - double roundedCircleSize = Math.Round(difficulty.CircleSize); + + if (new ManiaRuleset().RulesetInfo.Equals(difficulty.SourceRuleset)) + return (int)Math.Max(1, roundedCircleSize); + double roundedOverallDifficulty = Math.Round(difficulty.OverallDifficulty); int countSliderOrSpinner = difficulty.TotalObjectCount - difficulty.CircleCount; @@ -76,12 +77,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps return Math.Max(4, Math.Min((int)roundedOverallDifficulty + 1, 7)); } - public static int GetColumnCountForNonConvert(IBeatmapDifficultyInfo difficulty) - { - double roundedCircleSize = Math.Round(difficulty.CircleSize); - return (int)Math.Max(1, roundedCircleSize); - } - public override bool CanConvert() => Beatmap.HitObjects.All(h => h is IHasXPosition); protected override Beatmap ConvertBeatmap(IBeatmap original, CancellationToken cancellationToken) diff --git a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs index 7f8a00bf88..930ca217cd 100644 --- a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs +++ b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs @@ -4,6 +4,7 @@ using osu.Game.Beatmaps; using osu.Game.Rulesets.Filter; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Scoring.Legacy; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Filter; @@ -15,7 +16,7 @@ namespace osu.Game.Rulesets.Mania public bool Matches(BeatmapInfo beatmapInfo) { - return !keys.HasFilter || (beatmapInfo.Ruleset.OnlineID == new ManiaRuleset().LegacyID && keys.IsInRange(ManiaBeatmapConverter.GetColumnCountForNonConvert(beatmapInfo.Difficulty))); + return !keys.HasFilter || keys.IsInRange(ManiaBeatmapConverter.GetColumnCount(LegacyBeatmapConversionDifficultyInfo.FromBeatmapInfo(beatmapInfo))); } public bool TryParseCustomKeywordCriteria(string key, Operator op, string value) diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 0c317e0f8a..c38d6519bd 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -420,6 +420,9 @@ namespace osu.Game.Rulesets.Mania public override RulesetSetupSection CreateEditorSetupSection() => new ManiaSetupSection(); public override DifficultySection CreateEditorDifficultySection() => new ManiaDifficultySection(); + + public int GetKeyCount(IBeatmapInfo beatmapInfo) + => ManiaBeatmapConverter.GetColumnCount(LegacyBeatmapConversionDifficultyInfo.FromBeatmapInfo(beatmapInfo)); } public enum PlayfieldType diff --git a/osu.Game/Rulesets/ILegacyRuleset.cs b/osu.Game/Rulesets/ILegacyRuleset.cs index 6900afa243..18d86f477a 100644 --- a/osu.Game/Rulesets/ILegacyRuleset.cs +++ b/osu.Game/Rulesets/ILegacyRuleset.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Game.Beatmaps; using osu.Game.Rulesets.Scoring.Legacy; namespace osu.Game.Rulesets @@ -14,6 +15,12 @@ namespace osu.Game.Rulesets /// int LegacyID { get; } + /// + /// Retrieves the number of mania keys required to play the beatmap. + /// + /// + int GetKeyCount(IBeatmapInfo beatmapInfo) => 0; + ILegacyScoreSimulator CreateLegacyScoreSimulator(); } } diff --git a/osu.Game/Rulesets/Scoring/Legacy/LegacyBeatmapConversionDifficultyInfo.cs b/osu.Game/Rulesets/Scoring/Legacy/LegacyBeatmapConversionDifficultyInfo.cs index 9c9294417f..6f379e4ef1 100644 --- a/osu.Game/Rulesets/Scoring/Legacy/LegacyBeatmapConversionDifficultyInfo.cs +++ b/osu.Game/Rulesets/Scoring/Legacy/LegacyBeatmapConversionDifficultyInfo.cs @@ -1,10 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System.Linq; using osu.Game.Beatmaps; using osu.Game.Online.API.Requests.Responses; -using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Scoring.Legacy { @@ -31,9 +29,6 @@ namespace osu.Game.Rulesets.Scoring.Legacy /// /// The count of hitcircles in the beatmap. /// - /// - /// When converting from osu! ruleset beatmaps, this is equivalent to the sum of sliders and spinners in the beatmap. - /// public int CircleCount { get; set; } /// @@ -47,22 +42,17 @@ namespace osu.Game.Rulesets.Scoring.Legacy double IBeatmapDifficultyInfo.SliderTickRate => 0; int IBeatmapDifficultyInfo.EndTimeObjectCount => TotalObjectCount - CircleCount; - public static LegacyBeatmapConversionDifficultyInfo FromAPIBeatmap(APIBeatmap apiBeatmap) => new LegacyBeatmapConversionDifficultyInfo - { - SourceRuleset = apiBeatmap.Ruleset, - CircleSize = apiBeatmap.CircleSize, - OverallDifficulty = apiBeatmap.OverallDifficulty, - CircleCount = apiBeatmap.CircleCount, - TotalObjectCount = apiBeatmap.SliderCount + apiBeatmap.SpinnerCount + apiBeatmap.CircleCount - }; + public static LegacyBeatmapConversionDifficultyInfo FromAPIBeatmap(APIBeatmap apiBeatmap) => FromBeatmapInfo(apiBeatmap); - public static LegacyBeatmapConversionDifficultyInfo FromBeatmap(IBeatmap beatmap) => new LegacyBeatmapConversionDifficultyInfo + public static LegacyBeatmapConversionDifficultyInfo FromBeatmap(IBeatmap beatmap) => FromBeatmapInfo(beatmap.BeatmapInfo); + + public static LegacyBeatmapConversionDifficultyInfo FromBeatmapInfo(IBeatmapInfo beatmapInfo) => new LegacyBeatmapConversionDifficultyInfo { - SourceRuleset = beatmap.BeatmapInfo.Ruleset, - CircleSize = beatmap.Difficulty.CircleSize, - OverallDifficulty = beatmap.Difficulty.OverallDifficulty, - CircleCount = beatmap.HitObjects.Count(h => h is not IHasDuration), - TotalObjectCount = beatmap.HitObjects.Count + SourceRuleset = beatmapInfo.Ruleset, + CircleSize = beatmapInfo.Difficulty.CircleSize, + OverallDifficulty = beatmapInfo.Difficulty.OverallDifficulty, + CircleCount = beatmapInfo.Difficulty.TotalObjectCount - beatmapInfo.Difficulty.EndTimeObjectCount, + TotalObjectCount = beatmapInfo.Difficulty.TotalObjectCount }; } } diff --git a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs index 3dfd801f02..cda95a9d29 100644 --- a/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmap.cs @@ -27,6 +27,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osu.Game.Resources.Localisation.Web; +using osu.Game.Rulesets; using osuTK; using osuTK.Graphics; @@ -57,6 +58,8 @@ namespace osu.Game.Screens.Select.Carousel private StarCounter starCounter = null!; private DifficultyIcon difficultyIcon = null!; + private OsuSpriteText keyCountText = null!; + [Resolved] private BeatmapSetOverlay? beatmapOverlay { get; set; } @@ -69,6 +72,9 @@ namespace osu.Game.Screens.Select.Carousel [Resolved] private RealmAccess realm { get; set; } = null!; + [Resolved] + private IBindable ruleset { get; set; } = null!; + private IBindable starDifficultyBindable = null!; private CancellationTokenSource? starDifficultyCancellationSource; @@ -133,6 +139,13 @@ namespace osu.Game.Screens.Select.Carousel AutoSizeAxes = Axes.Both, Children = new[] { + keyCountText = new OsuSpriteText + { + Font = OsuFont.GetFont(size: 20), + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Alpha = 0, + }, new OsuSpriteText { Text = beatmapInfo.DifficultyName, @@ -167,6 +180,13 @@ namespace osu.Game.Screens.Select.Carousel }; } + protected override void LoadComplete() + { + base.LoadComplete(); + + ruleset.BindValueChanged(_ => updateKeyCount()); + } + protected override void Selected() { base.Selected(); @@ -216,11 +236,28 @@ namespace osu.Game.Screens.Select.Carousel if (d.NewValue != null) difficultyIcon.Current.Value = d.NewValue.Value; }, true); + + updateKeyCount(); } base.ApplyState(); } + private void updateKeyCount() + { + if (ruleset.Value.OnlineID == 3) + { + // Account for mania differences locally for now. + // Eventually this should be handled in a more modular way, allowing rulesets to add more information to the panel. + ILegacyRuleset legacyRuleset = (ILegacyRuleset)ruleset.Value.CreateInstance(); + + keyCountText.Alpha = 1; + keyCountText.Text = $"[{legacyRuleset.GetKeyCount(beatmapInfo)}K]"; + } + else + keyCountText.Alpha = 0; + } + public MenuItem[] ContextMenuItems { get diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index a383298faa..87185c351e 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -126,13 +126,21 @@ namespace osu.Game.Screens.Select.Details mod.ApplyToDifficulty(adjustedDifficulty); } - switch (BeatmapInfo?.Ruleset.OnlineID) + switch (gameRuleset.Value.OnlineID) { case 3: - // Account for mania differences locally for now - // Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes + // Account for mania differences locally for now. + // Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes. + ILegacyRuleset legacyRuleset = (ILegacyRuleset)gameRuleset.Value.CreateInstance(); + + // For the time being, the key count is static no matter what, because: + // a) The method doesn't have knowledge of the active keymods. Doing so may require considerations for filtering. + // b) Using the difficulty adjustment mod to adjust OD doesn't have an effect on conversion. + int keyCount = baseDifficulty == null ? 0 : legacyRuleset.GetKeyCount(BeatmapInfo); + FirstValue.Title = BeatmapsetsStrings.ShowStatsCsMania; - FirstValue.Value = (baseDifficulty?.CircleSize ?? 0, null); + FirstValue.Value = (keyCount, keyCount); + break; default: