@Override public void mouseReleased(MouseEvent e) { menu.clearPressed(); if (menu.getState() == State.MENU) { // menu navigation if (new Rectangle(820, 100, 350, 40).contains(e.getPoint())) { menu.setReleased(1); } else if (new Rectangle(820, 540, 350, 40).contains(e.getPoint())) { menu.setReleased(0); } else if (new Rectangle(950, 600, 200, 75).contains(e.getPoint())) { menu.startGame(); } else if (new Rectangle(700, 590, 125, 94).contains(e.getPoint())) { menu.setReleased(8); if (!menu.getMods()[0]) { menu.setHD(true); } else { menu.setHD(false); } } else if (new Rectangle(825, 590, 125, 94).contains(e.getPoint())) { menu.setReleased(9); if (!menu.getMods()[1]) { menu.setFL(true); } else { menu.setFL(false); } } else { for (int i = 0; i < menu.getSong().getNumOfDifficulties(); i++) { if (new Rectangle(300, 200 + 100 * i, 125, 94).contains(e.getPoint())) { menu.setDiff(i); break; } } } } else if (menu.getState() == State.PAUSE) { // pause navigation if (new Rectangle(550, 200, 125, 94).contains(e.getPoint())) { try { menu.getSong().playSong(); } catch (Exception exception) { } menu.setState(State.GAME); } else if (new Rectangle(550, 300, 125, 94).contains(e.getPoint())) { menu.setState(State.ENDSCREEN); } else if (new Rectangle(550, 400, 125, 94).contains(e.getPoint())) { handler.unpause(); handler.unpause(); handler.reset(); menu.setState(State.MENU); menu.reset(); } } else if (menu.getState() == State.ENDSCREEN) { // end screen navigation if (new Rectangle(1000, 550, 200, 100).contains(e.getPoint())) { handler.unpause(); handler.unpause(); handler.reset(); menu.setState(State.MENU); menu.reset(); } } }
private void paintMenu(Graphics2D g2d) { if (showMenu == true) { if (c.getPoints() > c.getHighscore().getLowestPointsInTable() && c.getLifes() == 0) { menu.setState(4); } menu.draw(g2d); } }
protected void visibleMouseEvent(MouseEvent e, Point tempPt) { if (isHidden()) return; boolean containsPoint = containsPoint(tempPt); if (containsPoint) mouseInside = true; if (!isEnabled()) return; if (menu == null) return; switch (e.getID()) { case MouseEvent.MOUSE_MOVED: if (containsPoint) { menu.setState(this, MenuItem.OVER); } else { menu.setState(this, MenuItem.UP); } break; case MouseEvent.MOUSE_PRESSED: if (containsPoint) { if (nearestMenu.actionOnMouseDown) performAction(); } // The switch statement continues on through the next case... case MouseEvent.MOUSE_DRAGGED: if (containsPoint) { menu.setState(this, MenuItem.DOWN); } else menu.setState(this, MenuItem.UP); break; case MouseEvent.MOUSE_RELEASED: if (containsPoint) { if (!nearestMenu.actionOnMouseDown) performAction(); // setState(MenuItem.OVER); if (getState() == MenuItem.DOWN) menu.setState(this, MenuItem.OVER); } else menu.setState(this, MenuItem.UP); default: break; } }