From 545049941592cda599e92ae24d67f9c21f057aee Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 14:32:53 +0200 Subject: [PATCH 01/30] Implement OsuScreen::CanBeatmapChange and use it in the music controller --- osu.Game/OsuGame.cs | 11 +++++---- osu.Game/Overlays/MusicController.cs | 35 ++++++++++++++++++++++++---- osu.Game/Screens/OsuScreen.cs | 2 ++ osu.Game/Screens/Play/Player.cs | 2 ++ osu.Game/Screens/Ranking/Results.cs | 2 ++ 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 7e5b913d10..fd68aa0fb3 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -298,21 +298,22 @@ namespace osu.Game private Container overlayContent; - private OsuScreen currentScreen; + public readonly Bindable CurrentScreen = new Bindable(); + private FrameworkConfigManager frameworkConfig; private void screenChanged(Screen newScreen) { - currentScreen = newScreen as OsuScreen; + CurrentScreen.Value = newScreen as OsuScreen; - if (currentScreen == null) + if (CurrentScreen.Value == null) { Exit(); return; } //central game screen change logic. - if (!currentScreen.ShowOverlays) + if (!CurrentScreen.Value.ShowOverlays) { settings.State = Visibility.Hidden; Toolbar.State = Visibility.Hidden; @@ -362,7 +363,7 @@ namespace osu.Game mainContent.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; - Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; + Cursor.State = CurrentScreen.Value?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 3a8a0a883a..e3dca32383 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -16,13 +16,14 @@ using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Input; using osu.Framework.Localisation; +using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Framework.Threading; using osu.Game.Overlays.Music; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens; namespace osu.Game.Overlays { @@ -39,7 +40,9 @@ namespace osu.Game.Overlays private Drawable currentBackground; private DragBar progressBar; + private IconButton prevButton; private IconButton playButton; + private IconButton nextButton; private IconButton playlistButton; private SpriteText title, artist; @@ -50,9 +53,13 @@ namespace osu.Game.Overlays private readonly Bindable beatmapBacking = new Bindable(); + private readonly Bindable currentScreenBacking = new Bindable(); + private Container dragContainer; private Container playerContainer; + private bool canChangeBeatmap; + public MusicController() { Width = 400; @@ -81,7 +88,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuGameBase game, OsuColour colours, LocalisationEngine localisation) + private void load(OsuGame game, OsuColour colours, LocalisationEngine localisation) { this.localisation = localisation; @@ -153,7 +160,7 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Children = new[] { - new IconButton + prevButton = new IconButton { Action = prev, Icon = FontAwesome.fa_step_backward, @@ -165,7 +172,7 @@ namespace osu.Game.Overlays Action = play, Icon = FontAwesome.fa_play_circle_o, }, - new IconButton + nextButton = new IconButton { Action = next, Icon = FontAwesome.fa_step_forward, @@ -197,6 +204,7 @@ namespace osu.Game.Overlays }; beatmapBacking.BindTo(game.Beatmap); + currentScreenBacking.BindTo(game.CurrentScreen); playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint); } @@ -206,9 +214,24 @@ namespace osu.Game.Overlays beatmapBacking.ValueChanged += beatmapChanged; beatmapBacking.TriggerChange(); + currentScreenBacking.ValueChanged += screenChanged; + currentScreenBacking.TriggerChange(); + base.LoadComplete(); } + private void screenChanged(OsuScreen newScreen) + { + canChangeBeatmap = newScreen?.CanChangeBeatmap ?? false; + + prevButton.Enabled = canChangeBeatmap; + playButton.Enabled = canChangeBeatmap; + nextButton.Enabled = canChangeBeatmap; + playlistButton.Enabled = canChangeBeatmap; + + progressBar.IsEnabled = canChangeBeatmap; + } + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); @@ -250,12 +273,16 @@ namespace osu.Game.Overlays private void prev() { + if(!canChangeBeatmap) return; + queuedDirection = TransformDirection.Prev; playlist.PlayPrevious(); } private void next() { + if (!canChangeBeatmap) return; + queuedDirection = TransformDirection.Next; playlist.PlayNext(); } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index de9c698f2a..855ddbbd2f 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -29,6 +29,8 @@ namespace osu.Game.Screens internal virtual bool AllowRulesetChange => true; + internal virtual bool CanChangeBeatmap => true; + private readonly Bindable beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c38ea65f90..f22133fa6a 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; + internal override bool CanChangeBeatmap => false; + internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; public BeatmapInfo BeatmapInfo; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 2523ce05ec..36bfa67f86 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -279,5 +279,7 @@ namespace osu.Game.Screens.Ranking modeChangeButtons.Current.TriggerChange(); } + + internal override bool CanChangeBeatmap => false; } } From 13df0e0b04d575c0baf9ccbe8badc41fc392d87d Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 14:52:36 +0200 Subject: [PATCH 02/30] Fixed test case --- osu.Game/OsuGame.cs | 2 -- osu.Game/OsuGameBase.cs | 3 +++ osu.Game/Overlays/MusicController.cs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index fd68aa0fb3..cea041b04d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -298,8 +298,6 @@ namespace osu.Game private Container overlayContent; - public readonly Bindable CurrentScreen = new Bindable(); - private FrameworkConfigManager frameworkConfig; private void screenChanged(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 306cdaddf0..56224675c1 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -18,6 +18,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; +using osu.Game.Screens; using SQLite.Net; using osu.Framework.Graphics.Performance; @@ -45,6 +46,8 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); + public readonly Bindable CurrentScreen = new Bindable(); + private Bindable fpsDisplayVisible; protected AssemblyName AssemblyName => Assembly.GetEntryAssembly()?.GetName() ?? new AssemblyName { Version = new Version() }; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e3dca32383..3c91b8de41 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -88,7 +88,7 @@ namespace osu.Game.Overlays } [BackgroundDependencyLoader] - private void load(OsuGame game, OsuColour colours, LocalisationEngine localisation) + private void load(OsuGameBase game, OsuColour colours, LocalisationEngine localisation) { this.localisation = localisation; @@ -222,7 +222,7 @@ namespace osu.Game.Overlays private void screenChanged(OsuScreen newScreen) { - canChangeBeatmap = newScreen?.CanChangeBeatmap ?? false; + canChangeBeatmap = newScreen?.CanChangeBeatmap ?? true; prevButton.Enabled = canChangeBeatmap; playButton.Enabled = canChangeBeatmap; From 9cc5dc6c2b90b861cafa70f51df0755cb0dd1bb3 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 15:03:07 +0200 Subject: [PATCH 03/30] Only disallow changing the current track, not pausing or seeking it --- osu.Game/Overlays/MusicController.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 3c91b8de41..2d2cdd1b23 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -225,11 +225,8 @@ namespace osu.Game.Overlays canChangeBeatmap = newScreen?.CanChangeBeatmap ?? true; prevButton.Enabled = canChangeBeatmap; - playButton.Enabled = canChangeBeatmap; nextButton.Enabled = canChangeBeatmap; playlistButton.Enabled = canChangeBeatmap; - - progressBar.IsEnabled = canChangeBeatmap; } protected override void UpdateAfterChildren() @@ -249,7 +246,7 @@ namespace osu.Game.Overlays progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping) next(); + if (track.HasCompleted && !track.Looping && canChangeBeatmap) next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; @@ -273,16 +270,12 @@ namespace osu.Game.Overlays private void prev() { - if(!canChangeBeatmap) return; - queuedDirection = TransformDirection.Prev; playlist.PlayPrevious(); } private void next() { - if (!canChangeBeatmap) return; - queuedDirection = TransformDirection.Next; playlist.PlayNext(); } From 73f2709a2dc106d8438bee6d015a4451470ac8d5 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 16:30:58 +0200 Subject: [PATCH 04/30] Move logic into PlaylistOverlay --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 13 +++++++++++-- osu.Game/Overlays/MusicController.cs | 19 +------------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 1ed7da83b6..e524089602 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -7,17 +7,18 @@ using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio.Track; using osu.Framework.Configuration; +using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; +using osu.Game.Screens; using OpenTK; using OpenTK.Graphics; -using osu.Framework.Extensions; -using osu.Framework.Input; namespace osu.Game.Overlays.Music { @@ -35,9 +36,13 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); + private readonly Bindable currentScreenBacking = new Bindable(); + public IEnumerable BeatmapSets; private InputManager inputManager; + private bool canChangeBeatmap => currentScreenBacking.Value?.CanChangeBeatmap != false; + [BackgroundDependencyLoader] private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager) { @@ -86,6 +91,7 @@ namespace osu.Game.Overlays.Music list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren().ToList(); beatmapBacking.BindTo(game.Beatmap); + currentScreenBacking.BindTo(game.CurrentScreen); filter.Search.OnCommit = (sender, newText) => { var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); @@ -152,6 +158,9 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { + if (!canChangeBeatmap) + return; + beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); Task.Run(() => diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 2d2cdd1b23..dfccc3ec64 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -53,13 +53,9 @@ namespace osu.Game.Overlays private readonly Bindable beatmapBacking = new Bindable(); - private readonly Bindable currentScreenBacking = new Bindable(); - private Container dragContainer; private Container playerContainer; - private bool canChangeBeatmap; - public MusicController() { Width = 400; @@ -204,7 +200,6 @@ namespace osu.Game.Overlays }; beatmapBacking.BindTo(game.Beatmap); - currentScreenBacking.BindTo(game.CurrentScreen); playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint); } @@ -214,21 +209,9 @@ namespace osu.Game.Overlays beatmapBacking.ValueChanged += beatmapChanged; beatmapBacking.TriggerChange(); - currentScreenBacking.ValueChanged += screenChanged; - currentScreenBacking.TriggerChange(); - base.LoadComplete(); } - private void screenChanged(OsuScreen newScreen) - { - canChangeBeatmap = newScreen?.CanChangeBeatmap ?? true; - - prevButton.Enabled = canChangeBeatmap; - nextButton.Enabled = canChangeBeatmap; - playlistButton.Enabled = canChangeBeatmap; - } - protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); @@ -246,7 +229,7 @@ namespace osu.Game.Overlays progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping && canChangeBeatmap) next(); + if (track.HasCompleted && !track.Looping) next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; From cb8b3cb8fba9a3efc94305ff5e0d33adbdc5330e Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 16:31:45 +0200 Subject: [PATCH 05/30] CI fix --- osu.Game/Overlays/MusicController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index dfccc3ec64..79de415614 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -23,7 +23,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Music; using osu.Game.Graphics.UserInterface; -using osu.Game.Screens; namespace osu.Game.Overlays { From 8bee06943b816c76a155f59bf76c0bb1af9d14df Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 16:33:08 +0200 Subject: [PATCH 06/30] Removed ununsed variables --- osu.Game/Overlays/MusicController.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 79de415614..cee0ab88c6 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -39,9 +39,7 @@ namespace osu.Game.Overlays private Drawable currentBackground; private DragBar progressBar; - private IconButton prevButton; private IconButton playButton; - private IconButton nextButton; private IconButton playlistButton; private SpriteText title, artist; @@ -155,7 +153,7 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Children = new[] { - prevButton = new IconButton + new IconButton { Action = prev, Icon = FontAwesome.fa_step_backward, @@ -167,7 +165,7 @@ namespace osu.Game.Overlays Action = play, Icon = FontAwesome.fa_play_circle_o, }, - nextButton = new IconButton + new IconButton { Action = next, Icon = FontAwesome.fa_step_forward, From 15a1dd14a6f96e2a8b13947da7126402a7fae385 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 16:45:21 +0200 Subject: [PATCH 07/30] CanChangeBeatmap -> CanBeatmapChange --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 4 ++-- osu.Game/Screens/OsuScreen.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Ranking/Results.cs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index e524089602..afe866c0df 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -41,7 +41,7 @@ namespace osu.Game.Overlays.Music public IEnumerable BeatmapSets; private InputManager inputManager; - private bool canChangeBeatmap => currentScreenBacking.Value?.CanChangeBeatmap != false; + private bool canBeatmapChange => currentScreenBacking.Value?.CanBeatmapChange != false; [BackgroundDependencyLoader] private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager) @@ -158,7 +158,7 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { - if (!canChangeBeatmap) + if (!canBeatmapChange) return; beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 855ddbbd2f..6fbabd675e 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens internal virtual bool AllowRulesetChange => true; - internal virtual bool CanChangeBeatmap => true; + internal virtual bool CanBeatmapChange => true; private readonly Bindable beatmap = new Bindable(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index f22133fa6a..47649372bf 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool CanChangeBeatmap => false; + internal override bool CanBeatmapChange => false; internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 36bfa67f86..8cd45e4b5d 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -280,6 +280,6 @@ namespace osu.Game.Screens.Ranking modeChangeButtons.Current.TriggerChange(); } - internal override bool CanChangeBeatmap => false; + internal override bool CanBeatmapChange => false; } } From aec46a57c82729057793a79b7a6c628ddf0422ab Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 17:33:58 +0200 Subject: [PATCH 08/30] Restart the current track when pressing PREVIOUS or NEXT rather than doing nothing --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index afe866c0df..aa4cfdc00f 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -159,7 +159,10 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { if (!canBeatmapChange) + { + beatmapBacking.Value?.Track?.Seek(0); return; + } beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); From 667e6a2d6bddad3e426805ffeaf06ea44410384a Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 18:06:39 +0200 Subject: [PATCH 09/30] Applied suggested changes --- osu.Game/OsuGame.cs | 11 +++++++---- osu.Game/OsuGameBase.cs | 2 -- osu.Game/Overlays/Music/PlaylistOverlay.cs | 7 ++----- osu.Game/Overlays/MusicController.cs | 15 +++++++++++++++ osu.Game/Screens/OsuScreen.cs | 2 +- osu.Game/Screens/Play/Player.cs | 2 +- osu.Game/Screens/Ranking/Results.cs | 2 +- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index cea041b04d..6a80840e93 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -298,20 +298,21 @@ namespace osu.Game private Container overlayContent; + private OsuScreen currentScreen; private FrameworkConfigManager frameworkConfig; private void screenChanged(Screen newScreen) { - CurrentScreen.Value = newScreen as OsuScreen; + currentScreen = newScreen as OsuScreen; - if (CurrentScreen.Value == null) + if (currentScreen == null) { Exit(); return; } //central game screen change logic. - if (!CurrentScreen.Value.ShowOverlays) + if (!currentScreen.ShowOverlays) { settings.State = Visibility.Hidden; Toolbar.State = Visibility.Hidden; @@ -326,6 +327,8 @@ namespace osu.Game } ScreenChanged?.Invoke(newScreen); + + musicController.AllowBeatmapChange = currentScreen.AllowBeatmapChange; } protected override bool OnExiting() @@ -361,7 +364,7 @@ namespace osu.Game mainContent.Padding = new MarginPadding { Top = Toolbar.Position.Y + Toolbar.DrawHeight }; - Cursor.State = CurrentScreen.Value?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; + Cursor.State = currentScreen?.HasLocalCursorDisplayed == false ? Visibility.Visible : Visibility.Hidden; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 56224675c1..5350cd03ea 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -46,8 +46,6 @@ namespace osu.Game public readonly Bindable Beatmap = new Bindable(); - public readonly Bindable CurrentScreen = new Bindable(); - private Bindable fpsDisplayVisible; protected AssemblyName AssemblyName => Assembly.GetEntryAssembly()?.GetName() ?? new AssemblyName { Version = new Version() }; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index aa4cfdc00f..53844a02d2 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -36,13 +36,11 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); - private readonly Bindable currentScreenBacking = new Bindable(); + public bool AllowBeatmapChange = true; public IEnumerable BeatmapSets; private InputManager inputManager; - private bool canBeatmapChange => currentScreenBacking.Value?.CanBeatmapChange != false; - [BackgroundDependencyLoader] private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, UserInputManager inputManager) { @@ -91,7 +89,6 @@ namespace osu.Game.Overlays.Music list.BeatmapSets = BeatmapSets = beatmaps.GetAllWithChildren().ToList(); beatmapBacking.BindTo(game.Beatmap); - currentScreenBacking.BindTo(game.CurrentScreen); filter.Search.OnCommit = (sender, newText) => { var beatmap = list.FirstVisibleSet?.Beatmaps?.FirstOrDefault(); @@ -158,7 +155,7 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { - if (!canBeatmapChange) + if (!AllowBeatmapChange) { beatmapBacking.Value?.Track?.Seek(0); return; diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index cee0ab88c6..457174a67f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -53,6 +53,21 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; + private bool allowBeatmapChange = true; + + public bool AllowBeatmapChange + { + get + { + return allowBeatmapChange; + } + set + { + allowBeatmapChange = value; + playlist.AllowBeatmapChange = value; + } + } + public MusicController() { Width = 400; diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 6fbabd675e..3eb26a01a9 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens internal virtual bool AllowRulesetChange => true; - internal virtual bool CanBeatmapChange => true; + internal virtual bool AllowBeatmapChange => true; private readonly Bindable beatmap = new Bindable(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 47649372bf..f92d16faf8 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool CanBeatmapChange => false; + internal override bool AllowBeatmapChange => false; internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 8cd45e4b5d..866bccc5fe 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -280,6 +280,6 @@ namespace osu.Game.Screens.Ranking modeChangeButtons.Current.TriggerChange(); } - internal override bool CanBeatmapChange => false; + internal override bool AllowBeatmapChange => false; } } From b9cf0e47ee0a7442a52e8cc53aa2e35d8bbd246c Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 18:12:26 +0200 Subject: [PATCH 10/30] CI fix --- osu.Game/OsuGameBase.cs | 1 - osu.Game/Overlays/Music/PlaylistOverlay.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 5350cd03ea..306cdaddf0 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -18,7 +18,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Processing; using osu.Game.Online.API; -using osu.Game.Screens; using SQLite.Net; using osu.Framework.Graphics.Performance; diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 53844a02d2..c810b29748 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -16,7 +16,6 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Database; using osu.Game.Graphics; -using osu.Game.Screens; using OpenTK; using OpenTK.Graphics; From b4437329cceb11092ecae9fced3049a4128c53cf Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 18:34:56 +0200 Subject: [PATCH 11/30] Removed redundant variable --- osu.Game/Overlays/MusicController.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 457174a67f..480cf6fc74 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -53,17 +53,14 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; - private bool allowBeatmapChange = true; - public bool AllowBeatmapChange { get { - return allowBeatmapChange; + return playlist.AllowBeatmapChange; } set { - allowBeatmapChange = value; playlist.AllowBeatmapChange = value; } } From 1b95991e40a0ad60e2b824905690e91dfa50ed5d Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Mon, 19 Jun 2017 19:05:09 +0200 Subject: [PATCH 12/30] Extended condition --- 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 480cf6fc74..f0d79534af 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -238,7 +238,7 @@ namespace osu.Game.Overlays progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping) next(); + if (track.HasCompleted && !track.Looping && AllowBeatmapChange) next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; From 03c13620c84acd339b9f52dcc43b38e281a1d392 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Tue, 20 Jun 2017 02:12:05 +0200 Subject: [PATCH 13/30] Filter the playlist overlay's beatmap list --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index c810b29748..0825e936ee 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -35,7 +35,41 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); - public bool AllowBeatmapChange = true; + private bool allowBeatmapChange = true; + + public bool AllowBeatmapChange + { + get + { + return allowBeatmapChange; + } + set + { + if (!IsLoaded || allowBeatmapChange == value) return; + + allowBeatmapChange = value; + + // Get the new list of available beatmap sets + if (allowBeatmapChange) + list.BeatmapSets = BeatmapSets; + else if (beatmapBacking.Value != null) + { + list.BeatmapSets = new List() + { + beatmapBacking.Value.BeatmapSetInfo + }; + } + else + list.BeatmapSets = new List(); + + // Apply the current filter + list.Filter(filter.Search.Text); + + // Select the current beatmap + if (beatmapBacking.Value != null) + list.SelectedItem = beatmapBacking.Value.BeatmapSetInfo; + } + } public IEnumerable BeatmapSets; private InputManager inputManager; From 354f5167790bf8e6cf0c65cf158b4895350ecac7 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Tue, 20 Jun 2017 15:19:59 +0200 Subject: [PATCH 14/30] Moved load condition and simplify list selection --- osu.Game/Overlays/Music/PlaylistOverlay.cs | 5 ++--- osu.Game/Overlays/MusicController.cs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 0825e936ee..1a8f8fcb06 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays.Music } set { - if (!IsLoaded || allowBeatmapChange == value) return; + if (allowBeatmapChange == value) return; allowBeatmapChange = value; @@ -66,8 +66,7 @@ namespace osu.Game.Overlays.Music list.Filter(filter.Search.Text); // Select the current beatmap - if (beatmapBacking.Value != null) - list.SelectedItem = beatmapBacking.Value.BeatmapSetInfo; + list.SelectedItem = beatmapBacking.Value?.BeatmapSetInfo; } } diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index f0d79534af..12b6768319 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -61,7 +61,8 @@ namespace osu.Game.Overlays } set { - playlist.AllowBeatmapChange = value; + if(IsLoaded) + playlist.AllowBeatmapChange = value; } } From edd7fd585c8d4d445e69c33797d64a6303d679ff Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 00:51:32 +0200 Subject: [PATCH 15/30] Disable beatmap changing buttons when entering a screen that disallows changing the beatmap --- osu.Game/Graphics/UserInterface/IconButton.cs | 47 ++++++++++++++++++- osu.Game/Overlays/Music/PlaylistOverlay.cs | 41 ---------------- osu.Game/Overlays/MusicController.cs | 40 +++++++++++++--- 3 files changed, 80 insertions(+), 48 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 7cacd09618..8d7f223624 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -33,6 +33,39 @@ namespace osu.Game.Graphics.UserInterface set { icon.Scale = value; } } + private Color4 disabledColour; + + public override bool Enabled + { + get + { + return base.Enabled; + } + + set + { + if (base.Enabled == value) return; + + base.Enabled = value; + + if (!value) + { + FadeColour(disabledColour, 200, EasingTypes.OutQuint); + content.ScaleTo(1, 200, EasingTypes.OutElastic); + + if (Hovering) + hover.FadeOut(200, EasingTypes.OutQuint); + } + else + { + FadeColour(Color4.White, 200, EasingTypes.OutQuint); + + if(Hovering) + hover.FadeIn(500, EasingTypes.OutQuint); + } + } + } + public IconButton() { AutoSizeAxes = Axes.Both; @@ -79,34 +112,46 @@ namespace osu.Game.Graphics.UserInterface { hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; + disabledColour = colours.Gray9; } protected override bool OnHover(InputState state) { + if (!Enabled) + return true; + hover.FadeIn(500, EasingTypes.OutQuint); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { + if (!Enabled) + return; + hover.FadeOut(500, EasingTypes.OutQuint); base.OnHoverLost(state); } protected override bool OnClick(InputState state) { - hover.FlashColour(flashColour, 800, EasingTypes.OutQuint); return base.OnClick(state); } protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { + if (!Enabled) + return true; + content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint); return base.OnMouseDown(state, args); } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { + if (!Enabled) + return true; + content.ScaleTo(1, 1000, EasingTypes.OutElastic); return base.OnMouseUp(state, args); } diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 1a8f8fcb06..580b53a34a 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -35,41 +35,6 @@ namespace osu.Game.Overlays.Music private readonly Bindable beatmapBacking = new Bindable(); - private bool allowBeatmapChange = true; - - public bool AllowBeatmapChange - { - get - { - return allowBeatmapChange; - } - set - { - if (allowBeatmapChange == value) return; - - allowBeatmapChange = value; - - // Get the new list of available beatmap sets - if (allowBeatmapChange) - list.BeatmapSets = BeatmapSets; - else if (beatmapBacking.Value != null) - { - list.BeatmapSets = new List() - { - beatmapBacking.Value.BeatmapSetInfo - }; - } - else - list.BeatmapSets = new List(); - - // Apply the current filter - list.Filter(filter.Search.Text); - - // Select the current beatmap - list.SelectedItem = beatmapBacking.Value?.BeatmapSetInfo; - } - } - public IEnumerable BeatmapSets; private InputManager inputManager; @@ -187,12 +152,6 @@ namespace osu.Game.Overlays.Music private void playSpecified(BeatmapInfo info) { - if (!AllowBeatmapChange) - { - beatmapBacking.Value?.Track?.Seek(0); - return; - } - beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); Task.Run(() => diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 12b6768319..e7cd4ce2ba 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -39,9 +39,13 @@ namespace osu.Game.Overlays private Drawable currentBackground; private DragBar progressBar; + private IconButton prevButton; private IconButton playButton; + private IconButton nextButton; private IconButton playlistButton; + private Color4 colorYellow; + private SpriteText title, artist; private PlaylistOverlay playlist; @@ -53,16 +57,36 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; + private bool showPlaylistOnceAvailable; + + private bool allowBeatmapChange = true; + public bool AllowBeatmapChange { get { - return playlist.AllowBeatmapChange; + return allowBeatmapChange; } set { - if(IsLoaded) - playlist.AllowBeatmapChange = value; + if (allowBeatmapChange == value) return; + + allowBeatmapChange = value; + + // Toggle the playlist's visibility if required + if (!allowBeatmapChange) + { + showPlaylistOnceAvailable = playlist.State == Visibility.Visible; + + if (showPlaylistOnceAvailable) + playlist?.Hide(); + } + else if (showPlaylistOnceAvailable) + playlist?.Show(); + + prevButton.Enabled = allowBeatmapChange; + nextButton.Enabled = allowBeatmapChange; + playlistButton.Enabled = allowBeatmapChange; } } @@ -166,7 +190,7 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Children = new[] { - new IconButton + prevButton = new IconButton { Action = prev, Icon = FontAwesome.fa_step_backward, @@ -178,7 +202,7 @@ namespace osu.Game.Overlays Action = play, Icon = FontAwesome.fa_play_circle_o, }, - new IconButton + nextButton = new IconButton { Action = next, Icon = FontAwesome.fa_step_forward, @@ -211,7 +235,9 @@ namespace osu.Game.Overlays beatmapBacking.BindTo(game.Beatmap); - playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint); + colorYellow = colours.Yellow; + + playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colorYellow : Color4.White, 200, EasingTypes.OutQuint); } protected override void LoadComplete() @@ -384,6 +410,8 @@ namespace osu.Game.Overlays FadeOut(transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(0.9f, transition_length, EasingTypes.OutQuint); + + showPlaylistOnceAvailable = false; } private enum TransformDirection From 70096b6c8668869351bebadb29fb0f20121f9d1c Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 01:28:43 +0200 Subject: [PATCH 16/30] Bug fixes --- osu.Game/Overlays/MusicController.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e7cd4ce2ba..ed7f357855 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -73,6 +73,10 @@ namespace osu.Game.Overlays allowBeatmapChange = value; + prevButton.Enabled = allowBeatmapChange; + nextButton.Enabled = allowBeatmapChange; + playlistButton.Enabled = allowBeatmapChange; + // Toggle the playlist's visibility if required if (!allowBeatmapChange) { @@ -81,12 +85,8 @@ namespace osu.Game.Overlays if (showPlaylistOnceAvailable) playlist?.Hide(); } - else if (showPlaylistOnceAvailable) + else if (showPlaylistOnceAvailable && State == Visibility.Visible) playlist?.Show(); - - prevButton.Enabled = allowBeatmapChange; - nextButton.Enabled = allowBeatmapChange; - playlistButton.Enabled = allowBeatmapChange; } } @@ -237,7 +237,11 @@ namespace osu.Game.Overlays colorYellow = colours.Yellow; - playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colorYellow : Color4.White, 200, EasingTypes.OutQuint); + playlist.StateChanged += (c, s) => + { + if (playlistButton.Enabled) + playlistButton.FadeColour(s == Visibility.Visible ? colorYellow : Color4.White, 200, EasingTypes.OutQuint); + }; } protected override void LoadComplete() @@ -402,6 +406,9 @@ namespace osu.Game.Overlays FadeIn(transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(1, transition_length, EasingTypes.OutElastic); + + if(Alpha == 0) + showPlaylistOnceAvailable = false; } protected override void PopOut() @@ -410,8 +417,6 @@ namespace osu.Game.Overlays FadeOut(transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(0.9f, transition_length, EasingTypes.OutQuint); - - showPlaylistOnceAvailable = false; } private enum TransformDirection From 2db0466722949ca98693eccd46bf80ad149816a0 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 02:47:11 +0200 Subject: [PATCH 17/30] Readded color flash and simplify logic --- osu.Game/Graphics/UserInterface/IconButton.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 8d7f223624..c6fb3d1896 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -54,14 +54,14 @@ namespace osu.Game.Graphics.UserInterface content.ScaleTo(1, 200, EasingTypes.OutElastic); if (Hovering) - hover.FadeOut(200, EasingTypes.OutQuint); + OnHoverLost(new InputState()); } else { FadeColour(Color4.White, 200, EasingTypes.OutQuint); - if(Hovering) - hover.FadeIn(500, EasingTypes.OutQuint); + if (Hovering) + OnHover(new InputState()); } } } @@ -135,6 +135,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnClick(InputState state) { + hover.FlashColour(flashColour, 800, EasingTypes.OutQuint); return base.OnClick(state); } From 7a9d430a28686e643fce5017f572f95a1b188055 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 12:17:59 +0200 Subject: [PATCH 18/30] Applied suggested changes --- osu.Game/Graphics/UserInterface/IconButton.cs | 73 ++++++++++--------- osu.Game/OsuGame.cs | 2 +- osu.Game/Overlays/MusicController.cs | 59 +++++++-------- 3 files changed, 65 insertions(+), 69 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index c6fb3d1896..a409f954f6 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; +using osu.Framework.Graphics.Transforms; namespace osu.Game.Graphics.UserInterface { @@ -35,37 +36,6 @@ namespace osu.Game.Graphics.UserInterface private Color4 disabledColour; - public override bool Enabled - { - get - { - return base.Enabled; - } - - set - { - if (base.Enabled == value) return; - - base.Enabled = value; - - if (!value) - { - FadeColour(disabledColour, 200, EasingTypes.OutQuint); - content.ScaleTo(1, 200, EasingTypes.OutElastic); - - if (Hovering) - OnHoverLost(new InputState()); - } - else - { - FadeColour(Color4.White, 200, EasingTypes.OutQuint); - - if (Hovering) - OnHover(new InputState()); - } - } - } - public IconButton() { AutoSizeAxes = Axes.Both; @@ -113,11 +83,44 @@ namespace osu.Game.Graphics.UserInterface hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; disabledColour = colours.Gray9; + + Enabled.ValueChanged += enabledChanged; + } + + private void enabledChanged(bool newEnabled) + { + if (newEnabled) + { + // Only fade the colour to white if there is no colour transformation pending + bool colorTransformation = false; + foreach (ITransform t in Transforms) + { + if (t is TransformColour) + { + colorTransformation = true; + break; + } + } + + if(!colorTransformation) + FadeColour(Color4.White, 200, EasingTypes.OutQuint); + + if (Hovering) + OnHover(new InputState()); + } + else + { + FadeColour(disabledColour, 200, EasingTypes.OutQuint); + content.ScaleTo(1, 200, EasingTypes.OutElastic); + + if (Hovering) + OnHoverLost(new InputState()); + } } protected override bool OnHover(InputState state) { - if (!Enabled) + if (!Enabled.Value) return true; hover.FadeIn(500, EasingTypes.OutQuint); @@ -126,7 +129,7 @@ namespace osu.Game.Graphics.UserInterface protected override void OnHoverLost(InputState state) { - if (!Enabled) + if (!Enabled.Value) return; hover.FadeOut(500, EasingTypes.OutQuint); @@ -141,7 +144,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - if (!Enabled) + if (!Enabled.Value) return true; content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint); @@ -150,7 +153,7 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - if (!Enabled) + if (!Enabled.Value) return true; content.ScaleTo(1, 1000, EasingTypes.OutElastic); diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 6a80840e93..4a1e54152c 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -328,7 +328,7 @@ namespace osu.Game ScreenChanged?.Invoke(newScreen); - musicController.AllowBeatmapChange = currentScreen.AllowBeatmapChange; + Beatmap.Disabled = !currentScreen.AllowBeatmapChange; } protected override bool OnExiting() diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index ed7f357855..c84201a7b7 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -59,36 +59,7 @@ namespace osu.Game.Overlays private bool showPlaylistOnceAvailable; - private bool allowBeatmapChange = true; - - public bool AllowBeatmapChange - { - get - { - return allowBeatmapChange; - } - set - { - if (allowBeatmapChange == value) return; - - allowBeatmapChange = value; - - prevButton.Enabled = allowBeatmapChange; - nextButton.Enabled = allowBeatmapChange; - playlistButton.Enabled = allowBeatmapChange; - - // Toggle the playlist's visibility if required - if (!allowBeatmapChange) - { - showPlaylistOnceAvailable = playlist.State == Visibility.Visible; - - if (showPlaylistOnceAvailable) - playlist?.Hide(); - } - else if (showPlaylistOnceAvailable && State == Visibility.Visible) - playlist?.Show(); - } - } + private bool AllowBeatmapChange => !beatmapBacking.Disabled; public MusicController() { @@ -239,7 +210,7 @@ namespace osu.Game.Overlays playlist.StateChanged += (c, s) => { - if (playlistButton.Enabled) + if (AllowBeatmapChange) playlistButton.FadeColour(s == Visibility.Visible ? colorYellow : Color4.White, 200, EasingTypes.OutQuint); }; } @@ -249,9 +220,30 @@ namespace osu.Game.Overlays beatmapBacking.ValueChanged += beatmapChanged; beatmapBacking.TriggerChange(); + beatmapBacking.DisabledChanged += beatmapDisabledChanged; + beatmapDisabledChanged(beatmapBacking.Disabled); + base.LoadComplete(); } + private void beatmapDisabledChanged(bool newBeatmapDisabled) + { + prevButton.Enabled.Value = !newBeatmapDisabled; + nextButton.Enabled.Value = !newBeatmapDisabled; + playlistButton.Enabled.Value = !newBeatmapDisabled; + + // Toggle the playlist's visibility if required + if (newBeatmapDisabled) + { + showPlaylistOnceAvailable = playlist.State == Visibility.Visible; + + if (showPlaylistOnceAvailable) + playlist?.Hide(); + } + else if (showPlaylistOnceAvailable && State == Visibility.Visible) + playlist?.Show(); + } + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); @@ -281,7 +273,8 @@ namespace osu.Game.Overlays if (track == null) { - playlist.PlayNext(); + if (AllowBeatmapChange) + playlist.PlayNext(); return; } @@ -407,7 +400,7 @@ namespace osu.Game.Overlays FadeIn(transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(1, transition_length, EasingTypes.OutElastic); - if(Alpha == 0) + if (Alpha == 0) showPlaylistOnceAvailable = false; } From 67292a5dcf09fc8e6d4236f99820621f4dec8589 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 12:27:45 +0200 Subject: [PATCH 19/30] Brought ITransform in line with framework changes --- osu.Game/Graphics/UserInterface/IconButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 561581c341..faabfb3e74 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -93,7 +93,7 @@ namespace osu.Game.Graphics.UserInterface { // Only fade the colour to white if there is no colour transformation pending bool colorTransformation = false; - foreach (ITransform t in Transforms) + foreach (ITransform t in Transforms) { if (t is TransformColour) { From 8b07565025ff2343f511108d7b01c8e73deceb46 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 16:33:26 +0200 Subject: [PATCH 20/30] Added test case usability, namings and bug fixes --- .../Tests/TestCaseMusicController.cs | 19 ++++++++++++++--- osu.Game/Graphics/UserInterface/IconButton.cs | 21 ++++--------------- osu.Game/Overlays/MusicController.cs | 14 ++++++------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 5665bf859a..282f5207c0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -1,11 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Testing; +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; -using osu.Framework.Timing; -using osu.Game.Overlays; using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; +using osu.Framework.Timing; +using osu.Game; +using osu.Game.Beatmaps; +using osu.Game.Overlays; namespace osu.Desktop.VisualTests.Tests { @@ -15,11 +19,19 @@ namespace osu.Desktop.VisualTests.Tests private MusicController mc; + private readonly Bindable beatmapBacking = new Bindable(); + public TestCaseMusicController() { Clock = new FramedClock(); } + [BackgroundDependencyLoader] + private void load(OsuGameBase game) + { + beatmapBacking.BindTo(game.Beatmap); + } + public override void Reset() { base.Reset(); @@ -33,6 +45,7 @@ namespace osu.Desktop.VisualTests.Tests AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden); AddStep(@"show", () => mc.State = Visibility.Visible); + AddToggleStep(@"toggle beatmap lock", state => beatmapBacking.Disabled = state); } } } diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index faabfb3e74..6b35aeac80 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Input; -using osu.Framework.Graphics.Transforms; namespace osu.Game.Graphics.UserInterface { @@ -34,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface set { icon.Scale = value; } } - private Color4 disabledColour; + private Color4 disableColour; public IconButton() { @@ -82,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface { hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; - disabledColour = colours.Gray9; + disableColour = colours.Gray9; Enabled.ValueChanged += enabledChanged; } @@ -91,26 +90,14 @@ namespace osu.Game.Graphics.UserInterface { if (newEnabled) { - // Only fade the colour to white if there is no colour transformation pending - bool colorTransformation = false; - foreach (ITransform t in Transforms) - { - if (t is TransformColour) - { - colorTransformation = true; - break; - } - } - - if(!colorTransformation) - FadeColour(Color4.White, 200, EasingTypes.OutQuint); + FadeColour(Color4.White, 200, EasingTypes.OutQuint); if (Hovering) OnHover(new InputState()); } else { - FadeColour(disabledColour, 200, EasingTypes.OutQuint); + FadeColour(disableColour, 200, EasingTypes.OutQuint); content.ScaleTo(1, 200, EasingTypes.OutElastic); if (Hovering) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 53a8204534..8ab17d8785 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -45,7 +45,7 @@ namespace osu.Game.Overlays private IconButton nextButton; private IconButton playlistButton; - private Color4 colorYellow; + private Color4 playlistButtonColor; private SpriteText title, artist; @@ -60,8 +60,6 @@ namespace osu.Game.Overlays private bool showPlaylistOnceAvailable; - private bool AllowBeatmapChange => !beatmapBacking.Disabled; - public MusicController() { Width = 400; @@ -207,12 +205,12 @@ namespace osu.Game.Overlays beatmapBacking.BindTo(game.Beatmap); - colorYellow = colours.Yellow; + playlistButtonColor = colours.Yellow; playlist.StateChanged += (c, s) => { - if (AllowBeatmapChange) - playlistButton.FadeColour(s == Visibility.Visible ? colorYellow : Color4.White, 200, EasingTypes.OutQuint); + if (!beatmapBacking.Disabled) + playlistButton.FadeColour(s == Visibility.Visible ? playlistButtonColor : Color4.White, 200, EasingTypes.OutQuint); }; } @@ -262,7 +260,7 @@ namespace osu.Game.Overlays progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping && AllowBeatmapChange) next(); + if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled) next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; @@ -274,7 +272,7 @@ namespace osu.Game.Overlays if (track == null) { - if (AllowBeatmapChange) + if (!beatmapBacking.Disabled) playlist.PlayNext(); return; } From 3b2df5fa0f9e84331fe03bcad96bd4f126b80158 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Wed, 21 Jun 2017 16:46:30 +0200 Subject: [PATCH 21/30] Renaming and smaller optimizations --- osu.Game/Overlays/MusicController.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8ab17d8785..b35918c79f 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -209,7 +209,7 @@ namespace osu.Game.Overlays playlist.StateChanged += (c, s) => { - if (!beatmapBacking.Disabled) + if (playlistButton.Enabled) playlistButton.FadeColour(s == Visibility.Visible ? playlistButtonColor : Color4.White, 200, EasingTypes.OutQuint); }; } @@ -217,30 +217,28 @@ namespace osu.Game.Overlays protected override void LoadComplete() { beatmapBacking.ValueChanged += beatmapChanged; - beatmapBacking.TriggerChange(); - beatmapBacking.DisabledChanged += beatmapDisabledChanged; - beatmapDisabledChanged(beatmapBacking.Disabled); + beatmapBacking.TriggerChange(); base.LoadComplete(); } - private void beatmapDisabledChanged(bool newBeatmapDisabled) + private void beatmapDisabledChanged(bool newBeatmapBackingDisabled) { - prevButton.Enabled.Value = !newBeatmapDisabled; - nextButton.Enabled.Value = !newBeatmapDisabled; - playlistButton.Enabled.Value = !newBeatmapDisabled; + prevButton.Enabled.Value = !newBeatmapBackingDisabled; + nextButton.Enabled.Value = !newBeatmapBackingDisabled; + playlistButton.Enabled.Value = !newBeatmapBackingDisabled; // Toggle the playlist's visibility if required - if (newBeatmapDisabled) + if (newBeatmapBackingDisabled) { showPlaylistOnceAvailable = playlist.State == Visibility.Visible; if (showPlaylistOnceAvailable) - playlist?.Hide(); + playlist.Hide(); } else if (showPlaylistOnceAvailable && State == Visibility.Visible) - playlist?.Show(); + playlist.Show(); } protected override void UpdateAfterChildren() From 0e1b49dff93e57bff21c923d94b66251a1b3ff4a Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Sun, 25 Jun 2017 20:56:22 +0200 Subject: [PATCH 22/30] Applied suggested changes --- osu.Game/Overlays/MusicController.cs | 10 +++++----- osu.Game/Screens/Ranking/Results.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index b35918c79f..90253f40a3 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -223,14 +223,14 @@ namespace osu.Game.Overlays base.LoadComplete(); } - private void beatmapDisabledChanged(bool newBeatmapBackingDisabled) + private void beatmapDisabledChanged(bool disabled) { - prevButton.Enabled.Value = !newBeatmapBackingDisabled; - nextButton.Enabled.Value = !newBeatmapBackingDisabled; - playlistButton.Enabled.Value = !newBeatmapBackingDisabled; + prevButton.Enabled.Value = !disabled; + nextButton.Enabled.Value = !disabled; + playlistButton.Enabled.Value = !disabled; // Toggle the playlist's visibility if required - if (newBeatmapBackingDisabled) + if (disabled) { showPlaylistOnceAvailable = playlist.State == Visibility.Visible; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 8bbe8a25c6..d82927f3b4 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -33,6 +33,8 @@ namespace osu.Game.Screens.Ranking internal override bool AllowRulesetChange => false; + internal override bool AllowBeatmapChange => false; + private Container currentPage; private static readonly Vector2 background_blur = new Vector2(20); @@ -280,7 +282,5 @@ namespace osu.Game.Screens.Ranking modeChangeButtons.Current.TriggerChange(); } - - internal override bool AllowBeatmapChange => false; } } From c053733ea942ca927375f0402437ae343f731633 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:09:55 +0200 Subject: [PATCH 23/30] Updated to use ppy's implementation --- osu.Game/Graphics/UserInterface/IconButton.cs | 4 ++-- osu.Game/OsuGame.cs | 2 -- osu.Game/Overlays/MusicController.cs | 7 ++----- osu.Game/Screens/OsuScreen.cs | 2 -- osu.Game/Screens/Play/Player.cs | 2 -- osu.Game/Screens/Ranking/Results.cs | 2 -- 6 files changed, 4 insertions(+), 15 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 842c2d88dc..89be0316b2 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -93,7 +93,7 @@ namespace osu.Game.Graphics.UserInterface { FadeColour(Color4.White, 200, EasingTypes.OutQuint); - if (Hovering) + if (IsHovered) OnHover(new InputState()); } else @@ -101,7 +101,7 @@ namespace osu.Game.Graphics.UserInterface FadeColour(disableColour, 200, EasingTypes.OutQuint); content.ScaleTo(1, 200, EasingTypes.OutElastic); - if (Hovering) + if (IsHovered) OnHoverLost(new InputState()); } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 576c55fd0e..843861c0da 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -329,8 +329,6 @@ namespace osu.Game } ScreenChanged?.Invoke(newScreen); - - Beatmap.Disabled = !currentScreen.AllowBeatmapChange; } protected override bool OnExiting() diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index e9fa9af038..81b1fef52e 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -262,7 +262,8 @@ namespace osu.Game.Overlays progressBar.UpdatePosition(track.Length == 0 ? 0 : (float)(track.CurrentTime / track.Length)); playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o; - if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled) next(); + if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled) + next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; @@ -287,16 +288,12 @@ namespace osu.Game.Overlays private void prev() { - if (beatmapBacking.Disabled) return; - queuedDirection = TransformDirection.Prev; playlist.PlayPrevious(); } private void next() { - if (beatmapBacking.Disabled) return; - queuedDirection = TransformDirection.Next; playlist.PlayNext(); } diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index e7cc84891a..64223db100 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -35,8 +35,6 @@ namespace osu.Game.Screens /// internal virtual bool AllowBeatmapRulesetChange => true; - internal virtual bool AllowBeatmapChange => true; - private readonly Bindable beatmap = new Bindable(); private readonly Bindable ruleset = new Bindable(); diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index e27631f6b8..c9ca91faa0 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -33,8 +33,6 @@ namespace osu.Game.Screens.Play internal override bool ShowOverlays => false; - internal override bool AllowBeatmapChange => false; - internal override bool HasLocalCursorDisplayed => !pauseContainer.IsPaused && !HasFailed && HitRenderer.ProvidingUserCursor; public BeatmapInfo BeatmapInfo; diff --git a/osu.Game/Screens/Ranking/Results.cs b/osu.Game/Screens/Ranking/Results.cs index 92732310f3..636851e14d 100644 --- a/osu.Game/Screens/Ranking/Results.cs +++ b/osu.Game/Screens/Ranking/Results.cs @@ -33,8 +33,6 @@ namespace osu.Game.Screens.Ranking internal override bool AllowBeatmapRulesetChange => false; - internal override bool AllowBeatmapChange => false; - private Container currentPage; private static readonly Vector2 background_blur = new Vector2(20); From 00a622da1a2462245aad37a9ededc1a55413a607 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:31:12 +0200 Subject: [PATCH 24/30] Let disabled icon buttons be interactive again --- osu.Game/Graphics/UserInterface/IconButton.cs | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 89be0316b2..124406d7bb 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -84,42 +84,17 @@ namespace osu.Game.Graphics.UserInterface flashColour = colours.Yellow; disableColour = colours.Gray9; - Enabled.ValueChanged += enabledChanged; - } - - private void enabledChanged(bool newEnabled) - { - if (newEnabled) - { - FadeColour(Color4.White, 200, EasingTypes.OutQuint); - - if (IsHovered) - OnHover(new InputState()); - } - else - { - FadeColour(disableColour, 200, EasingTypes.OutQuint); - content.ScaleTo(1, 200, EasingTypes.OutElastic); - - if (IsHovered) - OnHoverLost(new InputState()); - } + Enabled.ValueChanged += newEnabled => FadeColour(newEnabled ? Color4.White : disableColour, 200, EasingTypes.OutQuint); } protected override bool OnHover(InputState state) { - if (!Enabled.Value) - return true; - hover.FadeIn(500, EasingTypes.OutQuint); return base.OnHover(state); } protected override void OnHoverLost(InputState state) { - if (!Enabled.Value) - return; - hover.FadeOut(500, EasingTypes.OutQuint); base.OnHoverLost(state); } @@ -132,18 +107,12 @@ namespace osu.Game.Graphics.UserInterface protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) { - if (!Enabled.Value) - return true; - content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint); return base.OnMouseDown(state, args); } protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) { - if (!Enabled.Value) - return true; - content.ScaleTo(1, 1000, EasingTypes.OutElastic); return base.OnMouseUp(state, args); } From a95339dc1dd76d63fd87a642708aa22ec81bf5a2 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:37:56 +0200 Subject: [PATCH 25/30] Removed the reopening of the playlist overlay --- osu.Game/Overlays/MusicController.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 81b1fef52e..8845f11d86 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -59,8 +59,6 @@ namespace osu.Game.Overlays private Container dragContainer; private Container playerContainer; - private bool showPlaylistOnceAvailable; - public MusicController() { Width = 400; @@ -233,16 +231,8 @@ namespace osu.Game.Overlays nextButton.Enabled.Value = !disabled; playlistButton.Enabled.Value = !disabled; - // Toggle the playlist's visibility if required if (disabled) - { - showPlaylistOnceAvailable = playlist.State == Visibility.Visible; - - if (showPlaylistOnceAvailable) - playlist.Hide(); - } - else if (showPlaylistOnceAvailable && State == Visibility.Visible) - playlist.Show(); + playlist.Hide(); } protected override void UpdateAfterChildren() @@ -401,9 +391,6 @@ namespace osu.Game.Overlays FadeIn(transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(1, transition_length, EasingTypes.OutElastic); - - if (Alpha == 0) - showPlaylistOnceAvailable = false; } protected override void PopOut() From d2c18026f256638522183fe8a40509ec61445178 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:45:24 +0200 Subject: [PATCH 26/30] Removed unnecessary variables --- osu.Game/Graphics/UserInterface/IconButton.cs | 5 +---- osu.Game/Overlays/MusicController.cs | 14 ++++---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 124406d7bb..a9210c69fb 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -34,8 +34,6 @@ namespace osu.Game.Graphics.UserInterface set { icon.Scale = value; } } - private Color4 disableColour; - public IconButton() { AutoSizeAxes = Axes.Both; @@ -82,9 +80,8 @@ namespace osu.Game.Graphics.UserInterface { hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; - disableColour = colours.Gray9; - Enabled.ValueChanged += newEnabled => FadeColour(newEnabled ? Color4.White : disableColour, 200, EasingTypes.OutQuint); + Enabled.ValueChanged += newEnabled => FadeColour(newEnabled ? Color4.White : colours.Gray9, 200, EasingTypes.OutQuint); } protected override bool OnHover(InputState state) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 8845f11d86..a5be07401d 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -207,13 +207,7 @@ namespace osu.Game.Overlays beatmapBacking.BindTo(game.Beatmap); - playlistButtonColor = colours.Yellow; - - playlist.StateChanged += (c, s) => - { - if (playlistButton.Enabled) - playlistButton.FadeColour(s == Visibility.Visible ? playlistButtonColor : Color4.White, 200, EasingTypes.OutQuint); - }; + playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, EasingTypes.OutQuint); } protected override void LoadComplete() @@ -227,12 +221,12 @@ namespace osu.Game.Overlays private void beatmapDisabledChanged(bool disabled) { + if (disabled) + playlist.Hide(); + prevButton.Enabled.Value = !disabled; nextButton.Enabled.Value = !disabled; playlistButton.Enabled.Value = !disabled; - - if (disabled) - playlist.Hide(); } protected override void UpdateAfterChildren() From c0fd4a765e9af6877f64bd4656ecdaec85e92828 Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:46:07 +0200 Subject: [PATCH 27/30] Removed unused variable --- osu.Game/Overlays/MusicController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index a5be07401d..36ecbe4560 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -46,8 +46,6 @@ namespace osu.Game.Overlays private IconButton nextButton; private IconButton playlistButton; - private Color4 playlistButtonColor; - private SpriteText title, artist; private PlaylistOverlay playlist; From b01a6d46c9093a5b9b2eb5244dba95bd9a2eb74e Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Fri, 14 Jul 2017 12:54:37 +0200 Subject: [PATCH 28/30] Added beatmap lock functionallity to the music controller's test case --- .../Tests/TestCaseMusicController.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index cbb2775234..346c826d5e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -4,7 +4,11 @@ using osu.Framework.Testing; using osu.Framework.Graphics; using osu.Framework.Timing; +using osu.Game; +using osu.Game.Beatmaps; using osu.Game.Overlays; +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics.Containers; namespace osu.Desktop.VisualTests.Tests @@ -13,6 +17,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests music controller ui."; + private readonly Bindable beatmapBacking = new Bindable(); + public TestCaseMusicController() { Clock = new FramedClock(); @@ -26,6 +32,13 @@ namespace osu.Desktop.VisualTests.Tests AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden); AddStep(@"show", () => mc.State = Visibility.Visible); + AddToggleStep(@"toggle beatmap lock", state => beatmapBacking.Disabled = state); + } + + [BackgroundDependencyLoader] + private void load(OsuGameBase game) + { + beatmapBacking.BindTo(game.Beatmap); } } } From 4d8e5898fd9494a219e57b74284242f80f1f971d Mon Sep 17 00:00:00 2001 From: MrTheMake Date: Tue, 1 Aug 2017 17:28:18 +0200 Subject: [PATCH 29/30] Updates according to the framework and formatting --- osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs | 8 ++++---- osu.Game/Graphics/UserInterface/IconButton.cs | 2 +- osu.Game/Overlays/Music/PlaylistOverlay.cs | 3 --- osu.Game/Overlays/MusicController.cs | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 346c826d5e..292e31de75 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -1,15 +1,15 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Testing; +using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Testing; using osu.Framework.Timing; using osu.Game; using osu.Game.Beatmaps; using osu.Game.Overlays; -using osu.Framework.Allocation; -using osu.Framework.Configuration; -using osu.Framework.Graphics.Containers; namespace osu.Desktop.VisualTests.Tests { diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 110a955780..d58a1b2742 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; - Enabled.ValueChanged += newEnabled => FadeColour(newEnabled ? Color4.White : colours.Gray9, 200, EasingTypes.OutQuint); + Enabled.ValueChanged += newEnabled => this.FadeColour(newEnabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint); } protected override bool OnHover(InputState state) diff --git a/osu.Game/Overlays/Music/PlaylistOverlay.cs b/osu.Game/Overlays/Music/PlaylistOverlay.cs index 5bbaa1b1ae..942633b35e 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; -using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Input; using osu.Framework.Graphics; @@ -15,8 +14,6 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using OpenTK; using OpenTK.Graphics; -using osu.Framework.Input; -using osu.Framework.Graphics.Shapes; namespace osu.Game.Overlays.Music { diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index d53641ec78..d970089942 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -12,6 +12,7 @@ using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.UserInterface; @@ -23,7 +24,6 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Overlays.Music; using osu.Game.Graphics.UserInterface; -using osu.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; namespace osu.Game.Overlays From 256daeaf68b4334c11313155bbb8e2a395e33456 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 2 Aug 2017 11:56:29 +0900 Subject: [PATCH 30/30] Rename variable --- osu.Game/Graphics/UserInterface/IconButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index d58a1b2742..c073486713 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; - Enabled.ValueChanged += newEnabled => this.FadeColour(newEnabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint); + Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint); } protected override bool OnHover(InputState state)