Simplified EngineUtil and MenuBar
This commit is contained in:
parent
8077aaafdb
commit
d173fb7851
@ -30,7 +30,7 @@ public class EngineUtil {
|
|||||||
|
|
||||||
private EngineUtil() {}
|
private EngineUtil() {}
|
||||||
|
|
||||||
public static void addEngine(String enginePath, Runnable followup) {
|
public static void addEngine(String enginePath) {
|
||||||
try {
|
try {
|
||||||
EngineInfo info = new EngineInfo(enginePath);
|
EngineInfo info = new EngineInfo(enginePath);
|
||||||
UCIHandle handle = new UCIHandle(enginePath);
|
UCIHandle handle = new UCIHandle(enginePath);
|
||||||
@ -51,7 +51,6 @@ public class EngineUtil {
|
|||||||
engineInfos.add(info);
|
engineInfos.add(info);
|
||||||
handle.quit();
|
handle.quit();
|
||||||
saveEngineInfos();
|
saveEngineInfos();
|
||||||
followup.run();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handle.start();
|
handle.start();
|
||||||
|
@ -9,7 +9,6 @@ import javax.swing.JMenuItem;
|
|||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
import dev.kske.chess.game.Game;
|
import dev.kske.chess.game.Game;
|
||||||
import dev.kske.chess.ui.EngineUtil.EngineInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: <strong>Chess</strong><br>
|
* Project: <strong>Chess</strong><br>
|
||||||
@ -52,37 +51,19 @@ public class MenuBar extends JMenuBar {
|
|||||||
private void initEngineMenu() {
|
private void initEngineMenu() {
|
||||||
JMenu engineMenu = new JMenu("Engine");
|
JMenu engineMenu = new JMenu("Engine");
|
||||||
|
|
||||||
// TODO: Adjust menu
|
|
||||||
|
|
||||||
JMenuItem addEngineMenuItem = new JMenuItem("Add engine");
|
JMenuItem addEngineMenuItem = new JMenuItem("Add engine");
|
||||||
addEngineMenuItem.addActionListener((evt) -> {
|
addEngineMenuItem.addActionListener((evt) -> {
|
||||||
String enginePath = JOptionPane.showInputDialog(getParent(),
|
String enginePath = JOptionPane.showInputDialog(getParent(),
|
||||||
"Enter the path to a UCI-compatible chess engine:",
|
"Enter the path to a UCI-compatible chess engine:",
|
||||||
"Engine selection",
|
"Engine selection",
|
||||||
JOptionPane.QUESTION_MESSAGE);
|
JOptionPane.QUESTION_MESSAGE);
|
||||||
if (enginePath != null) {
|
if (enginePath != null) EngineUtil.addEngine(enginePath);
|
||||||
EngineUtil.addEngine(enginePath, () -> {
|
|
||||||
EngineInfo info = EngineUtil.getEngineInfos()
|
|
||||||
.get(EngineUtil.getEngineInfos().size() - 1);
|
|
||||||
/*
|
|
||||||
* JMenuItem engineMenuItem = new JMenuItem(info.name);
|
|
||||||
* engineMenuItem.addActionListener((evt2) ->
|
|
||||||
* startGame(Game.createUCI(boardPane, info.path)));
|
|
||||||
* engineMenu.add(engineMenuItem);
|
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
engineMenu.add(addEngineMenuItem);
|
|
||||||
|
|
||||||
/*
|
JMenuItem showInfoMenuItem = new JMenuItem("Show engine info");
|
||||||
* for (EngineInfo info : EngineUtil.getEngineInfos()) {
|
|
||||||
* JMenuItem engineMenuItem = new JMenuItem(info.name);
|
engineMenu.add(addEngineMenuItem);
|
||||||
* engineMenuItem.addActionListener((evt) -> startGame(Game.createUCI(boardPane,
|
engineMenu.add(showInfoMenuItem);
|
||||||
* info.path)));
|
|
||||||
* engineMenu.add(engineMenuItem);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
add(engineMenu);
|
add(engineMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user