1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

Make the news collapsable month sections sound like dropdowns, because they pseudo kinda are

This commit is contained in:
Jamie Taylor 2021-07-30 21:35:07 +09:00
parent 9b7bb37244
commit 9538c4c7f2
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C

View File

@ -15,13 +15,18 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.News.Sidebar namespace osu.Game.Overlays.News.Sidebar
{ {
public class MonthSection : CompositeDrawable public class MonthSection : CompositeDrawable
{ {
private const int animation_duration = 250; private const int animation_duration = 250;
private Sample sampleOpen;
private Sample sampleClose;
public readonly BindableBool Expanded = new BindableBool(); public readonly BindableBool Expanded = new BindableBool();
@ -51,6 +56,21 @@ namespace osu.Game.Overlays.News.Sidebar
} }
} }
}; };
Expanded.ValueChanged += expanded =>
{
if (expanded.NewValue)
sampleOpen?.Play();
else
sampleClose?.Play();
};
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
} }
private class DropdownHeader : OsuClickableContainer private class DropdownHeader : OsuClickableContainer
@ -59,6 +79,8 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly SpriteIcon icon; private readonly SpriteIcon icon;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
public DropdownHeader(int month, int year) public DropdownHeader(int month, int year)
{ {
var date = new DateTime(year, month, 1); var date = new DateTime(year, month, 1);
@ -104,6 +126,7 @@ namespace osu.Game.Overlays.News.Sidebar
private readonly APINewsPost post; private readonly APINewsPost post;
public PostButton(APINewsPost post) public PostButton(APINewsPost post)
: base(HoverSampleSet.Submit)
{ {
this.post = post; this.post = post;