From 6402f23f0245ecac17f82f1a9e5f06b9bd7898b2 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 12 Feb 2024 21:00:15 +0200 Subject: [PATCH 01/27] Added Traceable support for pp --- .../Difficulty/OsuPerformanceCalculator.cs | 12 ++++++++++++ osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs | 1 + 2 files changed, 13 insertions(+) diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index b31f4ff519..4771bce280 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -116,6 +116,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR. aimValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } + else if (score.Mods.Any(h => h is OsuModTraceable)) + { + // Default 2% increase and another is scaled by AR + aimValue *= 1.02 + 0.02 * (12.0 - attributes.ApproachRate); + } // We assume 15% of sliders in a map are difficult since there's no way to tell from the performance calculator. double estimateDifficultSliders = attributes.SliderCount * 0.15; @@ -167,6 +172,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR. speedValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } + else if (score.Mods.Any(h => h is OsuModTraceable)) + { + // More reward for speed because speed on Traceable is annoying + speedValue *= 1.04 + 0.06 * (12.0 - attributes.ApproachRate); + } // Calculate accuracy assuming the worst case scenario double relevantTotalDiff = totalHits - attributes.SpeedNoteCount; @@ -214,6 +224,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty accuracyValue *= 1.14; else if (score.Mods.Any(m => m is OsuModHidden)) accuracyValue *= 1.08; + else if (score.Mods.Any(m => m is OsuModTraceable)) + accuracyValue *= 1.02 + 0.01 * (12.0 - attributes.ApproachRate); if (score.Mods.Any(m => m is OsuModFlashlight)) accuracyValue *= 1.02; diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs index 9671f53bea..320c0a7040 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs @@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Osu.Mods public override ModType Type => ModType.Fun; public override LocalisableString Description => "Put your faith in the approach circles..."; public override double ScoreMultiplier => 1; + public override bool Ranked => UsesDefaultConfiguration; public override Type[] IncompatibleMods => new[] { typeof(IHidesApproachCircles), typeof(OsuModDepth) }; From 56391550096a19486e06d98a20e1f5bb1421c090 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Mon, 12 Feb 2024 23:31:00 +0200 Subject: [PATCH 02/27] Update OsuModTraceable.cs --- osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs index 320c0a7040..9671f53bea 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModTraceable.cs @@ -19,7 +19,6 @@ namespace osu.Game.Rulesets.Osu.Mods public override ModType Type => ModType.Fun; public override LocalisableString Description => "Put your faith in the approach circles..."; public override double ScoreMultiplier => 1; - public override bool Ranked => UsesDefaultConfiguration; public override Type[] IncompatibleMods => new[] { typeof(IHidesApproachCircles), typeof(OsuModDepth) }; From 600098d845611a45147154690cc09f992c961119 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 27 Mar 2024 04:05:04 +0900 Subject: [PATCH 03/27] Fix bulbs on Catmull sliders --- osu.Game/Rulesets/Objects/SliderPath.cs | 68 +++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/osu.Game/Rulesets/Objects/SliderPath.cs b/osu.Game/Rulesets/Objects/SliderPath.cs index f33a07f082..5398d6c45f 100644 --- a/osu.Game/Rulesets/Objects/SliderPath.cs +++ b/osu.Game/Rulesets/Objects/SliderPath.cs @@ -42,6 +42,17 @@ namespace osu.Game.Rulesets.Objects private readonly List cumulativeLength = new List(); private readonly Cached pathCache = new Cached(); + /// + /// Any additional length of the path which was optimised out during piecewise approximation, but should still be considered as part of . + /// + /// + /// This is a hack for Catmull paths. + /// + private double optimisedLength; + + /// + /// The final calculated length of the path. + /// private double calculatedLength; private readonly List segmentEnds = new List(); @@ -244,6 +255,7 @@ namespace osu.Game.Rulesets.Objects { calculatedPath.Clear(); segmentEnds.Clear(); + optimisedLength = 0; if (ControlPoints.Count == 0) return; @@ -268,7 +280,8 @@ namespace osu.Game.Rulesets.Objects calculatedPath.Add(segmentVertices[0]); else if (segmentVertices.Length > 1) { - List subPath = calculateSubPath(segmentVertices, segmentType); + List subPath = calculateSubPath(segmentVertices, segmentType, ref optimisedLength); + // Skip the first vertex if it is the same as the last vertex from the previous segment bool skipFirst = calculatedPath.Count > 0 && subPath.Count > 0 && calculatedPath.Last() == subPath[0]; @@ -287,7 +300,7 @@ namespace osu.Game.Rulesets.Objects } } - private List calculateSubPath(ReadOnlySpan subControlPoints, PathType type) + private static List calculateSubPath(ReadOnlySpan subControlPoints, PathType type, ref double optimisedLength) { switch (type.Type) { @@ -295,6 +308,7 @@ namespace osu.Game.Rulesets.Objects return PathApproximator.LinearToPiecewiseLinear(subControlPoints); case SplineType.PerfectCurve: + { if (subControlPoints.Length != 3) break; @@ -305,9 +319,55 @@ namespace osu.Game.Rulesets.Objects break; return subPath; + } case SplineType.Catmull: - return PathApproximator.CatmullToPiecewiseLinear(subControlPoints); + { + List subPath = PathApproximator.CatmullToPiecewiseLinear(subControlPoints); + + // At draw time, osu!stable optimises paths by only keeping piecewise segments that are 6px apart. + // For the most part we don't care about this optimisation, and its additional heuristics are hard to reproduce in every implementation. + // + // However, it matters for Catmull paths which form "bulbs" around sequential knots with identical positions, + // so we'll apply a very basic form of the optimisation here and return a length representing the optimised portion. + // The returned length is important so that the optimisation doesn't cause the path to get extended to match the value of ExpectedDistance. + + List optimisedPath = new List(subPath.Count); + + Vector2? lastStart = null; + double lengthRemovedSinceStart = 0; + + for (int i = 0; i < subPath.Count; i++) + { + if (lastStart == null) + { + optimisedPath.Add(subPath[i]); + lastStart = subPath[i]; + continue; + } + + Debug.Assert(i > 0); + + double distFromStart = Vector2.Distance(lastStart.Value, subPath[i]); + lengthRemovedSinceStart += Vector2.Distance(subPath[i - 1], subPath[i]); + + // See PathApproximator.catmull_detail. + const int catmull_detail = 50; + const int catmull_segment_length = catmull_detail * 2; + + // Either 6px from the start, the last vertex at every knot, or the end of the path. + if (distFromStart > 6 || (i + 1) % catmull_segment_length == 0 || i == subPath.Count - 1) + { + optimisedPath.Add(subPath[i]); + optimisedLength += lengthRemovedSinceStart - distFromStart; + + lastStart = null; + lengthRemovedSinceStart = 0; + } + } + + return optimisedPath; + } } return PathApproximator.BSplineToPiecewiseLinear(subControlPoints, type.Degree ?? subControlPoints.Length); @@ -315,7 +375,7 @@ namespace osu.Game.Rulesets.Objects private void calculateLength() { - calculatedLength = 0; + calculatedLength = optimisedLength; cumulativeLength.Clear(); cumulativeLength.Add(0); From 4806ea54f1a55c1220c0772d2b385f674a06661d Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 1 Apr 2024 17:22:50 +0900 Subject: [PATCH 04/27] Only optimise Catmull segments in osu ruleset --- osu.Game.Rulesets.Osu/Objects/Slider.cs | 2 +- osu.Game/Rulesets/Objects/SliderPath.cs | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 203e829180..cc3ffd376e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -41,7 +41,7 @@ namespace osu.Game.Rulesets.Osu.Objects public Vector2 StackedPositionAt(double t) => StackedPosition + this.CurvePositionAt(t); - private readonly SliderPath path = new SliderPath(); + private readonly SliderPath path = new SliderPath { OptimiseCatmull = true }; public SliderPath Path { diff --git a/osu.Game/Rulesets/Objects/SliderPath.cs b/osu.Game/Rulesets/Objects/SliderPath.cs index 5398d6c45f..e8e769e3fa 100644 --- a/osu.Game/Rulesets/Objects/SliderPath.cs +++ b/osu.Game/Rulesets/Objects/SliderPath.cs @@ -134,6 +134,24 @@ namespace osu.Game.Rulesets.Objects } } + private bool optimiseCatmull; + + /// + /// Whether to optimise Catmull path segments, usually resulting in removing bulbs around stacked knots. + /// + /// + /// This changes the path shape and should therefore not be used. + /// + public bool OptimiseCatmull + { + get => optimiseCatmull; + set + { + optimiseCatmull = value; + invalidate(); + } + } + /// /// Computes the slider path until a given progress that ranges from 0 (beginning of the slider) /// to 1 (end of the slider) and stores the generated path in the given list. @@ -280,7 +298,7 @@ namespace osu.Game.Rulesets.Objects calculatedPath.Add(segmentVertices[0]); else if (segmentVertices.Length > 1) { - List subPath = calculateSubPath(segmentVertices, segmentType, ref optimisedLength); + List subPath = calculateSubPath(segmentVertices, segmentType); // Skip the first vertex if it is the same as the last vertex from the previous segment bool skipFirst = calculatedPath.Count > 0 && subPath.Count > 0 && calculatedPath.Last() == subPath[0]; @@ -300,7 +318,7 @@ namespace osu.Game.Rulesets.Objects } } - private static List calculateSubPath(ReadOnlySpan subControlPoints, PathType type, ref double optimisedLength) + private List calculateSubPath(ReadOnlySpan subControlPoints, PathType type) { switch (type.Type) { @@ -325,6 +343,9 @@ namespace osu.Game.Rulesets.Objects { List subPath = PathApproximator.CatmullToPiecewiseLinear(subControlPoints); + if (!OptimiseCatmull) + return subPath; + // At draw time, osu!stable optimises paths by only keeping piecewise segments that are 6px apart. // For the most part we don't care about this optimisation, and its additional heuristics are hard to reproduce in every implementation. // From 6cb5bffdfc07cbd17abe6bd4ddf01148d975d928 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 10 Apr 2024 13:03:37 +0800 Subject: [PATCH 05/27] Update resources --- osu.Game/osu.Game.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 61ad2a4f5a..3ea756a8b8 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -36,7 +36,7 @@ - + From 3e8ddbd2a9d49173139dd06f709693d0999f456e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 11 Apr 2024 11:33:16 +0800 Subject: [PATCH 06/27] Add new entries to dotsettings (Rider 2024.1) --- osu.sln.DotSettings | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.sln.DotSettings b/osu.sln.DotSettings index 452f90ecea..dd71744bf0 100644 --- a/osu.sln.DotSettings +++ b/osu.sln.DotSettings @@ -774,9 +774,19 @@ See the LICENCE file in the repository root for full licence text. <Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Type parameters"><ElementKinds><Kind Name="TYPE_PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local functions"><ElementKinds><Kind Name="LOCAL_FUNCTION" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Enum members"><ElementKinds><Kind Name="ENUM_MEMBER" /></ElementKinds></Descriptor><Policy Inspect="False" Prefix="" Suffix="" Style="AaBb" /></Policy> <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="private methods"><ElementKinds><Kind Name="ASYNC_METHOD" /><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public" Description="internal/protected/public methods"><ElementKinds><Kind Name="ASYNC_METHOD" /><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="private properties"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> + <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Local constants"><ElementKinds><Kind Name="LOCAL_CONSTANT" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aa_bb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy> <Policy><Descriptor Staticness="Static, Instance" AccessRightKinds="Protected, ProtectedInternal, Internal, Public" Description="internal/protected/public properties"><ElementKinds><Kind Name="PROPERTY" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /> @@ -841,6 +851,7 @@ See the LICENCE file in the repository root for full licence text. True True True + True TestFolder True True From 8b2017be453fb03905bc857bd117c2555cb05e69 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 12 Apr 2024 01:02:40 +0900 Subject: [PATCH 07/27] Update Sentry to fix iOS build --- osu.Game/Utils/SentryLogger.cs | 2 +- osu.Game/osu.Game.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Utils/SentryLogger.cs b/osu.Game/Utils/SentryLogger.cs index 61622a7122..896f4daf33 100644 --- a/osu.Game/Utils/SentryLogger.cs +++ b/osu.Game/Utils/SentryLogger.cs @@ -64,7 +64,7 @@ namespace osu.Game.Utils localUser = user.GetBoundCopy(); localUser.BindValueChanged(u => { - SentrySdk.ConfigureScope(scope => scope.User = new User + SentrySdk.ConfigureScope(scope => scope.User = new SentryUser { Username = u.NewValue.Username, Id = u.NewValue.Id.ToString(), diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3ea756a8b8..21b5bc60a5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -37,7 +37,7 @@ - + From 3ec93745a45127a204b1b25df81784bc1392ac2f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Apr 2024 01:07:52 +0800 Subject: [PATCH 08/27] Fix test failures due to sentry oversight --- osu.Game/Utils/SentryLogger.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/osu.Game/Utils/SentryLogger.cs b/osu.Game/Utils/SentryLogger.cs index 896f4daf33..8d3e5fb834 100644 --- a/osu.Game/Utils/SentryLogger.cs +++ b/osu.Game/Utils/SentryLogger.cs @@ -39,12 +39,13 @@ namespace osu.Game.Utils public SentryLogger(OsuGame game) { this.game = game; + + if (!game.IsDeployedBuild || !game.CreateEndpoints().WebsiteRootUrl.EndsWith(@".ppy.sh", StringComparison.Ordinal)) + return; + sentrySession = SentrySdk.Init(options => { - // Not setting the dsn will completely disable sentry. - if (game.IsDeployedBuild && game.CreateEndpoints().WebsiteRootUrl.EndsWith(@".ppy.sh", StringComparison.Ordinal)) - options.Dsn = "https://ad9f78529cef40ac874afb95a9aca04e@sentry.ppy.sh/2"; - + options.Dsn = "https://ad9f78529cef40ac874afb95a9aca04e@sentry.ppy.sh/2"; options.AutoSessionTracking = true; options.IsEnvironmentUser = false; options.IsGlobalModeEnabled = true; @@ -59,6 +60,9 @@ namespace osu.Game.Utils public void AttachUser(IBindable user) { + if (sentrySession == null) + return; + Debug.Assert(localUser == null); localUser = user.GetBoundCopy(); From c0dce94f1593ef13d3d9bb214d2ef32331da1f07 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 12 Apr 2024 16:24:46 +0800 Subject: [PATCH 09/27] Fix newly placed items in skin editor not getting correct anchor placement --- osu.Game/Overlays/SkinEditor/SkinEditor.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Overlays/SkinEditor/SkinEditor.cs b/osu.Game/Overlays/SkinEditor/SkinEditor.cs index 619eac8f4a..bc929177d1 100644 --- a/osu.Game/Overlays/SkinEditor/SkinEditor.cs +++ b/osu.Game/Overlays/SkinEditor/SkinEditor.cs @@ -454,6 +454,7 @@ namespace osu.Game.Overlays.SkinEditor } SelectedComponents.Add(component); + SkinSelectionHandler.ApplyClosestAnchor(drawableComponent); return true; } @@ -666,8 +667,6 @@ namespace osu.Game.Overlays.SkinEditor SelectedComponents.Clear(); placeComponent(sprite, false); - - SkinSelectionHandler.ApplyClosestAnchor(sprite); }); return Task.CompletedTask; From c7f3a599c98f49e821e5790a436ff508e90ce097 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Sat, 13 Apr 2024 13:17:06 +0900 Subject: [PATCH 10/27] Fix crash when entering multiplayer on macOS --- osu.Desktop/DiscordRichPresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Desktop/DiscordRichPresence.cs b/osu.Desktop/DiscordRichPresence.cs index ed9d4ca2d2..f1c796d0cd 100644 --- a/osu.Desktop/DiscordRichPresence.cs +++ b/osu.Desktop/DiscordRichPresence.cs @@ -205,7 +205,9 @@ namespace osu.Desktop Password = room.Settings.Password, }; - presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); + if (client.HasRegisteredUriScheme) + presence.Secrets.JoinSecret = JsonConvert.SerializeObject(roomSecret); + // discord cannot handle both secrets and buttons at the same time, so we need to choose something. // the multiplayer room seems more important. presence.Buttons = null; From feb9b5bdb8a74e566e35d00ce23e492f129b6f05 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sat, 13 Apr 2024 13:42:57 +0300 Subject: [PATCH 11/27] Make traceable pp match HD --- .../Difficulty/OsuPerformanceCalculator.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index 4771bce280..e7e9308eb5 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -118,8 +118,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty } else if (score.Mods.Any(h => h is OsuModTraceable)) { - // Default 2% increase and another is scaled by AR - aimValue *= 1.02 + 0.02 * (12.0 - attributes.ApproachRate); + // The same as HD, placeholder bonus + aimValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } // We assume 15% of sliders in a map are difficult since there's no way to tell from the performance calculator. @@ -174,8 +174,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty } else if (score.Mods.Any(h => h is OsuModTraceable)) { - // More reward for speed because speed on Traceable is annoying - speedValue *= 1.04 + 0.06 * (12.0 - attributes.ApproachRate); + // The same as HD, placeholder bonus + speedValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } // Calculate accuracy assuming the worst case scenario @@ -225,7 +225,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty else if (score.Mods.Any(m => m is OsuModHidden)) accuracyValue *= 1.08; else if (score.Mods.Any(m => m is OsuModTraceable)) - accuracyValue *= 1.02 + 0.01 * (12.0 - attributes.ApproachRate); + accuracyValue *= 1.08; if (score.Mods.Any(m => m is OsuModFlashlight)) accuracyValue *= 1.02; From 4a21ff97263ac0219905e7a4fc51b8d5e1c55705 Mon Sep 17 00:00:00 2001 From: Givikap120 Date: Sat, 13 Apr 2024 13:59:09 +0300 Subject: [PATCH 12/27] removed duplication --- .../Difficulty/OsuPerformanceCalculator.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index e7e9308eb5..18a4b8be0c 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -111,16 +111,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty if (score.Mods.Any(m => m is OsuModBlinds)) aimValue *= 1.3 + (totalHits * (0.0016 / (1 + 2 * effectiveMissCount)) * Math.Pow(accuracy, 16)) * (1 - 0.003 * attributes.DrainRate * attributes.DrainRate); - else if (score.Mods.Any(h => h is OsuModHidden)) + else if (score.Mods.Any(m => m is OsuModHidden || m is OsuModTraceable)) { // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR. aimValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } - else if (score.Mods.Any(h => h is OsuModTraceable)) - { - // The same as HD, placeholder bonus - aimValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); - } // We assume 15% of sliders in a map are difficult since there's no way to tell from the performance calculator. double estimateDifficultSliders = attributes.SliderCount * 0.15; @@ -167,16 +162,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty // Increasing the speed value by object count for Blinds isn't ideal, so the minimum buff is given. speedValue *= 1.12; } - else if (score.Mods.Any(m => m is OsuModHidden)) + else if (score.Mods.Any(m => m is OsuModHidden || m is OsuModTraceable)) { // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR. speedValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); } - else if (score.Mods.Any(h => h is OsuModTraceable)) - { - // The same as HD, placeholder bonus - speedValue *= 1.0 + 0.04 * (12.0 - attributes.ApproachRate); - } // Calculate accuracy assuming the worst case scenario double relevantTotalDiff = totalHits - attributes.SpeedNoteCount; @@ -222,9 +212,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty // Increasing the accuracy value by object count for Blinds isn't ideal, so the minimum buff is given. if (score.Mods.Any(m => m is OsuModBlinds)) accuracyValue *= 1.14; - else if (score.Mods.Any(m => m is OsuModHidden)) - accuracyValue *= 1.08; - else if (score.Mods.Any(m => m is OsuModTraceable)) + else if (score.Mods.Any(m => m is OsuModHidden || m is OsuModTraceable)) accuracyValue *= 1.08; if (score.Mods.Any(m => m is OsuModFlashlight)) From 5a8b8908dd5ba8064f87d803fb1308340139582a Mon Sep 17 00:00:00 2001 From: Loreos7 Date: Sat, 13 Apr 2024 14:53:51 +0300 Subject: [PATCH 13/27] fix missing underscore --- osu.Game/Screens/Play/SubmittingPlayer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/SubmittingPlayer.cs b/osu.Game/Screens/Play/SubmittingPlayer.cs index 8ccfd039ec..6c5f7fab9e 100644 --- a/osu.Game/Screens/Play/SubmittingPlayer.cs +++ b/osu.Game/Screens/Play/SubmittingPlayer.cs @@ -152,7 +152,7 @@ namespace osu.Game.Screens.Play Logger.Log($"Please ensure that you are using the latest version of the official game releases.\n\n{whatWillHappen}", level: LogLevel.Important); break; - case @"invalid beatmap hash": + case @"invalid beatmap_hash": Logger.Log($"This beatmap does not match the online version. Please update or redownload it.\n\n{whatWillHappen}", level: LogLevel.Important); break; From 9833dd955f8c09ff8455ab499257ac044362414c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vaj=C4=8F=C3=A1k?= Date: Sun, 14 Apr 2024 01:30:59 +0200 Subject: [PATCH 14/27] Fix toolbar volume bar masking --- osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs index 5da0056787..718789e3c7 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs @@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Toolbar { public partial class ToolbarMusicButton : ToolbarOverlayToggleButton { - private Circle volumeBar; + private Box volumeBar; protected override Anchor TooltipAnchor => Anchor.TopRight; @@ -45,14 +45,15 @@ namespace osu.Game.Overlays.Toolbar Height = IconContainer.Height, Margin = new MarginPadding { Horizontal = 2.5f }, Masking = true, - Children = new[] + CornerRadius = 3f, + Children = new Drawable[] { new Circle { RelativeSizeAxes = Axes.Both, Colour = Color4.White.Opacity(0.25f), }, - volumeBar = new Circle + volumeBar = new Box { RelativeSizeAxes = Axes.Both, Height = 0f, From ed6680a61d535849beb78bd26738e55172e2aabc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vaj=C4=8F=C3=A1k?= Date: Sun, 14 Apr 2024 15:10:05 +0200 Subject: [PATCH 15/27] Fixed type inconsistency and rounding --- osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs index 718789e3c7..51b95b7d32 100644 --- a/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs +++ b/osu.Game/Overlays/Toolbar/ToolbarMusicButton.cs @@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Toolbar StateContainer = music; Flow.Padding = new MarginPadding { Horizontal = Toolbar.HEIGHT / 4 }; - Flow.Add(volumeDisplay = new Container + Flow.Add(volumeDisplay = new CircularContainer { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, @@ -45,10 +45,9 @@ namespace osu.Game.Overlays.Toolbar Height = IconContainer.Height, Margin = new MarginPadding { Horizontal = 2.5f }, Masking = true, - CornerRadius = 3f, - Children = new Drawable[] + Children = new[] { - new Circle + new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.White.Opacity(0.25f), From 8506da725dcf0aac225bd6ab5c230fb0150827e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Apr 2024 11:49:47 +0200 Subject: [PATCH 16/27] Add failing test --- .../TestSceneExpandedPanelMiddleContent.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs index 9f7726313a..02a321d22f 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs @@ -104,6 +104,21 @@ namespace osu.Game.Tests.Visual.Ranking }); } + [Test] + public void TestPPNotShownAsProvisionalIfClassicModIsPresentDueToLegacyScore() + { + AddStep("show example score", () => + { + var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser())); + score.PP = 400; + score.Mods = score.Mods.Append(new OsuModClassic()).ToArray(); + score.IsLegacyScore = true; + showPanel(score); + }); + + AddAssert("pp display faded out", () => this.ChildrenOfType().Single().Alpha == 1); + } + [Test] public void TestWithDefaultDate() { From 7c4c8ee75c746620f955f1fbb2b1e43f26badf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 15 Apr 2024 11:53:03 +0200 Subject: [PATCH 17/27] Fix stable scores showing with faded out pp display due to classic mod presence --- .../Expanded/Statistics/PerformanceStatistic.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 0a9c68eafc..8366f8d7ef 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -4,6 +4,7 @@ #nullable disable using System; +using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -17,6 +18,7 @@ using osu.Game.Graphics.UserInterface; using osu.Game.Resources.Localisation.Web; using osu.Game.Scoring; using osu.Game.Localisation; +using osu.Game.Rulesets.Mods; namespace osu.Game.Screens.Ranking.Expanded.Statistics { @@ -74,7 +76,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics Alpha = 0.5f; TooltipText = ResultsScreenStrings.NoPPForUnrankedBeatmaps; } - else if (scoreInfo.Mods.Any(m => !m.Ranked)) + else if (hasUnrankedMods(scoreInfo)) { Alpha = 0.5f; TooltipText = ResultsScreenStrings.NoPPForUnrankedMods; @@ -87,6 +89,16 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics } } + private static bool hasUnrankedMods(ScoreInfo scoreInfo) + { + IEnumerable modsToCheck = scoreInfo.Mods; + + if (scoreInfo.IsLegacyScore) + modsToCheck = modsToCheck.Where(m => m is not ModClassic); + + return modsToCheck.Any(m => !m.Ranked); + } + public override void Appear() { base.Appear(); From fe7df808b6065dcbb405f7775fdaaa0d5a441f52 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 15 Apr 2024 21:07:08 +0900 Subject: [PATCH 18/27] Add tests --- .../SongSelect/TestScenePlaySongSelect.cs | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs index ce241f3676..e03ffd48f1 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestScenePlaySongSelect.cs @@ -29,6 +29,7 @@ using osu.Game.Overlays.Dialog; using osu.Game.Overlays.Mods; using osu.Game.Overlays.Notifications; using osu.Game.Rulesets; +using osu.Game.Rulesets.Mania.Mods; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; @@ -1147,6 +1148,62 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("filter text cleared", () => songSelect!.FilterControl.ChildrenOfType().First().Text, () => Is.Empty); } + [Test] + public void TestNonFilterableModChange() + { + addRulesetImportStep(0); + + createSongSelect(); + + // Mod that is guaranteed to never re-filter. + AddStep("add non-filterable mod", () => SelectedMods.Value = new Mod[] { new OsuModCinema() }); + AddAssert("filter count is 1", () => songSelect!.FilterCount, () => Is.EqualTo(1)); + + // Removing the mod should still not re-filter. + AddStep("remove non-filterable mod", () => SelectedMods.Value = Array.Empty()); + AddAssert("filter count is 1", () => songSelect!.FilterCount, () => Is.EqualTo(1)); + } + + [Test] + public void TestFilterableModChange() + { + addRulesetImportStep(3); + + createSongSelect(); + + // Change to mania ruleset. + AddStep("filter to mania ruleset", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.OnlineID == 3)); + AddAssert("filter count is 2", () => songSelect!.FilterCount, () => Is.EqualTo(2)); + + // Apply a mod, but this should NOT re-filter because there's no search text. + AddStep("add filterable mod", () => SelectedMods.Value = new Mod[] { new ManiaModKey3() }); + AddAssert("filter count is 2", () => songSelect!.FilterCount, () => Is.EqualTo(2)); + + // Set search text. Should re-filter. + AddStep("set search text to match mods", () => songSelect!.FilterControl.CurrentTextSearch.Value = "keys=3"); + AddAssert("filter count is 3", () => songSelect!.FilterCount, () => Is.EqualTo(3)); + + // Change filterable mod. Should re-filter. + AddStep("change new filterable mod", () => SelectedMods.Value = new Mod[] { new ManiaModKey5() }); + AddAssert("filter count is 4", () => songSelect!.FilterCount, () => Is.EqualTo(4)); + + // Add non-filterable mod. Should NOT re-filter. + AddStep("apply non-filterable mod", () => SelectedMods.Value = new Mod[] { new ManiaModNoFail(), new ManiaModKey5() }); + AddAssert("filter count is 4", () => songSelect!.FilterCount, () => Is.EqualTo(4)); + + // Remove filterable mod. Should re-filter. + AddStep("remove filterable mod", () => SelectedMods.Value = new Mod[] { new ManiaModNoFail() }); + AddAssert("filter count is 5", () => songSelect!.FilterCount, () => Is.EqualTo(5)); + + // Remove non-filterable mod. Should NOT re-filter. + AddStep("remove filterable mod", () => SelectedMods.Value = Array.Empty()); + AddAssert("filter count is 5", () => songSelect!.FilterCount, () => Is.EqualTo(5)); + + // Add filterable mod. Should re-filter. + AddStep("add filterable mod", () => SelectedMods.Value = new Mod[] { new ManiaModKey3() }); + AddAssert("filter count is 6", () => songSelect!.FilterCount, () => Is.EqualTo(6)); + } + private void waitForInitialSelection() { AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault); From 343b3ba0e614dcfd68e9f3b6046b7d119776c95e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Mon, 15 Apr 2024 21:07:36 +0900 Subject: [PATCH 19/27] Don't re-filter unless mods may change the filter --- .../ManiaFilterCriteria.cs | 20 +++++++++++++++++++ .../NonVisual/Filtering/FilterMatchingTest.cs | 5 +++++ .../Filtering/FilterQueryParserTest.cs | 5 +++++ .../Rulesets/Filter/IRulesetFilterCriteria.cs | 10 ++++++++++ osu.Game/Screens/Select/FilterControl.cs | 13 ++++++------ 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs index ea7eb5b8f0..8c6efbc72d 100644 --- a/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs +++ b/osu.Game.Rulesets.Mania/ManiaFilterCriteria.cs @@ -1,9 +1,14 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using System.Linq; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets.Filter; using osu.Game.Rulesets.Mania.Beatmaps; +using osu.Game.Rulesets.Mania.Mods; +using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Scoring.Legacy; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Filter; @@ -30,5 +35,20 @@ namespace osu.Game.Rulesets.Mania return false; } + + public bool FilterMayChangeFromMods(ValueChangedEvent> mods) + { + if (keys.HasFilter) + { + // Interpreting as the Mod type is required for equality comparison. + HashSet oldSet = mods.OldValue.OfType().AsEnumerable().ToHashSet(); + HashSet newSet = mods.NewValue.OfType().AsEnumerable().ToHashSet(); + + if (!oldSet.SetEquals(newSet)) + return true; + } + + return false; + } } } diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs index 78d8eabba7..10e0e46f4c 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterMatchingTest.cs @@ -1,10 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; using NUnit.Framework; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Filter; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Carousel; using osu.Game.Screens.Select.Filter; @@ -311,6 +314,8 @@ namespace osu.Game.Tests.NonVisual.Filtering public bool Matches(BeatmapInfo beatmapInfo, FilterCriteria criteria) => match; public bool TryParseCustomKeywordCriteria(string key, Operator op, string value) => false; + + public bool FilterMayChangeFromMods(ValueChangedEvent> mods) => false; } } } diff --git a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs index b0ceed45b9..7897b3d8c0 100644 --- a/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs +++ b/osu.Game.Tests/NonVisual/Filtering/FilterQueryParserTest.cs @@ -2,10 +2,13 @@ // See the LICENCE file in the repository root for full licence text. using System; +using System.Collections.Generic; using System.Linq; using NUnit.Framework; +using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets.Filter; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Carousel; using osu.Game.Screens.Select.Filter; @@ -514,6 +517,8 @@ namespace osu.Game.Tests.NonVisual.Filtering return false; } + + public bool FilterMayChangeFromMods(ValueChangedEvent> mods) => false; } private static readonly object[] correct_date_query_examples = diff --git a/osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs b/osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs index f926b04db4..c374fe315d 100644 --- a/osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs +++ b/osu.Game/Rulesets/Filter/IRulesetFilterCriteria.cs @@ -1,7 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System.Collections.Generic; +using osu.Framework.Bindables; using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mods; using osu.Game.Screens.Select; using osu.Game.Screens.Select.Filter; @@ -52,5 +55,12 @@ namespace osu.Game.Rulesets.Filter /// while ignored criteria are included in . /// bool TryParseCustomKeywordCriteria(string key, Operator op, string value); + + /// + /// Whether to reapply the filter as a result of the given change in applied mods. + /// + /// The change in mods. + /// Whether the filter should be re-applied. + bool FilterMayChangeFromMods(ValueChangedEvent> mods); } } diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 0bfd927234..73c122dda6 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -49,15 +50,14 @@ namespace osu.Game.Screens.Select } private OsuTabControl sortTabs; - private Bindable sortMode; - private Bindable groupMode; - private FilterControlTextBox searchTextBox; - private CollectionDropdown collectionDropdown; + [CanBeNull] + private FilterCriteria currentCriteria; + public FilterCriteria CreateCriteria() { string query = searchTextBox.Text; @@ -228,7 +228,8 @@ namespace osu.Game.Screens.Select if (m.NewValue.SequenceEqual(m.OldValue)) return; - updateCriteria(); + if (currentCriteria?.RulesetCriteria?.FilterMayChangeFromMods(m) == true) + updateCriteria(); }); groupMode.BindValueChanged(_ => updateCriteria()); @@ -263,7 +264,7 @@ namespace osu.Game.Screens.Select private readonly Bindable minimumStars = new BindableDouble(); private readonly Bindable maximumStars = new BindableDouble(); - private void updateCriteria() => FilterChanged?.Invoke(CreateCriteria()); + private void updateCriteria() => FilterChanged?.Invoke(currentCriteria = CreateCriteria()); protected override bool OnClick(ClickEvent e) => true; From 7e4782d4b1aeec427ea41d3a5d3bfe5d25a2f1f4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Apr 2024 09:50:51 +0800 Subject: [PATCH 20/27] Allow nested high performance sessions Mostly just for safety, since I noticed this would pretty much fall over in this scenario until now. --- .../HighPerformanceSessionManager.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/osu.Desktop/Performance/HighPerformanceSessionManager.cs b/osu.Desktop/Performance/HighPerformanceSessionManager.cs index eb2b3be5b9..058d247aee 100644 --- a/osu.Desktop/Performance/HighPerformanceSessionManager.cs +++ b/osu.Desktop/Performance/HighPerformanceSessionManager.cs @@ -11,16 +11,24 @@ namespace osu.Desktop.Performance { public class HighPerformanceSessionManager : IHighPerformanceSessionManager { + private int activeSessions; + private GCLatencyMode originalGCMode; public IDisposable BeginSession() { - enableHighPerformanceSession(); - return new InvokeOnDisposal(this, static m => m.disableHighPerformanceSession()); + enterSession(); + return new InvokeOnDisposal(this, static m => m.exitSession()); } - private void enableHighPerformanceSession() + private void enterSession() { + if (Interlocked.Increment(ref activeSessions) > 1) + { + Logger.Log($"High performance session requested ({activeSessions} others already running)"); + return; + } + Logger.Log("Starting high performance session"); originalGCMode = GCSettings.LatencyMode; @@ -30,8 +38,14 @@ namespace osu.Desktop.Performance GC.Collect(0); } - private void disableHighPerformanceSession() + private void exitSession() { + if (Interlocked.Decrement(ref activeSessions) > 0) + { + Logger.Log($"High performance session finished ({activeSessions} others remain)"); + return; + } + Logger.Log("Ending high performance session"); if (GCSettings.LatencyMode == GCLatencyMode.LowLatency) From d89edd2b4f52fe776c77a66a414c1dcd2472bede Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Apr 2024 09:51:43 +0800 Subject: [PATCH 21/27] Expose high performance session state --- osu.Desktop/Performance/HighPerformanceSessionManager.cs | 3 +++ osu.Game/Performance/IHighPerformanceSessionManager.cs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/osu.Desktop/Performance/HighPerformanceSessionManager.cs b/osu.Desktop/Performance/HighPerformanceSessionManager.cs index 058d247aee..34762de04d 100644 --- a/osu.Desktop/Performance/HighPerformanceSessionManager.cs +++ b/osu.Desktop/Performance/HighPerformanceSessionManager.cs @@ -3,6 +3,7 @@ using System; using System.Runtime; +using System.Threading; using osu.Framework.Allocation; using osu.Framework.Logging; using osu.Game.Performance; @@ -11,6 +12,8 @@ namespace osu.Desktop.Performance { public class HighPerformanceSessionManager : IHighPerformanceSessionManager { + public bool IsSessionActive => activeSessions > 0; + private int activeSessions; private GCLatencyMode originalGCMode; diff --git a/osu.Game/Performance/IHighPerformanceSessionManager.cs b/osu.Game/Performance/IHighPerformanceSessionManager.cs index d3d1fda8fc..cc995e4942 100644 --- a/osu.Game/Performance/IHighPerformanceSessionManager.cs +++ b/osu.Game/Performance/IHighPerformanceSessionManager.cs @@ -14,6 +14,11 @@ namespace osu.Game.Performance /// public interface IHighPerformanceSessionManager { + /// + /// Whether a high performance session is currently active. + /// + bool IsSessionActive { get; } + /// /// Start a new high performance session. /// From a651cb8d507c8720a83db85acef9738107046461 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Apr 2024 09:51:58 +0800 Subject: [PATCH 22/27] Stop background processing from running when inside a high performance session --- osu.Game/Database/BackgroundDataStoreProcessor.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osu.Game/Database/BackgroundDataStoreProcessor.cs b/osu.Game/Database/BackgroundDataStoreProcessor.cs index 872194aa1d..f3b37f608c 100644 --- a/osu.Game/Database/BackgroundDataStoreProcessor.cs +++ b/osu.Game/Database/BackgroundDataStoreProcessor.cs @@ -16,6 +16,7 @@ using osu.Game.Extensions; using osu.Game.Online.API; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; +using osu.Game.Performance; using osu.Game.Rulesets; using osu.Game.Scoring; using osu.Game.Scoring.Legacy; @@ -51,6 +52,9 @@ namespace osu.Game.Database [Resolved] private ILocalUserPlayInfo? localUserPlayInfo { get; set; } + [Resolved] + private IHighPerformanceSessionManager? highPerformanceSessionManager { get; set; } + [Resolved] private INotificationOverlay? notificationOverlay { get; set; } @@ -493,7 +497,9 @@ namespace osu.Game.Database private void sleepIfRequired() { - while (localUserPlayInfo?.IsPlaying.Value == true) + // Importantly, also sleep if high performance session is active. + // If we don't do this, memory usage can become runaway due to GC running in a more lenient mode. + while (localUserPlayInfo?.IsPlaying.Value == true || highPerformanceSessionManager?.IsSessionActive == true) { Logger.Log("Background processing sleeping due to active gameplay..."); Thread.Sleep(TimeToSleepDuringGameplay); From 926424d8ea68b1b3eb7439faaff64e5e9afc8d5e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 16 Apr 2024 16:37:11 +0800 Subject: [PATCH 23/27] Update HighPerformanceSessionManager.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Desktop/Performance/HighPerformanceSessionManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Desktop/Performance/HighPerformanceSessionManager.cs b/osu.Desktop/Performance/HighPerformanceSessionManager.cs index 34762de04d..0df87ab007 100644 --- a/osu.Desktop/Performance/HighPerformanceSessionManager.cs +++ b/osu.Desktop/Performance/HighPerformanceSessionManager.cs @@ -28,7 +28,7 @@ namespace osu.Desktop.Performance { if (Interlocked.Increment(ref activeSessions) > 1) { - Logger.Log($"High performance session requested ({activeSessions} others already running)"); + Logger.Log($"High performance session requested ({activeSessions} running in total)"); return; } From c4bf03e6400d5047d2ebf916a7bd532334fff19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 16 Apr 2024 12:42:12 +0200 Subject: [PATCH 24/27] Add failing test --- .../TestSceneResume.cs | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs new file mode 100644 index 0000000000..023016c32d --- /dev/null +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneResume.cs @@ -0,0 +1,69 @@ +// 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 NUnit.Framework; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Game.Screens.Play; +using osu.Game.Tests.Visual; +using osuTK; +using osuTK.Input; + +namespace osu.Game.Rulesets.Osu.Tests +{ + public partial class TestSceneResume : PlayerTestScene + { + protected override Ruleset CreatePlayerRuleset() => new OsuRuleset(); + + protected override TestPlayer CreatePlayer(Ruleset ruleset) => new TestPlayer(true, false, AllowBackwardsSeeks); + + [Test] + public void TestPauseViaKeyboard() + { + AddStep("move mouse to center", () => InputManager.MoveMouseTo(Player.ScreenSpaceDrawQuad.Centre)); + AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value); + AddStep("press escape", () => InputManager.PressKey(Key.Escape)); + AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Visible)); + AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape)); + AddStep("resume", () => + { + InputManager.Key(Key.Down); + InputManager.Key(Key.Space); + }); + AddUntilStep("pause overlay present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Visible)); + } + + [Test] + public void TestPauseViaKeyboardWhenMouseOutsidePlayfield() + { + AddStep("move mouse outside playfield", () => InputManager.MoveMouseTo(Player.DrawableRuleset.Playfield.ScreenSpaceDrawQuad.BottomRight + new Vector2(1))); + AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value); + AddStep("press escape", () => InputManager.PressKey(Key.Escape)); + AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Visible)); + AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape)); + AddStep("resume", () => + { + InputManager.Key(Key.Down); + InputManager.Key(Key.Space); + }); + AddUntilStep("pause overlay present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Visible)); + } + + [Test] + public void TestPauseViaKeyboardWhenMouseOutsideScreen() + { + AddStep("move mouse outside playfield", () => InputManager.MoveMouseTo(new Vector2(-20))); + AddUntilStep("wait for gameplay start", () => Player.LocalUserPlaying.Value); + AddStep("press escape", () => InputManager.PressKey(Key.Escape)); + AddUntilStep("wait for pause overlay", () => Player.ChildrenOfType().Single().State.Value, () => Is.EqualTo(Visibility.Visible)); + AddStep("release escape", () => InputManager.ReleaseKey(Key.Escape)); + AddStep("resume", () => + { + InputManager.Key(Key.Down); + InputManager.Key(Key.Space); + }); + AddUntilStep("pause overlay not present", () => Player.DrawableRuleset.ResumeOverlay.State.Value, () => Is.EqualTo(Visibility.Hidden)); + } + } +} From f9873968a5f06fa355b074f834fad8e9579a3ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 16 Apr 2024 13:37:12 +0200 Subject: [PATCH 25/27] Apply NRT in `OsuResumeOverlay` --- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index adc7bd97ff..19d8a94f0a 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Allocation; using osu.Framework.Graphics; @@ -19,12 +17,12 @@ namespace osu.Game.Rulesets.Osu.UI { public partial class OsuResumeOverlay : ResumeOverlay { - private Container cursorScaleContainer; - private OsuClickToResumeCursor clickToResumeCursor; + private Container cursorScaleContainer = null!; + private OsuClickToResumeCursor clickToResumeCursor = null!; - private OsuCursorContainer localCursorContainer; + private OsuCursorContainer? localCursorContainer; - public override CursorContainer LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; + public override CursorContainer? LocalCursor => State.Value == Visibility.Visible ? localCursorContainer : null; protected override LocalisableString Message => "Click the orange cursor to resume"; @@ -71,8 +69,8 @@ namespace osu.Game.Rulesets.Osu.UI { public override bool HandlePositionalInput => true; - public Action ResumeRequested; - private Container scaleTransitionContainer; + public Action? ResumeRequested; + private Container scaleTransitionContainer = null!; public OsuClickToResumeCursor() { From e5e345712efea6467ae895219cad53a461403672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 16 Apr 2024 13:24:30 +0200 Subject: [PATCH 26/27] Fix resume overlay not appearing after pausing inside window but outside of actual playfield area Related to https://github.com/ppy/osu/discussions/27871 (although does not actually fix the issue with the pause button, _if_ it is to be considered an issue - the problem there is that the gameplay cursor gets hidden, so the other condition in the modified check takes over). Regressed in https://github.com/ppy/osu/commit/bce3bd55e5a863e52f41598c306a248a79638843. Reasoning for breakage is silent change in `this` when moving the `Contains()` check (`DrawableRuleset` will encompass screen bounds, while `OsuResumeOverlay` is only as big as the actual playfield). --- osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs index 19d8a94f0a..a04ea80640 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuResumeOverlay.cs @@ -10,6 +10,7 @@ using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Framework.Localisation; using osu.Game.Rulesets.Osu.UI.Cursor; +using osu.Game.Rulesets.UI; using osu.Game.Screens.Play; using osuTK.Graphics; @@ -26,6 +27,9 @@ namespace osu.Game.Rulesets.Osu.UI protected override LocalisableString Message => "Click the orange cursor to resume"; + [Resolved] + private DrawableRuleset? drawableRuleset { get; set; } + [BackgroundDependencyLoader] private void load() { @@ -38,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.UI protected override void PopIn() { // Can't display if the cursor is outside the window. - if (GameplayCursor.LastFrameState == Visibility.Hidden || !Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre)) + if (GameplayCursor.LastFrameState == Visibility.Hidden || drawableRuleset?.Contains(GameplayCursor.ActiveCursor.ScreenSpaceDrawQuad.Centre) == false) { Resume(); return; From 6c943681b0518848b5ace9755835e16996c505aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 16 Apr 2024 16:07:56 +0200 Subject: [PATCH 27/27] Fix preview tracks playing after their owning overlay has hidden RFC. Closes https://github.com/ppy/osu/issues/27883. The idea here is that `PopOut()` is called _when the hide is requested_, so once an overlay trigger would hide, the overlay would `StopAnyPlaying()`, but because of async load things, the actual track would start playing after that but before the overlay has fully hidden. (That last part is significant because after the overlay has fully hidden, schedules save the day.) Due to the loose coupling between `PreviewTrackManager` and `IPreviewTrackOwner` there's really no easy way to handle this locally to the usages of the preview tracks. Heck, `PreviewTrackManager` doesn't really know which preview track owner is to be considered _present_ at any time, it just kinda works on vibes based on DI until the owner tells all of its preview tracks to stop. This solution causes the preview tracks to stop a little bit later but maybe that's fine? Just trying to not overthink the issue is all. No tests because this is going to suck to test automatically while it is pretty easy to test manually (got it in a few tries on master). The issue also mentions that the track can sometimes resume playing after the overlay is pulled up again, but I don't see that as a problem necessarily, and even if it was, it's not going to be that easy to address due to the aforementioned loose coupling - to fix that, play buttons would have to know who is the current preview track owner and cancel schedules upon determining that their preview track owner has gone away. --- osu.Game/Overlays/WaveOverlayContainer.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/WaveOverlayContainer.cs b/osu.Game/Overlays/WaveOverlayContainer.cs index 0295ff467a..7744db5dd5 100644 --- a/osu.Game/Overlays/WaveOverlayContainer.cs +++ b/osu.Game/Overlays/WaveOverlayContainer.cs @@ -40,10 +40,12 @@ namespace osu.Game.Overlays protected override void PopOut() { - base.PopOut(); - Waves.Hide(); - this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InQuint); + this.FadeOut(WaveContainer.DISAPPEAR_DURATION, Easing.InQuint) + // base call is responsible for stopping preview tracks. + // delay it until the fade has concluded to ensure that nothing inside the overlay has triggered + // another preview track playback in the meantime, leaving an "orphaned" preview playing. + .OnComplete(_ => base.PopOut()); } } }