2019-01-24 08:43:03 +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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-04-02 05:51:28 +00:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-06-08 15:27:40 +00:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK.Graphics;
|
2019-06-08 15:27:40 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-06-10 01:36:34 +00:00
|
|
|
|
using osu.Framework.Input.Events;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
|
|
|
|
{
|
2019-06-12 17:51:21 +00:00
|
|
|
|
public class ToolbarRulesetTabButton : TabItem<RulesetInfo>
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-12 17:51:21 +00:00
|
|
|
|
private readonly RulesetButton ruleset;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2019-06-12 17:51:21 +00:00
|
|
|
|
public ToolbarRulesetTabButton(RulesetInfo value)
|
2019-06-08 15:27:40 +00:00
|
|
|
|
: base(value)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2019-06-12 17:51:21 +00:00
|
|
|
|
Child = ruleset = new RulesetButton
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
Active = false,
|
|
|
|
|
};
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-06-08 15:27:40 +00:00
|
|
|
|
var rInstance = value.CreateInstance();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-06-08 15:27:40 +00:00
|
|
|
|
ruleset.TooltipMain = rInstance.Description;
|
2020-09-06 17:13:06 +00:00
|
|
|
|
ruleset.TooltipSub = $"play some {rInstance.Description}";
|
2019-06-08 15:27:40 +00:00
|
|
|
|
ruleset.SetIcon(rInstance.CreateIcon());
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-08 15:27:40 +00:00
|
|
|
|
protected override void OnActivated() => ruleset.Active = true;
|
|
|
|
|
|
|
|
|
|
protected override void OnDeactivated() => ruleset.Active = false;
|
|
|
|
|
|
2019-06-12 17:51:21 +00:00
|
|
|
|
private class RulesetButton : ToolbarButton
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
public bool Active
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
set
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
if (value)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-08 15:27:40 +00:00
|
|
|
|
IconContainer.Colour = Color4.White;
|
|
|
|
|
IconContainer.EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Colour = new Color4(255, 194, 224, 100),
|
|
|
|
|
Radius = 15,
|
|
|
|
|
Roundness = 15,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
IconContainer.Colour = new Color4(255, 194, 224, 255);
|
|
|
|
|
IconContainer.EdgeEffect = new EdgeEffectParameters();
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-10 01:36:34 +00:00
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
|
{
|
|
|
|
|
Parent.Click();
|
|
|
|
|
return base.OnClick(e);
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|