mirror of
https://github.com/ppy/osu.git
synced 2026-05-23 12:37:30 +08:00
Play error sound when random selection fails
This commit is contained in:
@@ -771,12 +771,12 @@ namespace osu.Game.Screens.SelectV2
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PreviousRandom()
|
||||
public bool PreviousRandom()
|
||||
{
|
||||
var carouselItems = GetCarouselItems();
|
||||
|
||||
if (carouselItems?.Any() != true)
|
||||
return;
|
||||
return false;
|
||||
|
||||
while (randomHistory.Any())
|
||||
{
|
||||
@@ -786,7 +786,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
var previousBeatmapItem = carouselItems.FirstOrDefault(i => i.Model is BeatmapInfo b && b.Equals(previousBeatmap));
|
||||
|
||||
if (previousBeatmapItem == null)
|
||||
return;
|
||||
return false;
|
||||
|
||||
if (CurrentSelection is BeatmapInfo beatmapInfo)
|
||||
{
|
||||
@@ -800,8 +800,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
}
|
||||
|
||||
RequestSelection(previousBeatmap);
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private double distanceBetween(CarouselItem item1, CarouselItem item2) => Math.Ceiling(Math.Abs(item1.CarouselYPosition - item2.CarouselYPosition) / PanelBeatmapSet.HEIGHT);
|
||||
|
||||
@@ -6,6 +6,8 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@@ -103,6 +105,8 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
public override bool ShowFooter => true;
|
||||
|
||||
private Sample? errorSample;
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase? game { get; set; }
|
||||
|
||||
@@ -128,8 +132,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
errorSample = audio.Samples.Get(@"UI/generic-error");
|
||||
|
||||
AddRangeInternal(new Drawable[]
|
||||
{
|
||||
new GlobalScrollAdjustsVolume(),
|
||||
@@ -286,8 +292,16 @@ namespace osu.Game.Screens.SelectV2
|
||||
},
|
||||
new FooterButtonRandom
|
||||
{
|
||||
NextRandom = () => carousel.NextRandom(),
|
||||
PreviousRandom = () => carousel.PreviousRandom()
|
||||
NextRandom = () =>
|
||||
{
|
||||
if (!carousel.NextRandom())
|
||||
errorSample?.Play();
|
||||
},
|
||||
PreviousRandom = () =>
|
||||
{
|
||||
if (!carousel.PreviousRandom())
|
||||
errorSample?.Play();
|
||||
}
|
||||
},
|
||||
new FooterButtonOptions
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user