use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class MekChassisView method refreshStructure.
private void refreshStructure() {
boolean isMixed = techManager.useMixedTech();
boolean isClan = techManager.useClanTechBase();
cbStructure.removeActionListener(this);
EquipmentType prevStructure = (EquipmentType) cbStructure.getSelectedItem();
cbStructure.removeAllItems();
cbStructure.showTechBase(isMixed);
// at standard rules level. Superheavies can only use standard.
if (isIndustrial()) {
String name = EquipmentType.getStructureTypeName(EquipmentType.T_STRUCTURE_INDUSTRIAL, isClan);
cbStructure.addItem(EquipmentType.get(name));
} else if (isPrimitive()) {
String name = EquipmentType.getStructureTypeName(EquipmentType.T_STRUCTURE_STANDARD, isClan);
cbStructure.addItem(EquipmentType.get(name));
} else {
int[] structureTypes = isSuperheavy() ? SUPERHEAVY_STRUCTURE_TYPES : STRUCTURE_TYPES;
for (int i : structureTypes) {
String name = EquipmentType.getStructureTypeName(i, isClan);
EquipmentType structure = EquipmentType.get(name);
// LAMs cannot use bulky structure
if ((getBaseTypeIndex() == BASE_TYPE_LAM) && (structure.getCriticals(null) != 0)) {
continue;
}
if ((null != structure) && techManager.isLegal(structure)) {
cbStructure.addItem(structure);
}
}
}
cbStructure.setSelectedItem(prevStructure);
cbStructure.addActionListener(this);
if (cbStructure.getSelectedIndex() < 0) {
cbStructure.setSelectedIndex(0);
}
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class MovementView method refresh.
public void refresh() {
if (cbJumpType.isVisible()) {
EquipmentType prev = (EquipmentType) cbJumpType.getSelectedItem();
cbJumpType.removeActionListener(this);
cbJumpType.removeAllItems();
for (EquipmentType eq : TestEntity.validJumpJets(etype, industrial)) {
if (techManager.isLegal(eq)) {
cbJumpType.addItem(eq);
}
}
cbJumpType.setSelectedItem(prev);
cbJumpType.addActionListener(this);
if (cbJumpType.getModel().getSize() > 0) {
spnJump.setEnabled(true);
cbJumpType.setEnabled(true);
if ((cbJumpType.getSelectedIndex() < 0)) {
cbJumpType.setSelectedIndex(0);
}
} else {
spnJump.setEnabled(false);
cbJumpType.setEnabled(false);
}
}
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class PatchworkArmorView method initUI.
private void initUI() {
// $NON-NLS-1$
ResourceBundle resourceMap = ResourceBundle.getBundle("megameklab.resources.Views", new EncodeControl());
setLayout(new GridBagLayout());
setBorder(BorderFactory.createTitledBorder(// $NON-NLS-1$
null, // $NON-NLS-1$
resourceMap.getString("ArmorAllocationView.panPatwork.title"), TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(0, 5, 0, 5);
for (int loc = 0; loc < MAX_LOC; loc++) {
JLabel label = new JLabel();
TechComboBox<EquipmentType> combo = new TechComboBox<>(eq -> eq.getName());
combo.setActionCommand(Integer.toString(loc));
combo.addActionListener(this);
labels.add(label);
combos.add(combo);
gbc.gridx = 0;
gbc.anchor = GridBagConstraints.EAST;
add(label, gbc);
gbc.gridx = 1;
gbc.anchor = GridBagConstraints.WEST;
add(combo, gbc);
gbc.gridy++;
}
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class PatchworkArmorView method setFromEntity.
public void setFromEntity(Entity en) {
List<EquipmentType> armors = TestEntity.legalArmorsFor(en.getEntityType(), (en instanceof Mech) && ((Mech) en).isIndustrial(), en.getMovementMode(), techManager);
ignoreEvents = true;
for (int loc = 0; loc < combos.size(); loc++) {
if ((loc < en.locations()) && !((en.hasETypeFlag(Entity.ETYPE_TANK) && (loc == Tank.LOC_BODY))) && !((en.hasETypeFlag(Entity.ETYPE_AERO) && (loc == Aero.LOC_WINGS)))) {
labels.get(loc).setText(en.getLocationName(loc));
combos.get(loc).removeAllItems();
for (EquipmentType eq : armors) {
combos.get(loc).addItem(eq);
}
String name = EquipmentType.getArmorTypeName(en.getArmorType(loc), TechConstants.isClan(en.getArmorTechLevel(loc)));
combos.get(loc).setSelectedItem(EquipmentType.get(name));
labels.get(loc).setVisible(true);
combos.get(loc).setVisible(true);
} else {
labels.get(loc).setVisible(false);
combos.get(loc).setVisible(false);
}
}
ignoreEvents = false;
}
use of megamek.common.EquipmentType in project megameklab by MegaMek.
the class EquipmentListCellRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
StringBuffer text = new StringBuffer();
EquipmentType etype = (EquipmentType) value;
text.append(etype.getName());
if (unit.isClan() && (!TechConstants.isClan(etype.getTechLevel(unit.getTechLevelYear())))) {
text.append(" (IS)");
}
if (!unit.isClan() && (TechConstants.isClan(etype.getTechLevel(unit.getTechLevelYear())))) {
text.append(" (Clan)");
}
label.setText(text.toString());
return label;
}
Aggregations