mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:22:56 +08:00
Merge pull request #18818 from nekodex/rearrangeable-list-feedback
Add audio feedback for rearranging list items
This commit is contained in:
commit
730228ec2a
@ -51,7 +51,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.623.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.621.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.621.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
|
@ -3,9 +3,14 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.Containers
|
namespace osu.Game.Graphics.Containers
|
||||||
{
|
{
|
||||||
@ -18,11 +23,49 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected override ScrollContainer<Drawable> CreateScrollContainer() => new OsuScrollContainer();
|
protected override ScrollContainer<Drawable> CreateScrollContainer() => new OsuScrollContainer();
|
||||||
|
|
||||||
|
private Sample sampleSwap;
|
||||||
|
private double sampleLastPlaybackTime;
|
||||||
|
|
||||||
protected sealed override RearrangeableListItem<TModel> CreateDrawable(TModel item) => CreateOsuDrawable(item).With(d =>
|
protected sealed override RearrangeableListItem<TModel> CreateDrawable(TModel item) => CreateOsuDrawable(item).With(d =>
|
||||||
{
|
{
|
||||||
d.DragActive.BindTo(DragActive);
|
d.DragActive.BindTo(DragActive);
|
||||||
});
|
});
|
||||||
|
|
||||||
protected abstract OsuRearrangeableListItem<TModel> CreateOsuDrawable(TModel item);
|
protected abstract OsuRearrangeableListItem<TModel> CreateOsuDrawable(TModel item);
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Items.CollectionChanged += (_, args) =>
|
||||||
|
{
|
||||||
|
if (args.Action == NotifyCollectionChangedAction.Move)
|
||||||
|
playSwapSample();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSwapSample()
|
||||||
|
{
|
||||||
|
if (!DragActive.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Time.Current - sampleLastPlaybackTime <= 35)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var channel = sampleSwap?.GetChannel();
|
||||||
|
if (channel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
channel.Frequency.Value = 0.96 + RNG.NextDouble(0.08);
|
||||||
|
channel.Play();
|
||||||
|
sampleLastPlaybackTime = Time.Current;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(AudioManager audio)
|
||||||
|
{
|
||||||
|
sampleSwap = audio.Samples.Get(@"UI/item-swap");
|
||||||
|
sampleLastPlaybackTime = Time.Current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="10.14.0" />
|
<PackageReference Include="Realm" Version="10.14.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.621.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.621.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.623.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.17.1" />
|
<PackageReference Include="Sentry" Version="3.17.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.621.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.621.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.618.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.623.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user