Client getPlayerSelected() { if ((tablePlayers == null) || (tablePlayers.getSelectedRow() == -1)) { return clientgui.getClient(); } String name = (String) tablePlayers.getValueAt(tablePlayers.getSelectedRow(), 0); BotClient c = (BotClient) clientgui.getBots().get(name); if ((c == null) && clientgui.getClient().getName().equals(name)) { return clientgui.getClient(); } return c; }
/** * Construct a client which will display itself in a new frame. It will not * try to connect to a server yet. When the frame closes, this client will * clean up after itself as much as possible, but will not call * System.exit(). */ public ClientGUI(Client client, MegaMekController c) { super(new BorderLayout()); this.addComponentListener(this); this.client = client; controller = c; loadSoundClip(); panMain.setLayout(cardsMain); panSecondary.setLayout(cardsSecondary); JPanel panDisplay = new JPanel(new BorderLayout()); panDisplay.add(panMain, BorderLayout.CENTER); panDisplay.add(panSecondary, BorderLayout.SOUTH); add(panDisplay, BorderLayout.CENTER); }
@Override public void gamePlayerChat(GamePlayerChatEvent e) { bing(); }
public void mechEdit(Entity entity) { boolean editable = clientgui.getBots().get(entity.getOwner().getName()) != null; Client c; if (editable) { c = clientgui.getBots().get(entity.getOwner().getName()); } else { editable |= entity.getOwnerId() == clientgui.getClient().getLocalPlayer().getId(); c = clientgui.getClient(); } // display dialog UnitEditorDialog med = new UnitEditorDialog(clientgui.getFrame(), entity); // med.setPlayer(c.getLocalPlayer()); med.setVisible(true); c.sendUpdateEntity(entity); /* * if (editable && med.isSelect()) { // send changes * c.sendUpdateEntity(entity); } */ }
showAbout(); showSkinningHowTo(); showHelp(); doSaveUnit(); ignoreHotKeys = false; loadListFile(); ignoreHotKeys = false; deleteAllUnits(client); loadListFile(client.getLocalPlayer(), true); ignoreHotKeys = false; getRandomArmyDialog().setVisible(true); ignoreHotKeys = false; showSettings(); showOptions(); customizePlayer(); showPlayerList(); showRoundReport();
ClientGUI gui = new ClientGUI(client, controller); controller.clientgui = gui; frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); gui.initialize(); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (!client.connect()) { client.die(); launch(gui.getFrame());
clientgui.doAlertDialog(Messages.getString("ChatLounge.ImproperCommand"), Messages.getString("ChatLounge.SelectBotOrPlayer")); //$NON-NLS-1$ //$NON-NLS-2$ return; clientgui.deleteAllUnits(c); } else if (ev.getSource().equals(butOptions)) { if (!clientgui.getGameOptionsDialog().isEditable()) { clientgui.getGameOptionsDialog().setEditable(true); clientgui.getGameOptionsDialog().update(clientgui.getClient().getGame().getOptions()); clientgui.getGameOptionsDialog().setVisible(true); } else if (ev.getSource().equals(butCompact)) { if (butCompact.isSelected()) { clientgui.getStartingPositionDialog().update(); Client c = getPlayerSelected(); 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(butLoadList)) { clientgui.doAlertDialog(Messages.getString("ChatLounge.ImproperCommand"), Messages.getString("ChatLounge.SelectBotOrPlayer")); //$NON-NLS-1$ //$NON-NLS-2$ return;
for (Client client2 : swingGui.getBots().values()) { client2.die(); swingGui.getBots().clear(); swingGui = new ClientGUI(client, controller); controller.clientgui = swingGui; swingGui.initialize();
bv.clearMovementData(); bv.clearFieldofF(); for (Client client2 : getBots().values()) { client2.die(); getBots().clear(); ArrayList<Entity> living = getClient().getGame().getPlayerEntities(getClient().getLocalPlayer(), false); for (Enumeration<Entity> iter = getClient().getGame().getRetreatedEntities(); iter.hasMoreElements(); ) { Entity ent = iter.nextElement(); if (ent.getOwnerId() == getClient().getLocalPlayer().getId()) { living.add(ent); if (!living.isEmpty() && doYesNoDialog(Messages.getString("ClientGUI.SaveUnitsDialog.title"), //$NON-NLS-1$ Messages.getString("ClientGUI.SaveUnitsDialog.message"))) { //$NON-NLS-1$ saveVictoryList(); Enumeration<Entity> graveyard = getClient().getGame().getGraveyardEntities(); while (graveyard.hasMoreElements()) { Entity entity = graveyard.nextElement(); } catch (IOException excep) { excep.printStackTrace(System.err); doAlertDialog(Messages.getString("ClientGUI.errorSavingFile"), excep.getMessage()); //$NON-NLS-1$
@Override public void ready() { final Client client = clientgui.getClient(); final IGame game = client.getGame(); final GameOptions gOpts = game.getOptions(); clientgui.doAlertDialog(Messages.getString("ChatLounge.ExclusiveDeploy.title"), //$NON-NLS-1$ Messages.getString("ChatLounge.ExclusiveDeploy.msg")); //$NON-NLS-1$ return; || ((player.getStartingPos() - 1) == i)) && (player.getId() != client.getLocalPlayer().getId())) { clientgui.doAlertDialog(Messages.getString("ChatLounge.OverlapDeploy.title"), //$NON-NLS-1$ Messages.getString("ChatLounge.OverlapDeploy.msg")); //$NON-NLS-1$ return; players.add(client.getLocalPlayer().getName()); for (Client bc : clientgui.getBots().values()) { if ((game.getLiveCommandersOwnedBy(bc.getLocalPlayer()) < 1) && (game.getEntitiesOwnedBy(bc.getLocalPlayer()) > 0)) { clientgui.doAlertDialog(title, msg); return; client.sendDone(done); refreshDoneButton(done); for (Client client2 : clientgui.getBots().values()) { client2.sendDone(done);
@Override protected void correctName(Packet inP) { // If we have a clientgui, it keeps track of a Name -> Client map, and // we need to update that map with this name change. if (getClientGUI() != null) { Map<String, Client> bots = getClientGUI().getBots(); String oldName = getName(); String newName = (String) (inP.getObject(0)); assert (equals(bots.get(oldName))); bots.remove(oldName); bots.put(newName, this); } setName((String) (inP.getObject(0))); }
if (m_chPlayer.getSelectedIndex() > 0) { String name = (String) m_chPlayer.getSelectedItem(); c = m_clientgui.getBots().get(name); updateRATs(); } else if (ev.getSource().equals(m_bRandomSkills)) { m_clientgui.getRandomSkillDialog().showDialog();
/** * Checks to see if there is already a path and name stored; if not, calls * "save as"; otherwise, saves the board to the specified file. */ private void boardSave() { if (curfileBoard == null) { boardSaveAs(); return; } // save! try { OutputStream os = new FileOutputStream(curfileBoard); // tell the board to save! client.getGame().getBoard().save(os); // okay, done! os.close(); } catch (IOException ex) { System.err.println("error opening file to save!"); //$NON-NLS-1$ System.err.println(ex); } }
boardSaveImage(ignoreUnits);
/** * Saves the board in PNG image format. */ private void boardSaveImage(boolean ignoreUnits) { if (curfileBoardImage == null) { boardSaveAsImage(ignoreUnits); return; } JDialog waitD = new JDialog(frame, Messages .getString("BoardEditor.waitDialog.title")); //$NON-NLS-1$ waitD.add(new JLabel(Messages .getString("BoardEditor.waitDialog.message"))); //$NON-NLS-1$ waitD.setSize(250, 130); // move to middle of screen waitD.setLocation( (frame.getSize().width / 2) - (waitD.getSize().width / 2), (frame .getSize().height / 2) - (waitD.getSize().height / 2)); waitD.setVisible(true); frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); waitD.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // save! try { ImageIO.write(bv.getEntireBoardImage(ignoreUnits), "png", curfileBoardImage); } catch (IOException e) { e.printStackTrace(); } waitD.setVisible(false); frame.setCursor(Cursor.getDefaultCursor()); }
ClientGUI gui = new ClientGUI(client, controller); controller.clientgui = gui; frame.setCursor(new Cursor(Cursor.WAIT_CURSOR)); gui.initialize(); frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); if (!client.connect()) { client.die(); launch(gui.getFrame());
for (Client client2 : swingGui.getBots().values()) { client2.die(); swingGui.getBots().clear(); swingGui = new ClientGUI(client, controller); controller.clientgui = swingGui; swingGui.initialize(); BotForce bf = scenario.getBotForce(i); String name = bf.getName(); if (swingGui.getBots().containsKey(name)) { int append = 2; while (swingGui.getBots().containsKey(name + append)) { append++; MekHQ.getLogger().error(getClass(), "run", e); //$NON-NLS-1$ swingGui.getBots().put(name, botClient);
editable = clientgui.getBots().get(entity.getOwner().getName()) != null; Client c; if (editable) { c = clientgui.getBots().get(entity.getOwner().getName()); } else { editable |= entity.getOwnerId() == clientgui.getClient().getLocalPlayer().getId(); c = clientgui.getClient(); CamoChoiceDialog mcd = new CamoChoiceDialog(clientgui.getFrame(), null); mcd.setPlayer(c.getLocalPlayer()); mcd.setEntity(entity);
void select(boolean close) { Entity e = getSelectedEntity(); if (useAlternate) { // For MML chosenEntity = e; } else if (null != e) { Client c = null; if (comboPlayer.getSelectedIndex() > 0) { String name = (String) comboPlayer.getSelectedItem(); c = clientgui.getBots().get(name); } if (c == null) { c = client; } autoSetSkillsAndName(e); e.setOwner(c.getLocalPlayer()); c.sendAddEntity(e); } if (close) { setVisible(false); } }