Fix for double boards when the player starts the game by clicking 'play' instead of pressing <Enter>.
This commit is contained in:
@@ -31,8 +31,10 @@ public class UserChooserFrame extends JFrame {
|
||||
private final Player comPlayer;
|
||||
private final JButton playButton = new JButton("Play!");
|
||||
private final JComboBox<String> userNameBox = new JComboBox<String>();
|
||||
|
||||
private ArrayList<String> users;
|
||||
|
||||
private boolean gameLaunched = false;
|
||||
|
||||
public UserChooserFrame(ParsedArgs parsedArgs) {
|
||||
this.comPlayer = parsedArgs.getComPlayer();
|
||||
initLayout();
|
||||
@@ -143,6 +145,10 @@ public class UserChooserFrame extends JFrame {
|
||||
}
|
||||
|
||||
void launchSelectedPlayer() {
|
||||
if (gameLaunched) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = ((String) userNameBox.getSelectedItem());
|
||||
name = name == null ? name : name.trim().toLowerCase();
|
||||
|
||||
@@ -162,6 +168,7 @@ public class UserChooserFrame extends JFrame {
|
||||
|
||||
saveUserList();
|
||||
new MainFrame(name, comPlayer);
|
||||
gameLaunched = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user