Search in sources :

Example 1 with SmallCraft

use of megamek.common.SmallCraft 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 2 with SmallCraft

use of megamek.common.SmallCraft 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 3 with SmallCraft

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

the class MenuBarCreator method loadFileMenuOptions.

private void loadFileMenuOptions() {
    file.removeAll();
    file.setMnemonic(KeyEvent.VK_F);
    JMenuItem item = new JMenuItem();
    item = new JMenuItem("Reset Current Unit");
    item.setMnemonic(KeyEvent.VK_R);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuResetEntity_actionPerformed(e);
        }
    });
    file.add(item);
    JMenu unitMenu = new JMenu("Switch Unit Type");
    unitMenu.setMnemonic(KeyEvent.VK_S);
    Entity en = parentFrame.getEntity();
    if (!(en instanceof Mech) || ((Mech) en).isPrimitive()) {
        item = new JMenuItem();
        item.setText("Mech");
        item.setMnemonic(KeyEvent.VK_M);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(e -> jMenuLoadMech());
        unitMenu.add(item);
    }
    if (!(en.isFighter() || (en.isFighter() && ((Aero) en).isPrimitive()))) {
        item = new JMenuItem();
        item.setText("Aero/Conv Fighter");
        item.setMnemonic(KeyEvent.VK_A);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadAero();
            }
        });
        unitMenu.add(item);
    }
    if (!(en instanceof SmallCraft) || ((Aero) en).isPrimitive()) {
        item = new JMenuItem();
        item.setText("Dropship/Small Craft");
        item.setMnemonic(KeyEvent.VK_D);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(e -> jMenuLoadDropship());
        unitMenu.add(item);
    }
    if (!(parentFrame.getEntity() instanceof Tank)) {
        item = new JMenuItem();
        item.setText("Combat Vehicle");
        item.setMnemonic(KeyEvent.VK_T);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadVehicle();
            }
        });
        unitMenu.add(item);
    }
    if (!(parentFrame.getEntity() instanceof BattleArmor)) {
        item = new JMenuItem();
        item.setText("BattleArmor");
        item.setMnemonic(KeyEvent.VK_B);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadBattleArmor();
            }
        });
        unitMenu.add(item);
    }
    if (!(parentFrame.getEntity() instanceof Infantry) || (parentFrame.getEntity() instanceof BattleArmor)) {
        item = new JMenuItem();
        item.setText("Infantry");
        item.setMnemonic(KeyEvent.VK_I);
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadInfantry();
            }
        });
        unitMenu.add(item);
    }
    JMenu pMenu = new JMenu("Primitive/Retro");
    if (!(en instanceof Mech) || !((Mech) en).isPrimitive()) {
        item = new JMenuItem();
        item.setText("Mech");
        item.addActionListener(e -> jMenuLoadPrimitiveMech());
        pMenu.add(item);
    }
    if (!(en.isFighter()) || !((Aero) en).isPrimitive()) {
        item = new JMenuItem();
        item.setText("Aero");
        item.addActionListener(e -> jMenuLoadPrimitiveAero());
        pMenu.add(item);
    }
    if (!(en.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) || !((Aero) en).isPrimitive()) {
        item = new JMenuItem();
        item.setText("Dropship/Small Craft");
        item.addActionListener(e -> jMenuLoadPrimitiveDropship());
        pMenu.add(item);
    }
    unitMenu.add(pMenu);
    file.add(unitMenu);
    JMenu loadMenu = new JMenu("Load");
    loadMenu.setMnemonic(KeyEvent.VK_L);
    item = new JMenuItem();
    item.setText("From Cache");
    item.setMnemonic(KeyEvent.VK_C);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuLoadEntity_actionPerformed(e);
        }
    });
    loadMenu.add(item);
    item = new JMenuItem();
    item.setText("From File");
    item.setMnemonic(KeyEvent.VK_F);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuLoadEntityFromFile_actionPerformed(e);
        }
    });
    loadMenu.add(item);
    file.add(loadMenu);
    item = new JMenuItem(String.format("Current Unit"));
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.setMnemonic(KeyEvent.VK_C);
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuPrintCurrentUnit();
        }
    });
    file.add(UnitPrintManager.printMenu(parentFrame, item));
    item = new JMenuItem();
    item.setText("Save");
    item.setMnemonic(KeyEvent.VK_S);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuSaveEntity_actionPerformed(e);
        }
    });
    file.add(item);
    item = new JMenuItem();
    item.setText("Save As");
    item.setMnemonic(KeyEvent.VK_A);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuSaveAsEntity_actionPerformed(e);
        }
    });
    file.add(item);
    JMenu exportMenu = new JMenu("Export");
    item = new JMenuItem("to HTML");
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuExportEntityHTML_actionPerformed(e);
        }
    });
    exportMenu.add(item);
    item = new JMenuItem("to Text");
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuExportEntityText_actionPerformed(e);
        }
    });
    exportMenu.add(item);
    item = new JMenuItem("to Clipboard (text)");
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuExportEntityClipboard_actionPerformed(e);
        }
    });
    exportMenu.add(item);
    file.add(exportMenu);
    item = new JMenuItem("Configuration");
    item.setMnemonic(KeyEvent.VK_C);
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuConfiguration_actionPerformed(e);
        }
    });
    file.add(item);
    int fileNumber = 1;
    if (CConfig.getParam(CConfig.CONFIG_SAVE_FILE_1).length() > 1) {
        file.addSeparator();
        item = new JMenuItem();
        String newFile = CConfig.getParam(CConfig.CONFIG_SAVE_FILE_1);
        if (newFile.length() > 35) {
            item.setText(fileNumber + ". .." + newFile.substring(newFile.length() - 36));
        } else {
            item.setText(fileNumber + ". " + newFile);
        }
        item.setMnemonic(fileNumber);
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadEntityFromFile_actionPerformed(1);
            }
        });
        file.add(item);
        fileNumber++;
    }
    if (CConfig.getParam(CConfig.CONFIG_SAVE_FILE_2).length() > 1) {
        item = new JMenuItem();
        String newFile = CConfig.getParam(CConfig.CONFIG_SAVE_FILE_2);
        if (newFile.length() > 35) {
            item.setText(fileNumber + ". .." + newFile.substring(newFile.length() - 36));
        } else {
            item.setText(fileNumber + ". " + newFile);
        }
        item.setMnemonic(fileNumber);
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadEntityFromFile_actionPerformed(2);
            }
        });
        file.add(item);
        fileNumber++;
    }
    if (CConfig.getParam(CConfig.CONFIG_SAVE_FILE_3).length() > 1) {
        item = new JMenuItem();
        String newFile = CConfig.getParam(CConfig.CONFIG_SAVE_FILE_3);
        if (newFile.length() > 35) {
            item.setText(fileNumber + ". .." + newFile.substring(newFile.length() - 36));
        } else {
            item.setText(fileNumber + ". " + newFile);
        }
        item.setMnemonic(fileNumber);
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadEntityFromFile_actionPerformed(3);
            }
        });
        file.add(item);
        fileNumber++;
    }
    if (CConfig.getParam(CConfig.CONFIG_SAVE_FILE_4).length() > 1) {
        item = new JMenuItem();
        String newFile = CConfig.getParam(CConfig.CONFIG_SAVE_FILE_4);
        if (newFile.length() > 35) {
            item.setText(fileNumber + ". .." + newFile.substring(newFile.length() - 36));
        } else {
            item.setText(fileNumber + ". " + newFile);
        }
        item.setMnemonic(fileNumber);
        item.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jMenuLoadEntityFromFile_actionPerformed(4);
            }
        });
        file.add(item);
        fileNumber++;
    }
    file.addSeparator();
    item = new JMenuItem();
    item.setText("Exit");
    item.setMnemonic(KeyEvent.VK_X);
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    item.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            jMenuExit_actionPerformed(e);
        }
    });
    file.add(item);
}
Also used : Entity(megamek.common.Entity) ActionEvent(java.awt.event.ActionEvent) Tank(megamek.common.Tank) SmallCraft(megamek.common.SmallCraft) Infantry(megamek.common.Infantry) ActionListener(java.awt.event.ActionListener) Mech(megamek.common.Mech) JMenuItem(javax.swing.JMenuItem) JMenu(javax.swing.JMenu) Aero(megamek.common.Aero) BattleArmor(megamek.common.BattleArmor)

Example 4 with SmallCraft

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

the class UnitPrintManager method printAllUnits.

public static boolean printAllUnits(Vector<Entity> loadedUnits, boolean singlePrint) {
    Book book = new Book();
    List<Infantry> infList = new ArrayList<>();
    List<BattleArmor> baList = new ArrayList<>();
    List<Protomech> protoList = new ArrayList<>();
    List<Entity> unprintable = new ArrayList<>();
    HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.NA_LETTER);
    aset.add(new MediaPrintableArea(0, 0, 8.5f, 11, MediaPrintableArea.INCH));
    PrinterJob masterPrintJob = PrinterJob.getPrinterJob();
    if (!masterPrintJob.printDialog(aset)) {
        return true;
    }
    PageFormat pageFormat = new PageFormat();
    pageFormat = masterPrintJob.getPageFormat(null);
    Paper p = pageFormat.getPaper();
    p.setImageableArea(0, 0, p.getWidth(), p.getHeight());
    pageFormat.setPaper(p);
    Tank tank1 = null;
    Tank wige1 = null;
    Tank dualTurret1 = null;
    for (Entity unit : loadedUnits) {
        if (unit instanceof Mech) {
            UnitUtil.removeOneShotAmmo(unit);
            UnitUtil.expandUnitMounts((Mech) unit);
            book.append(new PrintMech((Mech) unit, book.getNumberOfPages()), pageFormat);
        } else if ((unit instanceof LargeSupportTank) || ((unit instanceof Tank) && (unit.getMovementMode() != EntityMovementMode.VTOL) && ((Tank) unit).isSuperHeavy())) {
            book.append(new PrintLargeSupportVehicle((Tank) unit), pageFormat);
        } else if (unit instanceof VTOL) {
            book.append(new PrintVTOL((VTOL) unit), pageFormat);
        } else if (unit.getMovementMode() == EntityMovementMode.WIGE) {
            if (singlePrint) {
                book.append(new PrintVehicle((Tank) unit, null), pageFormat);
            } else if (null != wige1) {
                book.append(new PrintVehicle(wige1, (Tank) unit), pageFormat);
                wige1 = null;
            } else {
                wige1 = (Tank) unit;
            }
        } else if ((unit instanceof Tank) && ((unit.getMovementMode() == EntityMovementMode.NAVAL) || (unit.getMovementMode() == EntityMovementMode.SUBMARINE) || (unit.getMovementMode() == EntityMovementMode.HYDROFOIL))) {
            unprintable.add(unit);
        // book.append(new PrintNavalVehicle((Tank) unit), pageFormat);
        } else if (unit instanceof Tank) {
            if (!((Tank) unit).hasNoDualTurret()) {
                if (singlePrint) {
                    book.append(new PrintDualTurretVehicle((Tank) unit, null), pageFormat);
                } else if (null != dualTurret1) {
                    book.append(new PrintDualTurretVehicle(dualTurret1, (Tank) unit), pageFormat);
                    dualTurret1 = null;
                } else {
                    dualTurret1 = (Tank) unit;
                }
            } else {
                if (singlePrint) {
                    book.append(new PrintVehicle((Tank) unit, null), pageFormat);
                } else if (null != tank1) {
                    book.append(new PrintVehicle(tank1, (Tank) unit), pageFormat);
                    tank1 = null;
                } else {
                    tank1 = (Tank) unit;
                }
            }
        } else if (unit.hasETypeFlag(Entity.ETYPE_AERO) && !unit.hasETypeFlag(Entity.ETYPE_JUMPSHIP)) {
            if (unit instanceof Dropship) {
                if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
                    book.append(new PrintAerodyne((Dropship) unit), pageFormat);
                } else {
                    book.append(new PrintSpheroid((Dropship) unit), pageFormat);
                }
            } else if (unit instanceof FixedWingSupport) {
                book.append(new PrintFixedWingSupport((FixedWingSupport) unit), pageFormat);
            } else if (unit instanceof ConvFighter) {
                book.append(new PrintConventionalFighter((ConvFighter) unit), pageFormat);
            } else if (unit instanceof SmallCraft) {
                if (unit.getMovementMode() == EntityMovementMode.AERODYNE) {
                    book.append(new PrintSmallCraftAerodyne((SmallCraft) unit), pageFormat);
                } else {
                    book.append(new PrintSmallCraftSpheroid((SmallCraft) unit), pageFormat);
                }
            } else {
                book.append(new PrintAero((Aero) unit), pageFormat);
            }
        } else if (unit instanceof BattleArmor) {
            baList.add((BattleArmor) unit);
            if (singlePrint || baList.size() > 4) {
                book.append(new PrintBattleArmor(baList), pageFormat);
                baList = new ArrayList<>();
            }
        } else if (unit instanceof Infantry) {
            infList.add((Infantry) unit);
            if (singlePrint || infList.size() > 3) {
                book.append(new PrintInfantry(infList), pageFormat);
                infList = new ArrayList<>();
            }
        } else if (unit instanceof Protomech) {
            protoList.add((Protomech) unit);
            if (singlePrint || protoList.size() > 4) {
                book.append(new PrintProtomech(protoList), pageFormat);
                protoList = new ArrayList<>();
            }
        } else {
            // TODO: show a message dialog that lists the unprintable units
            unprintable.add(unit);
        }
    }
    if (unprintable.size() > 0) {
        JOptionPane.showMessageDialog(null, "Printing is not currently supported for the following units:\n" + unprintable.stream().map(en -> en.getChassis() + " " + en.getModel()).collect(Collectors.joining("\n")));
    }
    if (null != wige1) {
        book.append(new PrintVehicle(wige1, null), pageFormat);
    }
    if (null != tank1) {
        book.append(new PrintVehicle(tank1, null), pageFormat);
    }
    if (null != dualTurret1) {
        book.append(new PrintDualTurretVehicle(dualTurret1, null), pageFormat);
    }
    if (baList.size() > 0) {
        book.append(new PrintBattleArmor(baList), pageFormat);
    }
    if (infList.size() > 0) {
        book.append(new PrintInfantry(infList), pageFormat);
    }
    if (protoList.size() > 0) {
        book.append(new PrintProtomech(protoList), pageFormat);
    }
    masterPrintJob.setPageable(book);
    if (loadedUnits.size() > 1) {
        masterPrintJob.setJobName(loadedUnits.get(0).getShortNameRaw() + " etc");
    } else if (loadedUnits.size() > 0) {
        masterPrintJob.setJobName(loadedUnits.get(0).getShortNameRaw());
    }
    PrintTask task = new PrintTask(masterPrintJob, aset);
    task.execute();
    return true;
}
Also used : PrintAero(megameklab.com.ui.Aero.Printing.PrintAero) Dropship(megamek.common.Dropship) Aero(megamek.common.Aero) PrintLargeSupportVehicle(megameklab.com.ui.Vehicle.Printing.PrintLargeSupportVehicle) PrintSmallCraftSpheroid(megameklab.com.ui.Aero.Printing.PrintSmallCraftSpheroid) PrintBattleArmor(megameklab.com.ui.BattleArmor.Printing.PrintBattleArmor) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrinterJob(java.awt.print.PrinterJob) PrintTask(megameklab.com.printing.PrintTask) Vector(java.util.Vector) BattleArmor(megamek.common.BattleArmor) PrintMech(megameklab.com.printing.PrintMech) PrintInfantry(megameklab.com.ui.Infantry.Printing.PrintInfantry) UnitLoadingDialog(megamek.client.ui.swing.UnitLoadingDialog) EntityListFile(megamek.common.EntityListFile) SmallCraft(megamek.common.SmallCraft) PageFormat(java.awt.print.PageFormat) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame) Infantry(megamek.common.Infantry) KeyStroke(javax.swing.KeyStroke) MechFileParser(megamek.common.MechFileParser) Frame(java.awt.Frame) PrintFixedWingSupport(megameklab.com.ui.Aero.Printing.PrintFixedWingSupport) Mech(megamek.common.Mech) VTOL(megamek.common.VTOL) JMenu(javax.swing.JMenu) KeyEvent(java.awt.event.KeyEvent) PrintAerodyne(megameklab.com.ui.Dropship.Printing.PrintAerodyne) Collectors(java.util.stream.Collectors) FixedWingSupport(megamek.common.FixedWingSupport) Book(java.awt.print.Book) Protomech(megamek.common.Protomech) PrintVehicle(megameklab.com.ui.Vehicle.Printing.PrintVehicle) List(java.util.List) LargeSupportTank(megamek.common.LargeSupportTank) Tank(megamek.common.Tank) Entity(megamek.common.Entity) MediaSizeName(javax.print.attribute.standard.MediaSizeName) ActionListener(java.awt.event.ActionListener) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) PrintSpheroid(megameklab.com.ui.Dropship.Printing.PrintSpheroid) Paper(java.awt.print.Paper) PrintDualTurretVehicle(megameklab.com.ui.Vehicle.Printing.PrintDualTurretVehicle) ArrayList(java.util.ArrayList) JMenuItem(javax.swing.JMenuItem) UnitPrintQueueDialog(megameklab.com.ui.dialog.UnitPrintQueueDialog) PrintSmallCraftAerodyne(megameklab.com.ui.Aero.Printing.PrintSmallCraftAerodyne) UnitSelectorDialog(megamek.client.ui.swing.UnitSelectorDialog) PrintConventionalFighter(megameklab.com.ui.Aero.Printing.PrintConventionalFighter) ConvFighter(megamek.common.ConvFighter) PrintVTOL(megameklab.com.ui.Vehicle.Printing.PrintVTOL) EntityMovementMode(megamek.common.EntityMovementMode) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) MediaPrintableArea(javax.print.attribute.standard.MediaPrintableArea) File(java.io.File) PrintProtomech(megameklab.com.ui.ProtoMek.Printing.PrintProtomech) Entity(megamek.common.Entity) PrintSmallCraftSpheroid(megameklab.com.ui.Aero.Printing.PrintSmallCraftSpheroid) PrintAero(megameklab.com.ui.Aero.Printing.PrintAero) PrintFixedWingSupport(megameklab.com.ui.Aero.Printing.PrintFixedWingSupport) PrintDualTurretVehicle(megameklab.com.ui.Vehicle.Printing.PrintDualTurretVehicle) ArrayList(java.util.ArrayList) PrinterJob(java.awt.print.PrinterJob) MediaPrintableArea(javax.print.attribute.standard.MediaPrintableArea) PageFormat(java.awt.print.PageFormat) Book(java.awt.print.Book) PrintProtomech(megameklab.com.ui.ProtoMek.Printing.PrintProtomech) PrintVehicle(megameklab.com.ui.Vehicle.Printing.PrintVehicle) PrintAerodyne(megameklab.com.ui.Dropship.Printing.PrintAerodyne) PrintBattleArmor(megameklab.com.ui.BattleArmor.Printing.PrintBattleArmor) BattleArmor(megamek.common.BattleArmor) PrintFixedWingSupport(megameklab.com.ui.Aero.Printing.PrintFixedWingSupport) FixedWingSupport(megamek.common.FixedWingSupport) PrintTask(megameklab.com.printing.PrintTask) PrintLargeSupportVehicle(megameklab.com.ui.Vehicle.Printing.PrintLargeSupportVehicle) LargeSupportTank(megamek.common.LargeSupportTank) Dropship(megamek.common.Dropship) ConvFighter(megamek.common.ConvFighter) PrintSmallCraftAerodyne(megameklab.com.ui.Aero.Printing.PrintSmallCraftAerodyne) LargeSupportTank(megamek.common.LargeSupportTank) Tank(megamek.common.Tank) SmallCraft(megamek.common.SmallCraft) PrintInfantry(megameklab.com.ui.Infantry.Printing.PrintInfantry) Infantry(megamek.common.Infantry) PrintInfantry(megameklab.com.ui.Infantry.Printing.PrintInfantry) VTOL(megamek.common.VTOL) PrintVTOL(megameklab.com.ui.Vehicle.Printing.PrintVTOL) Protomech(megamek.common.Protomech) PrintProtomech(megameklab.com.ui.ProtoMek.Printing.PrintProtomech) Paper(java.awt.print.Paper) PrintMech(megameklab.com.printing.PrintMech) Mech(megamek.common.Mech) PrintMech(megameklab.com.printing.PrintMech) PrintSpheroid(megameklab.com.ui.Dropship.Printing.PrintSpheroid) PrintBattleArmor(megameklab.com.ui.BattleArmor.Printing.PrintBattleArmor) PrintConventionalFighter(megameklab.com.ui.Aero.Printing.PrintConventionalFighter) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrintVTOL(megameklab.com.ui.Vehicle.Printing.PrintVTOL)

Example 5 with SmallCraft

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

the class ImageHelperAero method printAeroWeaponsNEquipment.

public static void printAeroWeaponsNEquipment(Aero aero, Graphics2D g2d) {
    int pointShift = 0;
    if ((aero instanceof SmallCraft) && aero.isSpheroid()) {
        pointShift = 11;
    }
    int qtyPoint = 30;
    int typePoint = 42;
    int locPoint = 112 + pointShift;
    int heatPoint = 130 + pointShift;
    int shtPoint = 147 + pointShift;
    int medPoint = 170 + pointShift;
    int longPoint = 190 + pointShift;
    int erPoint = 210 + pointShift;
    float linePoint = 204f;
    float maxHeight = 97.0f;
    float lineFeed = 6.7f;
    boolean newLineNeeded = false;
    ArrayList<Hashtable<String, EquipmentInfo>> equipmentLocations = new ArrayList<Hashtable<String, EquipmentInfo>>(aero.locations());
    for (int pos = 0; pos <= aero.locations(); pos++) {
        equipmentLocations.add(pos, new Hashtable<String, EquipmentInfo>());
    }
    for (Mounted eq : aero.getEquipment()) {
        if ((eq.isWeaponGroup() || (eq.getType() instanceof AmmoType)) || (eq.getLocation() == Entity.LOC_NONE) || !UnitUtil.isPrintableEquipment(eq.getType())) {
            continue;
        }
        Hashtable<String, EquipmentInfo> eqHash = equipmentLocations.get(eq.getLocation());
        String equipmentName = eq.getName();
        if (eq.isRearMounted()) {
            equipmentName += "(R)";
        }
        if (eqHash.containsKey(equipmentName)) {
            EquipmentInfo eqi = eqHash.get(equipmentName);
            if (eq.getType().getTechLevel(aero.getTechLevelYear()) != eqi.techLevel) {
                eqi = new EquipmentInfo(aero, eq);
            } else {
                eqi.count++;
            }
            eqHash.put(equipmentName, eqi);
        } else {
            EquipmentInfo eqi = new EquipmentInfo(aero, eq);
            eqHash.put(equipmentName, eqi);
        }
    }
    if (aero.getTroopCarryingSpace() > 0) {
        maxHeight -= lineFeed;
    }
    if (aero.hasWorkingMisc(MiscType.F_CHASSIS_MODIFICATION)) {
        maxHeight -= lineFeed;
    }
    if (aero.getCockpitType() != Aero.COCKPIT_STANDARD) {
        maxHeight -= lineFeed;
    }
    for (@SuppressWarnings("unused") Bay bay : aero.getTransportBays()) {
        maxHeight -= lineFeed;
    }
    if (aero.getAmmo().size() > 0) {
        maxHeight -= lineFeed;
    }
    g2d.setFont(UnitUtil.deriveFont(false, 7.0f));
    Font font = ImageHelperAero.getAeroWeaponsNEquipmentFont(g2d, false, maxHeight, equipmentLocations, 7.0f);
    g2d.setFont(font);
    float stringHeight = ImageHelper.getStringHeight(g2d, "H", font);
    lineFeed = stringHeight;
    for (int pos = Aero.LOC_NOSE; pos <= aero.locations(); pos++) {
        Hashtable<String, EquipmentInfo> eqHash = equipmentLocations.get(pos);
        if (eqHash.size() < 1) {
            continue;
        }
        ArrayList<EquipmentInfo> equipmentList = new ArrayList<EquipmentInfo>();
        for (EquipmentInfo eqi : eqHash.values()) {
            equipmentList.add(eqi);
        }
        Collections.sort(equipmentList, StringUtils.equipmentInfoComparator());
        for (EquipmentInfo eqi : equipmentList) {
            newLineNeeded = false;
            g2d.setFont(font);
            g2d.drawString(Integer.toString(eqi.count), qtyPoint, linePoint);
            String name = eqi.name.trim() + " " + eqi.damage.trim();
            if (eqi.c3Level == EquipmentInfo.C3I) {
                ImageHelper.printC3iName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3EM) {
                ImageHelper.printC3EmName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3S) {
                ImageHelper.printC3sName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3M) {
                ImageHelper.printC3mName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3SB) {
                ImageHelper.printC3sbName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3MB) {
                ImageHelper.printC3mbName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.c3Level == EquipmentInfo.C3REMOTESENSOR) {
                ImageHelper.printC3RemoteSensorName(g2d, typePoint, linePoint, font, false, aero.isMixedTech() && TechConstants.isClan(aero.getTechLevel()));
            } else if (eqi.isMashCore) {
                ImageHelper.printMashCore(g2d, typePoint, linePoint, font, false, aero);
            } else if (eqi.isDroneControl) {
                ImageHelper.printDroneControl(g2d, typePoint, linePoint, font, false, aero);
            } else {
                if (ImageHelper.getStringWidth(g2d, name, font) > 65) {
                    // g2d.setFont(UnitUtil.getNewFont(g2d, eqi.name.trim(),
                    // false, 65, font.getSize2D()));
                    g2d.drawString(eqi.name.trim(), typePoint, linePoint);
                    linePoint += lineFeed;
                    g2d.drawString(eqi.damage.trim(), typePoint, linePoint);
                } else {
                    g2d.drawString(name, typePoint, linePoint);
                }
            }
            g2d.setFont(font);
            String location = ImageHelperAero.getLocationAbbrs(pos);
            if ((aero instanceof SmallCraft) && (aero.getMovementMode() == EntityMovementMode.SPHEROID)) {
                location = ImageHelperAero.getLocationAbbrsSmallCraft(pos);
            }
            g2d.drawString(location, locPoint, linePoint);
            ImageHelper.printCenterString(g2d, Integer.toString(eqi.heat), font, heatPoint, linePoint);
            if (eqi.isMML) {
                linePoint += lineFeed;
                g2d.drawString("SRM Ammo", typePoint, linePoint);
                g2d.drawString(Integer.toString(eqi.shtRange * 2), shtPoint, (int) linePoint);
                g2d.drawString("\u2014", medPoint, linePoint);
                g2d.drawString("\u2014", longPoint, linePoint);
                g2d.drawString("\u2014", erPoint, linePoint);
                // g2d.drawLine(medPoint, (int) linePoint - 2, medPoint + 6, (int) linePoint - 2);
                // g2d.drawLine(longPoint, (int) linePoint - 2, longPoint + 6, (int) linePoint - 2);
                // g2d.drawLine(erPoint, (int) linePoint - 2, erPoint + 6, (int) linePoint - 2);
                linePoint += lineFeed;
                g2d.drawString("LRM Ammo", typePoint, linePoint);
                g2d.drawString(Integer.toString(eqi.shtRange), shtPoint, (int) linePoint);
                g2d.drawString(Integer.toString(eqi.medRange), medPoint, (int) linePoint);
                g2d.drawString(Integer.toString(eqi.longRange), longPoint, (int) linePoint);
                g2d.drawString("\u2014", erPoint, linePoint);
            // g2d.drawLine(erPoint, (int) linePoint - 2, erPoint + 6, (int) linePoint - 2);
            } else if (eqi.shtRange > 0) {
                g2d.drawString(Integer.toString(eqi.shtRange), shtPoint, (int) linePoint);
            } else {
                g2d.drawString("\u2014", shtPoint, linePoint);
            // g2d.drawLine(shtPoint, (int) linePoint - 2, shtPoint + 6, (int) linePoint - 2);
            }
            if ((eqi.medRange > 0) && !eqi.isMML) {
                g2d.drawString(Integer.toString(eqi.medRange), medPoint, (int) linePoint);
            } else if (!eqi.isMML) {
                g2d.drawString("\u2014", medPoint, linePoint);
            // g2d.drawLine(medPoint, (int) linePoint - 2, medPoint + 6, (int) linePoint - 2);
            }
            if ((eqi.longRange > 0) && !eqi.isMML) {
                g2d.drawString(Integer.toString(eqi.longRange), longPoint, (int) linePoint);
            } else if (!eqi.isMML) {
                g2d.drawString("\u2014", longPoint, linePoint);
            // g2d.drawLine(longPoint, (int) linePoint - 2, longPoint + 6, (int) linePoint - 2);
            }
            if ((eqi.erRange > 0) && !eqi.isMML) {
                g2d.drawString(Integer.toString(eqi.erRange), erPoint, (int) linePoint);
            } else if (!eqi.isMML) {
                g2d.drawString("\u2014", erPoint, linePoint);
            // g2d.drawLine(erPoint, (int) linePoint - 2, erPoint + 6, (int) linePoint - 2);
            }
            if (eqi.hasArtemis) {
                g2d.drawString("w/Artemis IV FCS", typePoint, linePoint + lineFeed);
                newLineNeeded = true;
            } else if (eqi.hasArtemisV) {
                g2d.drawString("w/Artemis V FCS", typePoint, linePoint + lineFeed);
                newLineNeeded = true;
            } else if (eqi.hasApollo) {
                g2d.drawString("w/Apollo FCS", typePoint, linePoint + lineFeed);
                newLineNeeded = true;
            }
            linePoint += lineFeed;
            if (newLineNeeded) {
                linePoint += lineFeed;
            }
        }
    }
    if (aero.getCockpitType() != Aero.COCKPIT_STANDARD) {
        g2d.drawString(aero.getCockpitTypeString(), 22, linePoint);
        linePoint += lineFeed;
    }
    if (aero instanceof FixedWingSupport) {
        ImageHelperAero.printFixedWingSupportCargoChassisMod((FixedWingSupport) aero, g2d, (int) linePoint);
    } else {
        ImageHelperAero.printCargo(aero, g2d, (int) linePoint);
    }
    ImageHelper.printVehicleAmmo(aero, g2d, -20, 8);
    ImageHelperAero.printAeroFuel(aero, g2d, 8);
}
Also used : FixedWingSupport(megamek.common.FixedWingSupport) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Font(java.awt.Font) SmallCraft(megamek.common.SmallCraft) AmmoType(megamek.common.AmmoType) Mounted(megamek.common.Mounted) Bay(megamek.common.Bay)

Aggregations

SmallCraft (megamek.common.SmallCraft)5 Aero (megamek.common.Aero)3 BattleArmor (megamek.common.BattleArmor)3 Dropship (megamek.common.Dropship)3 Tank (megamek.common.Tank)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 ConvFighter (megamek.common.ConvFighter)2 Entity (megamek.common.Entity)2 FixedWingSupport (megamek.common.FixedWingSupport)2 Infantry (megamek.common.Infantry)2 Mech (megamek.common.Mech)2 Font (java.awt.Font)1 Frame (java.awt.Frame)1 Image (java.awt.Image)1 KeyEvent (java.awt.event.KeyEvent)1