customizeMech();
} else if (ev.getSource().equals(butDelete)) {
// delete mech
Entity e = client.getEntity(entityCorrespondance[lisEntities
.getSelectedIndex()]);
Client c = clientgui.getBots().get(e.getOwner().getName());
if (c == null) {
c = client;
}
if (lisEntities.getSelectedIndex() != -1) {
c.sendDeleteEntity(entityCorrespondance[lisEntities
.getSelectedIndex()]);
}
} else if (ev.getSource().equals(butDeleteAll)) {
// Build a Vector of this player's entities.
ArrayList<Entity> currentUnits = client.game.getPlayerEntities(
client.getLocalPlayer(), false);
// Walk through the vector, deleting the entities.
Iterator<Entity> entities = currentUnits.iterator();
while (entities.hasNext()) {
final Entity entity = entities.next();
client.sendDeleteEntity(entity.getId());
}
} else if (ev.getSource().equals(butChangeBoard)
|| ev.getSource().equals(lisBoardsSelected)) {
// board settings
clientgui.getBoardSelectionDialog().update(client.getMapSettings(),
true);
clientgui.getBoardSelectionDialog().setVisible(true);
} else if (ev.getSource().equals(butOptions)) {
// Make sure the game options dialog is editable.
if (!clientgui.getGameOptionsDialog().isEditable()) {
clientgui.getGameOptionsDialog().setEditable(true);
}
// Display the game options dialog.
clientgui.getGameOptionsDialog().update(client.game.getOptions());
clientgui.getGameOptionsDialog().setVisible(true);
} else if (ev.getSource().equals(butChangeStart)
|| ev.getSource().equals(lisStarts)) {
clientgui.getStartingPositionDialog().update();
Client c = getPlayerListSelected(lisStarts);
if (c == null) {
clientgui
.doAlertDialog(
Messages
.getString("ChatLounge.ImproperCommand"), Messages.getString("ChatLounge.SelectBotOrPlayer")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
clientgui.getStartingPositionDialog().setClient(c);
clientgui.getStartingPositionDialog().setVisible(true);
} else if (ev.getSource().equals(butMechReadout)) {
mechReadout();
} else if (ev.getSource().equals(butViewGroup)) {
viewGroup();
} else if (ev.getSource().equals(butLoadList)) {
// Allow the player to replace their current
// list of entities with a list from a file.
clientgui.loadListFile();
} else if (ev.getSource().equals(butSaveList)) {
// Allow the player to save their current
// list of entities to a file.
clientgui.saveListFile(client.game.getPlayerEntities(client
.getLocalPlayer(), false));
} else if (ev.getSource().equals(butMinefield)) {
updateMinefield();
} else if (ev.getSource().equals(butCamo)) {
camoDialog.setVisible(true);
} else if (ev.getSource() == butInit) {
// alert about teams
if (clientgui.client.game.getOptions().booleanOption(
"team_initiative")) {
JOptionPane
.showMessageDialog(
clientgui.frame,
Messages
.getString("ChatLounge.InitiativeAlert.message"),
Messages
.getString("ChatLounge.InitiativeAlert.title"), JOptionPane.INFORMATION_MESSAGE); //$NON-NLS-1$
}
Client c = getPlayerListSelected(lisPlayerInfo);
if (c == null) {
clientgui
.doAlertDialog(
Messages
.getString("ChatLounge.ImproperCommand"), Messages.getString("ChatLounge.SelectBotOrPlayer")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
clientgui.getCustomInitiativeDialog().setClient(c);
clientgui.getCustomInitiativeDialog().updateValues();
clientgui.getCustomInitiativeDialog().setVisible(true);
} else if (ev.getSource().equals(butAddBot)) {
String name = "Bot" + lisPlayerInfo.getModel().getSize(); //$NON-NLS-1$
name = (String) JOptionPane.showInputDialog(clientgui.frame,
Messages.getString("ChatLounge.Name"), Messages
.getString("ChatLounge.ChooseBotName"),
JOptionPane.QUESTION_MESSAGE, null, null, name);
if (name == null) {
return;
}
if ("".equals(name.trim())) {
name = "Bot" + lisPlayerInfo.getModel().getSize(); //$NON-NLS-1$
}
BotClient c = new TestBot(name, client.getHost(), client.getPort());
c.game.addGameListener(new BotGUI(c));
try {
c.connect();
} catch (Exception e) {
clientgui
.doAlertDialog(
Messages.getString("ChatLounge.AlertBot.title"), Messages.getString("ChatLounge.AlertBot.message")); //$NON-NLS-1$ //$NON-NLS-2$
}
c.retrieveServerInfo();
clientgui.getBots().put(name, c);
} else if (ev.getSource().equals(butRemoveBot)) {
Client c = getPlayerListSelected(lisPlayerInfo);
if ((c == null) || c.equals(client)) {
clientgui
.doAlertDialog(
Messages
.getString("ChatLounge.ImproperCommand"), Messages.getString("ChatLounge.SelectBo")); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
c.die();
clientgui.getBots().remove(c.getName());
} else if (ev.getSource() == butConditions) {
// Display the game options dialog.
clientgui.getPlanetaryConditionsDialog().update(
client.game.getPlanetaryConditions());
clientgui.getPlanetaryConditionsDialog().setVisible(true);