mirror of
https://github.com/ppy/osu
synced 2024-12-29 02:12:43 +00:00
Add support for per-ruleset sample playback when switching rulesets (via toolbar)
This commit is contained in:
parent
ebfe9cbe23
commit
21f34be19f
@ -1,6 +1,7 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
@ -13,6 +14,8 @@ using osu.Framework.Input.Events;
|
||||
using osuTK.Input;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -20,6 +23,8 @@ namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
protected Drawable ModeButtonLine { get; private set; }
|
||||
|
||||
private readonly Dictionary<string, Sample> selectionSamples = new Dictionary<string, Sample>();
|
||||
|
||||
public ToolbarRulesetSelector()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
@ -27,7 +32,7 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
@ -54,6 +59,9 @@ namespace osu.Game.Overlays.Toolbar
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var ruleset in Rulesets.AvailableRulesets)
|
||||
selectionSamples[ruleset.ShortName] = audio.Samples.Get($"UI/ruleset-select-{ruleset.ShortName}");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -72,6 +80,10 @@ namespace osu.Game.Overlays.Toolbar
|
||||
if (SelectedTab != null)
|
||||
{
|
||||
ModeButtonLine.MoveToX(SelectedTab.DrawPosition.X, !hasInitialPosition ? 0 : 200, Easing.OutQuint);
|
||||
|
||||
if (hasInitialPosition)
|
||||
selectionSamples[SelectedTab.Value.ShortName]?.Play();
|
||||
|
||||
hasInitialPosition = true;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user