From bb6478cdc3e98dee0cbfb8a6d722d012ae556233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Thu, 10 May 2018 10:15:47 +0200 Subject: [PATCH 1/9] Adds a check to disable music controller's seek --- osu.Game/Overlays/MusicController.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index b4021f2808..0605b211b0 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -206,7 +206,7 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali Anchor = Anchor.BottomCentre, Height = progress_height, FillColour = colours.Yellow, - OnSeek = progress => current?.Track.Seek(progress) + OnSeek = progress => ConditionalSeek(progress) } }, }, @@ -219,6 +219,13 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } + private bool? ConditionalSeek(double progress) + { + if (current.Track.Looping) + return current?.Track.Seek(progress); + return false; + } + protected override void LoadComplete() { beatmapBacking.ValueChanged += beatmapChanged; From 5b99d8df62c5176f1400d41c81e88905d7c108e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Thu, 10 May 2018 11:29:19 +0200 Subject: [PATCH 2/9] Fixes private method name capitalization --- osu.Game/Overlays/MusicController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 0605b211b0..ee928b3ccc 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -206,7 +206,7 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali Anchor = Anchor.BottomCentre, Height = progress_height, FillColour = colours.Yellow, - OnSeek = progress => ConditionalSeek(progress) + OnSeek = progress => conditionalSeek(progress) } }, }, @@ -219,7 +219,7 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } - private bool? ConditionalSeek(double progress) + private bool? conditionalSeek(double progress) { if (current.Track.Looping) return current?.Track.Seek(progress); 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 3/9] 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 @@ protected override void UpdateAfterChildren() // 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 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali 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 @@ protected override void LoadComplete() 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 @@ public abstract class OsuScreen : Screen /// 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 @@ public abstract class ScreenWithBeatmapBackground : OsuScreen public override bool AllowBeatmapRulesetChange => false; + public override bool AllowUserSeek => false; + protected const float BACKGROUND_FADE_DURATION = 800; protected float BackgroundOpacity => 1 - (float)DimLevel; From a877855fc615f697d4d205a304d4dde62031e70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Fri, 11 May 2018 09:39:55 +0200 Subject: [PATCH 4/9] Changes conditionSeek return type to void --- osu.Game/Overlays/MusicController.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 9cfce04685..a0074ccee7 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -219,9 +219,11 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } - private bool? conditionalSeek(double progress) + private void conditionalSeek(double progress) { - return DisableSeek ? false : current?.Track.Seek(progress); + if (DisableSeek) + return; + current?.Track.Seek(progress); } protected override void LoadComplete() From 17ed5e48390cb3d19fb8ae2554b86c6aa60a3985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Fri, 11 May 2018 09:41:31 +0200 Subject: [PATCH 5/9] Moves seek restrictions to Player --- osu.Game/Screens/Play/Player.cs | 2 ++ osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 83958b2912..8989cbaad4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -45,6 +45,8 @@ public class Player : ScreenWithBeatmapBackground, IProvideCursor public bool AllowLeadIn { get; set; } = true; public bool AllowResults { get; set; } = true; + public override bool AllowUserSeek => false; + private Bindable mouseWheelDisabled; private Bindable userAudioOffset; diff --git a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs index add02732d4..1ccc5e2fe8 100644 --- a/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs +++ b/osu.Game/Screens/Play/ScreenWithBeatmapBackground.cs @@ -17,8 +17,6 @@ public abstract class ScreenWithBeatmapBackground : OsuScreen public override bool AllowBeatmapRulesetChange => false; - public override bool AllowUserSeek => false; - protected const float BACKGROUND_FADE_DURATION = 800; protected float BackgroundOpacity => 1 - (float)DimLevel; From c55d47ff1085d0b215f3619678bcbac277c63adf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Fri, 11 May 2018 09:56:23 +0200 Subject: [PATCH 6/9] Converts OnSeek assignment to method group --- osu.Game/Overlays/MusicController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index a0074ccee7..45a59a0f87 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -206,7 +206,7 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali Anchor = Anchor.BottomCentre, Height = progress_height, FillColour = colours.Yellow, - OnSeek = progress => conditionalSeek(progress) + OnSeek = conditionalSeek } }, }, From a7e7c3a74a2132d173f2be310e2583acd808d126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Sat, 12 May 2018 11:55:52 +0200 Subject: [PATCH 7/9] Enables/Disables seek and Play/Resume on call to beatmapDisabledChanged --- osu.Game/OsuGame.cs | 3 --- osu.Game/Overlays/MusicController.cs | 9 +++++---- osu.Game/Screens/OsuScreen.cs | 2 -- osu.Game/Screens/Play/Player.cs | 2 -- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 4d6b4520fe..4e79ea48ca 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -538,13 +538,10 @@ protected override void UpdateAfterChildren() // 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 applyBeatmapRulesetRestrictions = !currentScreen?.AllowBeatmapRulesetChange ?? false; - bool applyUserSeekRestrictions = !currentScreen?.AllowUserSeek ?? false; Ruleset.Disabled = applyBeatmapRulesetRestrictions; Beatmap.Disabled = applyBeatmapRulesetRestrictions; - musicController.DisableSeek = applyUserSeekRestrictions; - mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; CursorOverrideContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 45a59a0f87..8ff8dfb3ad 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -221,9 +221,8 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali private void conditionalSeek(double progress) { - if (DisableSeek) - return; - current?.Track.Seek(progress); + if (EnableSeek) + current?.Track.Seek(progress); } protected override void LoadComplete() @@ -235,16 +234,18 @@ protected override void LoadComplete() base.LoadComplete(); } - public bool DisableSeek { get; set; } + private bool EnableSeek { get; set; } private void beatmapDisabledChanged(bool disabled) { if (disabled) playlist.Hide(); + playButton.Enabled.Value = !disabled; prevButton.Enabled.Value = !disabled; nextButton.Enabled.Value = !disabled; playlistButton.Enabled.Value = !disabled; + EnableSeek = !disabled; } protected override void UpdateAfterChildren() diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 48c3d95b0c..7a910574e0 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -50,8 +50,6 @@ public abstract class OsuScreen : Screen /// 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/Player.cs b/osu.Game/Screens/Play/Player.cs index 2e6db93065..f397d0c3d4 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -45,8 +45,6 @@ public class Player : ScreenWithBeatmapBackground, IProvideCursor public bool AllowLeadIn { get; set; } = true; public bool AllowResults { get; set; } = true; - public override bool AllowUserSeek => false; - private Bindable mouseWheelDisabled; private Bindable userAudioOffset; From 861a8cf9a749a079f983ac38b4bb38fe0704f790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Sat, 12 May 2018 23:10:03 +0200 Subject: [PATCH 8/9] Fixes capitalization of enableSeek --- osu.Game/Overlays/MusicController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8ff8dfb3ad..0406bb812c 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -221,7 +221,7 @@ private void load(OsuGameBase game, OsuColour colours, LocalisationEngine locali private void conditionalSeek(double progress) { - if (EnableSeek) + if (enableSeek) current?.Track.Seek(progress); } @@ -234,7 +234,7 @@ protected override void LoadComplete() base.LoadComplete(); } - private bool EnableSeek { get; set; } + private bool enableSeek { get; set; } private void beatmapDisabledChanged(bool disabled) { @@ -245,7 +245,7 @@ private void beatmapDisabledChanged(bool disabled) prevButton.Enabled.Value = !disabled; nextButton.Enabled.Value = !disabled; playlistButton.Enabled.Value = !disabled; - EnableSeek = !disabled; + enableSeek = !disabled; } protected override void UpdateAfterChildren() From 2979cb96a6eae23852f245042a248966e5e802ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20Odg=C3=A5rd=20T=C3=B8rring?= Date: Wed, 4 Jul 2018 21:09:28 +0200 Subject: [PATCH 9/9] attemptSeek accesses beatmap Disabled directly --- osu.Game/Overlays/MusicController.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index f7f0d7ec6a..94b69271fd 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -183,7 +183,7 @@ private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour co Anchor = Anchor.BottomCentre, Height = progress_height, FillColour = colours.Yellow, - OnSeek = conditionalSeek + OnSeek = attemptSeek } }, }, @@ -198,9 +198,9 @@ private void load(BindableBeatmap beatmap, BeatmapManager beatmaps, OsuColour co playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint); } - private void conditionalSeek(double progress) + private void attemptSeek(double progress) { - if (enableSeek) + if (!beatmap.Disabled) current?.Track.Seek(progress); } @@ -220,8 +220,6 @@ protected override void LoadComplete() base.LoadComplete(); } - private bool enableSeek { get; set; } - private void beatmapDisabledChanged(bool disabled) { if (disabled) @@ -231,7 +229,6 @@ private void beatmapDisabledChanged(bool disabled) prevButton.Enabled.Value = !disabled; nextButton.Enabled.Value = !disabled; playlistButton.Enabled.Value = !disabled; - enableSeek = !disabled; } protected override void UpdateAfterChildren()