From d2c86b0813d41ddd01ce4cbc00906f94271bfbf2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 29 May 2024 21:32:52 +0900 Subject: [PATCH] Avoid passing beatmap in from editor when it's already present --- osu.Game/Screens/Edit/Editor.cs | 2 +- .../Screens/Edit/GameplayTest/EditorPlayer.cs | 32 +++++++++++-------- .../Edit/GameplayTest/EditorPlayerLoader.cs | 5 ++- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/osu.Game/Screens/Edit/Editor.cs b/osu.Game/Screens/Edit/Editor.cs index 2954d7dcaa..07c32983f5 100644 --- a/osu.Game/Screens/Edit/Editor.cs +++ b/osu.Game/Screens/Edit/Editor.cs @@ -452,7 +452,7 @@ namespace osu.Game.Screens.Edit pushEditorPlayer(); } - void pushEditorPlayer() => this.Push(new EditorPlayerLoader(this, playableBeatmap)); + void pushEditorPlayer() => this.Push(new EditorPlayerLoader(this)); } /// diff --git a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs index 42eb57c253..c327ae185d 100644 --- a/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs +++ b/osu.Game/Screens/Edit/GameplayTest/EditorPlayer.cs @@ -21,19 +21,17 @@ namespace osu.Game.Screens.Edit.GameplayTest { private readonly Editor editor; private readonly EditorState editorState; - private readonly IBeatmap playableBeatmap; protected override UserActivity InitialActivity => new UserActivity.TestingBeatmap(Beatmap.Value.BeatmapInfo); [Resolved] private MusicController musicController { get; set; } = null!; - public EditorPlayer(Editor editor, IBeatmap playableBeatmap) + public EditorPlayer(Editor editor) : base(new PlayerConfiguration { ShowResults = false }) { this.editor = editor; editorState = editor.GetState(); - this.playableBeatmap = playableBeatmap; } protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) @@ -52,17 +50,7 @@ namespace osu.Game.Screens.Edit.GameplayTest { base.LoadComplete(); - var frame = new ReplayFrame { Header = new FrameHeader(new ScoreInfo(), new ScoreProcessorStatistics()) }; - - foreach (var hitObject in enumerateHitObjects(playableBeatmap.HitObjects.Where(h => h.StartTime < editorState.Time))) - { - var judgement = hitObject.CreateJudgement(); - frame.Header.Statistics.TryAdd(judgement.MaxResult, 0); - frame.Header.Statistics[judgement.MaxResult]++; - } - - HealthProcessor.ResetFromReplayFrame(frame); - ScoreProcessor.ResetFromReplayFrame(frame); + markPreviousObjectsHit(); ScoreProcessor.HasCompleted.BindValueChanged(completed => { @@ -75,6 +63,22 @@ namespace osu.Game.Screens.Edit.GameplayTest }, RESULTS_DISPLAY_DELAY); } }); + } + + private void markPreviousObjectsHit() + { + var frame = new ReplayFrame { Header = new FrameHeader(new ScoreInfo(), new ScoreProcessorStatistics()) }; + + foreach (var hitObject in enumerateHitObjects(DrawableRuleset.Objects.Where(h => h.StartTime < editorState.Time))) + { + var judgement = hitObject.CreateJudgement(); + + frame.Header.Statistics.TryAdd(judgement.MaxResult, 0); + frame.Header.Statistics[judgement.MaxResult]++; + } + + HealthProcessor.ResetFromReplayFrame(frame); + ScoreProcessor.ResetFromReplayFrame(frame); static IEnumerable enumerateHitObjects(IEnumerable hitObjects) { diff --git a/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs b/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs index c62b8cafb8..bb151e4a45 100644 --- a/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs +++ b/osu.Game/Screens/Edit/GameplayTest/EditorPlayerLoader.cs @@ -4,7 +4,6 @@ using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Screens; -using osu.Game.Beatmaps; using osu.Game.Screens.Menu; using osu.Game.Screens.Play; @@ -15,8 +14,8 @@ namespace osu.Game.Screens.Edit.GameplayTest [Resolved] private OsuLogo osuLogo { get; set; } = null!; - public EditorPlayerLoader(Editor editor, IBeatmap playableBeatmap) - : base(() => new EditorPlayer(editor, playableBeatmap)) + public EditorPlayerLoader(Editor editor) + : base(() => new EditorPlayer(editor)) { }