-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToolbarRulesetTabButton.cs
80 lines (68 loc) · 2.46 KB
/
ToolbarRulesetTabButton.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.Toolbar
{
public partial class ToolbarRulesetTabButton : TabItem<RulesetInfo>
{
private readonly RulesetButton ruleset;
public ToolbarRulesetTabButton(RulesetInfo value)
: base(value)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
Child = ruleset = new RulesetButton
{
Active = false,
};
var rInstance = value.CreateInstance();
ruleset.TooltipMain = rInstance.Description;
ruleset.TooltipSub = ToolbarStrings.PlaySomeRuleset(rInstance.Description);
ruleset.SetIcon(rInstance.CreateIcon());
}
protected override void OnActivated() => ruleset.Active = true;
protected override void OnDeactivated() => ruleset.Active = false;
private partial class RulesetButton : ToolbarButton
{
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
[Resolved]
private OsuColour colours { get; set; } = null!;
public RulesetButton()
{
ButtonContent.Padding = new MarginPadding(PADDING)
{
Bottom = 5
};
}
public bool Active
{
set => Scheduler.AddOnce(() =>
{
if (value)
{
IconContainer.Colour = Color4Extensions.FromHex("#00FFAA");
}
else
{
IconContainer.Colour = colours.GrayF;
IconContainer.EdgeEffect = new EdgeEffectParameters();
}
});
}
protected override bool OnClick(ClickEvent e)
{
Parent!.TriggerClick();
return base.OnClick(e);
}
}
}
}