1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 03:23:03 +08:00

Make background handle its own lit state

This commit is contained in:
smoogipoo 2018-06-07 20:59:04 +09:00
parent 4af8baefc1
commit d49758d149
2 changed files with 28 additions and 25 deletions

View File

@ -31,7 +31,20 @@ namespace osu.Game.Rulesets.Mania.UI
private const float column_width = 45;
private const float special_column_width = 70;
public ManiaAction Action;
private ManiaAction action;
public ManiaAction Action
{
get => action;
set
{
if (action == value)
return;
action = value;
background.Action = value;
}
}
private readonly ColumnBackground background;
private readonly Container hitTargetBar;
@ -218,10 +231,7 @@ namespace osu.Game.Rulesets.Mania.UI
private bool onPressed(ManiaAction action)
{
if (action == Action)
{
background.IsLit = true;
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
}
return false;
}
@ -229,10 +239,7 @@ namespace osu.Game.Rulesets.Mania.UI
private bool onReleased(ManiaAction action)
{
if (action == Action)
{
background.IsLit = false;
keyIcon.ScaleTo(1f, 125, Easing.OutQuint);
}
return false;
}

View File

@ -7,14 +7,17 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using osu.Game.Rulesets.UI.Scrolling;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Mania.UI.Components
{
public class ColumnBackground : CompositeDrawable, IHasAccentColour
public class ColumnBackground : CompositeDrawable, IKeyBindingHandler<ManiaAction>, IHasAccentColour
{
public ManiaAction Action;
private readonly ScrollingDirection direction;
public ColumnBackground(ScrollingDirection direction)
@ -85,25 +88,18 @@ namespace osu.Game.Rulesets.Mania.UI.Components
direction == ScrollingDirection.Up ? dimPoint : brightPoint);
}
private bool isLit;
/// <summary>
/// Whether the column lighting should be visible.
/// </summary>
public bool IsLit
public bool OnPressed(ManiaAction action)
{
set
{
if (isLit == value)
return;
isLit = value;
if (isLit)
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
else
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
}
if (action == Action)
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
return false;
}
public bool OnReleased(ManiaAction action)
{
if (action == Action)
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
return false;
}
}
}