Added loading progress for sound files in splash screen.
Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
331f374a5b
commit
e7f74d8dd6
|
@ -510,7 +510,6 @@ public class GameScore {
|
|||
if (Options.isModActive(i)) {
|
||||
Image modImage = Options.getModImage(i);
|
||||
modImage.draw(
|
||||
// (width * 0.85f) + ((i - (Options.MOD_MAX / 2)) * modImage.getWidth() / 3f),
|
||||
modX - (modCount * (modWidth / 2f)),
|
||||
symbolHeight + circleDiameter + 10
|
||||
);
|
||||
|
|
|
@ -144,6 +144,16 @@ public class SoundController {
|
|||
*/
|
||||
private static float sampleVolumeMultiplier = 1f;
|
||||
|
||||
/**
|
||||
* The name of the current sound file being loaded.
|
||||
*/
|
||||
private static String currentFileName;
|
||||
|
||||
/**
|
||||
* The number of the current sound file being loaded.
|
||||
*/
|
||||
private static int currentFileIndex = -1;
|
||||
|
||||
// This class should not be instantiated.
|
||||
private SoundController() {}
|
||||
|
||||
|
@ -176,18 +186,26 @@ public class SoundController {
|
|||
*/
|
||||
public static void init() {
|
||||
// TODO: support MP3 sounds?
|
||||
currentFileIndex = 0;
|
||||
|
||||
// menu and game sounds
|
||||
for (int i = 0; i < SOUND_MAX; i++)
|
||||
sounds[i] = loadClip(String.format("%s.wav", soundNames[i]));
|
||||
for (int i = 0; i < SOUND_MAX; i++, currentFileIndex++) {
|
||||
currentFileName = String.format("%s.wav", soundNames[i]);
|
||||
sounds[i] = loadClip(currentFileName);
|
||||
}
|
||||
|
||||
// hit sounds
|
||||
for (int i = 0; i < sampleSets.length; i++) {
|
||||
for (int j = 0; j < HIT_MAX; j++)
|
||||
hitSounds[i][j] = loadClip(String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]));
|
||||
for (int j = 0; j < HIT_MAX; j++, currentFileIndex++) {
|
||||
currentFileName = String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]);
|
||||
hitSounds[i][j] = loadClip(currentFileName);
|
||||
}
|
||||
}
|
||||
|
||||
currentFileName = null;
|
||||
currentFileIndex = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sample set to use when playing hit sounds.
|
||||
* @param sampleSet the sample set ("None", "Normal", "Soft", "Drum")
|
||||
|
@ -297,4 +315,22 @@ public class SoundController {
|
|||
playClip(hitSounds[sampleSetIndex][sound],
|
||||
Options.getHitSoundVolume() * sampleVolumeMultiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current file being loaded, or null if none.
|
||||
*/
|
||||
public static String getCurrentFileName() {
|
||||
return (currentFileName != null) ? currentFileName : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the progress of sound loading, or -1 if not loading.
|
||||
* @return the completion percent [0, 100] or -1
|
||||
*/
|
||||
public static int getLoadingProgress() {
|
||||
if (currentFileIndex == -1)
|
||||
return -1;
|
||||
|
||||
return currentFileIndex * 100 / (SOUND_MAX + (sampleSets.length * HIT_MAX));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,32 +78,28 @@ public class Splash extends BasicGameState {
|
|||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
g.setBackground(Color.black);
|
||||
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
|
||||
logo.drawCentered(width / 2, height / 2);
|
||||
logo.drawCentered(container.getWidth() / 2, container.getHeight() / 2);
|
||||
|
||||
// display progress
|
||||
if (Options.isLoadVerbose()) {
|
||||
g.setColor(Color.white);
|
||||
g.setFont(Utils.FONT_MEDIUM);
|
||||
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
||||
|
||||
String unpackedFile = OszUnpacker.getCurrentFileName();
|
||||
String parsedFile = OsuParser.getCurrentFileName();
|
||||
String soundFile = SoundController.getCurrentFileName();
|
||||
if (unpackedFile != null) {
|
||||
g.drawString(
|
||||
String.format("Unpacking... (%d%%)", OszUnpacker.getUnpackerProgress()),
|
||||
25, height - 25 - (lineHeight * 2)
|
||||
drawLoadProgress(
|
||||
String.format("Unpacking new beatmaps... (%d%%)", OszUnpacker.getUnpackerProgress()),
|
||||
unpackedFile
|
||||
);
|
||||
g.drawString(unpackedFile, 25, height - 25 - lineHeight);
|
||||
} else if (parsedFile != null) {
|
||||
g.drawString(
|
||||
String.format("Loading... (%d%%)", OsuParser.getParserProgress()),
|
||||
25, height - 25 - (lineHeight * 2)
|
||||
drawLoadProgress(
|
||||
String.format("Loading beatmaps... (%d%%)", OsuParser.getParserProgress()),
|
||||
parsedFile
|
||||
);
|
||||
} else if (soundFile != null) {
|
||||
drawLoadProgress(
|
||||
String.format("Loading sounds... (%d%%)", SoundController.getLoadingProgress()),
|
||||
soundFile
|
||||
);
|
||||
g.drawString(parsedFile, 25, height - 25 - lineHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,4 +158,16 @@ public class Splash extends BasicGameState {
|
|||
container.exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws loading progress.
|
||||
* @param progress the progress text
|
||||
* @param file the file being loaded
|
||||
*/
|
||||
private void drawLoadProgress(String progress, String file) {
|
||||
int lineY = container.getHeight() - 25;
|
||||
int lineOffsetY = Utils.FONT_MEDIUM.getLineHeight();
|
||||
Utils.FONT_MEDIUM.drawString(25, lineY - (lineOffsetY * 2), progress, Color.white);
|
||||
Utils.FONT_MEDIUM.drawString(25, lineY - lineOffsetY, file, Color.white);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user