1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-15 14:47:18 +08:00

Merge pull request #18702 from nekodex/new-dialog-sfx

Add new dialog popup SFX
This commit is contained in:
Dean Herbert 2022-06-15 21:46:04 +09:00 committed by GitHub
commit 4d5f82ccd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 102 additions and 12 deletions

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.615.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.615.0" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2022.615.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">

View File

@ -20,6 +20,12 @@ namespace osu.Game.Graphics.UserInterface
TabSelect, TabSelect,
[Description("scrolltotop")] [Description("scrolltotop")]
ScrollToTop ScrollToTop,
[Description("dialog-cancel")]
DialogCancel,
[Description("dialog-ok")]
DialogOk
} }
} }

View File

@ -8,7 +8,8 @@ namespace osu.Game.Overlays.Dialog
{ {
public class PopupDialogButton : DialogButton public class PopupDialogButton : DialogButton
{ {
public PopupDialogButton() public PopupDialogButton(HoverSampleSet sampleSet = HoverSampleSet.Button)
: base(sampleSet)
{ {
Height = 50; Height = 50;
BackgroundColour = Color4Extensions.FromHex(@"150e14"); BackgroundColour = Color4Extensions.FromHex(@"150e14");

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Dialog namespace osu.Game.Overlays.Dialog
{ {
@ -13,5 +14,10 @@ namespace osu.Game.Overlays.Dialog
{ {
ButtonColour = colours.Blue; ButtonColour = colours.Blue;
} }
public PopupDialogCancelButton()
: base(HoverSampleSet.DialogCancel)
{
}
} }
} }

View File

@ -2,9 +2,13 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; 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;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Audio.Effects;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
@ -47,6 +51,33 @@ namespace osu.Game.Overlays.Dialog
{ {
} }
private Sample tickSample;
private Sample confirmSample;
private double lastTickPlaybackTime;
private AudioFilter lowPassFilter = null!;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
tickSample = audio.Samples.Get(@"UI/dialog-dangerous-tick");
confirmSample = audio.Samples.Get(@"UI/dialog-dangerous-select");
AddInternal(lowPassFilter = new AudioFilter(audio.SampleMixer));
}
protected override void LoadComplete()
{
base.LoadComplete();
Progress.BindValueChanged(progressChanged);
}
protected override void Confirm()
{
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
confirmSample?.Play();
base.Confirm();
}
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
BeginConfirm(); BeginConfirm();
@ -56,7 +87,28 @@ namespace osu.Game.Overlays.Dialog
protected override void OnMouseUp(MouseUpEvent e) protected override void OnMouseUp(MouseUpEvent e)
{ {
if (!e.HasAnyButtonPressed) if (!e.HasAnyButtonPressed)
{
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
AbortConfirm(); AbortConfirm();
}
}
private void progressChanged(ValueChangedEvent<double> progress)
{
if (progress.NewValue < progress.OldValue) return;
if (Clock.CurrentTime - lastTickPlaybackTime < 30) return;
lowPassFilter.CutoffTo((int)(progress.NewValue * AudioFilter.MAX_LOWPASS_CUTOFF * 0.5));
var channel = tickSample.GetChannel();
channel.Frequency.Value = 1 + progress.NewValue * 0.5f;
channel.Volume.Value = 0.5f + progress.NewValue / 2f;
channel.Play();
lastTickPlaybackTime = Clock.CurrentTime;
} }
} }
} }

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Dialog namespace osu.Game.Overlays.Dialog
{ {
@ -13,5 +14,10 @@ namespace osu.Game.Overlays.Dialog
{ {
ButtonColour = colours.Pink; ButtonColour = colours.Pink;
} }
public PopupDialogOkButton()
: base(HoverSampleSet.DialogOk)
{
}
} }
} }

View File

@ -63,6 +63,8 @@ namespace osu.Game.Screens.Edit
public override bool? AllowTrackAdjustments => false; public override bool? AllowTrackAdjustments => false;
protected override bool PlayExitSound => !ExitConfirmed && !switchingDifficulty;
protected bool HasUnsavedChanges protected bool HasUnsavedChanges
{ {
get get
@ -99,6 +101,8 @@ namespace osu.Game.Screens.Edit
protected bool ExitConfirmed { get; private set; } protected bool ExitConfirmed { get; private set; }
private bool switchingDifficulty;
private string lastSavedHash; private string lastSavedHash;
private Container<EditorScreen> screenContainer; private Container<EditorScreen> screenContainer;
@ -857,7 +861,10 @@ namespace osu.Game.Screens.Edit
} }
private void switchToNewDifficulty(RulesetInfo rulesetInfo, bool createCopy) private void switchToNewDifficulty(RulesetInfo rulesetInfo, bool createCopy)
=> loader?.ScheduleSwitchToNewDifficulty(editorBeatmap.BeatmapInfo, rulesetInfo, createCopy, GetState(rulesetInfo)); {
switchingDifficulty = true;
loader?.ScheduleSwitchToNewDifficulty(editorBeatmap.BeatmapInfo, rulesetInfo, createCopy, GetState(rulesetInfo));
}
private EditorMenuItem createDifficultySwitchMenu() private EditorMenuItem createDifficultySwitchMenu()
{ {

View File

@ -63,6 +63,8 @@ namespace osu.Game.Screens.Menu
protected virtual string SeeyaSampleName => "Intro/seeya"; protected virtual string SeeyaSampleName => "Intro/seeya";
protected override bool PlayExitSound => false;
private LeasedBindable<WorkingBeatmap> beatmap; private LeasedBindable<WorkingBeatmap> beatmap;
private OsuScreen nextScreen; private OsuScreen nextScreen;

View File

@ -66,6 +66,8 @@ namespace osu.Game.Screens.Menu
protected override BackgroundScreen CreateBackground() => background; protected override BackgroundScreen CreateBackground() => background;
protected override bool PlayExitSound => false;
private Bindable<double> holdDelay; private Bindable<double> holdDelay;
private Bindable<bool> loginDisplayed; private Bindable<bool> loginDisplayed;

View File

@ -37,6 +37,8 @@ namespace osu.Game.Screens.OnlinePlay.Lounge
{ {
public override string Title => "Lounge"; public override string Title => "Lounge";
protected override bool PlayExitSound => false;
protected override BackgroundScreen CreateBackground() => new LoungeBackgroundScreen protected override BackgroundScreen CreateBackground() => new LoungeBackgroundScreen
{ {
SelectedRoom = { BindTarget = SelectedRoom } SelectedRoom = { BindTarget = SelectedRoom }

View File

@ -41,6 +41,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public override string ShortTitle => "room"; public override string ShortTitle => "room";
protected override bool PlayExitSound => !exitConfirmed;
[Resolved] [Resolved]
private MultiplayerClient client { get; set; } private MultiplayerClient client { get; set; }

View File

@ -77,7 +77,7 @@ namespace osu.Game.Screens
private Sample sampleExit; private Sample sampleExit;
protected virtual bool PlayResumeSound => true; protected virtual bool PlayExitSound => true;
public virtual float BackgroundParallaxAmount => 1; public virtual float BackgroundParallaxAmount => 1;
@ -173,9 +173,6 @@ namespace osu.Game.Screens
public override void OnResuming(ScreenTransitionEvent e) public override void OnResuming(ScreenTransitionEvent e)
{ {
if (PlayResumeSound)
sampleExit?.Play();
applyArrivingDefaults(true); applyArrivingDefaults(true);
// it's feasible to resume to a screen if the target screen never loaded successfully. // it's feasible to resume to a screen if the target screen never loaded successfully.
@ -215,6 +212,9 @@ namespace osu.Game.Screens
public override bool OnExiting(ScreenExitEvent e) public override bool OnExiting(ScreenExitEvent e)
{ {
if (ValidForResume && PlayExitSound)
sampleExit?.Play();
if (ValidForResume && logo != null) if (ValidForResume && logo != null)
onExitingLogo(); onExitingLogo();

View File

@ -53,6 +53,8 @@ namespace osu.Game.Screens.Play
public override bool AllowBackButton => false; // handled by HoldForMenuButton public override bool AllowBackButton => false; // handled by HoldForMenuButton
protected override bool PlayExitSound => !isRestarting;
protected override UserActivity InitialActivity => new UserActivity.InSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value); protected override UserActivity InitialActivity => new UserActivity.InSoloGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
public override float BackgroundParallaxAmount => 0.1f; public override float BackgroundParallaxAmount => 0.1f;
@ -75,6 +77,8 @@ namespace osu.Game.Screens.Play
public Action RestartRequested; public Action RestartRequested;
private bool isRestarting;
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>(); private readonly Bindable<bool> storyboardReplacesBackground = new Bindable<bool>();
@ -643,6 +647,8 @@ namespace osu.Game.Screens.Play
if (!Configuration.AllowRestart) if (!Configuration.AllowRestart)
return; return;
isRestarting = true;
// at the point of restarting the track should either already be paused or the volume should be zero. // at the point of restarting the track should either already be paused or the volume should be zero.
// stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader. // stopping here is to ensure music doesn't become audible after exiting back to PlayerLoader.
musicController.Stop(); musicController.Stop();

View File

@ -51,8 +51,6 @@ namespace osu.Game.Screens.Play
// We show the previous screen status // We show the previous screen status
protected override UserActivity? InitialActivity => null; protected override UserActivity? InitialActivity => null;
protected override bool PlayResumeSound => false;
protected BeatmapMetadataDisplay MetadataInfo { get; private set; } = null!; protected BeatmapMetadataDisplay MetadataInfo { get; private set; } = null!;
/// <summary> /// <summary>

View File

@ -37,7 +37,7 @@
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="10.14.0" /> <PackageReference Include="Realm" Version="10.14.0" />
<PackageReference Include="ppy.osu.Framework" Version="2022.615.0" /> <PackageReference Include="ppy.osu.Framework" Version="2022.615.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.615.0" />
<PackageReference Include="Sentry" Version="3.17.1" /> <PackageReference Include="Sentry" Version="3.17.1" />
<PackageReference Include="SharpCompress" Version="0.31.0" /> <PackageReference Include="SharpCompress" Version="0.31.0" />
<PackageReference Include="NUnit" Version="3.13.3" /> <PackageReference Include="NUnit" Version="3.13.3" />

View File

@ -62,7 +62,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.615.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2022.615.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2022.615.0" />
</ItemGroup> </ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) --> <!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
<PropertyGroup> <PropertyGroup>