add option to load snapshot from command line

master
melvinzhang 2017-02-14 20:45:37 +08:00
parent 83b36734e7
commit 679bfafb7e
4 changed files with 15 additions and 3 deletions

View File

@ -200,6 +200,9 @@ release/Magarena-%.jar:
tags: $(SRC)
ctags -R src
%.game.run: $(MAG)
$(DEBUG) -DsaveGame=$*.game -Dmagarena.dir=`pwd`/release -jar $^ 2>&1
Test%.run: $(MAG)
$(DEBUG) -DtestGame=Test$* -Dmagarena.dir=`pwd`/release -jar $^ 2>&1 | tee Test$*.log

View File

@ -11,6 +11,7 @@ import magic.ui.SplashProgressReporter;
import magic.data.DuelConfig;
import magic.data.GeneralConfig;
import magic.test.TestGameBuilder;
import magic.game.state.GameLoader;
import magic.ui.ScreenController;
import magic.ui.helpers.LaFHelper;
import magic.ui.UiExceptionHandler;
@ -45,7 +46,7 @@ public class MagicMain {
}
LaFHelper.setDefaultLookAndFeel();
reporter.setMessage("Starting UI...");
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@ -87,6 +88,14 @@ public class MagicMain {
return;
}
// -DsaveGame=X, where X is the path to a snapshot.game
final String saveGame = System.getProperty("saveGame");
if (saveGame != null) {
final File f = new File(saveGame);
ScreenController.showDuelGameScreen(GameLoader.loadSavedGame(f));
return;
}
// -DselfMode=true
if (MagicSystem.isAiVersusAi()) {
final DuelConfig config = DuelConfig.getInstance();

View File

@ -19,7 +19,7 @@ public class DuelGameScreen extends MScreen {
showScreen(duel.nextGame());
}
// CTR - called when using -DtestGame=X argument.
// CTR - called when using -DtestGame=X or -DsaveGame=X
public DuelGameScreen(final MagicGame game) {
showScreen(game);
}

View File

@ -88,7 +88,7 @@ final public class MagicSystem {
}
public static boolean isTestGame() {
return (System.getProperty("testGame") != null && !System.getProperty("testGame").isEmpty());
return System.getProperty("testGame") != null || System.getProperty("saveGame") != null;
}
public static boolean isDevMode() {