Skip to content

Commit b3ed771

Browse files
authored
Merge pull request #35185 from nekodex/matchmaking-more-sfx
Yet more matchmaking SFX work
2 parents 557df19 + bc7e02c commit b3ed771

File tree

6 files changed

+93
-17
lines changed

6 files changed

+93
-17
lines changed

osu.Game/Screens/Menu/ButtonSystem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private void load(AudioManager audio, IdleTracker? idleTracker, GameHost host)
161161
{
162162
Padding = new MarginPadding { Left = WEDGE_WIDTH }
163163
});
164-
buttonsMulti.Add(new MainMenuButton("quick play", @"button-default-select", FontAwesome.Solid.Bolt, new Color4(94, 63, 186, 255), onMatchmaking, Key.Q));
164+
buttonsMulti.Add(new MainMenuButton("quick play", @"button-daily-select", FontAwesome.Solid.Bolt, new Color4(94, 63, 186, 255), onMatchmaking, Key.Q));
165165
buttonsMulti.ForEach(b => b.VisibleState = ButtonSystemState.Multi);
166166

167167
buttonsEdit.Add(new MainMenuButton(EditorStrings.BeatmapEditor.ToLower(), @"button-default-select", OsuIcon.Beatmap, new Color4(238, 170, 0, 255), (_, _) => OnEditBeatmap?.Invoke(), Key.B,

osu.Game/Screens/OnlinePlay/Matchmaking/Match/StageDisplay.StageSegment.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ internal partial class StageSegment : CompositeDrawable
3939
private DateTimeOffset countdownEndTime;
4040
private SpriteIcon arrow = null!;
4141

42-
private Sample? countdownTickSample;
43-
private double? lastSamplePlayback;
42+
private Sample? segmentStartedSample;
4443

4544
private Container mainContent = null!;
4645

@@ -120,7 +119,7 @@ private void load(AudioManager audio, OverlayColourProvider colourProvider)
120119
};
121120

122121
Alpha = 0.5f;
123-
countdownTickSample = audio.Samples.Get(@"Multiplayer/countdown-tick");
122+
segmentStartedSample = audio.Samples.Get(@"Multiplayer/Matchmaking/stage-segment");
124123
}
125124

126125
protected override void LoadComplete()
@@ -156,15 +155,6 @@ protected override void Update()
156155
}
157156

158157
progressBar.Width = (float)Math.Clamp(elapsed.TotalMilliseconds / total.TotalMilliseconds, 0, 1);
159-
160-
int secondsRemaining = Math.Max(0, (int)Math.Ceiling((total.TotalMilliseconds - elapsed.TotalMilliseconds) / 1000));
161-
162-
if (total.TotalMilliseconds - elapsed.TotalMilliseconds <= 3000
163-
&& lastSamplePlayback != secondsRemaining)
164-
{
165-
countdownTickSample?.Play();
166-
lastSamplePlayback = secondsRemaining;
167-
}
168158
}
169159

170160
private void onMatchRoomStateChanged(MatchRoomState? state) => Scheduler.Add(() =>
@@ -213,6 +203,8 @@ private void onCountdownStarted(MultiplayerCountdown countdown) => Scheduler.Add
213203
arrow.FadeIn(500, Easing.OutQuint);
214204

215205
this.FadeIn(200);
206+
207+
segmentStartedSample?.Play();
216208
});
217209

218210
private void onCountdownStopped(MultiplayerCountdown countdown) => Scheduler.Add(() =>

osu.Game/Screens/OnlinePlay/Matchmaking/Match/StageDisplay.StatusText.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ private void onMatchRoomStateChanged(MatchRoomState? state) => Scheduler.Add(()
6565
if (text.Text == string.Empty || (lastSamplePlayback != null && Time.Current - lastSamplePlayback < OsuGameBase.SAMPLE_DEBOUNCE_TIME))
6666
return;
6767

68-
textChangedSample?.Play();
69-
lastSamplePlayback = Time.Current;
68+
if (matchmakingState.Stage is MatchmakingStage.WaitingForClientsJoin or MatchmakingStage.WaitingForClientsBeatmapDownload)
69+
{
70+
textChangedSample?.Play();
71+
lastSamplePlayback = Time.Current;
72+
}
7073

7174
LocalisableString textForStatus = getTextForStatus(matchmakingState.Stage);
7275

osu.Game/Screens/OnlinePlay/Matchmaking/Match/StageDisplay.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
using System.Linq;
55
using osu.Framework.Allocation;
6+
using osu.Framework.Audio;
7+
using osu.Framework.Audio.Sample;
68
using osu.Framework.Extensions.Color4Extensions;
79
using osu.Framework.Graphics;
810
using osu.Framework.Graphics.Colour;
@@ -138,8 +140,15 @@ private partial class CurrentRoundDisplay : CompositeDrawable
138140
private Circle innerCircle = null!;
139141
private CircularProgress progress = null!;
140142

143+
private Sample? swishSample;
144+
private Sample? swooshSample;
145+
private Sample? roundUpSample;
146+
private SampleChannel? swishChannel;
147+
private SampleChannel? swooshChannel;
148+
private SampleChannel? roundUpChannel;
149+
141150
[BackgroundDependencyLoader]
142-
private void load(OverlayColourProvider colours)
151+
private void load(OverlayColourProvider colours, AudioManager audio)
143152
{
144153
Size = new Vector2(76);
145154

@@ -210,6 +219,10 @@ private void load(OverlayColourProvider colours)
210219
Text = $"{round_count}"
211220
},
212221
};
222+
223+
swishSample = audio.Samples.Get(@"UI/overlay-pop-in");
224+
swooshSample = audio.Samples.Get(@"UI/overlay-big-pop-out");
225+
roundUpSample = audio.Samples.Get(@"Multiplayer/Matchmaking/round-up");
213226
}
214227

215228
private int round;
@@ -231,11 +244,39 @@ public int? Round
231244
.MoveToY(0, 500, Easing.InQuart)
232245
.ScaleTo(1, 500, Easing.InQuart);
233246

247+
swishChannel = swishSample?.GetChannel();
248+
249+
if (swishChannel != null)
250+
{
251+
swishChannel.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
252+
swishChannel?.Play();
253+
}
254+
255+
Scheduler.AddDelayed(() =>
256+
{
257+
swooshChannel = swooshSample?.GetChannel();
258+
259+
if (swooshChannel == null) return;
260+
261+
swooshChannel.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
262+
swooshChannel?.Play();
263+
}, 1250);
264+
234265
Scheduler.AddDelayed(() =>
235266
{
236267
progress.ProgressTo((float)round / round_count, 500, Easing.InOutQuart);
268+
237269
Scheduler.AddDelayed(() =>
238270
{
271+
roundUpChannel = roundUpSample?.GetChannel();
272+
273+
if (roundUpChannel != null)
274+
{
275+
roundUpChannel.Balance.Value = -OsuGameBase.SFX_STEREO_STRENGTH;
276+
roundUpChannel.Frequency.Value = 1f + round * 0.05f;
277+
roundUpChannel?.Play();
278+
}
279+
239280
innerCircle
240281
.FadeTo(1, 250, Easing.OutQuint)
241282
.Then()

osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using osu.Framework.Input.Bindings;
1919
using osu.Framework.Input.Events;
2020
using osu.Framework.Screens;
21+
using osu.Framework.Threading;
2122
using osu.Game.Database;
2223
using osu.Game.Graphics;
2324
using osu.Game.Graphics.Sprites;
@@ -71,15 +72,23 @@ public partial class ScreenQueue : OsuScreen
7172
[Resolved]
7273
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
7374

75+
[Resolved]
76+
private MusicController musicController { get; set; } = null!;
77+
7478
private readonly IBindable<MatchmakingScreenState> currentState = new Bindable<MatchmakingScreenState>();
7579

7680
private readonly Bindable<MatchmakingPool[]> availablePools = new Bindable<MatchmakingPool[]>();
7781
private readonly Bindable<MatchmakingPool?> selectedPool = new Bindable<MatchmakingPool?>();
7882

7983
private CancellationTokenSource userLookupCancellation = new CancellationTokenSource();
8084

85+
private Sample? enqueueSample;
86+
private Sample? waitingLoopSample;
8187
private Sample? matchFoundSample;
8288

89+
private SampleChannel? waitingLoopChannel;
90+
private ScheduledDelegate? startLoopPlaybackDelegate;
91+
8392
protected override void LoadComplete()
8493
{
8594
base.LoadComplete();
@@ -155,6 +164,8 @@ private async Task populateAvailablePools()
155164
[BackgroundDependencyLoader]
156165
private void load(AudioManager audio)
157166
{
167+
enqueueSample = audio.Samples.Get(@"Multiplayer/Matchmaking/enqueue");
168+
waitingLoopSample = audio.Samples.Get(@"Multiplayer/Matchmaking/waiting-loop");
158169
matchFoundSample = audio.Samples.Get(@"Multiplayer/Matchmaking/match-found");
159170
}
160171

@@ -247,6 +258,9 @@ public void SetState(MatchmakingScreenState newState)
247258
mainContent.FadeInFromZero(500, Easing.OutQuint);
248259
mainContent.Clear();
249260

261+
startLoopPlaybackDelegate?.Cancel();
262+
stopWaitingLoopPlayback();
263+
250264
switch (newState)
251265
{
252266
case MatchmakingScreenState.Idle:
@@ -334,6 +348,9 @@ public void SetState(MatchmakingScreenState newState)
334348
sendToBackgroundButton.Enabled.Value = true;
335349
sendToBackgroundButton.TooltipText = "You will receive a notification when your game is ready. Make sure to watch out for it!";
336350
}, 5000);
351+
352+
enqueueSample?.Play();
353+
startLoopPlaybackDelegate = Scheduler.AddDelayed(startWaitingLoopPlayback, 2000);
337354
break;
338355

339356
case MatchmakingScreenState.PendingAccept:
@@ -369,6 +386,7 @@ public void SetState(MatchmakingScreenState newState)
369386
}
370387
};
371388
matchFoundSample?.Play();
389+
musicController.DuckMomentarily(1250);
372390
break;
373391

374392
case MatchmakingScreenState.AcceptedWaitingForRoom:
@@ -394,6 +412,8 @@ public void SetState(MatchmakingScreenState newState)
394412
},
395413
}
396414
};
415+
416+
startWaitingLoopPlayback();
397417
break;
398418

399419
case MatchmakingScreenState.InRoom:
@@ -430,6 +450,8 @@ protected override void Dispose(bool isDisposing)
430450
{
431451
base.Dispose(isDisposing);
432452

453+
stopWaitingLoopPlayback();
454+
433455
if (client.IsNotNull())
434456
client.MatchmakingLobbyStatusChanged -= onMatchmakingLobbyStatusChanged;
435457
}
@@ -443,6 +465,24 @@ public enum MatchmakingScreenState
443465
InRoom
444466
}
445467

468+
private void startWaitingLoopPlayback()
469+
{
470+
stopWaitingLoopPlayback();
471+
472+
waitingLoopChannel = waitingLoopSample?.GetChannel();
473+
if (waitingLoopChannel == null)
474+
return;
475+
476+
waitingLoopChannel.Looping = true;
477+
waitingLoopChannel?.Play();
478+
}
479+
480+
private void stopWaitingLoopPlayback()
481+
{
482+
waitingLoopChannel?.Stop();
483+
waitingLoopChannel?.Dispose();
484+
}
485+
446486
private partial class BeginQueueingButton : SelectionButton
447487
{
448488
public readonly IBindable<MatchmakingPool?> SelectedPool = new Bindable<MatchmakingPool?>();

osu.Game/osu.Game.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</PackageReference>
3737
<PackageReference Include="Realm" Version="20.1.0" />
3838
<PackageReference Include="ppy.osu.Framework" Version="2025.930.0" />
39-
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.1001.0" />
39+
<PackageReference Include="ppy.osu.Game.Resources" Version="2025.1006.0" />
4040
<PackageReference Include="Sentry" Version="5.1.1" />
4141
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
4242
<PackageReference Include="SharpCompress" Version="0.39.0" />

0 commit comments

Comments
 (0)