Merge pull request #14147 from nekodex/more-missing-sounds

Misc hover/select sound usage updates
This commit is contained in:
Dean Herbert
2021-08-08 04:14:04 +09:00
committed by GitHub
7 changed files with 52 additions and 10 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.807.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2021.807.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">

View File

@ -288,7 +288,7 @@ namespace osu.Game.Graphics.UserInterface
}, },
}; };
AddInternal(new HoverSounds()); AddInternal(new HoverClickSounds());
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -1,6 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osuTK.Graphics; using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -13,6 +16,12 @@ namespace osu.Game.Graphics.UserInterface
{ {
public class OsuMenu : Menu public class OsuMenu : Menu
{ {
private Sample sampleOpen;
private Sample sampleClose;
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
private bool wasOpened;
public OsuMenu(Direction direction, bool topLevelMenu = false) public OsuMenu(Direction direction, bool topLevelMenu = false)
: base(direction, topLevelMenu) : base(direction, topLevelMenu)
{ {
@ -22,8 +31,30 @@ namespace osu.Game.Graphics.UserInterface
ItemsContainer.Padding = new MarginPadding(5); ItemsContainer.Padding = new MarginPadding(5);
} }
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint); [BackgroundDependencyLoader]
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint); private void load(AudioManager audio)
{
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
}
protected override void AnimateOpen()
{
if (!TopLevelMenu && !wasOpened)
sampleOpen?.Play();
this.FadeIn(300, Easing.OutQuint);
wasOpened = true;
}
protected override void AnimateClose()
{
if (!TopLevelMenu && wasOpened)
sampleClose?.Play();
this.FadeOut(300, Easing.OutQuint);
wasOpened = false;
}
protected override void UpdateSize(Vector2 newSize) protected override void UpdateSize(Vector2 newSize)
{ {

View File

@ -79,8 +79,6 @@ 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);

View File

@ -5,6 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework; using osu.Framework;
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.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -44,6 +46,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
public event Action<SelectionState> StateChanged; public event Action<SelectionState> StateChanged;
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
private readonly Box selectionBox; private readonly Box selectionBox;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
@ -62,6 +66,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private SelectionState state; private SelectionState state;
private Sample sampleSelect;
private Sample sampleJoin;
public SelectionState State public SelectionState State
{ {
get => state; get => state;
@ -125,7 +132,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours, AudioManager audio)
{ {
float stripWidth = side_strip_width * (Room.Category.Value == RoomCategory.Spotlight ? 2 : 1); float stripWidth = side_strip_width * (Room.Category.Value == RoomCategory.Spotlight ? 2 : 1);
@ -221,6 +228,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
}, },
}, },
}; };
sampleSelect = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
sampleJoin = audio.Samples.Get($@"UI/{HoverSampleSet.Submit.GetDescription()}-select");
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
@ -273,22 +283,25 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
} }
protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected; protected override bool ShouldBeConsideredForInput(Drawable child) => state == SelectionState.Selected || child is HoverSounds;
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
if (Room != selectedRoom.Value) if (Room != selectedRoom.Value)
{ {
sampleSelect?.Play();
selectedRoom.Value = Room; selectedRoom.Value = Room;
return true; return true;
} }
if (Room.HasPassword.Value) if (Room.HasPassword.Value)
{ {
sampleJoin?.Play();
this.ShowPopover(); this.ShowPopover();
return true; return true;
} }
sampleJoin?.Play();
lounge?.Join(Room, null); lounge?.Join(Room, null);
return base.OnClick(e); return base.OnClick(e);

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.3.0" /> <PackageReference Include="Realm" Version="10.3.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.807.0" /> <PackageReference Include="ppy.osu.Framework" Version="2021.807.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
<PackageReference Include="Sentry" Version="3.8.3" /> <PackageReference Include="Sentry" Version="3.8.3" />
<PackageReference Include="SharpCompress" Version="0.28.3" /> <PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -71,7 +71,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.807.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2021.807.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.803.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2021.808.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup> <PropertyGroup>