mirror of
https://github.com/sethm/symon.git
synced 2025-08-09 11:25:13 +00:00
add menu entry to allow to switch the emulated machine type
This commit is contained in:
@@ -40,9 +40,9 @@ public class Main {
|
|||||||
*
|
*
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) throws Exception {
|
||||||
|
|
||||||
Class machineClass = null;
|
Class machineClass = SymonMachine.class;
|
||||||
for(int i = 0; i < args.length; ++i) {
|
for(int i = 0; i < args.length; ++i) {
|
||||||
String arg = args[i].toLowerCase(Locale.ENGLISH);
|
String arg = args[i].toLowerCase(Locale.ENGLISH);
|
||||||
if(arg.equals("-machine") && (i+1) < args.length) {
|
if(arg.equals("-machine") && (i+1) < args.length) {
|
||||||
@@ -55,38 +55,46 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(machineClass == null) {
|
while(true) {
|
||||||
Object[] possibilities = {"Symon", "Multicomp"};
|
if(machineClass == null) {
|
||||||
String s = (String)JOptionPane.showInputDialog(
|
Object[] possibilities = {"Symon", "Multicomp"};
|
||||||
null,
|
String s = (String)JOptionPane.showInputDialog(
|
||||||
"Please choose the machine type to be emulated:",
|
null,
|
||||||
"Machine selection",
|
"Please choose the machine type to be emulated:",
|
||||||
JOptionPane.PLAIN_MESSAGE,
|
"Machine selection",
|
||||||
null,
|
JOptionPane.PLAIN_MESSAGE,
|
||||||
possibilities,
|
null,
|
||||||
"Symon");
|
possibilities,
|
||||||
if(s.equals("Symon")) {
|
"Symon");
|
||||||
machineClass = SymonMachine.class;
|
if(s.equals("Symon")) {
|
||||||
} else {
|
machineClass = SymonMachine.class;
|
||||||
machineClass = MulticompMachine.class;
|
} else {
|
||||||
}
|
machineClass = MulticompMachine.class;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final Class mClass = machineClass;
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
||||||
// Create the main UI window
|
|
||||||
Simulator simulator = new Simulator(mClass);
|
|
||||||
simulator.createAndShowUi();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
|
final Simulator simulator = new Simulator(machineClass);
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
// Create the main UI window
|
||||||
|
simulator.createAndShowUi();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Simulator.MAIN_CMD cmd = simulator.waitForCommand();
|
||||||
|
if(cmd.equals(Simulator.MAIN_CMD.SELECTMACHINE)) {
|
||||||
|
machineClass = null;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -116,6 +116,13 @@ public class Simulator {
|
|||||||
private JFileChooser fileChooser;
|
private JFileChooser fileChooser;
|
||||||
private PreferencesDialog preferences;
|
private PreferencesDialog preferences;
|
||||||
|
|
||||||
|
private final Object commandMonitorObject = new Object();
|
||||||
|
private MAIN_CMD command = MAIN_CMD.NONE;
|
||||||
|
public static enum MAIN_CMD {
|
||||||
|
NONE,
|
||||||
|
SELECTMACHINE
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of step counts that will appear in the "Step" drop-down.
|
* The list of step counts that will appear in the "Step" drop-down.
|
||||||
*/
|
*/
|
||||||
@@ -230,6 +237,18 @@ public class Simulator {
|
|||||||
console.requestFocus();
|
console.requestFocus();
|
||||||
handleReset();
|
handleReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MAIN_CMD waitForCommand() {
|
||||||
|
synchronized(commandMonitorObject) {
|
||||||
|
try {
|
||||||
|
commandMonitorObject.wait();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleStart() {
|
private void handleStart() {
|
||||||
// Shift focus to the console.
|
// Shift focus to the console.
|
||||||
@@ -543,6 +562,34 @@ public class Simulator {
|
|||||||
preferences.getDialog().setVisible(true);
|
preferences.getDialog().setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SelectMachineAction extends AbstractAction {
|
||||||
|
Simulator simulator;
|
||||||
|
|
||||||
|
public SelectMachineAction() {
|
||||||
|
super("Switch emulated machine...", null);
|
||||||
|
putValue(SHORT_DESCRIPTION, "Select the type of the machine to be emulated");
|
||||||
|
putValue(MNEMONIC_KEY, KeyEvent.VK_M);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
|
if(runLoop != null) {
|
||||||
|
runLoop.requestStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
memoryWindow.dispose();
|
||||||
|
traceLog.dispose();
|
||||||
|
if(videoWindow != null) {
|
||||||
|
videoWindow.dispose();
|
||||||
|
}
|
||||||
|
mainWindow.dispose();
|
||||||
|
|
||||||
|
command = MAIN_CMD.SELECTMACHINE;
|
||||||
|
synchronized(commandMonitorObject) {
|
||||||
|
commandMonitorObject.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class QuitAction extends AbstractAction {
|
class QuitAction extends AbstractAction {
|
||||||
public QuitAction() {
|
public QuitAction() {
|
||||||
@@ -669,11 +716,13 @@ public class Simulator {
|
|||||||
loadProgramItem = new JMenuItem(new LoadProgramAction());
|
loadProgramItem = new JMenuItem(new LoadProgramAction());
|
||||||
loadRomItem = new JMenuItem(new LoadRomAction());
|
loadRomItem = new JMenuItem(new LoadRomAction());
|
||||||
JMenuItem prefsItem = new JMenuItem(new ShowPrefsAction());
|
JMenuItem prefsItem = new JMenuItem(new ShowPrefsAction());
|
||||||
|
JMenuItem selectMachineItem = new JMenuItem(new SelectMachineAction());
|
||||||
JMenuItem quitItem = new JMenuItem(new QuitAction());
|
JMenuItem quitItem = new JMenuItem(new QuitAction());
|
||||||
|
|
||||||
fileMenu.add(loadProgramItem);
|
fileMenu.add(loadProgramItem);
|
||||||
fileMenu.add(loadRomItem);
|
fileMenu.add(loadRomItem);
|
||||||
fileMenu.add(prefsItem);
|
fileMenu.add(prefsItem);
|
||||||
|
fileMenu.add(selectMachineItem);
|
||||||
fileMenu.add(quitItem);
|
fileMenu.add(quitItem);
|
||||||
|
|
||||||
add(fileMenu);
|
add(fileMenu);
|
||||||
|
Reference in New Issue
Block a user