mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 02:32:55 +08:00
Merge pull request #26382 from peppy/editor-more-frame-stable
Keep editor in frame stable mode when possible
This commit is contained in:
commit
6f8a3e15d8
@ -0,0 +1,51 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This test covers autoplay working correctly in the editor on fast streams.
|
||||||
|
/// Might seem like a weird test, but frame stability being toggled can cause autoplay to operation incorrectly.
|
||||||
|
/// This is clearly a bug with the autoplay algorithm, but is worked around at an editor level for now.
|
||||||
|
/// </summary>
|
||||||
|
public partial class TestSceneEditorAutoplayFastStreams : EditorTestScene
|
||||||
|
{
|
||||||
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
|
{
|
||||||
|
var testBeatmap = new TestBeatmap(ruleset, false);
|
||||||
|
testBeatmap.HitObjects.AddRange(new[]
|
||||||
|
{
|
||||||
|
new HitCircle { StartTime = 500 },
|
||||||
|
new HitCircle { StartTime = 530 },
|
||||||
|
new HitCircle { StartTime = 560 },
|
||||||
|
new HitCircle { StartTime = 590 },
|
||||||
|
new HitCircle { StartTime = 620 },
|
||||||
|
});
|
||||||
|
|
||||||
|
return testBeatmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestAllHit()
|
||||||
|
{
|
||||||
|
AddStep("start playback", () => EditorClock.Start());
|
||||||
|
AddUntilStep("wait for all hit", () =>
|
||||||
|
{
|
||||||
|
DrawableHitCircle[] hitCircles = Editor.ChildrenOfType<DrawableHitCircle>().OrderBy(s => s.HitObject.StartTime).ToArray();
|
||||||
|
|
||||||
|
return hitCircles.Length == 5 && hitCircles.All(h => h.IsHit);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,10 +46,12 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
moveMouseToObject(() => slider);
|
moveMouseToObject(() => slider);
|
||||||
|
|
||||||
AddStep("seek after end", () => EditorClock.Seek(750));
|
AddStep("seek after end", () => EditorClock.Seek(750));
|
||||||
|
AddUntilStep("wait for seek", () => !EditorClock.IsSeeking);
|
||||||
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
||||||
AddAssert("slider not selected", () => EditorBeatmap.SelectedHitObjects.Count == 0);
|
AddAssert("slider not selected", () => EditorBeatmap.SelectedHitObjects.Count == 0);
|
||||||
|
|
||||||
AddStep("seek to visible", () => EditorClock.Seek(650));
|
AddStep("seek to visible", () => EditorClock.Seek(650));
|
||||||
|
AddUntilStep("wait for seek", () => !EditorClock.IsSeeking);
|
||||||
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
AddStep("left click", () => InputManager.Click(MouseButton.Left));
|
||||||
AddUntilStep("slider selected", () => EditorBeatmap.SelectedHitObjects.Single() == slider);
|
AddUntilStep("slider selected", () => EditorBeatmap.SelectedHitObjects.Single() == slider);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// 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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -26,6 +27,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorBeatmap beatmap { get; set; } = null!;
|
private EditorBeatmap beatmap { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorClock editorClock { get; set; } = null!;
|
||||||
|
|
||||||
public DrawableEditorRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
|
public DrawableEditorRulesetWrapper(DrawableRuleset<TObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
this.drawableRuleset = drawableRuleset;
|
this.drawableRuleset = drawableRuleset;
|
||||||
@ -38,7 +42,6 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
drawableRuleset.FrameStablePlayback = false;
|
|
||||||
Playfield.DisplayJudgements.Value = false;
|
Playfield.DisplayJudgements.Value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +68,22 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
Scheduler.AddOnce(regenerateAutoplay);
|
Scheduler.AddOnce(regenerateAutoplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
// Whenever possible, we want to stay in frame stability playback.
|
||||||
|
// Without doing so, we run into bugs with some gameplay elements not behaving as expected.
|
||||||
|
//
|
||||||
|
// Note that this is not using EditorClock.IsSeeking as that would exit frame stability
|
||||||
|
// on all seeks. The intention here is to retain frame stability for small seeks.
|
||||||
|
//
|
||||||
|
// I still think no gameplay elements should require frame stability in the first place, but maybe that ship has sailed already..
|
||||||
|
bool shouldBypassFrameStability = Math.Abs(drawableRuleset.FrameStableClock.CurrentTime - editorClock.CurrentTime) > 1000;
|
||||||
|
|
||||||
|
drawableRuleset.FrameStablePlayback = !shouldBypassFrameStability;
|
||||||
|
}
|
||||||
|
|
||||||
private void regenerateAutoplay()
|
private void regenerateAutoplay()
|
||||||
{
|
{
|
||||||
var autoplayMod = drawableRuleset.Mods.OfType<ModAutoplay>().Single();
|
var autoplayMod = drawableRuleset.Mods.OfType<ModAutoplay>().Single();
|
||||||
|
Loading…
Reference in New Issue
Block a user