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:
@@ -71,6 +71,11 @@ public class MusicController {
|
||||
*/
|
||||
private static float pauseTime = 0f;
|
||||
|
||||
/**
|
||||
* Whether the current track volume is dimmed.
|
||||
*/
|
||||
private static boolean trackDimmed = false;
|
||||
|
||||
// This class should not be instantiated.
|
||||
private MusicController() {}
|
||||
|
||||
@@ -148,6 +153,7 @@ public class MusicController {
|
||||
else
|
||||
player.play();
|
||||
pauseTime = 0f;
|
||||
trackDimmed = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +308,20 @@ public class MusicController {
|
||||
return (themePlaying && trackExists());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the volume of the current track, if any,
|
||||
* has been dimmed.
|
||||
*/
|
||||
public static boolean isTrackDimmed() { return trackDimmed; }
|
||||
|
||||
/**
|
||||
* Toggles the volume dim state of the current track.
|
||||
*/
|
||||
public static void toggleTrackDimmed() {
|
||||
setVolume((trackDimmed) ? Options.getMusicVolume() : Options.getMusicVolume() / 3f);
|
||||
trackDimmed = !trackDimmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops and releases all sources, clears each of the specified Audio
|
||||
* buffers, destroys the OpenAL context, and resets SoundStore for future use.
|
||||
|
||||
Reference in New Issue
Block a user