Use separate samples for scrolling to top and scrolling to previous

This commit is contained in:
Jamie Taylor 2024-07-11 18:22:27 +09:00
parent ad2b354d9c
commit 320df7da2b
No known key found for this signature in database
GPG Key ID: 2ACFA8B6370B8C8C
2 changed files with 17 additions and 8 deletions

View File

@ -16,15 +16,9 @@ public enum HoverSampleSet
[Description("button-sidebar")] [Description("button-sidebar")]
ButtonSidebar, ButtonSidebar,
[Description("toolbar")]
Toolbar,
[Description("tabselect")] [Description("tabselect")]
TabSelect, TabSelect,
[Description("scrolltotop")]
ScrollToTop,
[Description("dialog-cancel")] [Description("dialog-cancel")]
DialogCancel, DialogCancel,

View File

@ -5,6 +5,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -112,8 +114,12 @@ public Visibility State
public Bindable<float?> LastScrollTarget = new Bindable<float?>(); public Bindable<float?> LastScrollTarget = new Bindable<float?>();
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
private Sample scrollToTopSample;
private Sample scrollToPreviousSample;
public ScrollBackButton() public ScrollBackButton()
: base(HoverSampleSet.ScrollToTop)
{ {
Size = new Vector2(50); Size = new Vector2(50);
Alpha = 0; Alpha = 0;
@ -150,11 +156,14 @@ public ScrollBackButton()
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OverlayColourProvider colourProvider, AudioManager audio)
{ {
IdleColour = colourProvider.Background6; IdleColour = colourProvider.Background6;
HoverColour = colourProvider.Background5; HoverColour = colourProvider.Background5;
flashColour = colourProvider.Light1; flashColour = colourProvider.Light1;
scrollToTopSample = audio.Samples.Get(@"UI/scroll-to-top");
scrollToPreviousSample = audio.Samples.Get(@"UI/scroll-to-previous");
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -171,6 +180,12 @@ protected override void LoadComplete()
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)
{ {
background.FlashColour(flashColour, 800, Easing.OutQuint); background.FlashColour(flashColour, 800, Easing.OutQuint);
if (LastScrollTarget.Value == null)
scrollToTopSample?.Play();
else
scrollToPreviousSample?.Play();
return base.OnClick(e); return base.OnClick(e);
} }