1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Add audio feedback for host change in multiplayer

This commit is contained in:
Jamie Taylor 2022-01-14 18:06:19 +09:00
parent 70f56cd0c9
commit 7e9b5dd150
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
3 changed files with 68 additions and 31 deletions

View File

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

View File

@ -0,0 +1,66 @@
// 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");
Host.ValueChanged += hostChanged;
}
private void hostChanged(ValueChangedEvent<APIUser> value)
{
if (value.OldValue == null) return;
hostChangedSample?.Play();
}
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();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Host.ValueChanged -= hostChanged;
}
}
}

View File

@ -4,12 +4,10 @@
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Online.Multiplayer;
using osuTK;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
@ -18,10 +16,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
{
private FillFlowContainer<ParticipantPanel> panels;
private Sample userJoinSample;
private Sample userLeftSample;
private Sample userKickedSample;
[BackgroundDependencyLoader]
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()