From 9cfe9164fa544794f1e4ecc0d0536a3827fe64d4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jul 2023 16:58:41 +0900 Subject: [PATCH 1/5] Add helper method to get drain length (and rename some usages) --- osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs | 8 ++++---- osu.Game/Beatmaps/IBeatmap.cs | 5 +++++ osu.Game/Rulesets/Edit/BeatmapVerifier.cs | 2 +- .../Checks/{CheckDrainTime.cs => CheckDrainLength.cs} | 7 ++++--- 4 files changed, 14 insertions(+), 8 deletions(-) rename osu.Game/Rulesets/Edit/Checks/{CheckDrainTime.cs => CheckDrainLength.cs} (86%) diff --git a/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs b/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs index f845d3c4c1..d4eb378222 100644 --- a/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs @@ -16,12 +16,12 @@ namespace osu.Game.Tests.Editing.Checks { public class CheckDrainTimeTest { - private CheckDrainTime check = null!; + private CheckDrainLength check = null!; [SetUp] public void Setup() { - check = new CheckDrainTime(); + check = new CheckDrainLength(); } [Test] @@ -40,7 +40,7 @@ namespace osu.Game.Tests.Editing.Checks var issues = check.Run(context).ToList(); Assert.That(issues, Has.Count.EqualTo(1)); - Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort); + Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort); } [Test] @@ -63,7 +63,7 @@ namespace osu.Game.Tests.Editing.Checks var issues = check.Run(context).ToList(); Assert.That(issues, Has.Count.EqualTo(1)); - Assert.That(issues.Single().Template is CheckDrainTime.IssueTemplateTooShort); + Assert.That(issues.Single().Template is CheckDrainLength.IssueTemplateTooShort); } [Test] diff --git a/osu.Game/Beatmaps/IBeatmap.cs b/osu.Game/Beatmaps/IBeatmap.cs index fbe1a9b462..d97eb00d7e 100644 --- a/osu.Game/Beatmaps/IBeatmap.cs +++ b/osu.Game/Beatmaps/IBeatmap.cs @@ -110,6 +110,11 @@ namespace osu.Game.Beatmaps /// public static double CalculatePlayableLength(this IBeatmap beatmap) => CalculatePlayableLength(beatmap.HitObjects); + /// + /// Find the total milliseconds between the first and last hittable objects, excluding any break time. + /// + public static double CalculateDrainLength(this IBeatmap beatmap) => CalculatePlayableLength(beatmap.HitObjects) - beatmap.TotalBreakTime; + /// /// Find the timestamps in milliseconds of the start and end of the playable region. /// diff --git a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs index 4bcf74db45..6782c4324a 100644 --- a/osu.Game/Rulesets/Edit/BeatmapVerifier.cs +++ b/osu.Game/Rulesets/Edit/BeatmapVerifier.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Edit new CheckUnsnappedObjects(), new CheckConcurrentObjects(), new CheckZeroLengthObjects(), - new CheckDrainTime(), + new CheckDrainLength(), // Timing new CheckPreviewTime(), diff --git a/osu.Game/Rulesets/Edit/Checks/CheckDrainTime.cs b/osu.Game/Rulesets/Edit/Checks/CheckDrainLength.cs similarity index 86% rename from osu.Game/Rulesets/Edit/Checks/CheckDrainTime.cs rename to osu.Game/Rulesets/Edit/Checks/CheckDrainLength.cs index 21f053f2c2..ac65dfadff 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckDrainTime.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckDrainLength.cs @@ -7,10 +7,11 @@ using osu.Game.Rulesets.Edit.Checks.Components; namespace osu.Game.Rulesets.Edit.Checks { - public class CheckDrainTime : ICheck + public class CheckDrainLength : ICheck { private const int min_drain_threshold = 30 * 1000; - public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "Too short drain time"); + + public CheckMetadata Metadata => new CheckMetadata(CheckCategory.Compose, "Drain length is too short"); public IEnumerable PossibleTemplates => new IssueTemplate[] { @@ -19,7 +20,7 @@ namespace osu.Game.Rulesets.Edit.Checks public IEnumerable Run(BeatmapVerifierContext context) { - double drainTime = context.Beatmap.CalculatePlayableLength() - context.Beatmap.TotalBreakTime; + double drainTime = context.Beatmap.CalculateDrainLength(); if (drainTime < min_drain_threshold) yield return new IssueTemplateTooShort(this).Create((int)(drainTime / 1000)); From 480163ec2e3ad4b2c7fb0e9c133761492430183b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jul 2023 16:58:53 +0900 Subject: [PATCH 2/5] Show drain length in length tooltip at song select --- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 45 +++++++++------------ 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 3605e3d706..81759f6787 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -352,29 +352,6 @@ namespace osu.Game.Screens.Select if (working.Beatmap?.HitObjects.Any() != true) return; - infoLabelContainer.Children = new Drawable[] - { - new InfoLabel(new BeatmapStatistic - { - Name = "Length", - CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length), - Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(), - }), - bpmLabelContainer = new Container - { - AutoSizeAxes = Axes.Both, - }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(20, 0), - Children = getRulesetInfoLabels() - } - }; - } - - private InfoLabel[] getRulesetInfoLabels() - { try { IBeatmap playableBeatmap; @@ -390,14 +367,30 @@ namespace osu.Game.Screens.Select playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset, Array.Empty()); } - return playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)).ToArray(); + infoLabelContainer.Children = new Drawable[] + { + new InfoLabel(new BeatmapStatistic + { + Name = $"Length (Drain: {playableBeatmap.CalculateDrainLength().ToFormattedDuration().ToString()})", + CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length), + Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(), + }), + bpmLabelContainer = new Container + { + AutoSizeAxes = Axes.Both, + }, + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Spacing = new Vector2(20, 0), + Children = playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)).ToArray() + } + }; } catch (Exception e) { Logger.Error(e, "Could not load beatmap successfully!"); } - - return Array.Empty(); } private void refreshBPMLabel() From 9edaa6909e0fd9255d6c9e16108f0a679882283c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 25 Jul 2023 17:02:27 +0900 Subject: [PATCH 3/5] Show only the break length instead of total minute breaks --- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 81759f6787..495a191c95 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -371,7 +371,7 @@ namespace osu.Game.Screens.Select { new InfoLabel(new BeatmapStatistic { - Name = $"Length (Drain: {playableBeatmap.CalculateDrainLength().ToFormattedDuration().ToString()})", + Name = $"Length (Breaks: {playableBeatmap.TotalBreakTime.ToFormattedDuration().ToString()})", CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length), Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(), }), From 3b11559fd0812c6ca2d2efa0b7e03cf5814c2ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 25 Jul 2023 22:17:55 +0200 Subject: [PATCH 4/5] Revert "Show only the break length instead of total minute breaks" This reverts commit 9edaa6909e0fd9255d6c9e16108f0a679882283c. --- osu.Game/Screens/Select/BeatmapInfoWedge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Select/BeatmapInfoWedge.cs b/osu.Game/Screens/Select/BeatmapInfoWedge.cs index 495a191c95..81759f6787 100644 --- a/osu.Game/Screens/Select/BeatmapInfoWedge.cs +++ b/osu.Game/Screens/Select/BeatmapInfoWedge.cs @@ -371,7 +371,7 @@ namespace osu.Game.Screens.Select { new InfoLabel(new BeatmapStatistic { - Name = $"Length (Breaks: {playableBeatmap.TotalBreakTime.ToFormattedDuration().ToString()})", + Name = $"Length (Drain: {playableBeatmap.CalculateDrainLength().ToFormattedDuration().ToString()})", CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length), Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(), }), From c6099edb88ef483e1e2d8c20bca9ba1c9bd43774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 25 Jul 2023 22:18:31 +0200 Subject: [PATCH 5/5] Rename test to match class --- .../Checks/{CheckDrainTimeTest.cs => CheckDrainLengthTest.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename osu.Game.Tests/Editing/Checks/{CheckDrainTimeTest.cs => CheckDrainLengthTest.cs} (98%) diff --git a/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs b/osu.Game.Tests/Editing/Checks/CheckDrainLengthTest.cs similarity index 98% rename from osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs rename to osu.Game.Tests/Editing/Checks/CheckDrainLengthTest.cs index d4eb378222..1b5c5c398f 100644 --- a/osu.Game.Tests/Editing/Checks/CheckDrainTimeTest.cs +++ b/osu.Game.Tests/Editing/Checks/CheckDrainLengthTest.cs @@ -14,7 +14,7 @@ using osu.Game.Tests.Beatmaps; namespace osu.Game.Tests.Editing.Checks { - public class CheckDrainTimeTest + public class CheckDrainLengthTest { private CheckDrainLength check = null!;