2019-04-26 13:29:58 +09: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 20:23:11 +09:00
|
|
|
using osu.Framework.Audio;
|
|
|
|
using osu.Framework.Audio.Sample;
|
2019-04-26 13:29:58 +09:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-06-25 19:10:04 +02:00
|
|
|
using osu.Framework.Localisation;
|
2021-07-08 20:23:11 +09:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-07-17 15:18:45 +02:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2019-04-26 13:29:58 +09:00
|
|
|
using osuTK;
|
|
|
|
|
2019-04-26 13:49:44 +09:00
|
|
|
namespace osu.Game.Overlays.Profile.Header.Components
|
2019-04-26 13:29:58 +09:00
|
|
|
{
|
2022-12-31 20:09:49 +01:00
|
|
|
public partial class ToggleCoverButton : ProfileHeaderButton
|
2019-04-26 13:29:58 +09:00
|
|
|
{
|
2023-01-24 23:30:07 +01:00
|
|
|
public readonly BindableBool CoverExpanded = new BindableBool(true);
|
2019-04-26 13:29:58 +09:00
|
|
|
|
2023-01-24 23:30:07 +01:00
|
|
|
public override LocalisableString TooltipText => CoverExpanded.Value ? UsersStrings.ShowCoverTo0 : UsersStrings.ShowCoverTo1;
|
2019-04-26 13:29:58 +09:00
|
|
|
|
2022-12-30 13:17:59 +01:00
|
|
|
private SpriteIcon icon = null!;
|
|
|
|
private Sample? sampleOpen;
|
|
|
|
private Sample? sampleClose;
|
2021-07-08 20:23:11 +09:00
|
|
|
|
2022-06-03 22:22:32 +09:00
|
|
|
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds();
|
2019-04-26 13:29:58 +09:00
|
|
|
|
2022-12-31 20:09:49 +01:00
|
|
|
public ToggleCoverButton()
|
2019-04-26 13:29:58 +09:00
|
|
|
{
|
2021-07-08 20:23:11 +09:00
|
|
|
Action = () =>
|
|
|
|
{
|
2023-01-24 23:30:07 +01:00
|
|
|
CoverExpanded.Toggle();
|
|
|
|
(CoverExpanded.Value ? sampleOpen : sampleClose)?.Play();
|
2021-07-08 20:23:11 +09:00
|
|
|
};
|
2019-04-26 13:29:58 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2021-07-08 20:23:11 +09:00
|
|
|
private void load(OverlayColourProvider colourProvider, AudioManager audio)
|
2019-04-26 13:29:58 +09:00
|
|
|
{
|
2020-01-29 22:25:28 +01:00
|
|
|
IdleColour = colourProvider.Background2;
|
2022-12-31 20:09:49 +01:00
|
|
|
HoverColour = colourProvider.Background1;
|
2019-04-26 13:29:58 +09:00
|
|
|
|
2021-07-08 20:23:11 +09:00
|
|
|
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
|
|
|
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
|
|
|
|
2022-12-31 20:09:49 +01:00
|
|
|
AutoSizeAxes = Axes.None;
|
|
|
|
Size = new Vector2(30);
|
2019-04-26 13:29:58 +09:00
|
|
|
Child = icon = new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2024-07-08 08:32:29 +03:00
|
|
|
Size = new Vector2(10.5f, 12),
|
|
|
|
Icon = FontAwesome.Solid.ChevronDown,
|
2019-04-26 13:29:58 +09:00
|
|
|
};
|
|
|
|
|
2023-01-24 23:30:07 +01:00
|
|
|
CoverExpanded.BindValueChanged(visible => updateState(visible.NewValue), true);
|
2019-04-26 13:29:58 +09:00
|
|
|
}
|
|
|
|
|
2024-07-08 08:32:29 +03:00
|
|
|
private void updateState(bool detailsVisible) => icon.ScaleTo(detailsVisible ? new Vector2(1f, -1f) : Vector2.One, 300, Easing.OutQuint);
|
2019-04-26 13:29:58 +09:00
|
|
|
}
|
|
|
|
}
|