Fixed a bug where sounds weren't reloaded when changing skins.
When restarting the program through the options menu, all sounds now get reloaded if the skin was changed. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -55,6 +55,9 @@ public class Splash extends BasicGameState {
|
||||
/** Number of times the 'Esc' key has been pressed. */
|
||||
private int escapeCount = 0;
|
||||
|
||||
/** Whether the skin being loaded is a new skin (for program restarts). */
|
||||
private boolean newSkin = false;
|
||||
|
||||
// game-related variables
|
||||
private int state;
|
||||
private GameContainer container;
|
||||
@@ -69,6 +72,10 @@ public class Splash extends BasicGameState {
|
||||
throws SlickException {
|
||||
this.container = container;
|
||||
|
||||
// check if skin changed
|
||||
if (Options.getSkin() != null)
|
||||
this.newSkin = (Options.getSkin().getDirectory() != Options.getSkinDir());
|
||||
|
||||
// load Utils class first (needed in other 'init' methods)
|
||||
Utils.init(container, game);
|
||||
|
||||
@@ -89,11 +96,27 @@ public class Splash extends BasicGameState {
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
||||
// resources already loaded (from application restart)
|
||||
if (BeatmapSetList.get() != null) {
|
||||
// resources already loaded (from application restart)
|
||||
finished = true;
|
||||
} else {
|
||||
// load resources in a new thread
|
||||
// reload sounds if skin changed
|
||||
if (newSkin) {
|
||||
thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO: only reload each sound if actually needed?
|
||||
SoundController.init();
|
||||
|
||||
finished = true;
|
||||
thread = null;
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
} else // don't reload anything
|
||||
finished = true;
|
||||
}
|
||||
|
||||
// load all resources in a new thread
|
||||
else {
|
||||
thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user