Changed more messy animations to use AnimatedValue.
Also finally refactored the main menu logo controller code... Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
c91146b024
commit
c0b3da37c2
|
@ -162,7 +162,7 @@ public class Spinner implements GameObject {
|
||||||
final int maxVel = 48;
|
final int maxVel = 48;
|
||||||
final int minTime = 2000;
|
final int minTime = 2000;
|
||||||
final int maxTime = 5000;
|
final int maxTime = 5000;
|
||||||
maxStoredDeltaAngles = (int) Utils.clamp((hitObject.getEndTime() - hitObject.getTime() - minTime)
|
maxStoredDeltaAngles = Utils.clamp((hitObject.getEndTime() - hitObject.getTime() - minTime)
|
||||||
* (maxVel - minVel) / (maxTime - minTime) + minVel, minVel, maxVel);
|
* (maxVel - minVel) / (maxTime - minTime) + minVel, minVel, maxVel);
|
||||||
storedDeltaAngle = new float[maxStoredDeltaAngles];
|
storedDeltaAngle = new float[maxStoredDeltaAngles];
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,9 @@ import itdelatrisu.opsu.downloads.Updater;
|
||||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.MenuButton.Expand;
|
import itdelatrisu.opsu.ui.MenuButton.Expand;
|
||||||
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -62,7 +63,7 @@ import org.newdawn.slick.state.transition.FadeOutTransition;
|
||||||
*/
|
*/
|
||||||
public class MainMenu extends BasicGameState {
|
public class MainMenu extends BasicGameState {
|
||||||
/** 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 MOVE_DELAY = 5000;
|
private static final short LOGO_IDLE_DELAY = 10000;
|
||||||
|
|
||||||
/** Max alpha level of the menu background. */
|
/** Max alpha level of the menu background. */
|
||||||
private static final float BG_MAX_ALPHA = 0.9f;
|
private static final float BG_MAX_ALPHA = 0.9f;
|
||||||
|
@ -70,12 +71,21 @@ public class MainMenu extends BasicGameState {
|
||||||
/** Logo button that reveals other buttons on click. */
|
/** Logo button that reveals other buttons on click. */
|
||||||
private MenuButton logo;
|
private MenuButton logo;
|
||||||
|
|
||||||
/** Whether or not the logo has been clicked. */
|
/** Logo states. */
|
||||||
private boolean logoClicked = false;
|
private enum LogoState { DEFAULT, OPENING, OPEN, CLOSING }
|
||||||
|
|
||||||
|
/** Current logo state. */
|
||||||
|
private LogoState logoState = LogoState.DEFAULT;
|
||||||
|
|
||||||
/** Delay timer, in milliseconds, before starting to move the logo back to the center. */
|
/** Delay timer, in milliseconds, before starting to move the logo back to the center. */
|
||||||
private int logoTimer = 0;
|
private int logoTimer = 0;
|
||||||
|
|
||||||
|
/** Logo horizontal offset for opening and closing actions. */
|
||||||
|
private AnimatedValue logoOpen, logoClose;
|
||||||
|
|
||||||
|
/** Logo button alpha levels. */
|
||||||
|
private AnimatedValue logoButtonAlpha;
|
||||||
|
|
||||||
/** Main "Play" and "Exit" buttons. */
|
/** Main "Play" and "Exit" buttons. */
|
||||||
private MenuButton playButton, exitButton;
|
private MenuButton playButton, exitButton;
|
||||||
|
|
||||||
|
@ -98,7 +108,7 @@ public class MainMenu extends BasicGameState {
|
||||||
private Stack<Integer> previous;
|
private Stack<Integer> previous;
|
||||||
|
|
||||||
/** Background alpha level (for fade-in effect). */
|
/** Background alpha level (for fade-in effect). */
|
||||||
private float bgAlpha = 0f;
|
private AnimatedValue bgAlpha = new AnimatedValue(1100, 0f, BG_MAX_ALPHA, AnimationEquation.LINEAR);
|
||||||
|
|
||||||
/** Whether or not a notification was already sent upon entering. */
|
/** Whether or not a notification was already sent upon entering. */
|
||||||
private boolean enterNotification = false;
|
private boolean enterNotification = false;
|
||||||
|
@ -154,7 +164,7 @@ public class MainMenu extends BasicGameState {
|
||||||
logo.setHoverAnimationEquation(logoAnimationEquation);
|
logo.setHoverAnimationEquation(logoAnimationEquation);
|
||||||
playButton.setHoverAnimationEquation(logoAnimationEquation);
|
playButton.setHoverAnimationEquation(logoAnimationEquation);
|
||||||
exitButton.setHoverAnimationEquation(logoAnimationEquation);
|
exitButton.setHoverAnimationEquation(logoAnimationEquation);
|
||||||
final float logoHoverScale = 1.1f;
|
final float logoHoverScale = 1.08f;
|
||||||
logo.setHoverExpand(logoHoverScale);
|
logo.setHoverExpand(logoHoverScale);
|
||||||
playButton.setHoverExpand(logoHoverScale);
|
playButton.setHoverExpand(logoHoverScale);
|
||||||
exitButton.setHoverExpand(logoHoverScale);
|
exitButton.setHoverExpand(logoHoverScale);
|
||||||
|
@ -203,6 +213,12 @@ public class MainMenu extends BasicGameState {
|
||||||
updateButton = new MenuButton(bangImg, startX - bangImg.getWidth(), startY - bangImg.getHeight());
|
updateButton = new MenuButton(bangImg, startX - bangImg.getWidth(), startY - bangImg.getHeight());
|
||||||
updateButton.setHoverExpand(1.15f);
|
updateButton.setHoverExpand(1.15f);
|
||||||
|
|
||||||
|
// logo animations
|
||||||
|
float centerOffsetX = container.getWidth() / 5f;
|
||||||
|
logoOpen = new AnimatedValue(400, 0, centerOffsetX, AnimationEquation.OUT_QUAD);
|
||||||
|
logoClose = new AnimatedValue(2200, centerOffsetX, 0, AnimationEquation.OUT_QUAD);
|
||||||
|
logoButtonAlpha = new AnimatedValue(300, 0f, 1f, AnimationEquation.LINEAR);
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,11 +231,11 @@ public class MainMenu extends BasicGameState {
|
||||||
// draw background
|
// draw background
|
||||||
Beatmap beatmap = MusicController.getBeatmap();
|
Beatmap beatmap = MusicController.getBeatmap();
|
||||||
if (Options.isDynamicBackgroundEnabled() &&
|
if (Options.isDynamicBackgroundEnabled() &&
|
||||||
beatmap != null && beatmap.drawBG(width, height, bgAlpha, true))
|
beatmap != null && beatmap.drawBG(width, height, bgAlpha.getValue(), true))
|
||||||
;
|
;
|
||||||
else {
|
else {
|
||||||
Image bg = GameImage.MENU_BG.getImage();
|
Image bg = GameImage.MENU_BG.getImage();
|
||||||
bg.setAlpha(bgAlpha);
|
bg.setAlpha(bgAlpha.getValue());
|
||||||
bg.draw();
|
bg.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +251,7 @@ public class MainMenu extends BasicGameState {
|
||||||
downloadsButton.draw();
|
downloadsButton.draw();
|
||||||
|
|
||||||
// draw buttons
|
// draw buttons
|
||||||
if (logoTimer > 0) {
|
if (logoState == LogoState.OPEN || logoState == LogoState.CLOSING) {
|
||||||
playButton.draw();
|
playButton.draw();
|
||||||
exitButton.draw();
|
exitButton.draw();
|
||||||
}
|
}
|
||||||
|
@ -336,46 +352,44 @@ public class MainMenu extends BasicGameState {
|
||||||
MusicController.toggleTrackDimmed(0.33f);
|
MusicController.toggleTrackDimmed(0.33f);
|
||||||
|
|
||||||
// fade in background
|
// fade in background
|
||||||
if (bgAlpha < BG_MAX_ALPHA) {
|
bgAlpha.update(delta);
|
||||||
bgAlpha += delta / 1000f;
|
|
||||||
if (bgAlpha > BG_MAX_ALPHA)
|
|
||||||
bgAlpha = BG_MAX_ALPHA;
|
|
||||||
}
|
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
if (logoClicked) {
|
int centerX = container.getWidth() / 2;
|
||||||
if (logoTimer == 0) { // shifting to left
|
float currentLogoButtonAlpha;
|
||||||
if (logo.getX() > container.getWidth() / 3.3f)
|
switch (logoState) {
|
||||||
logo.setX(logo.getX() - delta);
|
case DEFAULT:
|
||||||
else
|
break;
|
||||||
logoTimer = 1;
|
case OPENING:
|
||||||
} else if (logoTimer >= MOVE_DELAY) // timer over: shift back to center
|
if (logoOpen.update(delta)) // shifting to left
|
||||||
logoClicked = false;
|
logo.setX(centerX - logoOpen.getValue());
|
||||||
else { // increment timer
|
else {
|
||||||
|
logoState = LogoState.OPEN;
|
||||||
|
logoTimer = 0;
|
||||||
|
logoButtonAlpha.setTime(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPEN:
|
||||||
|
if (logoButtonAlpha.update(delta)) { // fade in buttons
|
||||||
|
currentLogoButtonAlpha = logoButtonAlpha.getValue();
|
||||||
|
playButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||||
|
exitButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||||
|
} else if (logoTimer >= LOGO_IDLE_DELAY) { // timer over: shift back to center
|
||||||
|
logoState = LogoState.CLOSING;
|
||||||
|
logoClose.setTime(0);
|
||||||
|
logoTimer = 0;
|
||||||
|
} else // increment timer
|
||||||
logoTimer += delta;
|
logoTimer += delta;
|
||||||
if (logoTimer <= 500) {
|
break;
|
||||||
// fade in buttons
|
case CLOSING:
|
||||||
playButton.getImage().setAlpha(logoTimer / 400f);
|
if (logoButtonAlpha.update(-delta)) { // fade out buttons
|
||||||
exitButton.getImage().setAlpha(logoTimer / 400f);
|
currentLogoButtonAlpha = logoButtonAlpha.getValue();
|
||||||
}
|
playButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||||
}
|
exitButton.getImage().setAlpha(currentLogoButtonAlpha);
|
||||||
} 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) {
|
|
||||||
logo.setX(logo.getX() + (delta / 3f));
|
|
||||||
if (logo.getX() > container.getWidth() / 2)
|
|
||||||
logo.setX(container.getWidth() / 2);
|
|
||||||
}
|
}
|
||||||
|
if (logoClose.update(delta)) // shifting to right
|
||||||
|
logo.setX(centerX - logoClose.getValue());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// tooltips
|
// tooltips
|
||||||
|
@ -471,7 +485,7 @@ public class MainMenu extends BasicGameState {
|
||||||
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
SongMenu menu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||||
menu.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 = 0f;
|
bgAlpha.setTime(0);
|
||||||
} else
|
} else
|
||||||
MusicController.setPosition(0);
|
MusicController.setPosition(0);
|
||||||
UI.sendBarNotification("<< Previous");
|
UI.sendBarNotification("<< Previous");
|
||||||
|
@ -511,9 +525,10 @@ public class MainMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// start moving logo (if clicked)
|
// start moving logo (if clicked)
|
||||||
else if (!logoClicked) {
|
else if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
||||||
if (logo.contains(x, y, 0.25f)) {
|
if (logo.contains(x, y, 0.25f)) {
|
||||||
logoClicked = true;
|
logoState = LogoState.OPENING;
|
||||||
|
logoOpen.setTime(0);
|
||||||
logoTimer = 0;
|
logoTimer = 0;
|
||||||
playButton.getImage().setAlpha(0f);
|
playButton.getImage().setAlpha(0f);
|
||||||
exitButton.getImage().setAlpha(0f);
|
exitButton.getImage().setAlpha(0f);
|
||||||
|
@ -522,7 +537,7 @@ public class MainMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// other button actions (if visible)
|
// other button actions (if visible)
|
||||||
else if (logoClicked) {
|
else if (logoState == LogoState.OPEN || logoState == LogoState.OPENING) {
|
||||||
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();
|
||||||
|
@ -546,8 +561,9 @@ public class MainMenu extends BasicGameState {
|
||||||
break;
|
break;
|
||||||
case Input.KEY_P:
|
case Input.KEY_P:
|
||||||
SoundController.playSound(SoundEffect.MENUHIT);
|
SoundController.playSound(SoundEffect.MENUHIT);
|
||||||
if (!logoClicked) {
|
if (logoState == LogoState.DEFAULT || logoState == LogoState.CLOSING) {
|
||||||
logoClicked = true;
|
logoState = LogoState.OPENING;
|
||||||
|
logoOpen.setTime(0);
|
||||||
logoTimer = 0;
|
logoTimer = 0;
|
||||||
playButton.getImage().setAlpha(0f);
|
playButton.getImage().setAlpha(0f);
|
||||||
exitButton.getImage().setAlpha(0f);
|
exitButton.getImage().setAlpha(0f);
|
||||||
|
@ -595,8 +611,11 @@ public class MainMenu extends BasicGameState {
|
||||||
public void reset() {
|
public void reset() {
|
||||||
// reset logo
|
// reset logo
|
||||||
logo.setX(container.getWidth() / 2);
|
logo.setX(container.getWidth() / 2);
|
||||||
logoClicked = false;
|
logoOpen.setTime(0);
|
||||||
|
logoClose.setTime(0);
|
||||||
|
logoButtonAlpha.setTime(0);
|
||||||
logoTimer = 0;
|
logoTimer = 0;
|
||||||
|
logoState = LogoState.DEFAULT;
|
||||||
|
|
||||||
logo.resetHover();
|
logo.resetHover();
|
||||||
playButton.resetHover();
|
playButton.resetHover();
|
||||||
|
@ -625,7 +644,7 @@ public class MainMenu extends BasicGameState {
|
||||||
previous.add(node.index);
|
previous.add(node.index);
|
||||||
}
|
}
|
||||||
if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
|
if (Options.isDynamicBackgroundEnabled() && !sameAudio && !MusicController.isThemePlaying())
|
||||||
bgAlpha = 0f;
|
bgAlpha.setTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,6 +41,8 @@ import itdelatrisu.opsu.db.ScoreDB;
|
||||||
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
import itdelatrisu.opsu.states.ButtonMenu.MenuState;
|
||||||
import itdelatrisu.opsu.ui.MenuButton;
|
import itdelatrisu.opsu.ui.MenuButton;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -138,8 +140,8 @@ public class SongMenu extends BasicGameState {
|
||||||
/** Button coordinate values. */
|
/** Button coordinate values. */
|
||||||
private float buttonX, buttonY, buttonOffset, buttonWidth, buttonHeight;
|
private float buttonX, buttonY, buttonOffset, buttonWidth, buttonHeight;
|
||||||
|
|
||||||
/** Current x offset of song buttons for mouse hover, in pixels. */
|
/** Horizontal offset of song buttons for mouse hover, in pixels. */
|
||||||
private float hoverOffset = 0f;
|
private AnimatedValue hoverOffset = new AnimatedValue(250, 0, MAX_HOVER_OFFSET, AnimationEquation.OUT_QUART);
|
||||||
|
|
||||||
/** Current index of hovered song button. */
|
/** Current index of hovered song button. */
|
||||||
private int hoverIndex = -1;
|
private int hoverIndex = -1;
|
||||||
|
@ -307,7 +309,7 @@ public class SongMenu extends BasicGameState {
|
||||||
g.setClip(0, (int) (headerY + DIVIDER_LINE_WIDTH / 2), width, (int) (footerY - headerY));
|
g.setClip(0, (int) (headerY + DIVIDER_LINE_WIDTH / 2), width, (int) (footerY - headerY));
|
||||||
for (int i = songButtonIndex; i <= MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
|
for (int i = songButtonIndex; i <= MAX_SONG_BUTTONS && node != null; i++, node = node.next) {
|
||||||
// draw the node
|
// draw the node
|
||||||
float offset = (i == hoverIndex) ? hoverOffset : 0f;
|
float offset = (i == hoverIndex) ? hoverOffset.getValue() : 0f;
|
||||||
ScoreData[] scores = getScoreDataForNode(node, false);
|
ScoreData[] scores = getScoreDataForNode(node, false);
|
||||||
node.draw(buttonX - offset, buttonY + (i*buttonOffset) + DIVIDER_LINE_WIDTH / 2,
|
node.draw(buttonX - offset, buttonY + (i*buttonOffset) + DIVIDER_LINE_WIDTH / 2,
|
||||||
(scores == null) ? Grade.NULL : scores[0].getGrade(), (node == focusNode));
|
(scores == null) ? Grade.NULL : scores[0].getGrade(), (node == focusNode));
|
||||||
|
@ -560,15 +562,11 @@ public class SongMenu extends BasicGameState {
|
||||||
float cx = (node.index == BeatmapSetList.get().getExpandedIndex()) ? buttonX * 0.9f : buttonX;
|
float cx = (node.index == BeatmapSetList.get().getExpandedIndex()) ? buttonX * 0.9f : buttonX;
|
||||||
if ((mouseX > cx && mouseX < cx + buttonWidth) &&
|
if ((mouseX > cx && mouseX < cx + buttonWidth) &&
|
||||||
(mouseY > buttonY + (i * buttonOffset) && mouseY < buttonY + (i * buttonOffset) + buttonHeight)) {
|
(mouseY > buttonY + (i * buttonOffset) && mouseY < buttonY + (i * buttonOffset) + buttonHeight)) {
|
||||||
if (i == hoverIndex) {
|
if (i == hoverIndex)
|
||||||
if (hoverOffset < MAX_HOVER_OFFSET) {
|
hoverOffset.update(delta);
|
||||||
hoverOffset += delta / 3f;
|
else {
|
||||||
if (hoverOffset > MAX_HOVER_OFFSET)
|
|
||||||
hoverOffset = MAX_HOVER_OFFSET;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hoverIndex = i;
|
hoverIndex = i;
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
}
|
}
|
||||||
isHover = true;
|
isHover = true;
|
||||||
break;
|
break;
|
||||||
|
@ -576,7 +574,7 @@ public class SongMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isHover) {
|
if (!isHover) {
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = -1;
|
hoverIndex = -1;
|
||||||
} else
|
} else
|
||||||
return;
|
return;
|
||||||
|
@ -660,7 +658,7 @@ public class SongMenu extends BasicGameState {
|
||||||
float cx = (node.index == expandedIndex) ? buttonX * 0.9f : buttonX;
|
float cx = (node.index == expandedIndex) ? buttonX * 0.9f : buttonX;
|
||||||
if ((x > cx && x < cx + buttonWidth) &&
|
if ((x > cx && x < cx + buttonWidth) &&
|
||||||
(y > buttonY + (i * buttonOffset) && y < buttonY + (i * buttonOffset) + buttonHeight)) {
|
(y > buttonY + (i * buttonOffset) && y < buttonY + (i * buttonOffset) + buttonHeight)) {
|
||||||
float oldHoverOffset = hoverOffset;
|
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||||
int oldHoverIndex = hoverIndex;
|
int oldHoverIndex = hoverIndex;
|
||||||
|
|
||||||
// clicked node is already expanded
|
// clicked node is already expanded
|
||||||
|
@ -685,7 +683,7 @@ public class SongMenu extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore hover data
|
// restore hover data
|
||||||
hoverOffset = oldHoverOffset;
|
hoverOffset.setTime(oldHoverOffsetTime);
|
||||||
hoverIndex = oldHoverIndex;
|
hoverIndex = oldHoverIndex;
|
||||||
|
|
||||||
// open beatmap menu
|
// open beatmap menu
|
||||||
|
@ -820,11 +818,11 @@ public class SongMenu extends BasicGameState {
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||||
BeatmapSetNode oldStartNode = startNode;
|
BeatmapSetNode oldStartNode = startNode;
|
||||||
float oldHoverOffset = hoverOffset;
|
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||||
int oldHoverIndex = hoverIndex;
|
int oldHoverIndex = hoverIndex;
|
||||||
setFocus(next, 0, false, true);
|
setFocus(next, 0, false, true);
|
||||||
if (startNode == oldStartNode) {
|
if (startNode == oldStartNode) {
|
||||||
hoverOffset = oldHoverOffset;
|
hoverOffset.setTime(oldHoverOffsetTime);
|
||||||
hoverIndex = oldHoverIndex;
|
hoverIndex = oldHoverIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -836,11 +834,11 @@ public class SongMenu extends BasicGameState {
|
||||||
if (prev != null) {
|
if (prev != null) {
|
||||||
SoundController.playSound(SoundEffect.MENUCLICK);
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
||||||
BeatmapSetNode oldStartNode = startNode;
|
BeatmapSetNode oldStartNode = startNode;
|
||||||
float oldHoverOffset = hoverOffset;
|
int oldHoverOffsetTime = hoverOffset.getTime();
|
||||||
int oldHoverIndex = hoverIndex;
|
int oldHoverIndex = hoverIndex;
|
||||||
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.getBeatmapSet().size() - 1, false, true);
|
setFocus(prev, (prev.index == focusNode.index) ? 0 : prev.getBeatmapSet().size() - 1, false, true);
|
||||||
if (startNode == oldStartNode) {
|
if (startNode == oldStartNode) {
|
||||||
hoverOffset = oldHoverOffset;
|
hoverOffset.setTime(oldHoverOffsetTime);
|
||||||
hoverIndex = oldHoverIndex;
|
hoverIndex = oldHoverIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -938,7 +936,7 @@ public class SongMenu extends BasicGameState {
|
||||||
selectRandomButton.resetHover();
|
selectRandomButton.resetHover();
|
||||||
selectMapOptionsButton.resetHover();
|
selectMapOptionsButton.resetHover();
|
||||||
selectOptionsButton.resetHover();
|
selectOptionsButton.resetHover();
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = -1;
|
hoverIndex = -1;
|
||||||
startScore = 0;
|
startScore = 0;
|
||||||
beatmapMenuTimer = -1;
|
beatmapMenuTimer = -1;
|
||||||
|
@ -1076,7 +1074,7 @@ public class SongMenu extends BasicGameState {
|
||||||
oldFocusNode = null;
|
oldFocusNode = null;
|
||||||
randomStack = new Stack<SongNode>();
|
randomStack = new Stack<SongNode>();
|
||||||
songInfo = null;
|
songInfo = null;
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = -1;
|
hoverIndex = -1;
|
||||||
search.setText("");
|
search.setText("");
|
||||||
searchTimer = SEARCH_DELAY;
|
searchTimer = SEARCH_DELAY;
|
||||||
|
@ -1157,7 +1155,7 @@ public class SongMenu extends BasicGameState {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (shifted) {
|
if (shifted) {
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = -1;
|
hoverIndex = -1;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1175,7 +1173,7 @@ public class SongMenu extends BasicGameState {
|
||||||
if (node == null)
|
if (node == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
hoverOffset = 0f;
|
hoverOffset.setTime(0);
|
||||||
hoverIndex = -1;
|
hoverIndex = -1;
|
||||||
songInfo = null;
|
songInfo = null;
|
||||||
BeatmapSetNode oldFocus = focusNode;
|
BeatmapSetNode oldFocus = focusNode;
|
||||||
|
|
|
@ -29,13 +29,14 @@ import itdelatrisu.opsu.beatmap.BeatmapParser;
|
||||||
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
import itdelatrisu.opsu.beatmap.BeatmapSetList;
|
||||||
import itdelatrisu.opsu.replay.ReplayImporter;
|
import itdelatrisu.opsu.replay.ReplayImporter;
|
||||||
import itdelatrisu.opsu.ui.UI;
|
import itdelatrisu.opsu.ui.UI;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimatedValue;
|
||||||
|
import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
|
||||||
import org.newdawn.slick.Input;
|
import org.newdawn.slick.Input;
|
||||||
import org.newdawn.slick.SlickException;
|
import org.newdawn.slick.SlickException;
|
||||||
import org.newdawn.slick.state.BasicGameState;
|
import org.newdawn.slick.state.BasicGameState;
|
||||||
|
@ -47,6 +48,9 @@ import org.newdawn.slick.state.StateBasedGame;
|
||||||
* Loads game resources and enters "Main Menu" state.
|
* Loads game resources and enters "Main Menu" state.
|
||||||
*/
|
*/
|
||||||
public class Splash extends BasicGameState {
|
public class Splash extends BasicGameState {
|
||||||
|
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
||||||
|
private static final int MIN_SPLASH_TIME = 300;
|
||||||
|
|
||||||
/** Whether or not loading has completed. */
|
/** Whether or not loading has completed. */
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
||||||
|
@ -59,6 +63,9 @@ public class Splash extends BasicGameState {
|
||||||
/** Whether the skin being loaded is a new skin (for program restarts). */
|
/** Whether the skin being loaded is a new skin (for program restarts). */
|
||||||
private boolean newSkin = false;
|
private boolean newSkin = false;
|
||||||
|
|
||||||
|
/** Logo alpha level. */
|
||||||
|
private AnimatedValue logoAlpha;
|
||||||
|
|
||||||
// game-related variables
|
// game-related variables
|
||||||
private int state;
|
private int state;
|
||||||
private GameContainer container;
|
private GameContainer container;
|
||||||
|
@ -80,6 +87,8 @@ public class Splash extends BasicGameState {
|
||||||
// load Utils class first (needed in other 'init' methods)
|
// load Utils class first (needed in other 'init' methods)
|
||||||
Utils.init(container, game);
|
Utils.init(container, game);
|
||||||
|
|
||||||
|
// fade in logo
|
||||||
|
this.logoAlpha = new AnimatedValue(MIN_SPLASH_TIME, 0f, 1f, AnimationEquation.LINEAR);
|
||||||
GameImage.MENU_LOGO.getImage().setAlpha(0f);
|
GameImage.MENU_LOGO.getImage().setAlpha(0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,13 +153,11 @@ public class Splash extends BasicGameState {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fade in logo
|
// fade in logo
|
||||||
Image logo = GameImage.MENU_LOGO.getImage();
|
if (logoAlpha.update(delta))
|
||||||
float alpha = logo.getAlpha();
|
GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue());
|
||||||
if (alpha < 1f)
|
|
||||||
logo.setAlpha(alpha + (delta / 500f));
|
|
||||||
|
|
||||||
// change states when loading complete
|
// change states when loading complete
|
||||||
if (finished && alpha >= 1f) {
|
if (finished && logoAlpha.getValue() >= 1f) {
|
||||||
// initialize song list
|
// initialize song list
|
||||||
if (BeatmapSetList.get().size() > 0) {
|
if (BeatmapSetList.get().size() > 0) {
|
||||||
BeatmapSetList.get().init();
|
BeatmapSetList.get().init();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user