1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge pull request #955 from MrTheMake/musiccontroller-canbeatmapchange

Disable track changing buttons in the music controller depending on the current screen
This commit is contained in:
Dean Herbert 2017-08-02 12:51:22 +09:00 committed by GitHub
commit 211731d017
4 changed files with 41 additions and 15 deletions

View File

@ -1,11 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
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);
}
}
}

View File

@ -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)

View File

@ -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
{

View File

@ -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();
}