/** * @see org.newdawn.slick.state.BasicGameState#keyReleased(int, char) */ public void keyReleased(int key, char c) { if (key == Input.KEY_2) { GameState target = game.getState(TestState2.ID); final long start = System.currentTimeMillis(); CrossStateTransition t = new CrossStateTransition(target) { public boolean isComplete() { return (System.currentTimeMillis() - start) > 2000; } public void init(GameState firstState, GameState secondState) { } }; game.enterState(TestState2.ID, t, new EmptyTransition()); } if (key == Input.KEY_3) { game.enterState(TestState3.ID, new FadeOutTransition(Color.black), new FadeInTransition(Color.black)); } }
@Override public void update(GameContainer gc, StateBasedGame sbg, int i) throws SlickException { if (shouldToggleFullscreen) { shouldToggleFullscreen = false; boolean fs = !gc.isFullscreen(); AppGameContainer agc = (AppGameContainer)gc; agc.setDisplayMode(fs ? agc.getScreenWidth() : Application.DISPLAY_WIDTH, fs ? agc.getScreenHeight() : Application.DISPLAY_HEIGHT, fs); } if (gc.getInput().isKeyPressed(Input.KEY_ENTER)) { click.play(1.0f, CLICK_VOLUME); mainMenu.fade(1000, 0.0f, true); sbg.enterState(Application.GAME, new FadeOutTransition(Color.black, 1000), new EmptyTransition()); } if (gc.getInput().isKeyPressed(Input.KEY_C)) { sbg.enterState(Application.CREDITS); } }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP, node); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); node.getBeatmapSet().setFavorite(true); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); node.getBeatmapSet().setFavorite(false); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_FAVORITE); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_CONFIRM, node); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); BeatmapSetNode node = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getNode(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.BEATMAP_DELETE_SELECT, node); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); ScoreData scoreData = ((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).getScoreData(); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.SCORE, scoreData); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); try { Desktop.getDesktop().browse(OpsuConstants.WEBSITE_URI); } catch (Exception e) { UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red); } game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); try { Desktop.getDesktop().browse(OpsuConstants.REPOSITORY_URI); } catch (Exception e) { UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red); } game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); StringBuilder sb = new StringBuilder(); sb.append("[Type your description here. Feel free to delete the info below if it's not relevant.]\n\n"); sb.append("---\n"); sb.append(ErrorHandler.getEnvironmentInfoForIssue()); URI uri = ErrorHandler.getIssueURI("", sb.toString()); try { Desktop.getDesktop().browse(uri); } catch (Exception e) { UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red); } game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); try { Desktop.getDesktop().browse(OpsuConstants.CREDITS_URI); } catch (Exception e) { UI.getNotificationManager().sendNotification("The web page could not be opened.", Color.red); } game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void mousePressed(int button, int x, int y) { if (gameFinished) return; // watching replay if (isReplay || GameMod.AUTO.isActive()) { if (button == Input.MOUSE_MIDDLE_BUTTON) return; // skip button if (skipButton.contains(x, y)) skipIntro(); // playback speed button else if (playbackSpeed.getButton().contains(x, y)) { playbackSpeed = playbackSpeed.next(); MusicController.setPitch(getCurrentPitch()); } // replay seeking else if (Options.isReplaySeekingEnabled() && !GameMod.AUTO.isActive() && musicPositionBarContains(x, y)) { SoundController.mute(true); // mute sounds while seeking float pos = (y - musicBarY) / musicBarHeight * beatmap.endTime; MusicController.setPosition((int) pos); lastTrackPosition = (int) pos; isSeeking = true; } return; } if (Options.isMouseDisabled()) return; // mouse wheel: pause the game if (button == Input.MOUSE_MIDDLE_BUTTON && !Options.isMouseWheelDisabled()) { int trackPosition = MusicController.getPosition(true); if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) { pausedMousePosition = new Vec2f(x, y); pausePulse = 0f; } if (MusicController.isPlaying() || isLeadIn()) pauseTime = trackPosition; if (video != null) video.pause(); game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition()); return; } // game keys int keys = ReplayFrame.KEY_NONE; if (button == Input.MOUSE_LEFT_BUTTON) keys = ReplayFrame.KEY_M1; else if (button == Input.MOUSE_RIGHT_BUTTON) keys = ReplayFrame.KEY_M2; if (keys != ReplayFrame.KEY_NONE) gameKeyPressed(keys, x, y, MusicController.getPosition(true)); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUBACK); game.enterState(Opsu.STATE_MAINMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUBACK); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
@Override public void click(GameContainer container, StateBasedGame game) { SoundController.playSound(SoundEffect.MENUHIT); ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).doStateActionOnLoad(MenuState.RELOAD); game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition()); }
/** * Enter a particular game state with no transition * * @param id The ID of the state to enter */ public void enterState(int id) { enterState(id, new EmptyTransition(), new EmptyTransition()); }
/** * Enter a particular game state with no transition * Modification: Saves the last state * * @param id The ID of the state to enter */ public void enterState(int id) { enterState(id, new EmptyTransition(), new EmptyTransition()); }