Use more appropriate sounds for certain components

This commit is contained in:
Jamie Taylor
2022-06-03 22:22:32 +09:00
parent 365819865e
commit 2878bb592f
4 changed files with 33 additions and 6 deletions

View File

@ -13,6 +13,7 @@ namespace osu.Game.Graphics.UserInterface
{ {
public class ShearedToggleButton : ShearedButton public class ShearedToggleButton : ShearedButton
{ {
private Sample? sampleClick;
private Sample? sampleOff; private Sample? sampleOff;
private Sample? sampleOn; private Sample? sampleOn;
@ -39,8 +40,9 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
sampleOn = audio.Samples.Get(@"UI/check-on"); sampleClick = audio.Samples.Get(@"UI/default-select");
sampleOff = audio.Samples.Get(@"UI/check-off"); sampleOn = audio.Samples.Get(@"UI/dropdown-open");
sampleOff = audio.Samples.Get(@"UI/dropdown-close");
} }
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds(sampleSet); protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds(sampleSet);
@ -67,6 +69,8 @@ namespace osu.Game.Graphics.UserInterface
private void playSample() private void playSample()
{ {
sampleClick?.Play();
if (Active.Value) if (Active.Value)
sampleOn?.Play(); sampleOn?.Play();
else else

View File

@ -40,7 +40,7 @@ namespace osu.Game.Overlays.BeatmapListing
Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular), Font = OsuFont.GetFont(size: 13, weight: FontWeight.Regular),
Text = LabelFor(Value) Text = LabelFor(Value)
}, },
new HoverClickSounds() new HoverClickSounds(HoverSampleSet.TabSelect)
}); });
Enabled.Value = true; Enabled.Value = true;

View File

@ -6,6 +6,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -16,6 +18,7 @@ using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Chat; using osu.Game.Online.Chat;
using osuTK; using osuTK;
@ -32,6 +35,8 @@ namespace osu.Game.Overlays.Chat.Listing
public IEnumerable<LocalisableString> FilterTerms => new LocalisableString[] { Channel.Name, Channel.Topic ?? string.Empty }; public IEnumerable<LocalisableString> FilterTerms => new LocalisableString[] { Channel.Name, Channel.Topic ?? string.Empty };
public bool MatchingFilter { set => this.FadeTo(value ? 1f : 0f, 100); } public bool MatchingFilter { set => this.FadeTo(value ? 1f : 0f, 100); }
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
private Box hoverBox = null!; private Box hoverBox = null!;
private SpriteIcon checkbox = null!; private SpriteIcon checkbox = null!;
private OsuSpriteText channelText = null!; private OsuSpriteText channelText = null!;
@ -46,14 +51,20 @@ namespace osu.Game.Overlays.Chat.Listing
private const float vertical_margin = 1.5f; private const float vertical_margin = 1.5f;
private Sample? sampleJoin;
private Sample? sampleLeave;
public ChannelListingItem(Channel channel) public ChannelListingItem(Channel channel)
{ {
Channel = channel; Channel = channel;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(AudioManager audio)
{ {
sampleJoin = audio.Samples.Get(@"UI/check-on");
sampleLeave = audio.Samples.Get(@"UI/check-off");
Masking = true; Masking = true;
CornerRadius = 5; CornerRadius = 5;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
@ -156,7 +167,19 @@ namespace osu.Game.Overlays.Chat.Listing
} }
}, true); }, true);
Action = () => (channelJoined.Value ? OnRequestLeave : OnRequestJoin)?.Invoke(Channel); Action = () =>
{
if (channelJoined.Value)
{
OnRequestLeave?.Invoke(Channel);
sampleLeave?.Play();
}
else
{
OnRequestJoin?.Invoke(Channel);
sampleJoin?.Play();
}
};
} }
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)

View File

@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
private Sample sampleOpen; private Sample sampleOpen;
private Sample sampleClose; private Sample sampleClose;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds(); protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverClickSounds();
public ExpandDetailsButton() public ExpandDetailsButton()
{ {