entities) {
sendUpdate(updateCandidates);
}
- /**
+ /**
* Returns true when the given entity may be configured by the local player,
* i.e. if it is his own unit or one of his bot's units.
* Note that this is more restrictive than the Server is. The Server
- * accepts entity changes also for teammates so that entity updates that
+ * accepts entity changes also for teammates so that entity updates that
* signal transporting a teammate's unit don't get rejected. I feel that
* configuration other than transporting units should be limited to one's
* own units (and bots) though.
*/
boolean isEditable(Entity entity) {
- return clientgui.getBots().containsKey(entity.getOwner().getName())
+ return clientgui.getLocalBots().containsKey(entity.getOwner().getName())
|| (entity.getOwnerId() == localPlayer().getId());
}
-
- /**
+
+ /**
* Returns true when the given entity may NOT be configured by the local player,
* i.e. if it is not own unit or one of his bot's units.
* @see #isEditable(Entity)
@@ -1495,8 +1494,8 @@ boolean isEditable(Entity entity) {
boolean isNotEditable(Entity entity) {
return !isEditable(entity);
}
-
- /**
+
+ /**
* Returns true when all given entities may be configured by the local player,
* i.e. if they are his own units or one of his bot's units.
* @see #isEditable(Entity)
@@ -1504,16 +1503,16 @@ boolean isNotEditable(Entity entity) {
boolean isEditable(Collection entities) {
return !entities.stream().anyMatch(this::isNotEditable);
}
-
- /**
+
+ /**
* Returns the Client associated with a given entity that may be configured
* by the local player (his own unit or one of his bot's units).
* For a unit that cannot be configured (owned by a remote player) the client
* of the local player is returned.
*/
Client getLocalClient(Entity entity) {
- if (clientgui.getBots().containsKey(entity.getOwner().getName())) {
- return clientgui.getBots().get(entity.getOwner().getName());
+ if (clientgui.getLocalBots().containsKey(entity.getOwner().getName())) {
+ return clientgui.getLocalBots().get(entity.getOwner().getName());
} else {
return clientgui.getClient();
}
@@ -1524,7 +1523,7 @@ public void configPlayer() {
if (null == c) {
return;
}
-
+
PlayerSettingsDialog psd = new PlayerSettingsDialog(clientgui, c);
if (psd.showDialog().isConfirmed()) {
Player player = c.getLocalPlayer();
@@ -1539,16 +1538,16 @@ public void configPlayer() {
// The deployment position
int startPos = psd.getStartPos();
final GameOptions gOpts = clientgui.getClient().getGame().getOptions();
-
+
player.setStartingPos(startPos);
player.setStartOffset(psd.getStartOffset());
player.setStartWidth(psd.getStartWidth());
c.sendPlayerInfo();
-
- // If the gameoption set_arty_player_homeedge is set, adjust the player's offboard
+
+ // If the gameoption set_arty_player_homeedge is set, adjust the player's offboard
// arty units to be behind the newly selected home edge.
OffBoardDirection direction = OffBoardDirection.translateStartPosition(startPos);
- if (direction != OffBoardDirection.NONE &&
+ if (direction != OffBoardDirection.NONE &&
gOpts.booleanOption(OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE)) {
for (Entity entity: c.getGame().getPlayerEntities(c.getLocalPlayer(), false)) {
if (entity.getOffBoardDirection() != OffBoardDirection.NONE) {
@@ -1566,7 +1565,7 @@ private void addUnit() {
clientgui.getMechSelectorDialog().updateOptionValues();
clientgui.getMechSelectorDialog().setVisible(true);
}
-
+
private void createArmy() {
clientgui.getRandomArmyDialog().setVisible(true);
}
@@ -1612,7 +1611,7 @@ public void gamePhaseChange(GamePhaseChangeEvent e) {
if (isIgnoringEvents()) {
return;
}
-
+
if (clientgui.getClient().getGame().getPhase().isLounge()) {
refreshDoneButton();
refreshGameSettings();
@@ -1658,7 +1657,7 @@ public void gameSettingsChange(GameSettingsChangeEvent e) {
public void gameClientFeedbackRequest(GameCFREvent evt) {
// Do nothing
}
-
+
private ActionListener lobbyListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent ev) {
@@ -1666,7 +1665,7 @@ public void actionPerformed(ActionEvent ev) {
if (isIgnoringEvents()) {
return;
}
-
+
if (ev.getSource().equals(butAdd)) {
addUnit();
} else if (ev.getSource().equals(butArmy)) {
@@ -1700,7 +1699,7 @@ public void actionPerformed(ActionEvent ev) {
return;
}
clientgui.loadListFile(c.getLocalPlayer());
-
+
} else if (ev.getSource().equals(butSaveList)) {
// Allow the player to save their current
// list of entities to a file.
@@ -1712,32 +1711,32 @@ public void actionPerformed(ActionEvent ev) {
}
clientgui.saveListFile(c.getGame().getPlayerEntities(c.getLocalPlayer(), false),
c.getLocalPlayer().getName());
-
+
} else if (ev.getSource().equals(butAddBot)) {
configAndCreateBot(null);
-
+
} else if (ev.getSource().equals(butRemoveBot)) {
removeBot();
-
+
} else if (ev.getSource().equals(butShowUnitID)) {
PreferenceManager.getClientPreferences().setShowUnitId(butShowUnitID.isSelected());
mekModel.refreshCells();
repaint();
-
+
} else if (ev.getSource() == butConditions) {
PlanetaryConditionsDialog pcd = new PlanetaryConditionsDialog(clientgui);
boolean userOkay = pcd.showDialog();
if (userOkay) {
clientgui.getClient().sendPlanetaryConditions(pcd.getConditions());
}
-
+
} else if (ev.getSource() == butRandomMap) {
RandomMapDialog rmd = new RandomMapDialog(clientgui.frame, ChatLounge.this, clientgui.getClient(), mapSettings);
rmd.activateDialog(clientgui.getBoardView().getTilesetManager().getThemes());
-
+
} else if (ev.getSource().equals(butBoardPreview)) {
previewGameBoard();
-
+
} else if (ev.getSource().equals(comMapSizes)) {
if (Messages.getString("ChatLounge.CustomMapSize").equals(comMapSizes.getSelectedItem())) {
refreshMapUI();
@@ -1747,67 +1746,67 @@ public void actionPerformed(ActionEvent ev) {
resetAvailBoardSelection = true;
resetSelectedBoards = true;
clientgui.getClient().sendMapSettings(mapSettings);
- }
-
+ }
+
} else if (ev.getSource() == butGroundMap) {
mapSettings.setMedium(MapSettings.MEDIUM_GROUND);
refreshMapUI();
clientgui.getClient().sendMapSettings(mapSettings);
-
+
} else if (ev.getSource() == butSpaceMap) {
mapSettings.setMedium(MapSettings.MEDIUM_SPACE);
mapSettings.setBoardSize(50, 50);
mapSettings.setMapSize(1, 1);
refreshMapUI();
clientgui.getClient().sendMapDimensions(mapSettings);
-
+
} else if (ev.getSource() == butLowAtmoMap) {
mapSettings.setMedium(MapSettings.MEDIUM_ATMOSPHERE);
refreshMapUI();
clientgui.getClient().sendMapSettings(mapSettings);
-
+
} else if (ev.getSource() == butAddX || ev.getSource() == butMapGrowW) {
int newMapWidth = mapSettings.getMapWidth() + 1;
mapSettings.setMapSize(newMapWidth, mapSettings.getMapHeight());
clientgui.getClient().sendMapDimensions(mapSettings);
-
+
} else if (ev.getSource() == butAddY || ev.getSource() == butMapGrowH) {
int newMapHeight = mapSettings.getMapHeight() + 1;
mapSettings.setMapSize(mapSettings.getMapWidth(), newMapHeight);
clientgui.getClient().sendMapDimensions(mapSettings);
-
+
} else if (ev.getSource() == butSaveMapSetup) {
saveMapSetup();
-
+
} else if (ev.getSource() == butLoadMapSetup) {
loadMapSetup();
-
+
} else if (ev.getSource() == fldMapWidth) {
setManualMapWidth();
-
+
} else if (ev.getSource() == fldMapHeight) {
setManualMapHeight();
-
+
} else if (ev.getSource() == fldSpaceBoardWidth) {
setManualBoardWidth();
-
+
} else if (ev.getSource() == fldSpaceBoardHeight) {
setManualBoardHeight();
-
+
} else if (ev.getSource() == butMapShrinkW) {
if (mapSettings.getMapWidth() > 1) {
int newMapWidth = mapSettings.getMapWidth() - 1;
mapSettings.setMapSize(newMapWidth, mapSettings.getMapHeight());
clientgui.getClient().sendMapDimensions(mapSettings);
}
-
+
} else if (ev.getSource() == butMapShrinkH) {
if (mapSettings.getMapHeight() > 1) {
int newMapHeight = mapSettings.getMapHeight() - 1;
mapSettings.setMapSize(mapSettings.getMapWidth(), newMapHeight);
clientgui.getClient().sendMapDimensions(mapSettings);
}
-
+
} else if (ev.getSource() == butDetach) {
butDetach.setEnabled(false);
panTeam.remove(panTeamOverview);
@@ -1816,7 +1815,7 @@ public void actionPerformed(ActionEvent ev) {
teamOverviewWindow.add(panTeamOverview);
teamOverviewWindow.center();
teamOverviewWindow.setVisible(true);
-
+
} else if (ev.getSource() == butCancelSearch) {
fldSearch.setText("");
@@ -1826,7 +1825,7 @@ public void actionPerformed(ActionEvent ev) {
Messages.getString("ChatLounge.map.title.mapAssemblyHelp"), true, true);
final int height = 600;
final int width = 600;
-
+
final JEditorPane pane = new JEditorPane();
pane.setName(CL_KEY_NAMEHELPPANE);
pane.setEditable(false);
@@ -1853,40 +1852,40 @@ public void actionPerformed(ActionEvent ev) {
Dimension sz = new Dimension(scaleForGUI(width), scaleForGUI(height));
dialog.setPreferredSize(sz);
dialog.setVisible(true);
-
+
} else if (ev.getSource() == butListView) {
scrMekTable.setViewportView(mekTable);
butCollapse.setEnabled(false);
butExpand.setEnabled(false);
-
+
} else if (ev.getSource() == butForceView) {
scrMekTable.setViewportView(mekForceTree);
butCollapse.setEnabled(true);
butExpand.setEnabled(true);
-
+
} else if (ev.getSource() == butCollapse) {
collapseTree();
-
+
} else if (ev.getSource() == butExpand) {
expandTree();
- }
+ }
}
};
-
+
/** Expands the Mek Force Tree fully. */
private void expandTree() {
for (int i = 0; i < mekForceTree.getRowCount(); i++) {
mekForceTree.expandRow(i);
}
}
-
+
/** Collapses the Mek Force Tree fully. */
private void collapseTree() {
for (int i = 0; i < mekForceTree.getRowCount(); i++) {
mekForceTree.collapseRow(i);
}
}
-
+
private void configAndCreateBot(@Nullable Player toReplace) {
BehaviorSettings behavior = null;
String botName = null;
@@ -1899,24 +1898,24 @@ private void configAndCreateBot(@Nullable Player toReplace) {
if (bcd.getResult() == DialogResult.CANCELLED) {
return;
}
- Princess botClient = Princess.createPrincess(bcd.getBotName(), client().getHost(),
+ Princess botClient = Princess.createPrincess(bcd.getBotName(), client().getHost(),
client().getPort(), bcd.getBehaviorSettings());
botClient.setClientGUI(clientgui);
botClient.getGame().addGameListener(new BotGUI(getClientgui().getFrame(), botClient));
try {
botClient.connect();
- clientgui.getBots().put(bcd.getBotName(), botClient);
+ clientgui.getLocalBots().put(bcd.getBotName(), botClient);
} catch (Exception e) {
clientgui.doAlertDialog(Messages.getString("ChatLounge.AlertBot.title"), Messages.getString("ChatLounge.AlertBot.message"));
botClient.die();
}
}
-
- /**
+
+ /**
* Opens a file chooser and saves the current map setup to the file,
* if any was chosen.
- * @see MapSetup
+ * @see MapSetup
*/
private void saveMapSetup() {
JFileChooser fc = new JFileChooser(Configuration.dataDir() + CL_KEY_FILEPATH_MAPSETUP);
@@ -1949,10 +1948,10 @@ private void saveMapSetup() {
}
}
- /**
+ /**
* Opens a file chooser and loads a new map setup from the file,
* if any was chosen.
- * @see MapSetup
+ * @see MapSetup
*/
private void loadMapSetup() {
JFileChooser fc = new JFileChooser(Configuration.dataDir() + CL_KEY_FILEPATH_MAPSETUP);
@@ -1982,29 +1981,29 @@ private void loadMapSetup() {
LogManager.getLogger().error("", ex);
}
}
-
+
private void removeBot() {
Client c = getSelectedClient();
- if (!client().bots.containsValue(c)) {
+ if (!client().localBots.containsValue(c)) {
LobbyErrors.showOnlyOwnBot(clientgui.frame);
return;
}
// Delete units first, which safely disembarks and offloads them
// Don't delete the bot's forces, as that could also delete other players' entitites
c.die();
- clientgui.getBots().remove(c.getName());
+ clientgui.getLocalBots().remove(c.getName());
}
-
+
private void doBotSettings() {
Player player = playerModel.getPlayerAt(tablePlayers.getSelectedRow());
- Princess bot = (Princess) clientgui.getBots().get(player.getName());
+ Princess bot = (Princess) clientgui.getLocalBots().get(player.getName());
var bcd = new BotConfigDialog(clientgui.frame, bot.getLocalPlayer().getName(), bot.getBehaviorSettings(), clientgui);
bcd.setVisible(true);
if (bcd.getResult() == DialogResult.CONFIRMED) {
bot.setBehaviorSettings(bcd.getBehaviorSettings());
}
}
-
+
// Put a filter on the files that the user can select the proper file.
FileFilter XMLFileFilter = new FileFilter() {
@Override
@@ -2017,7 +2016,7 @@ public String getDescription() {
return Messages.getString("ChatLounge.map.SetupXMLfiles");
}
};
-
+
private void setManualMapWidth() {
try {
int newMapWidth = Integer.parseInt(fldMapWidth.getText());
@@ -2029,7 +2028,7 @@ private void setManualMapWidth() {
// no number, no new map width
}
}
-
+
private void setManualMapHeight() {
try {
int newMapHeight = Integer.parseInt(fldMapHeight.getText());
@@ -2041,7 +2040,7 @@ private void setManualMapHeight() {
// no number, no new map height
}
}
-
+
private void setManualBoardWidth() {
try {
int newBoardWidth = Integer.parseInt(fldSpaceBoardWidth.getText());
@@ -2053,7 +2052,7 @@ private void setManualBoardWidth() {
// no number, no new board width
}
}
-
+
private void setManualBoardHeight() {
try {
int newBoardHeight = Integer.parseInt(fldSpaceBoardHeight.getText());
@@ -2090,7 +2089,7 @@ private void refreshLabels() {
txt += opts.intOption(OptionsConstants.ALLOWED_YEAR);
lblGameYear.setText(txt);
lblGameYear.setToolTipText(scaleStringForGUI(Messages.getString("ChatLounge.tooltip.techYear")));
-
+
String tlString = TechConstants.getLevelDisplayableName(TechConstants.T_TECH_UNKNOWN);
IOption tlOpt = opts.getOption(OptionsConstants.ALLOWED_TECHLEVEL);
if (tlOpt != null) {
@@ -2098,9 +2097,9 @@ private void refreshLabels() {
}
lblTechLevel.setText(Messages.getString("ChatLounge.TechLevel") + tlString);
lblTechLevel.setToolTipText(scaleStringForGUI(Messages.getString("ChatLounge.tooltip.techYear")));
-
+
txt = Messages.getString("ChatLounge.MapSummary");
- txt += (mapSettings.getBoardWidth() * mapSettings.getMapWidth()) + " x "
+ txt += (mapSettings.getBoardWidth() * mapSettings.getMapWidth()) + " x "
+ (mapSettings.getBoardHeight() * mapSettings.getMapHeight());
if (butGroundMap.isSelected()) {
txt += Messages.getString("ChatLounge.name.groundMap");
@@ -2120,17 +2119,17 @@ private void refreshLabels() {
} else {
selectedMaps.append(map);
}
- selectedMaps.append("
");
+ selectedMaps.append("
");
}
lblMapSummary.setToolTipText(scaleStringForGUI(selectedMaps.toString()));
}
-
+
@Override
public void ready() {
final Client client = clientgui.getClient();
final Game game = client.getGame();
final GameOptions gOpts = game.getOptions();
-
+
// enforce exclusive deployment zones in double blind
for (Player player: client.getGame().getPlayersVector()) {
if (!isValidStartPos(game, player)) {
@@ -2148,7 +2147,7 @@ public void ready() {
players.add(client.getLocalPlayer().getName());
}
- for (Client bc : clientgui.getBots().values()) {
+ for (Client bc : clientgui.getLocalBots().values()) {
if ((game.getLiveCommandersOwnedBy(bc.getLocalPlayer()) < 1)
&& (game.getEntitiesOwnedBy(bc.getLocalPlayer()) > 0)) {
players.add(bc.getLocalPlayer().getName());
@@ -2168,7 +2167,7 @@ public void ready() {
boolean done = !localPlayer().isDone();
client.sendDone(done);
refreshDoneButton(done);
- for (Client botClient : clientgui.getBots().values()) {
+ for (Client botClient : clientgui.getLocalBots().values()) {
botClient.sendDone(done);
}
}
@@ -2181,8 +2180,8 @@ Client getSelectedClient() {
Player player = playerModel.getPlayerAt(tablePlayers.getSelectedRow());
if (localPlayer().equals(player)) {
return client();
- } else if (client().bots.containsKey(player.getName())) {
- return client().bots.get(player.getName());
+ } else if (client().localBots.containsKey(player.getName())) {
+ return client().localBots.get(player.getName());
} else {
return null;
}
@@ -2198,26 +2197,26 @@ public void removeAllListeners() {
GUIP.removePreferenceChangeListener(this);
PreferenceManager.getClientPreferences().removePreferenceChangeListener(this);
MechSummaryCache.getInstance().removeListener(mechSummaryCacheListener);
-
+
if (loader != null) {
loader.cancel(true);
}
-
+
tablePlayers.getSelectionModel().removeListSelectionListener(this);
tablePlayers.removeMouseListener(new PlayerTableMouseAdapter());
-
+
lisBoardsAvailable.removeListSelectionListener(this);
lisBoardsAvailable.removeMouseListener(mapListMouseListener);
lisBoardsAvailable.removeMouseMotionListener(mapListMouseListener);
teamOverviewWindow.removeWindowListener(teamOverviewWindowListener);
-
+
mekTable.removeMouseListener(mekTableMouseAdapter);
mekForceTree.removeMouseListener(mekForceTreeMouseListener);
mekTable.getTableHeader().removeMouseListener(mekTableHeaderMouseListener);
mekTable.removeKeyListener(mekTableKeyListener);
mekForceTree.removeKeyListener(mekTreeKeyListener);
-
+
butAdd.removeActionListener(lobbyListener);
butAddBot.removeActionListener(lobbyListener);
butArmy.removeActionListener(lobbyListener);
@@ -2255,14 +2254,14 @@ public void removeAllListeners() {
butForceView.removeActionListener(lobbyListener);
butCollapse.removeActionListener(lobbyListener);
butExpand.removeActionListener(lobbyListener);
-
+
fldMapWidth.removeActionListener(lobbyListener);
fldMapHeight.removeActionListener(lobbyListener);
fldSpaceBoardWidth.removeActionListener(lobbyListener);
fldSpaceBoardHeight.removeActionListener(lobbyListener);
-
+
comboTeam.removeActionListener(lobbyListener);
-
+
KeyboardFocusManager kbfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
kbfm.removeKeyEventDispatcher(lobbyKeyDispatcher);
}
@@ -2271,14 +2270,14 @@ public void removeAllListeners() {
* Returns true if the given list of entities can be configured as a group.
* This requires that they all have the same owner, and that none of the
* units are being transported. Also, the owner must be the player or one
- * of his bots.
+ * of his bots.
*/
boolean canConfigureMultipleDeployment(Collection entities) {
- return haveSingleOwner(entities)
+ return haveSingleOwner(entities)
&& !containsTransportedUnit(entities)
&& canEditAny(entities);
}
-
+
/**
* Returns true if the given collection contains at least one entity
* that the local player can edit, i.e. is his own or belongs to
@@ -2289,7 +2288,7 @@ boolean canConfigureMultipleDeployment(Collection entities) {
boolean canEditAny(Collection entities) {
return entities.stream().anyMatch(this::isEditable);
}
-
+
/**
* Returns true if the local player can see all the given entities.
* This is true except when a blind drop option is active and one or more
@@ -2316,23 +2315,23 @@ boolean canSeeAll(Collection entities) {
boolean canSee(Entity entity) {
return canSeeAll(Arrays.asList(entity));
}
-
+
boolean entityInLocalTeam(Entity entity) {
return !localPlayer().isEnemyOf(entity.getOwner());
}
-
+
@Override
public void valueChanged(ListSelectionEvent event) {
if (event.getValueIsAdjusting()) {
return;
}
-
+
if (event.getSource().equals(tablePlayers.getSelectionModel())) {
refreshPlayerConfig();
}
}
-
+
/** Adapts the enabled state of the player config UI items to the player selection. */
private void refreshPlayerConfig() {
var selPlayers = getselectedPlayers();
@@ -2355,18 +2354,18 @@ private void refreshPlayerConfig() {
setTeamSelectedItem(selPlayer.getTeam());
}
}
-
+
/** Sets (without firing events) the team combobox. */
private void setTeamSelectedItem(int team) {
comboTeam.removeActionListener(lobbyListener);
comboTeam.setSelectedIndex(team);
comboTeam.addActionListener(lobbyListener);
}
-
- /**
- * Returns false when any blind-drop option is active and player is not on the local team;
- * true otherwise. When true, individual units of the given player should not be shown/saved/etc.
- */
+
+ /**
+ * Returns false when any blind-drop option is active and player is not on the local team;
+ * true otherwise. When true, individual units of the given player should not be shown/saved/etc.
+ */
private boolean unitsVisible(Player player) {
GameOptions opts = clientgui.getClient().getGame().getOptions();
boolean isBlindDrop = opts.booleanOption(OptionsConstants.BASE_BLIND_DROP)
@@ -2383,14 +2382,14 @@ public void mouseClicked(MouseEvent e) {
Player player = playerModel.getPlayerAt(row);
if (player != null) {
boolean isLocalPlayer = player.equals(localPlayer());
- boolean isLocalBot = clientgui.getBots().get(player.getName()) != null;
+ boolean isLocalBot = clientgui.getLocalBots().get(player.getName()) != null;
if ((isLocalPlayer || isLocalBot)) {
configPlayer();
}
}
}
}
-
+
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
@@ -2409,12 +2408,12 @@ private void showPopup(MouseEvent e) {
if (tablePlayers.getSelectedRowCount() == 0) {
return;
}
- ScalingPopup popup = PlayerTablePopup.playerTablePopup(clientgui,
+ ScalingPopup popup = PlayerTablePopup.playerTablePopup(clientgui,
playerTableActionListener, getselectedPlayers());
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
-
+
private ActionListener playerTableActionListener = evt -> {
if (tablePlayers.getSelectedRowCount() == 0) {
return;
@@ -2460,7 +2459,7 @@ private void showPopup(MouseEvent e) {
};
private ArrayList getselectedPlayers() {
- var result = new ArrayList();
+ var result = new ArrayList();
for (int row: tablePlayers.getSelectedRows()) {
Player player = playerModel.getPlayerAt(row);
if (player != null) {
@@ -2494,7 +2493,7 @@ public void keyPressed(KeyEvent evt) {
}
}
};
-
+
/** Copies the selected units, if any, from the displayed Unit Table / Force Tree to the clipboard. */
public void copyToClipboard() {
List entities = isForceView() ? getTreeSelectedEntities() : getSelectedEntities();
@@ -2502,7 +2501,7 @@ public void copyToClipboard() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, null);
}
-
+
/** Reads the clipboard and adds units, if it can parse them. */
public void importClipboard() {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@@ -2546,7 +2545,7 @@ public void importClipboard() {
}
}
}
-
+
/**
* @return a String representing the entities to export to the clipboard.
*/
@@ -2572,7 +2571,7 @@ private String clipboardString(Collection entities) {
}
return result.toString();
}
-
+
/** Returns a list of entities selected in the ForceTree. May be empty, but not null. */
private List getTreeSelectedEntities() {
TreePath[] selection = mekForceTree.getSelectionPaths();
@@ -2583,13 +2582,13 @@ private List getTreeSelectedEntities() {
Object selected = path.getLastPathComponent();
if (selected instanceof Entity) {
entities.add((Entity) selected);
- }
+ }
}
}
}
return entities;
}
-
+
/** Returns a list of forces selected in the ForceTree. May be empty, but not null. */
private List getTreeSelectedForces() {
TreePath[] selection = mekForceTree.getSelectionPaths();
@@ -2600,13 +2599,13 @@ private List getTreeSelectedForces() {
Object selected = path.getLastPathComponent();
if (selected instanceof Force) {
selForces.add((Force) selected);
- }
+ }
}
}
}
return selForces;
}
-
+
/** The key listener for the Force Tree. */
KeyListener mekTreeKeyListener = new KeyAdapter() {
@@ -2616,35 +2615,35 @@ public void keyPressed(KeyEvent e) {
List selForces = getTreeSelectedForces();
boolean onlyOneEntity = (selEntities.size() == 1) && selForces.isEmpty();
int code = e.getKeyCode();
-
+
if (code == KeyEvent.VK_SPACE) {
e.consume();
mechReadoutAction(selEntities, canSeeAll(selEntities), false, getClientgui().getFrame());
-
+
} else if (code == KeyEvent.VK_ENTER && onlyOneEntity) {
e.consume();
lobbyActions.customizeMech(selEntities.get(0));
-
+
} else if (code == KeyEvent.VK_UP && e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
e.consume();
lobbyActions.forceMove(selForces, selEntities, true);
-
+
} else if (code == KeyEvent.VK_DOWN && e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
e.consume();
lobbyActions.forceMove(selForces, selEntities, false);
-
+
} else if ((code == KeyEvent.VK_DELETE) || (code == KeyEvent.VK_BACK_SPACE)) {
e.consume();
lobbyActions.delete(selForces, selEntities, true);
-
+
} else if (code == KeyEvent.VK_RIGHT && e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
e.consume();
expandTree();
-
+
} else if (code == KeyEvent.VK_LEFT && e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) {
e.consume();
collapseTree();
-
+
}
}
};
@@ -2717,9 +2716,9 @@ private void showPopup(MouseEvent e) {
popup.show(e.getComponent(), e.getX() + MAP_POPUP_OFFSET, e.getY() + MAP_POPUP_OFFSET);
}
}
-
+
public class MekForceTreeMouseAdapter extends MouseInputAdapter {
-
+
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
@@ -2750,7 +2749,7 @@ private void showPopup(MouseEvent e) {
TreePath[] selection = mekForceTree.getSelectionPaths();
List entities = new ArrayList<>();
List selForces = new ArrayList<>();
-
+
if (selection != null) {
for (TreePath path: selection) {
if (path != null) {
@@ -2759,7 +2758,7 @@ private void showPopup(MouseEvent e) {
entities.add((Entity) selected);
} else if (selected instanceof Force) {
selForces.add((Force) selected);
- }
+ }
}
}
}
@@ -2817,7 +2816,7 @@ private void showPopup(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
-
+
/** Refreshes the Mek Tree, restoring expansion state and selection. */
private void refreshTree() {
// Refresh the force tree and restore selection/expand status
@@ -2830,7 +2829,7 @@ private void refreshTree() {
}
}
}
-
+
Forces forces = game().getForces();
List expandedForces = new ArrayList<>();
for (int i = 0; i < mekForceTree.getRowCount(); i++) {
@@ -2842,7 +2841,7 @@ private void refreshTree() {
}
}
}
-
+
mekForceTree.setUI(null);
try {
mekForceTreeModel.refreshData();
@@ -2862,12 +2861,12 @@ private void refreshTree() {
}
}
-
- /**
+
+ /**
* Returns a TreePath in the force tree for a possibly outdated entity
* or force. Outdated means a new object of the type was sent by the server
- * and has replaced this object. Also works for the game's current objects though.
- * Uses the force's/entity's id to get the
+ * and has replaced this object. Also works for the game's current objects though.
+ * Uses the force's/entity's id to get the
* game's real object with the same id. Used to reconstruct the selection
* and expansion state of the force tree after an update.
*/
@@ -2904,28 +2903,28 @@ private TreePath getPath(Object outdatedEntry) {
throw new IllegalArgumentException(Messages.getString("ChatLounge.TreePath.methodRequiresEntityForce"));
}
}
-
- /**
+
+ /**
* Returns a Collection that contains only those of the given entities
- * that the local player can affect, i.e. his units or those of his bots.
+ * that the local player can affect, i.e. his units or those of his bots.
* The returned Collection is a new Collection and can be safely altered.
* (The entities are not copies of course.)
- * See also {@link #isEditable(Entity)}
+ *
See also {@link #isEditable(Entity)}
*/
private Set editableEntities(Collection entities) {
return entities.stream().filter(this::isEditable).collect(Collectors.toSet());
}
-
-
- /**
- * Returns true if the given carrier and carried can be edited to have the
- * carrier transport the given carried entity. That is the case when they
- * are teammates and one of the entities can be edited by the local player.
+
+
+ /**
+ * Returns true if the given carrier and carried can be edited to have the
+ * carrier transport the given carried entity. That is the case when they
+ * are teammates and one of the entities can be edited by the local player.
* Note: this method does NOT check if the loading is rules-valid.
* See also {@link #isEditable(Entity)}
*/
private boolean isLoadable(Entity carried, Entity carrier) {
- return !carrier.getOwner().isEnemyOf(carried.getOwner())
+ return !carrier.getOwner().isEnemyOf(carried.getOwner())
&& (isEditable(carrier) || isEditable(carried));
}
@@ -2947,14 +2946,14 @@ public void preferenceChange(PreferenceChangeEvent e) {
break;
}
}
-
+
/** Silently adapts the state of the "Show IDs" button to the Client prefs. */
private void setButUnitIDState() {
butShowUnitID.removeActionListener(lobbyListener);
butShowUnitID.setSelected(PreferenceManager.getClientPreferences().getShowUnitId());
butShowUnitID.addActionListener(lobbyListener);
}
-
+
/** Sets the row height of the MekTable according to compact mode and GUI scale */
private void setTableRowHeights() {
int rowbaseHeight = butCompact.isSelected() ? MEKTABLE_ROWHEIGHT_COMPACT : MEKTABLE_ROWHEIGHT_FULL;
@@ -2976,7 +2975,7 @@ private void updateTableHeaders() {
if (activeSorter.getColumnIndex() == i) {
headerText += " " + guiScaledFontHTML(uiGray());
if (activeSorter.getSortingDirection() == MekTableSorter.Sorting.ASCENDING) {
- headerText += "\u25B4 ";
+ headerText += "\u25B4 ";
} else {
headerText += "\u25BE ";
}
@@ -2985,7 +2984,7 @@ private void updateTableHeaders() {
tabCol.setHeaderValue(headerText);
}
header.repaint();
-
+
// The player table
header = tablePlayers.getTableHeader();
colMod = header.getColumnModel();
@@ -3000,7 +2999,7 @@ private void updateTableHeaders() {
private Player ownerOf(Entity entity) {
return clientgui.getClient().getGame().getPlayer(entity.getOwnerId());
}
-
+
/** Sets the column width of the given table column of the MekTable with the value stored in the GUIP. */
private void setColumnWidth(TableColumn column) {
String key;
@@ -3017,7 +3016,7 @@ private void setColumnWidth(TableColumn column) {
}
column.setPreferredWidth(GUIP.getInt(key));
}
-
+
/** Adapts the whole Lobby UI (both panels) to the current guiScale. */
private void adaptToGUIScale() {
updateTableHeaders();
@@ -3040,10 +3039,10 @@ private void adaptToGUIScale() {
String searchTip = Messages.getString("ChatLounge.map.searchTip") + "
";
searchTip += autoTagHTMLTable();
fldSearch.setToolTipText(UIUtil.scaleStringForGUI(searchTip));
-
+
((TitledBorder) panUnitInfo.getBorder()).setTitleFont(scaledFont);
((TitledBorder) panPlayerInfo.getBorder()).setTitleFont(scaledFont);
-
+
int scaledBorder = UIUtil.scaleForGUI(TEAMOVERVIEW_BORDER);
panTeam.setBorder(new EmptyBorder(scaledBorder, scaledBorder, scaledBorder, scaledBorder));
@@ -3059,11 +3058,11 @@ private void adaptToGUIScale() {
Point locationOnScreen = MouseInfo.getPointerInfo().getLocation();
Point locationOnComponent = new Point(locationOnScreen);
SwingUtilities.convertPointFromScreen(locationOnComponent, mekTable);
- MouseEvent event = new MouseEvent(mekTable, -1, time, 0,
+ MouseEvent event = new MouseEvent(mekTable, -1, time, 0,
locationOnComponent.x, locationOnComponent.y, 0, 0, 1, false, 0);
manager.mouseMoved(event);
}
-
+
private String autoTagHTMLTable() {
String result = "
"+ UIUtil.guiScaledFontHTML();
int colCount = 0;
@@ -3085,11 +3084,11 @@ private String autoTagHTMLTable() {
result += "
";
return result;
}
-
-
- /**
+
+
+ /**
* Mouse Listener for the table header of the Mek Table.
- * Saves column widths of the Mek Table when the mouse button is released.
+ * Saves column widths of the Mek Table when the mouse button is released.
* Also switches between table sorting types
*/
MouseListener mekTableHeaderMouseListener = new MouseAdapter() {
@@ -3111,10 +3110,10 @@ private void changeSorter(MouseEvent e) {
}
GUIP.setValue(key, column.getWidth());
}
-
+
changeMekTableSorter(e);
}
-
+
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
@@ -3124,7 +3123,7 @@ public void mouseReleased(MouseEvent e) {
changeSorter(e);
}
}
-
+
private void sorterPopup(MouseEvent e) {
ScalingPopup popup = new ScalingPopup();
GameOptions opts = clientgui.getClient().getGame().getOptions();
@@ -3140,16 +3139,16 @@ private void sorterPopup(MouseEvent e) {
popup.show(e.getComponent(), e.getX(), e.getY());
}
};
-
+
/**
- * Sets the sorting used in the Mek Table depending on the column header
- * that was clicked.
- */
+ * Sets the sorting used in the Mek Table depending on the column header
+ * that was clicked.
+ */
private void changeMekTableSorter(MouseEvent e) {
int col = mekTable.columnAtPoint(e.getPoint());
MekTableSorter previousSorter = activeSorter;
List sorters;
-
+
// find the right list of sorters (or do nothing, if the column is not sortable)
if (col == MekTableModel.COL_UNIT) {
sorters = unitSorters;
@@ -3158,7 +3157,7 @@ private void changeMekTableSorter(MouseEvent e) {
} else {
return;
}
-
+
// Select the next allowed sorter and refresh the display if the sorter was changed
nextSorter(sorters);
if (activeSorter != previousSorter) {
@@ -3166,7 +3165,7 @@ private void changeMekTableSorter(MouseEvent e) {
updateTableHeaders();
}
}
-
+
/** Selects the next allowed sorter in the given list of sorters. */
private void nextSorter(List sorters) {
// Set the next sorter as active, if this column was already sorted, or
@@ -3178,7 +3177,7 @@ private void nextSorter(List sorters) {
index = (index + 1) % sorters.size();
activeSorter = sorters.get(index);
}
-
+
// Find an allowed sorter (e.g. blind drop may prohibit some)
int counter = 0; // Endless loop safeguard
while (!activeSorter.isAllowed(clientgui.getClient().getGame().getOptions())
@@ -3188,14 +3187,14 @@ private void nextSorter(List sorters) {
}
}
- /** Returns true when the compact view is active. */
+ /** Returns true when the compact view is active. */
public boolean isCompact() {
return butCompact.isSelected();
}
-
- /**
- * Returns a list of the selected entities in the Mek table.
- * The list may be empty but not null.
+
+ /**
+ * Returns a list of the selected entities in the Mek table.
+ * The list may be empty but not null.
*/
private List getSelectedEntities() {
ArrayList result = new ArrayList<>();
@@ -3208,15 +3207,15 @@ private List getSelectedEntities() {
}
return result;
}
-
+
/** Helper method to shorten calls. */
Player localPlayer() {
return clientgui.getClient().getLocalPlayer();
}
-
+
private void redrawMapTable(Image image) {
if (image != null) {
- if (lisBoardsAvailable.getFixedCellHeight() != image.getHeight(null)
+ if (lisBoardsAvailable.getFixedCellHeight() != image.getHeight(null)
|| lisBoardsAvailable.getFixedCellWidth() != image.getWidth(null)) {
lisBoardsAvailable.setFixedCellHeight(image.getHeight(null));
lisBoardsAvailable.setFixedCellWidth(image.getWidth(null));
@@ -3238,7 +3237,7 @@ private synchronized void add(String name) {
}
}
}
-
+
private Image prepareImage(String boardName) {
File boardFile = new MegaMekFile(Configuration.boardsDir(), boardName + CL_KEY_FILEEXTENTION_BOARD).getFile();
Board board;
@@ -3319,17 +3318,17 @@ protected Void doInBackground() throws Exception {
}
Map mapIcons = new HashMap<>();
-
+
/** A renderer for the list of available boards. */
public class BoardNameRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = -3218595828938299222L;
-
+
private float oldGUIScale = GUIP.getGUIScale();
private Image image;
private ImageIcon icon;
-
+
@Override
- public Component getListCellRendererComponent(JList> list, Object value,
+ public Component getListCellRendererComponent(JList> list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
String board = (String) value;
@@ -3337,7 +3336,7 @@ public Component getListCellRendererComponent(JList> list, Object value,
if (board.startsWith(MapSettings.BOARD_GENERATED)) {
board += mapSettings.getBoardSize();
}
-
+
// If the gui scaling has changed, clear out all images, triggering a reload
float currentGUIScale = GUIP.getGUIScale();
if (currentGUIScale != oldGUIScale) {
@@ -3347,7 +3346,7 @@ public Component getListCellRendererComponent(JList> list, Object value,
baseImages.clear();
}
}
-
+
// If an icon is present for the current board, use it
icon = mapIcons.get(board);
if (icon != null) {
@@ -3366,17 +3365,17 @@ public Component getListCellRendererComponent(JList> list, Object value,
} else {
// There is a base image: make it into an icon, store it and use it
if (!lisBoardsAvailable.isEnabled()) {
- ImageFilter filter = new GrayFilter(true, 50);
- ImageProducer producer = new FilteredImageSource(image.getSource(), filter);
- image = Toolkit.getDefaultToolkit().createImage(producer);
+ ImageFilter filter = new GrayFilter(true, 50);
+ ImageProducer producer = new FilteredImageSource(image.getSource(), filter);
+ image = Toolkit.getDefaultToolkit().createImage(producer);
}
icon = new ImageIcon(image);
-
+
mapIcons.put(board, icon);
setIcon(icon);
}
}
-
+
// Found or created an icon; finish the panel
setText("");
if (lisBoardsAvailable.isEnabled()) {
@@ -3384,7 +3383,7 @@ public Component getListCellRendererComponent(JList> list, Object value,
} else {
setToolTipText(null);
}
-
+
if (isSelected) {
setForeground(list.getSelectionForeground());
setBackground(list.getSelectionBackground());
@@ -3392,14 +3391,14 @@ public Component getListCellRendererComponent(JList> list, Object value,
setForeground(list.getForeground());
setBackground(list.getBackground());
}
-
+
return this;
}
}
private class MekTable extends JTable {
private static final long serialVersionUID = -4054214297803021212L;
-
+
public MekTable(MekTableModel mekModel) {
super(mekModel);
}
@@ -3433,10 +3432,10 @@ void updateMapButtons() {
Dimension size = maxMapButtonSize();
for (MapPreviewButton button: mapButtons) {
button.setPreviewSize(size);
- }
+ }
}
}
-
+
void updateMapButtons(Dimension size) {
if (!currentMapButtonSize.equals(size)) {
currentMapButtonSize = size;
@@ -3462,8 +3461,8 @@ Dimension optMapButtonSize(Image image) {
int h = (int) (factor * image.getHeight(null));
return new Dimension(w, h);
}
-
- /**
+
+ /**
* Returns true when the string boardName contains an invalid board. boardName may
* denote a generated board (which is never invalid) or a surprise board
* with several actual board names attached which will return true when at least
@@ -3472,18 +3471,18 @@ Dimension optMapButtonSize(Image image) {
boolean hasInvalidBoard(String boardName) {
return hasSpecialBoard(boardName, invalidBoards);
}
-
- /**
- * Returns true when the string boardName contains a board that isn't present on
- * the client (only on the server). boardName may denote a generated board
- * (which is never serverside) or a surprise board with several actual board names
+
+ /**
+ * Returns true when the string boardName contains a board that isn't present on
+ * the client (only on the server). boardName may denote a generated board
+ * (which is never serverside) or a surprise board with several actual board names
* attached which will return true when at least one of the boards is serverside.
*/
boolean hasServerSideBoard(String boardName) {
return hasSpecialBoard(boardName, serverBoards);
}
-
- /**
+
+ /**
* Returns true when boardName (if a single board) or any of the boards contained
* in boardName (if a surprise board list) is contained in the provided list. Returns
* false for generated boards.
@@ -3498,8 +3497,8 @@ private boolean hasSpecialBoard(String boardName, Collection list) {
}
}
- /**
- * Returns a tooltip for the provided boardName that may be a single board or
+ /**
+ * Returns a tooltip for the provided boardName that may be a single board or
* a generated or surprise board. Adds info for serverside or invalid boards.
*/
String createBoardTooltip(String boardName) {
@@ -3523,7 +3522,7 @@ String createBoardTooltip(String boardName) {
return result;
}
-
+
ActionListener mekTableHeaderAListener = e -> {
MekTableSorter previousSorter = activeSorter;
for (MekTableSorter sorter: union(unitSorters, bvSorters)) {
@@ -3537,20 +3536,20 @@ String createBoardTooltip(String boardName) {
updateTableHeaders();
}
};
-
+
Game game() {
return clientgui.getClient().getGame();
}
-
+
/** Convenience for clientgui.getClient() */
Client client() {
return clientgui.getClient();
}
-
+
boolean isForceView() {
return butForceView.isSelected();
}
-
+
public void killPreviewBV() {
if (previewBV != null) {
previewBV.die();
diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java
index 166048d0b36..6d76e2c7ca6 100644
--- a/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java
+++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyActions.java
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with MegaMek. If not, see .
- */
+ */
package megamek.client.ui.swing.lobby;
import megamek.client.Client;
@@ -66,7 +66,7 @@ public class LobbyActions {
lobby = cl;
}
- /** Sets a deployment round for the given entities. Sends an update to the server. */
+ /** Sets a deployment round for the given entities. Sends an update to the server. */
void applyDeployment(Collection entities, int newRound) {
if (!validateUpdate(entities)) {
return;
@@ -138,9 +138,9 @@ void applyProne(Collection entities, String info) {
}
sendUpdates(updateCandidates);
}
-
+
/**
- * Attaches the given force as a subforce to the given new parent.
+ * Attaches the given force as a subforce to the given new parent.
* Does NOT work for newParentId == NO_FORCE. Use promoteForce to do this.
* Does not allow attaching a force to one of its own subforces.
*/
@@ -150,13 +150,13 @@ void forceAttach(int forceId, int newParentId) {
|| (forceId == newParentId)) {
return;
}
-
+
Force force = forces.getForce(forceId);
Force newParent = forces.getForce(newParentId);
List subForces = forces.getFullSubForces(force);
Player owner = forces.getOwner(force);
Player newParentOwner = forces.getOwner(newParent);
-
+
if (owner.isEnemyOf(newParentOwner)) {
LobbyErrors.showOnlyTeam(frame());
return;
@@ -172,10 +172,10 @@ void forceAttach(int forceId, int newParentId) {
var forceList = new ArrayList<>(List.of(force));
client().sendForceParent(forceList, newParentId);
}
-
+
/**
- * Makes the given forces top-level, detaching them from any former parents.
+ * Makes the given forces top-level, detaching them from any former parents.
*/
void forcePromote(Collection forceIds) {
var forces = game().getForces();
@@ -204,10 +204,10 @@ void configureDamage(Collection entities) {
med.setVisible(true);
sendUpdates(entities);
}
-
- /**
+
+ /**
* Moves a force or entity within another force by one position. If up is true,
- * moves upward, otherwise downward.
+ * moves upward, otherwise downward.
*/
void forceMove(Collection forceList, Collection entityList, boolean up) {
// May only move a single force or a single entity
@@ -223,7 +223,7 @@ void forceMove(Collection forceList, Collection entityList, boole
return;
}
var forces = game().getForces();
- var changedForce = new HashSet();
+ var changedForce = new HashSet();
if (up) {
if (!forceList.isEmpty()) {
changedForce.addAll(forces.moveUp(CollectionUtil.anyOneElement(forceList)));
@@ -242,10 +242,10 @@ void forceMove(Collection forceList, Collection entityList, boole
client().sendUpdateForce(changedForce);
}
}
-
- /**
- * Displays a CamoChooser to choose an individual camo for the given entities.
- * The camo will only be applied to units configurable by the local player,
+
+ /**
+ * Displays a CamoChooser to choose an individual camo for the given entities.
+ * The camo will only be applied to units configurable by the local player,
* i.e. his own units or those of his bots.
*/
public void individualCamo(Collection entities) {
@@ -288,10 +288,10 @@ public void customizeMechs(Collection entities) {
String ownerName = randomSelected.getOwner().getName();
int ownerId = randomSelected.getOwner().getId();
- boolean editable = client().bots.get(ownerName) != null;
+ boolean editable = client().localBots.get(ownerName) != null;
Client client;
if (editable) {
- client = client().bots.get(ownerName);
+ client = client().localBots.get(ownerName);
} else {
editable |= ownerId == localPlayer().getId();
client = client();
@@ -300,7 +300,7 @@ public void customizeMechs(Collection entities) {
CustomMechDialog cmd = new CustomMechDialog(lobby.getClientgui(), client, new ArrayList<>(entities), editable);
cmd.setSize(new Dimension(GUIPreferences.getInstance().getCustomUnitWidth(),
GUIPreferences.getInstance().getCustomUnitHeight()));
- cmd.setTitle(Messages.getString("ChatLounge.CustomizeUnits"));
+ cmd.setTitle(Messages.getString("ChatLounge.CustomizeUnits"));
cmd.setVisible(true);
GUIPreferences.getInstance().setCustomUnitHeight(cmd.getSize().height);
GUIPreferences.getInstance().setCustomUnitWidth(cmd.getSize().width);
@@ -347,10 +347,10 @@ public void customizeMech(Entity entity) {
if (!validateUpdate(Arrays.asList(entity))) {
return;
}
- boolean editable = client().bots.get(entity.getOwner().getName()) != null;
+ boolean editable = client().localBots.get(entity.getOwner().getName()) != null;
Client c;
if (editable) {
- c = client().bots.get(entity.getOwner().getName());
+ c = client().localBots.get(entity.getOwner().getName());
} else {
editable |= entity.getOwnerId() == localPlayer().getId();
c = client();
@@ -429,9 +429,9 @@ public void customizeMech(Entity entity) {
}
}
- /**
+ /**
* Sets random skills for the given entities, as far as they can
- * be configured by the local player.
+ * be configured by the local player.
*/
void setRandomSkills(Collection entities) {
if (!validateUpdate(entities)) {
@@ -444,9 +444,9 @@ void setRandomSkills(Collection entities) {
sendUpdates(entities);
}
- /**
+ /**
* Sets random names for the given entities' pilots, as far as they can
- * be configured by the local player.
+ * be configured by the local player.
*/
void setRandomNames(Collection entities) {
if (!validateUpdate(entities)) {
@@ -462,9 +462,9 @@ void setRandomNames(Collection entities) {
sendUpdates(entities);
}
- /**
+ /**
* Sets random callsigns for the given entities' pilots, as far as they can
- * be configured by the local player.
+ * be configured by the local player.
*/
void setRandomCallsigns(Collection entities) {
if (!validateUpdate(entities)) {
@@ -477,9 +477,9 @@ void setRandomCallsigns(Collection entities) {
}
sendUpdates(entities);
}
-
+
/**
- * Asks for a name and creates a new top-level force of that name.
+ * Asks for a name and creates a new top-level force of that name.
*/
void forceCreateEmpty() {
// Ask for a name
@@ -489,10 +489,10 @@ void forceCreateEmpty() {
}
client().sendAddForce(Force.createToplevelForce(name, localPlayer()), new ArrayList<>());
}
-
+
/**
- * Asks for a name and creates a new top-level force of that name with the
- * selected entities in it.
+ * Asks for a name and creates a new top-level force of that name with the
+ * selected entities in it.
*/
void forceCreateFrom(Collection entities) {
if (!validateUpdate(entities)) {
@@ -509,10 +509,10 @@ void forceCreateFrom(Collection entities) {
}
client().sendAddForce(Force.createToplevelForce(name, CollectionUtil.anyOneElement(entities).getOwner()), entities);
}
-
+
/**
* Asks for a name and creates a new subforce of that name for the force given
- * as the parentId.
+ * as the parentId.
*/
void forceCreateSub(int parentId) {
// Ask for a name
@@ -522,7 +522,7 @@ void forceCreateSub(int parentId) {
}
client().sendAddForce(Force.createSubforce(name, game().getForces().getForce(parentId)), new ArrayList<>());
}
-
+
/**
* Toggles burst MG fire for the given entities to the state given as burstOn
*/
@@ -541,17 +541,17 @@ void toggleBurstMg(Collection entities, boolean burstOn) {
}
sendUpdates(updateCandidates);
}
-
+
/** Adds the given entities as strategic targets for the given local bot. */
void setPrioTarget(String botName, Collection entities) {
- Map bots = lobby.getClientgui().getBots();
+ Map bots = lobby.getClientgui().getLocalBots();
if (!bots.containsKey(botName) || !(bots.get(botName) instanceof Princess)) {
return;
}
BehaviorSettings behavior = ((Princess) bots.get(botName)).getBehaviorSettings();
entities.forEach(e -> behavior.addPriorityUnit(e.getId()));
}
-
+
/**
* Toggles hot loading LRMs for the given entities to the state given as hotLoadOn
*/
@@ -561,7 +561,7 @@ void toggleHotLoad(Collection entities, boolean hotLoadOn) {
}
Set updateCandidates = new HashSet<>();
for (Entity entity: entities) {
- for (Mounted m: entity.getAmmo()) {
+ for (Mounted m: entity.getAmmo()) {
// setHotLoad checks the Ammo to see if it can be hotloaded
m.setHotLoad(hotLoadOn);
// TODO: The following should ideally be part of setHotLoad in Mounted
@@ -575,7 +575,7 @@ void toggleHotLoad(Collection entities, boolean hotLoadOn) {
}
sendUpdates(updateCandidates);
}
-
+
public void load(Collection selEntities, String info) {
StringTokenizer stLoad = new StringTokenizer(info, ":");
int loaderId = Integer.parseInt(stLoad.nextToken());
@@ -587,7 +587,7 @@ public void load(Collection selEntities, String info) {
if (entities.isEmpty()) {
return;
}
-
+
// If a unit of the selected units is currently loaded onto another, 2nd unit of the selected
// units, do not continue. The player should unload units first. This would require
// a server update offloading that second unit AND embarking it. Currently not possible
@@ -599,7 +599,7 @@ public void load(Collection selEntities, String info) {
LobbyErrors.showNoDualLoad(frame());
return;
}
-
+
boolean loadRear = false;
if (stLoad.hasMoreTokens()) {
loadRear = Boolean.parseBoolean(stLoad.nextToken());
@@ -607,7 +607,7 @@ public void load(Collection selEntities, String info) {
StringBuilder errorMsg = new StringBuilder();
if (!LobbyUtility.validateLobbyLoad(entities, loader, bayNumber, loadRear, errorMsg)) {
- JOptionPane.showMessageDialog(frame(), errorMsg.toString(),
+ JOptionPane.showMessageDialog(frame(), errorMsg.toString(),
Messages.getString("LoadingBay.error"), JOptionPane.ERROR_MESSAGE);
return;
}
@@ -624,14 +624,14 @@ public void load(Collection selEntities, String info) {
lobby.loadOnto(e, loaderId, bayNumber);
}
}
-
+
/** Asks for a new name for the provided forceId and applies it. */
void forceRename(int forceId) {
Forces forces = game().getForces();
if (!forces.contains(forceId)) {
return;
}
- Force force = forces.getForce(forceId);
+ Force force = forces.getForce(forceId);
if (!isEditable(force)) {
LobbyErrors.showCannotConfigEnemies(frame());
return;
@@ -645,13 +645,13 @@ void forceRename(int forceId) {
var forceList = new ArrayList<>(List.of(force)); // must be mutable
client().sendUpdateForce(forceList);
}
-
+
/**
- * Deletes the given forces and entities. Asks for confirmation if confirm is true.
+ * Deletes the given forces and entities. Asks for confirmation if confirm is true.
*/
void delete(Collection foDelete, Collection enDelete, boolean confirm) {
Forces forces = game().getForces();
- // Remove redundant forces = subforces of other forces in the list
+ // Remove redundant forces = subforces of other forces in the list
Set allSubForces = new HashSet<>();
foDelete.forEach(f -> allSubForces.addAll(forces.getFullSubForces(f)));
foDelete.removeIf(allSubForces::contains);
@@ -661,7 +661,7 @@ void delete(Collection foDelete, Collection enDelete, boolean con
foDelete.stream().map(forces::getFullEntities).map(ForceAssignable::filterToEntityList).forEach(inForces::addAll);
enDelete.removeIf(inForces::contains);
Set finalEnDelete = new HashSet<>(enDelete);
-
+
if (!enDelete.isEmpty() && !validateUpdate(finalEnDelete)) {
return;
}
@@ -686,17 +686,17 @@ void delete(Collection foDelete, Collection enDelete, boolean con
return;
}
}
-
+
// Send a command to remove the forceless entities
Set senders = finalEnDelete.stream().map(this::correctSender).collect(toSet());
for (Client sender: senders) {
- // Gather the entities for this sending client;
+ // Gather the entities for this sending client;
// Serialization doesn't like the toList() result, therefore the new ArrayList
List ids = new ArrayList<>(finalEnDelete.stream()
.filter(e -> correctSender(e).equals(sender)).map(Entity::getId).collect(toList()));
sender.sendDeleteEntities(ids);
}
-
+
// Send a command to remove the forces (with entities)
senders = finalFoDelete.stream().map(this::correctSender).collect(toSet());
for (Client sender: senders) {
@@ -706,11 +706,11 @@ void delete(Collection foDelete, Collection enDelete, boolean con
sender.sendDeleteForces(foList);
}
}
-
+
/**
* Removes the given entities from their force(s), making them force-less.
* Entities must have a single owner and be editable (local units or local bot's units)
- * (Having multiple owners makes sending updates correctly for one's own bots difficult)
+ * (Having multiple owners makes sending updates correctly for one's own bots difficult)
*/
void forceRemoveEntity(Collection entities) {
if (!validateUpdate(entities)) {
@@ -718,9 +718,9 @@ void forceRemoveEntity(Collection entities) {
}
client().sendAddEntitiesToForce(entities, Force.NO_FORCE);
}
-
+
/**
- * Swaps pilots between the given entity
+ * Swaps pilots between the given entity
* and another entity of the given id
*/
void swapPilots(Collection entities, int targetId) {
@@ -741,12 +741,12 @@ void swapPilots(Collection entities, int targetId) {
selected.setCrew(temp);
sendUpdates(Arrays.asList(target, selected));
}
-
- /**
+
+ /**
* Disconnects the passed entities from their C3 network, if any.
* Due to the way C3 networks are represented in Entity, units
* cannot disconnect from a C3 network with an id that is the
- * entity's own id.
+ * entity's own id.
*/
void c3DisconnectFromNetwork(Collection entities) {
if (!validateUpdate(entities)) {
@@ -755,10 +755,10 @@ void c3DisconnectFromNetwork(Collection entities) {
Set updateCandidates = performDisconnect(entities);
sendUpdates(updateCandidates);
}
-
- /**
- * Performs a disconnect from C3 networks for the given entities without sending an update.
- * Returns a set of all affected units.
+
+ /**
+ * Performs a disconnect from C3 networks for the given entities without sending an update.
+ * Returns a set of all affected units.
*/
private HashSet performDisconnect(Collection entities) {
HashSet updateCandidates = new HashSet<>();
@@ -780,7 +780,7 @@ private HashSet performDisconnect(Collection entities) {
}
return updateCandidates;
}
-
+
/** Sets the entities' C3M to act as a Company Master. */
void c3SetCompanyMaster(Collection entities) {
if (!validateUpdate(entities)) {
@@ -793,7 +793,7 @@ void c3SetCompanyMaster(Collection entities) {
entities.forEach(e -> e.setC3Master(e.getId(), true));
sendUpdates(entities);
}
-
+
/** Sets the entities' C3M to act as a Lance Master (aka normal mode). */
void c3SetLanceMaster(Collection entities) {
if (!validateUpdate(entities)) {
@@ -806,8 +806,8 @@ void c3SetLanceMaster(Collection entities) {
entities.forEach(e -> e.setC3Master(-1, true));
sendUpdates(entities);
}
-
- /**
+
+ /**
* Connects the passed entities to a nonhierarchic C3 (NC3, C3i or Nova CEWS)
* identified by masterID.
*/
@@ -837,7 +837,7 @@ void c3JoinNh(Collection entities, int masterID, boolean disconnectFirst
sendUpdates(entities);
}
- /**
+ /**
* Connects the passed entities to a standard C3M
* identified by masterID.
*/
@@ -873,8 +873,8 @@ void c3Connect(Collection entities, int masterID, boolean disconnectFirs
entities.forEach(e -> e.setC3Master(master, true));
sendUpdates(updateCandidates);
}
-
- /**
+
+ /**
* Change the given entities' controller to the player with ID newOwnerId.
* If the given forceList is not empty, an error message will be shown.
*/
@@ -890,7 +890,7 @@ void changeOwner(Collection entities, Collection forceList, int n
}
client().sendChangeOwner(entities, newOwnerId);
}
-
+
/** Change the team of a controlled player (the local player or one of his bots). */
void changeTeam(Collection players, int team) {
var toSend = new HashSet();
@@ -900,7 +900,7 @@ void changeTeam(Collection players, int team) {
.forEach(toSend::add);
client().sendChangeTeam(toSend, team);
}
-
+
/**
* Add the entities to the force if admissible (the entities must all be editable
* by the local player and be allied to the force's owner.
@@ -917,14 +917,14 @@ void forceAddEntity(Collection entities, int forceId) {
}
client().sendAddEntitiesToForce(entities, forceId);
}
-
- /**
- * Changes the owner of the given forces to a different player without
- * affecting force structure.
+
+ /**
+ * Changes the owner of the given forces to a different player without
+ * affecting force structure.
* When assigning the force only to an enemy, it would dislodge that force
* from its parent and dislodge all units from it and leave it an empty
* force for the enemy. That seems useless. Therefore this is restricted
- * to only assign to team members of the former owner.
+ * to only assign to team members of the former owner.
*/
void forceAssignOnly(Collection forceList, int newOwnerId) {
Player newOwner = game().getPlayer(newOwnerId);
@@ -946,8 +946,8 @@ void forceAssignOnly(Collection forceList, int newOwnerId) {
}
client().sendUpdateForce(changedForces);
}
-
- /**
+
+ /**
* Changes the owner of the given forces to a different player together with
* all subforces and units.
*/
@@ -962,7 +962,7 @@ void forceAssignFull(Collection forceList, int newOwnerId) {
}
client().sendAssignForceFull(forceList, newOwnerId);
}
-
+
void unloadFromBay(Collection entities, int bayId) {
if (entities.size() != 1) {
LobbyErrors.showSingleUnit(frame(), "offload from bays");
@@ -983,7 +983,7 @@ void unloadFromBay(Collection entities, int bayId) {
}
sendUpdates(updateCandidates);
}
-
+
/**
* Creates a fighter squadron from the given list of entities.
* Checks if all entities are fighters and if the number of entities
@@ -1002,35 +1002,35 @@ void createSquadron(Collection entities) {
return;
}
boolean largeSquadrons = game().getOptions().booleanOption(OptionsConstants.ADVAERORULES_ALLOW_LARGE_SQUADRONS);
- if ((!largeSquadrons && entities.size() > FighterSquadron.MAX_SIZE)
+ if ((!largeSquadrons && entities.size() > FighterSquadron.MAX_SIZE)
|| entities.size() > FighterSquadron.ALTERNATE_MAX_SIZE) {
LobbyErrors.showSquadronTooMany(frame());
}
-
+
// Ask for a squadron name
String name = JOptionPane.showInputDialog(frame(), "Choose a squadron designation");
if ((name == null) || name.isBlank()) {
return;
}
-
+
// Now, actually create the squadron
FighterSquadron fs = new FighterSquadron(name);
fs.setOwner(createSquadronOwner(entities));
List fighterIds = new ArrayList<>(entities.stream().map(Entity::getId).collect(toList()));
correctSender(fs).sendAddSquadron(fs, fighterIds);
}
-
- /**
+
+ /**
* Returns a likely owner client; if any of the fighter belongs to the local
* player, returns the local player. If not, returns a local bot if any of the
- * fighters belongs to that; finally, returns the owner of a random one of the
+ * fighters belongs to that; finally, returns the owner of a random one of the
* fighters.
*/
private Player createSquadronOwner(Collection entities) {
if (entities.stream().anyMatch(e -> e.getOwner().equals(localPlayer()))) {
return localPlayer();
} else {
- for (Entry en: client().bots.entrySet()) {
+ for (Entry en: client().localBots.entrySet()) {
Player bot = en.getValue().getLocalPlayer();
if (entities.stream().anyMatch(e -> e.getOwner().equals(bot))) {
return en.getValue().getLocalPlayer();
@@ -1073,17 +1073,17 @@ private boolean validateUpdate(Collection entities) {
return true;
}
- /**
- * Sends the entities in the given Collection to the Server.
+ /**
+ * Sends the entities in the given Collection to the Server.
* Sends only those that can be edited, i.e. the player's own
* or his bots' units. Will separate the units into update
- * packets for the local player and any local bots so that the
+ * packets for the local player and any local bots so that the
* server accepts all changes (as the server does not know of
* local bots and rejects updates that are not for the sending client
- * or its teammates.
+ * or its teammates.
*/
void sendUpdates(Collection entities) {
- // Gather the necessary sending clients; this list may contain null if some units
+ // Gather the necessary sending clients; this list may contain null if some units
// cannot be affected at all, i.e. are enemies to localplayer and all his bots
List senders = entities.stream().map(this::correctSender).distinct().collect(toList());
for (Client sender: senders) {
@@ -1093,47 +1093,47 @@ void sendUpdates(Collection entities) {
sender.sendUpdateEntity(new ArrayList<>(entities.stream().filter(e -> correctSender(e).equals(sender)).collect(toList())));
}
}
-
- /**
- * Sends the entities and forces in the given Collections to the Server.
+
+ /**
+ * Sends the entities and forces in the given Collections to the Server.
* Sends only those that can be edited, i.e. the player's own
* or his bots' units. Will separate the units into update
- * packets for the local player and any local bots so that the
+ * packets for the local player and any local bots so that the
* server accepts all changes (as the server does not know of
* local bots and rejects updates that are not for the sending client
- * or its teammates.
+ * or its teammates.
*/
void sendUpdates(Collection changedEntities, Collection changedForces) {
- // Gather the necessary sending clients; this list may contain null if some units
+ // Gather the necessary sending clients; this list may contain null if some units
// cannot be affected at all, i.e. are enemies to localplayer and all his bots
Set senders = new HashSet<>();
senders.addAll(changedEntities.stream().map(this::correctSender).distinct().collect(toList()));
senders.addAll(changedForces.stream().map(this::correctSender).distinct().collect(toList()));
-
+
for (Client sender: senders) {
if (sender == null) {
continue;
}
List enList = changedEntities.stream().filter(e -> correctSender(e).equals(sender)).collect(toList());
List foList = changedForces.stream().filter(f -> correctSender(f).equals(sender)).collect(toList());
-
+
if (foList.isEmpty()) {
- sender.sendUpdateEntity(enList);
+ sender.sendUpdateEntity(enList);
} else {
sender.sendUpdateForce(foList, enList);
}
}
}
-
+
void sendSingleUpdate(Collection changedEntities, Collection changedForces) {
if (!areAllied(changedEntities, changedForces)) {
LogManager.getLogger().error("Cannot send force update unless all changed entities and forces are allied!");
return;
}
-
+
}
- /**
+ /**
* Returns the best sending client for an update of the given entity or
* null if none can be found (entity is an enemy to the local player and all his bots)
*/
@@ -1141,22 +1141,22 @@ private Client correctSender(Entity entity) {
Player owner = entity.getOwner();
if (localPlayer().equals(owner)) {
return client();
- } else if (client().bots.containsKey(owner.getName())) {
- return client().bots.get(owner.getName());
+ } else if (client().localBots.containsKey(owner.getName())) {
+ return client().localBots.get(owner.getName());
} else if (!localPlayer().isEnemyOf(owner)) {
return client();
} else {
- for (Client bot: client().bots.values()) {
+ for (Client bot: client().localBots.values()) {
if (!bot.getLocalPlayer().isEnemyOf(owner)) {
return bot;
}
}
}
-
+
return null;
}
-
- /**
+
+ /**
* Returns the best sending client for an update of the given force or
* null if none can be found (force is an enemy to the local player and all his bots)
*/
@@ -1164,12 +1164,12 @@ private Client correctSender(Force force) {
Player owner = game().getForces().getOwner(force);
if (localPlayer().equals(owner)) {
return client();
- } else if (client().bots.containsKey(owner.getName())) {
- return client().bots.get(owner.getName());
+ } else if (client().localBots.containsKey(owner.getName())) {
+ return client().localBots.get(owner.getName());
} else if (!localPlayer().isEnemyOf(owner) || isEditable(force)) {
return client();
} else {
- for (Client bot: client().bots.values()) {
+ for (Client bot: client().localBots.values()) {
if (!bot.getLocalPlayer().isEnemyOf(owner)) {
return bot;
}
@@ -1178,25 +1178,25 @@ private Client correctSender(Force force) {
return null;
}
- /**
+ /**
* Returns true when the given entity may be configured by the local player,
* i.e. if it is his own unit or one of his bot's units.
* Note that this is more restrictive than the Server is. The Server
- * accepts entity changes also for teammates so that entity updates that
- * signal transporting a teammate's unit don't get rejected.
+ * accepts entity changes also for teammates so that entity updates that
+ * signal transporting a teammate's unit don't get rejected.
* I think it's important to generally limit entity changes by other players
* to avoid collisions of updates.
- * TODO: A possible enhancement might be a GM mode for MM, where only one
+ * TODO: A possible enhancement might be a GM mode for MM, where only one
* player is allowed to change everything.
*/
boolean isEditable(Entity entity) {
- return client().bots.containsKey(entity.getOwner().getName())
+ return client().localBots.containsKey(entity.getOwner().getName())
|| (entity.getOwnerId() == localPlayer().getId())
|| (entity.partOfForce() && isSelfOrLocalBot(game().getForces().getOwner(entity.getForceId())))
|| (entity.partOfForce() && isEditable(game().getForces().getForce(entity)));
}
- /**
+ /**
* Returns true when the given entity may NOT be configured by the local player,
* i.e. if it is not own unit or one of his bot's units.
* @see #isEditable(Entity)
@@ -1205,7 +1205,7 @@ boolean isNotEditable(Entity entity) {
return !isEditable(entity);
}
- /**
+ /**
* Returns true when all given entities may be configured by the local player,
* i.e. if they are his own units or one of his bot's units.
* @see #isEditable(Entity)
@@ -1229,42 +1229,42 @@ boolean canSeeAll(Collection entities) {
boolean entityInLocalTeam(Entity entity) {
return !localPlayer().isEnemyOf(entity.getOwner());
}
-
+
boolean isSelfOrLocalBot(Player player) {
- return client().bots.containsKey(player.getName()) || localPlayer().equals(player);
+ return client().localBots.containsKey(player.getName()) || localPlayer().equals(player);
}
/** Returns true if the entity is an enemy of the local player. */
boolean isLocalEnemy(Entity entity) {
return localPlayer().isEnemyOf(entity.getOwner());
}
-
+
/**
* A force is editable to the local player if any forces in its force chain
* (this includes the force itself) is owned by the local player or one of the
* local bots. This allows editing forces of other players if they are a subforce
- * of a local/bot force.
+ * of a local/bot force.
*/
boolean isEditable(Force force) {
List chain = game().getForces().forceChain(force);
return chain.stream().map(f -> game().getForces().getOwner(f)).anyMatch(this::isSelfOrLocalBot);
}
-
+
boolean isEditable(int forceId) {
- return game().getForces().contains(forceId) && isEditable(game().getForces().getForce(forceId));
+ return game().getForces().contains(forceId) && isEditable(game().getForces().getForce(forceId));
}
-
+
boolean areForcesEditable(Collection forces) {
return forces.stream().allMatch(this::isEditable);
}
-
+
/**
* Returns true if no two of the given entities are enemies. This is
- * true when all entities belong to a single player. If they belong to
- * different players, it is true when all belong to the same team and
+ * true when all entities belong to a single player. If they belong to
+ * different players, it is true when all belong to the same team and
* that team is one of Teams 1 through 5 (not "No Team").
* Returns true when entities is empty or has only one entity. The case of
- * entities being empty should be considered by the caller.
+ * entities being empty should be considered by the caller.
*/
private boolean areAllied(Collection entities) {
if (entities.isEmpty()) {
@@ -1274,9 +1274,9 @@ private boolean areAllied(Collection entities) {
Entity randomEntry = entities.stream().findAny().get();
return entities.stream().noneMatch(e -> e.isEnemyOf(randomEntry));
}
-
+
/**
- * Returns true if no two of the given entities and forces are enemies. Also checks
+ * Returns true if no two of the given entities and forces are enemies. Also checks
* between forces and entities.
* @see #areAllied(Collection)
* @see #areForcesAllied(Collection)
@@ -1297,16 +1297,16 @@ private boolean areAllied(Collection entities, Collection forces)
Force randomForce = forces.stream().findAny().get();
Player forceOwner = game().getForces().getOwner(randomForce);
return areAllied(entities) && areForcesAllied(forces) && !entityOwner.isEnemyOf(forceOwner);
-
+
}
-
+
/**
* Returns true if no two of the given forces are enemies. This is
- * true when all forces belong to a single player. If they belong to
- * different players, it is true when all belong to the same team and
+ * true when all forces belong to a single player. If they belong to
+ * different players, it is true when all belong to the same team and
* that team is one of Teams 1 through 5 (not "No Team").
* Returns true when forces is empty or has only one force. The case of
- * forces being empty should be considered by the caller.
+ * forces being empty should be considered by the caller.
*/
private boolean areForcesAllied(Collection forces) {
if (forces.isEmpty()) {
@@ -1317,19 +1317,19 @@ private boolean areForcesAllied(Collection forces) {
Player owner = game().getForces().getOwner(randomEntry);
return forces.stream().noneMatch(f -> game().getForces().getOwner(f).isEnemyOf(owner));
}
-
+
private Game game() {
return lobby.game();
}
-
+
private Client client() {
return lobby.client();
}
-
+
private JFrame frame() {
return lobby.getClientgui().getFrame();
}
-
+
private Player localPlayer() {
return client().getLocalPlayer();
}
diff --git a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekPopup.java b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekPopup.java
index 52e694ec484..9bbf745487f 100644
--- a/megamek/src/megamek/client/ui/swing/lobby/LobbyMekPopup.java
+++ b/megamek/src/megamek/client/ui/swing/lobby/LobbyMekPopup.java
@@ -52,7 +52,7 @@
/** Creates the Lobby Mek right-click pop-up menu for both the sortable table and the force tree. */
class LobbyMekPopup {
-
+
static final String LMP_SKILLS = "SKILLS";
static final String LMP_CALLSIGN = "CALLSIGN";
static final String LMP_NAME = "NAME";
@@ -107,15 +107,15 @@ class LobbyMekPopup {
static final String LMP_ALPHASTRIKE = "ALPHASTRIKE";
private static final String NOINFO = "|-1";
-
+
static final String LMP_UNLOADALLFROMBAY = "UNLOADALLFROMBAY";
-
+
static ScalingPopup getPopup(List entities, List forces, ActionListener listener,
ChatLounge lobby) {
ClientGUI clientGui = lobby.getClientgui();
Game game = lobby.game();
GameOptions opts = game.getOptions();
-
+
boolean optQuirks = opts.booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS);
boolean optBurstMG = opts.booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_BURST);
boolean optLRMHotLoad = opts.booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_HOTLOAD);
@@ -125,7 +125,7 @@ static ScalingPopup getPopup(List entities, List forces, ActionLi
Set joinedEntities = new HashSet<>(entities);
for (Force force: forces) {
joinedEntities.addAll(ForceAssignable.filterToEntityList(game.getForces().getFullEntities(force)));
- }
+ }
// Find certain unit features among all units the player can access
// Used to hide some menu items entirely like "Form Squadron" when there's no fighter in the game
@@ -188,15 +188,15 @@ static ScalingPopup getPopup(List entities, List forces, ActionLi
if (optBurstMG || optLRMHotLoad) {
popup.add(equipMenu(anyRFMGOn, anyRFMGOff, anyHLOn, anyHLOff, optLRMHotLoad, optBurstMG, listener, seIds));
}
-
+
if (optQuirks) {
popup.add(quirksMenu(!entities.isEmpty() && canSeeAll, listener, eIds));
}
-
+
popup.add(ScalingPopup.spacer());
popup.add(changeOwnerMenu(!entities.isEmpty() || !forces.isEmpty(), clientGui, listener, entities, forces));
popup.add(loadMenu(clientGui, true, listener, joinedEntities));
-
+
if (accessibleCarriers) {
popup.add(menuItem("Disembark / leave from carriers", LMP_UNLOAD + NOINFO + seIds, !noneEmbarked, listener));
popup.add(menuItem("Offload all carried units", LMP_UNLOADALL + NOINFO + seIds, anyCarrier, listener));
@@ -282,7 +282,7 @@ private static JMenuItem forceTreeMenu(Force force, Game game, String enToken, A
static String idString(Game game, int id) {
if (PreferenceManager.getClientPreferences().getShowUnitId()) {
- return " [" + id + "]";
+ return " [" + id + "]";
} else {
return "";
}
@@ -303,7 +303,7 @@ private static JMenu loadMenu(ClientGUI cg, boolean enabled, ActionListener list
.filter(e -> !entities.contains(e))
.filter(e -> canLoadAll(e, entities))
.forEach(e -> menu.add(menuItem(
- "" + e.getShortNameRaw() + idString(game, e.getId()) + " (Free Collars: " + ((Jumpship) e).getFreeDockingCollars() + ")",
+ "" + e.getShortNameRaw() + idString(game, e.getId()) + " (Free Collars: " + ((Jumpship) e).getFreeDockingCollars() + ")",
LMP_LOAD + "|" + e.getId() + ":-1" + enToken(entities), enabled, listener)));
} else if (entities.stream().noneMatch(e -> e.hasETypeFlag(Entity.ETYPE_PROTOMECH))) {
// Standard loading, not ProtoMeks, not DropShip -> JumpShip
@@ -312,7 +312,7 @@ private static JMenu loadMenu(ClientGUI cg, boolean enabled, ActionListener list
.filter(e -> !entities.contains(e))
.filter(e -> canLoadAll(e, entities))
.forEach(e -> menu.add(menuItem(
- "" + e.getShortNameRaw() + idString(game, e.getId()),
+ "" + e.getShortNameRaw() + idString(game, e.getId()),
LMP_LOAD + "|" + e.getId() + ":-1" + enToken(entities), enabled, listener)));
}
}
@@ -380,7 +380,7 @@ private static JMenu squadronMenu(ClientGUI cg, boolean enabled, ActionListener
.filter(e -> e instanceof FighterSquadron)
.filter(e -> !entities.contains(e))
.filter(e -> canLoadAll(e, entities))
- .forEach(e -> menu.add(menuItem("Join " + e.getShortName(),
+ .forEach(e -> menu.add(menuItem("Join " + e.getShortName(),
LMP_LOAD + "|" + e.getId() + ":-1" + enToken(entities), enabled, listener)));
}
menu.setEnabled(enabled && (menu.getItemCount() > 0));
@@ -394,8 +394,8 @@ private static JMenu squadronMenu(ClientGUI cg, boolean enabled, ActionListener
private static JMenu prioTargetMenu(ClientGUI cg, boolean enabled, ActionListener listener,
Collection entities) {
JMenu menu = new JMenu("Set Priority Target for");
- if (enabled && !cg.getBots().isEmpty()) {
- for (String bot : cg.getBots().keySet()) {
+ if (enabled && !cg.getLocalBots().isEmpty()) {
+ for (String bot : cg.getLocalBots().keySet()) {
menu.add(menuItem(bot, LMP_PRIO_TARGET + "|" + bot + enToken(entities), enabled, listener));
}
}
@@ -456,7 +456,7 @@ private static JMenu deployMenu(ClientGUI clientGui, boolean enabled, ActionList
for (int i = 11; i < 41; i++) {
veryLateMenu.add(menuItem("Before round " + i, LMP_DEPLOY + "|" + i + eIds, enabled, listener));
}
-
+
lateMenu.add(veryLateMenu);
menu.add(lateMenu);
}
@@ -505,7 +505,7 @@ private static JMenu c3Menu(boolean enabled, Collection entities, Client
menu.add(menuItem("Form C3 Lance", LMP_C3FORMC3 + "|" + master.getId() + enToken(entities), true, listener));
}
}
-
+
// Special treatment if a group of NhC3 is selected
if (entities.size() > 1 && entities.size() <= 6) {
Entity master = anyOneElement(entities);
@@ -519,7 +519,7 @@ private static JMenu c3Menu(boolean enabled, Collection entities, Client
entity = entities.stream().filter(e -> e.hasC3S() || e.hasNhC3()).findAny().orElse(entity);
Game game = cg.getClient().getGame();
ArrayList