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:
parent
be1ec64f28
commit
31a97fbc5d
|
@ -129,7 +129,7 @@ public enum GameMod {
|
|||
Image img = new Image(filename);
|
||||
float scale = (height * 0.12f) / img.getHeight();
|
||||
img = img.getScaledCopy(scale);
|
||||
|
||||
|
||||
// find coordinates
|
||||
float offsetX = img.getWidth() * 1.5f;
|
||||
float x = (width / 2f) - (offsetX * SIZE / 2.75f);
|
||||
|
|
|
@ -451,20 +451,30 @@ public class GameScore {
|
|||
* @param firstObject true if the first hit object's start time has not yet passed
|
||||
*/
|
||||
public void drawGameElements(Graphics g, boolean breakPeriod, boolean firstObject) {
|
||||
int marginX = (int) (width * 0.008f);
|
||||
|
||||
// score
|
||||
drawSymbolString((scoreDisplay < 100000000) ? String.format("%08d", scoreDisplay) : Long.toString(scoreDisplay),
|
||||
width - 2, 0, 1.0f, true);
|
||||
width - marginX, 0, 1.0f, true);
|
||||
|
||||
// score percentage
|
||||
int symbolHeight = getScoreSymbolImage('0').getHeight();
|
||||
String scorePercentage = String.format("%02.2f%%", getScorePercent());
|
||||
drawSymbolString(scorePercentage, width - 2, symbolHeight, 0.75f, true);
|
||||
float scorePercent = getScorePercent();
|
||||
drawSymbolString(
|
||||
String.format((scorePercent < 10f) ? "0%.2f%%" : "%.2f%%", scorePercent),
|
||||
width - marginX, symbolHeight, 0.75f, true
|
||||
);
|
||||
|
||||
// map progress circle
|
||||
g.setAntiAlias(true);
|
||||
g.setLineWidth(2f);
|
||||
g.setColor(Color.white);
|
||||
int circleX = width - (getScoreSymbolImage('0').getWidth() * scorePercentage.length());
|
||||
int circleX = width - marginX - ( // max width: "100.00%"
|
||||
getScoreSymbolImage('1').getWidth() +
|
||||
getScoreSymbolImage('0').getWidth() * 4 +
|
||||
getScoreSymbolImage('.').getWidth() +
|
||||
getScoreSymbolImage('%').getWidth()
|
||||
);
|
||||
float circleDiameter = symbolHeight * 0.75f;
|
||||
g.drawOval(circleX, symbolHeight, circleDiameter, circleDiameter);
|
||||
|
||||
|
@ -783,7 +793,7 @@ public class GameScore {
|
|||
combo++;
|
||||
if (combo > comboMax)
|
||||
comboMax = combo;
|
||||
|
||||
|
||||
// combo bursts (at 30, 60, 100+50x)
|
||||
if (Options.isComboBurstEnabled() &&
|
||||
(combo == 30 || combo == 60 || (combo >= 100 && combo % 50 == 0))) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package itdelatrisu.opsu;
|
||||
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.states.Game;
|
||||
import itdelatrisu.opsu.states.GamePauseMenu;
|
||||
import itdelatrisu.opsu.states.GameRanking;
|
||||
|
@ -166,9 +165,9 @@ public class Opsu extends StateBasedGame {
|
|||
// intercept close requests in game-related states and return to song menu
|
||||
if (id == STATE_GAME || id == STATE_GAMEPAUSEMENU || id == STATE_GAMERANKING) {
|
||||
// start playing track at preview position
|
||||
MusicController.pause();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
((SongMenu) this.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
|
||||
SongMenu songMenu = (SongMenu) this.getState(Opsu.STATE_SONGMENU);
|
||||
songMenu.resetGameDataOnLoad();
|
||||
songMenu.resetTrackOnLoad();
|
||||
this.enterState(Opsu.STATE_SONGMENU, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ public class OsuFile implements Comparable<OsuFile> {
|
|||
/**
|
||||
* Compares two OsuFile objects first by overall difficulty, then by total objects.
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public int compareTo(OsuFile that) {
|
||||
int cmp = Float.compare(this.overallDifficulty, that.overallDifficulty);
|
||||
if (cmp == 0)
|
||||
|
|
|
@ -73,7 +73,7 @@ public class OsuGroupList {
|
|||
* Returns the single instance of this class.
|
||||
*/
|
||||
public static OsuGroupList get() { return list; }
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
|
@ -239,7 +239,7 @@ public class OsuGroupList {
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a new list of song groups in which each group contains a match to a search query.
|
||||
* Creates a new list of song groups in which each group contains a match to a search query.
|
||||
* @param query the search query (terms separated by spaces)
|
||||
* @return false if query is the same as the previous one, true otherwise
|
||||
*/
|
||||
|
|
|
@ -124,7 +124,7 @@ public class OsuGroupNode {
|
|||
osu.creator);
|
||||
info[2] = String.format("Length: %d:%02d BPM: %s Objects: %d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(osu.endTime),
|
||||
TimeUnit.MILLISECONDS.toSeconds(osu.endTime) -
|
||||
TimeUnit.MILLISECONDS.toSeconds(osu.endTime) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(osu.endTime)),
|
||||
(osu.bpmMax <= 0) ? "--" :
|
||||
((osu.bpmMin == osu.bpmMax) ? osu.bpmMin : String.format("%d-%d", osu.bpmMin, osu.bpmMax)),
|
||||
|
|
|
@ -98,7 +98,7 @@ public class Utils {
|
|||
* Last cursor coordinates.
|
||||
*/
|
||||
private static int lastX = -1, lastY = -1;
|
||||
|
||||
|
||||
/**
|
||||
* Stores all previous cursor locations to display a trail.
|
||||
*/
|
||||
|
@ -293,7 +293,7 @@ public class Utils {
|
|||
|
||||
/**
|
||||
* Loads the cursor images.
|
||||
* @throws SlickException
|
||||
* @throws SlickException
|
||||
*/
|
||||
public static void loadCursor() throws SlickException {
|
||||
// destroy old cursors, if they exist
|
||||
|
@ -428,7 +428,7 @@ public class Utils {
|
|||
int dx2 = (dx << 1); // point
|
||||
int ix = x1 < x2 ? 1 : -1; // increment direction
|
||||
int iy = y1 < y2 ? 1 : -1;
|
||||
|
||||
|
||||
int k = 5; // sample size
|
||||
if (dy <= dx) {
|
||||
for (int i = 0; ; i++) {
|
||||
|
|
|
@ -305,10 +305,10 @@ public class MusicController {
|
|||
/**
|
||||
* Stops and releases all sources, clears each of the specified Audio
|
||||
* buffers, destroys the OpenAL context, and resets SoundStore for future use.
|
||||
*
|
||||
*
|
||||
* Calling SoundStore.get().init() will re-initialize the OpenAL context
|
||||
* after a call to destroyOpenAL (Note: AudioLoader.getXXX calls init for you).
|
||||
*
|
||||
*
|
||||
* @author davedes (http://slick.ninjacave.com/forum/viewtopic.php?t=3920)
|
||||
*/
|
||||
private static void destroyOpenAL() {
|
||||
|
|
|
@ -124,7 +124,7 @@ public class SoundController {
|
|||
currentFileName = null;
|
||||
currentFileIndex = -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the sample volume (modifies the global sample volume).
|
||||
* @param volume the sample volume [0, 1]
|
||||
|
|
|
@ -90,6 +90,7 @@ public class Circle implements HitObject {
|
|||
this.comboEnd = comboEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int trackPosition, boolean currentObject, Graphics g) {
|
||||
int timeDiff = hitObject.getTime() - trackPosition;
|
||||
|
||||
|
@ -133,6 +134,7 @@ public class Circle implements HitObject {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int x, int y) {
|
||||
double distance = Math.hypot(hitObject.getX() - x, hitObject.getY() - y);
|
||||
int circleRadius = GameImage.HITCIRCLE.getImage().getWidth() / 2;
|
||||
|
@ -150,6 +152,7 @@ public class Circle implements HitObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY) {
|
||||
int time = hitObject.getTime();
|
||||
float x = hitObject.getX(), y = hitObject.getY();
|
||||
|
@ -162,7 +165,7 @@ public class Circle implements HitObject {
|
|||
if (overlap || trackPosition > time + hitResultOffset[GameScore.HIT_50]) {
|
||||
if (isAutoMod) // "auto" mod: catch any missed notes due to lag
|
||||
score.hitResult(time, GameScore.HIT_300, x, y, color, comboEnd, hitSound);
|
||||
|
||||
|
||||
else // no more points can be scored, so send a miss
|
||||
score.hitResult(time, GameScore.HIT_MISS, x, y, null, comboEnd, hitSound);
|
||||
return true;
|
||||
|
|
|
@ -84,7 +84,7 @@ public class Slider implements HitObject {
|
|||
* The time duration of the slider, in milliseconds.
|
||||
*/
|
||||
private float sliderTime = 0f;
|
||||
|
||||
|
||||
/**
|
||||
* The time duration of the slider including repeats, in milliseconds.
|
||||
*/
|
||||
|
@ -99,7 +99,7 @@ public class Slider implements HitObject {
|
|||
* Whether or not to show the follow circle.
|
||||
*/
|
||||
private boolean followCircleActive = false;
|
||||
|
||||
|
||||
/**
|
||||
* Whether or not the slider result ends the combo streak.
|
||||
*/
|
||||
|
@ -114,12 +114,12 @@ public class Slider implements HitObject {
|
|||
* The t values of the slider ticks.
|
||||
*/
|
||||
private float[] ticksT;
|
||||
|
||||
|
||||
/**
|
||||
* The tick index in the ticksT[] array.
|
||||
*/
|
||||
private int tickIndex = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Number of ticks hit and tick intervals so far.
|
||||
*/
|
||||
|
@ -201,7 +201,7 @@ public class Slider implements HitObject {
|
|||
* Returns the angle of the first control point.
|
||||
*/
|
||||
private float getStartAngle() { return startAngle; }
|
||||
|
||||
|
||||
/**
|
||||
* Returns the angle of the last control point.
|
||||
*/
|
||||
|
@ -336,6 +336,7 @@ public class Slider implements HitObject {
|
|||
this.bezier = new Bezier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int trackPosition, boolean currentObject, Graphics g) {
|
||||
float x = hitObject.getX(), y = hitObject.getY();
|
||||
float[] sliderX = hitObject.getSliderX(), sliderY = hitObject.getSliderY();
|
||||
|
@ -438,6 +439,7 @@ public class Slider implements HitObject {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(int x, int y) {
|
||||
if (sliderClicked) // first circle already processed
|
||||
return false;
|
||||
|
@ -448,7 +450,7 @@ public class Slider implements HitObject {
|
|||
int trackPosition = MusicController.getPosition();
|
||||
int timeDiff = Math.abs(trackPosition - hitObject.getTime());
|
||||
int[] hitResultOffset = game.getHitResultOffsets();
|
||||
|
||||
|
||||
int result = -1;
|
||||
if (timeDiff < hitResultOffset[GameScore.HIT_50]) {
|
||||
result = GameScore.HIT_SLIDER30;
|
||||
|
@ -467,6 +469,7 @@ public class Slider implements HitObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY) {
|
||||
int repeatCount = hitObject.getRepeatCount();
|
||||
|
||||
|
@ -490,7 +493,7 @@ public class Slider implements HitObject {
|
|||
|
||||
byte hitSound = hitObject.getHitSoundType();
|
||||
int trackPosition = MusicController.getPosition();
|
||||
int[] hitResultOffset = game.getHitResultOffsets();
|
||||
int[] hitResultOffset = game.getHitResultOffsets();
|
||||
int lastIndex = hitObject.getSliderX().length - 1;
|
||||
boolean isAutoMod = GameMod.AUTO.isActive();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public class Spinner implements HitObject {
|
|||
/**
|
||||
* Initializes the Spinner data type with images and dimensions.
|
||||
* @param container the game container
|
||||
* @throws SlickException
|
||||
* @throws SlickException
|
||||
*/
|
||||
public static void init(GameContainer container) throws SlickException {
|
||||
width = container.getWidth();
|
||||
|
@ -99,6 +99,7 @@ public class Spinner implements HitObject {
|
|||
rotationsNeeded = spinsPerMinute * (hitObject.getEndTime() - hitObject.getTime()) / 60000f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int trackPosition, boolean currentObject, Graphics g) {
|
||||
// only draw spinners if current object
|
||||
if (!currentObject)
|
||||
|
@ -139,7 +140,7 @@ public class Spinner implements HitObject {
|
|||
score.drawSymbolNumber(extraRotations * 1000, width / 2, height * 2 / 3, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates and sends the spinner hit result.
|
||||
* @return the hit result (GameScore.HIT_* constants)
|
||||
|
@ -165,9 +166,10 @@ public class Spinner implements HitObject {
|
|||
return result;
|
||||
}
|
||||
|
||||
// not used
|
||||
public boolean mousePressed(int x, int y) { return false; }
|
||||
@Override
|
||||
public boolean mousePressed(int x, int y) { return false; } // not used
|
||||
|
||||
@Override
|
||||
public boolean update(boolean overlap, int delta, int mouseX, int mouseY) {
|
||||
int trackPosition = MusicController.getPosition();
|
||||
if (overlap)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user