Search in sources :

Example 1 with EquipmentType

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

Example 2 with EquipmentType

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

Example 3 with EquipmentType

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

Example 4 with EquipmentType

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

Example 5 with EquipmentType

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