use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class MVFArmorView method setFromEntity.
public void setFromEntity(Entity en) {
etype = en.getEntityType();
industrial = (en instanceof Mech) && ((Mech) en).isIndustrial();
movementMode = en.getMovementMode();
refresh();
cbArmorType.removeActionListener(this);
spnTonnage.removeChangeListener(this);
if (en.hasPatchworkArmor()) {
for (int i = 0; i < cbArmorType.getModel().getSize(); i++) {
if (cbArmorType.getItemAt(i) == null) {
cbArmorType.setSelectedIndex(i);
break;
}
}
tonnageModel.setValue(Math.min(UnitUtil.getMaximumArmorTonnage(en), en.getLabArmorTonnage()));
spnTonnage.setEnabled(false);
btnMaximize.setEnabled(false);
btnUseRemaining.setEnabled(false);
} else {
String name = EquipmentType.getArmorTypeName(en.getArmorType(0), TechConstants.isClan(en.getArmorTechLevel(0)));
EquipmentType eq = EquipmentType.get(name);
cbArmorType.setSelectedItem(eq);
tonnageModel.setValue(Math.min(UnitUtil.getMaximumArmorTonnage(en), en.getLabArmorTonnage()));
tonnageModel.setMaximum(UnitUtil.getMaximumArmorTonnage(en));
spnTonnage.setEnabled(true);
btnMaximize.setEnabled(true);
btnUseRemaining.setEnabled(true);
}
cbArmorType.addActionListener(this);
spnTonnage.addChangeListener(this);
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class MekChassisView method refreshEnhancement.
private void refreshEnhancement() {
cbEnhancement.removeActionListener(this);
EquipmentType prev = (EquipmentType) cbEnhancement.getSelectedItem();
cbEnhancement.removeAllItems();
cbEnhancement.addItem(null);
if (!isSuperheavy() && !isPrimitive()) {
if (isIndustrial()) {
// $NON-NLS-1$
EquipmentType eq = EquipmentType.get("Industrial TSM");
if (techManager.isLegal(eq)) {
cbEnhancement.addItem(eq);
}
} else {
cbEnhancement.showTechBase(techManager.useMixedTech());
for (String name : ENHANCEMENT_NAMES) {
EquipmentType eq = EquipmentType.get(name);
if (techManager.isLegal(eq)) {
cbEnhancement.addItem(eq);
}
}
}
}
cbEnhancement.setSelectedItem(prev);
cbEnhancement.addActionListener(this);
if (cbEnhancement.getSelectedIndex() < 0) {
cbEnhancement.setSelectedIndex(0);
}
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class MekChassisView method setStructureType.
public void setStructureType(String structureName) {
EquipmentType structure = EquipmentType.get(structureName);
cbStructure.setSelectedItem(structure);
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class UnitUtil method resetArmor.
/**
* Remove all mounts for the current armor type from a single location on the passed unit
* and sets the armor type in that location to standard.
*
* @param unit The <code>Entity</code>
* @param loc The location from which to remove the armor mounts.
*/
public static void resetArmor(Entity unit, int loc) {
String name = EquipmentType.getArmorTypeName(unit.getArmorType(loc), TechConstants.isClan(unit.getArmorTechLevel(loc)));
EquipmentType eq = EquipmentType.get(name);
if (null != eq) {
for (int slot = 0; slot < unit.getNumberOfCriticals(loc); slot++) {
final CriticalSlot crit = unit.getCritical(loc, slot);
if ((null != crit) && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT) && (null != crit.getMount()) && crit.getMount().getType().equals(eq)) {
unit.getMisc().remove(crit.getMount());
unit.setCritical(loc, slot, null);
}
}
}
unit.setArmorType(EquipmentType.T_ARMOR_STANDARD, loc);
unit.setArmorTechLevel(TechConstants.T_INTRO_BOXSET, loc);
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class WeaponListCellRenderer 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);
EquipmentType eq = EquipmentType.get(value.toString());
if (eq == null) {
return label;
}
label.setText(UnitUtil.getCritName(unit, eq));
label.setName(value.toString());
label.setToolTipText(UnitUtil.getToolTipInfo(unit, new Mounted(unit, eq)));
return label;
}
Aggregations