Search in sources :

Example 1 with SimpleTechLevel

use of megamek.common.SimpleTechLevel in project megameklab by MegaMek.

the class MainUI method createNewUnit.

@Override
public void createNewUnit(long entitytype, boolean isPrimitive, boolean isIndustrial, Entity oldUnit) {
    if (entitytype == Entity.ETYPE_SMALL_CRAFT) {
        setEntity(new SmallCraft());
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else if (entitytype == Entity.ETYPE_DROPSHIP) {
        setEntity(new Dropship());
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else {
        MegaMekLab.getLogger().log(MainUI.class, "createNewUnit(long)", LogLevel.ERROR, "Received incorrect entityType!");
        return;
    }
    SmallCraft smallCraft = (SmallCraft) getEntity();
    if (isPrimitive) {
        smallCraft.setYear(2470);
        smallCraft.setOriginalBuildYear(2470);
        smallCraft.setArmorType(EquipmentType.T_ARMOR_PRIMITIVE_AERO);
    } else {
        smallCraft.setYear(3145);
        smallCraft.setArmorType(EquipmentType.T_ARMOR_AEROSPACE);
    }
    smallCraft.setWeight(200);
    // Start at 1G
    smallCraft.setOriginalWalkMP(2);
    smallCraft.setArmorTechLevel(getEntity().getTechLevel());
    smallCraft.set0SI(3);
    smallCraft.setDesignType(SmallCraft.MILITARY);
    smallCraft.setHeatType(Aero.HEAT_SINGLE);
    smallCraft.autoSetInternal();
    for (int loc = 0; loc < getEntity().locations(); loc++) {
        smallCraft.initializeArmor(smallCraft.get0SI(), loc);
    }
    if (null == oldUnit) {
        getEntity().setChassis("New");
        if (entitytype == Entity.ETYPE_SMALL_CRAFT) {
            smallCraft.setModel("Small Craft");
        } else {
            smallCraft.setModel("Dropship");
        }
        smallCraft.setSpheroid(false);
        smallCraft.setMovementMode(EntityMovementMode.AERODYNE);
    } else {
        smallCraft.setChassis(oldUnit.getChassis());
        smallCraft.setModel(oldUnit.getModel());
        smallCraft.setYear(Math.max(oldUnit.getYear(), smallCraft.getConstructionTechAdvancement().getIntroductionDate()));
        smallCraft.setSource(oldUnit.getSource());
        smallCraft.setManualBV(oldUnit.getManualBV());
        SimpleTechLevel lvl = SimpleTechLevel.max(smallCraft.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldUnit.getTechLevel()));
        smallCraft.setTechLevel(lvl.getCompoundTechLevel(oldUnit.isClan()));
        smallCraft.setMixedTech(oldUnit.isMixedTech());
        smallCraft.setSpheroid(((SmallCraft) oldUnit).isSpheroid());
        smallCraft.setMovementMode(oldUnit.getMovementMode());
    }
}
Also used : MegaMekLabMainUI(megameklab.com.ui.MegaMekLabMainUI) SimpleTechLevel(megamek.common.SimpleTechLevel) Dropship(megamek.common.Dropship) SmallCraft(megamek.common.SmallCraft)

Example 2 with SimpleTechLevel

use of megamek.common.SimpleTechLevel in project megameklab by MegaMek.

the class StructureTab method enableTabs.

private void enableTabs() {
    SimpleTechLevel level = panBasicInfo.getTechLevel();
    if (level.ordinal() >= SimpleTechLevel.ADVANCED.ordinal()) {
        txtArmor.setEnabled(true);
        txtSpecializations.setEnabled(true);
        equipmentPane.setEnabledAt(T_FIELD_GUNS, getInfantry().getMovementMode() == EntityMovementMode.INF_MOTORIZED || getInfantry().getMovementMode() == EntityMovementMode.TRACKED || getInfantry().getMovementMode() == EntityMovementMode.WHEELED);
        equipmentPane.setEnabledAt(T_ARMOR_KIT, true);
        equipmentPane.setEnabledAt(T_SPECIALIZATION, true);
        // Experimental level
        txtAugmentations.setEnabled(level.ordinal() >= SimpleTechLevel.EXPERIMENTAL.ordinal());
        equipmentPane.setEnabledAt(T_AUGMENTATION, level.ordinal() >= SimpleTechLevel.EXPERIMENTAL.ordinal());
    } else {
        txtArmor.setEnabled(false);
        txtSpecializations.setEnabled(false);
        txtAugmentations.setEnabled(false);
        equipmentPane.setEnabledAt(T_FIELD_GUNS, false);
        equipmentPane.setEnabledAt(T_ARMOR_KIT, false);
        equipmentPane.setEnabledAt(T_SPECIALIZATION, false);
        equipmentPane.setEnabledAt(T_AUGMENTATION, false);
    }
    if (!equipmentPane.isEnabledAt(equipmentPane.getSelectedIndex())) {
        equipmentPane.setSelectedIndex(T_INFANTRY_WEAPONS);
    }
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel)

Example 3 with SimpleTechLevel

use of megamek.common.SimpleTechLevel in project megameklab by MegaMek.

the class MainUI method createNewUnit.

@Override
public void createNewUnit(long entityType, boolean isPrimitive, boolean isIndustrial, Entity oldEntity) {
    int cockpit = Mech.COCKPIT_STANDARD;
    int at = EquipmentType.T_ARMOR_STANDARD;
    int st = EquipmentType.T_STRUCTURE_STANDARD;
    if (isPrimitive && isIndustrial) {
        cockpit = Mech.COCKPIT_PRIMITIVE_INDUSTRIAL;
        at = EquipmentType.T_ARMOR_PRIMITIVE;
        st = EquipmentType.T_STRUCTURE_INDUSTRIAL;
    } else if (isPrimitive) {
        cockpit = Mech.COCKPIT_PRIMITIVE;
        at = EquipmentType.T_ARMOR_PRIMITIVE;
    } else if (isIndustrial) {
        cockpit = Mech.COCKPIT_INDUSTRIAL;
        at = EquipmentType.T_ARMOR_INDUSTRIAL;
        st = EquipmentType.T_STRUCTURE_INDUSTRIAL;
    }
    if (entityType == Entity.ETYPE_TRIPOD_MECH) {
        setEntity(new TripodMech(Mech.GYRO_STANDARD, Mech.COCKPIT_TRIPOD));
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else if (entityType == Entity.ETYPE_QUAD_MECH) {
        setEntity(new QuadMech(Mech.GYRO_STANDARD, cockpit));
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else if (entityType == Entity.ETYPE_LAND_AIR_MECH) {
        setEntity(new LandAirMech(Mech.GYRO_STANDARD, Mech.COCKPIT_STANDARD, LandAirMech.LAM_STANDARD));
        getEntity().setTechLevel(TechConstants.T_IS_ADVANCED);
        getEntity().setManualBV(-1);
    } else if (entityType == Entity.ETYPE_QUADVEE) {
        setEntity(new QuadVee(Mech.GYRO_STANDARD, QuadVee.MOTIVE_TRACK));
        getEntity().setTechLevel(TechConstants.T_CLAN_ADVANCED);
        UnitUtil.createSpreadMounts((Mech) getEntity(), EquipmentType.get("Tracks"));
        getEntity().setManualBV(-1);
    } else {
        // type == 0
        setEntity(new BipedMech(Mech.GYRO_STANDARD, cockpit));
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    }
    Mech mech = (Mech) getEntity();
    getEntity().setWeight(25);
    if (entityType == Entity.ETYPE_LAND_AIR_MECH) {
        mech.setEngine(new Engine(75, Engine.NORMAL_ENGINE, 0));
        UnitUtil.updateJumpJets(((Mech) getEntity()), 3, Mech.JUMP_STANDARD);
    } else {
        mech.setEngine(new Engine(25, Engine.NORMAL_ENGINE, 0));
    }
    getEntity().setArmorType(at);
    getEntity().setArmorTechLevel(getEntity().getTechLevel());
    getEntity().setStructureType(st);
    mech.addGyro();
    mech.addEngineCrits();
    if (isPrimitive) {
        mech.addPrimitiveCockpit();
    } else if (isIndustrial) {
        mech.addIndustrialCockpit();
    } else if (Entity.ETYPE_QUADVEE == entityType) {
        mech.addQuadVeeCockpit();
    } else {
        mech.addCockpit();
    }
    UnitUtil.updateHeatSinks(mech, 10, "Single");
    getEntity().autoSetInternal();
    for (int loc = 0; loc < getEntity().locations(); loc++) {
        mech.initializeArmor(0, loc);
        mech.initializeRearArmor(0, loc);
    }
    if (null == oldEntity) {
        mech.setChassis("New");
        mech.setModel("Mek");
        mech.setYear(3145);
    } else {
        mech.setChassis(oldEntity.getChassis());
        mech.setModel(oldEntity.getModel());
        mech.setYear(Math.max(oldEntity.getYear(), mech.getConstructionTechAdvancement().getIntroductionDate()));
        mech.setSource(oldEntity.getSource());
        mech.setManualBV(oldEntity.getManualBV());
        SimpleTechLevel lvl = SimpleTechLevel.max(mech.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
        mech.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
        mech.setMixedTech(oldEntity.isMixedTech());
    }
}
Also used : TripodMech(megamek.common.TripodMech) QuadMech(megamek.common.QuadMech) SimpleTechLevel(megamek.common.SimpleTechLevel) BipedMech(megamek.common.BipedMech) Mech(megamek.common.Mech) LandAirMech(megamek.common.LandAirMech) TripodMech(megamek.common.TripodMech) QuadMech(megamek.common.QuadMech) QuadVee(megamek.common.QuadVee) BipedMech(megamek.common.BipedMech) Engine(megamek.common.Engine) LandAirMech(megamek.common.LandAirMech)

Example 4 with SimpleTechLevel

use of megamek.common.SimpleTechLevel in project megameklab by MegaMek.

the class BasicInfoView method refreshTechLevel.

private void refreshTechLevel() {
    SimpleTechLevel prev = getTechLevel();
    cbTechLevel.removeActionListener(this);
    cbTechLevel.removeAllItems();
    if (!useClanTechBase() && !useMixedTech() && SimpleTechLevel.INTRO.ordinal() >= baseTA.getStaticTechLevel().ordinal()) {
        cbTechLevel.addItem(SimpleTechLevel.INTRO);
    }
    if (!useMixedTech() && SimpleTechLevel.STANDARD.ordinal() >= baseTA.getStaticTechLevel().ordinal()) {
        cbTechLevel.addItem(SimpleTechLevel.STANDARD);
    }
    if (SimpleTechLevel.ADVANCED.ordinal() >= baseTA.getStaticTechLevel().ordinal()) {
        cbTechLevel.addItem(SimpleTechLevel.ADVANCED);
    }
    cbTechLevel.addItem(SimpleTechLevel.EXPERIMENTAL);
    cbTechLevel.addItem(SimpleTechLevel.UNOFFICIAL);
    cbTechLevel.setSelectedItem(prev);
    cbTechLevel.addActionListener(this);
    if (cbTechLevel.getSelectedItem() == null || cbTechLevel.getSelectedItem() != prev) {
        cbTechLevel.setSelectedIndex(0);
    }
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel)

Example 5 with SimpleTechLevel

use of megamek.common.SimpleTechLevel in project megameklab by MegaMek.

the class BasicInfoView method setFromEntity.

public void setFromEntity(Entity en) {
    boolean useTP = CConfig.getBooleanParam(CConfig.TECH_PROGRESSION);
    baseTA = en.getConstructionTechAdvancement();
    txtYear.setMinimum(baseTA.getIntroductionDate());
    refreshTechBase();
    setChassis(en.getChassis());
    setModel(en.getModel());
    setYear(en.getYear());
    setSource(en.getSource());
    cbTechBase.removeActionListener(this);
    setTechBase(en.isClan(), en.isMixedTech());
    cbTechBase.addActionListener(this);
    cbTechLevel.removeActionListener(this);
    SimpleTechLevel lvl = useTP ? en.getSimpleLevel(getGameYear()) : en.getStaticTechLevel();
    setTechLevel(SimpleTechLevel.max(lvl, SimpleTechLevel.convertCompoundToSimple(en.getTechLevel())));
    cbTechLevel.addActionListener(this);
    if (en.getManualBV() >= 0) {
        setManualBV(en.getManualBV());
    }
    refreshFaction();
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel)

Aggregations

SimpleTechLevel (megamek.common.SimpleTechLevel)7 Engine (megamek.common.Engine)3 Aero (megamek.common.Aero)1 BipedMech (megamek.common.BipedMech)1 ConvFighter (megamek.common.ConvFighter)1 Dropship (megamek.common.Dropship)1 LandAirMech (megamek.common.LandAirMech)1 Mech (megamek.common.Mech)1 QuadMech (megamek.common.QuadMech)1 QuadVee (megamek.common.QuadVee)1 SmallCraft (megamek.common.SmallCraft)1 SuperHeavyTank (megamek.common.SuperHeavyTank)1 Tank (megamek.common.Tank)1 TripodMech (megamek.common.TripodMech)1 VTOL (megamek.common.VTOL)1 MegaMekLabMainUI (megameklab.com.ui.MegaMekLabMainUI)1