2019-04-26 12:29:58 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2021-07-08 19:23:11 +08:00
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-04-26 12:29:58 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-06-26 01:10:04 +08:00
|
|
|
using osu.Framework.Localisation;
|
2021-07-08 19:23:11 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2019-04-26 12:29:58 +08:00
|
|
|
using osuTK;
|
|
|
|
|
2019-04-26 12:49:44 +08:00
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-04-26 12:29:58 +08:00
|
|
|
{
|
|
|
|
public class ExpandDetailsButton : ProfileHeaderButton
|
|
|
|
{
|
|
|
|
public readonly BindableBool DetailsVisible = new BindableBool();
|
|
|
|
|
2021-06-26 01:10:04 +08:00
|
|
|
public override LocalisableString TooltipText => DetailsVisible.Value ? "collapse" : "expand";
|
2019-04-26 12:29:58 +08:00
|
|
|
|
|
|
|
private SpriteIcon icon;
|
2021-07-08 19:23:11 +08:00
|
|
|
private Sample sampleOpen;
|
|
|
|
private Sample sampleClose;
|
|
|
|
|
2021-07-09 10:16:47 +08:00
|
|
|
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
|
2019-04-26 12:29:58 +08:00
|
|
|
|
|
|
|
public ExpandDetailsButton()
|
|
|
|
{
|
2021-07-08 19:23:11 +08:00
|
|
|
Action = () =>
|
|
|
|
{
|
|
|
|
DetailsVisible.Toggle();
|
|
|
|
(DetailsVisible.Value ? sampleOpen : sampleClose)?.Play();
|
|
|
|
};
|
2019-04-26 12:29:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-07-08 19:23:11 +08:00
|
|
|
private void load(OverlayColourProvider colourProvider, AudioManager audio)
|
2019-04-26 12:29:58 +08:00
|
|
|
{
|
2020-01-30 05:25:28 +08:00
|
|
|
IdleColour = colourProvider.Background2;
|
|
|
|
HoverColour = colourProvider.Background2.Lighten(0.2f);
|
2019-04-26 12:29:58 +08:00
|
|
|
|
2021-07-08 19:23:11 +08:00
|
|
|
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
|
|
|
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
|
|
|
|
2019-04-26 12:29:58 +08:00
|
|
|
Child = icon = new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(20, 12)
|
|
|
|
};
|
|
|
|
|
|
|
|
DetailsVisible.BindValueChanged(visible => updateState(visible.NewValue), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState(bool detailsVisible) => icon.Icon = detailsVisible ? FontAwesome.Solid.ChevronUp : FontAwesome.Solid.ChevronDown;
|
|
|
|
}
|
|
|
|
}
|