1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

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 @@ namespace osu.Game.Graphics.UserInterface
[Description("button-sidebar")]
ButtonSidebar,
[Description("toolbar")]
Toolbar,
[Description("tabselect")]
TabSelect,
[Description("scrolltotop")]
ScrollToTop,
[Description("dialog-cancel")]
DialogCancel,

View File

@ -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 @@ namespace osu.Game.Overlays
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 @@ namespace osu.Game.Overlays
}
[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 @@ namespace osu.Game.Overlays
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);
}