working splash state
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
package itdelatrisu.opsu.states;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
@@ -36,19 +35,18 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||
import java.io.File;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
import org.newdawn.slick.state.BasicGameState;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||
|
||||
/**
|
||||
* "Splash Screen" state.
|
||||
* <p>
|
||||
* Loads game resources and enters "Main Menu" state.
|
||||
*/
|
||||
public class Splash extends BasicGameState {
|
||||
public class Splash extends BaseOpsuState {
|
||||
|
||||
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
||||
private static final int MIN_SPLASH_TIME = 400;
|
||||
|
||||
@@ -71,18 +69,15 @@ public class Splash extends BasicGameState {
|
||||
private AnimatedValue logoAlpha;
|
||||
|
||||
// game-related variables
|
||||
private final int state;
|
||||
private GameContainer container;
|
||||
private boolean init = false;
|
||||
|
||||
public Splash(int state) {
|
||||
this.state = state;
|
||||
public Splash(DisplayContainer displayContainer) {
|
||||
super(displayContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(GameContainer container, StateBasedGame game)
|
||||
throws SlickException {
|
||||
this.container = container;
|
||||
protected void revalidate() {
|
||||
super.revalidate();
|
||||
|
||||
// check if skin changed
|
||||
if (Options.getSkin() != null)
|
||||
@@ -92,7 +87,7 @@ public class Splash extends BasicGameState {
|
||||
this.watchServiceChange = Options.isWatchServiceEnabled() && BeatmapWatchService.get() == null;
|
||||
|
||||
// load Utils class first (needed in other 'init' methods)
|
||||
Utils.init(container, game);
|
||||
Utils.init(displayContainer);
|
||||
|
||||
// fade in logo
|
||||
this.logoAlpha = new AnimatedValue(MIN_SPLASH_TIME, 0f, 1f, AnimationEquation.LINEAR);
|
||||
@@ -100,16 +95,14 @@ public class Splash extends BasicGameState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
public void render(Graphics g) {
|
||||
g.setBackground(Color.black);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(displayContainer.width / 2, displayContainer.height / 2);
|
||||
UI.drawLoadingProgress(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
public void update() {
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
||||
@@ -165,7 +158,7 @@ public class Splash extends BasicGameState {
|
||||
}
|
||||
|
||||
// fade in logo
|
||||
if (logoAlpha.update(delta))
|
||||
if (logoAlpha.update(displayContainer.delta))
|
||||
GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue());
|
||||
|
||||
// change states when loading complete
|
||||
@@ -176,30 +169,32 @@ public class Splash extends BasicGameState {
|
||||
if (Options.isThemeSongEnabled())
|
||||
MusicController.playThemeSong();
|
||||
else
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
//((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
System.out.println(("todo"));
|
||||
// TODO
|
||||
}
|
||||
|
||||
// play the theme song
|
||||
else
|
||||
MusicController.playThemeSong();
|
||||
|
||||
game.enterState(Opsu.STATE_MAINMENU);
|
||||
//game.enterState(Opsu.STATE_MAINMENU);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() { return state; }
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
public boolean keyPressed(int key, char c) {
|
||||
if (key == Input.KEY_ESCAPE) {
|
||||
// close program
|
||||
if (++escapeCount >= 3)
|
||||
container.exit();
|
||||
if (++escapeCount >= 3) System.out.println("hi");
|
||||
//container.exit(); // TODO
|
||||
|
||||
// stop parsing beatmaps by sending interrupt to BeatmapParser
|
||||
else if (thread != null)
|
||||
thread.interrupt();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user