/**
*
*/
public GameOptionsScreen() {
super();
gameOptions = new GameOptionsManager().load();
JPanel options = new JPanel();
options.setLayout(new GridLayout(4,2));
options.add(new JLabel(LanguageFactory.getInstance().getString(MessageId.BID_TYPE)));
final JComboBox bid = new JComboBox();
for(BidType bidType : BidType.values()) {
bid.addItem(bidType);
}
bid.setSelectedItem(gameOptions.getBidType());
options.add(bid);
bid.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
gameOptions.setBidType((BidType) bid.getSelectedItem());
}
});
options.add(new JLabel(LanguageFactory.getInstance().getString(MessageId.GAME_SPEED)));
final JComboBox gameSpeed = new JComboBox();
for(GameSpeed gameSpeed2 : GameSpeed.values()) {
gameSpeed.addItem(gameSpeed2);
}
gameSpeed.setSelectedItem(gameOptions.getGameSpeed());
options.add(gameSpeed);
gameSpeed.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
gameOptions.setGameSpeed((GameSpeed) gameSpeed.getSelectedItem());
}
});
options.add(new JLabel("Total Number Of Players"));
options.add(totalNumberOfPlayers);
totalNumberOfPlayers.setText(String.valueOf(gameOptions.getTotalNumberOfPlayers()));
options.add(new JLabel("Total Human Players"));
options.add(totalHumanPlayers);
totalHumanPlayers.setText(String.valueOf(gameOptions.getTotalHumanPlayers()));
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel buttonPanel = new JPanel();
JButton ok = new JButton(LanguageFactory.getInstance().getString(MessageId.ok));
buttonPanel.add(ok);
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
block = false;
gameOptions.setTotalNumberOfPlayers(Integer.parseInt(totalNumberOfPlayers.getText().trim()));
gameOptions.setTotalHumanPlayers(Integer.parseInt(totalHumanPlayers.getText().trim()));
new GameOptionsManager().persist(gameOptions);
setVisible(false);
dispose();
}
});
JButton cancel = new JButton(LanguageFactory.getInstance().getString(MessageId.CANCEL));
buttonPanel.add(cancel);
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
block = false;
gameOptions = new GameOptionsManager().load();
setVisible(false);
dispose();
}
});