use of megamek.common.VTOL 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;
}
use of megamek.common.VTOL 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;
}
use of megamek.common.VTOL in project megameklab by MegaMek.
the class CriticalView method refresh.
public void refresh() {
leftPanel.removeAll();
rightPanel.removeAll();
bodyPanel.removeAll();
frontPanel.removeAll();
rearPanel.removeAll();
turretPanel.removeAll();
dualTurretPanel.removeAll();
fullTurretPanel.removeAll();
rearLeftPanel.removeAll();
rearRightPanel.removeAll();
this.remove(fullTurretPanel);
if (getTank() instanceof VTOL) {
if (getTank().hasNoTurret()) {
turretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Rotor", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(turretPanel);
this.add(fullTurretPanel);
} else {
dualTurretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Turret", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(dualTurretPanel);
turretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Rotor", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(turretPanel);
this.add(fullTurretPanel);
}
} else if (!getTank().hasNoDualTurret()) {
dualTurretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Front Turret", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(dualTurretPanel);
turretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Rear Turret", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(turretPanel);
this.add(fullTurretPanel);
} else if (!getTank().hasNoTurret()) {
turretPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Turret", TitledBorder.TOP, TitledBorder.DEFAULT_POSITION));
fullTurretPanel.add(turretPanel);
this.add(fullTurretPanel);
}
synchronized (getTank()) {
for (int location = 0; location < getTank().locations(); location++) {
// JPanel locationPanel = new JPanel();
Vector<String> critNames = new Vector<String>(1, 1);
for (int slot = 0; slot < getTank().getNumberOfCriticals(location); slot++) {
CriticalSlot cs = getTank().getCritical(location, slot);
if (cs == null) {
continue;
} else if (cs.getType() == CriticalSlot.TYPE_SYSTEM) {
critNames.add(getMech().getSystemName(cs.getIndex()));
} else if (cs.getType() == CriticalSlot.TYPE_EQUIPMENT) {
try {
Mounted m = cs.getMount();
// Critical didn't get removed. Remove it now.
if (m == null) {
m = cs.getMount();
if (m == null) {
getTank().setCritical(location, slot, null);
continue;
}
cs.setMount(m);
}
StringBuffer critName = new StringBuffer(m.getName());
if (critName.length() > 25) {
critName.setLength(25);
critName.append("...");
}
if (m.isRearMounted()) {
critName.append(" (R)");
}
if (m.isSponsonTurretMounted()) {
critName.append(" (ST)");
}
if (m.isPintleTurretMounted()) {
critName.append(" (PT)");
}
critNames.add(critName.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
if (critNames.size() == 0) {
critNames.add(MtfFile.EMPTY);
}
DropTargetCriticalList<String> criticalSlotList = null;
DropTargetCriticalList<String> dropTargetCriticalList = new DropTargetCriticalList<String>(critNames, eSource, refresh, showEmpty);
criticalSlotList = dropTargetCriticalList;
criticalSlotList.setVisibleRowCount(critNames.size());
criticalSlotList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
criticalSlotList.setFont(new Font("Arial", Font.PLAIN, 10));
criticalSlotList.setName(Integer.toString(location));
criticalSlotList.setBorder(BorderFactory.createEtchedBorder(Color.WHITE.brighter(), Color.BLACK.darker()));
if (!(getTank()).isSuperHeavy()) {
switch(location) {
case Tank.LOC_FRONT:
frontPanel.add(criticalSlotList);
break;
case Tank.LOC_LEFT:
leftPanel.add(criticalSlotList);
break;
case Tank.LOC_RIGHT:
rightPanel.add(criticalSlotList);
break;
case Tank.LOC_BODY:
bodyPanel.add(criticalSlotList);
break;
case Tank.LOC_REAR:
rearPanel.add(criticalSlotList);
break;
case Tank.LOC_TURRET:
turretPanel.add(criticalSlotList);
break;
case Tank.LOC_TURRET_2:
dualTurretPanel.add(criticalSlotList);
break;
}
} else if (getTank() instanceof VTOL) {
switch(location) {
case Tank.LOC_FRONT:
frontPanel.add(criticalSlotList);
break;
case Tank.LOC_LEFT:
leftPanel.add(criticalSlotList);
break;
case Tank.LOC_RIGHT:
rightPanel.add(criticalSlotList);
break;
case Tank.LOC_BODY:
bodyPanel.add(criticalSlotList);
break;
case Tank.LOC_REAR:
rearPanel.add(criticalSlotList);
break;
case VTOL.LOC_ROTOR:
turretPanel.add(criticalSlotList);
break;
}
} else {
switch(location) {
case Tank.LOC_FRONT:
frontPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_FRONTLEFT:
leftPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_FRONTRIGHT:
rightPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_REARLEFT:
rearLeftPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_REARRIGHT:
rearRightPanel.add(criticalSlotList);
break;
case Tank.LOC_BODY:
bodyPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_REAR:
rearPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_TURRET:
turretPanel.add(criticalSlotList);
break;
case SuperHeavyTank.LOC_TURRET_2:
dualTurretPanel.add(criticalSlotList);
break;
}
}
}
middlePanel2.setVisible(getTank().isSuperHeavy() && !(getTank() instanceof VTOL));
frontPanel.repaint();
bodyPanel.repaint();
leftPanel.repaint();
rightPanel.repaint();
rearLeftPanel.repaint();
rearRightPanel.repaint();
rearPanel.repaint();
turretPanel.repaint();
dualTurretPanel.repaint();
}
}
use of megamek.common.VTOL 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;
}
use of megamek.common.VTOL in project megameklab by MegaMek.
the class MainUI method createNewUnit.
@Override
public void createNewUnit(long entityType, boolean isPrimitive, boolean isIndustrial, Entity oldEntity) {
if (entityType == Entity.ETYPE_VTOL) {
setEntity(new VTOL());
getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setWeight(20);
getEntity().setMovementMode(EntityMovementMode.VTOL);
} else {
if (entityType == Entity.ETYPE_SUPER_HEAVY_TANK) {
setEntity(new SuperHeavyTank());
getEntity().setTechLevel(TechConstants.T_IS_ADVANCED);
getEntity().setWeight(51);
} else {
setEntity(new Tank());
getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setWeight(20);
}
getEntity().setMovementMode(EntityMovementMode.HOVER);
}
Tank tank = (Tank) getEntity();
tank.setYear(3145);
tank.setEngine(new Engine(Math.max(10, (int) getEntity().getWeight() - tank.getSuspensionFactor()), Engine.NORMAL_ENGINE, Engine.TANK_ENGINE));
tank.autoSetInternal();
for (int loc = 0; loc < getEntity().locations(); loc++) {
tank.initializeArmor(0, loc);
}
getEntity().setArmorType(EquipmentType.T_ARMOR_STANDARD);
getEntity().setArmorTechLevel(TechConstants.T_INTRO_BOXSET);
getEntity().setStructureType(EquipmentType.T_STRUCTURE_STANDARD);
tank.setHasNoDualTurret(true);
if (Entity.ETYPE_VTOL == entityType) {
tank.setHasNoTurret(true);
}
if (null == oldEntity) {
tank.setChassis("New");
tank.setModel("Tank");
tank.setYear(3145);
} else {
tank.setChassis(oldEntity.getChassis());
tank.setModel(oldEntity.getModel());
tank.setYear(Math.max(oldEntity.getYear(), tank.getConstructionTechAdvancement().getIntroductionDate()));
tank.setSource(oldEntity.getSource());
tank.setManualBV(oldEntity.getManualBV());
SimpleTechLevel lvl = SimpleTechLevel.max(tank.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
tank.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
tank.setMixedTech(oldEntity.isMixedTech());
tank.setMovementMode(oldEntity.getMovementMode());
}
tank.setOriginalWalkMP((tank.getEngine().getRating() + tank.getSuspensionFactor()) / (int) tank.getWeight());
}
Aggregations