diff --git a/src/itdelatrisu/opsu/Opsu.java b/src/itdelatrisu/opsu/Opsu.java index 29f7c4ee..0b5bbd7c 100644 --- a/src/itdelatrisu/opsu/Opsu.java +++ b/src/itdelatrisu/opsu/Opsu.java @@ -86,7 +86,7 @@ public class Opsu extends StateBasedGame { @Override public void initStatesList(GameContainer container) throws SlickException { //addState(new Splash(STATE_SPLASH)); - addState(new MainMenu(STATE_MAINMENU)); + //addState(new MainMenu(STATE_MAINMENU)); addState(new ButtonMenu(STATE_BUTTONMENU)); addState(new SongMenu(STATE_SONGMENU)); addState(new Game(STATE_GAME)); diff --git a/src/itdelatrisu/opsu/Options.java b/src/itdelatrisu/opsu/Options.java index dcf2da73..2c033336 100644 --- a/src/itdelatrisu/opsu/Options.java +++ b/src/itdelatrisu/opsu/Options.java @@ -1281,11 +1281,11 @@ public class Options { /** * Sets the target frame rate to the next available option, and sends a * bar notification about the action. - * @param container the game container */ - public static void setNextFPS(GameContainer container) { + public static void setNextFPS(DisplayContainer displayContainer) { GameOption.TARGET_FPS.clickListItem((targetFPSindex + 1) % targetFPS.length); UI.sendBarNotification(String.format("Frame limiter: %s", GameOption.TARGET_FPS.getValueString())); + displayContainer.setFPS(GameOption.TARGET_FPS.val); } /** diff --git a/src/itdelatrisu/opsu/states/ButtonMenu.java b/src/itdelatrisu/opsu/states/ButtonMenu.java index df9e7db1..ff95558c 100644 --- a/src/itdelatrisu/opsu/states/ButtonMenu.java +++ b/src/itdelatrisu/opsu/states/ButtonMenu.java @@ -705,7 +705,8 @@ public class ButtonMenu extends BasicGameState { menuState.leave(container, game); break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO + //Options.setNextFPS(displayContainer); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/DownloadsMenu.java b/src/itdelatrisu/opsu/states/DownloadsMenu.java index 76fd7376..df4435bc 100644 --- a/src/itdelatrisu/opsu/states/DownloadsMenu.java +++ b/src/itdelatrisu/opsu/states/DownloadsMenu.java @@ -911,7 +911,8 @@ public class DownloadsMenu extends BasicGameState { resetSearchTimer(); break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO d + //Options.setNextFPS(container); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index 0c29abae..49bb6c95 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -1198,7 +1198,8 @@ public class Game extends BasicGameState { UI.changeVolume(-1); break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO d + //Options.setNextFPS(container); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/GamePauseMenu.java b/src/itdelatrisu/opsu/states/GamePauseMenu.java index c3c9dec1..a9d5a7ad 100644 --- a/src/itdelatrisu/opsu/states/GamePauseMenu.java +++ b/src/itdelatrisu/opsu/states/GamePauseMenu.java @@ -143,7 +143,8 @@ public class GamePauseMenu extends BasicGameState { } break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO d + //Options.setNextFPS(container); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/GameRanking.java b/src/itdelatrisu/opsu/states/GameRanking.java index fe7450fd..00f1b48f 100644 --- a/src/itdelatrisu/opsu/states/GameRanking.java +++ b/src/itdelatrisu/opsu/states/GameRanking.java @@ -148,7 +148,8 @@ public class GameRanking extends BasicGameState { returnToSongMenu(); break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO d + //Options.setNextFPS(container); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/MainMenu.java b/src/itdelatrisu/opsu/states/MainMenu.java index 93fd15e7..568754f2 100644 --- a/src/itdelatrisu/opsu/states/MainMenu.java +++ b/src/itdelatrisu/opsu/states/MainMenu.java @@ -29,7 +29,6 @@ import itdelatrisu.opsu.audio.SoundEffect; import itdelatrisu.opsu.beatmap.Beatmap; import itdelatrisu.opsu.beatmap.BeatmapSetList; import itdelatrisu.opsu.beatmap.BeatmapSetNode; -import itdelatrisu.opsu.beatmap.TimingPoint; import itdelatrisu.opsu.downloads.Updater; import itdelatrisu.opsu.states.ButtonMenu.MenuState; import itdelatrisu.opsu.ui.*; @@ -43,23 +42,26 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Stack; +import org.lwjgl.opengl.Display; import org.newdawn.slick.Color; -import org.newdawn.slick.GameContainer; import org.newdawn.slick.Graphics; import org.newdawn.slick.Image; import org.newdawn.slick.Input; -import org.newdawn.slick.SlickException; -import org.newdawn.slick.state.BasicGameState; -import org.newdawn.slick.state.StateBasedGame; import org.newdawn.slick.state.transition.EasedFadeOutTransition; import org.newdawn.slick.state.transition.FadeInTransition; +import yugecin.opsudance.core.DisplayContainer; +import yugecin.opsudance.core.inject.InstanceContainer; +import yugecin.opsudance.core.state.BaseOpsuState; /** * "Main Menu" state. *

* Players are able to enter the song menu or downloads menu from this state. */ -public class MainMenu extends BasicGameState { +public class MainMenu extends BaseOpsuState { + + private final InstanceContainer instanceContainer; + /** Idle time, in milliseconds, before returning the logo to its original position. */ private static final short LOGO_IDLE_DELAY = 10000; @@ -123,40 +125,27 @@ public class MainMenu extends BasicGameState { /** The star fountain. */ private StarFountain starFountain; - // game-related variables - private GameContainer container; - private StateBasedGame game; - private Input input; - private final int state; - - public MainMenu(int state) { - this.state = state; + public MainMenu(DisplayContainer displayContainer, InstanceContainer instanceContainer) { + super(displayContainer); + this.instanceContainer = instanceContainer; } @Override - public void init(GameContainer container, StateBasedGame game) - throws SlickException { - this.container = container; - this.game = game; - this.input = container.getInput(); - + protected void revalidate() { programStartTime = System.currentTimeMillis(); - previous = new Stack(); - - int width = container.getWidth(); - int height = container.getHeight(); + previous = new Stack<>(); // initialize menu buttons Image logoImg = GameImage.MENU_LOGO.getImage(); Image playImg = GameImage.MENU_PLAY.getImage(); Image exitImg = GameImage.MENU_EXIT.getImage(); float exitOffset = (playImg.getWidth() - exitImg.getWidth()) / 3f; - logo = new MenuButton(logoImg, width / 2f, height / 2f); + logo = new MenuButton(logoImg, displayContainer.width / 2f, displayContainer.height / 2f); playButton = new MenuButton(playImg, - width * 0.75f, (height / 2) - (logoImg.getHeight() / 5f) + displayContainer.width * 0.75f, (displayContainer.height / 2) - (logoImg.getHeight() / 5f) ); exitButton = new MenuButton(exitImg, - width * 0.75f - exitOffset, (height / 2) + (exitImg.getHeight() / 2f) + displayContainer.width * 0.75f - exitOffset, (displayContainer.height / 2) + (exitImg.getHeight() / 2f) ); final int logoAnimationDuration = 350; logo.setHoverAnimationDuration(logoAnimationDuration); @@ -174,30 +163,30 @@ public class MainMenu extends BasicGameState { // initialize music buttons int musicWidth = GameImage.MUSIC_PLAY.getImage().getWidth(); int musicHeight = GameImage.MUSIC_PLAY.getImage().getHeight(); - musicPlay = new MenuButton(GameImage.MUSIC_PLAY.getImage(), width - (2 * musicWidth), musicHeight / 1.5f); - musicPause = new MenuButton(GameImage.MUSIC_PAUSE.getImage(), width - (2 * musicWidth), musicHeight / 1.5f); - musicNext = new MenuButton(GameImage.MUSIC_NEXT.getImage(), width - musicWidth, musicHeight / 1.5f); - musicPrevious = new MenuButton(GameImage.MUSIC_PREVIOUS.getImage(), width - (3 * musicWidth), musicHeight / 1.5f); + musicPlay = new MenuButton(GameImage.MUSIC_PLAY.getImage(), displayContainer.width - (2 * musicWidth), musicHeight / 1.5f); + musicPause = new MenuButton(GameImage.MUSIC_PAUSE.getImage(), displayContainer.width - (2 * musicWidth), musicHeight / 1.5f); + musicNext = new MenuButton(GameImage.MUSIC_NEXT.getImage(), displayContainer.width - musicWidth, musicHeight / 1.5f); + musicPrevious = new MenuButton(GameImage.MUSIC_PREVIOUS.getImage(), displayContainer.width - (3 * musicWidth), musicHeight / 1.5f); musicPlay.setHoverExpand(1.5f); musicPause.setHoverExpand(1.5f); musicNext.setHoverExpand(1.5f); musicPrevious.setHoverExpand(1.5f); // initialize music position bar location - musicBarX = width - musicWidth * 3.5f; + musicBarX = displayContainer.width - musicWidth * 3.5f; musicBarY = musicHeight * 1.25f; musicBarWidth = musicWidth * 3f; musicBarHeight = musicHeight * 0.11f; // initialize downloads button Image dlImg = GameImage.DOWNLOADS.getImage(); - downloadsButton = new MenuButton(dlImg, width - dlImg.getWidth() / 2f, height / 2f); + downloadsButton = new MenuButton(dlImg, displayContainer.width - dlImg.getWidth() / 2f, displayContainer.height / 2f); downloadsButton.setHoverAnimationDuration(350); downloadsButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK); downloadsButton.setHoverExpand(1.03f, Expand.LEFT); // initialize repository button - float startX = width * 0.997f, startY = height * 0.997f; + float startX = displayContainer.width * 0.997f, startY = displayContainer.height * 0.997f; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { // only if a webpage can be opened Image repoImg; repoImg = GameImage.REPOSITORY.getImage(); @@ -217,7 +206,7 @@ public class MainMenu extends BasicGameState { } // initialize update buttons - float updateX = width / 2f, updateY = height * 17 / 18f; + float updateX = displayContainer.width / 2f, updateY = displayContainer.height * 17 / 18f; Image downloadImg = GameImage.DOWNLOAD.getImage(); updateButton = new MenuButton(downloadImg, updateX, updateY); updateButton.setHoverAnimationDuration(400); @@ -230,10 +219,10 @@ public class MainMenu extends BasicGameState { restartButton.setHoverRotate(360); // initialize star fountain - starFountain = new StarFountain(width, height); + starFountain = new StarFountain(displayContainer.width, displayContainer.height); // logo animations - float centerOffsetX = width / 6.5f; + float centerOffsetX = displayContainer.width / 6.5f; logoOpen = new AnimatedValue(100, 0, centerOffsetX, AnimationEquation.OUT_QUAD); logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD); logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR); @@ -242,10 +231,9 @@ public class MainMenu extends BasicGameState { } @Override - public void render(GameContainer container, StateBasedGame game, Graphics g) - throws SlickException { - int width = container.getWidth(); - int height = container.getHeight(); + public void render(Graphics g) { + int width = displayContainer.width; + int height = displayContainer.height; // draw background Beatmap beatmap = MusicController.getBeatmap(); @@ -305,7 +293,8 @@ public class MainMenu extends BasicGameState { musicPrevious.draw(); // draw music position bar - int mouseX = input.getMouseX(), mouseY = input.getMouseY(); + int mouseX = displayContainer.mouseX; + int mouseY = displayContainer.mouseY; g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL); g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4); g.setColor(Color.white); @@ -366,12 +355,14 @@ public class MainMenu extends BasicGameState { } @Override - public void update(GameContainer container, StateBasedGame game, int delta) - throws SlickException { + public void preRenderUpdate() { + int delta = displayContainer.renderDelta; + UI.update(delta); if (MusicController.trackEnded()) nextTrack(false); // end of track: go to next track - int mouseX = input.getMouseX(), mouseY = input.getMouseY(); + int mouseX = displayContainer.mouseX; + int mouseY = displayContainer.mouseY; logo.hoverUpdate(delta, mouseX, mouseY, 0.25f); playButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); @@ -396,7 +387,7 @@ public class MainMenu extends BasicGameState { // window focus change: increase/decrease theme song volume if (MusicController.isThemePlaying() && - MusicController.isTrackDimmed() == container.hasFocus()) + MusicController.isTrackDimmed() == Display.isActive()) MusicController.toggleTrackDimmed(0.33f); // fade in background @@ -413,7 +404,7 @@ public class MainMenu extends BasicGameState { } // buttons - int centerX = container.getWidth() / 2; + int centerX = displayContainer.width / 2; float currentLogoButtonAlpha; switch (logoState) { case DEFAULT: @@ -468,11 +459,8 @@ public class MainMenu extends BasicGameState { } @Override - public int getID() { return state; } - - @Override - public void enter(GameContainer container, StateBasedGame game) - throws SlickException { + public void enter() { + super.enter(); UI.enter(); if (!enterNotification) { if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) { @@ -489,7 +477,8 @@ public class MainMenu extends BasicGameState { starFountain.clear(); // reset button hover states if mouse is not currently hovering over the button - int mouseX = input.getMouseX(), mouseY = input.getMouseY(); + int mouseX = displayContainer.mouseX; + int mouseY = displayContainer.mouseY; if (!logo.contains(mouseX, mouseY, 0.25f)) logo.resetHover(); if (!playButton.contains(mouseX, mouseY, 0.25f)) @@ -515,17 +504,17 @@ public class MainMenu extends BasicGameState { } @Override - public void leave(GameContainer container, StateBasedGame game) - throws SlickException { + public void leave() { + super.leave(); if (MusicController.isTrackDimmed()) MusicController.toggleTrackDimmed(1f); } @Override - public void mousePressed(int button, int x, int y) { + public boolean mousePressed(int button, int x, int y) { // check mouse button if (button == Input.MOUSE_MIDDLE_BUTTON) - return; + return false; // music position bar if (MusicController.isPlaying()) { @@ -533,7 +522,7 @@ public class MainMenu extends BasicGameState { lastMeasureProgress = 0f; float pos = (x - musicBarX) / musicBarWidth; MusicController.setPosition((int) (pos * MusicController.getDuration())); - return; + return true; } } @@ -546,29 +535,29 @@ public class MainMenu extends BasicGameState { MusicController.resume(); UI.sendBarNotification("Play"); } - return; + return true; } else if (musicNext.contains(x, y)) { nextTrack(true); UI.sendBarNotification(">> Next"); - return; + return true; } else if (musicPrevious.contains(x, y)) { lastMeasureProgress = 0f; if (!previous.isEmpty()) { - SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); - menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false); + instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false); if (Options.isDynamicBackgroundEnabled()) bgAlpha.setTime(0); } else MusicController.setPosition(0); UI.sendBarNotification("<< Previous"); - return; + return true; } // downloads button actions if (downloadsButton.contains(x, y)) { SoundController.playSound(SoundEffect.MENUHIT); - game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition()); - return; + // TODO //displayContainer.switchState(DownloadsMenu.class); + //game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition()); + return true; } // repository button actions @@ -580,7 +569,7 @@ public class MainMenu extends BasicGameState { } catch (IOException e) { ErrorHandler.error("Could not browse to repository URI.", e, false); } - return; + return true; } if (danceRepoButton != null && danceRepoButton.contains(x, y)) { @@ -591,7 +580,7 @@ public class MainMenu extends BasicGameState { } catch (IOException e) { ErrorHandler.error("Could not browse to repository URI.", e, false); } - return; + return true; } // update button actions @@ -604,13 +593,14 @@ public class MainMenu extends BasicGameState { updateButton.setHoverAnimationDuration(800); updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD); updateButton.setHoverFade(0.6f); - return; + return true; } else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) { SoundController.playSound(SoundEffect.MENUHIT); Updater.get().prepareUpdate(); - container.setForceExit(false); - container.exit(); - return; + // TODO: exit? + //container.setForceExit(false); + //container.exit(); + return true; } } @@ -623,7 +613,7 @@ public class MainMenu extends BasicGameState { playButton.getImage().setAlpha(0f); exitButton.getImage().setAlpha(0f); SoundController.playSound(SoundEffect.MENUHIT); - return; + return true; } } @@ -632,21 +622,24 @@ public class MainMenu extends BasicGameState { if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) { SoundController.playSound(SoundEffect.MENUHIT); enterSongMenu(); - return; + return true; } else if (exitButton.contains(x, y, 0.25f)) { - container.exit(); - return; + // TODO exit? + //container.exit(); + return true; } } + return false; } @Override - public void mouseWheelMoved(int newValue) { + public boolean mouseWheelMoved(int newValue) { UI.changeVolume((newValue < 0) ? -1 : 1); + return true; } @Override - public void keyPressed(int key, char c) { + public boolean keyPressed(int key, char c) { switch (key) { case Input.KEY_ESCAPE: case Input.KEY_Q: @@ -656,9 +649,10 @@ public class MainMenu extends BasicGameState { logoTimer = 0; break; } - ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.EXIT); - game.enterState(Opsu.STATE_BUTTONMENU); - break; + // TODO + //((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.EXIT); + //game.enterState(Opsu.STATE_BUTTONMENU); + return true; case Input.KEY_P: SoundController.playSound(SoundEffect.MENUHIT); if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) { @@ -669,30 +663,32 @@ public class MainMenu extends BasicGameState { exitButton.getImage().setAlpha(0f); } else enterSongMenu(); - break; + return true; case Input.KEY_D: - SoundController.playSound(SoundEffect.MENUHIT); - game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition()); - break; + // TODO + //SoundController.playSound(SoundEffect.MENUHIT); + //game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition()); + return true; case Input.KEY_R: nextTrack(true); - break; + return true; case Input.KEY_UP: UI.changeVolume(1); - break; + return true; case Input.KEY_DOWN: UI.changeVolume(-1); - break; + return true; case Input.KEY_F7: - Options.setNextFPS(container); - break; + Options.setNextFPS(displayContainer); + return true; case Input.KEY_F10: Options.toggleMouseDisabled(); - break; + return true; case Input.KEY_F12: Utils.takeScreenShot(); - break; + return true; } + return false; } /** @@ -710,7 +706,7 @@ public class MainMenu extends BasicGameState { */ public void reset() { // reset logo - logo.setX(container.getWidth() / 2); + logo.setX(displayContainer.width / 2); logoOpen.setTime(0); logoClose.setTime(0); logoButtonAlpha.setTime(0); @@ -746,8 +742,7 @@ public class MainMenu extends BasicGameState { MusicController.playAt(0, false); return; } - SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU); - BeatmapSetNode node = menu.setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false); + BeatmapSetNode node = instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false); boolean sameAudio = false; if (node != null) { sameAudio = MusicController.getBeatmap().audioFilename.equals(node.getBeatmapSet().get(0).audioFilename); @@ -764,9 +759,11 @@ public class MainMenu extends BasicGameState { private void enterSongMenu() { int state = Opsu.STATE_SONGMENU; if (BeatmapSetList.get().getMapSetCount() == 0) { - ((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!"); - state = Opsu.STATE_DOWNLOADSMENU; + // TODO + //((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!"); + //state = Opsu.STATE_DOWNLOADSMENU; } - game.enterState(state, new EasedFadeOutTransition(), new FadeInTransition()); + // TODO + //game.enterState(state, new EasedFadeOutTransition(), new FadeInTransition()); } } diff --git a/src/itdelatrisu/opsu/states/SongMenu.java b/src/itdelatrisu/opsu/states/SongMenu.java index a0328350..4178065a 100644 --- a/src/itdelatrisu/opsu/states/SongMenu.java +++ b/src/itdelatrisu/opsu/states/SongMenu.java @@ -1120,7 +1120,8 @@ public class SongMenu extends BasicGameState { } break; case Input.KEY_F7: - Options.setNextFPS(container); + // TODO d + //Options.setNextFPS(container); break; case Input.KEY_F10: Options.toggleMouseDisabled(); diff --git a/src/itdelatrisu/opsu/states/Splash.java b/src/itdelatrisu/opsu/states/Splash.java index 03154422..5aa82ee6 100644 --- a/src/itdelatrisu/opsu/states/Splash.java +++ b/src/itdelatrisu/opsu/states/Splash.java @@ -38,6 +38,7 @@ import org.newdawn.slick.Color; import org.newdawn.slick.Graphics; import org.newdawn.slick.Input; import yugecin.opsudance.core.DisplayContainer; +import yugecin.opsudance.core.inject.InstanceContainer; import yugecin.opsudance.core.state.BaseOpsuState; /** @@ -47,6 +48,8 @@ import yugecin.opsudance.core.state.BaseOpsuState; */ public class Splash extends BaseOpsuState { + private final InstanceContainer instanceContainer; + /** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */ private static final int MIN_SPLASH_TIME = 400; @@ -71,8 +74,9 @@ public class Splash extends BaseOpsuState { // game-related variables private boolean init = false; - public Splash(DisplayContainer displayContainer) { + public Splash(DisplayContainer displayContainer, InstanceContainer instanceContainer) { super(displayContainer); + this.instanceContainer = instanceContainer; } @Override @@ -102,7 +106,7 @@ public class Splash extends BaseOpsuState { } @Override - public void update() { + public void preRenderUpdate() { if (!init) { init = true; @@ -158,7 +162,7 @@ public class Splash extends BaseOpsuState { } // fade in logo - if (logoAlpha.update(displayContainer.delta)) + if (logoAlpha.update(displayContainer.renderDelta)) GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue()); // change states when loading complete @@ -166,20 +170,16 @@ public class Splash extends BaseOpsuState { // initialize song list if (BeatmapSetList.get().size() > 0) { BeatmapSetList.get().init(); - if (Options.isThemeSongEnabled()) + if (Options.isThemeSongEnabled()) { MusicController.playThemeSong(); - else - //((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true); + } else { + instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true); System.out.println(("todo")); - // TODO - } - - // play the theme song - else + } + } else { MusicController.playThemeSong(); - - //game.enterState(Opsu.STATE_MAINMENU); - + } + displayContainer.switchState(MainMenu.class); } } diff --git a/src/yugecin/opsudance/core/inject/OpsuDanceInjector.java b/src/yugecin/opsudance/core/inject/OpsuDanceInjector.java index bcf806bd..bf9145bd 100644 --- a/src/yugecin/opsudance/core/inject/OpsuDanceInjector.java +++ b/src/yugecin/opsudance/core/inject/OpsuDanceInjector.java @@ -17,6 +17,7 @@ */ package yugecin.opsudance.core.inject; +import itdelatrisu.opsu.states.MainMenu; import itdelatrisu.opsu.states.Splash; import yugecin.opsudance.PreStartupInitializer; import yugecin.opsudance.core.DisplayContainer; @@ -53,6 +54,7 @@ public class OpsuDanceInjector extends Injector { bind(EmptyState.class).asEagerSingleton(); bind(Splash.class).asEagerSingleton(); + bind(MainMenu.class).asEagerSingleton(); } }