@Override public String getLocationAbbr(int loc) { if (loc == LOC_NMISS) { return "a near miss"; } return super.getLocationAbbr(loc); }
/** * Returns the location that the specified abbreviation indicates */ public int getLocationFromAbbr(String abbr) { for (int i = 0; i < locations(); i++) { if (getLocationAbbr(i).equalsIgnoreCase(abbr)) { return i; } } return Entity.LOC_NONE; }
public String getLocationAbbr(int location) { return getEntity().getLocationAbbr(location); }
/** * Formats displayable location name for use in equipment table. The format of * the name can vary by unit type due to available space based on number of * columns, and in some cases the official TROs have different location names * than the ones used by MM. * * @param entity * The entity the TRO is created for * @param mounted * The mounted equipment * @param rear * Whether the equipment is rear mounted * @return The location name to use in the table. */ protected String formatLocationTableEntry(Entity entity, Mounted mounted) { // Default: location abbreviation return entity.getLocationAbbr(mounted.getLocation()); }
@Override protected String formatLocationTableEntry(Entity entity, Mounted mounted) { String loc = entity.getLocationAbbr(mounted.getLocation()); if (mounted.isRearMounted()) { loc += "(R)"; } return loc; } }
private String getAmmo() { StringBuffer sAmmo = new StringBuffer(); if (entity.getAmmo().size() < 1) { return ""; } sAmmo.append(String.format("%1$-30s %2$3s %3$5s\n", "Ammo", "Loc", "Shots")); sAmmo.append("----------------------------------------\n"); for (Mounted mounted : entity.getAmmo()) { sAmmo.append(String.format("%1$-30s %2$3s %3$5d\n", mounted.getName(), entity.getLocationAbbr(mounted.getLocation()), mounted.getBaseShotsLeft())); } sAmmo.append("\n"); return sAmmo.toString(); }
private String formatAmmo(Mounted m) { StringBuffer sb = new StringBuffer(64); int ammoIndex = m.getDesc().indexOf( Messages.getString("MechDisplay.0")); //$NON-NLS-1$ int loc = m.getLocation(); if (loc != Entity.LOC_NONE) { sb.append('[').append(entity.getLocationAbbr(loc)).append("] "); //$NON-NLS-1$ } if (ammoIndex == -1) { sb.append(m.getDesc()); } else { sb.append(m.getDesc().substring(0, ammoIndex)); sb.append(m.getDesc().substring(ammoIndex + 4)); } if (m.isHotLoaded()) { sb.append(Messages.getString("MechDisplay.isHotLoaded")); } return sb.toString(); }
/** * Worker function that refreshes the combo box with "up-to-date" ammo names. */ public void refreshAmmoBinNames() { int selectedIndex = ammoBins.getSelectedIndex(); ammoBins.removeAllItems(); int currentIndex = 0; for(Mounted ammoBin : matchingAmmoBins) { ammoBins.addItem("(" + ammoBin.getEntity().getLocationAbbr(ammoBin.getLocation()) + ") " + ammoBin.getName()); if(m_mounted.getLinked() == ammoBin) { selectedIndex = currentIndex; } currentIndex++; } if(selectedIndex >= 0) { ammoBins.setSelectedIndex(selectedIndex); } validate(); }
MineChoicePanel(Mounted m) { m_mounted = m; m_choice = new JComboBox<String>(); m_choice.addItem(Messages .getString("CustomMechDialog.Conventional")); //$NON-NLS-1$ m_choice.addItem(Messages.getString("CustomMechDialog.Vibrabomb")); //$NON-NLS-1$ // m_choice.add("Messages.getString("CustomMechDialog.Command-detonated")); // //$NON-NLS-1$ int loc; loc = m.getLocation(); String sDesc = '(' + entity.getLocationAbbr(loc) + ')'; JLabel lLoc = new JLabel(sDesc); GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); add(lLoc, GBC.std()); m_choice.setSelectedIndex(m.getMineType()); add(m_choice, GBC.eol()); }
ammoBins.insertItemAt("(" + ammoBin.getEntity().getLocationAbbr(ammoBin.getLocation()) + ") " + selectedAmmoType.getName(), index);
entity.getLocationAbbr(mounted.getLocation())));
RapidfireMGPanel(Mounted m) { m_mounted = m; int loc = m.getLocation(); String sDesc = Messages .getString( "CustomMechDialog.switchToRapidFire", new Object[] { entity.getLocationAbbr(loc) }); //$NON-NLS-1$ JLabel labRapid = new JLabel(sDesc); GridBagLayout g = new GridBagLayout(); setLayout(g); add(labRapid, GBC.std().anchor(GridBagConstraints.EAST)); chRapid.setSelected(m.isRapidfire()); add(chRapid, GBC.eol()); }
protected Map<String, String> addPatchworkATs(Entity entity, int[][] locSets) { final Map<String, String> retVal = new HashMap<>(); for (final int[] locs : locSets) { if ((locs.length == 0) || (locs[0] >= entity.locations())) { continue; } String val = null; if (locs.length > 1) { for (int i = 1; i < locs.length; i++) { if ((locs[i] < entity.locations()) && (entity.getArmorType(locs[i]) != entity.getArmorType(locs[0]))) { val = Arrays.stream(locs).mapToObj(l -> formatArmorType(entity.getArmorType(l), true)) .collect(Collectors.joining("/")); break; } } } if (null == val) { val = formatArmorType(entity.getArmorType(locs[0]), true); } for (final int loc : locs) { if (loc < entity.locations()) { retVal.put(entity.getLocationAbbr(loc), val); } } } return retVal; }
/** * Returns the abbreviated name of the location specified. */ public String getLocationAbbr(HitData hit) { return getLocationAbbr(hit.getLocation()) + (hit.isRear() && hasRearArmor(hit.getLocation()) ? "R" : "") + (((hit.getEffect() & HitData.EFFECT_CRITICAL) == HitData.EFFECT_CRITICAL) ? " (critical)" : ""); }
/** * This returns a textual description of a specific location of the entity * for visualy impaired users. * * @param loc the location * @return a string descibing the status of the location. */ public String statusToString(int loc) { if (loc == LOC_NONE) { return "No location given."; } return getLocationName(loc) + " (" + getLocationAbbr(loc) + "): Armor: " + getArmorString(loc) + "/" + getOArmor(loc) + " Structure: " + getInternalString(loc) + "/" + getOInternal(loc); }
entity.getLocationAbbr(loc), slot, m.getType() .getInternalName(), unitId); quirkEntries.add(qe);
weaponName.setText("(" + weapon.getEntity().getLocationAbbr(weapon.getLocation()) + ") " + weapon.getName()); add(weaponName, GBC.std());
@Override public String printArmorLocation(int loc) { return StringUtil .makeLength(getEntity().getLocationAbbr(loc) + ":", 10) + StringUtil.makeLength(getEntity().getOInternal(loc), 4) + StringUtil.makeLength(getEntity().getOArmor(loc), 6) + " "; }
public String printArmorLocation(int loc) { if (getEntity().hasRearArmor(loc)) { return StringUtil.makeLength( getEntity().getLocationAbbr(loc) + ":", 5) + StringUtil.makeLength(getEntity().getOInternal(loc), 4) + StringUtil.makeLength(getEntity().getOArmor(loc), 3) + " / " + StringUtil .makeLength(getEntity().getOArmor(loc, true), 2); } return StringUtil.makeLength(getEntity().getLocationAbbr(loc) + ":", 5) + StringUtil.makeLength(getEntity().getOInternal(loc), 4) + StringUtil.makeLength(getEntity().getOArmor(loc), 6) + " "; }
String[] row = { mounted.getName(), entity.getLocationAbbr(mounted.getLocation()), String.valueOf(mounted.getBaseShotsLeft()), "" }; if (entity.isOmni()) {