From d54a7295f6a72a49cd7d7eece02cbb4cdb30f5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Thu, 10 May 2018 13:20:04 +0200 Subject: [PATCH] Adds DisableSeek property to MusicController --- osu.Game/OsuGame.cs | 9 ++++++--- osu.Game/Overlays/MusicController.cs | 6 +++--- osu.Game/Screens/OsuScreen.cs | 2 ++ osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d443ed36ae..4d6b4520fe 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -537,10 +537,13 @@ namespace osu.Game // we only want to apply these restrictions when we are inside a screen stack. // the use case for not applying is in visual/unit tests. - bool applyRestrictions = !currentScreen?.AllowBeatmapRulesetChange ?? false; + bool applyBeatmapRulesetRestrictions = !currentScreen?.AllowBeatmapRulesetChange ?? false; + bool applyUserSeekRestrictions = !currentScreen?.AllowUserSeek ?? false; - Ruleset.Disabled = applyRestrictions; - Beatmap.Disabled = applyRestrictions; + Ruleset.Disabled = applyBeatmapRulesetRestrictions; + Beatmap.Disabled = applyBeatmapRulesetRestrictions; + + musicController.DisableSeek = applyUserSeekRestrictions; mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ee928b3ccc..9cfce04685 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -221,9 +221,7 @@ namespace osu.Game.Overlays private bool? conditionalSeek(double progress) { - if (current.Track.Looping) - return current?.Track.Seek(progress); - return false; + return DisableSeek ? false : current?.Track.Seek(progress); } protected override void LoadComplete() @@ -235,6 +233,8 @@ namespace osu.Game.Overlays base.LoadComplete(); } + public bool DisableSeek { get; set; } + private void beatmapDisabledChanged(bool disabled) { if (disabled) diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 7a910574e0..48c3d95b0c 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -50,6 +50,8 @@ namespace osu.Game.Screens /// public virtual bool AllowBeatmapRulesetChange => true; + public virtual bool AllowUserSeek => true; + protected readonly Bindable Beatmap = new Bindable(); protected virtual float BackgroundParallaxAmount => 1; diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index 1ccc5e2fe8..add02732d4 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -17,6 +17,8 @@ namespace osu.Game.Screens.Play public override bool AllowBeatmapRulesetChange => false; + public override bool AllowUserSeek => false; + protected const float BACKGROUND_FADE_DURATION = 800; protected float BackgroundOpacity => 1 - (float)DimLevel;