mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 18:32:55 +08:00
Disable beatmap changing buttons when entering a screen that disallows changing the beatmap
This commit is contained in:
parent
354f516779
commit
edd7fd585c
@ -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);
|
||||
}
|
||||
|
@ -35,41 +35,6 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
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;
|
||||
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(() =>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user