[Merged by Bors] - Add a way to toggle AudioSink#6321
Closed
lovelymono wants to merge 2 commits intobevyengine:mainfrom
lovelymono:audio_toggle
Closed
[Merged by Bors] - Add a way to toggle AudioSink#6321lovelymono wants to merge 2 commits intobevyengine:mainfrom lovelymono:audio_toggle
AudioSink#6321lovelymono wants to merge 2 commits intobevyengine:mainfrom
lovelymono:audio_toggle
Conversation
Signed-off-by: Lena Milizé <me@lvmn.org>
Member
|
Code is correct, and docs are good. Unsure about adding non-idempotent methods, but users will want this. Would you use this for e.g. "disable all dialogue" buttons in menus? |
Signed-off-by: Lena Milizé <me@lvmn.org>
Contributor
Author
Right now in my game I have a persistent background music (similar to Stellaris' music player), and use this for a "Toggle music" button in options menu. |
harudagondi
approved these changes
Oct 20, 2022
Member
|
I am okay with this change, but note that |
Pietrek14
approved these changes
Oct 25, 2022
Contributor
Pietrek14
left a comment
There was a problem hiding this comment.
Maybe the use case isn't broad, but it won't hurt to have this feature.
Member
|
Sure, why not. This is a common pattern. bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Oct 31, 2022
# Objective
Currently toggling an `AudioSink` (for example from a game menu) requires writing
```rs
if sink.is_paused() {
sink.play();
} else {
sink.pause();
}
```
It would be nicer if we could reduce this down to a single line
```rs
sink.toggle();
```
## Solution
Add an `AudioSink::toggle` method which does exactly that.
---
## Changelog
- Added `AudioSink::toggle` which can be used to toggle state of a sink.
Contributor
AudioSinkAudioSink
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Feb 1, 2023
# Objective
Currently toggling an `AudioSink` (for example from a game menu) requires writing
```rs
if sink.is_paused() {
sink.play();
} else {
sink.pause();
}
```
It would be nicer if we could reduce this down to a single line
```rs
sink.toggle();
```
## Solution
Add an `AudioSink::toggle` method which does exactly that.
---
## Changelog
- Added `AudioSink::toggle` which can be used to toggle state of a sink.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Currently toggling an
AudioSink(for example from a game menu) requires writingIt would be nicer if we could reduce this down to a single line
Solution
Add an
AudioSink::togglemethod which does exactly that.Changelog
AudioSink::togglewhich can be used to toggle state of a sink.