From 83863d35c3713f29b271bcf571c10789c4daf3b6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 16:34:26 +0900 Subject: [PATCH 1/3] Remove AllowLeadIn flag --- osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs | 1 - osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs | 1 - osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs | 2 -- osu.Game/Screens/Play/GameplayClockContainer.cs | 6 ++---- osu.Game/Screens/Play/Player.cs | 3 +-- osu.Game/Tests/Visual/AllPlayersTestCase.cs | 1 - osu.Game/Tests/Visual/PlayerTestCase.cs | 1 - 7 files changed, 3 insertions(+), 12 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs index 2f33982d41..9614ece40e 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs @@ -333,7 +333,6 @@ namespace osu.Game.Rulesets.Osu.Tests var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } }) { AllowPause = false, - AllowLeadIn = false, AllowResults = false }; diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs index 2b0254f232..efb6dac158 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs @@ -18,7 +18,6 @@ namespace osu.Game.Tests.Visual.Gameplay return new ScoreAccessiblePlayer { AllowPause = false, - AllowLeadIn = false, AllowResults = false, }; } diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs index be2a21d23d..f571e85fe8 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs @@ -29,7 +29,6 @@ namespace osu.Game.Tests.Visual.Gameplay AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player { AllowPause = false, - AllowLeadIn = false, AllowResults = false, }))); @@ -50,7 +49,6 @@ namespace osu.Game.Tests.Visual.Gameplay stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer { AllowPause = false, - AllowLeadIn = false, AllowResults = false, })); diff --git a/osu.Game/Screens/Play/GameplayClockContainer.cs b/osu.Game/Screens/Play/GameplayClockContainer.cs index deac5e02bf..6ceef1dd18 100644 --- a/osu.Game/Screens/Play/GameplayClockContainer.cs +++ b/osu.Game/Screens/Play/GameplayClockContainer.cs @@ -54,7 +54,7 @@ namespace osu.Game.Screens.Play private readonly FramedOffsetClock offsetClock; - public GameplayClockContainer(WorkingBeatmap beatmap, bool allowLeadIn, double gameplayStartTime) + public GameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime) { this.beatmap = beatmap; @@ -64,9 +64,7 @@ namespace osu.Game.Screens.Play adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; - adjustableClock.Seek(allowLeadIn - ? Math.Min(0, gameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn) - : gameplayStartTime); + adjustableClock.Seek(Math.Min(0, gameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn)); adjustableClock.ProcessFrame(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 7b1cdd21a6..3ef8525b65 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -44,7 +44,6 @@ namespace osu.Game.Screens.Play public bool HasFailed { get; private set; } public bool AllowPause { get; set; } = true; - public bool AllowLeadIn { get; set; } = true; public bool AllowResults { get; set; } = true; private Bindable mouseWheelDisabled; @@ -90,7 +89,7 @@ namespace osu.Game.Screens.Play if (!ScoreProcessor.Mode.Disabled) config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode); - InternalChild = GameplayClockContainer = new GameplayClockContainer(working, AllowLeadIn, DrawableRuleset.GameplayStartTime); + InternalChild = GameplayClockContainer = new GameplayClockContainer(working, DrawableRuleset.GameplayStartTime); GameplayClockContainer.Children = new[] { diff --git a/osu.Game/Tests/Visual/AllPlayersTestCase.cs b/osu.Game/Tests/Visual/AllPlayersTestCase.cs index 03bd7b218a..25c397857d 100644 --- a/osu.Game/Tests/Visual/AllPlayersTestCase.cs +++ b/osu.Game/Tests/Visual/AllPlayersTestCase.cs @@ -83,7 +83,6 @@ namespace osu.Game.Tests.Visual protected virtual Player CreatePlayer(Ruleset ruleset) => new Player { AllowPause = false, - AllowLeadIn = false, AllowResults = false, }; } diff --git a/osu.Game/Tests/Visual/PlayerTestCase.cs b/osu.Game/Tests/Visual/PlayerTestCase.cs index 50cb839ed9..3be887910c 100644 --- a/osu.Game/Tests/Visual/PlayerTestCase.cs +++ b/osu.Game/Tests/Visual/PlayerTestCase.cs @@ -59,7 +59,6 @@ namespace osu.Game.Tests.Visual protected virtual Player CreatePlayer(Ruleset ruleset) => new Player { AllowPause = false, - AllowLeadIn = false, AllowResults = false, }; } From a88f23e55530d569b1ff953f4af9ab40cc67035a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 16:53:44 +0900 Subject: [PATCH 2/3] Convert remaining two flags to ctor parameters --- .../TestCaseSliderInput.cs | 8 ++----- .../TestCaseBackgroundScreenBeatmap.cs | 8 +++++-- .../Visual/Gameplay/TestCaseAutoplay.cs | 11 +++++----- .../Visual/Gameplay/TestCasePlayerLoader.cs | 17 +++++++-------- osu.Game/Screens/Play/Player.cs | 21 ++++++++++++++----- osu.Game/Screens/Play/ReplayPlayer.cs | 3 ++- osu.Game/Tests/Visual/AllPlayersTestCase.cs | 6 +----- osu.Game/Tests/Visual/PlayerTestCase.cs | 6 +----- 8 files changed, 41 insertions(+), 39 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs index 9614ece40e..a14af59b38 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs @@ -330,11 +330,7 @@ namespace osu.Game.Rulesets.Osu.Tests }, }, Clock); - var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } }) - { - AllowPause = false, - AllowResults = false - }; + var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } }); p.OnLoadComplete += _ => { @@ -363,7 +359,7 @@ namespace osu.Game.Rulesets.Osu.Tests public new ScoreProcessor ScoreProcessor => base.ScoreProcessor; public ScoreAccessibleReplayPlayer(Score score) - : base(score) + : base(score, false, false) { } } diff --git a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs index e56156752b..9abd1bdf23 100644 --- a/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs +++ b/osu.Game.Tests/Visual/Background/TestCaseBackgroundScreenBeatmap.cs @@ -257,9 +257,8 @@ namespace osu.Game.Tests.Visual.Background AddStep("Start player loader", () => { - songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer + songSelect.Push(playerLoader = new TestPlayerLoader(player = new TestPlayer(allowPause) { - AllowPause = allowPause, Ready = true, })); }); @@ -357,6 +356,11 @@ namespace osu.Game.Tests.Visual.Background public readonly Bindable ReplacesBackground = new Bindable(); public readonly Bindable IsPaused = new Bindable(); + public TestPlayer(bool allowPause = true) + : base(allowPause) + { + } + public bool IsStoryboardVisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha == 1; public bool IsStoryboardInvisible() => ((TestUserDimContainer)CurrentStoryboardContainer).CurrentAlpha <= 1; diff --git a/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs b/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs index efb6dac158..a2d92b7861 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCaseAutoplay.cs @@ -15,11 +15,7 @@ namespace osu.Game.Tests.Visual.Gameplay protected override Player CreatePlayer(Ruleset ruleset) { Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }); - return new ScoreAccessiblePlayer - { - AllowPause = false, - AllowResults = false, - }; + return new ScoreAccessiblePlayer(); } protected override void AddCheckSteps() @@ -32,6 +28,11 @@ namespace osu.Game.Tests.Visual.Gameplay { public new ScoreProcessor ScoreProcessor => base.ScoreProcessor; public new HUDOverlay HUDOverlay => base.HUDOverlay; + + public ScoreAccessiblePlayer() + : base(false, false) + { + } } } } diff --git a/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs index f571e85fe8..41d484e21f 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestCasePlayerLoader.cs @@ -26,11 +26,7 @@ namespace osu.Game.Tests.Visual.Gameplay { Beatmap.Value = new DummyWorkingBeatmap(game); - AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player - { - AllowPause = false, - AllowResults = false, - }))); + AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player(false, false)))); AddUntilStep("wait for current", () => loader.IsCurrentScreen()); @@ -46,11 +42,7 @@ namespace osu.Game.Tests.Visual.Gameplay { SlowLoadPlayer slow = null; - stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer - { - AllowPause = false, - AllowResults = false, - })); + stack.Push(loader = new PlayerLoader(() => slow = new SlowLoadPlayer(false, false))); Scheduler.AddDelayed(() => slow.Ready = true, 5000); }); @@ -62,6 +54,11 @@ namespace osu.Game.Tests.Visual.Gameplay { public bool Ready; + public SlowLoadPlayer(bool allowPause = true, bool showResults = true) + : base(allowPause, showResults) + { + } + [BackgroundDependencyLoader] private void load() { diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3ef8525b65..6847dcafd3 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -43,9 +43,6 @@ namespace osu.Game.Screens.Play public bool HasFailed { get; private set; } - public bool AllowPause { get; set; } = true; - public bool AllowResults { get; set; } = true; - private Bindable mouseWheelDisabled; private readonly Bindable storyboardReplacesBackground = new Bindable(); @@ -70,6 +67,20 @@ namespace osu.Game.Screens.Play protected GameplayClockContainer GameplayClockContainer { get; private set; } + private readonly bool allowPause; + private readonly bool showResults; + + /// + /// Create a new player instance. + /// + /// Whether pausing should be allowed. If not allowed, attempting to pause will quit. + /// Whether results screen should be pushed on completion. + public Player(bool allowPause = true, bool showResults = true) + { + this.allowPause = allowPause; + this.showResults = showResults; + } + [BackgroundDependencyLoader] private void load(AudioManager audio, IAPIProvider api, OsuConfigManager config) { @@ -233,7 +244,7 @@ namespace osu.Game.Screens.Play ValidForResume = false; - if (!AllowResults) return; + if (!showResults) return; using (BeginDelayedSequence(1000)) { @@ -347,7 +358,7 @@ namespace osu.Game.Screens.Play private bool canPause => // must pass basic screen conditions (beatmap loaded, instance allows pause) - LoadedBeatmapSuccessfully && AllowPause && ValidForResume + LoadedBeatmapSuccessfully && allowPause && ValidForResume // replays cannot be paused and exit immediately && !DrawableRuleset.HasReplayLoaded.Value // cannot pause if we are already in a fail state diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 949b08d98d..a9c0ee3a15 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -9,7 +9,8 @@ namespace osu.Game.Screens.Play { private readonly Score score; - public ReplayPlayer(Score score) + public ReplayPlayer(Score score, bool allowPause = true, bool showResults = true) + : base(allowPause, showResults) { this.score = score; } diff --git a/osu.Game/Tests/Visual/AllPlayersTestCase.cs b/osu.Game/Tests/Visual/AllPlayersTestCase.cs index 25c397857d..4ef9b346b0 100644 --- a/osu.Game/Tests/Visual/AllPlayersTestCase.cs +++ b/osu.Game/Tests/Visual/AllPlayersTestCase.cs @@ -80,10 +80,6 @@ namespace osu.Game.Tests.Visual return Player; } - protected virtual Player CreatePlayer(Ruleset ruleset) => new Player - { - AllowPause = false, - AllowResults = false, - }; + protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false); } } diff --git a/osu.Game/Tests/Visual/PlayerTestCase.cs b/osu.Game/Tests/Visual/PlayerTestCase.cs index 3be887910c..c655b7ed47 100644 --- a/osu.Game/Tests/Visual/PlayerTestCase.cs +++ b/osu.Game/Tests/Visual/PlayerTestCase.cs @@ -56,10 +56,6 @@ namespace osu.Game.Tests.Visual LoadScreen(Player); } - protected virtual Player CreatePlayer(Ruleset ruleset) => new Player - { - AllowPause = false, - AllowResults = false, - }; + protected virtual Player CreatePlayer(Ruleset ruleset) => new Player(false, false); } } From 6ac49fed757409b58df76cede6b6559fa7e54dda Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 26 Mar 2019 17:40:22 +0900 Subject: [PATCH 3/3] Remove broken frame --- osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs index a14af59b38..76bd9ef758 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseSliderInput.cs @@ -297,11 +297,6 @@ namespace osu.Game.Rulesets.Osu.Tests private void performTest(List frames) { - // Empty frame to be added as a workaround for first frame behavior. - // If an input exists on the first frame, the input would apply to the entire intro lead-in - // Likely requires some discussion regarding how first frame inputs should be handled. - frames.Insert(0, new OsuReplayFrame()); - AddStep("load player", () => { Beatmap.Value = new TestWorkingBeatmap(new Beatmap