-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30910 from nekodex/improve-menu-sample-playback
Improve menu/context-menu sample playback
- Loading branch information
Showing
12 changed files
with
107 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
#nullable disable | ||
|
||
using osu.Framework.Allocation; | ||
using osu.Framework.Audio; | ||
using osu.Framework.Audio.Sample; | ||
using osu.Framework.Graphics; | ||
|
||
namespace osu.Game.Graphics.UserInterface | ||
{ | ||
public partial class OsuMenuSamples : Component | ||
{ | ||
private Sample sampleClick; | ||
private Sample sampleOpen; | ||
private Sample sampleSubOpen; | ||
private Sample sampleClose; | ||
|
||
private bool triggerOpen; | ||
private bool triggerSubOpen; | ||
private bool triggerClose; | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(AudioManager audio) | ||
{ | ||
sampleClick = audio.Samples.Get(@"UI/menu-open-select"); | ||
sampleOpen = audio.Samples.Get(@"UI/menu-open"); | ||
sampleSubOpen = audio.Samples.Get(@"UI/menu-sub-open"); | ||
sampleClose = audio.Samples.Get(@"UI/menu-close"); | ||
} | ||
|
||
public void PlayClickSample() | ||
{ | ||
Scheduler.AddOnce(playClickSample); | ||
} | ||
|
||
public void PlayOpenSample() | ||
{ | ||
triggerOpen = true; | ||
Scheduler.AddOnce(resolvePlayback); | ||
} | ||
|
||
public void PlaySubOpenSample() | ||
{ | ||
triggerSubOpen = true; | ||
Scheduler.AddOnce(resolvePlayback); | ||
} | ||
|
||
public void PlayCloseSample() | ||
{ | ||
triggerClose = true; | ||
Scheduler.AddOnce(resolvePlayback); | ||
} | ||
|
||
private void playClickSample() => sampleClick.Play(); | ||
|
||
private void resolvePlayback() | ||
{ | ||
if (triggerSubOpen) | ||
sampleSubOpen?.Play(); | ||
else if (triggerOpen) | ||
sampleOpen?.Play(); | ||
else if (triggerClose) | ||
sampleClose?.Play(); | ||
|
||
triggerOpen = triggerSubOpen = triggerClose = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters