Search in sources :

Example 1 with Tank

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

the class ImageHelperVehicle method getTableImage.

public static Image getTableImage(Entity unit) {
    Image table = null;
    String path = new File(ImageHelper.recordSheetPath).getAbsolutePath() + File.separatorChar;
    if (unit instanceof VTOL) {
        table = new ImageIcon(path + "twvee-vtoltables.png").getImage();
    } else if (unit instanceof Tank) {
        table = new ImageIcon(path + "twvee-groundtables.png").getImage();
    }
    return table;
}
Also used : ImageIcon(javax.swing.ImageIcon) VTOL(megamek.common.VTOL) Image(java.awt.Image) File(java.io.File) Tank(megamek.common.Tank)

Example 2 with Tank

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

the class MenuBarCreator method jMenuResetEntity_actionPerformed.

public void jMenuResetEntity_actionPerformed(ActionEvent event) {
    CConfig.updateSaveFiles("Reset Unit");
    CConfig.setParam(CConfig.CONFIG_SAVE_FILE_1, "");
    Entity en = parentFrame.getEntity();
    if (en instanceof Tank) {
        parentFrame.createNewUnit(Entity.ETYPE_TANK);
    } else if (en instanceof Mech) {
        parentFrame.createNewUnit(Entity.ETYPE_BIPED_MECH, ((Mech) en).isPrimitive(), ((Mech) en).isIndustrial());
    } else if (en.hasETypeFlag(Entity.ETYPE_DROPSHIP)) {
        parentFrame.createNewUnit(Entity.ETYPE_DROPSHIP);
    } else if (en.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) {
        parentFrame.createNewUnit(Entity.ETYPE_SMALL_CRAFT, ((Aero) en).isPrimitive());
    } else if (parentFrame.getEntity() instanceof Aero) {
        parentFrame.createNewUnit(Entity.ETYPE_AERO, ((Aero) en).isPrimitive());
    } else if (parentFrame.getEntity() instanceof BattleArmor) {
        parentFrame.createNewUnit(Entity.ETYPE_BATTLEARMOR);
    } else if (parentFrame.getEntity() instanceof Infantry) {
        parentFrame.createNewUnit(Entity.ETYPE_INFANTRY);
    } else {
        System.out.println("util.MenuBarCreatoer: " + "Received unknown entityType!");
    }
    setVisible(true);
    reload();
    refresh();
    parentFrame.setVisible(true);
    parentFrame.repaint();
}
Also used : Entity(megamek.common.Entity) Infantry(megamek.common.Infantry) Mech(megamek.common.Mech) Tank(megamek.common.Tank) Aero(megamek.common.Aero) BattleArmor(megamek.common.BattleArmor)

Example 3 with Tank

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

the class ImageHelper method getRecordSheet.

public static Image getRecordSheet(Entity unit, boolean advanced) {
    Image recordSheet = null;
    String path = new File(recordSheetPath).getAbsolutePath() + File.separatorChar;
    if (unit instanceof BipedMech) {
        if (advanced) {
            recordSheet = new ImageIcon(path + "tobiped.png").getImage();
        } else {
            recordSheet = new ImageIcon(path + "twbiped.png").getImage();
        }
    } else if (unit instanceof QuadMech) {
        if (advanced) {
            recordSheet = new ImageIcon(path + "toquad.png").getImage();
        } else {
            recordSheet = new ImageIcon(path + "twquad.png").getImage();
        }
    } else if (unit instanceof VTOL) {
        recordSheet = new ImageIcon(path + "twvee-vtol.png").getImage();
    } else if ((unit instanceof LargeSupportTank) || ((unit instanceof Tank) && ((Tank) unit).isSuperHeavy())) {
        if (unit.getOInternal(LargeSupportTank.LOC_TURRET) > 0) {
            recordSheet = new ImageIcon(path + "twvee-lgsupground-turret.png").getImage();
        } else {
            recordSheet = new ImageIcon(path + "twvee-lgsupground.png").getImage();
        }
    } else if (unit instanceof Tank) {
        if ((unit.getMovementMode() == EntityMovementMode.NAVAL) || (unit.getMovementMode() == EntityMovementMode.SUBMARINE) || (unit.getMovementMode() == EntityMovementMode.HYDROFOIL)) {
            if (unit.getOInternal(((Tank) unit).getLocTurret()) > 0) {
                recordSheet = new ImageIcon(path + "twnaval-turret.png").getImage();
            } else {
                recordSheet = new ImageIcon(path + "twnaval.png").getImage();
            }
        } else if (advanced) {
            String imageName = "twvee-" + unit.getMovementModeAsString().toLowerCase().trim() + "-dualturret.png";
            recordSheet = new ImageIcon(path + imageName).getImage();
        } else {
            String imageName = "twvee-" + unit.getMovementModeAsString().toLowerCase().trim() + ".png";
            recordSheet = new ImageIcon(path + imageName).getImage();
        }
    } else if (unit instanceof Aero) {
        if (unit instanceof Dropship) {
            if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
                recordSheet = new ImageIcon(path + "twaerodyneds.png").getImage();
            } else {
                recordSheet = new ImageIcon(path + "twspheroidds.png").getImage();
            }
        } else if (unit instanceof ConvFighter) {
            recordSheet = new ImageIcon(path + "twconventionalfighter.png").getImage();
        } else if (unit instanceof SmallCraft) {
            if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
                recordSheet = new ImageIcon(path + "twaero-smallcraft.png").getImage();
            } else {
                recordSheet = new ImageIcon(path + "twspheroid-smallcraft.png").getImage();
            }
        } else {
            recordSheet = new ImageIcon(path + "twaero.png").getImage();
        }
    } else if (unit instanceof BattleArmor) {
        recordSheet = new ImageIcon(path + "twba.png").getImage();
    } else if (unit instanceof Protomech) {
        recordSheet = new ImageIcon(path + "twproto.png").getImage();
    }
    return recordSheet;
}
Also used : QuadMech(megamek.common.QuadMech) ImageIcon(javax.swing.ImageIcon) LargeSupportTank(megamek.common.LargeSupportTank) Dropship(megamek.common.Dropship) ConvFighter(megamek.common.ConvFighter) Image(java.awt.Image) LargeSupportTank(megamek.common.LargeSupportTank) Tank(megamek.common.Tank) SmallCraft(megamek.common.SmallCraft) VTOL(megamek.common.VTOL) Protomech(megamek.common.Protomech) BipedMech(megamek.common.BipedMech) File(java.io.File) Aero(megamek.common.Aero) BattleArmor(megamek.common.BattleArmor)

Example 4 with Tank

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

the class CVStatusBar method refresh.

public void refresh() {
    int walk = getTank().getOriginalWalkMP();
    int run = getTank().getRunMP(true, true, false);
    int jump = getTank().getOriginalJumpMP();
    double tonnage = getTank().getWeight();
    double currentTonnage;
    int bv = getTank().calculateBattleValue();
    testEntity = new TestTank(getTank(), entityVerifier.tankOption, null);
    currentTonnage = testEntity.calculateWeight();
    currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getTank());
    long currentCost = Math.round(getTank().getCost(false));
    tons.setText(String.format("Tonnage: %.1f/%.1f (%.1f Remaining)", currentTonnage, tonnage, tonnage - currentTonnage));
    tons.setToolTipText("Current Tonnage/Max Tonnage");
    if (currentTonnage > tonnage) {
        tons.setForeground(Color.red);
    } else {
        tons.setForeground(UIManager.getColor("Label.foreground"));
    }
    Tank tank = getTank();
    int currentSlots = tank.getTotalSlots() - tank.getFreeSlots();
    slots.setText("Slots: " + currentSlots + "/" + tank.getTotalSlots());
    if (currentSlots > tank.getTotalSlots()) {
        slots.setForeground(Color.red);
    } else {
        slots.setForeground(UIManager.getColor("Label.foreground"));
    }
    bvLabel.setText("BV: " + bv);
    bvLabel.setToolTipText("BV 2.0");
    cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
    move.setText("Movement: " + walk + "/" + run + "/" + jump);
    move.setToolTipText("Walk/Run/Jump MP");
    StringBuffer sb = new StringBuffer();
    invalid.setVisible(!testEntity.correctEntity(sb));
    invalid.setToolTipText("<html>" + sb.toString().replaceAll("\n", "<br/>") + "</html>");
}
Also used : TestTank(megamek.common.verifier.TestTank) Tank(megamek.common.Tank) TestTank(megamek.common.verifier.TestTank)

Example 5 with Tank

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

the class ImageHelperVehicle method getTurretImage.

public static Image getTurretImage(Entity unit) {
    Image table = null;
    String path = new File(ImageHelper.recordSheetPath).getAbsolutePath() + File.separatorChar;
    if ((unit instanceof Tank) && (unit.getMovementMode() == EntityMovementMode.WIGE)) {
        table = new ImageIcon(path + "twvee-wige-turret.png").getImage();
    } else {
        table = new ImageIcon(path + "twvee-turret.png").getImage();
    }
    return table;
}
Also used : ImageIcon(javax.swing.ImageIcon) Image(java.awt.Image) File(java.io.File) Tank(megamek.common.Tank)

Aggregations

Tank (megamek.common.Tank)14 Aero (megamek.common.Aero)7 BattleArmor (megamek.common.BattleArmor)6 File (java.io.File)5 Infantry (megamek.common.Infantry)5 Mech (megamek.common.Mech)5 TestTank (megamek.common.verifier.TestTank)5 Entity (megamek.common.Entity)4 VTOL (megamek.common.VTOL)4 Image (java.awt.Image)3 ImageIcon (javax.swing.ImageIcon)3 SmallCraft (megamek.common.SmallCraft)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 FixedWingSupport (megamek.common.FixedWingSupport)2 MechFileParser (megamek.common.MechFileParser)2 TestSupportVehicle (megamek.common.verifier.TestSupportVehicle)2 Frame (java.awt.Frame)1