Java Code Examples for org.newdawn.slick.state.StateBasedGame#enterState()
The following examples show how to use
org.newdawn.slick.state.StateBasedGame#enterState() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StateSelectMode.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); if(isTopLevel && (cursor == list.length - 1)) { // More... NullpoMinoSlick.propGlobal.setProperty("name.mode.toplevel", list[cursor]); game.enterState(StateSelectModeFolder.ID); } else { // Go to rule selector if(isTopLevel) { NullpoMinoSlick.propGlobal.setProperty("name.mode.toplevel", list[cursor]); } if(strCurrentFolder.length() > 0) { NullpoMinoSlick.propGlobal.setProperty("name.mode." + strCurrentFolder, list[cursor]); } NullpoMinoSlick.propGlobal.setProperty("name.mode", list[cursor]); NullpoMinoSlick.saveConfig(); game.enterState(StateSelectRuleFromList.ID); } return false; }
Example 2
Source File: StateConfigKeyboardNavi.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { if (cursor == 0) { for(int i = 0; i < GameKeySlick.MAX_BUTTON; i++) { GameKeySlick.gamekey[player].keymapNav[i] = GameKeySlick.gamekey[player].keymap[i]; } } else if (cursor == 1) { NullpoMinoSlick.stateConfigKeyboard.player = player; NullpoMinoSlick.stateConfigKeyboard.isNavSetting = true; game.enterState(StateConfigKeyboard.ID); return true; } GameKeySlick.gamekey[player].saveConfig(NullpoMinoSlick.propConfig); NullpoMinoSlick.saveConfig(); ResourceHolderSlick.soundManager.play("decide"); gameObj.enterState(StateConfigMainMenu.ID); return true; }
Example 3
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 4
Source File: StateConfigKeyboardReset.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); GameKeySlick.gamekey[player].loadDefaultKeymap(cursor); GameKeySlick.gamekey[player].saveConfig(NullpoMinoSlick.propConfig); NullpoMinoSlick.saveConfig(); game.enterState(StateConfigMainMenu.ID); return false; }
Example 5
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 6
Source File: StateLoading.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if(preloadSet > 2) { // Change title bar caption if(container instanceof AppGameContainer) { ((AppGameContainer) container).setTitle("NullpoMino version" + GameManager.getVersionString()); ((AppGameContainer) container).setUpdateOnlyWhenVisible(true); } // First run if(NullpoMinoSlick.propConfig.getProperty("option.firstSetupMode", true) == true) { // Set various default settings here GameKeySlick.gamekey[0].loadDefaultKeymap(); GameKeySlick.gamekey[0].saveConfig(NullpoMinoSlick.propConfig); NullpoMinoSlick.propConfig.setProperty("option.firstSetupMode", false); // Set default rotation button setting (only for first run) if(NullpoMinoSlick.propGlobal.getProperty("global.firstSetupMode", true) == true) { for(int pl = 0; pl < 2; pl++) { if(NullpoMinoSlick.propGlobal.getProperty(pl + ".tuning.owRotateButtonDefaultRight") == null) { NullpoMinoSlick.propGlobal.setProperty(pl + ".tuning.owRotateButtonDefaultRight", 0); } } NullpoMinoSlick.propGlobal.setProperty("global.firstSetupMode", false); } // Save settings NullpoMinoSlick.saveConfig(); // Go to title screen game.enterState(StateTitle.ID); } // Second+ run else { game.enterState(StateTitle.ID); } } }
Example 7
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 8
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 9
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 10
Source File: ButtonMenu.java From opsu with GNU General Public License v3.0 | 5 votes |
@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()); }
Example 11
Source File: TransitionTest.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.state.GameState#update(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, int) */ public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if (container.getInput().isKeyPressed(Input.KEY_SPACE)) { Transition[] pair = getNextTransitionPair(); game.enterState(next, pair[0], pair[1]); } }
Example 12
Source File: StateSelectModeFolder.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); if(cursor < listFolder.size()) { strCurrentFolder = list[cursor]; } else { strCurrentFolder = ""; } NullpoMinoSlick.propGlobal.setProperty("name.folder", strCurrentFolder); NullpoMinoSlick.saveConfig(); StateSelectMode.isTopLevel = false; game.enterState(StateSelectMode.ID); return false; }
Example 13
Source File: StateConfigRuleStyleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onCancel(GameContainer container, StateBasedGame game, int delta) { game.enterState(StateConfigMainMenu.ID); return false; }
Example 14
Source File: StateConfigKeyboardNavi.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onCancel(GameContainer container, StateBasedGame game, int delta) { game.enterState(StateConfigMainMenu.ID); return false; }
Example 15
Source File: StateConfigRuleSelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onCancel(GameContainer container, StateBasedGame game, int delta) { game.enterState(StateConfigRuleStyleSelect.ID); return true; }
Example 16
Source File: StateConfigAISelect.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void updateImpl(GameContainer container, StateBasedGame game, int delta) throws SlickException { // Update key input states GameKeySlick.gamekey[0].update(container.getInput()); // Cursor movement if(GameKeySlick.gamekey[0].isMenuRepeatKey(GameKeySlick.BUTTON_UP)) { cursor--; if(cursor < 0) cursor = 6; ResourceHolderSlick.soundManager.play("cursor"); } if(GameKeySlick.gamekey[0].isMenuRepeatKey(GameKeySlick.BUTTON_DOWN)) { cursor++; if(cursor > 6) cursor = 0; ResourceHolderSlick.soundManager.play("cursor"); } // Configuration changes int change = 0; if(GameKeySlick.gamekey[0].isMenuRepeatKey(GameKeySlick.BUTTON_LEFT)) change = -1; if(GameKeySlick.gamekey[0].isMenuRepeatKey(GameKeySlick.BUTTON_RIGHT)) change = 1; if(change != 0) { ResourceHolderSlick.soundManager.play("change"); switch(cursor) { case 0: aiID += change; if(aiID < -1) aiID = aiNameList.length - 1; if(aiID > aiNameList.length - 1) aiID = -1; break; case 1: aiMoveDelay += change; if(aiMoveDelay < -1) aiMoveDelay = 99; if(aiMoveDelay > 99) aiMoveDelay = -1; break; case 2: aiThinkDelay += change * 10; if(aiThinkDelay < 0) aiThinkDelay = 1000; if(aiThinkDelay > 1000) aiThinkDelay = 0; break; case 3: aiUseThread = !aiUseThread; break; case 4: aiShowHint = !aiShowHint; break; case 5: aiPrethink = !aiPrethink; break; case 6: aiShowState = !aiShowState; break; } } // Confirm button if(GameKeySlick.gamekey[0].isPushKey(GameKeySlick.BUTTON_A)) { ResourceHolderSlick.soundManager.play("decide"); if(aiID >= 0) NullpoMinoSlick.propGlobal.setProperty(player + ".ai", aiPathList[aiID]); else NullpoMinoSlick.propGlobal.setProperty(player + ".ai", ""); NullpoMinoSlick.propGlobal.setProperty(player + ".aiMoveDelay", aiMoveDelay); NullpoMinoSlick.propGlobal.setProperty(player + ".aiThinkDelay", aiThinkDelay); NullpoMinoSlick.propGlobal.setProperty(player + ".aiUseThread", aiUseThread); NullpoMinoSlick.propGlobal.setProperty(player + ".aiShowHint",aiShowHint); NullpoMinoSlick.propGlobal.setProperty(player + ".aiPrethink",aiPrethink); NullpoMinoSlick.propGlobal.setProperty(player + ".aiShowState",aiShowState); NullpoMinoSlick.saveConfig(); game.enterState(StateConfigMainMenu.ID); return; } // Cancel button if(GameKeySlick.gamekey[0].isPushKey(GameKeySlick.BUTTON_B)) { game.enterState(StateConfigMainMenu.ID); return; } }
Example 17
Source File: Splash.java From opsu with GNU General Public License v3.0 | 4 votes |
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { if (!init) { init = true; // resources already loaded (from application restart) if (BeatmapSetList.get() != null) { if (newSkin || watchServiceChange) { // need to reload resources thread = new Thread() { @Override public void run() { // reload beatmaps if watch service newly enabled if (watchServiceChange) BeatmapParser.parseAllFiles(Options.getBeatmapDir()); // reload sounds if skin changed // TODO: only reload each sound if actually needed? if (newSkin) SoundController.init(); Utils.gc(true); finished = true; thread = null; } }; thread.start(); } else // don't reload anything finished = true; } // load all resources in a new thread else { thread = new Thread() { @Override public void run() { File beatmapDir = Options.getBeatmapDir(); File importDir = Options.getImportDir(); // unpack all OSZ archives OszUnpacker.unpackAllFiles(importDir, beatmapDir); // parse song directory BeatmapParser.parseAllFiles(beatmapDir); // import skins SkinUnpacker.unpackAllFiles(importDir, Options.getSkinRootDir()); // import replays ReplayImporter.importAllReplaysFromDir(importDir); // load sounds SoundController.init(); Utils.gc(true); finished = true; thread = null; } }; thread.start(); } } // fade in logo if (logoAlpha.update(delta)) GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue()); // fade in loading progress elapsedTime += delta; if (elapsedTime >= PROGRESS_START_TIME) progressAlpha.update(delta); // change states when loading complete if (finished && logoAlpha.isFinished()) { // initialize song list if (BeatmapSetList.get().size() > 0) { BeatmapSetList.get().init(); if (Options.isThemeSongEnabled()) MusicController.playThemeSong(); else ((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true); } // play the theme song else MusicController.playThemeSong(); game.enterState(Opsu.STATE_MAINMENU); } }
Example 18
Source File: StateConfigMainMenu.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onCancel(GameContainer container, StateBasedGame game, int delta) { game.enterState(StateTitle.ID); return false; }
Example 19
Source File: StateConfigMainMenu.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onDecide(GameContainer container, StateBasedGame game, int delta) { ResourceHolderSlick.soundManager.play("decide"); switch (cursor) { case 0: game.enterState(StateConfigGeneral.ID); break; case 1: NullpoMinoSlick.stateConfigRuleStyleSelect.player = player; game.enterState(StateConfigRuleStyleSelect.ID); break; case 2: NullpoMinoSlick.stateConfigGameTuning.player = player; game.enterState(StateConfigGameTuning.ID); break; case 3: NullpoMinoSlick.stateConfigAISelect.player = player; game.enterState(StateConfigAISelect.ID); break; case 4: NullpoMinoSlick.stateConfigKeyboard.player = player; NullpoMinoSlick.stateConfigKeyboard.isNavSetting = false; game.enterState(StateConfigKeyboard.ID); break; case 5: NullpoMinoSlick.stateConfigKeyboardNavi.player = player; game.enterState(StateConfigKeyboardNavi.ID); break; case 6: NullpoMinoSlick.stateConfigKeyboardReset.player = player; game.enterState(StateConfigKeyboardReset.ID); break; case 7: NullpoMinoSlick.stateConfigJoystickMain.player = player; game.enterState(StateConfigJoystickMain.ID); break; } return false; }
Example 20
Source File: StateSelectRuleFromList.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected boolean onCancel(GameContainer container, StateBasedGame game, int delta) { game.enterState(StateSelectMode.ID); return false; }