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