mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 21:52:58 +08:00
Add button sound effect
This commit is contained in:
parent
1293bbdbd9
commit
a4ec32b499
@ -4,6 +4,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -26,6 +28,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
private readonly double adjustAmount;
|
private readonly double adjustAmount;
|
||||||
private ScheduledDelegate adjustDelegate;
|
private ScheduledDelegate adjustDelegate;
|
||||||
|
|
||||||
|
private const int max_multiplier = 10;
|
||||||
|
|
||||||
private const int adjust_levels = 4;
|
private const int adjust_levels = 4;
|
||||||
|
|
||||||
private const double initial_delay = 300;
|
private const double initial_delay = 300;
|
||||||
@ -40,6 +44,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private readonly OsuSpriteText text;
|
private readonly OsuSpriteText text;
|
||||||
|
|
||||||
|
private Sample sample;
|
||||||
|
|
||||||
public LocalisableString Text
|
public LocalisableString Text
|
||||||
{
|
{
|
||||||
get => text.Text;
|
get => text.Text;
|
||||||
@ -79,8 +85,10 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(AudioManager audio)
|
||||||
{
|
{
|
||||||
|
sample = audio.Samples.Get(@"UI/notch-tick");
|
||||||
|
|
||||||
background.Colour = colourProvider.Background3;
|
background.Colour = colourProvider.Background3;
|
||||||
|
|
||||||
for (int i = 1; i <= adjust_levels; i++)
|
for (int i = 1; i <= adjust_levels; i++)
|
||||||
@ -120,6 +128,17 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
adjustDelay = Math.Max(minimum_delay, adjustDelay * 0.9f);
|
adjustDelay = Math.Max(minimum_delay, adjustDelay * 0.9f);
|
||||||
|
|
||||||
hoveredBox.Flash();
|
hoveredBox.Flash();
|
||||||
|
|
||||||
|
var channel = sample?.GetChannel();
|
||||||
|
|
||||||
|
if (channel != null)
|
||||||
|
{
|
||||||
|
double repeatModifier = 0.05f * (Math.Abs(adjustDelay - initial_delay) / minimum_delay);
|
||||||
|
double multiplierModifier = (hoveredBox.Multiplier / max_multiplier) * 0.2f;
|
||||||
|
|
||||||
|
channel.Frequency.Value = 1 + multiplierModifier + repeatModifier;
|
||||||
|
channel.Play();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,7 +214,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
case 3: return 5;
|
case 3: return 5;
|
||||||
|
|
||||||
case 4: return 10;
|
case 4:
|
||||||
|
return max_multiplier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user