1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 11:27:24 +08:00

Merge pull request #16447 from nekodex/mp-host-changed-sfx

Add audio feedback for host change in multiplayer rooms
This commit is contained in:
Dean Herbert 2022-01-15 23:43:35 +09:00 committed by GitHub
commit 4ca2822d40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 70 additions and 34 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="2022.114.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.111.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2022.111.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">

View File

@ -21,6 +21,7 @@ using osu.Game.Overlays.Mods;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Screens.OnlinePlay.Match.Components; using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Multiplayer;
namespace osu.Game.Screens.OnlinePlay.Match namespace osu.Game.Screens.OnlinePlay.Match
{ {
@ -101,6 +102,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
beatmapAvailabilityTracker, beatmapAvailabilityTracker,
new MultiplayerRoomSounds(),
new GridContainer new GridContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,

View File

@ -0,0 +1,65 @@
// 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;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Multiplayer;
namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
public class MultiplayerRoomSounds : MultiplayerRoomComposite
{
private Sample hostChangedSample;
private Sample userJoinedSample;
private Sample userLeftSample;
private Sample userKickedSample;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
hostChangedSample = audio.Samples.Get(@"Multiplayer/host-changed");
userJoinedSample = audio.Samples.Get(@"Multiplayer/player-joined");
userLeftSample = audio.Samples.Get(@"Multiplayer/player-left");
userKickedSample = audio.Samples.Get(@"Multiplayer/player-kicked");
}
protected override void LoadComplete()
{
base.LoadComplete();
Host.BindValueChanged(hostChanged);
}
protected override void UserJoined(MultiplayerRoomUser user)
{
base.UserJoined(user);
userJoinedSample?.Play();
}
protected override void UserLeft(MultiplayerRoomUser user)
{
base.UserLeft(user);
userLeftSample?.Play();
}
protected override void UserKicked(MultiplayerRoomUser user)
{
base.UserKicked(user);
userKickedSample?.Play();
}
private void hostChanged(ValueChangedEvent<APIUser> value)
{
// only play sound when the host changes from an already-existing host.
if (value.OldValue == null) return;
hostChangedSample?.Play();
}
}
}

View File

@ -4,12 +4,10 @@
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
using osu.Game.Online.Multiplayer;
using osuTK; using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
@ -18,10 +16,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
{ {
private FillFlowContainer<ParticipantPanel> panels; private FillFlowContainer<ParticipantPanel> panels;
private Sample userJoinSample;
private Sample userLeftSample;
private Sample userKickedSample;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
{ {
@ -41,31 +35,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
} }
} }
}; };
userJoinSample = audio.Samples.Get(@"Multiplayer/player-joined");
userLeftSample = audio.Samples.Get(@"Multiplayer/player-left");
userKickedSample = audio.Samples.Get(@"Multiplayer/player-kicked");
}
protected override void UserJoined(MultiplayerRoomUser user)
{
base.UserJoined(user);
userJoinSample?.Play();
}
protected override void UserLeft(MultiplayerRoomUser user)
{
base.UserLeft(user);
userLeftSample?.Play();
}
protected override void UserKicked(MultiplayerRoomUser user)
{
base.UserKicked(user);
userKickedSample?.Play();
} }
protected override void OnRoomUpdated() protected override void OnRoomUpdated()

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.7.1" /> <PackageReference Include="Realm" Version="10.7.1" />
<PackageReference Include="ppy.osu.Framework" Version="2022.111.0" /> <PackageReference Include="ppy.osu.Framework" Version="2022.111.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.114.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.0" />
<PackageReference Include="Sentry" Version="3.12.1" /> <PackageReference Include="Sentry" Version="3.12.1" />
<PackageReference Include="SharpCompress" Version="0.30.1" /> <PackageReference Include="SharpCompress" Version="0.30.1" />
<PackageReference Include="NUnit" Version="3.13.2" /> <PackageReference Include="NUnit" Version="3.13.2" />

View File

@ -61,7 +61,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.111.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2022.111.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.114.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.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>