mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Make background handle its own lit state
This commit is contained in:
@ -31,7 +31,20 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private const float column_width = 45;
|
private const float column_width = 45;
|
||||||
private const float special_column_width = 70;
|
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 ColumnBackground background;
|
||||||
private readonly Container hitTargetBar;
|
private readonly Container hitTargetBar;
|
||||||
@ -218,10 +231,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private bool onPressed(ManiaAction action)
|
private bool onPressed(ManiaAction action)
|
||||||
{
|
{
|
||||||
if (action == Action)
|
if (action == Action)
|
||||||
{
|
|
||||||
background.IsLit = true;
|
|
||||||
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
|
keyIcon.ScaleTo(1.4f, 50, Easing.OutQuint).Then().ScaleTo(1.3f, 250, Easing.OutQuint);
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -229,10 +239,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private bool onReleased(ManiaAction action)
|
private bool onReleased(ManiaAction action)
|
||||||
{
|
{
|
||||||
if (action == Action)
|
if (action == Action)
|
||||||
{
|
|
||||||
background.IsLit = false;
|
|
||||||
keyIcon.ScaleTo(1f, 125, Easing.OutQuint);
|
keyIcon.ScaleTo(1f, 125, Easing.OutQuint);
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,17 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI.Components
|
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;
|
private readonly ScrollingDirection direction;
|
||||||
|
|
||||||
public ColumnBackground(ScrollingDirection direction)
|
public ColumnBackground(ScrollingDirection direction)
|
||||||
@ -85,25 +88,18 @@ namespace osu.Game.Rulesets.Mania.UI.Components
|
|||||||
direction == ScrollingDirection.Up ? dimPoint : brightPoint);
|
direction == ScrollingDirection.Up ? dimPoint : brightPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isLit;
|
public bool OnPressed(ManiaAction action)
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether the column lighting should be visible.
|
|
||||||
/// </summary>
|
|
||||||
public bool IsLit
|
|
||||||
{
|
{
|
||||||
set
|
if (action == Action)
|
||||||
{
|
|
||||||
if (isLit == value)
|
|
||||||
return;
|
|
||||||
isLit = value;
|
|
||||||
|
|
||||||
if (isLit)
|
|
||||||
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
|
backgroundOverlay.FadeTo(1, 50, Easing.OutQuint).Then().FadeTo(0.5f, 250, Easing.OutQuint);
|
||||||
else
|
return false;
|
||||||
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnReleased(ManiaAction action)
|
||||||
|
{
|
||||||
|
if (action == Action)
|
||||||
|
backgroundOverlay.FadeTo(0, 250, Easing.OutQuint);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user