2014-06-30 04:17:04 +02:00
|
|
|
/*
|
|
|
|
* opsu! - an open-source osu! client
|
|
|
|
* Copyright (C) 2014 Jeffrey Han
|
|
|
|
*
|
|
|
|
* opsu! is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* opsu! is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package itdelatrisu.opsu.states;
|
|
|
|
|
2015-01-08 05:45:21 +01:00
|
|
|
import itdelatrisu.opsu.GameImage;
|
2014-12-30 06:00:58 +01:00
|
|
|
import itdelatrisu.opsu.MenuButton;
|
2014-06-30 04:17:04 +02:00
|
|
|
import itdelatrisu.opsu.Opsu;
|
2014-07-02 09:02:11 +02:00
|
|
|
import itdelatrisu.opsu.OsuFile;
|
2015-01-11 20:17:33 +01:00
|
|
|
import itdelatrisu.opsu.OsuGroupList;
|
2014-06-30 04:17:04 +02:00
|
|
|
import itdelatrisu.opsu.OsuGroupNode;
|
2014-07-02 01:32:03 +02:00
|
|
|
import itdelatrisu.opsu.Utils;
|
2015-01-08 01:29:51 +01:00
|
|
|
import itdelatrisu.opsu.audio.MusicController;
|
|
|
|
import itdelatrisu.opsu.audio.SoundController;
|
|
|
|
import itdelatrisu.opsu.audio.SoundEffect;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Stack;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
import org.newdawn.slick.Color;
|
|
|
|
import org.newdawn.slick.GameContainer;
|
|
|
|
import org.newdawn.slick.Graphics;
|
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.Input;
|
|
|
|
import org.newdawn.slick.SlickException;
|
|
|
|
import org.newdawn.slick.state.BasicGameState;
|
|
|
|
import org.newdawn.slick.state.StateBasedGame;
|
|
|
|
import org.newdawn.slick.state.transition.FadeInTransition;
|
|
|
|
import org.newdawn.slick.state.transition.FadeOutTransition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Main Menu" state.
|
|
|
|
* <ul>
|
|
|
|
* <li>[Play] - move to song selection menu
|
|
|
|
* <li>[Exit] - move to confirm exit menu
|
|
|
|
* </ul>
|
|
|
|
*/
|
|
|
|
public class MainMenu extends BasicGameState {
|
|
|
|
/**
|
|
|
|
* Idle time, in milliseconds, before returning the logo to its original position.
|
|
|
|
*/
|
|
|
|
private static final short MOVE_DELAY = 5000;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Logo button that reveals other buttons on click.
|
|
|
|
*/
|
2014-12-30 06:00:58 +01:00
|
|
|
private MenuButton logo;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not the logo has been clicked.
|
|
|
|
*/
|
|
|
|
private boolean logoClicked = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delay timer, in milliseconds, before starting to move the logo back to the center.
|
|
|
|
*/
|
|
|
|
private int logoTimer = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main "Play" and "Exit" buttons.
|
|
|
|
*/
|
2014-12-30 06:00:58 +01:00
|
|
|
private MenuButton playButton, exitButton;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Music control buttons.
|
|
|
|
*/
|
2014-12-30 06:00:58 +01:00
|
|
|
private MenuButton musicPlay, musicPause, musicNext, musicPrevious;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Application start time, for drawing the total running time.
|
|
|
|
*/
|
|
|
|
private long osuStartTime;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indexes of previous songs.
|
|
|
|
*/
|
|
|
|
private static Stack<Integer> previous;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main menu background image (optional).
|
|
|
|
*/
|
|
|
|
private Image backgroundImage;
|
|
|
|
|
2014-07-02 09:02:11 +02:00
|
|
|
/**
|
2014-07-06 03:00:52 +02:00
|
|
|
* Background alpha level (for fade-in effect).
|
2014-07-02 09:02:11 +02:00
|
|
|
*/
|
2014-07-06 03:00:52 +02:00
|
|
|
private float bgAlpha = 0f;
|
2014-07-02 09:02:11 +02:00
|
|
|
|
2015-01-11 02:14:39 +01:00
|
|
|
/**
|
|
|
|
* Whether the theme song volume has been dimmed.
|
|
|
|
*/
|
|
|
|
private boolean volumeDimmed = false;
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// game-related variables
|
2014-12-21 23:02:11 +01:00
|
|
|
private GameContainer container;
|
2014-06-30 04:17:04 +02:00
|
|
|
private StateBasedGame game;
|
2014-12-24 05:41:37 +01:00
|
|
|
private Input input;
|
2014-06-30 04:17:04 +02:00
|
|
|
private int state;
|
|
|
|
|
|
|
|
public MainMenu(int state) {
|
|
|
|
this.state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
2014-12-21 23:02:11 +01:00
|
|
|
this.container = container;
|
2014-06-30 04:17:04 +02:00
|
|
|
this.game = game;
|
2014-12-24 05:41:37 +01:00
|
|
|
this.input = container.getInput();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
osuStartTime = System.currentTimeMillis();
|
|
|
|
previous = new Stack<Integer>();
|
|
|
|
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
// initialize buttons
|
2015-01-08 05:45:21 +01:00
|
|
|
// TODO: clean this up, scale in GameImage.process_sub()
|
2014-06-30 04:17:04 +02:00
|
|
|
Image logoImg = new Image("logo.png");
|
|
|
|
float buttonScale = (height / 1.2f) / logoImg.getHeight();
|
2015-01-08 05:45:21 +01:00
|
|
|
Image logoImgScaled = GameImage.MENU_LOGO.getImage();
|
2014-12-30 06:00:58 +01:00
|
|
|
logo = new MenuButton(logoImgScaled, width / 2f, height / 2f);
|
2014-12-24 05:41:37 +01:00
|
|
|
logo.setHoverScale(1.05f);
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2015-01-08 05:45:21 +01:00
|
|
|
Image playImg = GameImage.MENU_PlAY.getImage();
|
|
|
|
Image exitImg = GameImage.MENU_EXIT.getImage();
|
2014-06-30 04:17:04 +02:00
|
|
|
playImg = playImg.getScaledCopy((logoImg.getWidth() * 0.83f) / playImg.getWidth());
|
|
|
|
exitImg = exitImg.getScaledCopy((logoImg.getWidth() * 0.66f) / exitImg.getWidth());
|
|
|
|
float exitOffset = (playImg.getWidth() - exitImg.getWidth()) / 3f;
|
2014-12-30 06:00:58 +01:00
|
|
|
playButton = new MenuButton(playImg.getScaledCopy(buttonScale),
|
2014-06-30 04:17:04 +02:00
|
|
|
width * 0.75f, (height / 2) - (logoImgScaled.getHeight() / 5f)
|
|
|
|
);
|
2014-12-30 06:00:58 +01:00
|
|
|
exitButton = new MenuButton(exitImg.getScaledCopy(buttonScale),
|
2014-06-30 04:17:04 +02:00
|
|
|
width * 0.75f - exitOffset, (height / 2) + (exitImg.getHeight() / 2f)
|
|
|
|
);
|
2014-12-24 05:41:37 +01:00
|
|
|
playButton.setHoverScale(1.05f);
|
|
|
|
exitButton.setHoverScale(1.05f);
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
// initialize music buttons
|
|
|
|
int musicWidth = 48;
|
|
|
|
int musicHeight = 30;
|
2015-01-08 05:45:21 +01:00
|
|
|
musicPlay = new MenuButton(GameImage.MUSIC_PLAY.getImage(), width - (2 * musicWidth), musicHeight);
|
|
|
|
musicPause = new MenuButton(GameImage.MUSIC_PAUSE.getImage(), width - (2 * musicWidth), musicHeight);
|
|
|
|
musicNext = new MenuButton(GameImage.MUSIC_NEXT.getImage(), width - musicWidth, musicHeight);
|
|
|
|
musicPrevious = new MenuButton(GameImage.MUSIC_PREVIOUS.getImage(), width - (3 * musicWidth), musicHeight);
|
2014-12-24 05:41:37 +01:00
|
|
|
musicPlay.setHoverScale(1.5f);
|
|
|
|
musicPause.setHoverScale(1.5f);
|
|
|
|
musicNext.setHoverScale(1.5f);
|
|
|
|
musicPrevious.setHoverScale(1.5f);
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-12-30 06:41:32 +01:00
|
|
|
reset();
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// menu background
|
|
|
|
try {
|
|
|
|
backgroundImage = new Image("menu-background.jpg").getScaledCopy(width, height);
|
|
|
|
backgroundImage.setAlpha(0.9f);
|
|
|
|
} catch (Exception e) {
|
|
|
|
// optional
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
|
|
|
throws SlickException {
|
2014-07-02 09:02:11 +02:00
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
// draw background
|
|
|
|
OsuFile osu = MusicController.getOsuFile();
|
|
|
|
if (Options.isDynamicBackgroundEnabled() &&
|
2014-07-06 03:00:52 +02:00
|
|
|
osu != null && osu.drawBG(width, height, bgAlpha))
|
2014-07-02 09:02:11 +02:00
|
|
|
;
|
2014-07-06 03:00:52 +02:00
|
|
|
else if (backgroundImage != null) {
|
|
|
|
backgroundImage.setAlpha(bgAlpha);
|
2014-06-30 04:17:04 +02:00
|
|
|
backgroundImage.draw();
|
2014-07-06 03:00:52 +02:00
|
|
|
} else
|
2014-07-02 01:32:03 +02:00
|
|
|
g.setBackground(Utils.COLOR_BLUE_BACKGROUND);
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
// draw buttons
|
|
|
|
if (logoTimer > 0) {
|
|
|
|
playButton.draw();
|
|
|
|
exitButton.draw();
|
|
|
|
}
|
|
|
|
logo.draw();
|
|
|
|
|
|
|
|
// draw music buttons
|
|
|
|
if (MusicController.isPlaying())
|
|
|
|
musicPause.draw();
|
|
|
|
else
|
|
|
|
musicPlay.draw();
|
|
|
|
musicNext.draw();
|
|
|
|
musicPrevious.draw();
|
2014-07-02 01:32:03 +02:00
|
|
|
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
2014-06-30 04:17:04 +02:00
|
|
|
g.fillRoundRect(width - 168, 54, 148, 5, 4);
|
|
|
|
g.setColor(Color.white);
|
2014-07-19 03:33:07 +02:00
|
|
|
if (!MusicController.isTrackLoading() && osu != null)
|
2014-06-30 04:17:04 +02:00
|
|
|
g.fillRoundRect(width - 168, 54,
|
2014-07-18 03:16:15 +02:00
|
|
|
148f * MusicController.getPosition() / osu.endTime, 5, 4);
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
// draw text
|
2014-07-02 09:02:11 +02:00
|
|
|
g.setFont(Utils.FONT_MEDIUM);
|
2014-07-02 01:32:03 +02:00
|
|
|
int lineHeight = Utils.FONT_MEDIUM.getLineHeight();
|
2014-06-30 04:17:04 +02:00
|
|
|
g.drawString(String.format("Loaded %d songs and %d beatmaps.",
|
2015-01-11 20:17:33 +01:00
|
|
|
OsuGroupList.get().size(), OsuGroupList.get().getMapCount()), 25, 25);
|
2014-07-15 06:20:36 +02:00
|
|
|
if (MusicController.isTrackLoading())
|
2014-06-30 04:17:04 +02:00
|
|
|
g.drawString("Track loading...", 25, 25 + lineHeight);
|
|
|
|
else if (MusicController.trackExists()) {
|
|
|
|
g.drawString((MusicController.isPlaying()) ? "Now Playing:" : "Paused:", 25, 25 + lineHeight);
|
|
|
|
g.drawString(String.format("%s: %s",
|
|
|
|
MusicController.getArtistName(),
|
|
|
|
MusicController.getTrackName()),
|
|
|
|
50, 25 + (lineHeight * 2));
|
|
|
|
}
|
|
|
|
long time = System.currentTimeMillis() - osuStartTime;
|
|
|
|
g.drawString(String.format("opsu! has been running for %d minutes, %d seconds.",
|
|
|
|
TimeUnit.MILLISECONDS.toMinutes(time),
|
2014-07-09 19:36:42 +02:00
|
|
|
TimeUnit.MILLISECONDS.toSeconds(time) -
|
|
|
|
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))),
|
|
|
|
25, height - 25 - (lineHeight * 2));
|
2014-06-30 04:17:04 +02:00
|
|
|
g.drawString(String.format("The current time is %s.",
|
|
|
|
new SimpleDateFormat("h:mm a").format(new Date())),
|
|
|
|
25, height - 25 - lineHeight);
|
|
|
|
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.drawFPS();
|
|
|
|
Utils.drawCursor();
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
2014-07-02 16:14:15 +02:00
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
@Override
|
|
|
|
public void update(GameContainer container, StateBasedGame game, int delta)
|
|
|
|
throws SlickException {
|
2014-07-07 05:13:33 +02:00
|
|
|
Utils.updateCursor(delta);
|
2014-12-24 05:41:37 +01:00
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
|
|
|
logo.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
playButton.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
exitButton.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
musicPlay.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
musicPause.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
musicNext.hoverUpdate(delta, mouseX, mouseY);
|
|
|
|
musicPrevious.hoverUpdate(delta, mouseX, mouseY);
|
2014-07-07 05:13:33 +02:00
|
|
|
|
2015-01-11 02:14:39 +01:00
|
|
|
// window focus change: increase/decrease theme song volume
|
|
|
|
if (MusicController.isThemePlaying()) {
|
|
|
|
boolean hasFocus = container.hasFocus();
|
|
|
|
if (volumeDimmed == hasFocus) {
|
|
|
|
if (hasFocus) // restored focus
|
|
|
|
MusicController.setVolume(Options.getMusicVolume());
|
|
|
|
else // lost focus
|
|
|
|
MusicController.setVolume(Options.getMusicVolume() / 3f);
|
|
|
|
volumeDimmed = !hasFocus;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-06 03:00:52 +02:00
|
|
|
// fade in background
|
|
|
|
if (bgAlpha < 0.9f) {
|
|
|
|
bgAlpha += delta / 1000f;
|
|
|
|
if (bgAlpha > 0.9f)
|
|
|
|
bgAlpha = 0.9f;
|
2014-07-02 09:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// buttons
|
2014-06-30 04:17:04 +02:00
|
|
|
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);
|
|
|
|
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));
|
|
|
|
exitButton.getImage().setAlpha(alpha - (delta / 200f));
|
|
|
|
} else
|
|
|
|
logoTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// move back to original location
|
|
|
|
if (logo.getX() < container.getWidth() / 2) {
|
2014-07-15 19:21:37 +02:00
|
|
|
logo.setX(logo.getX() + (delta / 3f));
|
2014-06-30 04:17:04 +02:00
|
|
|
if (logo.getX() > container.getWidth() / 2)
|
|
|
|
logo.setX(container.getWidth() / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getID() { return state; }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void enter(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
2014-12-30 06:41:32 +01:00
|
|
|
// reset button hover states if mouse is not currently hovering over the button
|
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
|
|
|
if (!logo.contains(mouseX, mouseY))
|
|
|
|
logo.setScale(1f);
|
|
|
|
if (!playButton.contains(mouseX, mouseY))
|
|
|
|
playButton.setScale(1f);
|
|
|
|
if (!exitButton.contains(mouseX, mouseY))
|
|
|
|
exitButton.setScale(1f);
|
|
|
|
if (!musicPlay.contains(mouseX, mouseY))
|
|
|
|
musicPlay.setScale(1f);
|
|
|
|
if (!musicPause.contains(mouseX, mouseY))
|
|
|
|
musicPause.setScale(1f);
|
|
|
|
if (!musicNext.contains(mouseX, mouseY))
|
|
|
|
musicNext.setScale(1f);
|
|
|
|
if (!musicPrevious.contains(mouseX, mouseY))
|
|
|
|
musicPrevious.setScale(1f);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mousePressed(int button, int x, int y) {
|
|
|
|
// check mouse button
|
|
|
|
if (button != Input.MOUSE_LEFT_BUTTON)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// music button actions
|
|
|
|
if (musicPlay.contains(x, y)) {
|
|
|
|
if (MusicController.isPlaying())
|
|
|
|
MusicController.pause();
|
2014-07-15 06:20:36 +02:00
|
|
|
else if (!MusicController.isTrackLoading())
|
2014-06-30 04:17:04 +02:00
|
|
|
MusicController.resume();
|
|
|
|
} else if (musicNext.contains(x, y)) {
|
2014-12-21 00:17:04 +01:00
|
|
|
boolean isTheme = MusicController.isThemePlaying();
|
2014-06-30 04:17:04 +02:00
|
|
|
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
2015-01-11 20:17:33 +01:00
|
|
|
OsuGroupNode node = menu.setFocus(OsuGroupList.get().getRandomNode(), -1, true);
|
2014-12-24 06:25:26 +01:00
|
|
|
boolean sameAudio = false;
|
|
|
|
if (node != null) {
|
|
|
|
sameAudio = MusicController.getOsuFile().audioFilename.equals(node.osuFiles.get(0).audioFilename);
|
|
|
|
if (!isTheme && !sameAudio)
|
|
|
|
previous.add(node.index);
|
|
|
|
}
|
|
|
|
if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
|
2014-07-06 03:00:52 +02:00
|
|
|
bgAlpha = 0f;
|
2014-06-30 04:17:04 +02:00
|
|
|
} else if (musicPrevious.contains(x, y)) {
|
|
|
|
if (!previous.isEmpty()) {
|
|
|
|
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
2015-01-11 20:17:33 +01:00
|
|
|
menu.setFocus(OsuGroupList.get().getBaseNode(previous.pop()), -1, true);
|
2014-07-06 03:00:52 +02:00
|
|
|
if (Options.isDynamicBackgroundEnabled())
|
|
|
|
bgAlpha = 0f;
|
2014-06-30 04:17:04 +02:00
|
|
|
} else
|
|
|
|
MusicController.setPosition(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// start moving logo (if clicked)
|
|
|
|
else if (!logoClicked) {
|
|
|
|
if (logo.contains(x, y)) {
|
|
|
|
logoClicked = true;
|
|
|
|
logoTimer = 0;
|
|
|
|
playButton.getImage().setAlpha(0f);
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
2015-01-08 01:29:51 +01:00
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// other button actions (if visible)
|
|
|
|
else if (logoClicked) {
|
2014-07-13 17:53:56 +02:00
|
|
|
if (logo.contains(x, y) || playButton.contains(x, y)) {
|
2015-01-08 01:29:51 +01:00
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
2014-06-30 04:17:04 +02:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
2014-07-01 07:14:03 +02:00
|
|
|
} else if (exitButton.contains(x, y)) {
|
2014-12-21 23:02:11 +01:00
|
|
|
Options.saveOptions();
|
|
|
|
Opsu.closeSocket();
|
|
|
|
container.exit();
|
2014-07-01 07:14:03 +02:00
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void keyPressed(int key, char c) {
|
|
|
|
switch (key) {
|
|
|
|
case Input.KEY_ESCAPE:
|
2014-07-05 20:29:48 +02:00
|
|
|
case Input.KEY_Q:
|
|
|
|
game.enterState(Opsu.STATE_MAINMENUEXIT);
|
|
|
|
break;
|
|
|
|
case Input.KEY_P:
|
|
|
|
if (!logoClicked) {
|
|
|
|
logoClicked = true;
|
|
|
|
logoTimer = 0;
|
|
|
|
playButton.getImage().setAlpha(0f);
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
2015-01-08 01:29:51 +01:00
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
2014-07-05 20:29:48 +02:00
|
|
|
} else {
|
2015-01-08 01:29:51 +01:00
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
2014-07-05 20:29:48 +02:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
|
|
|
}
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
case Input.KEY_F12:
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.takeScreenShot();
|
2014-06-30 04:17:04 +02:00
|
|
|
break;
|
|
|
|
}
|
2014-12-30 06:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the button states.
|
|
|
|
*/
|
|
|
|
public void reset() {
|
|
|
|
// reset logo
|
|
|
|
logo.setX(container.getWidth() / 2);
|
|
|
|
logoClicked = false;
|
|
|
|
logoTimer = 0;
|
|
|
|
|
|
|
|
logo.setScale(1f);
|
|
|
|
playButton.setScale(1f);
|
|
|
|
exitButton.setScale(1f);
|
|
|
|
musicPlay.setScale(1f);
|
|
|
|
musicPause.setScale(1f);
|
|
|
|
musicNext.setScale(1f);
|
|
|
|
musicPrevious.setScale(1f);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|