@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { UI.update(delta); MusicController.loopTrackIfEnded(false); if (menuState != null) menuState.update(container, delta, input.getMouseX(), input.getMouseY()); }
@Override public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { UI.update(delta); if (MusicController.trackEnded()) nextTrack(); // end of track: go to next track int mouseX = input.getMouseX(), mouseY = input.getMouseY(); logo.hoverUpdate(delta, mouseX, mouseY, 0.25f); playButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); optionsButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f); if (repoButton != null) repoButton.hoverUpdate(delta, mouseX, mouseY); updateButton.hoverUpdate(delta, mouseX, mouseY); downloadsButton.hoverUpdate(delta, mouseX, mouseY); // ensure only one button is in hover state at once boolean noHoverUpdate = musicPositionBarContains(mouseX, mouseY); boolean contains = musicPlay.contains(mouseX, mouseY); musicPlay.hoverUpdate(delta, !noHoverUpdate && contains); musicPause.hoverUpdate(delta, !noHoverUpdate && contains); noHoverUpdate |= contains; musicNext.hoverUpdate(delta, !noHoverUpdate && musicNext.contains(mouseX, mouseY)); musicPrevious.hoverUpdate(delta, !noHoverUpdate && musicPrevious.contains(mouseX, mouseY)); // window focus change: increase/decrease theme song volume if (MusicController.isThemePlaying() && MusicController.isTrackDimmed() == container.hasFocus()) MusicController.toggleTrackDimmed(0.33f); // fade in background if (bgAlpha < BG_MAX_ALPHA) { bgAlpha += delta / 1000f; if (bgAlpha > BG_MAX_ALPHA) bgAlpha = BG_MAX_ALPHA; } // buttons if (logoClicked) { if (logoTimer == 0) { // shifting to left if (logo.getX() > container.getWidth() / 3.3f) logo.setX(logo.getX() - delta); else logoTimer = 1; } else if (logoTimer >= MOVE_DELAY) // timer over: shift back to center logoClicked = false; else { // increment timer logoTimer += delta; if (logoTimer <= 500) { // fade in buttons playButton.getImage().setAlpha(logoTimer / 400f); optionsButton.getImage().setAlpha(logoTimer / 400f); exitButton.getImage().setAlpha(logoTimer / 400f); } } } else { // fade out buttons if (logoTimer > 0) { float alpha = playButton.getImage().getAlpha(); if (alpha > 0f) { playButton.getImage().setAlpha(alpha - (delta / 200f)); optionsButton.getImage().setAlpha(alpha - (delta / 200f)); exitButton.getImage().setAlpha(alpha - (delta / 200f)); } else logoTimer = 0; } // move back to original location if (logo.getX() < container.getWidth() / 2) { logo.setX(logo.getX() + (delta / 3f)); if (logo.getX() > container.getWidth() / 2) logo.setX(container.getWidth() / 2); } } // tooltips if (musicPositionBarContains(mouseX, mouseY)) UI.updateTooltip(delta, "Click to seek to a specific point in the song.", false); else if (musicPlay.contains(mouseX, mouseY)) UI.updateTooltip(delta, (MusicController.isPlaying()) ? "Pause" : "Play", false); else if (musicNext.contains(mouseX, mouseY)) UI.updateTooltip(delta, "Next track", false); else if (musicPrevious.contains(mouseX, mouseY)) UI.updateTooltip(delta, "Previous track", false); else if (Updater.get().showButton() && updateButton.contains(mouseX, mouseY)) UI.updateTooltip(delta, Updater.get().getStatus().getDescription(), true); }