mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Merge pull request #16739 from nekodex/cursor-tap
Add cursor 'tap' audio feedback
This commit is contained in:
@ -51,7 +51,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.202.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.128.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.128.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
|
@ -10,6 +10,8 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -30,13 +32,17 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
private DragRotationState dragRotationState;
|
private DragRotationState dragRotationState;
|
||||||
private Vector2 positionMouseDown;
|
private Vector2 positionMouseDown;
|
||||||
|
|
||||||
|
private Sample tapSample;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load([NotNull] OsuConfigManager config, [CanBeNull] ScreenshotManager screenshotManager)
|
private void load([NotNull] OsuConfigManager config, [CanBeNull] ScreenshotManager screenshotManager, AudioManager audio)
|
||||||
{
|
{
|
||||||
cursorRotate = config.GetBindable<bool>(OsuSetting.CursorRotation);
|
cursorRotate = config.GetBindable<bool>(OsuSetting.CursorRotation);
|
||||||
|
|
||||||
if (screenshotManager != null)
|
if (screenshotManager != null)
|
||||||
screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility);
|
screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility);
|
||||||
|
|
||||||
|
tapSample = audio.Samples.Get(@"UI/cursor-tap");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
@ -87,6 +93,8 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
dragRotationState = DragRotationState.DragStarted;
|
dragRotationState = DragRotationState.DragStarted;
|
||||||
positionMouseDown = e.MousePosition;
|
positionMouseDown = e.MousePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
playTapSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnMouseDown(e);
|
return base.OnMouseDown(e);
|
||||||
@ -104,6 +112,9 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
|
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||||
dragRotationState = DragRotationState.NotDragging;
|
dragRotationState = DragRotationState.NotDragging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (State.Value == Visibility.Visible)
|
||||||
|
playTapSample(0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
@ -121,6 +132,18 @@ namespace osu.Game.Graphics.Cursor
|
|||||||
activeCursor.ScaleTo(0.6f, 250, Easing.In);
|
activeCursor.ScaleTo(0.6f, 250, Easing.In);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playTapSample(double baseFrequency = 1f)
|
||||||
|
{
|
||||||
|
const float random_range = 0.02f;
|
||||||
|
SampleChannel channel = tapSample.GetChannel();
|
||||||
|
|
||||||
|
// Scale to [-0.75, 0.75] so that the sample isn't fully panned left or right (sounds weird)
|
||||||
|
channel.Balance.Value = ((activeCursor.X / DrawWidth) * 2 - 1) * 0.75;
|
||||||
|
channel.Frequency.Value = baseFrequency - (random_range / 2f) + RNG.NextDouble(random_range);
|
||||||
|
|
||||||
|
channel.Play();
|
||||||
|
}
|
||||||
|
|
||||||
public class Cursor : Container
|
public class Cursor : Container
|
||||||
{
|
{
|
||||||
private Container cursorContainer;
|
private Container cursorContainer;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="10.8.0" />
|
<PackageReference Include="Realm" Version="10.8.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.128.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.128.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.202.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.13.0" />
|
<PackageReference Include="Sentry" Version="3.13.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
<PackageReference Include="SharpCompress" Version="0.30.1" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.128.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.128.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.115.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.202.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
Reference in New Issue
Block a user