diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index cbb2775234..292e31de75 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 { @@ -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); } } } diff --git a/osu.Game/Graphics/UserInterface/IconButton.cs b/osu.Game/Graphics/UserInterface/IconButton.cs index 1598ace9df..c073486713 100644 --- a/osu.Game/Graphics/UserInterface/IconButton.cs +++ b/osu.Game/Graphics/UserInterface/IconButton.cs @@ -80,6 +80,8 @@ namespace osu.Game.Graphics.UserInterface { hover.Colour = colours.Yellow.Opacity(0.6f); flashColour = colours.Yellow; + + Enabled.ValueChanged += enabled => this.FadeColour(enabled ? 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 100b397890..942633b35e 100644 --- a/osu.Game/Overlays/Music/PlaylistOverlay.cs +++ b/osu.Game/Overlays/Music/PlaylistOverlay.cs @@ -6,14 +6,14 @@ using System.Linq; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; 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 2807a02543..d970089942 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -12,18 +12,18 @@ 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; using osu.Framework.Input; using osu.Framework.Localisation; +using osu.Framework.Threading; using osu.Game.Beatmaps; 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.Framework.Graphics.Shapes; using osu.Game.Graphics.Containers; namespace osu.Game.Overlays @@ -41,7 +41,9 @@ namespace osu.Game.Overlays private Drawable currentBackground; private ProgressBar progressBar; + private IconButton prevButton; private IconButton playButton; + private IconButton nextButton; private IconButton playlistButton; private SpriteText title, artist; @@ -158,7 +160,7 @@ namespace osu.Game.Overlays Anchor = Anchor.Centre, Children = new[] { - new IconButton + prevButton = new IconButton { Action = prev, Icon = FontAwesome.fa_step_backward, @@ -170,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, @@ -209,11 +211,22 @@ namespace osu.Game.Overlays protected override void LoadComplete() { beatmapBacking.ValueChanged += beatmapChanged; + beatmapBacking.DisabledChanged += beatmapDisabledChanged; beatmapBacking.TriggerChange(); base.LoadComplete(); } + private void beatmapDisabledChanged(bool disabled) + { + if (disabled) + playlist.Hide(); + + prevButton.Enabled.Value = !disabled; + nextButton.Enabled.Value = !disabled; + playlistButton.Enabled.Value = !disabled; + } + protected override void UpdateAfterChildren() { base.UpdateAfterChildren(); @@ -233,7 +246,8 @@ namespace osu.Game.Overlays 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 && !beatmapBacking.Disabled) + next(); } else playButton.Icon = FontAwesome.fa_play_circle_o; @@ -245,7 +259,8 @@ namespace osu.Game.Overlays if (track == null) { - playlist.PlayNext(); + if (!beatmapBacking.Disabled) + playlist.PlayNext(); return; } @@ -257,16 +272,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(); }