2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2023-12-28 03:06:29 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2022-10-11 16:59:07 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2019-06-08 23:27:40 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2019-06-10 09:36:34 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2023-12-28 03:06:29 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2023-10-19 16:11:21 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-10-11 15:30:32 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2022-10-11 16:59:07 +08:00
|
|
|
|
using osu.Game.Rulesets;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-12-01 13:22:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Toolbar
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2019-06-13 01:51:21 +08:00
|
|
|
|
public partial class ToolbarRulesetTabButton : TabItem<RulesetInfo>
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2019-06-13 01:51:21 +08:00
|
|
|
|
private readonly RulesetButton ruleset;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2019-06-13 01:51:21 +08:00
|
|
|
|
public ToolbarRulesetTabButton(RulesetInfo value)
|
2019-06-08 23:27:40 +08:00
|
|
|
|
: base(value)
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2019-06-08 23:27:40 +08:00
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
|
RelativeSizeAxes = Axes.Y;
|
2019-06-13 01:51:21 +08:00
|
|
|
|
Child = ruleset = new RulesetButton
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2019-06-08 23:27:40 +08:00
|
|
|
|
Active = false,
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-08 23:27:40 +08:00
|
|
|
|
var rInstance = value.CreateInstance();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-08 23:27:40 +08:00
|
|
|
|
ruleset.TooltipMain = rInstance.Description;
|
2023-01-16 07:19:06 +08:00
|
|
|
|
ruleset.TooltipSub = ToolbarStrings.PlaySomeRuleset(rInstance.Description);
|
2019-06-08 23:27:40 +08:00
|
|
|
|
ruleset.SetIcon(rInstance.CreateIcon());
|
2016-10-04 18:41:18 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-08 23:27:40 +08:00
|
|
|
|
protected override void OnActivated() => ruleset.Active = true;
|
|
|
|
|
|
|
|
|
|
protected override void OnDeactivated() => ruleset.Active = false;
|
|
|
|
|
|
2019-06-13 01:51:21 +08:00
|
|
|
|
private partial class RulesetButton : ToolbarButton
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2023-10-19 16:23:39 +08:00
|
|
|
|
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
|
2023-10-19 16:11:21 +08:00
|
|
|
|
|
2023-12-28 03:06:29 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
private OsuColour colours { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
public RulesetButton()
|
|
|
|
|
{
|
|
|
|
|
Padding = new MarginPadding(3)
|
|
|
|
|
{
|
|
|
|
|
Bottom = 5
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-08 23:27:40 +08:00
|
|
|
|
public bool Active
|
2016-10-04 18:41:18 +08:00
|
|
|
|
{
|
2023-12-28 03:06:29 +08:00
|
|
|
|
set => Scheduler.AddOnce(() =>
|
2016-12-01 18:15:34 +08:00
|
|
|
|
{
|
2019-06-08 23:27:40 +08:00
|
|
|
|
if (value)
|
2016-12-01 18:15:34 +08:00
|
|
|
|
{
|
2023-12-28 03:06:29 +08:00
|
|
|
|
IconContainer.Colour = Color4Extensions.FromHex("#00FFAA");
|
2019-06-08 23:27:40 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-28 03:06:29 +08:00
|
|
|
|
IconContainer.Colour = colours.GrayF;
|
2019-06-08 23:27:40 +08:00
|
|
|
|
IconContainer.EdgeEffect = new EdgeEffectParameters();
|
|
|
|
|
}
|
2023-12-28 03:06:29 +08:00
|
|
|
|
});
|
2016-10-04 18:41:18 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-06-10 09:36:34 +08:00
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
|
{
|
2023-10-17 16:40:44 +08:00
|
|
|
|
Parent!.TriggerClick();
|
2019-06-10 09:36:34 +08:00
|
|
|
|
return base.OnClick(e);
|
|
|
|
|
}
|
2016-10-04 18:41:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-30 16:12:11 +08:00
|
|
|
|
}
|