Added support for multiple GameImage file extensions.
Specifically, the main menu background and pause/fail backgrounds now accept JPGs as well as PNGs. Other changes: - Don't draw the default pause/fail background if the buttons are skinned and the background is unskinned. - Preload logo and main menu background. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -84,11 +84,19 @@ public class GamePauseMenu extends BasicGameState {
|
||||
@Override
|
||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
// background
|
||||
if (gameState.getRestart() != Game.Restart.LOSE)
|
||||
GameImage.PAUSE_OVERLAY.getImage().draw();
|
||||
// get background image
|
||||
GameImage bg = (gameState.getRestart() == Game.Restart.LOSE) ?
|
||||
GameImage.FAIL_BACKGROUND : GameImage.PAUSE_OVERLAY;
|
||||
|
||||
// don't draw default background if button skinned and background unskinned
|
||||
boolean buttonsSkinned =
|
||||
GameImage.PAUSE_CONTINUE.hasSkinImage() ||
|
||||
GameImage.PAUSE_RETRY.hasSkinImage() ||
|
||||
GameImage.PAUSE_BACK.hasSkinImage();
|
||||
if (!buttonsSkinned || bg.hasSkinImage())
|
||||
bg.getImage().draw();
|
||||
else
|
||||
GameImage.FAIL_BACKGROUND.getImage().draw();
|
||||
g.setBackground(Color.black);
|
||||
|
||||
// draw buttons
|
||||
if (gameState.getRestart() != Game.Restart.LOSE)
|
||||
|
||||
@@ -93,11 +93,6 @@ public class MainMenu extends BasicGameState {
|
||||
*/
|
||||
private Stack<Integer> previous;
|
||||
|
||||
/**
|
||||
* Main menu background image (optional).
|
||||
*/
|
||||
private Image backgroundImage;
|
||||
|
||||
/**
|
||||
* Background alpha level (for fade-in effect).
|
||||
*/
|
||||
@@ -160,14 +155,6 @@ public class MainMenu extends BasicGameState {
|
||||
musicPrevious.setHoverScale(1.5f);
|
||||
|
||||
reset();
|
||||
|
||||
// menu background
|
||||
try {
|
||||
backgroundImage = new Image("menu-background.jpg").getScaledCopy(width, height);
|
||||
backgroundImage.setAlpha(0.9f);
|
||||
} catch (Exception e) {
|
||||
// optional
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,11 +168,11 @@ public class MainMenu extends BasicGameState {
|
||||
if (Options.isDynamicBackgroundEnabled() &&
|
||||
osu != null && osu.drawBG(width, height, bgAlpha))
|
||||
;
|
||||
else if (backgroundImage != null) {
|
||||
backgroundImage.setAlpha(bgAlpha);
|
||||
backgroundImage.draw();
|
||||
} else
|
||||
g.setBackground(Utils.COLOR_BLUE_BACKGROUND);
|
||||
else {
|
||||
Image bg = GameImage.MENU_BG.getImage();
|
||||
bg.setAlpha(bgAlpha);
|
||||
bg.draw();
|
||||
}
|
||||
|
||||
// draw buttons
|
||||
if (logoTimer > 0) {
|
||||
|
||||
Reference in New Issue
Block a user