Add audio feedback to song select 'random'

This commit is contained in:
Jamie Taylor
2022-01-28 13:27:12 +09:00
parent d1158acb82
commit f59828e2d9
2 changed files with 46 additions and 4 deletions

View File

@ -100,6 +100,7 @@ namespace osu.Game.Screens.Select
private Sample sampleChangeDifficulty;
private Sample sampleChangeBeatmap;
private Sample sampleRandomBeatmap;
private Container carouselContainer;
@ -109,6 +110,8 @@ namespace osu.Game.Screens.Select
private double audioFeedbackLastPlaybackTime;
private bool randomClicked;
[Resolved]
private MusicController music { get; set; }
@ -288,6 +291,7 @@ namespace osu.Game.Screens.Select
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Samples.Get(@"SongSelect/select-expand");
sampleRandomBeatmap = audio.Samples.Get(@"SongSelect/select-random");
SampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection");
if (dialogOverlay != null)
@ -315,8 +319,16 @@ namespace osu.Game.Screens.Select
(new FooterButtonMods { Current = Mods }, ModSelect),
(new FooterButtonRandom
{
NextRandom = () => Carousel.SelectNextRandom(),
PreviousRandom = Carousel.SelectPreviousRandom
NextRandom = () =>
{
randomClicked = true;
Carousel.SelectNextRandom();
},
PreviousRandom = () =>
{
randomClicked = true;
Carousel.SelectPreviousRandom();
}
}, null),
(new FooterButtonOptions(), BeatmapOptions)
};
@ -486,7 +498,9 @@ namespace osu.Game.Screens.Select
{
if (beatmap != null && beatmapInfoPrevious != null && Time.Current - audioFeedbackLastPlaybackTime >= 50)
{
if (beatmap.BeatmapSet?.ID == beatmapInfoPrevious.BeatmapSet?.ID)
if (randomClicked)
sampleRandomBeatmap.Play();
else if (beatmap.BeatmapSet?.ID == beatmapInfoPrevious.BeatmapSet?.ID)
sampleChangeDifficulty.Play();
else
sampleChangeBeatmap.Play();
@ -494,6 +508,7 @@ namespace osu.Game.Screens.Select
audioFeedbackLastPlaybackTime = Time.Current;
}
randomClicked = false;
beatmapInfoPrevious = beatmap;
}