Moved track volume dimming into MusicController.
- Fixes an issue where the first few milliseconds of the theme song would always play at full volume, even if container is not focused. - Allows easier application to any song. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -106,11 +106,6 @@ public class MainMenu extends BasicGameState {
|
||||
*/
|
||||
private float bgAlpha = 0f;
|
||||
|
||||
/**
|
||||
* Whether the theme song volume has been dimmed.
|
||||
*/
|
||||
private boolean volumeDimmed = false;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
@@ -259,16 +254,9 @@ public class MainMenu extends BasicGameState {
|
||||
repoButton.hoverUpdate(delta, mouseX, mouseY);
|
||||
|
||||
// window focus change: increase/decrease theme song volume
|
||||
if (MusicController.isThemePlaying()) {
|
||||
boolean hasFocus = container.hasFocus();
|
||||
if (volumeDimmed == hasFocus) {
|
||||
if (hasFocus) // restored focus
|
||||
MusicController.setVolume(Options.getMusicVolume());
|
||||
else // lost focus
|
||||
MusicController.setVolume(Options.getMusicVolume() / 3f);
|
||||
volumeDimmed = !hasFocus;
|
||||
}
|
||||
}
|
||||
if (MusicController.isThemePlaying() &&
|
||||
MusicController.isTrackDimmed() == container.hasFocus())
|
||||
MusicController.toggleTrackDimmed();
|
||||
|
||||
// fade in background
|
||||
if (bgAlpha < 0.9f) {
|
||||
|
||||
Reference in New Issue
Block a user