1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Applied suggested changes

This commit is contained in:
MrTheMake 2017-06-21 12:17:59 +02:00
parent 2db0466722
commit 7a9d430a28
3 changed files with 65 additions and 69 deletions

View File

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

View File

@ -328,7 +328,7 @@ namespace osu.Game
ScreenChanged?.Invoke(newScreen);
musicController.AllowBeatmapChange = currentScreen.AllowBeatmapChange;
Beatmap.Disabled = !currentScreen.AllowBeatmapChange;
}
protected override bool OnExiting()

View File

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