1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 22:22:54 +08:00

Disable beatmap changing buttons when entering a screen that disallows changing the beatmap

This commit is contained in:
MrTheMake 2017-06-21 00:51:32 +02:00
parent 354f516779
commit edd7fd585c
3 changed files with 80 additions and 48 deletions

View File

@ -33,6 +33,39 @@ namespace osu.Game.Graphics.UserInterface
set { icon.Scale = value; } 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() public IconButton()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
@ -79,34 +112,46 @@ namespace osu.Game.Graphics.UserInterface
{ {
hover.Colour = colours.Yellow.Opacity(0.6f); hover.Colour = colours.Yellow.Opacity(0.6f);
flashColour = colours.Yellow; flashColour = colours.Yellow;
disabledColour = colours.Gray9;
} }
protected override bool OnHover(InputState state) protected override bool OnHover(InputState state)
{ {
if (!Enabled)
return true;
hover.FadeIn(500, EasingTypes.OutQuint); hover.FadeIn(500, EasingTypes.OutQuint);
return base.OnHover(state); return base.OnHover(state);
} }
protected override void OnHoverLost(InputState state) protected override void OnHoverLost(InputState state)
{ {
if (!Enabled)
return;
hover.FadeOut(500, EasingTypes.OutQuint); hover.FadeOut(500, EasingTypes.OutQuint);
base.OnHoverLost(state); base.OnHoverLost(state);
} }
protected override bool OnClick(InputState state) protected override bool OnClick(InputState state)
{ {
hover.FlashColour(flashColour, 800, EasingTypes.OutQuint);
return base.OnClick(state); return base.OnClick(state);
} }
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args) protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
{ {
if (!Enabled)
return true;
content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint); content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint);
return base.OnMouseDown(state, args); return base.OnMouseDown(state, args);
} }
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args) protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
{ {
if (!Enabled)
return true;
content.ScaleTo(1, 1000, EasingTypes.OutElastic); content.ScaleTo(1, 1000, EasingTypes.OutElastic);
return base.OnMouseUp(state, args); return base.OnMouseUp(state, args);
} }

View File

@ -35,41 +35,6 @@ namespace osu.Game.Overlays.Music
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>(); private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
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<BeatmapSetInfo>()
{
beatmapBacking.Value.BeatmapSetInfo
};
}
else
list.BeatmapSets = new List<BeatmapSetInfo>();
// Apply the current filter
list.Filter(filter.Search.Text);
// Select the current beatmap
list.SelectedItem = beatmapBacking.Value?.BeatmapSetInfo;
}
}
public IEnumerable<BeatmapSetInfo> BeatmapSets; public IEnumerable<BeatmapSetInfo> BeatmapSets;
private InputManager inputManager; private InputManager inputManager;
@ -187,12 +152,6 @@ namespace osu.Game.Overlays.Music
private void playSpecified(BeatmapInfo info) private void playSpecified(BeatmapInfo info)
{ {
if (!AllowBeatmapChange)
{
beatmapBacking.Value?.Track?.Seek(0);
return;
}
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking); beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
Task.Run(() => Task.Run(() =>

View File

@ -39,9 +39,13 @@ namespace osu.Game.Overlays
private Drawable currentBackground; private Drawable currentBackground;
private DragBar progressBar; private DragBar progressBar;
private IconButton prevButton;
private IconButton playButton; private IconButton playButton;
private IconButton nextButton;
private IconButton playlistButton; private IconButton playlistButton;
private Color4 colorYellow;
private SpriteText title, artist; private SpriteText title, artist;
private PlaylistOverlay playlist; private PlaylistOverlay playlist;
@ -53,16 +57,36 @@ namespace osu.Game.Overlays
private Container dragContainer; private Container dragContainer;
private Container playerContainer; private Container playerContainer;
private bool showPlaylistOnceAvailable;
private bool allowBeatmapChange = true;
public bool AllowBeatmapChange public bool AllowBeatmapChange
{ {
get get
{ {
return playlist.AllowBeatmapChange; return allowBeatmapChange;
} }
set set
{ {
if(IsLoaded) if (allowBeatmapChange == value) return;
playlist.AllowBeatmapChange = value;
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, Anchor = Anchor.Centre,
Children = new[] Children = new[]
{ {
new IconButton prevButton = new IconButton
{ {
Action = prev, Action = prev,
Icon = FontAwesome.fa_step_backward, Icon = FontAwesome.fa_step_backward,
@ -178,7 +202,7 @@ namespace osu.Game.Overlays
Action = play, Action = play,
Icon = FontAwesome.fa_play_circle_o, Icon = FontAwesome.fa_play_circle_o,
}, },
new IconButton nextButton = new IconButton
{ {
Action = next, Action = next,
Icon = FontAwesome.fa_step_forward, Icon = FontAwesome.fa_step_forward,
@ -211,7 +235,9 @@ namespace osu.Game.Overlays
beatmapBacking.BindTo(game.Beatmap); 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() protected override void LoadComplete()
@ -384,6 +410,8 @@ namespace osu.Game.Overlays
FadeOut(transition_length, EasingTypes.OutQuint); FadeOut(transition_length, EasingTypes.OutQuint);
dragContainer.ScaleTo(0.9f, transition_length, EasingTypes.OutQuint); dragContainer.ScaleTo(0.9f, transition_length, EasingTypes.OutQuint);
showPlaylistOnceAvailable = false;
} }
private enum TransformDirection private enum TransformDirection