Follow-up to f98edf8: better checks for application restart.

- Fixes resource reloading when OsuGroupList is empty (i.e. if user has no beatmaps installed).
- OsuGroupList is no longer initialized with a class instance; OsuGroupList.create() is called by OsuParser.
- Also clear 'lastOsu' field in MusicController.reset().  Fixes theme song not playing on restart if it was the last track played (i.e. if no beatmaps installed).
- Call MusicController.reset() last so that more garbage is collected.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han
2015-01-20 19:24:59 -05:00
parent f98edf8fc8
commit 2bc45bec0a
5 changed files with 32 additions and 22 deletions

View File

@@ -113,30 +113,32 @@ public class Splash extends BasicGameState {
if (!init) {
init = true;
// load other resources in a new thread
final int width = container.getWidth();
final int height = container.getHeight();
thread = new Thread() {
@Override
public void run() {
// application restart: everything already loaded
if (OsuGroupList.get().size() < 1) {
if (OsuGroupList.get() != null) {
// resources already loaded (from application restart)
finished = true;
} else {
// load resources in a new thread
final int width = container.getWidth();
final int height = container.getHeight();
thread = new Thread() {
@Override
public void run() {
File beatmapDir = Options.getBeatmapDir();
// unpack all OSZ archives
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
// parse song directory
OsuParser.parseAllFiles(beatmapDir, width, height);
// load sounds
SoundController.init();
}
finished = true;
}
};
thread.start();
finished = true;
}
};
thread.start();
}
}
// fade in logo