mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 17:52:54 +08:00
Merge pull request #26465 from LeNitrous/fix/editor-test-exit
Fix editor test play not marking hit objects before its start time as judged.
This commit is contained in:
commit
81c6da98c2
@ -126,6 +126,24 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value);
|
AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestCase(2000)] // chosen to be after last object in the map
|
||||||
|
[TestCase(22000)] // chosen to be in the middle of the last spinner
|
||||||
|
public void TestGameplayTestAtEndOfBeatmap(int offsetFromEnd)
|
||||||
|
{
|
||||||
|
AddStep($"seek to end minus {offsetFromEnd}ms", () => EditorClock.Seek(importedBeatmapSet.MaxLength - offsetFromEnd));
|
||||||
|
AddStep("click test gameplay button", () =>
|
||||||
|
{
|
||||||
|
var button = Editor.ChildrenOfType<TestGameplayButton>().Single();
|
||||||
|
|
||||||
|
InputManager.MoveMouseTo(button);
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("player pushed", () => Stack.CurrentScreen is EditorPlayer);
|
||||||
|
|
||||||
|
AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCancelGameplayTestWithUnsavedChanges()
|
public void TestCancelGameplayTestWithUnsavedChanges()
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
|
||||||
@ -43,6 +46,10 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
markPreviousObjectsHit();
|
||||||
|
markVisibleDrawableObjectsHit();
|
||||||
|
|
||||||
ScoreProcessor.HasCompleted.BindValueChanged(completed =>
|
ScoreProcessor.HasCompleted.BindValueChanged(completed =>
|
||||||
{
|
{
|
||||||
if (completed.NewValue)
|
if (completed.NewValue)
|
||||||
@ -56,6 +63,69 @@ namespace osu.Game.Screens.Edit.GameplayTest
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void markPreviousObjectsHit()
|
||||||
|
{
|
||||||
|
foreach (var hitObject in enumerateHitObjects(DrawableRuleset.Objects, editorState.Time))
|
||||||
|
{
|
||||||
|
var judgement = hitObject.Judgement;
|
||||||
|
var result = new JudgementResult(hitObject, judgement) { Type = judgement.MaxResult };
|
||||||
|
|
||||||
|
HealthProcessor.ApplyResult(result);
|
||||||
|
ScoreProcessor.ApplyResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<HitObject> enumerateHitObjects(IEnumerable<HitObject> hitObjects, double cutoffTime)
|
||||||
|
{
|
||||||
|
foreach (var hitObject in hitObjects)
|
||||||
|
{
|
||||||
|
foreach (var nested in enumerateHitObjects(hitObject.NestedHitObjects, cutoffTime))
|
||||||
|
{
|
||||||
|
if (nested.GetEndTime() < cutoffTime)
|
||||||
|
yield return nested;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hitObject.GetEndTime() < cutoffTime)
|
||||||
|
yield return hitObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markVisibleDrawableObjectsHit()
|
||||||
|
{
|
||||||
|
if (!DrawableRuleset.Playfield.IsLoaded)
|
||||||
|
{
|
||||||
|
Schedule(markVisibleDrawableObjectsHit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var drawableObjectEntry in enumerateDrawableEntries(
|
||||||
|
DrawableRuleset.Playfield.AllHitObjects
|
||||||
|
.Select(ho => ho.Entry)
|
||||||
|
.Where(e => e != null)
|
||||||
|
.Cast<HitObjectLifetimeEntry>(), editorState.Time))
|
||||||
|
{
|
||||||
|
drawableObjectEntry.Result = new JudgementResult(drawableObjectEntry.HitObject, drawableObjectEntry.HitObject.Judgement)
|
||||||
|
{
|
||||||
|
Type = drawableObjectEntry.HitObject.Judgement.MaxResult
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static IEnumerable<HitObjectLifetimeEntry> enumerateDrawableEntries(IEnumerable<HitObjectLifetimeEntry> entries, double cutoffTime)
|
||||||
|
{
|
||||||
|
foreach (var entry in entries)
|
||||||
|
{
|
||||||
|
foreach (var nested in enumerateDrawableEntries(entry.NestedEntries, cutoffTime))
|
||||||
|
{
|
||||||
|
if (nested.HitObject.GetEndTime() < cutoffTime)
|
||||||
|
yield return nested;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.HitObject.GetEndTime() < cutoffTime)
|
||||||
|
yield return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void PrepareReplay()
|
protected override void PrepareReplay()
|
||||||
{
|
{
|
||||||
// don't record replays.
|
// don't record replays.
|
||||||
|
Loading…
Reference in New Issue
Block a user