mirror of
https://github.com/ppy/osu
synced 2024-12-17 12:25:19 +00:00
Merge pull request #25395 from nekodex/buttonsystem-updates
SFX improvements for `ButtonSystem`/`MainMenu`
This commit is contained in:
commit
67de1b34bd
@ -85,7 +85,8 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly List<MainMenuButton> buttonsTopLevel = new List<MainMenuButton>();
|
||||
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
||||
|
||||
private Sample sampleBack;
|
||||
private Sample sampleBackToLogo;
|
||||
private Sample sampleLogoSwoosh;
|
||||
|
||||
private readonly LogoTrackingContainer logoTrackingContainer;
|
||||
|
||||
@ -104,7 +105,7 @@ namespace osu.Game.Screens.Menu
|
||||
buttonArea.AddRange(new Drawable[]
|
||||
{
|
||||
new MainMenuButton(ButtonSystemStrings.Settings, string.Empty, FontAwesome.Solid.Cog, new Color4(85, 85, 85, 255), () => OnSettings?.Invoke(), -WEDGE_WIDTH, Key.O),
|
||||
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"button-back-select", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
|
||||
backButton = new MainMenuButton(ButtonSystemStrings.Back, @"back-to-top", OsuIcon.LeftCircle, new Color4(51, 58, 94, 255), () => State = ButtonSystemState.TopLevel,
|
||||
-WEDGE_WIDTH)
|
||||
{
|
||||
VisibleState = ButtonSystemState.Play,
|
||||
@ -127,14 +128,14 @@ namespace osu.Game.Screens.Menu
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
|
||||
{
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-solo-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-generic-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Solo, @"button-default-select", FontAwesome.Solid.User, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Multi, @"button-default-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
||||
buttonsPlay.Add(new MainMenuButton(ButtonSystemStrings.Playlists, @"button-default-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
||||
buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play);
|
||||
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Play, @"button-play-select", OsuIcon.Logo, new Color4(102, 68, 204, 255), () => State = ButtonSystemState.Play, WEDGE_WIDTH, Key.P));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-edit-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-direct-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Edit, @"button-default-select", OsuIcon.EditCircle, new Color4(238, 170, 0, 255), () => OnEdit?.Invoke(), 0, Key.E));
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Browse, @"button-default-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
||||
|
||||
if (host.CanExit)
|
||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
||||
@ -155,7 +156,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle);
|
||||
|
||||
sampleBack = audio.Samples.Get(@"Menu/button-back-select");
|
||||
sampleBackToLogo = audio.Samples.Get(@"Menu/back-to-logo");
|
||||
sampleLogoSwoosh = audio.Samples.Get(@"Menu/osu-logo-swoosh");
|
||||
}
|
||||
|
||||
private void onMultiplayer()
|
||||
@ -197,6 +199,7 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
if (State == ButtonSystemState.Initial)
|
||||
{
|
||||
StopSamplePlayback();
|
||||
logo?.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
@ -260,10 +263,15 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
case ButtonSystemState.TopLevel:
|
||||
State = ButtonSystemState.Initial;
|
||||
sampleBack?.Play();
|
||||
|
||||
// Samples are explicitly played here in response to user interaction and not when transitioning due to idle.
|
||||
StopSamplePlayback();
|
||||
sampleBackToLogo?.Play();
|
||||
|
||||
return true;
|
||||
|
||||
case ButtonSystemState.Play:
|
||||
StopSamplePlayback();
|
||||
backButton.TriggerClick();
|
||||
return true;
|
||||
|
||||
@ -272,6 +280,13 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public void StopSamplePlayback()
|
||||
{
|
||||
buttonsPlay.ForEach(button => button.StopSamplePlayback());
|
||||
buttonsTopLevel.ForEach(button => button.StopSamplePlayback());
|
||||
logo?.StopSamplePlayback();
|
||||
}
|
||||
|
||||
private bool onOsuLogo()
|
||||
{
|
||||
switch (state)
|
||||
@ -346,6 +361,9 @@ namespace osu.Game.Screens.Menu
|
||||
logo?.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
|
||||
logo?.ScaleTo(1, 800, Easing.OutExpo);
|
||||
}, buttonArea.Alpha * 150);
|
||||
|
||||
if (lastState == ButtonSystemState.TopLevel)
|
||||
sampleLogoSwoosh?.Play();
|
||||
break;
|
||||
|
||||
case ButtonSystemState.TopLevel:
|
||||
|
@ -7,6 +7,8 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -89,8 +91,10 @@ namespace osu.Game.Screens.Menu
|
||||
private SongTicker songTicker;
|
||||
private Container logoTarget;
|
||||
|
||||
private Sample reappearSampleSwoosh;
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics)
|
||||
private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings, OsuConfigManager config, SessionStatics statics, AudioManager audio)
|
||||
{
|
||||
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
||||
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
|
||||
@ -162,6 +166,8 @@ namespace osu.Game.Screens.Menu
|
||||
Buttons.OnSettings = () => settings?.ToggleVisibility();
|
||||
Buttons.OnBeatmapListing = () => beatmapListing?.ToggleVisibility();
|
||||
|
||||
reappearSampleSwoosh = audio.Samples.Get(@"Menu/reappear-swoosh");
|
||||
|
||||
preloadSongSelect();
|
||||
}
|
||||
|
||||
@ -291,6 +297,10 @@ namespace osu.Game.Screens.Menu
|
||||
{
|
||||
base.OnResuming(e);
|
||||
|
||||
// Ensures any playing `ButtonSystem` samples are stopped when returning to MainMenu (as to not overlap with the 'back' sample)
|
||||
Buttons.StopSamplePlayback();
|
||||
reappearSampleSwoosh?.Play();
|
||||
|
||||
ApplyToBackground(b => (b as BackgroundScreenDefault)?.Next());
|
||||
|
||||
// we may have consumed our preloaded instance, so let's make another.
|
||||
|
@ -51,6 +51,7 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly Action clickAction;
|
||||
private Sample sampleClick;
|
||||
private Sample sampleHover;
|
||||
private SampleChannel sampleChannel;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
@ -225,7 +226,8 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private void trigger()
|
||||
{
|
||||
sampleClick?.Play();
|
||||
sampleChannel = sampleClick?.GetChannel();
|
||||
sampleChannel?.Play();
|
||||
|
||||
clickAction?.Invoke();
|
||||
|
||||
@ -237,6 +239,8 @@ namespace osu.Game.Screens.Menu
|
||||
public override bool HandleNonPositionalInput => state == ButtonState.Expanded;
|
||||
public override bool HandlePositionalInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f;
|
||||
|
||||
public void StopSamplePlayback() => sampleChannel?.Stop();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
iconText.Alpha = Math.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
|
||||
|
@ -52,6 +52,8 @@ namespace osu.Game.Screens.Menu
|
||||
private readonly IntroSequence intro;
|
||||
|
||||
private Sample sampleClick;
|
||||
private SampleChannel sampleClickChannel;
|
||||
|
||||
private Sample sampleBeat;
|
||||
private Sample sampleDownbeat;
|
||||
|
||||
@ -391,7 +393,11 @@ namespace osu.Game.Screens.Menu
|
||||
flashLayer.FadeOut(1500, Easing.OutExpo);
|
||||
|
||||
if (Action?.Invoke() == true)
|
||||
sampleClick.Play();
|
||||
{
|
||||
StopSamplePlayback();
|
||||
sampleClickChannel = sampleClick.GetChannel();
|
||||
sampleClickChannel.Play();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -440,6 +446,8 @@ namespace osu.Game.Screens.Menu
|
||||
private Container currentProxyTarget;
|
||||
private Drawable proxy;
|
||||
|
||||
public void StopSamplePlayback() => sampleClickChannel?.Stop();
|
||||
|
||||
public Drawable ProxyToContainer(Container c)
|
||||
{
|
||||
if (currentProxyTarget != null)
|
||||
|
@ -37,7 +37,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2023.1030.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1023.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1109.0" />
|
||||
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user