Search in sources :

Example 26 with EquipmentType

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);
    }
}
Also used : EquipmentType(megamek.common.EquipmentType)

Example 27 with EquipmentType

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);
        }
    }
}
Also used : EquipmentType(megamek.common.EquipmentType)

Example 28 with EquipmentType

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++;
    }
}
Also used : TechComboBox(megameklab.com.ui.util.TechComboBox) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) EncodeControl(megamek.common.util.EncodeControl) JLabel(javax.swing.JLabel) ResourceBundle(java.util.ResourceBundle) EquipmentType(megamek.common.EquipmentType)

Example 29 with EquipmentType

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;
}
Also used : Mech(megamek.common.Mech) EquipmentType(megamek.common.EquipmentType)

Example 30 with EquipmentType

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;
}
Also used : JLabel(javax.swing.JLabel) EquipmentType(megamek.common.EquipmentType)

Aggregations

EquipmentType (megamek.common.EquipmentType)49 Mounted (megamek.common.Mounted)24 MiscType (megamek.common.MiscType)14 LocationFullException (megamek.common.LocationFullException)10 ArrayList (java.util.ArrayList)8 JLabel (javax.swing.JLabel)6 AmmoType (megamek.common.AmmoType)6 CriticalSlot (megamek.common.CriticalSlot)6 WeaponType (megamek.common.WeaponType)5 Dimension (java.awt.Dimension)4 List (java.util.List)4 Vector (java.util.Vector)4 BattleArmor (megamek.common.BattleArmor)4 Mech (megamek.common.Mech)4 EntitySource (megameklab.com.ui.EntitySource)4 RefreshListener (megameklab.com.util.RefreshListener)4 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 ActionEvent (java.awt.event.ActionEvent)3 StringJoiner (java.util.StringJoiner)3