use of megamek.common.WeaponType in project megameklab by MegaMek.
the class DropTargetCriticalList method mousePressed.
public void mousePressed(MouseEvent e) {
if (buildView) {
if (e.getButton() == MouseEvent.BUTTON2) {
setSelectedIndex(locationToIndex(e.getPoint()));
removeCrit();
} else if (e.getButton() == MouseEvent.BUTTON3) {
setSelectedIndex(locationToIndex(e.getPoint()));
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
removeCrit();
return;
}
int location = getCritLocation();
JPopupMenu popup = new JPopupMenu();
CriticalSlot cs = getCrit();
final Mounted mount = getMounted();
if ((e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
changeWeaponFacing(!mount.isRearMounted());
return;
}
if (mount != null && (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
changeOmniMounting(!mount.isOmniPodMounted());
return;
}
if (mount != null && !((getUnit().getEntityType() & Entity.ETYPE_QUADVEE) == Entity.ETYPE_QUADVEE && mount.getType() instanceof MiscType && mount.getType().hasFlag(MiscType.F_TRACKS))) {
JMenuItem info;
if (!UnitUtil.isFixedLocationSpreadEquipment(mount.getType())) {
popup.setAutoscrolls(true);
info = new JMenuItem("Remove " + mount.getName());
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeCrit();
}
});
popup.add(info);
}
info = new JMenuItem("Delete " + mount.getName());
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeMount();
}
});
if (!((getUnit() instanceof BattleArmor) && UnitUtil.isFixedLocationSpreadEquipment(mount.getType()))) {
popup.add(info);
}
// Allow making this a sort weapon
if ((mount.getType() instanceof WeaponType) && !mount.isSquadSupportWeapon() && mount.getLocation() == BattleArmor.LOC_SQUAD && (getUnit() instanceof BattleArmor) && ((BattleArmor) getUnit()).getChassisType() != BattleArmor.CHASSIS_TYPE_QUAD) {
info = new JMenuItem("Mount as squad support weapon");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mount.setSquadSupportWeapon(true);
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
// Adding ammo as a squad support mount is slightly different
if ((mount.getType() instanceof AmmoType) && !mount.getType().hasFlag(WeaponType.F_MISSILE) && !mount.isSquadSupportWeapon() && mount.getLocation() == BattleArmor.LOC_SQUAD && (getUnit() instanceof BattleArmor) && ((BattleArmor) getUnit()).getChassisType() != BattleArmor.CHASSIS_TYPE_QUAD) {
boolean enabled = false;
for (Mounted weapon : getUnit().getWeaponList()) {
WeaponType wtype = (WeaponType) weapon.getType();
if (weapon.isSquadSupportWeapon() && AmmoType.isAmmoValid(mount, wtype)) {
enabled = true;
}
}
info = new JMenuItem("Mount as squad support weapon");
info.setEnabled(enabled);
info.setToolTipText("Ammo can only be squad mounted along " + "with a weapon that uses it");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mount.setSquadSupportWeapon(true);
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
// Allow removing squad support weapon
if (mount.isSquadSupportWeapon()) {
info = new JMenuItem("Remove squad support weapon mount");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mount.setSquadSupportWeapon(false);
// squad support weapon
for (Mounted ammo : getUnit().getAmmo()) {
ammo.setSquadSupportWeapon(false);
}
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
// Right-clicked on a DWP that has an attached weapon
if (mount.getType().hasFlag(MiscType.F_DETACHABLE_WEAPON_PACK) && mount.getLinked() != null) {
info = new JMenuItem("Remove attached weapon");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mounted attached = mount.getLinked();
attached.setDWPMounted(false);
mount.setLinked(null);
mount.setLinkedBy(null);
attached.setLinked(null);
attached.setLinkedBy(null);
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
// Right-clicked on a AP Mount that has an attached weapon
if (mount.getType().hasFlag(MiscType.F_AP_MOUNT) && mount.getLinked() != null) {
info = new JMenuItem("Remove attached weapon");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Mounted attached = mount.getLinked();
attached.setAPMMounted(false);
mount.setLinked(null);
mount.setLinkedBy(null);
attached.setLinked(null);
attached.setLinkedBy(null);
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
if ((mount.getLocation() != Mech.LOC_LARM) && (mount.getLocation() != Mech.LOC_RARM)) {
if (mount.getType() instanceof WeaponType) {
if (getUnit().hasWorkingMisc(MiscType.F_QUAD_TURRET, -1, mount.getLocation()) || getUnit().hasWorkingMisc(MiscType.F_SHOULDER_TURRET, -1, mount.getLocation()) || (getUnit().hasWorkingMisc(MiscType.F_HEAD_TURRET, -1, Mech.LOC_CT) && (mount.getLocation() == Mech.LOC_HEAD))) {
if (!mount.isMechTurretMounted()) {
info = new JMenuItem("Mount " + mount.getName() + " in Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeTurretMount(true);
}
});
popup.add(info);
} else {
info = new JMenuItem("Remove " + mount.getName() + " from Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeTurretMount(false);
}
});
popup.add(info);
}
}
}
if (!(getUnit() instanceof BattleArmor) && ((mount.getType() instanceof WeaponType) || ((mount.getType() instanceof MiscType) && mount.getType().hasFlag(MiscType.F_LIFTHOIST)))) {
if (!mount.isRearMounted()) {
info = new JMenuItem("Make " + mount.getName() + " Rear Facing");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeWeaponFacing(true);
}
});
popup.add(info);
} else {
info = new JMenuItem("Make " + mount.getName() + " Forward Facing");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeWeaponFacing(false);
}
});
popup.add(info);
}
}
}
// Allow number of shots selection
if ((getUnit() instanceof BattleArmor) && mount.getType() instanceof AmmoType) {
AmmoType at = (AmmoType) mount.getType();
int maxNumShots = TestBattleArmor.NUM_SHOTS_PER_CRIT;
int stepSize = 1;
if (at.getAmmoType() == AmmoType.T_BA_TUBE) {
maxNumShots = TestBattleArmor.NUM_SHOTS_PER_CRIT_TA;
stepSize = 2;
}
for (int i = at.getShots(); i <= maxNumShots; i += stepSize) {
if (i == mount.getBaseShotsLeft()) {
continue;
}
info = new JMenuItem("Set Shots: " + i);
final int shots = i;
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
mount.setShotsLeft(shots);
if (refresh != null) {
refresh.refreshAll();
}
}
});
popup.add(info);
}
}
if (getUnit().isOmni() && !mount.getType().isOmniFixedOnly()) {
if (mount.isOmniPodMounted()) {
info = new JMenuItem("Change to fixed mount");
info.addActionListener(ev -> changeOmniMounting(false));
popup.add(info);
} else if (UnitUtil.canPodMount(getUnit(), mount)) {
info = new JMenuItem("Change to pod mount");
info.addActionListener(ev -> changeOmniMounting(true));
popup.add(info);
}
}
}
if ((getUnit() instanceof BipedMech || getUnit() instanceof TripodMech) && ((location == Mech.LOC_LARM) || (location == Mech.LOC_RARM))) {
boolean canHaveLowerArm = true;
if (getUnit().isOmni()) {
int numCrits = getUnit().getNumberOfCriticals(location);
for (int slot = 0; slot < numCrits; slot++) {
CriticalSlot crit = getUnit().getCritical(location, slot);
if (crit == null) {
continue;
}
if (crit.getType() == CriticalSlot.TYPE_SYSTEM) {
continue;
}
Mounted m = crit.getMount();
if ((m.getType() instanceof GaussWeapon) || (m.getType() instanceof ACWeapon) || (m.getType() instanceof UACWeapon) || (m.getType() instanceof LBXACWeapon) || (m.getType() instanceof PPCWeapon)) {
canHaveLowerArm = false;
}
}
}
popup.addSeparator();
popup.setAutoscrolls(true);
if (canHaveLowerArm && ((getUnit().getCritical(location, 3) == null) || (getUnit().getCritical(location, 3).getType() != CriticalSlot.TYPE_SYSTEM))) {
JMenuItem info = new JMenuItem("Add Hand");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addHand(Integer.parseInt(e.getActionCommand()));
}
});
popup.add(info);
} else if ((getUnit().getCritical(location, 3) != null) && (getUnit().getCritical(location, 3).getType() == CriticalSlot.TYPE_SYSTEM)) {
JMenuItem info = new JMenuItem("Remove Hand");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeHand(Integer.parseInt(e.getActionCommand()));
}
});
popup.add(info);
}
if (canHaveLowerArm && ((getUnit().getCritical(location, 2) == null) || (getUnit().getCritical(location, 2).getType() != CriticalSlot.TYPE_SYSTEM))) {
JMenuItem info = new JMenuItem("Add Lower Arm");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
addArm(Integer.parseInt(e.getActionCommand()));
}
});
popup.add(info);
} else if ((getUnit().getCritical(location, 2) != null) && (getUnit().getCritical(location, 2).getType() == CriticalSlot.TYPE_SYSTEM)) {
JMenuItem info = new JMenuItem("Remove Lower Arm");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeArm(Integer.parseInt(e.getActionCommand()));
}
});
popup.add(info);
}
}
if (UnitUtil.isArmorable(cs) && !(getUnit() instanceof BattleArmor) && eSource.getTechManager().isLegal(Entity.getArmoredComponentTechAdvancement())) {
popup.addSeparator();
if (cs.isArmored()) {
JMenuItem info = new JMenuItem("Remove Armoring");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeArmoring();
}
});
popup.add(info);
} else if (!(getUnit() instanceof Mech && ((Mech) getUnit()).isSuperHeavy())) {
JMenuItem info = new JMenuItem("Add Armoring");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeArmoring();
}
});
popup.add(info);
}
}
if (popup.getComponentCount() > 0) {
popup.show(this, e.getX(), e.getY());
}
}
}
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class StringUtils method getEquipmentInfo.
public static String getEquipmentInfo(Dropship unit, Mounted mount, Mounted bay) {
String info = "";
if (mount.getType() instanceof WeaponType) {
WeaponType weapon = (WeaponType) mount.getType();
if (weapon.getAmmoType() == AmmoType.T_AR10) {
int barracudaAmmo = 0;
int killerwhaleAmmo = 0;
int whitesharkAmmo = 0;
for (int ammoIndex : bay.getBayAmmo()) {
Mounted ammoMount = unit.getEquipment(ammoIndex);
try {
AmmoType aType = (AmmoType) ammoMount.getType();
if ((mount.getLinked() != null) && (aType.getRackSize() == weapon.getRackSize()) && (aType.getAmmoType() == weapon.getAmmoType())) {
if (aType.hasFlag(AmmoType.F_AR10_BARRACUDA)) {
barracudaAmmo += ammoMount.getUsableShotsLeft();
} else if (aType.hasFlag(AmmoType.F_AR10_KILLER_WHALE)) {
killerwhaleAmmo += ammoMount.getUsableShotsLeft();
} else if (aType.hasFlag(AmmoType.F_AR10_WHITE_SHARK)) {
whitesharkAmmo += ammoMount.getUsableShotsLeft();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
info = "";
if (barracudaAmmo > 0) {
info += String.format("[%1$s Barracuda misl]", barracudaAmmo);
}
if (killerwhaleAmmo > 0) {
info += String.format("[%1$s Killer Whale misl]", killerwhaleAmmo);
}
if (whitesharkAmmo > 0) {
info += String.format("[%1$s White Shark misl]", whitesharkAmmo);
}
} else if (weapon.getAmmoType() == AmmoType.T_MML) {
int lrmAmmo = 0;
int srmAmmo = 0;
for (int ammoIndex : bay.getBayAmmo()) {
Mounted ammoMount = unit.getEquipment(ammoIndex);
try {
AmmoType aType = (AmmoType) ammoMount.getType();
if ((mount.getLinked() != null) && (aType.getRackSize() == weapon.getRackSize()) && (aType.getAmmoType() == weapon.getAmmoType())) {
if (aType.hasFlag(AmmoType.F_MML_LRM)) {
lrmAmmo += ammoMount.getUsableShotsLeft();
} else {
srmAmmo += ammoMount.getUsableShotsLeft();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
info = String.format("[%1$s LRM rnds][%2$s SRM rnds]", lrmAmmo, srmAmmo);
} else {
int totalAmmo = 0;
for (int ammoIndex : bay.getBayAmmo()) {
Mounted ammoMount = unit.getEquipment(ammoIndex);
try {
if ((mount.getLinked() != null) && (ammoMount.getType() == mount.getLinked().getType())) {
totalAmmo += ammoMount.getUsableShotsLeft();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
if (weapon instanceof ScreenLauncherWeapon) {
info = String.format("[%1$s Screens]", totalAmmo);
} else if (weapon.hasFlag(WeaponType.F_BALLISTIC) || weapon.hasFlag(WeaponType.F_MISSILE) || weapon.hasFlag(WeaponType.F_ARTILLERY) || (weapon.getAtClass() == WeaponType.CLASS_CAPITAL_MISSILE)) {
info = String.format("[%1$s rnds]", totalAmmo);
}
}
}
return info;
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class StringUtils method getEquipmentInfo.
public static String getEquipmentInfo(Aero unit, Mounted mount) {
String info = "";
if (mount.getType() instanceof WeaponType) {
WeaponType weapon = (WeaponType) mount.getType();
if (weapon instanceof InfantryWeapon) {
info = Integer.toString(weapon.getDamage());
if (weapon.hasFlag(WeaponType.F_BALLISTIC)) {
info += " (B)";
} else if (weapon.hasFlag(WeaponType.F_ENERGY)) {
info += " (E)";
} else if (weapon.hasFlag(WeaponType.F_MISSILE)) {
info += " (M)";
} else if (weapon.hasFlag(WeaponType.F_INF_POINT_BLANK)) {
info += " (P)";
}
if (weapon.hasFlag(WeaponType.F_INF_BURST)) {
info += "B";
}
if (weapon.hasFlag(WeaponType.F_INF_AA)) {
info += "A";
}
if (weapon.hasFlag(WeaponType.F_FLAMER)) {
info += "F";
}
if (weapon.hasFlag(WeaponType.F_INF_NONPENETRATING)) {
info += "N";
}
} else if (weapon.hasFlag(WeaponType.F_MGA)) {
info = "[T]";
} else if (weapon instanceof ISC3M) {
info = "[E]";
} else if (weapon.getDamage() < 0) {
if (weapon instanceof SRMWeapon) {
info = "[M,C]";
} else if ((weapon instanceof LRMWeapon) || (weapon instanceof MekMortarWeapon)) {
info = "[M,C,S]";
} else if ((weapon instanceof MRMWeapon) || (weapon instanceof RLWeapon)) {
info = "[M,C]";
} else if ((weapon instanceof ISSnubNosePPC) || (weapon instanceof ISBombastLaser)) {
info = "[DE,V]";
} else if (weapon instanceof ISVariableSpeedPulseLaserSmall) {
info = "[P,V]";
} else if (weapon instanceof ISVariableSpeedPulseLaserMedium) {
info = "[P,V]";
} else if (weapon instanceof ISVariableSpeedPulseLaserLarge) {
info = "[P,V]";
} else if (weapon instanceof ISHGaussRifle) {
info = "[DB,X]";
} else if (weapon instanceof ISPlasmaRifle) {
info = "[DE,H,AI]";
} else if (weapon instanceof CLPlasmaCannon) {
info = "[DE,H,AI]";
} else if (weapon instanceof HAGWeapon) {
info = "[C,F]";
} else if (weapon instanceof ArtilleryWeapon) {
info = "[AE,S,F]";
} else if (weapon instanceof ArtilleryCannonWeapon) {
info = "[DB,AE]";
} else if (weapon instanceof ThunderBoltWeapon) {
info = "[M]";
} else if (weapon instanceof NarcWeapon) {
info = "[M]";
} else {
info = "";
}
} else if (weapon instanceof UACWeapon) {
info = "[DB,R/C]";
} else {
info = " [";
if (weapon.hasFlag(WeaponType.F_BALLISTIC)) {
info += "DB,";
}
if (UnitUtil.isAMS(weapon) || (weapon instanceof BPodWeapon)) {
info += "PD,";
} else if (weapon.hasFlag(WeaponType.F_PULSE)) {
info += "P,";
} else if (weapon.hasFlag(WeaponType.F_ENERGY)) {
info += "DE,";
}
if ((weapon instanceof LBXACWeapon) || (weapon instanceof ISSilverBulletGauss)) {
info += "C/F,";
}
if (UnitUtil.hasSwitchableAmmo(weapon)) {
info += "S,";
}
if ((weapon instanceof MGWeapon) || (weapon instanceof BPodWeapon) || (weapon instanceof CLERPulseLaserSmall) || (weapon instanceof ISXPulseLaserSmall) || (weapon instanceof ISPulseLaserSmall) || (weapon instanceof CLPulseLaserSmall) || (weapon instanceof CLPulseLaserMicro)) {
info += "AI,";
}
if (weapon instanceof FlamerWeapon) {
info += "H,AI,";
}
if (weapon.isExplosive(mount) && !(weapon instanceof ACWeapon) && (!(weapon instanceof PPCWeapon) || ((mount.getLinkedBy() != null) && mount.getLinkedBy().getType().hasFlag(MiscType.F_PPC_CAPACITOR)))) {
info += "X,";
}
if (weapon.hasFlag(WeaponType.F_ONESHOT)) {
info += "OS,";
}
info = info.substring(0, info.length() - 1) + "]";
}
} else {
info = "[E]";
}
return info;
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class UnitUtil method removeMounted.
public static void removeMounted(Entity unit, Mounted mount) {
UnitUtil.removeCriticals(unit, mount);
// Some special checks for BA
if (unit instanceof BattleArmor) {
// to detach the weapon
if (mount.getType().hasFlag(MiscType.F_DETACHABLE_WEAPON_PACK) && (mount.getLinked() != null)) {
Mounted link = mount.getLinked();
link.setDWPMounted(false);
link.setLinked(null);
link.setLinkedBy(null);
}
// to clear the mounted status of the DWP
if ((mount.getLinkedBy() != null) && mount.getLinkedBy().getType().hasFlag(MiscType.F_DETACHABLE_WEAPON_PACK)) {
Mounted dwp = mount.getLinkedBy();
dwp.setLinked(null);
dwp.setLinkedBy(null);
}
// to detach the weapon
if (mount.getType().hasFlag(MiscType.F_AP_MOUNT) && (mount.getLinked() != null)) {
Mounted link = mount.getLinked();
link.setAPMMounted(false);
link.setLinked(null);
link.setLinkedBy(null);
}
// to clear the mounted status of the AP Mount
if ((mount.getLinkedBy() != null) && mount.getLinkedBy().getType().hasFlag(MiscType.F_AP_MOUNT)) {
Mounted apm = mount.getLinkedBy();
apm.setLinked(null);
apm.setLinkedBy(null);
}
}
// Some special checks for Aeros
if (unit instanceof Aero) {
if (mount.getType() instanceof WeaponType) {
// Aeros have additional weapon lists that need to be cleared
((Aero) unit).getTotalWeaponList().remove(mount);
((Aero) unit).getWeaponBayList().remove(mount);
((Aero) unit).getWeaponGroupList().remove(mount);
}
}
// We will need to reset the equipment numbers of the bay ammo and weapons
Map<Mounted, List<Mounted>> bayWeapons = new HashMap<>();
Map<Mounted, List<Mounted>> bayAmmo = new HashMap<>();
for (Mounted bay : unit.getWeaponBayList()) {
List<Mounted> list = bay.getBayWeapons().stream().map(n -> unit.getEquipment(n)).collect(Collectors.toList());
bayWeapons.put(bay, list);
list = bay.getBayAmmo().stream().map(n -> unit.getEquipment(n)).collect(Collectors.toList());
bayAmmo.put(bay, list);
}
unit.getEquipment().remove(mount);
if (mount.getType() instanceof MiscType) {
unit.getMisc().remove(mount);
} else if (mount.getType() instanceof AmmoType) {
unit.getAmmo().remove(mount);
} else {
unit.getWeaponList().remove(mount);
unit.getTotalWeaponList().remove(mount);
}
for (Mounted bay : bayWeapons.keySet()) {
bay.getBayWeapons().clear();
for (Mounted w : bayWeapons.get(bay)) {
if (mount != w) {
bay.getBayWeapons().add(unit.getEquipmentNum(w));
}
}
}
for (Mounted bay : bayAmmo.keySet()) {
bay.getBayAmmo().clear();
for (Mounted a : bayAmmo.get(bay)) {
if (mount != a) {
bay.getBayAmmo().add(unit.getEquipmentNum(a));
}
}
}
// An example of this would be removing a linked Artemis IV FCS
for (Mounted m : unit.getEquipment()) {
if (mount.equals(m.getLinkedBy())) {
m.setLinkedBy(null);
}
}
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class CritListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean hasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, hasFocus);
this.list = list;
setPreferredSize(new Dimension(110, 15));
setMaximumSize(new Dimension(110, 15));
setMinimumSize(new Dimension(110, 15));
String[] split = ((String) value).split(":");
label.setText(split[0]);
CriticalSlot cs;
if (split.length > 2) {
int eqId = Integer.parseInt(split[2]);
cs = new CriticalSlot(unit.getEquipment(eqId));
} else if (split.length > 1) {
cs = getCrit(Integer.parseInt(split[1]));
} else if (((String) value).equals("-Empty-")) {
cs = null;
} else {
cs = getCrit(index);
}
if (cs != null) {
if (cs.getType() == CriticalSlot.TYPE_SYSTEM) {
if (useColor) {
label.setBackground(CConfig.getBackgroundColor(CConfig.CONFIG_SYSTEMS));
label.setForeground(CConfig.getForegroundColor(CConfig.CONFIG_SYSTEMS));
}
if (cs.isArmored()) {
label.setText(label.getText() + " (A)");
}
} else if (cs.getMount() != null) {
Mounted mount = cs.getMount();
if (useColor) {
if (mount.getType() instanceof WeaponType) {
label.setBackground(CConfig.getBackgroundColor(CConfig.CONFIG_WEAPONS));
label.setForeground(CConfig.getForegroundColor(CConfig.CONFIG_WEAPONS));
} else if (mount.getType() instanceof AmmoType) {
label.setBackground(CConfig.getBackgroundColor(CConfig.CONFIG_AMMO));
label.setForeground(CConfig.getForegroundColor(CConfig.CONFIG_AMMO));
} else {
label.setBackground(CConfig.getBackgroundColor(CConfig.CONFIG_EQUIPMENT));
label.setForeground(CConfig.getForegroundColor(CConfig.CONFIG_EQUIPMENT));
}
}
String name = UnitUtil.getCritName(unit, mount.getType());
if (mount.isRearMounted()) {
name += " (R)";
}
if (mount.isArmored()) {
name += " (A)";
}
if (mount.isMechTurretMounted()) {
name += " (T)";
}
if (mount.isSponsonTurretMounted()) {
name += " (ST)";
}
if (mount.isPintleTurretMounted()) {
name += " (PT)";
}
if (mount.isDWPMounted()) {
name += " (DWP)";
}
if (unit.isOmni() && !mount.getType().isOmniFixedOnly()) {
if (mount.isOmniPodMounted()) {
name += " (Pod)";
} else {
name += " (Fixed)";
label.setFont(label.getFont().deriveFont(Font.ITALIC));
}
}
if ((mount.getType().hasFlag(MiscType.F_DETACHABLE_WEAPON_PACK) || mount.getType().hasFlag(MiscType.F_AP_MOUNT)) && mount.getLinked() != null) {
name += " (attached " + mount.getLinked().getName() + ")";
}
// many shots are in this Critical
if ((unit instanceof BattleArmor) && (mount.getType() instanceof AmmoType)) {
name += " (" + mount.getBaseShotsLeft() + ")";
}
String toolTipText = UnitUtil.getToolTipInfo(unit, mount);
if (cs.getMount2() != null) {
mount = cs.getMount2();
name += " | " + UnitUtil.getCritName(unit, mount.getType());
}
label.setText(name);
label.setToolTipText(toolTipText);
}
} else if (useColor) {
label.setBackground(CConfig.getBackgroundColor(CConfig.CONFIG_EMPTY));
label.setForeground(CConfig.getForegroundColor(CConfig.CONFIG_EMPTY));
}
int loc = getCritLocation();
if ((cs != null) && UnitUtil.isLastCrit(unit, cs, index, loc) && UnitUtil.isPreviousCritEmpty(unit, cs, index, loc)) {
label.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.black));
} else if ((cs != null) && UnitUtil.isLastCrit(unit, cs, index, loc)) {
label.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.black));
} else if ((cs != null) && UnitUtil.isPreviousCritEmpty(unit, cs, index, loc)) {
label.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.black));
}
return label;
}
Aggregations