CommandLineArgs should be transient and just parse arguments or provide default values.
parent
60a51b477f
commit
e4f4fc63b3
|
@ -3,7 +3,6 @@ package magic;
|
|||
import java.util.Locale;
|
||||
import magic.ai.MagicAI;
|
||||
import magic.ai.MagicAIImpl;
|
||||
import magic.ui.widget.duel.animation.MagicAnimations;
|
||||
import magic.utility.MagicSystem;
|
||||
|
||||
class CommandLineArgs {
|
||||
|
@ -12,6 +11,9 @@ class CommandLineArgs {
|
|||
private MagicAIImpl ai2 = MagicAIImpl.MMABFast;
|
||||
private int ai1Level = 8;
|
||||
private int ai2Level = 8;
|
||||
private boolean isAnimationsEnabled = true;
|
||||
private int maxAiThreads = MagicAI.getMaxThreads();
|
||||
private boolean isDevMode = false;
|
||||
|
||||
CommandLineArgs(final String[] args) {
|
||||
|
||||
|
@ -37,15 +39,15 @@ class CommandLineArgs {
|
|||
break;
|
||||
|
||||
case "--nofx": // turns off gameplay animations for session (does not change preferences).
|
||||
MagicAnimations.setEnabled(false);
|
||||
isAnimationsEnabled = false;
|
||||
break;
|
||||
|
||||
case "--threads": // limits the number of threads AI uses. (eg. --threads 2)
|
||||
MagicAI.setMaxThreads(Integer.parseInt(args[i + 1].trim()));
|
||||
maxAiThreads = Integer.parseInt(args[i + 1].trim());
|
||||
break;
|
||||
|
||||
case "--devmode": // enables access to additional functionality.
|
||||
MagicSystem.setIsDevMode(true);
|
||||
isDevMode = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -86,4 +88,16 @@ class CommandLineArgs {
|
|||
return ai2Level;
|
||||
}
|
||||
|
||||
boolean isAnimationsEnabled() {
|
||||
return isAnimationsEnabled;
|
||||
}
|
||||
|
||||
int getMaxThreads() {
|
||||
return maxAiThreads;
|
||||
}
|
||||
|
||||
boolean isDevMode() {
|
||||
return isDevMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import magic.ui.ScreenController;
|
|||
import magic.ui.SplashProgressReporter;
|
||||
import magic.ui.UiExceptionHandler;
|
||||
import magic.ui.helpers.LaFHelper;
|
||||
import magic.ui.widget.duel.animation.MagicAnimations;
|
||||
import magic.utility.MagicFileSystem;
|
||||
import magic.utility.MagicFileSystem.DataPath;
|
||||
import magic.utility.MagicSystem;
|
||||
|
@ -22,7 +23,6 @@ public class MagicMain {
|
|||
|
||||
private static SplashScreen splash;
|
||||
private static ProgressReporter reporter = new ProgressReporter();
|
||||
private static CommandLineArgs cmdline;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
|
||||
|
@ -31,7 +31,12 @@ public class MagicMain {
|
|||
setSplashScreen();
|
||||
|
||||
System.out.println(MagicSystem.getRuntimeParameters());
|
||||
cmdline = new CommandLineArgs(args);
|
||||
|
||||
// parse command line
|
||||
final CommandLineArgs cmdline = new CommandLineArgs(args);
|
||||
MagicAnimations.setEnabled(cmdline.isAnimationsEnabled());
|
||||
MagicAI.setMaxThreads(cmdline.getMaxThreads());
|
||||
MagicSystem.setIsDevMode(cmdline.isDevMode());
|
||||
|
||||
// show the data folder being used
|
||||
System.out.println("Data folder : "+ MagicFileSystem.getDataPath());
|
||||
|
@ -48,11 +53,7 @@ public class MagicMain {
|
|||
LaFHelper.setDefaultLookAndFeel();
|
||||
|
||||
reporter.setMessage("Starting UI...");
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
startUI();
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(() -> { startUI(cmdline); });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,7 +80,7 @@ public class MagicMain {
|
|||
}
|
||||
}
|
||||
|
||||
private static void startUI() {
|
||||
private static void startUI(CommandLineArgs cmdline) {
|
||||
|
||||
// -DtestGame=X, where X is one of the classes (without the .java) in "magic.test".
|
||||
final String testGame = System.getProperty("testGame");
|
||||
|
|
Loading…
Reference in New Issue