mirror of https://github.com/ppy/osu
Use separate samples for scrolling to top and scrolling to previous
This commit is contained in:
parent
ad2b354d9c
commit
320df7da2b
|
@ -16,15 +16,9 @@ public enum HoverSampleSet
|
|||
[Description("button-sidebar")]
|
||||
ButtonSidebar,
|
||||
|
||||
[Description("toolbar")]
|
||||
Toolbar,
|
||||
|
||||
[Description("tabselect")]
|
||||
TabSelect,
|
||||
|
||||
[Description("scrolltotop")]
|
||||
ScrollToTop,
|
||||
|
||||
[Description("dialog-cancel")]
|
||||
DialogCancel,
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
|
@ -112,8 +114,12 @@ public Visibility State
|
|||
|
||||
public Bindable<float?> LastScrollTarget = new Bindable<float?>();
|
||||
|
||||
protected override HoverSounds CreateHoverSounds(HoverSampleSet sampleSet) => new HoverSounds();
|
||||
|
||||
private Sample scrollToTopSample;
|
||||
private Sample scrollToPreviousSample;
|
||||
|
||||
public ScrollBackButton()
|
||||
: base(HoverSampleSet.ScrollToTop)
|
||||
{
|
||||
Size = new Vector2(50);
|
||||
Alpha = 0;
|
||||
|
@ -150,11 +156,14 @@ public ScrollBackButton()
|
|||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
private void load(OverlayColourProvider colourProvider, AudioManager audio)
|
||||
{
|
||||
IdleColour = colourProvider.Background6;
|
||||
HoverColour = colourProvider.Background5;
|
||||
flashColour = colourProvider.Light1;
|
||||
|
||||
scrollToTopSample = audio.Samples.Get(@"UI/scroll-to-top");
|
||||
scrollToPreviousSample = audio.Samples.Get(@"UI/scroll-to-previous");
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -171,6 +180,12 @@ protected override void LoadComplete()
|
|||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
background.FlashColour(flashColour, 800, Easing.OutQuint);
|
||||
|
||||
if (LastScrollTarget.Value == null)
|
||||
scrollToTopSample?.Play();
|
||||
else
|
||||
scrollToPreviousSample?.Play();
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue