2020-01-01 19:49:04 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using osuTK;
|
2020-01-30 07:34:22 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-01-01 19:49:04 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-01-30 07:34:22 +00:00
|
|
|
|
public class OverlayRulesetTabItem : TabItem<RulesetInfo>
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
2020-01-30 07:34:22 +00:00
|
|
|
|
private Color4 accentColour;
|
2020-01-01 19:49:04 +00:00
|
|
|
|
|
2020-01-30 07:34:22 +00:00
|
|
|
|
protected virtual Color4 AccentColour
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
2020-01-30 07:34:22 +00:00
|
|
|
|
get => accentColour;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
accentColour = value;
|
2020-02-03 06:13:21 +00:00
|
|
|
|
text.FadeColour(value, 120, Easing.OutQuint);
|
2020-01-30 07:34:22 +00:00
|
|
|
|
}
|
2020-01-01 19:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 06:13:21 +00:00
|
|
|
|
protected override Container<Drawable> Content { get; }
|
|
|
|
|
|
2020-01-30 07:34:22 +00:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OverlayColourProvider colourProvider { get; set; }
|
2020-01-01 19:49:04 +00:00
|
|
|
|
|
2020-02-03 06:13:21 +00:00
|
|
|
|
private readonly OsuSpriteText text;
|
|
|
|
|
|
2020-01-01 19:49:04 +00:00
|
|
|
|
public OverlayRulesetTabItem(RulesetInfo value)
|
|
|
|
|
: base(value)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
|
|
|
{
|
2020-02-03 06:13:21 +00:00
|
|
|
|
Content = new FillFlowContainer
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(3, 0),
|
2020-02-03 06:13:21 +00:00
|
|
|
|
Child = text = new OsuSpriteText
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Text = value.Name,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new HoverClickSounds()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Enabled.Value = true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 18:45:10 +00:00
|
|
|
|
protected override void LoadComplete()
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
2020-02-03 18:45:10 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
Enabled.BindValueChanged(_ => updateState(), true);
|
2020-01-01 19:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-04 03:53:57 +00:00
|
|
|
|
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
|
|
|
|
|
|
2020-01-01 19:49:04 +00:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHover(e);
|
2020-02-03 18:45:10 +00:00
|
|
|
|
updateState();
|
2020-01-01 19:49:04 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2020-02-03 18:45:10 +00:00
|
|
|
|
updateState();
|
2020-01-01 19:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 18:45:10 +00:00
|
|
|
|
protected override void OnActivated() => updateState();
|
2020-01-01 19:49:04 +00:00
|
|
|
|
|
2020-02-03 18:45:10 +00:00
|
|
|
|
protected override void OnDeactivated() => updateState();
|
2020-01-01 19:49:04 +00:00
|
|
|
|
|
2020-02-03 18:45:10 +00:00
|
|
|
|
private void updateState()
|
2020-01-01 19:49:04 +00:00
|
|
|
|
{
|
2020-02-03 06:13:21 +00:00
|
|
|
|
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium);
|
2020-02-03 21:55:41 +00:00
|
|
|
|
AccentColour = Enabled.Value ? getActiveColour() : colourProvider.Foreground1;
|
2020-01-01 19:49:04 +00:00
|
|
|
|
}
|
2020-02-03 18:45:10 +00:00
|
|
|
|
|
2020-02-03 21:55:41 +00:00
|
|
|
|
private Color4 getActiveColour() => IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1;
|
2020-01-01 19:49:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|