Enabled application restarts.
- Pressing Ctrl+Shift+F5 in the options menu restarts the game. Beatmaps and sounds are not reloaded. - Use GameContainer.setForceExit(false) to trigger a restart after exiting. Other changes: - Fixed general issues with track pausing/pause states. - Store all background images loaded in OsuFiles in a static hash table, instead of in individual objects. This allows easier access to the allocated memory. - Only delete OSZ files if they were unzipped. (They were previously deleted in all cases.) - Moved more images (mods, playfield, lighting) into GameImage. - Moved OsuHitObject initialization inside Utils. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -165,12 +165,6 @@ public class Game extends BasicGameState {
|
||||
*/
|
||||
private float pausePulse;
|
||||
|
||||
/**
|
||||
* Default playfield background (optional).
|
||||
* Overridden by song background unless "ForceDefaultPlayfield" option enabled.
|
||||
*/
|
||||
private Image playfield;
|
||||
|
||||
/**
|
||||
* Whether a checkpoint has been loaded during this game.
|
||||
*/
|
||||
@@ -214,13 +208,6 @@ public class Game extends BasicGameState {
|
||||
// create the associated GameScore object
|
||||
score = new GameScore(width, height);
|
||||
((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameScore(score);
|
||||
|
||||
// playfield background
|
||||
try {
|
||||
playfield = new Image("playfield.png").getScaledCopy(width, height);
|
||||
} catch (Exception e) {
|
||||
// optional
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,10 +219,8 @@ public class Game extends BasicGameState {
|
||||
// background
|
||||
g.setBackground(Color.black);
|
||||
float dimLevel = Options.getBackgroundDim();
|
||||
if (Options.isDefaultPlayfieldForced() && playfield != null) {
|
||||
playfield.setAlpha(dimLevel);
|
||||
playfield.draw();
|
||||
} else if (!osu.drawBG(width, height, dimLevel) && playfield != null) {
|
||||
if (Options.isDefaultPlayfieldForced() || !osu.drawBG(width, height, dimLevel)) {
|
||||
Image playfield = GameImage.PLAYFIELD.getImage();
|
||||
playfield.setAlpha(dimLevel);
|
||||
playfield.draw();
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class Options extends BasicGameState {
|
||||
*/
|
||||
private static enum GameOption {
|
||||
NULL (null, null),
|
||||
SCREEN_RESOLUTION ("Screen Resolution", "Restart to apply resolution changes.") {
|
||||
SCREEN_RESOLUTION ("Screen Resolution", "Restart (Ctrl+Shift+F5) to apply resolution changes.") {
|
||||
@Override
|
||||
public String getValueString() { return resolution.toString(); }
|
||||
|
||||
@@ -325,7 +325,7 @@ public class Options extends BasicGameState {
|
||||
@Override
|
||||
public void click(GameContainer container) { loadVerbose = !loadVerbose; }
|
||||
},
|
||||
CHECKPOINT ("Track Checkpoint", "Press CTRL+L while playing to load a checkpoint, and CTRL+S to set one.") {
|
||||
CHECKPOINT ("Track Checkpoint", "Press Ctrl+L while playing to load a checkpoint, and Ctrl+S to set one.") {
|
||||
@Override
|
||||
public String getValueString() {
|
||||
return (checkpoint == 0) ? "Disabled" : String.format("%02d:%02d",
|
||||
@@ -975,10 +975,19 @@ public class Options extends BasicGameState {
|
||||
SoundController.playSound(SoundEffect.MENUBACK);
|
||||
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
|
||||
break;
|
||||
case Input.KEY_F5:
|
||||
// restart application
|
||||
if ((input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) &&
|
||||
(input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT))) {
|
||||
container.setForceExit(false);
|
||||
container.exit();
|
||||
}
|
||||
break;
|
||||
case Input.KEY_F12:
|
||||
Utils.takeScreenShot();
|
||||
break;
|
||||
case Input.KEY_TAB:
|
||||
// change tabs
|
||||
int i = 1;
|
||||
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
|
||||
i = TAB_MAX - 1;
|
||||
@@ -1130,8 +1139,8 @@ public class Options extends BasicGameState {
|
||||
app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), false);
|
||||
|
||||
// set borderless window if dimensions match screen size
|
||||
if (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight())
|
||||
System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
|
||||
boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight());
|
||||
System.setProperty("org.lwjgl.opengl.Window.undecorated", Boolean.toString(borderless));
|
||||
}
|
||||
|
||||
// /**
|
||||
|
||||
@@ -209,7 +209,6 @@ public class SongMenu extends BasicGameState {
|
||||
|
||||
// song button background & graphics context
|
||||
Image menuBackground = GameImage.MENU_BUTTON_BG.getImage();
|
||||
OsuGroupNode.setBackground(menuBackground);
|
||||
|
||||
// song button coordinates
|
||||
buttonX = width * 0.6f;
|
||||
@@ -651,6 +650,13 @@ public class SongMenu extends BasicGameState {
|
||||
if (MusicController.isThemePlaying() && focusNode != null)
|
||||
MusicController.play(focusNode.osuFiles.get(focusNode.osuFileIndex), true);
|
||||
|
||||
// reset music track
|
||||
else if (resetTrack) {
|
||||
MusicController.pause();
|
||||
MusicController.playAt(MusicController.getOsuFile().previewTime, true);
|
||||
resetTrack = false;
|
||||
}
|
||||
|
||||
// unpause track
|
||||
else if (MusicController.isPaused())
|
||||
MusicController.resume();
|
||||
@@ -664,13 +670,6 @@ 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
|
||||
|
||||
@@ -119,16 +119,19 @@ public class Splash extends BasicGameState {
|
||||
thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
File beatmapDir = Options.getBeatmapDir();
|
||||
// application restart: everything already loaded
|
||||
if (OsuGroupList.get().size() < 1) {
|
||||
File beatmapDir = Options.getBeatmapDir();
|
||||
|
||||
// unpack all OSZ archives
|
||||
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
|
||||
// unpack all OSZ archives
|
||||
OszUnpacker.unpackAllFiles(Options.getOSZDir(), beatmapDir);
|
||||
|
||||
// parse song directory
|
||||
OsuParser.parseAllFiles(beatmapDir, width, height);
|
||||
|
||||
// parse song directory
|
||||
OsuParser.parseAllFiles(beatmapDir, width, height);
|
||||
|
||||
// load sounds
|
||||
SoundController.init();
|
||||
// load sounds
|
||||
SoundController.init();
|
||||
}
|
||||
|
||||
finished = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user