@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); mc.getTextureManager().bindTexture(skrivemaskinegui); this.drawTexturedModalRect(this.width / 2 - 128, this.height / 2 - 128, 0, 0, 256, 256); /* this is where the editor reads keys and writes to the screen */ if (org.lwjgl.input.Keyboard.getEventKeyState()) { // if (isAllowedDeletion()) { text.deleteCharAt(cursorLocation); cursorLocation--; text.deleteCharAt(cursorLocation); text.insert(cursorLocation, cursor); // moving cursor } else if (isAllowedNewLine()) { text.deleteCharAt(cursorLocation); text.insert(cursorLocation, '\n'); cursorLocation++; text.insert(cursorLocation, cursor); // moving cursor } else if (isAllowedLeftArrowNavigation()) { text.deleteCharAt(cursorLocation); cursorLocation--; text.insert(cursorLocation, cursor); // moving cursor } else if (isAllowedRightArrowNavigation()) { text.deleteCharAt(cursorLocation); cursorLocation++; text.insert(cursorLocation, cursor); // moving cursor } else if (Keyboard.getEventKey() == Keyboard.KEY_TAB) { text.deleteCharAt(cursorLocation); for (int i = 0; i < 3; i++) { text.insert(cursorLocation, " "); cursorLocation++; } text.insert(cursorLocation, cursor); // moving cursor } else { if (isAllowedCharacters()) { // System.out.println(org.lwjgl.input.Keyboard.getEventKey()); text.deleteCharAt(cursorLocation); text.insert(cursorLocation, org.lwjgl.input.Keyboard.getEventCharacter()); cursorLocation++; text.insert(cursorLocation, cursor); // moving cursor } } org.lwjgl.input.Keyboard.destroy(); } else if (!org.lwjgl.input.Keyboard.isCreated()) { try { org.lwjgl.input.Keyboard.create(); } catch (Exception e) { } } /* writes the text string to the screen */ renderer.drawSplitString( text.toString(), this.width / 2 - 118, this.height / 2 - 119, 238, 0xFFFFF0); super.drawScreen(mouseX, mouseY, partialTicks); }
/** Handles keyboard input. */ public void handleKeyboardInput() throws IOException { if (Keyboard.getEventKeyState()) { this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); } this.mc.dispatchKeypresses(); }
private void doKeys() { while (Keyboard.next()) { char eventChar = Keyboard.getEventCharacter(); int eventKey = Keyboard.getEventKey(); long eventTick = Keyboard.getEventNanoseconds(); boolean eventState = Keyboard.getEventKeyState(); // System.out.println("doKeys("+eventKey+")"); if (eventKey == Keyboard.KEY_LSHIFT) { if (eventState) { mModifiers |= KeyEvent.VK_SHIFT; } else { mModifiers &= ~KeyEvent.VK_SHIFT; } } else if (eventKey == Keyboard.KEY_RSHIFT) { if (eventState) { mModifiers |= KeyEvent.VK_SHIFT; } else { mModifiers &= ~KeyEvent.VK_SHIFT; } } else if (eventKey == Keyboard.KEY_LCONTROL) { if (eventState) { mModifiers |= KeyEvent.VK_CONTROL; } else { mModifiers &= ~KeyEvent.VK_CONTROL; } } else if (eventKey == Keyboard.KEY_RCONTROL) { if (eventState) { mModifiers |= KeyEvent.VK_CONTROL; } else { mModifiers &= ~KeyEvent.VK_CONTROL; } } else if (eventKey == Keyboard.KEY_LMENU) { if (eventState) { mModifiers |= KeyEvent.VK_ALT; } else { mModifiers &= ~KeyEvent.VK_ALT; } } else if (eventKey == Keyboard.KEY_RMENU) { if (eventState) { mModifiers |= KeyEvent.VK_ALT; } else { mModifiers &= ~KeyEvent.VK_ALT; } } if (KEY_LWJGL_TO_AWT.containsKey(eventKey)) { eventKey = KEY_LWJGL_TO_AWT.get(eventKey); } KeyEvent e = new KeyEvent( this, eventState ? KeyEvent.KEY_PRESSED : KeyEvent.KEY_RELEASED, eventTick, mModifiers, eventKey, eventChar); fireKeyEvent(e); } }
@Override protected void input() { while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == Keyboard.KEY_F1) { font = (font + 1) % fonts.length; } else if (Keyboard.getEventKey() == Keyboard.KEY_BACK && text.length() > 1) { text.deleteCharAt(text.length() - 2); } else if (Keyboard.getEventKey() == Keyboard.KEY_RETURN) { text.insert(text.length() - 1, '\n'); } else if (activeFont() .getAvailableChars() .contains(Character.toLowerCase(Keyboard.getEventCharacter()))) { text.insert(text.length() - 1, Keyboard.getEventCharacter()); } } } }
public void func_569_f() { if (Keyboard.getEventKeyState()) { if (Keyboard.getEventKey() == 87) { this.field_945_b.func_6270_h(); return; } this.func_580_a(Keyboard.getEventCharacter(), Keyboard.getEventKey()); } }
@Override public void handleKeyboardInput() { ControlsBasicItem item = model.getEditingItem(); if (item != null) { this.keyTyped( org.lwjgl.input.Keyboard.getEventCharacter(), org.lwjgl.input.Keyboard.getEventKey(), org.lwjgl.input.Keyboard.getEventKeyState()); } else { super.handleKeyboardInput(); } }
// TODO: Deal with duplicates. Can't use Traits sadly. public void keyboardInput() { HashMap<String, Object> passedInformation = new HashMap<String, Object>(0); passedInformation.put("character", Keyboard.getEventCharacter()); passedInformation.put("key", Keyboard.getEventKey()); passedInformation.put("down", Keyboard.getEventKeyState()); passedInformation.put("time", Keyboard.getEventNanoseconds()); passedInformation.put("count", Keyboard.getKeyCount()); for (ScreenLayer layer : guiLayers) { MinecraftForge.EVENT_BUS.post(new LayerEvent.KeyboardInput(GUIAPIEvent.Phase.START, layer)); layer.keyInputEvent(passedInformation); MinecraftForge.EVENT_BUS.post(new LayerEvent.KeyboardInput(GUIAPIEvent.Phase.END, layer)); } }
private void refreshKeyboard() { while (Keyboard.next()) { int key = Keyboard.getEventKey(); boolean keyState = Keyboard.getEventKeyState(); String keyname = Keyboard.getKeyName(key); if (keyState) { char c = Keyboard.getEventCharacter(); for (InputListener listener : listeners) { if (listener.onKeyDown(key, keyname, c)) break; } } else { for (InputListener listener : listeners) { if (listener.onKeyUp(key, keyname)) break; } } } }
public void pollInput(Player player) { if (org.lwjgl.input.Keyboard.isCreated()) { while (org.lwjgl.input.Keyboard.next()) { Keyboard key = Keyboard.get(org.lwjgl.input.Keyboard.getEventKey()); if (key != null) { onKeyPressed( player, key, org.lwjgl.input.Keyboard.getEventKeyState(), org.lwjgl.input.Keyboard.getEventCharacter()); } } } // Handle mouse if (org.lwjgl.input.Mouse.isCreated()) { int x, y; while (org.lwjgl.input.Mouse.next()) { // Calculate dx/dy since last event polling x = org.lwjgl.input.Mouse.getEventX(); y = org.lwjgl.input.Mouse.getEventY(); Mouse button = Mouse.get(org.lwjgl.input.Mouse.getEventButton()); if (button != null) { onMouseClicked(player, button, org.lwjgl.input.Mouse.getEventButtonState(), x, y); continue; } // Handle scrolls int scroll = org.lwjgl.input.Mouse.getEventDWheel(); if (scroll < 0) { onMouseClicked(player, Mouse.MOUSE_SCROLLUP, true, x, y); } else if (scroll > 0) { onMouseClicked(player, Mouse.MOUSE_SCROLLDOWN, true, x, y); } onMouseMove( player, org.lwjgl.input.Mouse.getEventDX(), org.lwjgl.input.Mouse.getEventDY(), org.lwjgl.input.Mouse.getEventX(), org.lwjgl.input.Mouse.getEventY()); } } }
@Override protected boolean onEvent(InputEvent event) { if (current != null) { if (event instanceof MouseInputEvent) { int mid = Mouse.getEventButton(); if (mid == 1 && Mouse.getEventButtonState()) { current.handleClicking(Raytrace.traceLiving(player, 4, EntitySelectors.nothing)); } } else { if (Keyboard.getEventKeyState()) { if (current.handlesKeyInput()) current.handleKeyInput(Keyboard.getEventCharacter(), Keyboard.getEventKey()); } } } else { AcademyCraft.log.error("Human is dead. Mismatch."); this.setDead(); } return true; }
/** * Poll the state of the input * * @param width The width of the game view * @param height The height of the game view */ public void poll(int width, int height) { if (paused) { clearControlPressedRecord(); clearKeyPressedRecord(); clearMousePressedRecord(); while (Keyboard.next()) {} while (Mouse.next()) {} return; } if (!Display.isActive()) { clearControlPressedRecord(); clearKeyPressedRecord(); clearMousePressedRecord(); } // add any listeners requested since last time for (int i = 0; i < keyListenersToAdd.size(); i++) { addKeyListenerImpl((KeyListener) keyListenersToAdd.get(i)); } keyListenersToAdd.clear(); for (int i = 0; i < mouseListenersToAdd.size(); i++) { addMouseListenerImpl((MouseListener) mouseListenersToAdd.get(i)); } mouseListenersToAdd.clear(); if (doubleClickTimeout != 0) { if (System.currentTimeMillis() > doubleClickTimeout) { doubleClickTimeout = 0; } } this.height = height; Iterator allStarts = allListeners.iterator(); while (allStarts.hasNext()) { ControlledInputReciever listener = (ControlledInputReciever) allStarts.next(); listener.inputStarted(); } while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { int eventKey = resolveEventKey(Keyboard.getEventKey(), Keyboard.getEventCharacter()); keys[eventKey] = Keyboard.getEventCharacter(); pressed[eventKey] = true; nextRepeat[eventKey] = System.currentTimeMillis() + keyRepeatInitial; consumed = false; for (int i = 0; i < keyListeners.size(); i++) { KeyListener listener = (KeyListener) keyListeners.get(i); if (listener.isAcceptingInput()) { listener.keyPressed(eventKey, Keyboard.getEventCharacter()); if (consumed) { break; } } } } else { int eventKey = resolveEventKey(Keyboard.getEventKey(), Keyboard.getEventCharacter()); nextRepeat[eventKey] = 0; consumed = false; for (int i = 0; i < keyListeners.size(); i++) { KeyListener listener = (KeyListener) keyListeners.get(i); if (listener.isAcceptingInput()) { listener.keyReleased(eventKey, keys[eventKey]); if (consumed) { break; } } } } } while (Mouse.next()) { if (Mouse.getEventButton() >= 0 && Mouse.getEventButton() < mousePressed.length) { if (Mouse.getEventButtonState()) { consumed = false; mousePressed[Mouse.getEventButton()] = true; pressedX = (int) (xoffset + (Mouse.getEventX() * scaleX)); pressedY = (int) (yoffset + ((height - Mouse.getEventY()) * scaleY)); for (int i = 0; i < mouseListeners.size(); i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { listener.mousePressed(Mouse.getEventButton(), pressedX, pressedY); if (consumed) { break; } } } } else { consumed = false; mousePressed[Mouse.getEventButton()] = false; int releasedX = (int) (xoffset + (Mouse.getEventX() * scaleX)); int releasedY = (int) (yoffset + ((height - Mouse.getEventY()) * scaleY)); if ((pressedX != -1) && (pressedY != -1) && (Math.abs(pressedX - releasedX) < mouseClickTolerance) && (Math.abs(pressedY - releasedY) < mouseClickTolerance)) { considerDoubleClick(Mouse.getEventButton(), releasedX, releasedY); pressedX = pressedY = -1; } for (int i = 0; i < mouseListeners.size(); i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { listener.mouseReleased(Mouse.getEventButton(), releasedX, releasedY); if (consumed) { break; } } } } } else { if (Mouse.isGrabbed() && displayActive) { if ((Mouse.getEventDX() != 0) || (Mouse.getEventDY() != 0)) { consumed = false; for (int i = 0; i < mouseListeners.size(); i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { if (anyMouseDown()) { listener.mouseDragged(0, 0, Mouse.getEventDX(), -Mouse.getEventDY()); } else { listener.mouseMoved(0, 0, Mouse.getEventDX(), -Mouse.getEventDY()); } if (consumed) { break; } } } } } int dwheel = Mouse.getEventDWheel(); wheel += dwheel; if (dwheel != 0) { consumed = false; for (int i = 0; i < mouseListeners.size(); i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { listener.mouseWheelMoved(dwheel); if (consumed) { break; } } } } } } if (!displayActive || Mouse.isGrabbed()) { lastMouseX = getMouseX(); lastMouseY = getMouseY(); } else { if ((lastMouseX != getMouseX()) || (lastMouseY != getMouseY())) { consumed = false; for (int i = 0; i < mouseListeners.size(); i++) { MouseListener listener = (MouseListener) mouseListeners.get(i); if (listener.isAcceptingInput()) { if (anyMouseDown()) { listener.mouseDragged(lastMouseX, lastMouseY, getMouseX(), getMouseY()); } else { listener.mouseMoved(lastMouseX, lastMouseY, getMouseX(), getMouseY()); } if (consumed) { break; } } } lastMouseX = getMouseX(); lastMouseY = getMouseY(); } } if (controllersInited) { for (int i = 0; i < getControllerCount(); i++) { int count = ((Controller) controllers.get(i)).getButtonCount() + 3; count = Math.min(count, 24); for (int c = 0; c <= count; c++) { try { if (controls[i][c] && !isControlDwn(c, i)) { controls[i][c] = false; fireControlRelease(c, i); } else if (!controls[i][c] && isControlDwn(c, i)) { controllerPressed[i][c] = true; controls[i][c] = true; fireControlPress(c, i); } } catch (ArrayIndexOutOfBoundsException e) { break; } } } } if (keyRepeat) { for (int i = 0; i < 1024; i++) { if (pressed[i] && (nextRepeat[i] != 0)) { if (System.currentTimeMillis() > nextRepeat[i]) { nextRepeat[i] = System.currentTimeMillis() + keyRepeatInterval; consumed = false; for (int j = 0; j < keyListeners.size(); j++) { KeyListener listener = (KeyListener) keyListeners.get(j); if (listener.isAcceptingInput()) { listener.keyPressed(i, keys[i]); if (consumed) { break; } } } } } } } Iterator all = allListeners.iterator(); while (all.hasNext()) { ControlledInputReciever listener = (ControlledInputReciever) all.next(); listener.inputEnded(); } if (Display.isCreated()) { displayActive = Display.isActive(); } }
public char getEventCharacter() { return Keyboard.getEventCharacter(); }
public void handleInput() { // handle movement keys if (!editorMode) { if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { player.move(Player.LEFT); } else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { player.move(Player.RIGHT); } else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { player.move(Player.DOWN); } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { player.move(Player.UP); } } else { if (Keyboard.isKeyDown(Keyboard.KEY_LEFT)) { editorTag.getPosition().add(new Coord(-1f, 0f)); } else if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT)) { editorTag.getPosition().add(new Coord(1f, 0f)); } else if (Keyboard.isKeyDown(Keyboard.KEY_DOWN)) { editorTag.getPosition().add(new Coord(0f, -1f)); } else if (Keyboard.isKeyDown(Keyboard.KEY_UP)) { editorTag.getPosition().add(new Coord(0f, 1f)); } } // handle other keys while (Keyboard.next()) { char k = Keyboard.getEventCharacter(); // the ` key toggles the console if (k == '`') { if (console.isEnabled()) { console.disable(); } else { console.enable(); } } else if (console.isEnabled()) { if (Keyboard.getEventKeyState()) { console.nextChar(k); } } // editor specific commands if (editorMode && !console.isEnabled()) { if (k == ' ') { map.setTile(editorTag.getPosition(), currentEditorTile); } else if (k == 'n') { currentEditorTile = (currentEditorTile + 1) % map.getNumTypes(); } } } }
/** * Poll the state of the input * * @param width The width of the game view * @param height The height of the game view */ public void poll(int width, int height) { if (paused) { while (Keyboard.next()) {} while (Mouse.next()) {} return; } this.height = height; while (Keyboard.next()) { if (Keyboard.getEventKeyState()) { int eventKey = resolveEventKey(Keyboard.getEventKey(), Keyboard.getEventCharacter()); keys[eventKey] = Keyboard.getEventCharacter(); pressed[eventKey] = true; nextRepeat[eventKey] = System.currentTimeMillis() + keyRepeatInitial; consumed = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.keyPressed(eventKey, Keyboard.getEventCharacter()); if (consumed) { break; } } } } else { int eventKey = resolveEventKey(Keyboard.getEventKey(), Keyboard.getEventCharacter()); nextRepeat[eventKey] = 0; consumed = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.keyReleased(eventKey, keys[eventKey]); if (consumed) { break; } } } } } while (Mouse.next()) { if (Mouse.getEventButton() >= 0) { if (Mouse.getEventButtonState()) { consumed = false; mousePressed[Mouse.getEventButton()] = true; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.mousePressed( Mouse.getEventButton(), (int) (xoffset + (Mouse.getEventX() * scaleX)), (int) (yoffset + ((height - Mouse.getEventY()) * scaleY))); if (consumed) { break; } } } } else { consumed = false; mousePressed[Mouse.getEventButton()] = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.mouseReleased( Mouse.getEventButton(), (int) (xoffset + (Mouse.getEventX() * scaleX)), (int) (yoffset + ((height - Mouse.getEventY()) * scaleY))); if (consumed) { break; } } } } } else { if (Mouse.isGrabbed()) { if ((Mouse.getEventDX() != 0) || (Mouse.getEventDY() != 0)) { consumed = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.mouseMoved(0, 0, Mouse.getEventDX(), -Mouse.getEventDY()); if (consumed) { break; } } } } } int dwheel = Mouse.getEventDWheel(); wheel += dwheel; if (dwheel != 0) { consumed = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.mouseWheelMoved(dwheel); if (consumed) { break; } } } } } } if (!displayActive) { lastMouseX = getMouseX(); lastMouseY = getMouseY(); } else { if ((lastMouseX != getMouseX()) || (lastMouseY != getMouseY())) { consumed = false; for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); if (listener.isAcceptingInput()) { listener.mouseMoved(lastMouseX, lastMouseY, getMouseX(), getMouseY()); if (consumed) { break; } } } lastMouseX = getMouseX(); lastMouseY = getMouseY(); } } if (controllersInited) { for (int i = 0; i < getControllerCount(); i++) { int count = ((Controller) controllers.get(i)).getButtonCount() + 3; count = Math.min(count, 24); for (int c = 0; c <= count; c++) { if (controls[i][c] && !isControlDwn(c, i)) { controls[i][c] = false; fireControlRelease(c, i); } else if (!controls[i][c] && isControlDwn(c, i)) { controllerPressed[c] = true; controls[i][c] = true; fireControlPress(c, i); } } } } if (keyRepeat) { for (int i = 0; i < 1024; i++) { if (pressed[i] && (nextRepeat[i] != 0)) { if (System.currentTimeMillis() > nextRepeat[i]) { nextRepeat[i] = System.currentTimeMillis() + keyRepeatInterval; consumed = false; for (int j = 0; j < listeners.size(); j++) { InputListener listener = (InputListener) listeners.get(j); if (listener.isAcceptingInput()) { listener.keyPressed(i, keys[i]); if (consumed) { break; } } } } } } } for (int i = 0; i < listeners.size(); i++) { InputListener listener = (InputListener) listeners.get(i); listener.inputEnded(); } if (Display.isCreated()) { displayActive = Display.isActive(); } }
public void getInput() { if (gameStatus != -1) { float b = (float) (15f / Main.fps); switch (controlMode) { case 3: if (Keyboard.isKeyDown(Keyboard.KEY_DOWN) && !player.isBot) { if (player.y <= 100 * Main.ratio - player.amplitude * 2 - player.sy) player.playerYShift += b; } case 1: if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) && !player.isBot) { if (player.freak >= player.minFreak) player.freak -= freakChanger; } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && !player.isBot) { if (player.freak <= player.maxFreak) player.freak += freakChanger; } if (player2 != null) { if (Keyboard.isKeyDown(Keyboard.KEY_A) && !player2.isBot) { if (player2.freak >= player.minFreak) player2.freak -= freakChanger; } if (Keyboard.isKeyDown(Keyboard.KEY_D) && !player2.isBot) { if (player2.freak <= player.maxFreak) player2.freak += freakChanger; } } break; case 2: if (Keyboard.isKeyDown(Keyboard.KEY_SPACE) && !player.isBot) { if (player.freak <= player.maxFreak) player.freak += freakChanger; } if (Keyboard.isKeyDown(Keyboard.KEY_1)) { ListWorker.getList(); } if (Keyboard.isKeyDown(Keyboard.KEY_M)) { gameConfiguration.mute = true; if (Draw.musicIsPlaying(Music.FON1)) Draw.musicStop(Music.FON1); } if (Keyboard.isKeyDown(Keyboard.KEY_N)) { gameConfiguration.mute = false; if (!Draw.musicIsPlaying(Music.FON1)) Draw.musicPlay(Music.FON1); } if (Keyboard.isKeyDown(Keyboard.KEY_0)) { mouseGrabbed = true; } if (Keyboard.isKeyDown(Keyboard.KEY_9)) { mouseGrabbed = false; } if (Keyboard.isKeyDown(Keyboard.KEY_P)) { pause = true; } if (Keyboard.isKeyDown(Keyboard.KEY_O)) { pause = false; } if (player2 != null) { if (Keyboard.isKeyDown(Keyboard.KEY_Q) && !player2.isBot) { if (player2.freak <= player2.maxFreak) player2.freak += freakChanger; } } break; } if (Keyboard.isKeyDown(Keyboard.KEY_I)) { player.immortalityDie = 99999999; player.die = false; } if (Keyboard.isKeyDown(Keyboard.KEY_O)) { player.immortalityDie = 0; player.die = false; } /*if (Keyboard.isKeyDown(Keyboard.KEY_3)) { if (gameStatus == 9) restartGame = true; gameStatus = 3; changedGameStatus = true; return; } if (Keyboard.isKeyDown(Keyboard.KEY_1)) { if (gameStatus == 9) restartGame = true; gameStatus = 1; changedGameStatus = true; return; } if (Keyboard.isKeyDown(Keyboard.KEY_2)) { if (gameStatus == 9) restartGame = true; gameStatus = 2; changedGameStatus = true; return; } if (Keyboard.isKeyDown(Keyboard.KEY_0)) { if (gameStatus == 9) restartGame = true; gameStatus = 0; changedGameStatus = true; return; } if (Keyboard.isKeyDown(Keyboard.KEY_4)) { if (gameStatus == 9) restartGame = true; gameStatus = 4; changedGameStatus = true; return; } */ } lastKeyDownTime++; if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) { if (lastKeyDownTime > 10) { lastKeyDownTime = 0; changedGameStatus = true; if (gameStatus == 9) { restartGame = true; gameStatus = 0; changedGameStatus = true; } else { if (gameStatus == 2) { gameStatus = 1; } else { if (gameStatus == 1) { gameStatus = 2; } else { if (gameStatus == 0) { changedGameStatus = false; } else { gameStatus = 0; } } } } } } if (Mouse.isButtonDown(0)) { if (lastKeyDownTime > 10) { lastKeyDownTime = 0; switch (checkButtonIsOver()) { case 1: switch (gameStatus) { case (-1): gameStatus = 0; break; case 0: gameStatus = 2; changedGameStatus = true; Main.restartGame(); break; case 1: gameStatus = 2; changedGameStatus = true; break; case 3: if (pg > 1) { pg--; } // getPreviousTopList(); break; case 4: setMultiplayer(); break; case 9: saveScore(); gameStatus = 10; changedGameStatus = true; break; case 10: gameStatus = 2; Main.restartGame(); break; } break; case 2: switch (gameStatus) { case 0: gameStatus = 3; // TOP SCORES changedGameStatus = true; break; case 1: gameStatus = 2; Main.restartGame(); break; case 3: if (pg < maxPg) { pg++; } // getNextTopList(); break; case 4: setBot(); break; case 9: gameStatus = 10; break; case 10: gameStatus = 0; changedGameStatus = true; break; } changedGameStatus = true; break; case 3: switch (gameStatus) { case 0: gameStatus = 4; // Settings createNewConfiguration(); changedGameStatus = true; break; case 1: gameStatus = 0; changedGameStatus = true; break; case 3: gameStatus = 0; changedGameStatus = true; break; case 4: setAudio(); break; } break; case 4: switch (gameStatus) { case 0: exit(); break; case 4: // setPreviousMusicGenre(); break; } break; case 5: if (gameStatus == 4) // setNextMusicGenre(); break; case 6: if (gameStatus == 4) gameStatus = 0; changedGameStatus = true; if (changedSettings == true) { changedSettings = false; saveConfiguration(); gameConfigurationNew = null; } break; case 7: if (gameStatus == 4) gameStatus = 0; changedGameStatus = true; if (changedSettings == true) { changedSettings = false; gameConfigurationNew = null; } break; default: /* if (gameStatus == 9) { restartGame = true; gameStatus = 2; //changedGameStatus = true; }*/ break; } } } if ((gameStatus == -1) || (gameStatus == 9)) { while (Keyboard.next()) { // System.out.println(playerName); char x = Keyboard.getEventCharacter(); // if ((int)(x) == 42) { // continue; // } if ((int) (x) == 0) continue; if ((int) (x) == 32) continue; if ((int) (x) == 13) { gameStatus = 0; break; } if ((int) (x) == 8) { if (playerNamelenght > 0) { playerName.deleteCharAt(playerNamelenght - 1); playerNamelenght--; } continue; } // playerName = Keyboard.getKeyName(x); // playerNameChars[playerNamelenght] = Keyboard.get if (playerNamelenght < 15) { playerName.append(x); playerNamelenght++; } // System.out.println(playerName); } } }