Пример #1
0
        public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
        {
            GameplayClockContainer       gameplayContainer = null;
            TestDrawableStoryboardSample sample            = null;

            Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;

            switch (testedMod)
            {
            case ModRateAdjust m:
                m.SpeedChange.Value = expectedRate;
                break;

            case ModTimeRamp m:
                m.InitialRate.Value = m.FinalRate.Value = expectedRate;
                break;
            }

            AddStep("setup storyboard sample", () =>
            {
                Beatmap.Value      = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, Audio);
                SelectedMods.Value = new[] { testedMod };

                Add(gameplayContainer = new GameplayClockContainer(Beatmap.Value, SelectedMods.Value, 0));

                gameplayContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
                {
                    Clock = gameplayContainer.GameplayClock
                });
            });

            AddStep("start", () => gameplayContainer.Start());

            AddAssert("sample playback rate matches mod rates", () => sample.Channel.AggregateFrequency.Value == expectedRate);
        }
        public void TestSeekPerformsInGameplayTime(
            [Values(1.0, 0.5, 2.0)] double clockRate,
            [Values(0.0, 200.0, -200.0)] double userOffset,
            [Values(false, true)] bool whileStopped)
        {
            ClockBackedTestWorkingBeatmap working = null;
            GameplayClockContainer        gameplayClockContainer = null;

            AddStep("create container", () =>
            {
                working = new ClockBackedTestWorkingBeatmap(new OsuRuleset().RulesetInfo, new FramedClock(new ManualClock()), Audio);
                working.LoadTrack();

                Add(gameplayClockContainer = new MasterGameplayClockContainer(working, 0));

                if (whileStopped)
                {
                    gameplayClockContainer.Stop();
                }

                gameplayClockContainer.Reset();
            });

            AddStep($"set clock rate to {clockRate}", () => working.Track.AddAdjustment(AdjustableProperty.Frequency, new BindableDouble(clockRate)));
            AddStep($"set audio offset to {userOffset}", () => localConfig.SetValue(OsuSetting.AudioOffset, userOffset));

            AddStep("seek to 2500", () => gameplayClockContainer.Seek(2500));
            AddAssert("gameplay clock time = 2500", () => Precision.AlmostEquals(gameplayClockContainer.CurrentTime, 2500, 10f));

            AddStep("seek to 10000", () => gameplayClockContainer.Seek(10000));
            AddAssert("gameplay clock time = 10000", () => Precision.AlmostEquals(gameplayClockContainer.CurrentTime, 10000, 10f));
        }
Пример #3
0
        public void TestSamplePlaybackWithBeatmapHitsoundsOff()
        {
            GameplayClockContainer       gameplayContainer = null;
            TestDrawableStoryboardSample sample            = null;

            AddStep("disable beatmap hitsounds", () => config.SetValue(OsuSetting.BeatmapHitsounds, false));

            AddStep("setup storyboard sample", () =>
            {
                Beatmap.Value = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, this);

                var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);

                Add(gameplayContainer = new MasterGameplayClockContainer(Beatmap.Value, 0)
                {
                    Child = beatmapSkinSourceContainer
                });

                beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(new StoryboardSampleInfo("test-sample", 1, 1))
                {
                    Clock = gameplayContainer.GameplayClock
                });
            });

            AddStep("start", () => gameplayContainer.Start());

            AddUntilStep("sample played", () => sample.IsPlayed);
            AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);

            AddStep("restore default", () => config.GetBindable <bool>(OsuSetting.BeatmapHitsounds).SetDefault());
        }
Пример #4
0
        public void TestSampleHasLifetimeEndWithInitialClockTime()
        {
            GameplayClockContainer   gameplayContainer = null;
            DrawableStoryboardSample sample            = null;

            AddStep("create container", () =>
            {
                var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
                working.LoadTrack();

                Add(gameplayContainer = new MasterGameplayClockContainer(working, 1000, true)
                {
                    IsPaused = { Value = true },
                    Child    = new FrameStabilityContainer
                    {
                        Child = sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
                    }
                });
            });

            AddStep("start time", () => gameplayContainer.Start());

            AddUntilStep("sample not played", () => !sample.RequestedPlaying);
            AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
        }
Пример #5
0
        public void TestSharedClockState()
        {
            AddStep("seek to 00:01:00", () => EditorClock.Seek(60_000));
            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);

            GameplayClockContainer gameplayClockContainer = null;

            AddStep("fetch gameplay clock", () => gameplayClockContainer = editorPlayer.ChildrenOfType <GameplayClockContainer>().First());
            AddUntilStep("gameplay clock running", () => gameplayClockContainer.IsRunning);
            AddAssert("gameplay time past 00:01:00", () => gameplayClockContainer.CurrentTime >= 60_000);

            double timeAtPlayerExit = 0;

            AddWaitStep("wait some", 5);
            AddStep("store time before exit", () => timeAtPlayerExit = gameplayClockContainer.CurrentTime);

            AddStep("exit player", () => editorPlayer.Exit());
            AddUntilStep("current screen is editor", () => Stack.CurrentScreen is Editor);
            AddAssert("time is past player exit", () => EditorClock.CurrentTime >= timeAtPlayerExit);
        }
Пример #6
0
        public void TestElapseThenReset()
        {
            GameplayClockContainer gameplayClockContainer = null;

            AddStep("create container", () =>
            {
                var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
                working.LoadTrack();

                Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
            });

            AddStep("start clock", () => gameplayClockContainer.Start());
            AddUntilStep("current time greater 2000", () => gameplayClockContainer.GameplayClock.CurrentTime > 2000);

            double timeAtReset = 0;

            AddStep("reset clock", () =>
            {
                timeAtReset = gameplayClockContainer.GameplayClock.CurrentTime;
                gameplayClockContainer.Reset();
            });

            AddAssert("current time < time at reset", () => gameplayClockContainer.GameplayClock.CurrentTime < timeAtReset);
        }
Пример #7
0
        public void SetUp() => Schedule(() =>
        {
            requestCount = 0;
            increment    = skip_time;

            var working = CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
            working.LoadTrack();

            Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0)
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new Drawable[]
                {
                    skip = new TestSkipOverlay(skip_time)
                    {
                        RequestSkip = () =>
                        {
                            requestCount++;
                            gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
                        }
                    }
                },
            };

            gameplayClockContainer.Start();
            gameplayClock = gameplayClockContainer.GameplayClock;
        });
        public void TestStartThenElapsedTime()
        {
            GameplayClockContainer gcc = null;

            AddStep("create container", () => Add(gcc = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty <Mod>(), 0)));
            AddStep("start track", () => gcc.Start());
            AddUntilStep("elapsed greater than zero", () => gcc.GameplayClock.ElapsedFrameTime > 0);
        }
Пример #9
0
        protected override bool CheckModsAllowFailure() => false; // never fail.

        public override void OnEntering(ScreenTransitionEvent e)
        {
            base.OnEntering(e);

            // finish alpha transforms on entering to avoid gameplay starting in a half-hidden state.
            // the finish calls are purposefully not propagated to children to avoid messing up their state.
            FinishTransforms();
            GameplayClockContainer.FinishTransforms(false, nameof(Alpha));
        }
Пример #10
0
 public void SetGameplayClockPaused(bool value)
 {
     if (GameplayClockContainer.IsPaused.Value && !value)
     {
         GameplayClockContainer.Start();
     }
     else if (!GameplayClockContainer.IsPaused.Value && value)
     {
         GameplayClockContainer.Stop();
     }
 }
Пример #11
0
        public void TestStartThenElapsedTime()
        {
            GameplayClockContainer gameplayClockContainer = null;

            AddStep("create container", () =>
            {
                var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
                working.LoadTrack();

                Child = gameplayClockContainer = new MasterGameplayClockContainer(working, 0);
            });

            AddStep("start clock", () => gameplayClockContainer.Start());
            AddUntilStep("elapsed greater than zero", () => gameplayClockContainer.GameplayClock.ElapsedFrameTime > 0);
        }
Пример #12
0
        public void TestSamplePlaybackWithRateMods(Type expectedMod, double expectedRate)
        {
            GameplayClockContainer       gameplayContainer = null;
            StoryboardSampleInfo         sampleInfo        = null;
            TestDrawableStoryboardSample sample            = null;

            Mod testedMod = Activator.CreateInstance(expectedMod) as Mod;

            switch (testedMod)
            {
            case ModRateAdjust m:
                m.SpeedChange.Value = expectedRate;
                break;

            case ModTimeRamp m:
                m.FinalRate.Value = m.InitialRate.Value = expectedRate;
                break;
            }

            AddStep("setup storyboard sample", () =>
            {
                Beatmap.Value      = new TestCustomSkinWorkingBeatmap(new OsuRuleset().RulesetInfo, this);
                SelectedMods.Value = new[] { testedMod };

                var beatmapSkinSourceContainer = new BeatmapSkinProvidingContainer(Beatmap.Value.Skin);

                Add(gameplayContainer = new MasterGameplayClockContainer(Beatmap.Value, 0)
                {
                    Child = beatmapSkinSourceContainer
                });

                beatmapSkinSourceContainer.Add(sample = new TestDrawableStoryboardSample(sampleInfo = new StoryboardSampleInfo("test-sample", 1, 1))
                {
                    Clock = gameplayContainer.GameplayClock
                });
            });

            AddStep("start", () => gameplayContainer.Start());

            AddAssert("sample playback rate matches mod rates", () =>
                      testedMod != null && Precision.AlmostEquals(
                          sample.ChildrenOfType <DrawableSample>().First().AggregateFrequency.Value,
                          ((IApplicableToRate)testedMod).ApplyToRate(sampleInfo.StartTime)));
        }
Пример #13
0
        public void TestSamplePlaybackAtZero()
        {
            GameplayClockContainer   gameplayContainer = null;
            DrawableStoryboardSample sample            = null;

            AddStep("create container", () =>
            {
                Add(gameplayContainer = new GameplayClockContainer(CreateWorkingBeatmap(new OsuRuleset().RulesetInfo), Array.Empty <Mod>(), 0));

                gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
                {
                    Clock = gameplayContainer.GameplayClock
                });
            });

            AddStep("start time", () => gameplayContainer.Start());

            AddUntilStep("sample playback succeeded", () => sample.LifetimeEnd < double.MaxValue);
        }
Пример #14
0
        public void TestSamplePlaybackAtZero()
        {
            GameplayClockContainer   gameplayContainer = null;
            DrawableStoryboardSample sample            = null;

            AddStep("create container", () =>
            {
                var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
                working.LoadTrack();

                Add(gameplayContainer = new GameplayClockContainer(working, 0));

                gameplayContainer.Add(sample = new DrawableStoryboardSample(new StoryboardSampleInfo(string.Empty, 0, 1))
                {
                    Clock = gameplayContainer.GameplayClock
                });
            });

            AddStep("start time", () => gameplayContainer.Start());

            AddUntilStep("sample played", () => sample.RequestedPlaying);
            AddUntilStep("sample has lifetime end", () => sample.LifetimeEnd < double.MaxValue);
        }
Пример #15
0
        public void SetUp() => Schedule(() =>
        {
            requestCount = 0;
            increment    = skip_time;

            Child = gameplayClockContainer = new GameplayClockContainer(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), Array.Empty <Mod>(), 0)
            {
                RelativeSizeAxes = Axes.Both,
                Children         = new Drawable[]
                {
                    skip = new SkipOverlay(skip_time)
                    {
                        RequestSkip = () =>
                        {
                            requestCount++;
                            gameplayClockContainer.Seek(gameplayClock.CurrentTime + increment);
                        }
                    }
                },
            };

            gameplayClockContainer.Start();
            gameplayClock = gameplayClockContainer.GameplayClock;
        });
Пример #16
0
 public override void OnEntering(IScreen last)
 {
     base.OnEntering(last);
     GameplayClockContainer.Stop();
 }
Пример #17
0
 public override void OnEntering(ScreenTransitionEvent e)
 {
     base.OnEntering(e);
     GameplayClockContainer.Stop();
 }