wExtR.setText("---"); //$NON-NLS-1$
return;
}
Mounted mounted = entity.getWeaponList().get(
weaponList.getSelectedIndex());
WeaponType wtype = (WeaponType) mounted.getType();
// update weapon display
wNameR.setText(mounted.getDesc());
if (mounted.hasChargedCapacitor()) {
wHeatR.setText(Integer.toString((Compute.dialDownHeat(mounted,
wtype) + 5)));
} else if (wtype.hasFlag(WeaponType.F_ENERGY)
&& wtype.hasModes()
&& clientgui.getClient().game.getOptions().booleanOption(
"tacops_energy_weapons")) {
wHeatR.setText(Integer.toString((Compute.dialDownHeat(mounted,
wtype))));
} else {
wHeatR.setText(Integer.toString(mounted.getCurrentHeat()));
}
wArcHeatR.setText(Integer.toString(entity.getHeatInArc(mounted
.getLocation(), mounted.isRearMounted())));
if (wtype.getDamage() == WeaponType.DAMAGE_MISSILE) {
wDamR.setText(Messages.getString("MechDisplay.Missile")); //$NON-NLS-1$
} else if (wtype.getDamage() == WeaponType.DAMAGE_VARIABLE) {
wDamR.setText(Messages.getString("MechDisplay.Variable")); //$NON-NLS-1$
} else if (wtype.getDamage() == WeaponType.DAMAGE_SPECIAL) {
wDamR.setText(Messages.getString("MechDisplay.Special")); //$NON-NLS-1$
} else if (wtype.getDamage() == WeaponType.DAMAGE_ARTILLERY) {
StringBuffer damage = new StringBuffer();
damage.append(Integer.toString(wtype.getRackSize()))
.append('/').append(
Integer.toString(wtype.getRackSize() / 2));
wDamR.setText(damage.toString());
} else if (wtype.hasFlag(WeaponType.F_ENERGY)
&& wtype.hasModes()
&& clientgui.getClient().game.getOptions().booleanOption(
"tacops_energy_weapons")) {
if (mounted.hasChargedCapacitor()) {
wDamR.setText(Integer.toString(Compute.dialDownDamage(
mounted, wtype) + 5));
} else {
wDamR.setText(Integer.toString(Compute.dialDownDamage(
mounted, wtype)));
}
} else {
wDamR.setText(Integer.toString(wtype.getDamage()));
}
// update range
int shortR = wtype.getShortRange();
int mediumR = wtype.getMediumRange();
int longR = wtype.getLongRange();
int extremeR = wtype.getExtremeRange();
if ((entity.getLocationStatus(mounted.getLocation()) == ILocationExposureStatus.WET)
|| (longR == 0)) {
shortR = wtype.getWShortRange();
mediumR = wtype.getWMediumRange();
longR = wtype.getWLongRange();
extremeR = wtype.getWExtremeRange();
}
if (wtype.getMinimumRange() > 0) {
wMinR.setText(Integer.toString(wtype.getMinimumRange()));
} else {
wMinR.setText("---"); //$NON-NLS-1$
}
if (shortR > 1) {
wShortR.setText("1 - " + shortR); //$NON-NLS-1$
} else {
wShortR.setText("" + shortR); //$NON-NLS-1$
}
if (mediumR - shortR > 1) {
wMedR.setText(shortR + 1 + " - " + mediumR); //$NON-NLS-1$
} else {
wMedR.setText("" + mediumR); //$NON-NLS-1$
}
if (longR - mediumR > 1) {
wLongR.setText(mediumR + 1 + " - " + longR); //$NON-NLS-1$
} else {
wLongR.setText("" + longR); //$NON-NLS-1$
}
if (extremeR - longR > 1) {
wExtR.setText(longR + 1 + " - " + extremeR); //$NON-NLS-1$
} else {
wExtR.setText("" + extremeR); //$NON-NLS-1$
}
// Update the range display to account for the weapon's loaded ammo.
if (mounted.getLinked() != null) {
updateRangeDisplayForAmmo(mounted.getLinked());
}
if (entity instanceof Aero) {
// change damage report to a statement of standard or capital
if (wtype.isCapital()) {
wDamR.setText(Messages.getString("MechDisplay.CapitalD")); //$NON-NLS-1$
} else {
wDamR.setText(Messages.getString("MechDisplay.StandardD")); //$NON-NLS-1$
}
// if this is a weapons bay, then I need to compile it to get
// accurate results
if (wtype instanceof BayWeapon) {
compileWeaponBay(mounted, wtype.isCapital());
} else {
// otherwise I need to replace range display with standard
// ranges and attack values
updateAttackValues(wtype, mounted.getLinked());
}
}
// update weapon bay selector
int chosen = m_chBayWeapon.getSelectedIndex();
m_chBayWeapon.removeAllItems();
if (!(wtype instanceof BayWeapon) || !entity.usesWeaponBays()) {
m_chBayWeapon.setEnabled(false);
} else {
m_chBayWeapon.setEnabled(true);
for (int wId : mounted.getBayWeapons()) {
Mounted curWeapon = entity.getEquipment(wId);
if (null == curWeapon) {
continue;
}
m_chBayWeapon.addItem(formatBayWeapon(curWeapon));
}
if (chosen == -1) {
m_chBayWeapon.setSelectedIndex(0);
} else {
m_chBayWeapon.setSelectedIndex(chosen);
}
}
// update ammo selector
((DefaultComboBoxModel) m_chAmmo.getModel()).removeAllElements();
Mounted oldmount = mounted;
if (wtype instanceof BayWeapon) {
int n = m_chBayWeapon.getSelectedIndex();
if (n == -1) {
n = 0;
}
mounted = entity.getEquipment(mounted.getBayWeapons()
.elementAt(n));
wtype = (WeaponType) mounted.getType();
}
if (wtype.getAmmoType() == AmmoType.T_NA) {
m_chAmmo.setEnabled(false);
} else if (wtype.hasFlag(WeaponType.F_ONESHOT)) {
if (mounted.getLinked().getShotsLeft() == 1) {
m_chAmmo.addItem(formatAmmo(mounted.getLinked()));
m_chAmmo.setEnabled(true);
} else {
m_chAmmo.setEnabled(false);
}
} else {
if (!(entity instanceof Infantry)
|| (entity instanceof BattleArmor)) {
m_chAmmo.setEnabled(true);
} else {
m_chAmmo.setEnabled(false);
}
vAmmo = new ArrayList<Mounted>();
int nCur = -1;
int i = 0;
for (Mounted mountedAmmo : entity.getAmmo()) {
AmmoType atype = (AmmoType) mountedAmmo.getType();
// for all aero units other than fighters,
// ammo must be located in the same place to be usable
boolean same = true;
if ((entity instanceof SmallCraft)
|| (entity instanceof Jumpship)) {
same = (mounted.getLocation() == mountedAmmo
.getLocation());
}
boolean rightBay = true;
if (entity.usesWeaponBays()
&& !(entity instanceof FighterSquadron)) {
rightBay = oldmount.ammoInBay(entity
.getEquipmentNum(mountedAmmo));
}
if (mountedAmmo.isAmmoUsable() && same && rightBay
&& (atype.getAmmoType() == wtype.getAmmoType())
&& (atype.getRackSize() == wtype.getRackSize())) {
vAmmo.add(mountedAmmo);
// we don't want this to fire the actionlistener,
// otherwise linked ammo would change
m_chAmmo.removeActionListener(this);