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

Merge pull request #1038 from peppy/fix-songselect-footer-light

Fix footer button light fading incorrectly
This commit is contained in:
Thomas Müller 2017-07-20 12:10:38 +02:00 committed by GitHub
commit a104754e64

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using OpenTK.Input; using OpenTK.Input;
@ -31,7 +32,7 @@ namespace osu.Game.Screens.Select
public Action OnBack; public Action OnBack;
public Action OnStart; public Action OnStart;
private readonly FillFlowContainer buttons; private readonly FillFlowContainer<FooterButton> buttons;
public OsuLogo StartButton; public OsuLogo StartButton;
@ -43,29 +44,21 @@ namespace osu.Game.Screens.Select
/// <para>Higher depth to be put on the left, and lower to be put on the right.</para> /// <para>Higher depth to be put on the left, and lower to be put on the right.</para>
/// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para> /// <para>Notice this is different to <see cref="Options.BeatmapOptionsOverlay"/>!</para>
/// </param> /// </param>
public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) public void AddButton(string text, Color4 colour, Action action, Key? hotkey = null, float depth = 0) => buttons.Add(new FooterButton
{ {
var button = new FooterButton Text = text,
{ Height = play_song_select_button_height,
Text = text, Width = play_song_select_button_width,
Height = play_song_select_button_height, Depth = depth,
Width = play_song_select_button_width, SelectedColour = colour,
Depth = depth, DeselectedColour = colour.Opacity(0.5f),
SelectedColour = colour, Hotkey = hotkey,
DeselectedColour = colour.Opacity(0.5f), Hovered = updateModeLight,
Hotkey = hotkey, HoverLost = updateModeLight,
}; Action = action,
});
button.Hovered = () => updateModeLight(button); private void updateModeLight() => modeLight.FadeColour(buttons.FirstOrDefault(b => b.IsHovered)?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
button.HoverLost = () => updateModeLight();
button.Action = action;
buttons.Add(button);
}
private void updateModeLight(FooterButton button = null)
{
modeLight.FadeColour(button?.SelectedColour ?? Color4.Transparent, TRANSITION_LENGTH, EasingTypes.OutQuint);
}
public Footer() public Footer()
{ {
@ -111,7 +104,7 @@ namespace osu.Game.Screens.Select
Spacing = new Vector2(padding, 0), Spacing = new Vector2(padding, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
buttons = new FillFlowContainer buttons = new FillFlowContainer<FooterButton>
{ {
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(0.2f, 0), Spacing = new Vector2(0.2f, 0),