Fixed frozen game after adding a new one

This commit is contained in:
Kai S. K. Engelbart 2019-09-06 13:24:58 +02:00
parent 875cd22521
commit 897353efeb

View File

@ -38,7 +38,9 @@ public class MenuBar extends JMenuBar {
dialog.setVisible(true);
if (dialog.isStartGame()) {
GamePane gamePane = mainWindow.addGamePane();
gamePane.setGame(new Game(gamePane.getBoardPane(), dialog.getWhiteName(), dialog.getBlackName()));
Game game = new Game(gamePane.getBoardPane(), dialog.getWhiteName(), dialog.getBlackName());
gamePane.setGame(game);
game.start();
}
});
gameMenu.add(newGameMenuItem);
@ -56,7 +58,8 @@ public class MenuBar extends JMenuBar {
JMenuItem addEngineMenuItem = new JMenuItem("Add engine");
addEngineMenuItem.addActionListener((evt) -> {
String enginePath = JOptionPane.showInputDialog(getParent(),
"Enter the path to a UCI-compatible chess engine:", "Engine selection",
"Enter the path to a UCI-compatible chess engine:",
"Engine selection",
JOptionPane.QUESTION_MESSAGE);
if (enginePath != null) EngineUtil.addEngine(enginePath);
});