mirror of
https://github.com/ppy/osu.git
synced 2025-03-28 20:47:22 +08: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> buttonsTopLevel = new List<MainMenuButton>();
|
||||||
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
private readonly List<MainMenuButton> buttonsPlay = new List<MainMenuButton>();
|
||||||
|
|
||||||
private Sample sampleBack;
|
private Sample sampleBackToLogo;
|
||||||
|
private Sample sampleLogoSwoosh;
|
||||||
|
|
||||||
private readonly LogoTrackingContainer logoTrackingContainer;
|
private readonly LogoTrackingContainer logoTrackingContainer;
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
buttonArea.AddRange(new Drawable[]
|
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),
|
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)
|
-WEDGE_WIDTH)
|
||||||
{
|
{
|
||||||
VisibleState = ButtonSystemState.Play,
|
VisibleState = ButtonSystemState.Play,
|
||||||
@ -127,14 +128,14 @@ namespace osu.Game.Screens.Menu
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, IdleTracker idleTracker, GameHost host)
|
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.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-generic-select", FontAwesome.Solid.Users, new Color4(94, 63, 186, 255), onMultiplayer, 0, Key.M));
|
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-generic-select", OsuIcon.Charts, new Color4(94, 63, 186, 255), onPlaylists, 0, Key.L));
|
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);
|
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.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.Edit, @"button-default-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.Browse, @"button-default-select", OsuIcon.ChevronDownCircle, new Color4(165, 204, 0, 255), () => OnBeatmapListing?.Invoke(), 0, Key.B, Key.D));
|
||||||
|
|
||||||
if (host.CanExit)
|
if (host.CanExit)
|
||||||
buttonsTopLevel.Add(new MainMenuButton(ButtonSystemStrings.Exit, string.Empty, OsuIcon.CrossCircle, new Color4(238, 51, 153, 255), () => OnExit?.Invoke(), 0, Key.Q));
|
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);
|
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()
|
private void onMultiplayer()
|
||||||
@ -197,6 +199,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
if (State == ButtonSystemState.Initial)
|
if (State == ButtonSystemState.Initial)
|
||||||
{
|
{
|
||||||
|
StopSamplePlayback();
|
||||||
logo?.TriggerClick();
|
logo?.TriggerClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -260,10 +263,15 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
case ButtonSystemState.TopLevel:
|
case ButtonSystemState.TopLevel:
|
||||||
State = ButtonSystemState.Initial;
|
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;
|
return true;
|
||||||
|
|
||||||
case ButtonSystemState.Play:
|
case ButtonSystemState.Play:
|
||||||
|
StopSamplePlayback();
|
||||||
backButton.TriggerClick();
|
backButton.TriggerClick();
|
||||||
return true;
|
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()
|
private bool onOsuLogo()
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
@ -346,6 +361,9 @@ namespace osu.Game.Screens.Menu
|
|||||||
logo?.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
|
logo?.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo);
|
||||||
logo?.ScaleTo(1, 800, Easing.OutExpo);
|
logo?.ScaleTo(1, 800, Easing.OutExpo);
|
||||||
}, buttonArea.Alpha * 150);
|
}, buttonArea.Alpha * 150);
|
||||||
|
|
||||||
|
if (lastState == ButtonSystemState.TopLevel)
|
||||||
|
sampleLogoSwoosh?.Play();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ButtonSystemState.TopLevel:
|
case ButtonSystemState.TopLevel:
|
||||||
|
@ -7,6 +7,8 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
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.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -89,8 +91,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
private SongTicker songTicker;
|
private SongTicker songTicker;
|
||||||
private Container logoTarget;
|
private Container logoTarget;
|
||||||
|
|
||||||
|
private Sample reappearSampleSwoosh;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[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);
|
holdDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
||||||
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
|
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
|
||||||
@ -162,6 +166,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
Buttons.OnSettings = () => settings?.ToggleVisibility();
|
Buttons.OnSettings = () => settings?.ToggleVisibility();
|
||||||
Buttons.OnBeatmapListing = () => beatmapListing?.ToggleVisibility();
|
Buttons.OnBeatmapListing = () => beatmapListing?.ToggleVisibility();
|
||||||
|
|
||||||
|
reappearSampleSwoosh = audio.Samples.Get(@"Menu/reappear-swoosh");
|
||||||
|
|
||||||
preloadSongSelect();
|
preloadSongSelect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +297,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
base.OnResuming(e);
|
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());
|
ApplyToBackground(b => (b as BackgroundScreenDefault)?.Next());
|
||||||
|
|
||||||
// we may have consumed our preloaded instance, so let's make another.
|
// 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 readonly Action clickAction;
|
||||||
private Sample sampleClick;
|
private Sample sampleClick;
|
||||||
private Sample sampleHover;
|
private Sample sampleHover;
|
||||||
|
private SampleChannel sampleChannel;
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => box.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
@ -225,7 +226,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private void trigger()
|
private void trigger()
|
||||||
{
|
{
|
||||||
sampleClick?.Play();
|
sampleChannel = sampleClick?.GetChannel();
|
||||||
|
sampleChannel?.Play();
|
||||||
|
|
||||||
clickAction?.Invoke();
|
clickAction?.Invoke();
|
||||||
|
|
||||||
@ -237,6 +239,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
public override bool HandleNonPositionalInput => state == ButtonState.Expanded;
|
public override bool HandleNonPositionalInput => state == ButtonState.Expanded;
|
||||||
public override bool HandlePositionalInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f;
|
public override bool HandlePositionalInput => state != ButtonState.Exploded && box.Scale.X >= 0.8f;
|
||||||
|
|
||||||
|
public void StopSamplePlayback() => sampleChannel?.Stop();
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
iconText.Alpha = Math.Clamp((box.Scale.X - 0.5f) / 0.3f, 0, 1);
|
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 readonly IntroSequence intro;
|
||||||
|
|
||||||
private Sample sampleClick;
|
private Sample sampleClick;
|
||||||
|
private SampleChannel sampleClickChannel;
|
||||||
|
|
||||||
private Sample sampleBeat;
|
private Sample sampleBeat;
|
||||||
private Sample sampleDownbeat;
|
private Sample sampleDownbeat;
|
||||||
|
|
||||||
@ -391,7 +393,11 @@ namespace osu.Game.Screens.Menu
|
|||||||
flashLayer.FadeOut(1500, Easing.OutExpo);
|
flashLayer.FadeOut(1500, Easing.OutExpo);
|
||||||
|
|
||||||
if (Action?.Invoke() == true)
|
if (Action?.Invoke() == true)
|
||||||
sampleClick.Play();
|
{
|
||||||
|
StopSamplePlayback();
|
||||||
|
sampleClickChannel = sampleClick.GetChannel();
|
||||||
|
sampleClickChannel.Play();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -440,6 +446,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
private Container currentProxyTarget;
|
private Container currentProxyTarget;
|
||||||
private Drawable proxy;
|
private Drawable proxy;
|
||||||
|
|
||||||
|
public void StopSamplePlayback() => sampleClickChannel?.Stop();
|
||||||
|
|
||||||
public Drawable ProxyToContainer(Container c)
|
public Drawable ProxyToContainer(Container c)
|
||||||
{
|
{
|
||||||
if (currentProxyTarget != null)
|
if (currentProxyTarget != null)
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="11.5.0" />
|
<PackageReference Include="Realm" Version="11.5.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2023.1030.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" />
|
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user