Skip to content

Commit

Permalink
Merge pull request #12528 from nekodex/ruleset-switch-sounds
Browse files Browse the repository at this point in the history
Add support for playing a per-ruleset sound when switching rulesets
  • Loading branch information
peppy authored Apr 23, 2021
2 parents 8de8856 + fbb9cb3 commit 8ee881b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<Reference Include="Java.Interop" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.422.1" />
</ItemGroup>
</Project>
14 changes: 13 additions & 1 deletion osu.Game/Overlays/Toolbar/ToolbarRulesetSelector.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -13,21 +14,25 @@
using osuTK.Input;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;

namespace osu.Game.Overlays.Toolbar
{
public class ToolbarRulesetSelector : RulesetSelector
{
protected Drawable ModeButtonLine { get; private set; }

private readonly Dictionary<string, Sample> selectionSamples = new Dictionary<string, Sample>();

public ToolbarRulesetSelector()
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
}

[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audio)
{
AddRangeInternal(new[]
{
Expand All @@ -54,6 +59,9 @@ private void load()
}
}
});

foreach (var ruleset in Rulesets.AvailableRulesets)
selectionSamples[ruleset.ShortName] = audio.Samples.Get($"UI/ruleset-select-{ruleset.ShortName}");
}

protected override void LoadComplete()
Expand All @@ -72,6 +80,10 @@ private void moveLineToCurrent() => ScheduleAfterChildren(() =>
if (SelectedTab != null)
{
ModeButtonLine.MoveToX(SelectedTab.DrawPosition.X, !hasInitialPosition ? 0 : 200, Easing.OutQuint);

if (hasInitialPosition)
selectionSamples[SelectedTab.Value.ShortName]?.Play();

hasInitialPosition = true;
}
});
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/osu.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<PackageReference Include="Microsoft.NETCore.Targets" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.422.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
<PackageReference Include="Sentry" Version="3.2.0" />
<PackageReference Include="SharpCompress" Version="0.28.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
Expand Down
2 changes: 1 addition & 1 deletion osu.iOS.props
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.422.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.412.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.422.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
<PropertyGroup>
Expand Down

0 comments on commit 8ee881b

Please sign in to comment.