|
|
@ -29,7 +29,6 @@ import itdelatrisu.opsu.audio.SoundEffect;
|
|
|
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
|
|
|
import itdelatrisu.opsu.beatmap.Beatmap;
|
|
|
|
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
|
|
|
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
|
|
|
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
|
|
|
import itdelatrisu.opsu.beatmap.BeatmapSetNode;
|
|
|
|
import itdelatrisu.opsu.beatmap.TimingPoint;
|
|
|
|
|
|
|
|
import itdelatrisu.opsu.downloads.Updater;
|
|
|
|
import itdelatrisu.opsu.downloads.Updater;
|
|
|
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
|
|
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
|
|
|
import itdelatrisu.opsu.ui.*;
|
|
|
|
import itdelatrisu.opsu.ui.*;
|
|
|
@ -43,23 +42,26 @@ import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Stack;
|
|
|
|
import java.util.Stack;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.Display;
|
|
|
|
import org.newdawn.slick.Color;
|
|
|
|
import org.newdawn.slick.Color;
|
|
|
|
import org.newdawn.slick.GameContainer;
|
|
|
|
|
|
|
|
import org.newdawn.slick.Graphics;
|
|
|
|
import org.newdawn.slick.Graphics;
|
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.Input;
|
|
|
|
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.EasedFadeOutTransition;
|
|
|
|
import org.newdawn.slick.state.transition.EasedFadeOutTransition;
|
|
|
|
import org.newdawn.slick.state.transition.FadeInTransition;
|
|
|
|
import org.newdawn.slick.state.transition.FadeInTransition;
|
|
|
|
|
|
|
|
import yugecin.opsudance.core.DisplayContainer;
|
|
|
|
|
|
|
|
import yugecin.opsudance.core.inject.InstanceContainer;
|
|
|
|
|
|
|
|
import yugecin.opsudance.core.state.BaseOpsuState;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* "Main Menu" state.
|
|
|
|
* "Main Menu" state.
|
|
|
|
* <p>
|
|
|
|
* <p>
|
|
|
|
* Players are able to enter the song menu or downloads menu from this state.
|
|
|
|
* Players are able to enter the song menu or downloads menu from this state.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class MainMenu extends BasicGameState {
|
|
|
|
public class MainMenu extends BaseOpsuState {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final InstanceContainer instanceContainer;
|
|
|
|
|
|
|
|
|
|
|
|
/** Idle time, in milliseconds, before returning the logo to its original position. */
|
|
|
|
/** Idle time, in milliseconds, before returning the logo to its original position. */
|
|
|
|
private static final short LOGO_IDLE_DELAY = 10000;
|
|
|
|
private static final short LOGO_IDLE_DELAY = 10000;
|
|
|
|
|
|
|
|
|
|
|
@ -123,40 +125,27 @@ public class MainMenu extends BasicGameState {
|
|
|
|
/** The star fountain. */
|
|
|
|
/** The star fountain. */
|
|
|
|
private StarFountain starFountain;
|
|
|
|
private StarFountain starFountain;
|
|
|
|
|
|
|
|
|
|
|
|
// game-related variables
|
|
|
|
public MainMenu(DisplayContainer displayContainer, InstanceContainer instanceContainer) {
|
|
|
|
private GameContainer container;
|
|
|
|
super(displayContainer);
|
|
|
|
private StateBasedGame game;
|
|
|
|
this.instanceContainer = instanceContainer;
|
|
|
|
private Input input;
|
|
|
|
|
|
|
|
private final int state;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MainMenu(int state) {
|
|
|
|
|
|
|
|
this.state = state;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void init(GameContainer container, StateBasedGame game)
|
|
|
|
protected void revalidate() {
|
|
|
|
throws SlickException {
|
|
|
|
|
|
|
|
this.container = container;
|
|
|
|
|
|
|
|
this.game = game;
|
|
|
|
|
|
|
|
this.input = container.getInput();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
programStartTime = System.currentTimeMillis();
|
|
|
|
programStartTime = System.currentTimeMillis();
|
|
|
|
previous = new Stack<Integer>();
|
|
|
|
previous = new Stack<>();
|
|
|
|
|
|
|
|
|
|
|
|
int width = container.getWidth();
|
|
|
|
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// initialize menu buttons
|
|
|
|
// initialize menu buttons
|
|
|
|
Image logoImg = GameImage.MENU_LOGO.getImage();
|
|
|
|
Image logoImg = GameImage.MENU_LOGO.getImage();
|
|
|
|
Image playImg = GameImage.MENU_PLAY.getImage();
|
|
|
|
Image playImg = GameImage.MENU_PLAY.getImage();
|
|
|
|
Image exitImg = GameImage.MENU_EXIT.getImage();
|
|
|
|
Image exitImg = GameImage.MENU_EXIT.getImage();
|
|
|
|
float exitOffset = (playImg.getWidth() - exitImg.getWidth()) / 3f;
|
|
|
|
float exitOffset = (playImg.getWidth() - exitImg.getWidth()) / 3f;
|
|
|
|
logo = new MenuButton(logoImg, width / 2f, height / 2f);
|
|
|
|
logo = new MenuButton(logoImg, displayContainer.width / 2f, displayContainer.height / 2f);
|
|
|
|
playButton = new MenuButton(playImg,
|
|
|
|
playButton = new MenuButton(playImg,
|
|
|
|
width * 0.75f, (height / 2) - (logoImg.getHeight() / 5f)
|
|
|
|
displayContainer.width * 0.75f, (displayContainer.height / 2) - (logoImg.getHeight() / 5f)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
exitButton = new MenuButton(exitImg,
|
|
|
|
exitButton = new MenuButton(exitImg,
|
|
|
|
width * 0.75f - exitOffset, (height / 2) + (exitImg.getHeight() / 2f)
|
|
|
|
displayContainer.width * 0.75f - exitOffset, (displayContainer.height / 2) + (exitImg.getHeight() / 2f)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
final int logoAnimationDuration = 350;
|
|
|
|
final int logoAnimationDuration = 350;
|
|
|
|
logo.setHoverAnimationDuration(logoAnimationDuration);
|
|
|
|
logo.setHoverAnimationDuration(logoAnimationDuration);
|
|
|
@ -174,30 +163,30 @@ public class MainMenu extends BasicGameState {
|
|
|
|
// initialize music buttons
|
|
|
|
// initialize music buttons
|
|
|
|
int musicWidth = GameImage.MUSIC_PLAY.getImage().getWidth();
|
|
|
|
int musicWidth = GameImage.MUSIC_PLAY.getImage().getWidth();
|
|
|
|
int musicHeight = GameImage.MUSIC_PLAY.getImage().getHeight();
|
|
|
|
int musicHeight = GameImage.MUSIC_PLAY.getImage().getHeight();
|
|
|
|
musicPlay = new MenuButton(GameImage.MUSIC_PLAY.getImage(), width - (2 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicPlay = new MenuButton(GameImage.MUSIC_PLAY.getImage(), displayContainer.width - (2 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicPause = new MenuButton(GameImage.MUSIC_PAUSE.getImage(), width - (2 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicPause = new MenuButton(GameImage.MUSIC_PAUSE.getImage(), displayContainer.width - (2 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicNext = new MenuButton(GameImage.MUSIC_NEXT.getImage(), width - musicWidth, musicHeight / 1.5f);
|
|
|
|
musicNext = new MenuButton(GameImage.MUSIC_NEXT.getImage(), displayContainer.width - musicWidth, musicHeight / 1.5f);
|
|
|
|
musicPrevious = new MenuButton(GameImage.MUSIC_PREVIOUS.getImage(), width - (3 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicPrevious = new MenuButton(GameImage.MUSIC_PREVIOUS.getImage(), displayContainer.width - (3 * musicWidth), musicHeight / 1.5f);
|
|
|
|
musicPlay.setHoverExpand(1.5f);
|
|
|
|
musicPlay.setHoverExpand(1.5f);
|
|
|
|
musicPause.setHoverExpand(1.5f);
|
|
|
|
musicPause.setHoverExpand(1.5f);
|
|
|
|
musicNext.setHoverExpand(1.5f);
|
|
|
|
musicNext.setHoverExpand(1.5f);
|
|
|
|
musicPrevious.setHoverExpand(1.5f);
|
|
|
|
musicPrevious.setHoverExpand(1.5f);
|
|
|
|
|
|
|
|
|
|
|
|
// initialize music position bar location
|
|
|
|
// initialize music position bar location
|
|
|
|
musicBarX = width - musicWidth * 3.5f;
|
|
|
|
musicBarX = displayContainer.width - musicWidth * 3.5f;
|
|
|
|
musicBarY = musicHeight * 1.25f;
|
|
|
|
musicBarY = musicHeight * 1.25f;
|
|
|
|
musicBarWidth = musicWidth * 3f;
|
|
|
|
musicBarWidth = musicWidth * 3f;
|
|
|
|
musicBarHeight = musicHeight * 0.11f;
|
|
|
|
musicBarHeight = musicHeight * 0.11f;
|
|
|
|
|
|
|
|
|
|
|
|
// initialize downloads button
|
|
|
|
// initialize downloads button
|
|
|
|
Image dlImg = GameImage.DOWNLOADS.getImage();
|
|
|
|
Image dlImg = GameImage.DOWNLOADS.getImage();
|
|
|
|
downloadsButton = new MenuButton(dlImg, width - dlImg.getWidth() / 2f, height / 2f);
|
|
|
|
downloadsButton = new MenuButton(dlImg, displayContainer.width - dlImg.getWidth() / 2f, displayContainer.height / 2f);
|
|
|
|
downloadsButton.setHoverAnimationDuration(350);
|
|
|
|
downloadsButton.setHoverAnimationDuration(350);
|
|
|
|
downloadsButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
|
|
|
downloadsButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
|
|
|
downloadsButton.setHoverExpand(1.03f, Expand.LEFT);
|
|
|
|
downloadsButton.setHoverExpand(1.03f, Expand.LEFT);
|
|
|
|
|
|
|
|
|
|
|
|
// initialize repository button
|
|
|
|
// initialize repository button
|
|
|
|
float startX = width * 0.997f, startY = height * 0.997f;
|
|
|
|
float startX = displayContainer.width * 0.997f, startY = displayContainer.height * 0.997f;
|
|
|
|
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { // only if a webpage can be opened
|
|
|
|
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { // only if a webpage can be opened
|
|
|
|
Image repoImg;
|
|
|
|
Image repoImg;
|
|
|
|
repoImg = GameImage.REPOSITORY.getImage();
|
|
|
|
repoImg = GameImage.REPOSITORY.getImage();
|
|
|
@ -217,7 +206,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// initialize update buttons
|
|
|
|
// initialize update buttons
|
|
|
|
float updateX = width / 2f, updateY = height * 17 / 18f;
|
|
|
|
float updateX = displayContainer.width / 2f, updateY = displayContainer.height * 17 / 18f;
|
|
|
|
Image downloadImg = GameImage.DOWNLOAD.getImage();
|
|
|
|
Image downloadImg = GameImage.DOWNLOAD.getImage();
|
|
|
|
updateButton = new MenuButton(downloadImg, updateX, updateY);
|
|
|
|
updateButton = new MenuButton(downloadImg, updateX, updateY);
|
|
|
|
updateButton.setHoverAnimationDuration(400);
|
|
|
|
updateButton.setHoverAnimationDuration(400);
|
|
|
@ -230,10 +219,10 @@ public class MainMenu extends BasicGameState {
|
|
|
|
restartButton.setHoverRotate(360);
|
|
|
|
restartButton.setHoverRotate(360);
|
|
|
|
|
|
|
|
|
|
|
|
// initialize star fountain
|
|
|
|
// initialize star fountain
|
|
|
|
starFountain = new StarFountain(width, height);
|
|
|
|
starFountain = new StarFountain(displayContainer.width, displayContainer.height);
|
|
|
|
|
|
|
|
|
|
|
|
// logo animations
|
|
|
|
// logo animations
|
|
|
|
float centerOffsetX = width / 6.5f;
|
|
|
|
float centerOffsetX = displayContainer.width / 6.5f;
|
|
|
|
logoOpen = new AnimatedValue(100, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
|
|
|
logoOpen = new AnimatedValue(100, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
|
|
|
logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD);
|
|
|
|
logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD);
|
|
|
|
logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
|
|
|
logoButtonAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
|
|
@ -242,10 +231,9 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
|
|
|
public void render(Graphics g) {
|
|
|
|
throws SlickException {
|
|
|
|
int width = displayContainer.width;
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = displayContainer.height;
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// draw background
|
|
|
|
// draw background
|
|
|
|
Beatmap beatmap = MusicController.getBeatmap();
|
|
|
|
Beatmap beatmap = MusicController.getBeatmap();
|
|
|
@ -305,7 +293,8 @@ public class MainMenu extends BasicGameState {
|
|
|
|
musicPrevious.draw();
|
|
|
|
musicPrevious.draw();
|
|
|
|
|
|
|
|
|
|
|
|
// draw music position bar
|
|
|
|
// draw music position bar
|
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
|
|
|
int mouseX = displayContainer.mouseX;
|
|
|
|
|
|
|
|
int mouseY = displayContainer.mouseY;
|
|
|
|
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL);
|
|
|
|
g.setColor((musicPositionBarContains(mouseX, mouseY)) ? Colors.BLACK_BG_HOVER : Colors.BLACK_BG_NORMAL);
|
|
|
|
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
|
|
|
|
g.fillRoundRect(musicBarX, musicBarY, musicBarWidth, musicBarHeight, 4);
|
|
|
|
g.setColor(Color.white);
|
|
|
|
g.setColor(Color.white);
|
|
|
@ -366,12 +355,14 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void update(GameContainer container, StateBasedGame game, int delta)
|
|
|
|
public void preRenderUpdate() {
|
|
|
|
throws SlickException {
|
|
|
|
int delta = displayContainer.renderDelta;
|
|
|
|
|
|
|
|
|
|
|
|
UI.update(delta);
|
|
|
|
UI.update(delta);
|
|
|
|
if (MusicController.trackEnded())
|
|
|
|
if (MusicController.trackEnded())
|
|
|
|
nextTrack(false); // end of track: go to next track
|
|
|
|
nextTrack(false); // end of track: go to next track
|
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
|
|
|
int mouseX = displayContainer.mouseX;
|
|
|
|
|
|
|
|
int mouseY = displayContainer.mouseY;
|
|
|
|
logo.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
|
logo.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
|
playButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
|
playButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
|
exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
|
exitButton.hoverUpdate(delta, mouseX, mouseY, 0.25f);
|
|
|
@ -396,7 +387,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
|
|
|
|
|
|
|
|
// window focus change: increase/decrease theme song volume
|
|
|
|
// window focus change: increase/decrease theme song volume
|
|
|
|
if (MusicController.isThemePlaying() &&
|
|
|
|
if (MusicController.isThemePlaying() &&
|
|
|
|
MusicController.isTrackDimmed() == container.hasFocus())
|
|
|
|
MusicController.isTrackDimmed() == Display.isActive())
|
|
|
|
MusicController.toggleTrackDimmed(0.33f);
|
|
|
|
MusicController.toggleTrackDimmed(0.33f);
|
|
|
|
|
|
|
|
|
|
|
|
// fade in background
|
|
|
|
// fade in background
|
|
|
@ -413,7 +404,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// buttons
|
|
|
|
// buttons
|
|
|
|
int centerX = container.getWidth() / 2;
|
|
|
|
int centerX = displayContainer.width / 2;
|
|
|
|
float currentLogoButtonAlpha;
|
|
|
|
float currentLogoButtonAlpha;
|
|
|
|
switch (logoState) {
|
|
|
|
switch (logoState) {
|
|
|
|
case DEFAULT:
|
|
|
|
case DEFAULT:
|
|
|
@ -468,11 +459,8 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getID() { return state; }
|
|
|
|
public void enter() {
|
|
|
|
|
|
|
|
super.enter();
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void enter(GameContainer container, StateBasedGame game)
|
|
|
|
|
|
|
|
throws SlickException {
|
|
|
|
|
|
|
|
UI.enter();
|
|
|
|
UI.enter();
|
|
|
|
if (!enterNotification) {
|
|
|
|
if (!enterNotification) {
|
|
|
|
if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) {
|
|
|
|
if (Updater.get().getStatus() == Updater.Status.UPDATE_AVAILABLE) {
|
|
|
@ -489,7 +477,8 @@ public class MainMenu extends BasicGameState {
|
|
|
|
starFountain.clear();
|
|
|
|
starFountain.clear();
|
|
|
|
|
|
|
|
|
|
|
|
// reset button hover states if mouse is not currently hovering over the button
|
|
|
|
// reset button hover states if mouse is not currently hovering over the button
|
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
|
|
|
int mouseX = displayContainer.mouseX;
|
|
|
|
|
|
|
|
int mouseY = displayContainer.mouseY;
|
|
|
|
if (!logo.contains(mouseX, mouseY, 0.25f))
|
|
|
|
if (!logo.contains(mouseX, mouseY, 0.25f))
|
|
|
|
logo.resetHover();
|
|
|
|
logo.resetHover();
|
|
|
|
if (!playButton.contains(mouseX, mouseY, 0.25f))
|
|
|
|
if (!playButton.contains(mouseX, mouseY, 0.25f))
|
|
|
@ -515,17 +504,17 @@ public class MainMenu extends BasicGameState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void leave(GameContainer container, StateBasedGame game)
|
|
|
|
public void leave() {
|
|
|
|
throws SlickException {
|
|
|
|
super.leave();
|
|
|
|
if (MusicController.isTrackDimmed())
|
|
|
|
if (MusicController.isTrackDimmed())
|
|
|
|
MusicController.toggleTrackDimmed(1f);
|
|
|
|
MusicController.toggleTrackDimmed(1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void mousePressed(int button, int x, int y) {
|
|
|
|
public boolean mousePressed(int button, int x, int y) {
|
|
|
|
// check mouse button
|
|
|
|
// check mouse button
|
|
|
|
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
|
|
|
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
|
|
|
return;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// music position bar
|
|
|
|
// music position bar
|
|
|
|
if (MusicController.isPlaying()) {
|
|
|
|
if (MusicController.isPlaying()) {
|
|
|
@ -533,7 +522,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
lastMeasureProgress = 0f;
|
|
|
|
lastMeasureProgress = 0f;
|
|
|
|
float pos = (x - musicBarX) / musicBarWidth;
|
|
|
|
float pos = (x - musicBarX) / musicBarWidth;
|
|
|
|
MusicController.setPosition((int) (pos * MusicController.getDuration()));
|
|
|
|
MusicController.setPosition((int) (pos * MusicController.getDuration()));
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -546,29 +535,29 @@ public class MainMenu extends BasicGameState {
|
|
|
|
MusicController.resume();
|
|
|
|
MusicController.resume();
|
|
|
|
UI.sendBarNotification("Play");
|
|
|
|
UI.sendBarNotification("Play");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
} else if (musicNext.contains(x, y)) {
|
|
|
|
} else if (musicNext.contains(x, y)) {
|
|
|
|
nextTrack(true);
|
|
|
|
nextTrack(true);
|
|
|
|
UI.sendBarNotification(">> Next");
|
|
|
|
UI.sendBarNotification(">> Next");
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
} else if (musicPrevious.contains(x, y)) {
|
|
|
|
} else if (musicPrevious.contains(x, y)) {
|
|
|
|
lastMeasureProgress = 0f;
|
|
|
|
lastMeasureProgress = 0f;
|
|
|
|
if (!previous.isEmpty()) {
|
|
|
|
if (!previous.isEmpty()) {
|
|
|
|
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
|
|
|
instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
|
|
|
|
menu.setFocus(BeatmapSetList.get().getBaseNode(previous.pop()), -1, true, false);
|
|
|
|
|
|
|
|
if (Options.isDynamicBackgroundEnabled())
|
|
|
|
if (Options.isDynamicBackgroundEnabled())
|
|
|
|
bgAlpha.setTime(0);
|
|
|
|
bgAlpha.setTime(0);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
MusicController.setPosition(0);
|
|
|
|
MusicController.setPosition(0);
|
|
|
|
UI.sendBarNotification("<< Previous");
|
|
|
|
UI.sendBarNotification("<< Previous");
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// downloads button actions
|
|
|
|
// downloads button actions
|
|
|
|
if (downloadsButton.contains(x, y)) {
|
|
|
|
if (downloadsButton.contains(x, y)) {
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
// TODO //displayContainer.switchState(DownloadsMenu.class);
|
|
|
|
return;
|
|
|
|
//game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// repository button actions
|
|
|
|
// repository button actions
|
|
|
@ -580,7 +569,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
|
|
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (danceRepoButton != null && danceRepoButton.contains(x, y)) {
|
|
|
|
if (danceRepoButton != null && danceRepoButton.contains(x, y)) {
|
|
|
@ -591,7 +580,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
|
|
|
ErrorHandler.error("Could not browse to repository URI.", e, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// update button actions
|
|
|
|
// update button actions
|
|
|
@ -604,13 +593,14 @@ public class MainMenu extends BasicGameState {
|
|
|
|
updateButton.setHoverAnimationDuration(800);
|
|
|
|
updateButton.setHoverAnimationDuration(800);
|
|
|
|
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
|
|
|
|
updateButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_QUAD);
|
|
|
|
updateButton.setHoverFade(0.6f);
|
|
|
|
updateButton.setHoverFade(0.6f);
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
} else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) {
|
|
|
|
} else if (restartButton.contains(x, y) && status == Updater.Status.UPDATE_DOWNLOADED) {
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
Updater.get().prepareUpdate();
|
|
|
|
Updater.get().prepareUpdate();
|
|
|
|
container.setForceExit(false);
|
|
|
|
// TODO: exit?
|
|
|
|
container.exit();
|
|
|
|
//container.setForceExit(false);
|
|
|
|
return;
|
|
|
|
//container.exit();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -623,7 +613,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
playButton.getImage().setAlpha(0f);
|
|
|
|
playButton.getImage().setAlpha(0f);
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -632,21 +622,24 @@ public class MainMenu extends BasicGameState {
|
|
|
|
if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) {
|
|
|
|
if (logo.contains(x, y, 0.25f) || playButton.contains(x, y, 0.25f)) {
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
enterSongMenu();
|
|
|
|
enterSongMenu();
|
|
|
|
return;
|
|
|
|
return true;
|
|
|
|
} else if (exitButton.contains(x, y, 0.25f)) {
|
|
|
|
} else if (exitButton.contains(x, y, 0.25f)) {
|
|
|
|
container.exit();
|
|
|
|
// TODO exit?
|
|
|
|
return;
|
|
|
|
//container.exit();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void mouseWheelMoved(int newValue) {
|
|
|
|
public boolean mouseWheelMoved(int newValue) {
|
|
|
|
UI.changeVolume((newValue < 0) ? -1 : 1);
|
|
|
|
UI.changeVolume((newValue < 0) ? -1 : 1);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void keyPressed(int key, char c) {
|
|
|
|
public boolean keyPressed(int key, char c) {
|
|
|
|
switch (key) {
|
|
|
|
switch (key) {
|
|
|
|
case Input.KEY_ESCAPE:
|
|
|
|
case Input.KEY_ESCAPE:
|
|
|
|
case Input.KEY_Q:
|
|
|
|
case Input.KEY_Q:
|
|
|
@ -656,9 +649,10 @@ public class MainMenu extends BasicGameState {
|
|
|
|
logoTimer = 0;
|
|
|
|
logoTimer = 0;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.EXIT);
|
|
|
|
// TODO
|
|
|
|
game.enterState(Opsu.STATE_BUTTONMENU);
|
|
|
|
//((ButtonMenu) game.getState(Opsu.STATE_BUTTONMENU)).setMenuState(MenuState.EXIT);
|
|
|
|
break;
|
|
|
|
//game.enterState(Opsu.STATE_BUTTONMENU);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
case Input.KEY_P:
|
|
|
|
case Input.KEY_P:
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
|
|
|
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
|
|
@ -669,30 +663,32 @@ public class MainMenu extends BasicGameState {
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
|
|
|
exitButton.getImage().setAlpha(0f);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
enterSongMenu();
|
|
|
|
enterSongMenu();
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_D:
|
|
|
|
case Input.KEY_D:
|
|
|
|
SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
// TODO
|
|
|
|
game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
//SoundController.playSound(SoundEffect.MENUHIT);
|
|
|
|
break;
|
|
|
|
//game.enterState(Opsu.STATE_DOWNLOADSMENU, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
case Input.KEY_R:
|
|
|
|
case Input.KEY_R:
|
|
|
|
nextTrack(true);
|
|
|
|
nextTrack(true);
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_UP:
|
|
|
|
case Input.KEY_UP:
|
|
|
|
UI.changeVolume(1);
|
|
|
|
UI.changeVolume(1);
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_DOWN:
|
|
|
|
case Input.KEY_DOWN:
|
|
|
|
UI.changeVolume(-1);
|
|
|
|
UI.changeVolume(-1);
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_F7:
|
|
|
|
case Input.KEY_F7:
|
|
|
|
Options.setNextFPS(container);
|
|
|
|
Options.setNextFPS(displayContainer);
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_F10:
|
|
|
|
case Input.KEY_F10:
|
|
|
|
Options.toggleMouseDisabled();
|
|
|
|
Options.toggleMouseDisabled();
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
case Input.KEY_F12:
|
|
|
|
case Input.KEY_F12:
|
|
|
|
Utils.takeScreenShot();
|
|
|
|
Utils.takeScreenShot();
|
|
|
|
break;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -710,7 +706,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void reset() {
|
|
|
|
public void reset() {
|
|
|
|
// reset logo
|
|
|
|
// reset logo
|
|
|
|
logo.setX(container.getWidth() / 2);
|
|
|
|
logo.setX(displayContainer.width / 2);
|
|
|
|
logoOpen.setTime(0);
|
|
|
|
logoOpen.setTime(0);
|
|
|
|
logoClose.setTime(0);
|
|
|
|
logoClose.setTime(0);
|
|
|
|
logoButtonAlpha.setTime(0);
|
|
|
|
logoButtonAlpha.setTime(0);
|
|
|
@ -746,8 +742,7 @@ public class MainMenu extends BasicGameState {
|
|
|
|
MusicController.playAt(0, false);
|
|
|
|
MusicController.playAt(0, false);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
|
|
|
BeatmapSetNode node = instanceContainer.provide(SongMenu.class).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false);
|
|
|
|
BeatmapSetNode node = menu.setFocus(BeatmapSetList.get().getRandomNode(), -1, true, false);
|
|
|
|
|
|
|
|
boolean sameAudio = false;
|
|
|
|
boolean sameAudio = false;
|
|
|
|
if (node != null) {
|
|
|
|
if (node != null) {
|
|
|
|
sameAudio = MusicController.getBeatmap().audioFilename.equals(node.getBeatmapSet().get(0).audioFilename);
|
|
|
|
sameAudio = MusicController.getBeatmap().audioFilename.equals(node.getBeatmapSet().get(0).audioFilename);
|
|
|
@ -764,9 +759,11 @@ public class MainMenu extends BasicGameState {
|
|
|
|
private void enterSongMenu() {
|
|
|
|
private void enterSongMenu() {
|
|
|
|
int state = Opsu.STATE_SONGMENU;
|
|
|
|
int state = Opsu.STATE_SONGMENU;
|
|
|
|
if (BeatmapSetList.get().getMapSetCount() == 0) {
|
|
|
|
if (BeatmapSetList.get().getMapSetCount() == 0) {
|
|
|
|
((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!");
|
|
|
|
// TODO
|
|
|
|
state = Opsu.STATE_DOWNLOADSMENU;
|
|
|
|
//((DownloadsMenu) game.getState(Opsu.STATE_DOWNLOADSMENU)).notifyOnLoad("Download some beatmaps to get started!");
|
|
|
|
|
|
|
|
//state = Opsu.STATE_DOWNLOADSMENU;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
game.enterState(state, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
//game.enterState(state, new EasedFadeOutTransition(), new FadeInTransition());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|