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)) {
|
if (Options.isModActive(i)) {
|
||||||
Image modImage = Options.getModImage(i);
|
Image modImage = Options.getModImage(i);
|
||||||
modImage.draw(
|
modImage.draw(
|
||||||
// (width * 0.85f) + ((i - (Options.MOD_MAX / 2)) * modImage.getWidth() / 3f),
|
|
||||||
modX - (modCount * (modWidth / 2f)),
|
modX - (modCount * (modWidth / 2f)),
|
||||||
symbolHeight + circleDiameter + 10
|
symbolHeight + circleDiameter + 10
|
||||||
);
|
);
|
||||||
|
|
|
@ -144,6 +144,16 @@ public class SoundController {
|
||||||
*/
|
*/
|
||||||
private static float sampleVolumeMultiplier = 1f;
|
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.
|
// This class should not be instantiated.
|
||||||
private SoundController() {}
|
private SoundController() {}
|
||||||
|
|
||||||
|
@ -176,16 +186,24 @@ public class SoundController {
|
||||||
*/
|
*/
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// TODO: support MP3 sounds?
|
// TODO: support MP3 sounds?
|
||||||
|
currentFileIndex = 0;
|
||||||
|
|
||||||
// menu and game sounds
|
// menu and game sounds
|
||||||
for (int i = 0; i < SOUND_MAX; i++)
|
for (int i = 0; i < SOUND_MAX; i++, currentFileIndex++) {
|
||||||
sounds[i] = loadClip(String.format("%s.wav", soundNames[i]));
|
currentFileName = String.format("%s.wav", soundNames[i]);
|
||||||
|
sounds[i] = loadClip(currentFileName);
|
||||||
|
}
|
||||||
|
|
||||||
// hit sounds
|
// hit sounds
|
||||||
for (int i = 0; i < sampleSets.length; i++) {
|
for (int i = 0; i < sampleSets.length; i++) {
|
||||||
for (int j = 0; j < HIT_MAX; j++)
|
for (int j = 0; j < HIT_MAX; j++, currentFileIndex++) {
|
||||||
hitSounds[i][j] = loadClip(String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]));
|
currentFileName = String.format("%s-%s.wav", sampleSets[i], hitSoundNames[j]);
|
||||||
|
hitSounds[i][j] = loadClip(currentFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentFileName = null;
|
||||||
|
currentFileIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,4 +315,22 @@ public class SoundController {
|
||||||
playClip(hitSounds[sampleSetIndex][sound],
|
playClip(hitSounds[sampleSetIndex][sound],
|
||||||
Options.getHitSoundVolume() * sampleVolumeMultiplier);
|
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)
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||||
throws SlickException {
|
throws SlickException {
|
||||||
g.setBackground(Color.black);
|
g.setBackground(Color.black);
|
||||||
|
logo.drawCentered(container.getWidth() / 2, container.getHeight() / 2);
|
||||||
int width = container.getWidth();
|
|
||||||
int height = container.getHeight();
|
|
||||||
|
|
||||||
logo.drawCentered(width / 2, height / 2);
|
|
||||||
|
|
||||||
// display progress
|
// display progress
|
||||||
if (Options.isLoadVerbose()) {
|
if (Options.isLoadVerbose()) {
|
||||||
g.setColor(Color.white);
|
|
||||||
g.setFont(Utils.FONT_MEDIUM);
|
|
||||||
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
|
||||||
|
|
||||||
String unpackedFile = OszUnpacker.getCurrentFileName();
|
String unpackedFile = OszUnpacker.getCurrentFileName();
|
||||||
String parsedFile = OsuParser.getCurrentFileName();
|
String parsedFile = OsuParser.getCurrentFileName();
|
||||||
|
String soundFile = SoundController.getCurrentFileName();
|
||||||
if (unpackedFile != null) {
|
if (unpackedFile != null) {
|
||||||
g.drawString(
|
drawLoadProgress(
|
||||||
String.format("Unpacking... (%d%%)", OszUnpacker.getUnpackerProgress()),
|
String.format("Unpacking new beatmaps... (%d%%)", OszUnpacker.getUnpackerProgress()),
|
||||||
25, height - 25 - (lineHeight * 2)
|
unpackedFile
|
||||||
);
|
);
|
||||||
g.drawString(unpackedFile, 25, height - 25 - lineHeight);
|
|
||||||
} else if (parsedFile != null) {
|
} else if (parsedFile != null) {
|
||||||
g.drawString(
|
drawLoadProgress(
|
||||||
String.format("Loading... (%d%%)", OsuParser.getParserProgress()),
|
String.format("Loading beatmaps... (%d%%)", OsuParser.getParserProgress()),
|
||||||
25, height - 25 - (lineHeight * 2)
|
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();
|
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