From 4d743f64f52ec3ce7123ccab545f5e1445b69db1 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 23 Sep 2020 21:15:41 +0200 Subject: [PATCH 01/73] Add a method to calculate asynchronously performance on a beatmap. --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index e9d26683c3..d9fb6ccd81 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -16,6 +16,7 @@ using osu.Framework.Lists; using osu.Framework.Threading; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; +using osu.Game.Scoring; namespace osu.Game.Beatmaps { @@ -114,6 +115,28 @@ namespace osu.Game.Beatmaps return computeDifficulty(key, beatmapInfo, rulesetInfo); } + /// + /// Calculates performance for the given on a given . + /// + /// The to do the calculation on. + /// The score to do the calculation on. + /// An optional to cancel the operation. + /// + public async Task CalculateScorePerformance([NotNull] WorkingBeatmap beatmap, [NotNull] ScoreInfo score, CancellationToken token = default) + { + return await Task.Factory.StartNew(() => + { + if (token.IsCancellationRequested) + return default; + + var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); + var total = calculator.Calculate(null); + + return total; + + }, token, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler); + } + private CancellationTokenSource trackedUpdateCancellationSource; private readonly List linkedCancellationSources = new List(); From 77a9d92f4221a21b75e597696a796244e2c899c8 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 25 Sep 2020 19:15:40 +0200 Subject: [PATCH 02/73] Add dynamic pp calculation to score panels for local scores --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 1 - .../Expanded/ExpandedPanelMiddleContent.cs | 2 +- .../Statistics/PerformanceStatistic.cs | 76 +++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index d9fb6ccd81..280e1f5a67 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -133,7 +133,6 @@ namespace osu.Game.Beatmaps var total = calculator.Calculate(null); return total; - }, token, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler); } diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index 0033cd1f43..88c61ce267 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -61,7 +61,7 @@ namespace osu.Game.Screens.Ranking.Expanded { new AccuracyStatistic(score.Accuracy), new ComboStatistic(score.MaxCombo, !score.Statistics.TryGetValue(HitResult.Miss, out var missCount) || missCount == 0), - new CounterStatistic("pp", (int)(score.PP ?? 0)), + new PerformanceStatistic(score), }; var bottomStatistics = new List(); diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs new file mode 100644 index 0000000000..e92e3df2dc --- /dev/null +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -0,0 +1,76 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Threading; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Beatmaps; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Scoring; +using osu.Game.Screens.Ranking.Expanded.Accuracy; +using osuTK; + +namespace osu.Game.Screens.Ranking.Expanded.Statistics +{ + public class PerformanceStatistic : StatisticDisplay + { + private readonly ScoreInfo score; + + private readonly Bindable performance = new Bindable(); + + private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + + private RollingCounter counter; + + public PerformanceStatistic(ScoreInfo score) + : base("PP") + { + this.score = score; + } + + [BackgroundDependencyLoader] + private void load(BeatmapManager beatmapManager, BeatmapDifficultyManager difficultyManager) + { + if (score.PP.HasValue) + { + performance.Value = (int)score.PP.Value; + } + else + { + var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); + difficultyManager.CalculateScorePerformance(beatmap, score, cancellationTokenSource.Token) + .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); + } + } + + public override void Appear() + { + base.Appear(); + counter.Current.BindTo(performance); + } + + protected override Drawable CreateContent() => counter = new Counter(); + + private class Counter : RollingCounter + { + protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION; + + protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING; + + protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s => + { + s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true); + s.Spacing = new Vector2(-2, 0); + }); + } + + protected override void Dispose(bool isDisposing) + { + cancellationTokenSource.Cancel(); + base.Dispose(isDisposing); + } + } +} From 4d94bf3163e76240ade710e775f54da14b6e62a5 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 25 Sep 2020 19:16:33 +0200 Subject: [PATCH 03/73] Rename CalculateScorePerformance -> CalculatePerformance --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 2 +- .../Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index 280e1f5a67..73834a137f 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -122,7 +122,7 @@ namespace osu.Game.Beatmaps /// The score to do the calculation on. /// An optional to cancel the operation. /// - public async Task CalculateScorePerformance([NotNull] WorkingBeatmap beatmap, [NotNull] ScoreInfo score, CancellationToken token = default) + public async Task CalculatePerformance([NotNull] WorkingBeatmap beatmap, [NotNull] ScoreInfo score, CancellationToken token = default) { return await Task.Factory.StartNew(() => { diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index e92e3df2dc..11edab6636 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -41,7 +41,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics else { var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); - difficultyManager.CalculateScorePerformance(beatmap, score, cancellationTokenSource.Token) + difficultyManager.CalculatePerformance(beatmap, score, cancellationTokenSource.Token) .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); } } From c5cf0d0410e57ffd63f105d4467ba9b4c05df1b1 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 26 Sep 2020 21:50:39 +0200 Subject: [PATCH 04/73] Fix tests failing. --- .../Visual/Background/TestSceneUserDimBackgrounds.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 19294d12fc..ce73e9061b 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -194,7 +194,8 @@ namespace osu.Game.Tests.Visual.Background AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" }, - Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo + Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, + Ruleset = new OsuRuleset().RulesetInfo, }))); AddUntilStep("Wait for results is current", () => results.IsCurrentScreen()); From 84cc6068f5819a86c57e17dbdf4dc8e9270e8db4 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 27 Sep 2020 09:25:01 +0200 Subject: [PATCH 05/73] Remove unnecessary XMLDoc comment and remove unecessary implicit null parm --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index 73834a137f..1acc4b290f 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -121,7 +121,6 @@ namespace osu.Game.Beatmaps /// The to do the calculation on. /// The score to do the calculation on. /// An optional to cancel the operation. - /// public async Task CalculatePerformance([NotNull] WorkingBeatmap beatmap, [NotNull] ScoreInfo score, CancellationToken token = default) { return await Task.Factory.StartNew(() => @@ -130,7 +129,7 @@ namespace osu.Game.Beatmaps return default; var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); - var total = calculator.Calculate(null); + var total = calculator.Calculate(); return total; }, token, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler); From 3cb9103fe094fdfe5845a877e9bd3bf4307f4dd2 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 27 Sep 2020 09:37:57 +0200 Subject: [PATCH 06/73] Inherit PerformanceStatistic from CounterStatistic --- .../Expanded/Statistics/CounterStatistic.cs | 8 ++--- .../Statistics/PerformanceStatistic.cs | 29 ++----------------- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs index e820831809..1f8deb4d59 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { private readonly int count; - private RollingCounter counter; + protected RollingCounter Counter; /// /// Creates a new . @@ -33,12 +33,12 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics public override void Appear() { base.Appear(); - counter.Current.Value = count; + Counter.Current.Value = count; } - protected override Drawable CreateContent() => counter = new Counter(); + protected override Drawable CreateContent() => Counter = new StatisticCounter(); - private class Counter : RollingCounter + private class StatisticCounter : RollingCounter { protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION; diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 11edab6636..b84d0b7ff7 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -4,18 +4,12 @@ using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Scoring; -using osu.Game.Screens.Ranking.Expanded.Accuracy; -using osuTK; namespace osu.Game.Screens.Ranking.Expanded.Statistics { - public class PerformanceStatistic : StatisticDisplay + public class PerformanceStatistic : CounterStatistic { private readonly ScoreInfo score; @@ -23,10 +17,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); - private RollingCounter counter; - public PerformanceStatistic(ScoreInfo score) - : base("PP") + : base("PP", 0) { this.score = score; } @@ -49,22 +41,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics public override void Appear() { base.Appear(); - counter.Current.BindTo(performance); - } - - protected override Drawable CreateContent() => counter = new Counter(); - - private class Counter : RollingCounter - { - protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION; - - protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING; - - protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s => - { - s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true); - s.Spacing = new Vector2(-2, 0); - }); + Counter.Current.BindTo(performance); } protected override void Dispose(bool isDisposing) From ddede857043f8a7a189cd69dcffde9503bccdf88 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 27 Sep 2020 12:44:29 +0200 Subject: [PATCH 07/73] Split performance calculation to its own class. --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 21 ---------- osu.Game/OsuGameBase.cs | 5 +++ osu.Game/Scoring/ScorePerformanceManager.cs | 39 +++++++++++++++++++ .../Statistics/PerformanceStatistic.cs | 8 ++-- 4 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 osu.Game/Scoring/ScorePerformanceManager.cs diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index 1acc4b290f..e9d26683c3 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -16,7 +16,6 @@ using osu.Framework.Lists; using osu.Framework.Threading; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; -using osu.Game.Scoring; namespace osu.Game.Beatmaps { @@ -115,26 +114,6 @@ namespace osu.Game.Beatmaps return computeDifficulty(key, beatmapInfo, rulesetInfo); } - /// - /// Calculates performance for the given on a given . - /// - /// The to do the calculation on. - /// The score to do the calculation on. - /// An optional to cancel the operation. - public async Task CalculatePerformance([NotNull] WorkingBeatmap beatmap, [NotNull] ScoreInfo score, CancellationToken token = default) - { - return await Task.Factory.StartNew(() => - { - if (token.IsCancellationRequested) - return default; - - var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); - var total = calculator.Calculate(); - - return total; - }, token, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler); - } - private CancellationTokenSource trackedUpdateCancellationSource; private readonly List linkedCancellationSources = new List(); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index b1269e9300..9a4710d576 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -58,6 +58,8 @@ namespace osu.Game protected ScoreManager ScoreManager; + protected ScorePerformanceManager ScorePerformanceManager; + protected BeatmapDifficultyManager DifficultyManager; protected SkinManager SkinManager; @@ -226,6 +228,9 @@ namespace osu.Game dependencies.Cache(DifficultyManager = new BeatmapDifficultyManager()); AddInternal(DifficultyManager); + dependencies.Cache(ScorePerformanceManager = new ScorePerformanceManager()); + AddInternal(ScorePerformanceManager); + dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs new file mode 100644 index 0000000000..c8fec3b40c --- /dev/null +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -0,0 +1,39 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Threading; +using System.Threading.Tasks; +using JetBrains.Annotations; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Game.Beatmaps; + +namespace osu.Game.Scoring +{ + public class ScorePerformanceManager : Component + { + [Resolved] + private BeatmapManager beatmapManager { get; set; } + + /// + /// Calculates performance for the given . + /// + /// The score to do the calculation on. + /// An optional to cancel the operation. + public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) + { + return await Task.Factory.StartNew(() => + { + if (token.IsCancellationRequested) + return default; + + var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); + + var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); + var total = calculator.Calculate(); + + return total; + }, token); + } + } +} diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index b84d0b7ff7..e014258fd4 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -4,7 +4,6 @@ using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; -using osu.Game.Beatmaps; using osu.Game.Scoring; namespace osu.Game.Screens.Ranking.Expanded.Statistics @@ -24,7 +23,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics } [BackgroundDependencyLoader] - private void load(BeatmapManager beatmapManager, BeatmapDifficultyManager difficultyManager) + private void load(ScorePerformanceManager performanceManager) { if (score.PP.HasValue) { @@ -32,9 +31,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics } else { - var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); - difficultyManager.CalculatePerformance(beatmap, score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); + performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) + .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); } } From 6efc4c42505bbfd373a196a8639b5954869335fc Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 28 Sep 2020 19:04:39 +0200 Subject: [PATCH 08/73] Cache performance calculations to prevent recomputations. --- osu.Game/Scoring/ScorePerformanceManager.cs | 78 ++++++++++++++++--- .../Statistics/PerformanceStatistic.cs | 11 +-- 2 files changed, 71 insertions(+), 18 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index c8fec3b40c..0a57ccbd1f 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -1,17 +1,22 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; +using System.Collections.Concurrent; using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Beatmaps; +using osu.Game.Rulesets.Mods; namespace osu.Game.Scoring { public class ScorePerformanceManager : Component { + private readonly ConcurrentDictionary performanceCache = new ConcurrentDictionary(); + [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -22,18 +27,73 @@ namespace osu.Game.Scoring /// An optional to cancel the operation. public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) { + if (score.PP.HasValue) + return score.PP.Value; + + if (tryGetExisting(score, out var perf, out var lookupKey)) + return perf; + return await Task.Factory.StartNew(() => { - if (token.IsCancellationRequested) - return default; - - var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); - - var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); - var total = calculator.Calculate(); - - return total; + return computePerformance(score, lookupKey, token); }, token); } + + private bool tryGetExisting(ScoreInfo score, out double performance, out PerformanceCacheLookup lookupKey) + { + lookupKey = new PerformanceCacheLookup(score); + + return performanceCache.TryGetValue(lookupKey, out performance); + } + + private double computePerformance(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) + { + var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); + + if (token.IsCancellationRequested) + return default; + + var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); + var total = calculator.Calculate(); + + performanceCache[lookupKey] = total; + + return total; + } + + public readonly struct PerformanceCacheLookup + { + public readonly double Accuracy; + public readonly int BeatmapId; + public readonly long TotalScore; + public readonly int Combo; + public readonly Mod[] Mods; + public readonly int RulesetId; + + public PerformanceCacheLookup(ScoreInfo info) + { + Accuracy = info.Accuracy; + BeatmapId = info.Beatmap.ID; + TotalScore = info.TotalScore; + Combo = info.Combo; + Mods = info.Mods; + RulesetId = info.Ruleset.ID.Value; + } + + public override int GetHashCode() + { + var hash = new HashCode(); + + hash.Add(Accuracy); + hash.Add(BeatmapId); + hash.Add(TotalScore); + hash.Add(Combo); + hash.Add(RulesetId); + foreach (var mod in Mods) + hash.Add(mod); + + return hash.ToHashCode(); + } + } } } diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index e014258fd4..6c2ad5844b 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -25,15 +25,8 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics [BackgroundDependencyLoader] private void load(ScorePerformanceManager performanceManager) { - if (score.PP.HasValue) - { - performance.Value = (int)score.PP.Value; - } - else - { - performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); - } + performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) + .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); } public override void Appear() From 35f7de2084ada88bbe7c25de3e36d4e4266c521c Mon Sep 17 00:00:00 2001 From: Lucas A Date: Mon, 28 Sep 2020 19:05:22 +0200 Subject: [PATCH 09/73] Apply review suggestions. --- osu.Game/Scoring/ScorePerformanceManager.cs | 3 --- .../Ranking/Expanded/Statistics/CounterStatistic.cs | 2 +- .../Expanded/Statistics/PerformanceStatistic.cs | 13 ++++++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 0a57ccbd1f..a27e38fb07 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -27,9 +27,6 @@ namespace osu.Game.Scoring /// An optional to cancel the operation. public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) { - if (score.PP.HasValue) - return score.PP.Value; - if (tryGetExisting(score, out var perf, out var lookupKey)) return perf; diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs index 1f8deb4d59..368075b13b 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs @@ -17,7 +17,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { private readonly int count; - protected RollingCounter Counter; + protected RollingCounter Counter { get; private set; } /// /// Creates a new . diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 6c2ad5844b..7e342a33f1 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -25,8 +25,15 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics [BackgroundDependencyLoader] private void load(ScorePerformanceManager performanceManager) { - performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); + if (score.PP.HasValue) + { + performance.Value = (int)score.PP.Value; + } + else + { + performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) + .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); + } } public override void Appear() @@ -37,7 +44,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics protected override void Dispose(bool isDisposing) { - cancellationTokenSource.Cancel(); + cancellationTokenSource?.Cancel(); base.Dispose(isDisposing); } } From 2766cf73b492ea751723b387399a40c4b6e20bc3 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 29 Sep 2020 18:32:02 +0200 Subject: [PATCH 10/73] Reuse BeatmapDifficultyManager cache for beatmap difficulty attributes. --- osu.Game.Rulesets.Catch/CatchRuleset.cs | 2 +- .../Difficulty/CatchPerformanceCalculator.cs | 4 ++-- .../Difficulty/ManiaPerformanceCalculator.cs | 4 ++-- osu.Game.Rulesets.Mania/ManiaRuleset.cs | 2 +- .../Difficulty/OsuPerformanceCalculator.cs | 4 ++-- osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- .../Difficulty/TaikoPerformanceCalculator.cs | 4 ++-- osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 2 +- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 9 ++++++--- .../Rulesets/Difficulty/PerformanceCalculator.cs | 4 ++-- osu.Game/Rulesets/Ruleset.cs | 2 +- osu.Game/Scoring/ScorePerformanceManager.cs | 15 ++++++++------- 12 files changed, 29 insertions(+), 25 deletions(-) diff --git a/osu.Game.Rulesets.Catch/CatchRuleset.cs b/osu.Game.Rulesets.Catch/CatchRuleset.cs index ca75a816f1..1a9a79f6ff 100644 --- a/osu.Game.Rulesets.Catch/CatchRuleset.cs +++ b/osu.Game.Rulesets.Catch/CatchRuleset.cs @@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Catch public override ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => new CatchLegacySkinTransformer(source); - public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new CatchPerformanceCalculator(this, beatmap, score); + public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) => new CatchPerformanceCalculator(this, beatmap, score); public int LegacyID => 2; diff --git a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs index d700f79e5b..33c807333f 100644 --- a/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceCalculator.cs @@ -25,8 +25,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty private int tinyTicksMissed; private int misses; - public CatchPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score) - : base(ruleset, beatmap, score) + public CatchPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) + : base(ruleset, beatmap, score, attributes) { } diff --git a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs index 91383c5548..5a32509b8d 100644 --- a/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Mania/Difficulty/ManiaPerformanceCalculator.cs @@ -29,8 +29,8 @@ namespace osu.Game.Rulesets.Mania.Difficulty private int countMeh; private int countMiss; - public ManiaPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score) - : base(ruleset, beatmap, score) + public ManiaPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes) + : base(ruleset, beatmap, score, attributes) { } diff --git a/osu.Game.Rulesets.Mania/ManiaRuleset.cs b/osu.Game.Rulesets.Mania/ManiaRuleset.cs index 71ac85dd1b..93390c1f0a 100644 --- a/osu.Game.Rulesets.Mania/ManiaRuleset.cs +++ b/osu.Game.Rulesets.Mania/ManiaRuleset.cs @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Mania public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this); - public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score); + public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) => new ManiaPerformanceCalculator(this, beatmap, score, attributes); public const string SHORT_NAME = "mania"; diff --git a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs index 6f4c0f9cfa..e3faa55d9e 100644 --- a/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Osu/Difficulty/OsuPerformanceCalculator.cs @@ -31,8 +31,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty private int countMeh; private int countMiss; - public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score) - : base(ruleset, beatmap, score) + public OsuPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes) + : base(ruleset, beatmap, score, attributes) { countHitCircles = Beatmap.HitObjects.Count(h => h is HitCircle); diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 7f4a0dcbbb..452491361a 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -171,7 +171,7 @@ namespace osu.Game.Rulesets.Osu public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new OsuDifficultyCalculator(this, beatmap); - public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new OsuPerformanceCalculator(this, beatmap, score); + public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) => new OsuPerformanceCalculator(this, beatmap, score, attributes); public override HitObjectComposer CreateHitObjectComposer() => new OsuHitObjectComposer(this); diff --git a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs index b9d95a6ba6..26840d72f1 100644 --- a/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs +++ b/osu.Game.Rulesets.Taiko/Difficulty/TaikoPerformanceCalculator.cs @@ -24,8 +24,8 @@ namespace osu.Game.Rulesets.Taiko.Difficulty private int countMeh; private int countMiss; - public TaikoPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score) - : base(ruleset, beatmap, score) + public TaikoPerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) + : base(ruleset, beatmap, score, attributes) { } diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 9d485e3f20..093084805d 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -153,7 +153,7 @@ namespace osu.Game.Rulesets.Taiko public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new TaikoDifficultyCalculator(this, beatmap); - public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new TaikoPerformanceCalculator(this, beatmap, score); + public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) => new TaikoPerformanceCalculator(this, beatmap, score, attributes); public int LegacyID => 1; diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index e9d26683c3..ee85908aa2 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -15,6 +15,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Lists; using osu.Framework.Threading; using osu.Game.Rulesets; +using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Mods; namespace osu.Game.Beatmaps @@ -207,7 +208,7 @@ namespace osu.Game.Beatmaps var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo)); var attributes = calculator.Calculate(key.Mods); - return difficultyCache[key] = new StarDifficulty(attributes.StarRating, attributes.MaxCombo); + return difficultyCache[key] = new StarDifficulty(attributes.StarRating, attributes.MaxCombo, attributes); } catch { @@ -300,11 +301,13 @@ namespace osu.Game.Beatmaps public readonly double Stars; public readonly int MaxCombo; - public StarDifficulty(double stars, int maxCombo) + public readonly DifficultyAttributes Attributes; + + public StarDifficulty(double stars, int maxCombo, DifficultyAttributes attributes = null) { Stars = stars; MaxCombo = maxCombo; - + Attributes = attributes; // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) } } diff --git a/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs b/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs index ac3b817840..fc1d232a00 100644 --- a/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs +++ b/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs @@ -21,14 +21,14 @@ namespace osu.Game.Rulesets.Difficulty protected double TimeRate { get; private set; } = 1; - protected PerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score) + protected PerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) { Ruleset = ruleset; Score = score; Beatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, score.Mods); - Attributes = ruleset.CreateDifficultyCalculator(beatmap).Calculate(score.Mods); + Attributes = attributes ?? ruleset.CreateDifficultyCalculator(beatmap).Calculate(score.Mods); ApplyMods(score.Mods); } diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index 915544d010..a8f62bca4a 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -158,7 +158,7 @@ namespace osu.Game.Rulesets public abstract DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap); - public virtual PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => null; + public virtual PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score, DifficultyAttributes attributes = null) => null; public virtual HitObjectComposer CreateHitObjectComposer() => null; diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index a27e38fb07..97b4be7edc 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -20,6 +20,9 @@ namespace osu.Game.Scoring [Resolved] private BeatmapManager beatmapManager { get; set; } + [Resolved] + private BeatmapDifficultyManager difficultyManager { get; set; } + /// /// Calculates performance for the given . /// @@ -30,10 +33,7 @@ namespace osu.Game.Scoring if (tryGetExisting(score, out var perf, out var lookupKey)) return perf; - return await Task.Factory.StartNew(() => - { - return computePerformance(score, lookupKey, token); - }, token); + return await computePerformanceAsync(score, lookupKey, token); } private bool tryGetExisting(ScoreInfo score, out double performance, out PerformanceCacheLookup lookupKey) @@ -43,14 +43,15 @@ namespace osu.Game.Scoring return performanceCache.TryGetValue(lookupKey, out performance); } - private double computePerformance(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) + private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) { var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); + var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token); if (token.IsCancellationRequested) return default; - var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score); + var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score, attributes.Attributes); var total = calculator.Calculate(); performanceCache[lookupKey] = total; @@ -74,7 +75,7 @@ namespace osu.Game.Scoring TotalScore = info.TotalScore; Combo = info.Combo; Mods = info.Mods; - RulesetId = info.Ruleset.ID.Value; + RulesetId = info.Ruleset.ID ?? 0; } public override int GetHashCode() From a425cf4a31372b7fee31b71ae2748ba57f84a0ff Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 7 Oct 2020 13:29:10 +0200 Subject: [PATCH 11/73] Fix broken class reference. --- .../Screens/Ranking/Expanded/Statistics/CounterStatistic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs index e070f76289..08a9714fd8 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs @@ -46,7 +46,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Child = Counter = new Counter + Child = Counter = new StatisticCounter { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre From cd15f83f85341f86ac5f0e3f112ac4bb46c8e3ac Mon Sep 17 00:00:00 2001 From: Lucas A Date: Wed, 7 Oct 2020 14:10:25 +0200 Subject: [PATCH 12/73] Update ScorePerformanceCalculator code path. --- osu.Game/Scoring/ScorePerformanceManager.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 97b4be7edc..0189a86172 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -17,9 +17,6 @@ namespace osu.Game.Scoring { private readonly ConcurrentDictionary performanceCache = new ConcurrentDictionary(); - [Resolved] - private BeatmapManager beatmapManager { get; set; } - [Resolved] private BeatmapDifficultyManager difficultyManager { get; set; } @@ -45,14 +42,13 @@ namespace osu.Game.Scoring private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) { - var beatmap = beatmapManager.GetWorkingBeatmap(score.Beatmap); var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token); if (token.IsCancellationRequested) return default; - var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(beatmap, score, attributes.Attributes); - var total = calculator.Calculate(); + var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(attributes.Attributes, score); + var total = calculator?.Calculate() ?? default; performanceCache[lookupKey] = total; From fa201be2adb1ef8c7382ea578585854d476bc128 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Thu, 8 Oct 2020 18:31:29 +0200 Subject: [PATCH 13/73] Simplify PerformanceCacheLookup --- osu.Game/Scoring/ScorePerformanceManager.cs | 26 +++++---------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 0189a86172..783425052f 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -9,7 +9,6 @@ using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Mods; namespace osu.Game.Scoring { @@ -57,34 +56,21 @@ namespace osu.Game.Scoring public readonly struct PerformanceCacheLookup { - public readonly double Accuracy; - public readonly int BeatmapId; - public readonly long TotalScore; - public readonly int Combo; - public readonly Mod[] Mods; - public readonly int RulesetId; + public readonly string ScoreHash; + public readonly int LocalId; public PerformanceCacheLookup(ScoreInfo info) { - Accuracy = info.Accuracy; - BeatmapId = info.Beatmap.ID; - TotalScore = info.TotalScore; - Combo = info.Combo; - Mods = info.Mods; - RulesetId = info.Ruleset.ID ?? 0; + ScoreHash = info.Hash; + LocalId = info.ID; } public override int GetHashCode() { var hash = new HashCode(); - hash.Add(Accuracy); - hash.Add(BeatmapId); - hash.Add(TotalScore); - hash.Add(Combo); - hash.Add(RulesetId); - foreach (var mod in Mods) - hash.Add(mod); + hash.Add(ScoreHash); + hash.Add(LocalId); return hash.ToHashCode(); } From 6459ce28a34654c94c351e22340ce166c46b2ed8 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Fri, 9 Oct 2020 18:32:03 +0200 Subject: [PATCH 14/73] Don't calculate performance if difficulty attributes aren't locally computable. --- osu.Game/Scoring/ScorePerformanceManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 783425052f..c2e36ae798 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -43,6 +43,10 @@ namespace osu.Game.Scoring { var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token); + // Performance calculation requires the beatmap and ruleset to be locally available. If not, return a default value. + if (attributes.Attributes == null) + return default; + if (token.IsCancellationRequested) return default; From de522d53eaf408238b81df3e8eb3dd3603b68549 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Oct 2020 19:16:21 +0200 Subject: [PATCH 15/73] Make CalculatePerformanceAsync() nullable. --- osu.Game/Scoring/ScorePerformanceManager.cs | 14 +++++++------- .../Expanded/Statistics/PerformanceStatistic.cs | 6 +++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index c2e36ae798..21b1b679eb 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -24,7 +24,7 @@ namespace osu.Game.Scoring /// /// The score to do the calculation on. /// An optional to cancel the operation. - public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) + public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) { if (tryGetExisting(score, out var perf, out var lookupKey)) return perf; @@ -39,21 +39,21 @@ namespace osu.Game.Scoring return performanceCache.TryGetValue(lookupKey, out performance); } - private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) + private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) { var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token); // Performance calculation requires the beatmap and ruleset to be locally available. If not, return a default value. if (attributes.Attributes == null) - return default; + return null; - if (token.IsCancellationRequested) - return default; + token.ThrowIfCancellationRequested(); var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(attributes.Attributes, score); - var total = calculator?.Calculate() ?? default; + var total = calculator?.Calculate(); - performanceCache[lookupKey] = total; + if (total.HasValue) + performanceCache[lookupKey] = total.Value; return total; } diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 7e342a33f1..068745ca17 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -32,7 +32,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics else { performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => performance.Value = (int)t.Result), cancellationTokenSource.Token); + .ContinueWith(t => Schedule(() => + { + if (t.Result.HasValue) + performance.Value = (int)t.Result.Value; + }), cancellationTokenSource.Token); } } From a0e6226b7aef1decee427628fa0e2f54db2ad9ad Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Oct 2020 19:19:24 +0200 Subject: [PATCH 16/73] Rename LocalId -> LocalScoreID --- osu.Game/Scoring/ScorePerformanceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 21b1b679eb..d8daf7189a 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -61,12 +61,12 @@ namespace osu.Game.Scoring public readonly struct PerformanceCacheLookup { public readonly string ScoreHash; - public readonly int LocalId; + public readonly int LocalScoreID; public PerformanceCacheLookup(ScoreInfo info) { ScoreHash = info.Hash; - LocalId = info.ID; + LocalScoreID = info.ID; } public override int GetHashCode() @@ -74,7 +74,7 @@ namespace osu.Game.Scoring var hash = new HashCode(); hash.Add(ScoreHash); - hash.Add(LocalId); + hash.Add(LocalScoreID); return hash.ToHashCode(); } From e845cc92b8d656373969dda9b767994fae0846ed Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sat, 10 Oct 2020 19:58:06 +0200 Subject: [PATCH 17/73] Round pp values to nearest integer. --- .../Ranking/Expanded/Statistics/PerformanceStatistic.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 068745ca17..3976682241 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.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 System; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -27,7 +28,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { if (score.PP.HasValue) { - performance.Value = (int)score.PP.Value; + performance.Value = (int)Math.Round(score.PP.Value, MidpointRounding.AwayFromZero); } else { @@ -35,7 +36,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics .ContinueWith(t => Schedule(() => { if (t.Result.HasValue) - performance.Value = (int)t.Result.Value; + performance.Value = (int)Math.Round(t.Result.Value, MidpointRounding.AwayFromZero); }), cancellationTokenSource.Token); } } From 779e6e10a7516f2d3f961af5f9f9a5ba81880c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 12 Oct 2020 21:43:14 +0200 Subject: [PATCH 18/73] Split ctors to avoid passing fields one by one --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index bdabe148a7..bbd204dede 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -227,7 +227,7 @@ namespace osu.Game.Beatmaps var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo)); var attributes = calculator.Calculate(key.Mods); - return difficultyCache[key] = new StarDifficulty(attributes.StarRating, attributes.MaxCombo, attributes); + return difficultyCache[key] = new StarDifficulty(attributes); } catch { @@ -322,14 +322,21 @@ namespace osu.Game.Beatmaps public readonly DifficultyAttributes Attributes; - public StarDifficulty(double stars, int maxCombo, DifficultyAttributes attributes = null) + public StarDifficulty([NotNull] DifficultyAttributes attributes) { - Stars = stars; - MaxCombo = maxCombo; + Stars = attributes.StarRating; + MaxCombo = attributes.MaxCombo; Attributes = attributes; // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) } + public StarDifficulty(double starDifficulty, int maxCombo) + { + Stars = starDifficulty; + MaxCombo = maxCombo; + Attributes = null; + } + public DifficultyRating DifficultyRating => BeatmapDifficultyManager.GetDifficultyRating(Stars); } } From 7117fd0fbaacaa1a7aa959bfa52fbc0ab5958f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 12 Oct 2020 21:44:04 +0200 Subject: [PATCH 19/73] Add xmldoc and nullability annotations --- osu.Game/Beatmaps/BeatmapDifficultyManager.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs index bbd204dede..3a21df8aeb 100644 --- a/osu.Game/Beatmaps/BeatmapDifficultyManager.cs +++ b/osu.Game/Beatmaps/BeatmapDifficultyManager.cs @@ -317,11 +317,27 @@ namespace osu.Game.Beatmaps public readonly struct StarDifficulty { + /// + /// The star difficulty rating for the given beatmap. + /// public readonly double Stars; + + /// + /// The maximum combo achievable on the given beatmap. + /// public readonly int MaxCombo; + /// + /// The difficulty attributes computed for the given beatmap. + /// Might not be available if the star difficulty is associated with a beatmap that's not locally available. + /// + [CanBeNull] public readonly DifficultyAttributes Attributes; + /// + /// Creates a structure based on computed + /// by a . + /// public StarDifficulty([NotNull] DifficultyAttributes attributes) { Stars = attributes.StarRating; @@ -330,6 +346,10 @@ namespace osu.Game.Beatmaps // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) } + /// + /// Creates a structure with a pre-populated star difficulty and max combo + /// in scenarios where computing is not feasible (i.e. when working with online sources). + /// public StarDifficulty(double starDifficulty, int maxCombo) { Stars = starDifficulty; From d4ba9d268254278bef604aa16e80e8cb901d8d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 12 Oct 2020 22:10:02 +0200 Subject: [PATCH 20/73] Simplify implementation of CalculatePerformanceAsync --- osu.Game/Scoring/ScorePerformanceManager.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index d8daf7189a..b7657c73c6 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -26,19 +26,14 @@ namespace osu.Game.Scoring /// An optional to cancel the operation. public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) { - if (tryGetExisting(score, out var perf, out var lookupKey)) - return perf; + var lookupKey = new PerformanceCacheLookup(score); + + if (performanceCache.TryGetValue(lookupKey, out double performance)) + return performance; return await computePerformanceAsync(score, lookupKey, token); } - private bool tryGetExisting(ScoreInfo score, out double performance, out PerformanceCacheLookup lookupKey) - { - lookupKey = new PerformanceCacheLookup(score); - - return performanceCache.TryGetValue(lookupKey, out performance); - } - private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) { var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token); From 68b505ab86df0f77bc0888c780189e6da0970122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Mon, 12 Oct 2020 22:14:39 +0200 Subject: [PATCH 21/73] Extract helper function for pp value handling --- .../Expanded/Statistics/PerformanceStatistic.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 3976682241..1b4edb99d7 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -28,19 +28,21 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { if (score.PP.HasValue) { - performance.Value = (int)Math.Round(score.PP.Value, MidpointRounding.AwayFromZero); + setPerformanceValue(score.PP.Value); } else { performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token) - .ContinueWith(t => Schedule(() => - { - if (t.Result.HasValue) - performance.Value = (int)Math.Round(t.Result.Value, MidpointRounding.AwayFromZero); - }), cancellationTokenSource.Token); + .ContinueWith(t => Schedule(() => setPerformanceValue(t.Result)), cancellationTokenSource.Token); } } + private void setPerformanceValue(double? pp) + { + if (pp.HasValue) + performance.Value = (int)Math.Round(pp.Value, MidpointRounding.AwayFromZero); + } + public override void Appear() { base.Appear(); From 7e709349b829a98660fd6dd839c5c10932c4ee50 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 13 Oct 2020 06:26:14 +0900 Subject: [PATCH 22/73] Use already available test ruleset --- .../Visual/Background/TestSceneUserDimBackgrounds.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index ce73e9061b..9ef9649f77 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -19,7 +19,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; using osu.Game.Rulesets; -using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu.Mods; using osu.Game.Scoring; using osu.Game.Screens; @@ -194,8 +193,8 @@ namespace osu.Game.Tests.Visual.Background AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" }, - Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, - Ruleset = new OsuRuleset().RulesetInfo, + Beatmap = new TestBeatmap(Ruleset.Value).BeatmapInfo, + Ruleset = Ruleset.Value, }))); AddUntilStep("Wait for results is current", () => results.IsCurrentScreen()); From 704f8cc4f27b81c92906332a4ac13931cf341c57 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Mon, 26 Oct 2020 18:03:04 +0100 Subject: [PATCH 23/73] Fix selection box wandering off into the distance --- .../Timeline/TimelineBlueprintContainer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs index 84328466c3..b76032709f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; +using osu.Framework.Utils; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; @@ -107,7 +108,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline OnDragHandled = handleScrollViaDrag }; - protected override DragBox CreateDragBox(Action performSelect) => new TimelineDragBox(performSelect); + protected override DragBox CreateDragBox(Action performSelect) => new TimelineDragBox(performSelect, this); private void handleScrollViaDrag(DragEvent e) { @@ -138,11 +139,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private class TimelineDragBox : DragBox { private Vector2 lastMouseDown; + private float? lastZoom; private float localMouseDown; - public TimelineDragBox(Action performSelect) + private readonly TimelineBlueprintContainer parent; + + public TimelineDragBox(Action performSelect, TimelineBlueprintContainer parent) : base(performSelect) { + this.parent = parent; } protected override Drawable CreateBox() => new Box @@ -158,8 +163,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline { lastMouseDown = e.ScreenSpaceMouseDownPosition; localMouseDown = e.MouseDownPosition.X; + lastZoom = null; } + //Zooming the timeline shifts the coordinate system this compensates for this shift + float zoomCorrection = lastZoom.HasValue ? (parent.timeline.Zoom / lastZoom.Value) : 1; + localMouseDown *= zoomCorrection; + lastZoom = parent.timeline.Zoom; + float selection1 = localMouseDown; float selection2 = e.MousePosition.X; From a96c067bead52c21d4950c1d29717b611b077b31 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 27 Oct 2020 13:45:21 +0100 Subject: [PATCH 24/73] Remove uncessary async-await state machine level. --- osu.Game/Scoring/ScorePerformanceManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index b7657c73c6..746aa67a55 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -24,14 +24,14 @@ namespace osu.Game.Scoring /// /// The score to do the calculation on. /// An optional to cancel the operation. - public async Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) + public Task CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default) { var lookupKey = new PerformanceCacheLookup(score); if (performanceCache.TryGetValue(lookupKey, out double performance)) - return performance; + return Task.FromResult((double?)performance); - return await computePerformanceAsync(score, lookupKey, token); + return computePerformanceAsync(score, lookupKey, token); } private async Task computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default) From 064c50c3ac8642803c91b6a08a11ea5d64f1d796 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Tue, 27 Oct 2020 12:39:50 +0100 Subject: [PATCH 25/73] Expose currentZoom to fix selection box wiggle --- .../Components/Timeline/TimelineBlueprintContainer.cs | 10 +++++----- .../Components/Timeline/ZoomableScrollContainer.cs | 8 +++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs index b76032709f..008da14a21 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; -using osu.Framework.Utils; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; @@ -139,6 +138,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private class TimelineDragBox : DragBox { private Vector2 lastMouseDown; + private float? lastZoom; private float localMouseDown; @@ -166,13 +166,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline lastZoom = null; } - //Zooming the timeline shifts the coordinate system this compensates for this shift - float zoomCorrection = lastZoom.HasValue ? (parent.timeline.Zoom / lastZoom.Value) : 1; + //Zooming the timeline shifts the coordinate system. zoomCorrection compensates for that + float zoomCorrection = lastZoom.HasValue ? (parent.timeline.CurrentZoom / lastZoom.Value) : 1; localMouseDown *= zoomCorrection; - lastZoom = parent.timeline.Zoom; + lastZoom = parent.timeline.CurrentZoom; float selection1 = localMouseDown; - float selection2 = e.MousePosition.X; + float selection2 = e.MousePosition.X * zoomCorrection; Box.X = Math.Min(selection1, selection2); Box.Width = Math.Abs(selection1 - selection2); diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index 227eecf9c7..6a9552a2c4 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -29,9 +29,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private readonly Container zoomedContent; protected override Container Content => zoomedContent; - private float currentZoom = 1; + /// + /// The current zoom level of . + /// It may differ from during transitions. + /// + public float CurrentZoom => currentZoom; + + [Resolved(canBeNull: true)] private IFrameBasedClock editorClock { get; set; } From 983a2774e89c4e973c28c08bba669e9ae25f3096 Mon Sep 17 00:00:00 2001 From: Leon Gebler Date: Tue, 27 Oct 2020 15:09:10 +0100 Subject: [PATCH 26/73] Code Formatting --- .../Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs index 6a9552a2c4..f90658e99c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/ZoomableScrollContainer.cs @@ -37,7 +37,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline /// public float CurrentZoom => currentZoom; - [Resolved(canBeNull: true)] private IFrameBasedClock editorClock { get; set; } From 44471b4596bab45dea5ed4350c763d4522cfe35c Mon Sep 17 00:00:00 2001 From: Lucas A Date: Tue, 27 Oct 2020 20:19:15 +0100 Subject: [PATCH 27/73] Fix tests not building. --- osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs index 1c0af19322..9ef9649f77 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneUserDimBackgrounds.cs @@ -192,7 +192,6 @@ namespace osu.Game.Tests.Visual.Background AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo { - Ruleset = new OsuRuleset().RulesetInfo, User = new User { Username = "osu!" }, Beatmap = new TestBeatmap(Ruleset.Value).BeatmapInfo, Ruleset = Ruleset.Value, From a8e9c62583c8951b4e2f86b449fb1da6f75f3433 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:11:25 +0900 Subject: [PATCH 28/73] Make results panels aware of whether they are a local score that has just been set --- osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs | 2 +- osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs | 2 +- .../Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs | 7 ++++++- .../Ranking/Expanded/ExpandedPanelMiddleContent.cs | 8 ++++++-- osu.Game/Screens/Ranking/ResultsScreen.cs | 2 +- osu.Game/Screens/Ranking/ScorePanel.cs | 7 +++++-- osu.Game/Screens/Ranking/ScorePanelList.cs | 5 +++-- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs index 1e87893f39..f69ccc1773 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs @@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Ranking } } }, - new AccuracyCircle(score) + new AccuracyCircle(score, false) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs index 250fdc5ebd..5af55e99f8 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneScorePanel.cs @@ -103,7 +103,7 @@ namespace osu.Game.Tests.Visual.Ranking private void addPanelStep(ScoreInfo score, PanelState state = PanelState.Expanded) => AddStep("add panel", () => { - Child = panel = new ScorePanel(score) + Child = panel = new ScorePanel(score, true) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 45da23f1f9..9aeb2b60b7 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -73,14 +73,19 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy private readonly ScoreInfo score; + private readonly bool withFlair; + private SmoothCircularProgress accuracyCircle; private SmoothCircularProgress innerMask; private Container badges; private RankText rankText; - public AccuracyCircle(ScoreInfo score) + private SampleChannel applauseSound; + + public AccuracyCircle(ScoreInfo score, bool withFlair) { this.score = score; + this.withFlair = withFlair; } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index 30747438c3..5f8609d190 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -29,6 +29,8 @@ namespace osu.Game.Screens.Ranking.Expanded private const float padding = 10; private readonly ScoreInfo score; + private readonly bool withFlair; + private readonly List statisticDisplays = new List(); private FillFlowContainer starAndModDisplay; @@ -41,9 +43,11 @@ namespace osu.Game.Screens.Ranking.Expanded /// Creates a new . /// /// The score to display. - public ExpandedPanelMiddleContent(ScoreInfo score) + /// Whether to add flair for a new score being set. + public ExpandedPanelMiddleContent(ScoreInfo score, bool withFlair = false) { this.score = score; + this.withFlair = withFlair; RelativeSizeAxes = Axes.Both; Masking = true; @@ -116,7 +120,7 @@ namespace osu.Game.Screens.Ranking.Expanded Margin = new MarginPadding { Top = 40 }, RelativeSizeAxes = Axes.X, Height = 230, - Child = new AccuracyCircle(score) + Child = new AccuracyCircle(score, withFlair) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Ranking/ResultsScreen.cs b/osu.Game/Screens/Ranking/ResultsScreen.cs index 026ce01857..f8bdf0140c 100644 --- a/osu.Game/Screens/Ranking/ResultsScreen.cs +++ b/osu.Game/Screens/Ranking/ResultsScreen.cs @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Ranking }; if (Score != null) - ScorePanelList.AddScore(Score); + ScorePanelList.AddScore(Score, true); if (player != null && allowRetry) { diff --git a/osu.Game/Screens/Ranking/ScorePanel.cs b/osu.Game/Screens/Ranking/ScorePanel.cs index ee97ee55eb..6e6227da38 100644 --- a/osu.Game/Screens/Ranking/ScorePanel.cs +++ b/osu.Game/Screens/Ranking/ScorePanel.cs @@ -85,6 +85,8 @@ namespace osu.Game.Screens.Ranking public readonly ScoreInfo Score; + private readonly bool isNewLocalScore; + private Container content; private Container topLayerContainer; @@ -97,9 +99,10 @@ namespace osu.Game.Screens.Ranking private Container middleLayerContentContainer; private Drawable middleLayerContent; - public ScorePanel(ScoreInfo score) + public ScorePanel(ScoreInfo score, bool isNewLocalScore = false) { Score = score; + this.isNewLocalScore = isNewLocalScore; } [BackgroundDependencyLoader] @@ -209,7 +212,7 @@ namespace osu.Game.Screens.Ranking middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint); topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0)); - middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score).With(d => d.Alpha = 0)); + middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, isNewLocalScore).With(d => d.Alpha = 0)); break; case PanelState.Contracted: diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs index 0d7d339df0..cc163ba762 100644 --- a/osu.Game/Screens/Ranking/ScorePanelList.cs +++ b/osu.Game/Screens/Ranking/ScorePanelList.cs @@ -95,9 +95,10 @@ namespace osu.Game.Screens.Ranking /// Adds a to this list. /// /// The to add. - public ScorePanel AddScore(ScoreInfo score) + /// Whether this is a score that has just been achieved locally. Controls whether flair is added to the display or not. + public ScorePanel AddScore(ScoreInfo score, bool isNewLocalScore = false) { - var panel = new ScorePanel(score) + var panel = new ScorePanel(score, isNewLocalScore) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, From fb82c043a515cb95c3267eacdd915be43ff4e3c4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:11:37 +0900 Subject: [PATCH 29/73] Add rank appear sound (new default) --- .../Ranking/Expanded/Accuracy/AccuracyCircle.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 9aeb2b60b7..0c15aa509f 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -4,6 +4,8 @@ using System; using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; @@ -89,8 +91,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy } [BackgroundDependencyLoader] - private void load() + private void load(AudioManager audio) { + if (withFlair) + applauseSound = audio.Samples.Get(score.Rank >= ScoreRank.A ? "Results/rankpass" : "Results/rankfail"); + InternalChildren = new Drawable[] { new SmoothCircularProgress @@ -239,11 +244,16 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy continue; using (BeginDelayedSequence(inverseEasing(ACCURACY_TRANSFORM_EASING, Math.Min(1 - virtual_ss_percentage, badge.Accuracy) / targetAccuracy) * ACCURACY_TRANSFORM_DURATION, true)) + { badge.Appear(); + } } using (BeginDelayedSequence(TEXT_APPEAR_DELAY, true)) + { + this.Delay(-1440).Schedule(() => applauseSound?.Play()); rankText.Appear(); + } } } From b49a57941103145f782810e873b811723e593139 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:32:03 +0900 Subject: [PATCH 30/73] Allow SampleInfo to specify fallback sample lookup names --- osu.Game/Audio/SampleInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index 2406b0bef2..240d70c418 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -10,14 +10,14 @@ namespace osu.Game.Audio /// public class SampleInfo : ISampleInfo { - private readonly string sampleName; + private readonly string[] sampleNames; - public SampleInfo(string sampleName) + public SampleInfo(params string[] sampleNames) { - this.sampleName = sampleName; + this.sampleNames = sampleNames; } - public IEnumerable LookupNames => new[] { sampleName }; + public IEnumerable LookupNames => sampleNames; public int Volume { get; } = 100; } From c863341ca1e7f1965222cbc0db0471da9c61ca29 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:32:20 +0900 Subject: [PATCH 31/73] Don't force Gameplay prefix on all skin sample lookups --- osu.Game/Audio/HitSampleInfo.cs | 4 ++-- osu.Game/Skinning/SkinnableSound.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Audio/HitSampleInfo.cs b/osu.Game/Audio/HitSampleInfo.cs index 8b1f5a366a..8efaeb3795 100644 --- a/osu.Game/Audio/HitSampleInfo.cs +++ b/osu.Game/Audio/HitSampleInfo.cs @@ -50,9 +50,9 @@ namespace osu.Game.Audio get { if (!string.IsNullOrEmpty(Suffix)) - yield return $"{Bank}-{Name}{Suffix}"; + yield return $"Gameplay/{Bank}-{Name}{Suffix}"; - yield return $"{Bank}-{Name}"; + yield return $"Gameplay/{Bank}-{Name}"; } } diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs index f6e91811dd..ffa0a963ce 100644 --- a/osu.Game/Skinning/SkinnableSound.cs +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -88,7 +88,7 @@ namespace osu.Game.Skinning { foreach (var lookup in s.LookupNames) { - if ((ch = samples.Get($"Gameplay/{lookup}")) != null) + if ((ch = samples.Get(lookup)) != null) break; } } From 5d5b0221e5199f96e0fda82669862bbe8854ec72 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:32:29 +0900 Subject: [PATCH 32/73] Add skinning support for legacy applause playback --- .../Ranking/Expanded/Accuracy/AccuracyCircle.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index 0c15aa509f..c6d4b66724 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -11,9 +11,11 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Utils; +using osu.Game.Audio; using osu.Game.Graphics; using osu.Game.Rulesets.Mods; using osu.Game.Scoring; +using osu.Game.Skinning; using osuTK; namespace osu.Game.Screens.Ranking.Expanded.Accuracy @@ -82,7 +84,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy private Container badges; private RankText rankText; - private SampleChannel applauseSound; + private SkinnableSound applauseSound; public AccuracyCircle(ScoreInfo score, bool withFlair) { @@ -93,9 +95,6 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy [BackgroundDependencyLoader] private void load(AudioManager audio) { - if (withFlair) - applauseSound = audio.Samples.Get(score.Rank >= ScoreRank.A ? "Results/rankpass" : "Results/rankfail"); - InternalChildren = new Drawable[] { new SmoothCircularProgress @@ -213,6 +212,13 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy }, rankText = new RankText(score.Rank) }; + + if (withFlair) + { + AddInternal(applauseSound = score.Rank >= ScoreRank.A + ? new SkinnableSound(new SampleInfo("Results/rankpass", "applause")) + : new SkinnableSound(new SampleInfo("Results/rankfail"))); + } } private ScoreRank getRank(ScoreRank rank) From f1ce09930eb0fc5ff86b164a01c6edd2b6183894 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 17:03:45 +0900 Subject: [PATCH 33/73] Fix panel expanded state being updated multiple times unnecessarily --- osu.Game/Screens/Ranking/ScorePanelList.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Ranking/ScorePanelList.cs b/osu.Game/Screens/Ranking/ScorePanelList.cs index cc163ba762..e85580a734 100644 --- a/osu.Game/Screens/Ranking/ScorePanelList.cs +++ b/osu.Game/Screens/Ranking/ScorePanelList.cs @@ -119,7 +119,10 @@ namespace osu.Game.Screens.Ranking })); if (SelectedScore.Value == score) - selectedScoreChanged(new ValueChangedEvent(SelectedScore.Value, SelectedScore.Value)); + { + if (IsLoaded) + SelectedScore.TriggerChange(); + } else { // We want the scroll position to remain relative to the expanded panel. When a new panel is added after the expanded panel, nothing needs to be done. @@ -143,11 +146,15 @@ namespace osu.Game.Screens.Ranking /// The to present. private void selectedScoreChanged(ValueChangedEvent score) { - // Contract the old panel. - foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue)) + // avoid contracting panels unnecessarily when TriggerChange is fired manually. + if (score.OldValue != score.NewValue) { - t.Panel.State = PanelState.Contracted; - t.Margin = new MarginPadding(); + // Contract the old panel. + foreach (var t in flow.Where(t => t.Panel.Score == score.OldValue)) + { + t.Panel.State = PanelState.Contracted; + t.Margin = new MarginPadding(); + } } // Find the panel corresponding to the new score. From 4a26084df838916ae5cac8124c12d08aba74a106 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 17:04:33 +0900 Subject: [PATCH 34/73] Only play results panel animation once (and only for the local user) --- .../Ranking/Expanded/ExpandedPanelMiddleContent.cs | 3 +++ osu.Game/Screens/Ranking/ScorePanel.cs | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index 5f8609d190..711763330c 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -270,6 +270,9 @@ namespace osu.Game.Screens.Ranking.Expanded delay += 200; } } + + if (!withFlair) + FinishTransforms(true); }); } } diff --git a/osu.Game/Screens/Ranking/ScorePanel.cs b/osu.Game/Screens/Ranking/ScorePanel.cs index 6e6227da38..df710e4eb8 100644 --- a/osu.Game/Screens/Ranking/ScorePanel.cs +++ b/osu.Game/Screens/Ranking/ScorePanel.cs @@ -85,7 +85,7 @@ namespace osu.Game.Screens.Ranking public readonly ScoreInfo Score; - private readonly bool isNewLocalScore; + private bool displayWithFlair; private Container content; @@ -102,7 +102,7 @@ namespace osu.Game.Screens.Ranking public ScorePanel(ScoreInfo score, bool isNewLocalScore = false) { Score = score; - this.isNewLocalScore = isNewLocalScore; + displayWithFlair = isNewLocalScore; } [BackgroundDependencyLoader] @@ -191,7 +191,7 @@ namespace osu.Game.Screens.Ranking state = value; - if (LoadState >= LoadState.Ready) + if (IsLoaded) updateState(); StateChanged?.Invoke(value); @@ -212,7 +212,10 @@ namespace osu.Game.Screens.Ranking middleLayerBackground.FadeColour(expanded_middle_layer_colour, resize_duration, Easing.OutQuint); topLayerContentContainer.Add(topLayerContent = new ExpandedPanelTopContent(Score.User).With(d => d.Alpha = 0)); - middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, isNewLocalScore).With(d => d.Alpha = 0)); + middleLayerContentContainer.Add(middleLayerContent = new ExpandedPanelMiddleContent(Score, displayWithFlair).With(d => d.Alpha = 0)); + + // only the first expanded display should happen with flair. + displayWithFlair = false; break; case PanelState.Contracted: From f1b8a8f7f56337edd8693ea2cb8bf57c6c6bd5ff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 18:16:04 +0900 Subject: [PATCH 35/73] Remove unused using --- osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs index c6d4b66724..bca3a07fa6 100644 --- a/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs +++ b/osu.Game/Screens/Ranking/Expanded/Accuracy/AccuracyCircle.cs @@ -5,7 +5,6 @@ using System; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; -using osu.Framework.Audio.Sample; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Colour; From c9a85587fb21be9c1d54e448e26f0b930e664ea0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:32:03 +0900 Subject: [PATCH 36/73] Allow SampleInfo to specify fallback sample lookup names --- osu.Game/Audio/SampleInfo.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Audio/SampleInfo.cs b/osu.Game/Audio/SampleInfo.cs index 2406b0bef2..240d70c418 100644 --- a/osu.Game/Audio/SampleInfo.cs +++ b/osu.Game/Audio/SampleInfo.cs @@ -10,14 +10,14 @@ namespace osu.Game.Audio /// public class SampleInfo : ISampleInfo { - private readonly string sampleName; + private readonly string[] sampleNames; - public SampleInfo(string sampleName) + public SampleInfo(params string[] sampleNames) { - this.sampleName = sampleName; + this.sampleNames = sampleNames; } - public IEnumerable LookupNames => new[] { sampleName }; + public IEnumerable LookupNames => sampleNames; public int Volume { get; } = 100; } From 0b28cca7e6b53b7e3be67782f00ea9a12b55cfa9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 29 Oct 2020 16:32:20 +0900 Subject: [PATCH 37/73] Don't force Gameplay prefix on all skin sample lookups --- osu.Game/Audio/HitSampleInfo.cs | 4 ++-- osu.Game/Skinning/SkinnableSound.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Audio/HitSampleInfo.cs b/osu.Game/Audio/HitSampleInfo.cs index 8b1f5a366a..8efaeb3795 100644 --- a/osu.Game/Audio/HitSampleInfo.cs +++ b/osu.Game/Audio/HitSampleInfo.cs @@ -50,9 +50,9 @@ namespace osu.Game.Audio get { if (!string.IsNullOrEmpty(Suffix)) - yield return $"{Bank}-{Name}{Suffix}"; + yield return $"Gameplay/{Bank}-{Name}{Suffix}"; - yield return $"{Bank}-{Name}"; + yield return $"Gameplay/{Bank}-{Name}"; } } diff --git a/osu.Game/Skinning/SkinnableSound.cs b/osu.Game/Skinning/SkinnableSound.cs index f6e91811dd..ffa0a963ce 100644 --- a/osu.Game/Skinning/SkinnableSound.cs +++ b/osu.Game/Skinning/SkinnableSound.cs @@ -88,7 +88,7 @@ namespace osu.Game.Skinning { foreach (var lookup in s.LookupNames) { - if ((ch = samples.Get($"Gameplay/{lookup}")) != null) + if ((ch = samples.Get(lookup)) != null) break; } } From d319b27b3d9b90c8d69e48dcdd137d8ec08be566 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 11:14:08 +0900 Subject: [PATCH 38/73] Run sample lookup logic through getFallbackNames --- osu.Game/Skinning/LegacySkin.cs | 54 +++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 94b09684d3..d927d54abc 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -417,10 +417,14 @@ namespace osu.Game.Skinning public override SampleChannel GetSample(ISampleInfo sampleInfo) { - var lookupNames = sampleInfo.LookupNames; + IEnumerable lookupNames = null; if (sampleInfo is HitSampleInfo hitSample) lookupNames = getLegacyLookupNames(hitSample); + else + { + lookupNames = sampleInfo.LookupNames.SelectMany(getFallbackNames); + } foreach (var lookup in lookupNames) { @@ -433,6 +437,36 @@ namespace osu.Game.Skinning return null; } + private IEnumerable getLegacyLookupNames(HitSampleInfo hitSample) + { + var lookupNames = hitSample.LookupNames.SelectMany(getFallbackNames); + + if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix)) + { + // for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin. + // using .EndsWith() is intentional as it ensures parity in all edge cases + // (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not). + foreach (var l in lookupNames) + { + if (!l.EndsWith(hitSample.Suffix, StringComparison.Ordinal)) + { + foreach (var n in getFallbackNames(l)) + yield return n; + } + } + } + else + { + foreach (var l in lookupNames) + yield return l; + } + + // also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort. + // going forward specifying banks shall always be required, even for elements that wouldn't require it on stable, + // which is why this is done locally here. + yield return hitSample.Name; + } + private IEnumerable getFallbackNames(string componentName) { // May be something like "Gameplay/osu/approachcircle" from lazer, or "Arrows/note1" from a user skin. @@ -442,23 +476,5 @@ namespace osu.Game.Skinning string lastPiece = componentName.Split('/').Last(); yield return componentName.StartsWith("Gameplay/taiko/", StringComparison.Ordinal) ? "taiko-" + lastPiece : lastPiece; } - - private IEnumerable getLegacyLookupNames(HitSampleInfo hitSample) - { - var lookupNames = hitSample.LookupNames; - - if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix)) - // for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin. - // using .EndsWith() is intentional as it ensures parity in all edge cases - // (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not). - lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal)); - - // also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort. - // going forward specifying banks shall always be required, even for elements that wouldn't require it on stable, - // which is why this is done locally here. - lookupNames = lookupNames.Append(hitSample.Name); - - return lookupNames; - } } } From 2ea4aa0a37c86b74f67cfb3f493e882e0adbd335 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 11:52:25 +0900 Subject: [PATCH 39/73] Fix incorrect specification on some sample lookups --- osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs | 2 +- osu.Game/Rulesets/Mods/ModNightcore.cs | 8 ++++---- osu.Game/Screens/Play/ComboEffects.cs | 2 +- osu.Game/Screens/Play/PauseOverlay.cs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs index 864e88d023..fc0cda2c1f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneSkinnableSound.cs @@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Gameplay skinSource = new TestSkinSourceContainer { RelativeSizeAxes = Axes.Both, - Child = skinnableSound = new PausableSkinnableSound(new SampleInfo("normal-sliderslide")) + Child = skinnableSound = new PausableSkinnableSound(new SampleInfo("Gameplay/normal-sliderslide")) }, }; }); diff --git a/osu.Game/Rulesets/Mods/ModNightcore.cs b/osu.Game/Rulesets/Mods/ModNightcore.cs index 282de3a8e1..e8b051b4d9 100644 --- a/osu.Game/Rulesets/Mods/ModNightcore.cs +++ b/osu.Game/Rulesets/Mods/ModNightcore.cs @@ -69,10 +69,10 @@ namespace osu.Game.Rulesets.Mods { InternalChildren = new Drawable[] { - hatSample = new PausableSkinnableSound(new SampleInfo("nightcore-hat")), - clapSample = new PausableSkinnableSound(new SampleInfo("nightcore-clap")), - kickSample = new PausableSkinnableSound(new SampleInfo("nightcore-kick")), - finishSample = new PausableSkinnableSound(new SampleInfo("nightcore-finish")), + hatSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-hat")), + clapSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-clap")), + kickSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-kick")), + finishSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-finish")), }; } diff --git a/osu.Game/Screens/Play/ComboEffects.cs b/osu.Game/Screens/Play/ComboEffects.cs index 5bcda50399..831b2f593c 100644 --- a/osu.Game/Screens/Play/ComboEffects.cs +++ b/osu.Game/Screens/Play/ComboEffects.cs @@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load(OsuConfigManager config) { - InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("combobreak")); + InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("Gameplay/combobreak")); alwaysPlay = config.GetBindable(OsuSetting.AlwaysPlayFirstComboBreak); } diff --git a/osu.Game/Screens/Play/PauseOverlay.cs b/osu.Game/Screens/Play/PauseOverlay.cs index 65f34aba3e..8778cff535 100644 --- a/osu.Game/Screens/Play/PauseOverlay.cs +++ b/osu.Game/Screens/Play/PauseOverlay.cs @@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); - AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop")) + AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("Gameplay/pause-loop")) { Looping = true, Volume = { Value = 0 } From 2ec2749cb49aec0683217116904fb1f526ea26a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 11:52:08 +0900 Subject: [PATCH 40/73] Fix taiko lookup logic --- osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs b/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs index a804ea5f82..c88480d18f 100644 --- a/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Taiko/Skinning/TaikoLegacySkinTransformer.cs @@ -162,7 +162,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning get { foreach (var name in source.LookupNames) - yield return $"taiko-{name}"; + yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-"); foreach (var name in source.LookupNames) yield return name; From fed4accfeab0100cdbcc3af7e292a1e408cf62c2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 12:12:30 +0900 Subject: [PATCH 41/73] Update tests to refect new mappings --- .../convert-samples-expected-conversion.json | 16 ++++++++-------- .../mania-samples-expected-conversion.json | 8 ++++---- ...er-convert-samples-expected-conversion.json | 6 +++--- .../Formats/LegacyBeatmapDecoderTest.cs | 18 +++++++++--------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json index d49ffa01c5..6f1d45ad8c 100644 --- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json +++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/convert-samples-expected-conversion.json @@ -6,20 +6,20 @@ "EndTime": 2750.0, "Column": 1, "NodeSamples": [ - ["normal-hitnormal"], - ["soft-hitnormal"], - ["drum-hitnormal"] + ["Gameplay/normal-hitnormal"], + ["Gameplay/soft-hitnormal"], + ["Gameplay/drum-hitnormal"] ], - "Samples": ["-hitnormal"] + "Samples": ["Gameplay/-hitnormal"] }, { "StartTime": 1875.0, "EndTime": 2750.0, "Column": 0, "NodeSamples": [ - ["soft-hitnormal"], - ["drum-hitnormal"] + ["Gameplay/soft-hitnormal"], + ["Gameplay/drum-hitnormal"] ], - "Samples": ["-hitnormal"] + "Samples": ["Gameplay/-hitnormal"] }] }, { "StartTime": 3750.0, @@ -27,7 +27,7 @@ "StartTime": 3750.0, "EndTime": 3750.0, "Column": 3, - "Samples": ["normal-hitnormal"] + "Samples": ["Gameplay/normal-hitnormal"] }] }] } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json index 1aca75a796..fd0c0cad60 100644 --- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json +++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/mania-samples-expected-conversion.json @@ -6,10 +6,10 @@ "EndTime": 1500.0, "Column": 0, "NodeSamples": [ - ["normal-hitnormal"], + ["Gameplay/normal-hitnormal"], [] ], - "Samples": ["normal-hitnormal"] + "Samples": ["Gameplay/normal-hitnormal"] }] }, { "StartTime": 2000.0, @@ -18,10 +18,10 @@ "EndTime": 3000.0, "Column": 2, "NodeSamples": [ - ["drum-hitnormal"], + ["Gameplay/drum-hitnormal"], [] ], - "Samples": ["drum-hitnormal"] + "Samples": ["Gameplay/drum-hitnormal"] }] }] } \ No newline at end of file diff --git a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json index e3768a90d7..e07bd3c47c 100644 --- a/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json +++ b/osu.Game.Rulesets.Mania/Resources/Testing/Beatmaps/slider-convert-samples-expected-conversion.json @@ -5,17 +5,17 @@ "StartTime": 8470.0, "EndTime": 8470.0, "Column": 0, - "Samples": ["normal-hitnormal", "normal-hitclap"] + "Samples": ["Gameplay/normal-hitnormal", "Gameplay/normal-hitclap"] }, { "StartTime": 8626.470587768974, "EndTime": 8626.470587768974, "Column": 1, - "Samples": ["normal-hitnormal"] + "Samples": ["Gameplay/normal-hitnormal"] }, { "StartTime": 8782.941175537948, "EndTime": 8782.941175537948, "Column": 2, - "Samples": ["normal-hitnormal", "normal-hitclap"] + "Samples": ["Gameplay/normal-hitnormal", "Gameplay/normal-hitclap"] }] }] } diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index b6e1af57fd..4b9e9dd88c 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -410,13 +410,13 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); // The control point at the end time of the slider should be applied - Assert.AreEqual("soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First()); + Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First()); } static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]); @@ -432,9 +432,9 @@ namespace osu.Game.Tests.Beatmaps.Formats { var hitObjects = decoder.Decode(stream).HitObjects; - Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); } static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]); @@ -452,7 +452,7 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); - Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); + Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume); } From b906736b85efdd9bdc739aab9fdeae74a5f43ad5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 12:28:40 +0900 Subject: [PATCH 42/73] Remove redundant initialisation --- osu.Game/Skinning/LegacySkin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index d927d54abc..4dea42cf92 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -417,7 +417,7 @@ namespace osu.Game.Skinning public override SampleChannel GetSample(ISampleInfo sampleInfo) { - IEnumerable lookupNames = null; + IEnumerable lookupNames; if (sampleInfo is HitSampleInfo hitSample) lookupNames = getLegacyLookupNames(hitSample); From f58f8e0f93a66d1553e63f151e9e63ddafe0475b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 13:46:54 +0900 Subject: [PATCH 43/73] Update resources --- osu.Android.props | 2 +- osu.Game/osu.Game.csproj | 2 +- osu.iOS.props | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Android.props b/osu.Android.props index 2d531cf01e..b3100d268b 100644 --- a/osu.Android.props +++ b/osu.Android.props @@ -51,7 +51,7 @@ - + diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index ca588b89d9..54f86e5839 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -27,7 +27,7 @@ - + diff --git a/osu.iOS.props b/osu.iOS.props index 9c22dec330..6100b55334 100644 --- a/osu.iOS.props +++ b/osu.iOS.props @@ -71,7 +71,7 @@ - + From a1fa6588f6a933c97551f78b98e21734f06e0c10 Mon Sep 17 00:00:00 2001 From: cadon0 Date: Sat, 31 Oct 2020 01:03:57 +1300 Subject: [PATCH 44/73] Fix "bounce" when metadata container text is empty --- osu.Game/Screens/Select/BeatmapDetails.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 0ee52f3e48..71f78c5c95 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -300,6 +300,7 @@ namespace osu.Game.Screens.Select public MetadataSection(string title) { + Alpha = 0; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; From bc69ed3870457e25e83b32879e3fc36982f4031d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Oct 2020 22:33:05 +0900 Subject: [PATCH 45/73] Simplify sample lookup --- osu.Game/Skinning/LegacySkin.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/osu.Game/Skinning/LegacySkin.cs b/osu.Game/Skinning/LegacySkin.cs index 4dea42cf92..fb020f4e39 100644 --- a/osu.Game/Skinning/LegacySkin.cs +++ b/osu.Game/Skinning/LegacySkin.cs @@ -446,21 +446,12 @@ namespace osu.Game.Skinning // for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin. // using .EndsWith() is intentional as it ensures parity in all edge cases // (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not). - foreach (var l in lookupNames) - { - if (!l.EndsWith(hitSample.Suffix, StringComparison.Ordinal)) - { - foreach (var n in getFallbackNames(l)) - yield return n; - } - } - } - else - { - foreach (var l in lookupNames) - yield return l; + lookupNames = lookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal)); } + foreach (var l in lookupNames) + yield return l; + // also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort. // going forward specifying banks shall always be required, even for elements that wouldn't require it on stable, // which is why this is done locally here. From 6a293dd536a9444a52ffd3de7c4992256e04bf64 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 31 Oct 2020 18:56:30 +0900 Subject: [PATCH 46/73] Add missing ctor parameters back --- osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs | 2 +- osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs index 1e87893f39..2af15923a0 100644 --- a/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs +++ b/osu.Game.Tests/Visual/Ranking/TestSceneAccuracyCircle.cs @@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Ranking } } }, - new AccuracyCircle(score) + new AccuracyCircle(score, true) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs index cb4560802b..711763330c 100644 --- a/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs +++ b/osu.Game/Screens/Ranking/Expanded/ExpandedPanelMiddleContent.cs @@ -120,7 +120,7 @@ namespace osu.Game.Screens.Ranking.Expanded Margin = new MarginPadding { Top = 40 }, RelativeSizeAxes = Axes.X, Height = 230, - Child = new AccuracyCircle(score) + Child = new AccuracyCircle(score, withFlair) { Anchor = Anchor.Centre, Origin = Anchor.Centre, From 129b1bc6d3dfcebb51e4e30a7f40d34b6dea9807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 11:35:25 +0100 Subject: [PATCH 47/73] Delete all selected objects if shift-clicked on one --- .../Edit/Compose/Components/SelectionHandler.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 01e23bafc5..92c75eae4f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -226,13 +226,21 @@ namespace osu.Game.Screens.Edit.Compose.Components internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state) { if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right)) - EditorBeatmap.Remove(blueprint.HitObject); + handleQuickDeletion(blueprint); else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left)) blueprint.ToggleSelection(); else ensureSelected(blueprint); } + private void handleQuickDeletion(SelectionBlueprint blueprint) + { + if (!blueprint.IsSelected) + EditorBeatmap.Remove(blueprint.HitObject); + else + deleteSelected(); + } + private void ensureSelected(SelectionBlueprint blueprint) { if (blueprint.IsSelected) From 003994ab7518cf821204a5ba417c9b9bb4c35ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 12:21:07 +0100 Subject: [PATCH 48/73] Bind UpdateVisibility() directly to source of truth --- .../Edit/Compose/Components/BlueprintContainer.cs | 9 +-------- .../Edit/Compose/Components/SelectionHandler.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 5ac360d029..fa98358dbe 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -210,10 +210,7 @@ namespace osu.Game.Screens.Edit.Compose.Components } if (DragBox.State == Visibility.Visible) - { DragBox.Hide(); - SelectionHandler.UpdateVisibility(); - } } protected override bool OnKeyDown(KeyDownEvent e) @@ -352,11 +349,7 @@ namespace osu.Game.Screens.Edit.Compose.Components /// /// Selects all s. /// - private void selectAll() - { - SelectionBlueprints.ToList().ForEach(m => m.Select()); - SelectionHandler.UpdateVisibility(); - } + private void selectAll() => SelectionBlueprints.ToList().ForEach(m => m.Select()); /// /// Deselects all selected s. diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 01e23bafc5..07ae283667 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -201,8 +201,6 @@ namespace osu.Game.Screens.Edit.Compose.Components // there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once. if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject)) EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject); - - UpdateVisibility(); } /// @@ -214,8 +212,6 @@ namespace osu.Game.Screens.Edit.Compose.Components selectedBlueprints.Remove(blueprint); EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject); - - UpdateVisibility(); } /// @@ -254,7 +250,7 @@ namespace osu.Game.Screens.Edit.Compose.Components /// /// Updates whether this is visible. /// - internal void UpdateVisibility() + private void updateVisibility() { int count = selectedBlueprints.Count; @@ -421,7 +417,11 @@ namespace osu.Game.Screens.Edit.Compose.Components // bring in updates from selection changes EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates(); - EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => UpdateTernaryStates(); + EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => + { + updateVisibility(); + UpdateTernaryStates(); + }; } /// From 3322b8a7ea03d97e3c18acf58965d0c7798d4ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 12:25:02 +0100 Subject: [PATCH 49/73] Run OnSelectionChanged() on each change --- .../Screens/Edit/Compose/Components/SelectionHandler.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 07ae283667..0547b15e3d 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -257,16 +257,15 @@ namespace osu.Game.Screens.Edit.Compose.Components selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty; if (count > 0) - { Show(); - OnSelectionChanged(); - } else Hide(); + + OnSelectionChanged(); } /// - /// Triggered whenever more than one object is selected, on each change. + /// Triggered whenever the set of selected objects changes. /// Should update the selection box's state to match supported operations. /// protected virtual void OnSelectionChanged() From d74c19e2d703f6e57139727692a3473ea7bd55fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 12:28:35 +0100 Subject: [PATCH 50/73] Shorten show/hide code --- .../Screens/Edit/Compose/Components/SelectionHandler.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 0547b15e3d..41098cc84c 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -256,11 +256,7 @@ namespace osu.Game.Screens.Edit.Compose.Components selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty; - if (count > 0) - Show(); - else - Hide(); - + this.FadeTo(count > 0 ? 1 : 0); OnSelectionChanged(); } From 007c27d3ffa987afdfc5c3502c27d4a89f8538fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 14:45:11 +0100 Subject: [PATCH 51/73] Schedule visibility update once per frame --- osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index 41098cc84c..5c1b41d848 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -414,7 +414,7 @@ namespace osu.Game.Screens.Edit.Compose.Components EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates(); EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => { - updateVisibility(); + Scheduler.AddOnce(updateVisibility); UpdateTernaryStates(); }; } From a9a3489e92b200d99c335cd52aab2c93e4cf3a17 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sat, 31 Oct 2020 22:51:31 +0900 Subject: [PATCH 52/73] Fix potential null reference when loading background As seen in https://discordapp.com/channels/188630481301012481/188630652340404224/772094427342569493. Caused due to async load of the loader, which means it may not be ready before Next() is called. --- osu.Game/Graphics/Backgrounds/SeasonalBackgroundLoader.cs | 1 - osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Graphics/Backgrounds/SeasonalBackgroundLoader.cs b/osu.Game/Graphics/Backgrounds/SeasonalBackgroundLoader.cs index 99f3a8a6e8..a48da37804 100644 --- a/osu.Game/Graphics/Backgrounds/SeasonalBackgroundLoader.cs +++ b/osu.Game/Graphics/Backgrounds/SeasonalBackgroundLoader.cs @@ -15,7 +15,6 @@ using osu.Game.Online.API.Requests.Responses; namespace osu.Game.Graphics.Backgrounds { - [LongRunningLoad] public class SeasonalBackgroundLoader : Component { /// diff --git a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs index 3f6210310f..8beb955824 100644 --- a/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs +++ b/osu.Game/Screens/Backgrounds/BackgroundScreenDefault.cs @@ -44,6 +44,8 @@ namespace osu.Game.Screens.Backgrounds mode = config.GetBindable(OsuSetting.MenuBackgroundSource); introSequence = config.GetBindable(OsuSetting.IntroSequence); + AddInternal(seasonalBackgroundLoader); + user.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next(); mode.ValueChanged += _ => Next(); @@ -53,7 +55,6 @@ namespace osu.Game.Screens.Backgrounds currentDisplay = RNG.Next(0, background_count); - LoadComponentAsync(seasonalBackgroundLoader); Next(); } From 2065680e9d1d12183c5493dfc639fff9b74ee97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 31 Oct 2020 17:01:45 +0100 Subject: [PATCH 53/73] Simplify test case --- .../Background/TestSceneSeasonalBackgroundLoader.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/Background/TestSceneSeasonalBackgroundLoader.cs b/osu.Game.Tests/Visual/Background/TestSceneSeasonalBackgroundLoader.cs index 8f5990aeb1..fba0d92d4b 100644 --- a/osu.Game.Tests/Visual/Background/TestSceneSeasonalBackgroundLoader.cs +++ b/osu.Game.Tests/Visual/Background/TestSceneSeasonalBackgroundLoader.cs @@ -149,18 +149,14 @@ namespace osu.Game.Tests.Visual.Background => AddStep($"set seasonal mode to {mode}", () => config.Set(OsuSetting.SeasonalBackgroundMode, mode)); private void createLoader() - { - AddStep("create loader", () => + => AddStep("create loader", () => { if (backgroundLoader != null) Remove(backgroundLoader); - LoadComponentAsync(backgroundLoader = new SeasonalBackgroundLoader(), Add); + Add(backgroundLoader = new SeasonalBackgroundLoader()); }); - AddUntilStep("wait for loaded", () => backgroundLoader.IsLoaded); - } - private void loadNextBackground() { SeasonalBackground background = null; From 6bfff436348cb48de3a2809d4b63b29fe8e0bce1 Mon Sep 17 00:00:00 2001 From: Lucas A Date: Sun, 1 Nov 2020 13:25:36 +0100 Subject: [PATCH 54/73] Extract StatisticCounter to a separate class and use it instead. --- .../Expanded/Statistics/CounterStatistic.cs | 20 +++------------ .../Statistics/PerformanceStatistic.cs | 16 +++++++++--- .../Expanded/Statistics/StatisticCounter.cs | 25 +++++++++++++++++++ 3 files changed, 41 insertions(+), 20 deletions(-) create mode 100644 osu.Game/Screens/Ranking/Expanded/Statistics/StatisticCounter.cs diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs index 08a9714fd8..d37f6c5e5f 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/CounterStatistic.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens.Ranking.Expanded.Accuracy; using osuTK; namespace osu.Game.Screens.Ranking.Expanded.Statistics @@ -19,7 +18,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics private readonly int count; private readonly int? maxCount; - protected RollingCounter Counter { get; private set; } + private RollingCounter counter; /// /// Creates a new . @@ -37,7 +36,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics public override void Appear() { base.Appear(); - Counter.Current.Value = count; + counter.Current.Value = count; } protected override Drawable CreateContent() @@ -46,7 +45,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, - Child = Counter = new StatisticCounter + Child = counter = new StatisticCounter { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre @@ -67,18 +66,5 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics return container; } - - private class StatisticCounter : RollingCounter - { - protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION; - - protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING; - - protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s => - { - s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true); - s.Spacing = new Vector2(-2, 0); - }); - } } } diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs index 1b4edb99d7..cd9d8005c6 100644 --- a/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/PerformanceStatistic.cs @@ -5,11 +5,13 @@ using System; using System.Threading; using osu.Framework.Allocation; using osu.Framework.Bindables; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; using osu.Game.Scoring; namespace osu.Game.Screens.Ranking.Expanded.Statistics { - public class PerformanceStatistic : CounterStatistic + public class PerformanceStatistic : StatisticDisplay { private readonly ScoreInfo score; @@ -17,8 +19,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); + private RollingCounter counter; + public PerformanceStatistic(ScoreInfo score) - : base("PP", 0) + : base("PP") { this.score = score; } @@ -46,7 +50,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics public override void Appear() { base.Appear(); - Counter.Current.BindTo(performance); + counter.Current.BindTo(performance); } protected override void Dispose(bool isDisposing) @@ -54,5 +58,11 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics cancellationTokenSource?.Cancel(); base.Dispose(isDisposing); } + + protected override Drawable CreateContent() => counter = new StatisticCounter + { + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre + }; } } diff --git a/osu.Game/Screens/Ranking/Expanded/Statistics/StatisticCounter.cs b/osu.Game/Screens/Ranking/Expanded/Statistics/StatisticCounter.cs new file mode 100644 index 0000000000..bbcfc43dc8 --- /dev/null +++ b/osu.Game/Screens/Ranking/Expanded/Statistics/StatisticCounter.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Ranking.Expanded.Accuracy; +using osuTK; + +namespace osu.Game.Screens.Ranking.Expanded.Statistics +{ + public class StatisticCounter : RollingCounter + { + protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION; + + protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING; + + protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s => + { + s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true); + s.Spacing = new Vector2(-2, 0); + }); + } +} From 8a54fdd4e6427b079f8d1f45205270d1f487b007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 14:25:33 +0100 Subject: [PATCH 55/73] Ensure LoadOszIntoOsu returns actual imported map --- osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 80fbda8e1d..b941313103 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -821,15 +821,13 @@ namespace osu.Game.Tests.Beatmaps.IO var manager = osu.Dependencies.Get(); - await manager.Import(temp); - - var imported = manager.GetAllUsableBeatmapSets(); + var importedSet = await manager.Import(temp); ensureLoaded(osu); waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000); - return imported.LastOrDefault(); + return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID); } private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu) From 5903c3be9066b6fd101abab48f4eebcb7421a50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 14:39:10 +0100 Subject: [PATCH 56/73] Fix inaccurate xmldoc --- osu.Game/Online/Spectator/SpectatorStreamingClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Spectator/SpectatorStreamingClient.cs b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs index 481c94e6f3..cb170ad298 100644 --- a/osu.Game/Online/Spectator/SpectatorStreamingClient.cs +++ b/osu.Game/Online/Spectator/SpectatorStreamingClient.cs @@ -70,7 +70,7 @@ namespace osu.Game.Online.Spectator public event Action OnUserBeganPlaying; /// - /// Called whenever a user starts a play session. + /// Called whenever a user finishes a play session. /// public event Action OnUserFinishedPlaying; From b7696c85ad5a42c7c35902579765c4c04c79bffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 15:21:24 +0100 Subject: [PATCH 57/73] Add more xmldocs --- osu.Game/Rulesets/UI/IFrameStableClock.cs | 3 +++ osu.Game/Screens/Play/GameplayClockContainer.cs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/osu.Game/Rulesets/UI/IFrameStableClock.cs b/osu.Game/Rulesets/UI/IFrameStableClock.cs index c1d8733d26..569ef5e06c 100644 --- a/osu.Game/Rulesets/UI/IFrameStableClock.cs +++ b/osu.Game/Rulesets/UI/IFrameStableClock.cs @@ -10,6 +10,9 @@ namespace osu.Game.Rulesets.UI { IBindable IsCatchingUp { get; } + /// + /// Whether the frame stable clock is waiting on new frames to arrive to be able to progress time. + /// IBindable WaitingOnFrames { get; } } } diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index 6154ec67b8..2c83161614 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -63,6 +63,14 @@ namespace osu.Game.Screens.Play private readonly FramedOffsetClock platformOffsetClock; + /// + /// Creates a new . + /// + /// The beatmap being played. + /// The suggested time to start gameplay at. + /// + /// Whether should be used regardless of when storyboard events and hitobjects are supposed to start. + /// public GameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false) { this.beatmap = beatmap; From 716458344fa374a7b83cbeb64b448d4dd046961d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 16:03:28 +0100 Subject: [PATCH 58/73] Ensure spectator player is unsubscribed to prevent leak --- osu.Game/Screens/Play/SpectatorPlayer.cs | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index fbd21b32ba..6c1e83f236 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -26,12 +26,6 @@ namespace osu.Game.Screens.Play spectatorStreaming.OnUserBeganPlaying += userBeganPlaying; } - private void userBeganPlaying(int userId, SpectatorState state) - { - if (userId == Score.ScoreInfo.UserID) - Schedule(this.Exit); - } - protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) { // if we already have frames, start gameplay at the point in time they exist, should they be too far into the beatmap. @@ -42,5 +36,25 @@ namespace osu.Game.Screens.Play return new GameplayClockContainer(beatmap, firstFrameTime.Value, true); } + + public override bool OnExiting(IScreen next) + { + spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying; + return base.OnExiting(next); + } + + protected override void Dispose(bool isDisposing) + { + base.Dispose(isDisposing); + + if (spectatorStreaming != null) + spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying; + } + + private void userBeganPlaying(int userId, SpectatorState state) + { + if (userId == Score.ScoreInfo.UserID) + Schedule(this.Exit); + } } } From 6ff13e399ad66d7bf898630efafb8851e625c688 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2020 17:14:13 +0000 Subject: [PATCH 59/73] Bump Microsoft.CodeAnalysis.FxCopAnalyzers from 3.0.0 to 3.3.1 Bumps [Microsoft.CodeAnalysis.FxCopAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 3.0.0 to 3.3.1. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v3.0.0...v3.3.1) Signed-off-by: dependabot-preview[bot] --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2d3478f256..186b2049c6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,7 +18,7 @@ - + $(MSBuildThisFileDirectory)CodeAnalysis\osu.ruleset From 6e9ed76251ea86fbc6f216953d964ae0ccc61f62 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2020 17:14:57 +0000 Subject: [PATCH 60/73] Bump Microsoft.Build.Traversal from 2.1.1 to 2.2.3 Bumps [Microsoft.Build.Traversal](https://github.com/Microsoft/MSBuildSdks) from 2.1.1 to 2.2.3. - [Release notes](https://github.com/Microsoft/MSBuildSdks/releases) - [Changelog](https://github.com/microsoft/MSBuildSdks/blob/master/RELEASE.md) - [Commits](https://github.com/Microsoft/MSBuildSdks/compare/Microsoft.Build.Traversal.2.1.1...Microsoft.Build.Traversal.2.2.3) Signed-off-by: dependabot-preview[bot] --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index a9a531f59c..10b61047ac 100644 --- a/global.json +++ b/global.json @@ -5,6 +5,6 @@ "version": "3.1.100" }, "msbuild-sdks": { - "Microsoft.Build.Traversal": "2.1.1" + "Microsoft.Build.Traversal": "2.2.3" } } \ No newline at end of file From 79e610d31b9017e9d13e82fd704a32fc72c5e768 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 1 Nov 2020 17:15:23 +0000 Subject: [PATCH 61/73] Bump Microsoft.CodeAnalysis.BannedApiAnalyzers from 3.3.0 to 3.3.1 Bumps [Microsoft.CodeAnalysis.BannedApiAnalyzers](https://github.com/dotnet/roslyn-analyzers) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/dotnet/roslyn-analyzers/releases) - [Changelog](https://github.com/dotnet/roslyn-analyzers/blob/master/PostReleaseActivities.md) - [Commits](https://github.com/dotnet/roslyn-analyzers/compare/v3.3.0...v3.3.1) Signed-off-by: dependabot-preview[bot] --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 2d3478f256..056216f14b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,7 +16,7 @@ - + From 2b0bea535efa58df11a2ac216742a2a8521e3e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 18:47:40 +0100 Subject: [PATCH 62/73] Resolve CA1805 inspections "Member is explicitly initialized to its default value" --- osu.Game/Database/DatabaseWriteUsage.cs | 2 +- osu.Game/Graphics/Containers/OsuScrollContainer.cs | 2 +- osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs | 2 +- osu.Game/Tests/Visual/PlayerTestScene.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Database/DatabaseWriteUsage.cs b/osu.Game/Database/DatabaseWriteUsage.cs index 1fd2f23d50..ddafd77066 100644 --- a/osu.Game/Database/DatabaseWriteUsage.cs +++ b/osu.Game/Database/DatabaseWriteUsage.cs @@ -26,7 +26,7 @@ namespace osu.Game.Database /// Whether this write usage will commit a transaction on completion. /// If false, there is a parent usage responsible for transaction commit. /// - public bool IsTransactionLeader = false; + public bool IsTransactionLeader; protected void Dispose(bool disposing) { diff --git a/osu.Game/Graphics/Containers/OsuScrollContainer.cs b/osu.Game/Graphics/Containers/OsuScrollContainer.cs index ed5c73bee6..b9122d254d 100644 --- a/osu.Game/Graphics/Containers/OsuScrollContainer.cs +++ b/osu.Game/Graphics/Containers/OsuScrollContainer.cs @@ -21,7 +21,7 @@ namespace osu.Game.Graphics.Containers /// Allows controlling the scroll bar from any position in the container using the right mouse button. /// Uses the value of to smoothly scroll to the dragged location. /// - public bool RightMouseScrollbar = false; + public bool RightMouseScrollbar; /// /// Controls the rate with which the target position is approached when performing a relative drag. Default is 0.02. diff --git a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs index cf5c88b8fd..b671f4c68c 100644 --- a/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs +++ b/osu.Game/Rulesets/Replays/FramedReplayInputHandler.cs @@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Replays /// When set, we will ensure frames executed by nested drawables are frame-accurate to replay data. /// Disabling this can make replay playback smoother (useful for autoplay, currently). /// - public bool FrameAccuratePlayback = false; + public bool FrameAccuratePlayback; protected bool HasFrames => Frames.Count > 0; diff --git a/osu.Game/Tests/Visual/PlayerTestScene.cs b/osu.Game/Tests/Visual/PlayerTestScene.cs index aa3bd2e4b7..088e997de9 100644 --- a/osu.Game/Tests/Visual/PlayerTestScene.cs +++ b/osu.Game/Tests/Visual/PlayerTestScene.cs @@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual /// /// Whether custom test steps are provided. Custom tests should invoke to create the test steps. /// - protected virtual bool HasCustomSteps { get; } = false; + protected virtual bool HasCustomSteps => false; protected TestPlayer Player; From ca5de22ca5d8047424958eab6975b17056917055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 18:49:11 +0100 Subject: [PATCH 63/73] Resolve CA1834 inspection "Use `StringBuilder.Append(char)` instead of `StringBuilder.Append(string)` when the input is a constant unit string" --- osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index 80a4d6dea4..80fd6c22bb 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -417,7 +417,7 @@ namespace osu.Game.Beatmaps.Formats string sampleFilename = samples.FirstOrDefault(s => string.IsNullOrEmpty(s.Name))?.LookupNames.First() ?? string.Empty; int volume = samples.FirstOrDefault()?.Volume ?? 100; - sb.Append(":"); + sb.Append(':'); sb.Append(FormattableString.Invariant($"{customSampleBank}:")); sb.Append(FormattableString.Invariant($"{volume}:")); sb.Append(FormattableString.Invariant($"{sampleFilename}")); From 89bf7b1bd669d83e57b6f299b0489e8cd950b1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 18:51:39 +0100 Subject: [PATCH 64/73] Resolve CA1835 inspection "Change the `ReadAsync` method call to use the `Stream.ReadAsync(Memory, CancellationToken)` overload" --- osu.Game/IO/Archives/ArchiveReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/IO/Archives/ArchiveReader.cs b/osu.Game/IO/Archives/ArchiveReader.cs index a30f961daf..f74574e60c 100644 --- a/osu.Game/IO/Archives/ArchiveReader.cs +++ b/osu.Game/IO/Archives/ArchiveReader.cs @@ -41,7 +41,7 @@ namespace osu.Game.IO.Archives return null; byte[] buffer = new byte[input.Length]; - await input.ReadAsync(buffer, 0, buffer.Length); + await input.ReadAsync(buffer); return buffer; } } From 3090b6ccb5eed7b77868cf508b2cf48832f6d0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 18:54:44 +0100 Subject: [PATCH 65/73] Resolve CA2249 inspections "Use `string.Contains` instead of `string.IndexOf` to improve readability" --- osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs | 2 +- osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs | 2 +- osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs | 2 +- osu.Game/Screens/Select/FilterCriteria.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs index e2550d1ca4..8d8ca523d5 100644 --- a/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyStoryboardDecoder.cs @@ -347,7 +347,7 @@ namespace osu.Game.Beatmaps.Formats /// The line which may contains variables. private void decodeVariables(ref string line) { - while (line.IndexOf('$') >= 0) + while (line.Contains('$')) { string origLine = line; diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs index 60c6aa1d8a..c7c37cbc0d 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomsContainer.cs @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components matchingFilter &= r.Room.Playlist.Count == 0 || r.Room.Playlist.Any(i => i.Ruleset.Value.Equals(criteria.Ruleset)); if (!string.IsNullOrEmpty(criteria.SearchString)) - matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0); + matchingFilter &= r.FilterTerms.Any(term => term.Contains(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase)); r.MatchingFilter = matchingFilter; } diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index dce4028f17..1aab50037a 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -59,7 +59,7 @@ namespace osu.Game.Screens.Select.Carousel var terms = Beatmap.SearchableTerms; foreach (var criteriaTerm in criteria.SearchTerms) - match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0); + match &= terms.Any(term => term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase)); // if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs. // this should be done after text matching so we can prioritise matching numbers in metadata. diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index f34f8f6505..7bddb3e51b 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -126,7 +126,7 @@ namespace osu.Game.Screens.Select if (string.IsNullOrEmpty(value)) return false; - return value.IndexOf(SearchTerm, StringComparison.InvariantCultureIgnoreCase) >= 0; + return value.Contains(SearchTerm, StringComparison.InvariantCultureIgnoreCase); } public string SearchTerm; From 164370bc7da7ed6dfe08507eec0fbafc32cffd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 20:51:23 +0100 Subject: [PATCH 66/73] Resolve more CA1805 inspections --- osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs | 7 +++++-- osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs | 4 ++-- .../Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs | 2 +- .../Visual/SongSelect/TestSceneBeatmapInfoWedge.cs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs index 937473e824..6841ecd23c 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModBlinds.cs @@ -64,8 +64,8 @@ namespace osu.Game.Rulesets.Osu.Mods /// private const float target_clamp = 1; - private readonly float targetBreakMultiplier = 0; - private readonly float easing = 1; + private readonly float targetBreakMultiplier; + private readonly float easing; private readonly CompositeDrawable restrictTo; @@ -86,6 +86,9 @@ namespace osu.Game.Rulesets.Osu.Mods { this.restrictTo = restrictTo; this.beatmap = beatmap; + + targetBreakMultiplier = 0; + easing = 1; } [BackgroundDependencyLoader] diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs index 58cc324233..de46f9d1cf 100644 --- a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs +++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs @@ -81,8 +81,8 @@ namespace osu.Game.Tests.Gameplay private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation { - public bool NewCombo { get; set; } = false; - public int ComboOffset { get; } = 0; + public bool NewCombo { get; set; } + public int ComboOffset => 0; public Bindable IndexInCurrentComboBindable { get; } = new Bindable(); diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs index fdc20dc477..07ff56b5c3 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMatchSettingsOverlay.cs @@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.Multiplayer public Bindable InitialRoomsReceived { get; } = new Bindable(true); - public IBindableList Rooms { get; } = null; + public IBindableList Rooms => null; public void CreateRoom(Room room, Action onSuccess = null, Action onError = null) { diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs index e02ebf3be1..0b2c0ce63b 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapInfoWedge.cs @@ -197,8 +197,8 @@ namespace osu.Game.Tests.Visual.SongSelect private class TestHitObject : ConvertHitObject, IHasPosition { - public float X { get; } = 0; - public float Y { get; } = 0; + public float X => 0; + public float Y => 0; public Vector2 Position { get; } = Vector2.Zero; } } From 432282e8de8fb62a50fd2fef4de3f77047889e65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 1 Nov 2020 21:22:04 +0100 Subject: [PATCH 67/73] Use alternative solution to avoid storing last zoom --- .../Timeline/TimelineBlueprintContainer.cs | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs index 008da14a21..10913a8bb9 100644 --- a/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/Timeline/TimelineBlueprintContainer.cs @@ -9,10 +9,10 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Shapes; using osu.Framework.Input.Events; +using osu.Framework.Utils; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Objects; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; -using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Edit.Compose.Components.Timeline @@ -107,7 +107,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline OnDragHandled = handleScrollViaDrag }; - protected override DragBox CreateDragBox(Action performSelect) => new TimelineDragBox(performSelect, this); + protected override DragBox CreateDragBox(Action performSelect) => new TimelineDragBox(performSelect); private void handleScrollViaDrag(DragEvent e) { @@ -137,17 +137,18 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline private class TimelineDragBox : DragBox { - private Vector2 lastMouseDown; + // the following values hold the start and end X positions of the drag box in the timeline's local space, + // but with zoom unapplied in order to be able to compensate for positional changes + // while the timeline is being zoomed in/out. + private float? selectionStart; + private float selectionEnd; - private float? lastZoom; - private float localMouseDown; + [Resolved] + private Timeline timeline { get; set; } - private readonly TimelineBlueprintContainer parent; - - public TimelineDragBox(Action performSelect, TimelineBlueprintContainer parent) + public TimelineDragBox(Action performSelect) : base(performSelect) { - this.parent = parent; } protected override Drawable CreateBox() => new Box @@ -158,27 +159,34 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline public override bool HandleDrag(MouseButtonEvent e) { - // store the original position of the mouse down, as we may be scrolled during selection. - if (lastMouseDown != e.ScreenSpaceMouseDownPosition) - { - lastMouseDown = e.ScreenSpaceMouseDownPosition; - localMouseDown = e.MouseDownPosition.X; - lastZoom = null; - } + selectionStart ??= e.MouseDownPosition.X / timeline.CurrentZoom; - //Zooming the timeline shifts the coordinate system. zoomCorrection compensates for that - float zoomCorrection = lastZoom.HasValue ? (parent.timeline.CurrentZoom / lastZoom.Value) : 1; - localMouseDown *= zoomCorrection; - lastZoom = parent.timeline.CurrentZoom; + // only calculate end when a transition is not in progress to avoid bouncing. + if (Precision.AlmostEquals(timeline.CurrentZoom, timeline.Zoom)) + selectionEnd = e.MousePosition.X / timeline.CurrentZoom; - float selection1 = localMouseDown; - float selection2 = e.MousePosition.X * zoomCorrection; + updateDragBoxPosition(); + return true; + } - Box.X = Math.Min(selection1, selection2); - Box.Width = Math.Abs(selection1 - selection2); + private void updateDragBoxPosition() + { + if (selectionStart == null) + return; + + float rescaledStart = selectionStart.Value * timeline.CurrentZoom; + float rescaledEnd = selectionEnd * timeline.CurrentZoom; + + Box.X = Math.Min(rescaledStart, rescaledEnd); + Box.Width = Math.Abs(rescaledStart - rescaledEnd); PerformSelection?.Invoke(Box.ScreenSpaceDrawQuad.AABBFloat); - return true; + } + + public override void Hide() + { + base.Hide(); + selectionStart = null; } } From 71d55f16f3853f3e9f3cc56bb4cf981d957e9840 Mon Sep 17 00:00:00 2001 From: Joehu Date: Sun, 1 Nov 2020 13:50:38 -0800 Subject: [PATCH 68/73] Fix edit beatmap options button not resuming back to song select --- osu.Game/Screens/Select/PlaySongSelect.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/PlaySongSelect.cs b/osu.Game/Screens/Select/PlaySongSelect.cs index 19769f487d..ee8825640c 100644 --- a/osu.Game/Screens/Select/PlaySongSelect.cs +++ b/osu.Game/Screens/Select/PlaySongSelect.cs @@ -32,11 +32,7 @@ namespace osu.Game.Screens.Select [BackgroundDependencyLoader] private void load(OsuColour colours) { - BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => - { - ValidForResume = false; - Edit(); - }); + BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit()); ((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += PresentScore; } From bfa6ae1b66eb38c9c77f4f163c3cb0c3b82a98d9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 14:24:17 +0900 Subject: [PATCH 69/73] Fix taiko drum not correct handling sample / group point changes Closes https://github.com/ppy/osu/issues/10642 --- .../Audio/DrumSampleContainer.cs | 79 ++++++++++++++----- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs index fcf7c529f5..fd6eca3850 100644 --- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs +++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs @@ -2,6 +2,9 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Audio; using osu.Game.Beatmaps.ControlPoints; @@ -18,9 +21,24 @@ namespace osu.Game.Rulesets.Taiko.Audio private readonly ControlPointInfo controlPoints; private readonly Dictionary mappings = new Dictionary(); + private IBindableList groups; + public DrumSampleContainer(ControlPointInfo controlPoints) { this.controlPoints = controlPoints; + } + + [BackgroundDependencyLoader] + private void load() + { + groups = controlPoints.Groups.GetBoundCopy(); + groups.BindCollectionChanged((_, __) => recreateMappings(), true); + } + + private void recreateMappings() + { + mappings.Clear(); + ClearInternal(); IReadOnlyList samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints; @@ -28,37 +46,56 @@ namespace osu.Game.Rulesets.Taiko.Audio { var samplePoint = samplePoints[i]; - var centre = samplePoint.GetSampleInfo(); - var rim = samplePoint.GetSampleInfo(HitSampleInfo.HIT_CLAP); - var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue; var lifetimeEnd = i + 1 < samplePoints.Count ? samplePoints[i + 1].Time : double.MaxValue; - mappings[samplePoint.Time] = new DrumSample + AddInternal(mappings[samplePoint.Time] = new DrumSample(samplePoint) { - Centre = addSound(centre, lifetimeStart, lifetimeEnd), - Rim = addSound(rim, lifetimeStart, lifetimeEnd) - }; + LifetimeStart = lifetimeStart, + LifetimeEnd = lifetimeEnd + }); } } - private PausableSkinnableSound addSound(HitSampleInfo hitSampleInfo, double lifetimeStart, double lifetimeEnd) - { - var drawable = new PausableSkinnableSound(hitSampleInfo) - { - LifetimeStart = lifetimeStart, - LifetimeEnd = lifetimeEnd - }; - AddInternal(drawable); - return drawable; - } - public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time]; - public class DrumSample + public class DrumSample : CompositeDrawable { - public PausableSkinnableSound Centre; - public PausableSkinnableSound Rim; + public override bool RemoveWhenNotAlive => false; + + public PausableSkinnableSound Centre { get; private set; } + public PausableSkinnableSound Rim { get; private set; } + + private readonly SampleControlPoint samplePoint; + + private Bindable sampleBank; + private BindableNumber sampleVolume; + + public DrumSample(SampleControlPoint samplePoint) + { + this.samplePoint = samplePoint; + } + + [BackgroundDependencyLoader] + private void load() + { + sampleBank = samplePoint.SampleBankBindable.GetBoundCopy(); + sampleBank.BindValueChanged(_ => recreate()); + + sampleVolume = samplePoint.SampleVolumeBindable.GetBoundCopy(); + sampleVolume.BindValueChanged(_ => recreate()); + + recreate(); + } + + private void recreate() + { + InternalChildren = new Drawable[] + { + Centre = new PausableSkinnableSound(samplePoint.GetSampleInfo()), + Rim = new PausableSkinnableSound(samplePoint.GetSampleInfo(HitSampleInfo.HIT_CLAP)) + }; + } } } } From 3adf451e8277a8862e2221cda8000acc37938b8e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 14:39:01 +0900 Subject: [PATCH 70/73] Handle changes via SamplePoints list for simplicity --- .../Audio/DrumSampleContainer.cs | 17 ++++++++++------- .../Beatmaps/ControlPoints/ControlPointInfo.cs | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs b/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs index fd6eca3850..4a3dc58604 100644 --- a/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs +++ b/osu.Game.Rulesets.Taiko/Audio/DrumSampleContainer.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System.Collections.Generic; +using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; @@ -21,7 +22,7 @@ namespace osu.Game.Rulesets.Taiko.Audio private readonly ControlPointInfo controlPoints; private readonly Dictionary mappings = new Dictionary(); - private IBindableList groups; + private IBindableList samplePoints; public DrumSampleContainer(ControlPointInfo controlPoints) { @@ -31,8 +32,8 @@ namespace osu.Game.Rulesets.Taiko.Audio [BackgroundDependencyLoader] private void load() { - groups = controlPoints.Groups.GetBoundCopy(); - groups.BindCollectionChanged((_, __) => recreateMappings(), true); + samplePoints = controlPoints.SamplePoints.GetBoundCopy(); + samplePoints.BindCollectionChanged((_, __) => recreateMappings(), true); } private void recreateMappings() @@ -40,14 +41,16 @@ namespace osu.Game.Rulesets.Taiko.Audio mappings.Clear(); ClearInternal(); - IReadOnlyList samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints; + SampleControlPoint[] points = samplePoints.Count == 0 + ? new[] { controlPoints.SamplePointAt(double.MinValue) } + : samplePoints.ToArray(); - for (int i = 0; i < samplePoints.Count; i++) + for (int i = 0; i < points.Length; i++) { - var samplePoint = samplePoints[i]; + var samplePoint = points[i]; var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue; - var lifetimeEnd = i + 1 < samplePoints.Count ? samplePoints[i + 1].Time : double.MaxValue; + var lifetimeEnd = i + 1 < points.Length ? points[i + 1].Time : double.MaxValue; AddInternal(mappings[samplePoint.Time] = new DrumSample(samplePoint) { diff --git a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs index 22314f28c7..b843aad950 100644 --- a/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs +++ b/osu.Game/Beatmaps/ControlPoints/ControlPointInfo.cs @@ -41,9 +41,9 @@ namespace osu.Game.Beatmaps.ControlPoints /// All sound points. /// [JsonProperty] - public IReadOnlyList SamplePoints => samplePoints; + public IBindableList SamplePoints => samplePoints; - private readonly SortedList samplePoints = new SortedList(Comparer.Default); + private readonly BindableList samplePoints = new BindableList(); /// /// All effect points. From fb105a1e9c23de90db8c9f5783c79bf4c821b4ed Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 14:49:25 +0900 Subject: [PATCH 71/73] Remove unnecessary field storage --- osu.Game/OsuGameBase.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 4db057dccc..4bc54e7e83 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -59,8 +59,6 @@ namespace osu.Game protected ScoreManager ScoreManager; - protected ScorePerformanceManager ScorePerformanceManager; - protected BeatmapDifficultyManager DifficultyManager; protected SkinManager SkinManager; @@ -231,8 +229,9 @@ namespace osu.Game dependencies.Cache(DifficultyManager = new BeatmapDifficultyManager()); AddInternal(DifficultyManager); - dependencies.Cache(ScorePerformanceManager = new ScorePerformanceManager()); - AddInternal(ScorePerformanceManager); + var scorePerformanceManager = new ScorePerformanceManager(); + dependencies.Cache(scorePerformanceManager); + AddInternal(scorePerformanceManager); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); From d46f7535c949fdd097e66f09860d2a6618770ed9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 14:50:44 +0900 Subject: [PATCH 72/73] Add xmldoc for new component --- osu.Game/Scoring/ScorePerformanceManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index 746aa67a55..b63443180f 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -12,6 +12,9 @@ using osu.Game.Beatmaps; namespace osu.Game.Scoring { + /// + /// A global component which calculates and caches results of performance calculations for locally databased scores. + /// public class ScorePerformanceManager : Component { private readonly ConcurrentDictionary performanceCache = new ConcurrentDictionary(); From 7b320a991fd45b24d469ceb904e5c7269abfdfdd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 14:51:19 +0900 Subject: [PATCH 73/73] Add note about missing expiration logic --- osu.Game/Scoring/ScorePerformanceManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Scoring/ScorePerformanceManager.cs b/osu.Game/Scoring/ScorePerformanceManager.cs index b63443180f..ddda1b99af 100644 --- a/osu.Game/Scoring/ScorePerformanceManager.cs +++ b/osu.Game/Scoring/ScorePerformanceManager.cs @@ -17,6 +17,8 @@ namespace osu.Game.Scoring /// public class ScorePerformanceManager : Component { + // this cache will grow indefinitely per session and should be considered temporary. + // this whole component should likely be replaced with database persistence. private readonly ConcurrentDictionary performanceCache = new ConcurrentDictionary(); [Resolved]