Implemented in-game beatmap reloading.
- Press F5 to reload beatmaps in the song menu (resets OsuGroupList, then invokes OSZ unpacker and OsuFile parser). - Many components reused from Splash screen (progress display, 'Esc' interrupt). Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -85,27 +85,7 @@ public class Splash extends BasicGameState {
|
||||
throws SlickException {
|
||||
g.setBackground(Color.black);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2);
|
||||
|
||||
// display progress
|
||||
String unpackedFile = OszUnpacker.getCurrentFileName();
|
||||
String parsedFile = OsuParser.getCurrentFileName();
|
||||
String soundFile = SoundController.getCurrentFileName();
|
||||
if (unpackedFile != null) {
|
||||
drawLoadProgress(
|
||||
g, OszUnpacker.getUnpackerProgress(),
|
||||
"Unpacking new beatmaps...", unpackedFile
|
||||
);
|
||||
} else if (parsedFile != null) {
|
||||
drawLoadProgress(
|
||||
g, OsuParser.getParserProgress(),
|
||||
"Loading beatmaps...", parsedFile
|
||||
);
|
||||
} else if (soundFile != null) {
|
||||
drawLoadProgress(
|
||||
g, SoundController.getLoadingProgress(),
|
||||
"Loading sounds...", soundFile
|
||||
);
|
||||
}
|
||||
Utils.drawLoadingProgress(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -136,6 +116,7 @@ public class Splash extends BasicGameState {
|
||||
SoundController.init();
|
||||
|
||||
finished = true;
|
||||
thread = null;
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
@@ -151,8 +132,10 @@ public class Splash extends BasicGameState {
|
||||
// change states when loading complete
|
||||
if (finished && alpha >= 1f) {
|
||||
// initialize song list
|
||||
OsuGroupList.get().init();
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(OsuGroupList.get().getRandomNode(), -1, true);
|
||||
if (OsuGroupList.get().size() > 0) {
|
||||
OsuGroupList.get().init();
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(OsuGroupList.get().getRandomNode(), -1, true);
|
||||
}
|
||||
|
||||
// play the theme song
|
||||
if (Options.isThemSongEnabled())
|
||||
@@ -175,29 +158,4 @@ public class Splash extends BasicGameState {
|
||||
else if (key == Input.KEY_ESCAPE && thread != null)
|
||||
thread.interrupt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws loading progress.
|
||||
* @param g the graphics context
|
||||
* @param progress the completion percentage
|
||||
* @param text the progress text
|
||||
* @param file the file being loaded
|
||||
*/
|
||||
private void drawLoadProgress(Graphics g, int progress, String text, String file) {
|
||||
float marginX = container.getWidth() * 0.02f, marginY = container.getHeight() * 0.02f;
|
||||
float lineY = container.getHeight() - marginY;
|
||||
int lineOffsetY = Utils.FONT_MEDIUM.getLineHeight();
|
||||
if (Options.isLoadVerbose()) {
|
||||
Utils.FONT_MEDIUM.drawString(
|
||||
marginX, lineY - (lineOffsetY * 2),
|
||||
String.format("%s (%d%%)", text, progress), Color.white);
|
||||
Utils.FONT_MEDIUM.drawString(marginX, lineY - lineOffsetY, file, Color.white);
|
||||
} else {
|
||||
Utils.FONT_MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Color.white);
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(marginX, lineY - (lineOffsetY / 2f),
|
||||
(container.getWidth() - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user