Initial replay writing support.
- Added Replay.save() method to save replays to a file. - Separated Replay loading from the constructor into a load() method. - Added OsuWriter class to write replays. - Parse replay seeds (what do they do?). - Added Updater.getBuildDate() method to retrieve the current build date (for the replay 'version' field). - Added osu! mode constants in OsuFile. - Added methods to retrieve raw ReplayFrame coordinates. - Added replay fields/methods to GameData and Game state. - Added jponge/lzma-java dependency for LZMA compression, since it isn't implemented in Apache commons-compress... Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import itdelatrisu.opsu.replay.Replay;
|
||||
import itdelatrisu.opsu.replay.ReplayFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -175,6 +176,9 @@ public class Game extends BasicGameState {
|
||||
/** The previous game mod state (before the replay). */
|
||||
private int previousMods = 0;
|
||||
|
||||
/** The list of current replay frames (for recording replays). */
|
||||
private LinkedList<ReplayFrame> frameList;
|
||||
|
||||
// game-related variables
|
||||
private GameContainer container;
|
||||
private StateBasedGame game;
|
||||
@@ -468,7 +472,8 @@ public class Game extends BasicGameState {
|
||||
game.closeRequested();
|
||||
else { // go to ranking screen
|
||||
((GameRanking) game.getState(Opsu.STATE_GAMERANKING)).setGameData(data);
|
||||
ScoreData score = data.getScoreData(osu);
|
||||
ScoreData score = data.getScoreData(osu, (frameList == null) ? null :
|
||||
frameList.toArray(new ReplayFrame[frameList.size()]));
|
||||
if (!GameMod.AUTO.isActive() && !GameMod.RELAX.isActive() && !GameMod.AUTOPILOT.isActive() && !isReplay)
|
||||
ScoreDB.addScore(score);
|
||||
game.enterState(Opsu.STATE_GAMERANKING, new FadeOutTransition(Color.black), new FadeInTransition(Color.black));
|
||||
@@ -893,7 +898,8 @@ public class Game extends BasicGameState {
|
||||
};
|
||||
replayThreadRunning = true;
|
||||
replayThread.start();
|
||||
}
|
||||
} else
|
||||
frameList = new LinkedList<ReplayFrame>();
|
||||
|
||||
leadInTime = osu.audioLeadIn + approachTime;
|
||||
restart = Restart.FALSE;
|
||||
@@ -938,6 +944,7 @@ public class Game extends BasicGameState {
|
||||
checkpointLoaded = false;
|
||||
deaths = 0;
|
||||
deathTime = -1;
|
||||
frameList = null;
|
||||
|
||||
System.gc();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user