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 15fc153dac
commit 00eea6d863
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13

View File

@ -38,7 +38,9 @@ public class MenuBar extends JMenuBar {
dialog.setVisible(true); dialog.setVisible(true);
if (dialog.isStartGame()) { if (dialog.isStartGame()) {
GamePane gamePane = mainWindow.addGamePane(); 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); gameMenu.add(newGameMenuItem);
@ -56,7 +58,8 @@ public class MenuBar extends JMenuBar {
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:", "Engine selection", "Enter the path to a UCI-compatible chess engine:",
"Engine selection",
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (enginePath != null) EngineUtil.addEngine(enginePath); if (enginePath != null) EngineUtil.addEngine(enginePath);
}); });