Minor graphical updates and code cleaning.
- Padded game score display, and always display 2 digits in front of the decimal (e.g. 00.00% instead of 0.00%). - Keep map progress circle at a fixed location instead of basing it off the score length. - Moved some track resets (pause + restart at preview) to trigger upon loading the song menu. Fixes weird behaviors when leaving the game state. - Cleaned up trailing whitespace and added missing overrides. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -932,7 +932,7 @@ public class Game extends BasicGameState {
|
||||
* Returns the object approach time, in milliseconds.
|
||||
*/
|
||||
public int getApproachTime() { return approachTime; }
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of hit result offset times, in milliseconds (indexed by GameScore.HIT_* constants).
|
||||
*/
|
||||
|
||||
@@ -135,10 +135,10 @@ public class GamePauseMenu extends BasicGameState {
|
||||
case Input.KEY_ESCAPE:
|
||||
// 'esc' will normally unpause, but will return to song menu if health is zero
|
||||
if (gameState.getRestart() == Game.Restart.LOSE) {
|
||||
MusicController.stop();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
songMenu.resetTrackOnLoad();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
} else {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
@@ -179,10 +179,10 @@ public class GamePauseMenu extends BasicGameState {
|
||||
gameState.setRestart(Game.Restart.MANUAL);
|
||||
game.enterState(Opsu.STATE_GAME);
|
||||
} else if (backButton.contains(x, y)) {
|
||||
MusicController.pause(); // lose state
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
songMenu.resetTrackOnLoad();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,10 @@ public class GameRanking extends BasicGameState {
|
||||
}
|
||||
|
||||
// header text
|
||||
Utils.FONT_LARGE.drawString(10, 0,
|
||||
float marginX = width * 0.01f, marginY = height * 0.01f;
|
||||
Utils.FONT_LARGE.drawString(marginX, marginY,
|
||||
String.format("%s - %s [%s]", osu.getArtist(), osu.getTitle(), osu.version), Color.white);
|
||||
Utils.FONT_MEDIUM.drawString(10, Utils.FONT_LARGE.getLineHeight() - 6,
|
||||
Utils.FONT_MEDIUM.drawString(marginX, marginY + Utils.FONT_LARGE.getLineHeight() - 6,
|
||||
String.format("Beatmap by %s", osu.creator), Color.white);
|
||||
|
||||
// buttons
|
||||
@@ -147,10 +148,10 @@ public class GameRanking extends BasicGameState {
|
||||
public void keyPressed(int key, char c) {
|
||||
switch (key) {
|
||||
case Input.KEY_ESCAPE:
|
||||
MusicController.pause();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
songMenu.resetTrackOnLoad();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
break;
|
||||
case Input.KEY_F12:
|
||||
@@ -161,7 +162,7 @@ public class GameRanking extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
// check mouse button
|
||||
// check mouse button
|
||||
if (button != Input.MOUSE_LEFT_BUTTON)
|
||||
return;
|
||||
|
||||
@@ -177,10 +178,10 @@ public class GameRanking extends BasicGameState {
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
game.enterState(Opsu.STATE_MAINMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
} else if (Utils.getBackButton().contains(x, y)) {
|
||||
MusicController.pause();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) game.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
songMenu.resetTrackOnLoad();
|
||||
game.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ public class MainMenu extends BasicGameState {
|
||||
throws SlickException {
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
|
||||
|
||||
// draw background
|
||||
OsuFile osu = MusicController.getOsuFile();
|
||||
if (Options.isDynamicBackgroundEnabled() &&
|
||||
@@ -232,7 +232,7 @@ public class MainMenu extends BasicGameState {
|
||||
long time = System.currentTimeMillis() - osuStartTime;
|
||||
g.drawString(String.format("opsu! has been running for %d minutes, %d seconds.",
|
||||
TimeUnit.MILLISECONDS.toMinutes(time),
|
||||
TimeUnit.MILLISECONDS.toSeconds(time) -
|
||||
TimeUnit.MILLISECONDS.toSeconds(time) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(time))),
|
||||
25, height - 25 - (lineHeight * 2));
|
||||
g.drawString(String.format("The current time is %s.",
|
||||
@@ -342,7 +342,7 @@ public class MainMenu extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
// check mouse button
|
||||
// check mouse button
|
||||
if (button != Input.MOUSE_LEFT_BUTTON)
|
||||
return;
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class MainMenuExit extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
// check mouse button
|
||||
// check mouse button
|
||||
if (button != Input.MOUSE_LEFT_BUTTON)
|
||||
return;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public class Options extends BasicGameState {
|
||||
* Temporary folder for file conversions, auto-deleted upon successful exit.
|
||||
*/
|
||||
public static final File TMP_DIR = new File(".opsu_tmp/");
|
||||
|
||||
|
||||
/**
|
||||
* File for logging errors.
|
||||
*/
|
||||
@@ -591,7 +591,7 @@ public class Options extends BasicGameState {
|
||||
* Frame limiters.
|
||||
*/
|
||||
private static final int[] targetFPS = { 60, 120, 240 };
|
||||
|
||||
|
||||
/**
|
||||
* Index in targetFPS[] array.
|
||||
*/
|
||||
@@ -761,7 +761,7 @@ public class Options extends BasicGameState {
|
||||
int subtextWidth = Utils.FONT_DEFAULT.getWidth("Click or drag an option to change it.");
|
||||
float tabX = (width / 50) + (tab.getWidth() / 2f);
|
||||
float tabY = 15 + Utils.FONT_XLARGE.getLineHeight() + (tab.getHeight() / 2f);
|
||||
int tabOffset = Math.min(tab.getWidth(),
|
||||
int tabOffset = Math.min(tab.getWidth(),
|
||||
((width - subtextWidth - tab.getWidth()) / 2) / TAB_MAX);
|
||||
for (int i = 0; i < optionTabs.length; i++)
|
||||
optionTabs[i] = new MenuButton(tab, tabX + (i * tabOffset), tabY);
|
||||
@@ -872,7 +872,7 @@ public class Options extends BasicGameState {
|
||||
return;
|
||||
}
|
||||
|
||||
// check mouse button
|
||||
// check mouse button
|
||||
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
||||
return;
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
package itdelatrisu.opsu.states;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.GameMod;
|
||||
import itdelatrisu.opsu.MenuButton;
|
||||
@@ -35,6 +33,8 @@ import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.newdawn.slick.Animation;
|
||||
import org.newdawn.slick.Color;
|
||||
@@ -182,6 +182,11 @@ public class SongMenu extends BasicGameState {
|
||||
*/
|
||||
private boolean resetGame = false;
|
||||
|
||||
/**
|
||||
* Whether or not to reset music track upon entering the state.
|
||||
*/
|
||||
private boolean resetTrack = false;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
@@ -435,7 +440,7 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
@Override
|
||||
public void mousePressed(int button, int x, int y) {
|
||||
// check mouse button
|
||||
// check mouse button
|
||||
if (button != Input.MOUSE_LEFT_BUTTON)
|
||||
return;
|
||||
|
||||
@@ -657,6 +662,13 @@ public class SongMenu extends BasicGameState {
|
||||
GameImage.destroySkinImages(); // destroy skin images, if any
|
||||
resetGame = false;
|
||||
}
|
||||
|
||||
// reset music track
|
||||
if (resetTrack) {
|
||||
MusicController.pause();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
resetTrack = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -679,7 +691,7 @@ public class SongMenu extends BasicGameState {
|
||||
while (n != 0) {
|
||||
if (startNode == null)
|
||||
break;
|
||||
|
||||
|
||||
int height = container.getHeight();
|
||||
if (n < 0 && startNode.prev != null) {
|
||||
startNode = startNode.prev;
|
||||
@@ -777,6 +789,11 @@ public class SongMenu extends BasicGameState {
|
||||
*/
|
||||
public void resetGameDataOnLoad() { resetGame = true; }
|
||||
|
||||
/**
|
||||
* Triggers a reset of the music track upon entering this state.
|
||||
*/
|
||||
public void resetTrackOnLoad() { resetTrack = true; }
|
||||
|
||||
/**
|
||||
* Starts the game.
|
||||
* @param osu the OsuFile to send to the game
|
||||
|
||||
Reference in New Issue
Block a user