Commandline arguments are passed in to emulator init again

This commit is contained in:
Brendan Robert 2015-02-03 23:56:41 -06:00
parent d5b0e10add
commit 8fc422e0dd
3 changed files with 17 additions and 28 deletions

View File

@ -21,19 +21,10 @@ package jace;
import jace.apple2e.Apple2e;
import jace.config.Configuration;
import jace.ui.AbstractEmulatorFrame;
import jace.ui.EmulatorFrame;
import java.awt.Component;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
/**
* Created on January 15, 2007, 10:10 PM
@ -44,10 +35,10 @@ public class Emulator {
public static Emulator instance;
public static Thread mainThread;
public static void main(String... args) {
mainThread = Thread.currentThread();
instance = new Emulator(args);
}
// public static void main(String... args) {
// mainThread = Thread.currentThread();
// instance = new Emulator(args);
// }
public static Apple2e computer;
public AbstractEmulatorFrame theApp;
@ -56,16 +47,17 @@ public class Emulator {
* Creates a new instance of Emulator
* @param args
*/
public Emulator(String... args) {
public Emulator(List<String> args) {
computer = new Apple2e();
Configuration.loadSettings();
mainThread = Thread.currentThread();
Map<String, String> settings = new HashMap<>();
if (args != null) {
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-")) {
String key = args[i].substring(1);
if ((i + 1) < args.length) {
String val = args[i + 1];
for (int i = 0; i < args.size(); i++) {
if (args.get(i).startsWith("-")) {
String key = args.get(i).substring(1);
if ((i + 1) < args.size()) {
String val = args.get(i + 1);
if (!val.startsWith("-")) {
settings.put(key, val);
i++;
@ -76,7 +68,7 @@ public class Emulator {
settings.put(key, "true");
}
} else {
System.err.println("Did not understand parameter " + args[i] + ", skipping.");
System.err.println("Did not understand parameter " + args.get(i) + ", skipping.");
}
}
}

View File

@ -39,15 +39,15 @@ public class JaceApplication extends Application {
}
primaryStage.show();
Emulator e = new Emulator();
Emulator emulator = new Emulator(getParameters().getRaw());
javafx.application.Platform.runLater(() -> {
while (Emulator.computer.getVideo() == null || Emulator.computer.getVideo().getFrameBuffer() == null) {
Thread.yield();
}
controller.connectComputer(Emulator.computer);
});
primaryStage.setOnCloseRequest(value -> {
Emulator.computer.deactivate();
primaryStage.setOnCloseRequest(event->{
emulator.computer.deactivate();
Platform.exit();
System.exit(0);
});

View File

@ -18,7 +18,6 @@
*/
package jace.core;
import jace.Emulator;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.io.File;
@ -46,9 +45,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
@ -96,7 +93,7 @@ public class Utility {
try {
// Try to create an instance of the object
String className = pckgname + "." + classname;
System.out.println("Class: " + className);
// System.out.println("Class: " + className);
Class c = Class.forName(className);
if (clazz.isAssignableFrom(c)) {
output.add(c);