mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 15:27:30 +08:00
Changed ModCustomisationHeader to inherit from OsuClickableContainer.
ModCustomisationHeader changes color depending on state.
This commit is contained in:
parent
ef1add3ebb
commit
17760afa60
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -20,17 +19,16 @@ using static osu.Game.Overlays.Mods.ModCustomisationPanel;
|
|||||||
|
|
||||||
namespace osu.Game.Overlays.Mods
|
namespace osu.Game.Overlays.Mods
|
||||||
{
|
{
|
||||||
public partial class ModCustomisationHeader : OsuHoverContainer
|
public partial class ModCustomisationHeader : OsuClickableContainer
|
||||||
{
|
{
|
||||||
private Box background = null!;
|
private Box background = null!;
|
||||||
|
private Box hoverBackground = null!;
|
||||||
private Box backgroundFlash = null!;
|
private Box backgroundFlash = null!;
|
||||||
private SpriteIcon icon = null!;
|
private SpriteIcon icon = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; } = null!;
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
|
|
||||||
|
|
||||||
public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>(ModCustomisationPanelState.Collapsed);
|
public readonly Bindable<ModCustomisationPanelState> ExpandedState = new Bindable<ModCustomisationPanelState>(ModCustomisationPanelState.Collapsed);
|
||||||
|
|
||||||
private readonly ModCustomisationPanel panel;
|
private readonly ModCustomisationPanel panel;
|
||||||
@ -53,6 +51,13 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
|
hoverBackground = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = OsuColour.Gray(80).Opacity(180),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
backgroundFlash = new Box
|
backgroundFlash = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -84,9 +89,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
IdleColour = colourProvider.Dark3;
|
|
||||||
HoverColour = colourProvider.Light4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
@ -109,15 +111,40 @@ namespace osu.Game.Overlays.Mods
|
|||||||
ExpandedState.BindValueChanged(v =>
|
ExpandedState.BindValueChanged(v =>
|
||||||
{
|
{
|
||||||
icon.ScaleTo(v.NewValue > ModCustomisationPanelState.Collapsed ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
|
icon.ScaleTo(v.NewValue > ModCustomisationPanelState.Collapsed ? new Vector2(1, -1) : Vector2.One, 300, Easing.OutQuint);
|
||||||
|
|
||||||
|
switch (v.NewValue)
|
||||||
|
{
|
||||||
|
case ModCustomisationPanelState.Collapsed:
|
||||||
|
background.FadeColour(colourProvider.Dark3, 500, Easing.OutQuint);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ModCustomisationPanelState.Expanded:
|
||||||
|
case ModCustomisationPanelState.ExpandedByMod:
|
||||||
|
background.FadeColour(colourProvider.Light4, 500, Easing.OutQuint);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
if (Enabled.Value && panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed)
|
if (!Enabled.Value)
|
||||||
|
return base.OnHover(e);
|
||||||
|
|
||||||
|
if (panel.ExpandedState.Value == ModCustomisationPanelState.Collapsed)
|
||||||
panel.ExpandedState.Value = ModCustomisationPanelState.Expanded;
|
panel.ExpandedState.Value = ModCustomisationPanelState.Expanded;
|
||||||
|
|
||||||
|
hoverBackground.FadeIn(200);
|
||||||
|
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
|
{
|
||||||
|
if (Enabled.Value)
|
||||||
|
hoverBackground.FadeOut(200);
|
||||||
|
|
||||||
|
base.OnHoverLost(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user