Fixed engine menu reloading on engine addition
This commit is contained in:
parent
490d42548c
commit
758205e5a5
@ -103,8 +103,6 @@ public class Board implements Cloneable {
|
||||
Piece piece = getPos(move);
|
||||
Piece capturePiece = getDest(move);
|
||||
|
||||
// TODO: reset halfmove clock
|
||||
|
||||
switch (move.type) {
|
||||
case PAWN_PROMOTION:
|
||||
setPos(move, null);
|
||||
|
@ -30,7 +30,7 @@ public class EngineUtil {
|
||||
|
||||
private EngineUtil() {}
|
||||
|
||||
public static void addEngine(String enginePath) {
|
||||
public static void addEngine(String enginePath, Runnable followup) {
|
||||
try {
|
||||
EngineInfo info = new EngineInfo(enginePath);
|
||||
UCIHandle handle = new UCIHandle(enginePath);
|
||||
@ -51,6 +51,7 @@ public class EngineUtil {
|
||||
engineInfos.add(info);
|
||||
handle.quit();
|
||||
saveEngineInfos();
|
||||
followup.run();
|
||||
}
|
||||
});
|
||||
handle.start();
|
||||
|
@ -81,8 +81,13 @@ public class MenuBar extends JMenuBar {
|
||||
"Engine selection",
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
if (enginePath != null) {
|
||||
EngineUtil.addEngine(enginePath);
|
||||
// TODO: Rebuilt the engine menu
|
||||
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);
|
||||
|
Reference in New Issue
Block a user