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); }
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()); }
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); }
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)); }
private void load() { Container leaderboardContainer; masterClockContainer = new MasterGameplayClockContainer(Beatmap.Value, 0); InternalChildren = new[] { (Drawable)(syncManager = new CatchUpSyncManager(masterClockContainer)), masterClockContainer.WithChild(new GridContainer { RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { leaderboardContainer = new Container { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X }, grid = new PlayerGrid { RelativeSizeAxes = Axes.Both } } } }) }; for (int i = 0; i < UserIds.Count; i++) { grid.Add(instances[i] = new PlayerArea(UserIds[i], masterClockContainer.GameplayClock)); syncManager.AddPlayerClock(instances[i].GameplayClock); } // Todo: This is not quite correct - it should be per-user to adjust for other mod combinations. var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value); var scoreProcessor = Ruleset.Value.CreateInstance().CreateScoreProcessor(); scoreProcessor.ApplyBeatmap(playableBeatmap); LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(scoreProcessor, UserIds.ToArray()) { Expanded = { Value = true }, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, l => { foreach (var instance in instances) { leaderboard.AddClock(instance.UserId, instance.GameplayClock); } leaderboardContainer.Add(leaderboard); }); }
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); }
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))); }
private void load() { FillFlowContainer leaderboardFlow; Container scoreDisplayContainer; masterClockContainer = CreateMasterGameplayClockContainer(Beatmap.Value); InternalChildren = new[] { (Drawable)(syncManager = new CatchUpSyncManager(masterClockContainer)), masterClockContainer.WithChild(new GridContainer { RelativeSizeAxes = Axes.Both, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { scoreDisplayContainer = new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y }, }, new Drawable[] { new GridContainer { RelativeSizeAxes = Axes.Both, ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, Content = new[] { new Drawable[] { leaderboardFlow = new FillFlowContainer { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(5) }, grid = new PlayerGrid { RelativeSizeAxes = Axes.Both } } } } } } }) }; for (int i = 0; i < Users.Count; i++) { grid.Add(instances[i] = new PlayerArea(Users[i], masterClockContainer.GameplayClock)); syncManager.AddPlayerClock(instances[i].GameplayClock); } // Todo: This is not quite correct - it should be per-user to adjust for other mod combinations. var playableBeatmap = Beatmap.Value.GetPlayableBeatmap(Ruleset.Value); var scoreProcessor = Ruleset.Value.CreateInstance().CreateScoreProcessor(); scoreProcessor.ApplyBeatmap(playableBeatmap); LoadComponentAsync(leaderboard = new MultiSpectatorLeaderboard(Ruleset.Value, scoreProcessor, users) { Expanded = { Value = true }, }, l => { foreach (var instance in instances) { leaderboard.AddClock(instance.UserId, instance.GameplayClock); } leaderboardFlow.Insert(0, leaderboard); if (leaderboard.TeamScores.Count == 2) { LoadComponentAsync(new MatchScoreDisplay { Team1Score = { BindTarget = leaderboard.TeamScores.First().Value }, Team2Score = { BindTarget = leaderboard.TeamScores.Last().Value }, }, scoreDisplayContainer.Add); } }); LoadComponentAsync(new GameplayChatDisplay(room) { Expanded = { Value = true }, }, chat => leaderboardFlow.Insert(1, chat)); }