public void TestGameplayTestWhenTrackRunning() { AddStep("start track", () => EditorClock.Start()); AddAssert("sample playback enabled", () => !Editor.SamplePlaybackDisabled.Value); AddStep("click test gameplay button", () => { var button = Editor.ChildrenOfType <TestGameplayButton>().Single(); InputManager.MoveMouseTo(button); InputManager.Click(MouseButton.Left); }); EditorPlayer editorPlayer = null; AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); AddAssert("editor track stopped", () => !EditorClock.IsRunning); AddAssert("sample playback disabled", () => Editor.SamplePlaybackDisabled.Value); AddStep("exit player", () => editorPlayer.Exit()); AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); AddUntilStep("background has correct params", () => { var background = this.ChildrenOfType <BackgroundScreenBeatmap>().Single(); return(background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0); }); AddStep("start track", () => EditorClock.Start()); AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value); }
public void TestCopyPaste(bool deselectAfterCopy) { var addedObject = new HitCircle { StartTime = 1000 }; AddStep("add hitobject", () => EditorBeatmap.Add(addedObject)); AddStep("select added object", () => EditorBeatmap.SelectedHitObjects.Add(addedObject)); AddStep("copy hitobject", () => Editor.Copy()); AddStep("move forward in time", () => EditorClock.Seek(2000)); if (deselectAfterCopy) { AddStep("deselect", () => EditorBeatmap.SelectedHitObjects.Clear()); AddUntilStep("timeline selection box is not visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<SelectionHandler>().First().Alpha == 0); AddUntilStep("composer selection box is not visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<SelectionHandler>().First().Alpha == 0); } AddStep("paste hitobject", () => Editor.Paste()); AddAssert("are two objects", () => EditorBeatmap.HitObjects.Count == 2); AddAssert("new object selected", () => EditorBeatmap.SelectedHitObjects.Single().StartTime == 2000); AddUntilStep("timeline selection box is visible", () => Editor.ChildrenOfType<Timeline>().First().ChildrenOfType<SelectionHandler>().First().Alpha > 0); AddUntilStep("composer selection box is visible", () => Editor.ChildrenOfType<HitObjectComposer>().First().ChildrenOfType<SelectionHandler>().First().Alpha > 0); }
public void TestSlidingSampleStopsOnSeek() { DrawableSlider slider = null; DrawableSample[] samples = null; AddStep("get first slider", () => { slider = Editor.ChildrenOfType <DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First(); samples = slider.ChildrenOfType <DrawableSample>().ToArray(); }); AddStep("start playback", () => EditorClock.Start()); AddUntilStep("wait for slider sliding then seek", () => { if (!slider.Tracking.Value) { return(false); } if (!samples.Any(s => s.Playing)) { return(false); } EditorClock.Seek(20000); return(true); }); AddAssert("slider samples are not playing", () => samples.Length == 5 && samples.All(s => s.Played && !s.Playing)); }
protected EditorClockTestScene() { Clock = new EditorClock(new Beatmap(), BeatDivisor) { IsCoupled = false }; }
private void load() { Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap); base.Content.AddRange(new Drawable[] { new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both, Child = Content }, dialogOverlay = new DialogOverlay() }); var beatDivisor = new BindableBeatDivisor { Value = Beatmap.Value.BeatmapInfo.BeatDivisor }; var editorClock = new EditorClock(Beatmap.Value.Beatmap, beatDivisor) { IsCoupled = false }; Dependencies.CacheAs(editorClock); Dependencies.Cache(beatDivisor); Dependencies.Cache(dialogOverlay); }
protected EditorClockTestCase() { Clock = new EditorClock(new ControlPointInfo(), 5000, BeatDivisor) { IsCoupled = false }; }
public void TestGameplayTestWhenTrackRunning() { AddStep("start track", () => EditorClock.Start()); AddAssert("sample playback enabled", () => !Editor.SamplePlaybackDisabled.Value); AddStep("click test gameplay button", () => { var button = Editor.ChildrenOfType <TestGameplayButton>().Single(); InputManager.MoveMouseTo(button); InputManager.Click(MouseButton.Left); }); EditorPlayer editorPlayer = null; AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null); AddAssert("editor track stopped", () => !EditorClock.IsRunning); AddAssert("sample playback disabled", () => Editor.SamplePlaybackDisabled.Value); AddStep("exit player", () => editorPlayer.Exit()); AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor); AddUntilStep("background has correct params", () => { // the test gameplay player's beatmap may be the "same" beatmap as the one being edited, *but* the `BeatmapInfo` references may differ // due to the beatmap refetch logic ran on editor suspend. // this test cares about checking the background belonging to the editor specifically, so check that using reference equality // (as `.Equals()` cannot discern between the two, as they technically share the same database GUID). var background = this.ChildrenOfType <BackgroundScreenBeatmap>().Single(b => ReferenceEquals(b.Beatmap.BeatmapInfo, EditorBeatmap.BeatmapInfo)); return(background.Colour == Color4.DarkGray && background.BlurAmount.Value == 0); }); AddStep("start track", () => EditorClock.Start()); AddAssert("sample playback re-enabled", () => !Editor.SamplePlaybackDisabled.Value); }
public void TestSlidingSampleStopsOnSeek() { DrawableSlider slider = null; PoolableSkinnableSample[] loopingSamples = null; PoolableSkinnableSample[] onceOffSamples = null; AddStep("get first slider", () => { slider = Editor.ChildrenOfType <DrawableSlider>().OrderBy(s => s.HitObject.StartTime).First(); onceOffSamples = slider.ChildrenOfType <PoolableSkinnableSample>().Where(s => !s.Looping).ToArray(); loopingSamples = slider.ChildrenOfType <PoolableSkinnableSample>().Where(s => s.Looping).ToArray(); }); AddStep("start playback", () => EditorClock.Start()); AddUntilStep("wait for slider sliding then seek", () => { if (!slider.Tracking.Value) { return(false); } if (!loopingSamples.Any(s => s.Playing)) { return(false); } EditorClock.Seek(20000); return(true); }); AddAssert("non-looping samples are playing", () => onceOffSamples.Length == 4 && loopingSamples.All(s => s.Played || s.Playing)); AddAssert("looping samples are not playing", () => loopingSamples.Length == 1 && loopingSamples.All(s => s.Played && !s.Playing)); }
private void load(IBindable <WorkingBeatmap> beatmap, OsuColour colours, EditorClock clock) { Beatmap.BindTo(beatmap); Track.BindTo(clock.Track); background.Colour = colours.Gray1; }
public override void SetUpSteps() { base.SetUpSteps(); AddStep("load editor", LoadEditor); AddUntilStep("wait for editor to load", () => EditorComponentsReady); AddStep("get beatmap", () => EditorBeatmap = Editor.ChildrenOfType <EditorBeatmap>().Single()); AddStep("get clock", () => EditorClock = Editor.ChildrenOfType <EditorClock>().Single()); }
public void TestSecondCircleInSelectionAlsoSnaps() { AddStep("move mouse to centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre)); AddStep("disable distance snap", () => InputManager.Key(Key.Q)); AddStep("enter placement mode", () => InputManager.Key(Key.Number2)); AddStep("place first object", () => InputManager.Click(MouseButton.Left)); AddStep("increment time", () => EditorClock.SeekForward(true)); AddStep("move mouse right", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * 0.2f, 0))); AddStep("place second object", () => InputManager.Click(MouseButton.Left)); AddStep("increment time", () => EditorClock.SeekForward(true)); AddStep("move mouse down", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(0, playfield.ScreenSpaceDrawQuad.Width * 0.2f))); AddStep("place third object", () => InputManager.Click(MouseButton.Left)); AddStep("enter selection mode", () => InputManager.Key(Key.Number1)); AddStep("select objects 2 and 3", () => { // add selection backwards to test non-sequential time ordering EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects[2]); EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects[1]); }); AddStep("begin drag", () => InputManager.PressButton(MouseButton.Left)); AddStep("move mouse slightly off centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * 0.02f, 0))); AddAssert("object 3 snapped to 1", () => { var objects = EditorBeatmap.HitObjects; var first = (OsuHitObject)objects.First(); var third = (OsuHitObject)objects.Last(); return(Precision.AlmostEquals(first.EndPosition, third.Position)); }); AddStep("move mouse slightly off centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * -0.22f, playfield.ScreenSpaceDrawQuad.Width * 0.21f))); AddAssert("object 2 snapped to 1", () => { var objects = EditorBeatmap.HitObjects; var first = (OsuHitObject)objects.First(); var second = (OsuHitObject)objects.ElementAt(1); return(Precision.AlmostEquals(first.EndPosition, second.Position)); }); AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left)); }
protected override bool OnDoubleClick(DoubleClickEvent e) { if (!base.OnDoubleClick(e)) { return(false); } EditorClock?.SeekSmoothlyTo(ClickedBlueprint.Item.StartTime); return(true); }
public void TestConversionPreservesSliderProperties() { Slider slider = null; AddStep("select second new-combo-starting slider", () => { slider = (Slider)EditorBeatmap.HitObjects.Where(h => h is Slider s && s.NewCombo).ElementAt(1); EditorClock.Seek(slider.StartTime); EditorBeatmap.SelectedHitObjects.Add(slider); });
public override void SetUpSteps() { base.SetUpSteps(); AddStep("load editor", () => LoadScreen(Editor = CreateEditor())); AddUntilStep("wait for editor to load", () => Editor.ChildrenOfType <HitObjectComposer>().FirstOrDefault()?.IsLoaded == true && Editor.ChildrenOfType <TimelineArea>().FirstOrDefault()?.IsLoaded == true); AddStep("get beatmap", () => EditorBeatmap = Editor.ChildrenOfType <EditorBeatmap>().Single()); AddStep("get clock", () => EditorClock = Editor.ChildrenOfType <EditorClock>().Single()); }
public void TestBeatSnapHitCircle() { double firstTimingPointTime() => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints.First().Time; AddStep("seek some milliseconds forward", () => EditorClock.Seek(firstTimingPointTime() + 10)); AddStep("move mouse to centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre)); AddStep("enter placement mode", () => InputManager.Key(Key.Number2)); AddStep("place first object", () => InputManager.Click(MouseButton.Left)); AddAssert("ensure object snapped back to correct time", () => EditorBeatmap.HitObjects.First().StartTime == firstTimingPointTime()); }
public void TestSnappedSeeking() { AddStep("seek to 0", () => EditorClock.Seek(0)); AddAssert("time is 0", () => EditorClock.CurrentTime == 0); pressAndCheckTime(Key.Right, 1000); pressAndCheckTime(Key.Right, 2000); pressAndCheckTime(Key.Right, 2500); pressAndCheckTime(Key.Right, 3000); pressAndCheckTime(Key.Left, 2500); pressAndCheckTime(Key.Left, 2000); pressAndCheckTime(Key.Left, 1000); }
public void EndPlacement(HitObject hitObject, bool commit) { EditorBeatmap.PlacementObject.Value = null; if (commit) { EditorBeatmap.Add(hitObject); if (EditorClock.CurrentTime < hitObject.StartTime) { EditorClock.SeekSmoothlyTo(hitObject.StartTime); } } }
public void TestClockPositionPreservedBetweenSwitches() { BeatmapInfo targetDifficulty = null; AddStep("seek editor to 00:05:00", () => EditorClock.Seek(5000)); AddStep("set target difficulty", () => targetDifficulty = importedBeatmapSet.Beatmaps.Last(beatmap => !beatmap.Equals(Beatmap.Value.BeatmapInfo))); switchToDifficulty(() => targetDifficulty); confirmEditingBeatmap(() => targetDifficulty); AddAssert("editor clock at 00:05:00", () => EditorClock.CurrentTime == 5000); AddStep("exit editor", () => Stack.Exit()); // ensure editor loader didn't resume. AddAssert("stack empty", () => Stack.CurrentScreen == null); }
protected override bool OnDoubleClick(DoubleClickEvent e) { if (e.Button == MouseButton.Right) { return(false); } // ensure the blueprint which was hovered for the first click is still the hovered blueprint. if (clickedBlueprint == null || SelectionHandler.SelectedBlueprints.FirstOrDefault(b => b.IsHovered) != clickedBlueprint) { return(false); } EditorClock?.SeekSmoothlyTo(clickedBlueprint.HitObject.StartTime); return(true); }
public TestSceneOsuDistanceSnapGrid() { editorBeatmap = new EditorBeatmap(new OsuBeatmap { BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo } }); editorClock = new EditorClock(editorBeatmap); base.Content.Children = new Drawable[] { snapProvider, Content }; }
public void TestCutPaste(double newTime) { var addedObject = new HitCircle { StartTime = 1000 }; AddStep("add hitobject", () => EditorBeatmap.Add(addedObject)); AddStep("select added object", () => EditorBeatmap.SelectedHitObjects.Add(addedObject)); AddStep("cut hitobject", () => Editor.Cut()); AddStep("move forward in time", () => EditorClock.Seek(newTime)); AddStep("paste hitobject", () => Editor.Paste()); AddAssert("is one object", () => EditorBeatmap.HitObjects.Count == 1); AddAssert("new object selected", () => EditorBeatmap.SelectedHitObjects.Single().StartTime == newTime); }
public void TestConversionWithNonMatchingDivisor() { Slider slider = null; AddStep("select second slider", () => { slider = (Slider)EditorBeatmap.HitObjects.Where(h => h is Slider).ElementAt(1); EditorClock.Seek(slider.StartTime); EditorBeatmap.SelectedHitObjects.Add(slider); }); AddStep("change beat divisor", () => beatDivisor.Value = 3); convertToStream(); AddAssert("stream created", () => streamCreatedFor(slider, (time: 0, pathPosition: 0), (time: 2 / 3d, pathPosition: 2 / 3d))); }
private void load(EditorClock clock) { drawableLyric.Clock = clock; state.BindableMode.BindValueChanged(e => { // initial default caret here CreateCaret(e.NewValue); }, true); // update change if caret changed. state.BindableHoverCaretPosition.BindValueChanged(e => { UpdateCaretPosition(e.NewValue, true); }); state.BindableCaretPosition.BindValueChanged(e => { UpdateCaretPosition(e.NewValue, false); }); }
public void TestSimpleConversion() { Slider slider = null; AddStep("select first slider", () => { slider = (Slider)EditorBeatmap.HitObjects.First(h => h is Slider); EditorClock.Seek(slider.StartTime); EditorBeatmap.SelectedHitObjects.Add(slider); }); convertToStream(); AddAssert("stream created", () => streamCreatedFor(slider, (time: 0, pathPosition: 0), (time: 0.25, pathPosition: 0.25), (time: 0.5, pathPosition: 0.5), (time: 0.75, pathPosition: 0.75), (time: 1, pathPosition: 1))); AddStep("undo", () => Editor.Undo()); AddAssert("slider restored", () => sliderRestored(slider)); AddStep("select first slider", () => { slider = (Slider)EditorBeatmap.HitObjects.First(h => h is Slider); EditorClock.Seek(slider.StartTime); EditorBeatmap.SelectedHitObjects.Add(slider); }); AddStep("change beat divisor", () => beatDivisor.Value = 8); convertToStream(); AddAssert("stream created", () => streamCreatedFor(slider, (time: 0, pathPosition: 0), (time: 0.125, pathPosition: 0.125), (time: 0.25, pathPosition: 0.25), (time: 0.375, pathPosition: 0.375), (time: 0.5, pathPosition: 0.5), (time: 0.625, pathPosition: 0.625), (time: 0.75, pathPosition: 0.75), (time: 0.875, pathPosition: 0.875), (time: 1, pathPosition: 1))); }
private void load() { var clock = new EditorClock { IsCoupled = false }; Dependencies.CacheAs(clock); var playback = new PlaybackControl { Anchor = Anchor.Centre, Origin = Anchor.Centre, Size = new Vector2(200, 100) }; Beatmap.Value = CreateWorkingBeatmap(new Beatmap()); Child = playback; }
public void TestCopyPaste() { var addedObject = new HitCircle { StartTime = 1000 }; AddStep("add hitobject", () => EditorBeatmap.Add(addedObject)); AddStep("select added object", () => EditorBeatmap.SelectedHitObjects.Add(addedObject)); AddStep("copy hitobject", () => Editor.Copy()); AddStep("move forward in time", () => EditorClock.Seek(2000)); AddStep("paste hitobject", () => Editor.Paste()); AddAssert("are two objects", () => EditorBeatmap.HitObjects.Count == 2); AddAssert("new object selected", () => EditorBeatmap.SelectedHitObjects.Single().StartTime == 2000); }
public void TestConversionWithRepeats() { Slider slider = null; AddStep("select first slider with repeats", () => { slider = (Slider)EditorBeatmap.HitObjects.First(h => h is Slider s && s.RepeatCount > 0); EditorClock.Seek(slider.StartTime); EditorBeatmap.SelectedHitObjects.Add(slider); }); AddStep("change beat divisor", () => beatDivisor.Value = 2); convertToStream(); AddAssert("stream created", () => streamCreatedFor(slider, (time: 0, pathPosition: 0), (time: 0.25, pathPosition: 0.5), (time: 0.5, pathPosition: 1), (time: 0.75, pathPosition: 0.5), (time: 1, pathPosition: 0))); }
private void load(EditorClock clock) { lyricPiece.Clock = clock; state.BindableMode.BindValueChanged(e => { // initial default caret. InitializeCaret(e.NewValue); // Initial blueprint container. InitializeBlueprint(e.NewValue); }, true); // update change if caret changed. state.BindableHoverCaretPosition.BindValueChanged(e => { UpdateCaretPosition(e.NewValue, true); }); state.BindableCaretPosition.BindValueChanged(e => { UpdateCaretPosition(e.NewValue, false); }); }
public void TestSnappedSeekingAfterControlPointChange() { AddStep("seek to 0", () => EditorClock.Seek(0)); AddAssert("time is 0", () => EditorClock.CurrentTime == 0); pressAndCheckTime(Key.Right, 1000); pressAndCheckTime(Key.Right, 2000); pressAndCheckTime(Key.Right, 2500); pressAndCheckTime(Key.Right, 3000); AddStep("remove 2nd timing point", () => { EditorBeatmap.BeginChange(); var group = EditorBeatmap.ControlPointInfo.GroupAt(2000); EditorBeatmap.ControlPointInfo.RemoveGroup(group); EditorBeatmap.EndChange(); }); pressAndCheckTime(Key.Left, 2000); pressAndCheckTime(Key.Left, 1000); pressAndCheckTime(Key.Right, 2000); pressAndCheckTime(Key.Right, 3000); }
public void TestPlacementOfConcurrentObjectWithDuration() { AddStep("seek to timing point", () => EditorClock.Seek(2170)); AddStep("add hit circle", () => EditorBeatmap.Add(createHitCircle(2170, Vector2.Zero))); AddStep("choose spinner placement tool", () => { InputManager.Key(Key.Number4); var hitObjectContainer = Editor.ChildrenOfType <HitObjectContainer>().Single(); InputManager.MoveMouseTo(hitObjectContainer.ScreenSpaceDrawQuad.Centre); }); AddStep("begin placing spinner", () => { InputManager.Click(MouseButton.Left); }); AddStep("end placing spinner", () => { EditorClock.Seek(2500); InputManager.Click(MouseButton.Right); }); AddAssert("two timeline blueprints present", () => Editor.ChildrenOfType <TimelineHitObjectBlueprint>().Count() == 2); }