From 50ffa1b1866eb44923704157f82bb884416cfa40 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Mon, 4 Mar 2024 00:14:46 -0800 Subject: [PATCH 1/5] Allow user to add pagebreaks when queueing units to print --- .../src/megameklab/printing/PageBreak.java | 228 ++++++++++++++++++ .../ui/dialog/PrintQueueDialog.java | 12 +- .../src/megameklab/util/UnitPrintManager.java | 25 +- 3 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 megameklab/src/megameklab/printing/PageBreak.java diff --git a/megameklab/src/megameklab/printing/PageBreak.java b/megameklab/src/megameklab/printing/PageBreak.java new file mode 100644 index 000000000..adbe19b25 --- /dev/null +++ b/megameklab/src/megameklab/printing/PageBreak.java @@ -0,0 +1,228 @@ +package megameklab.printing; + +import megamek.client.ui.swing.calculationReport.CalculationReport; +import megamek.common.*; +import megamek.common.enums.AimingMode; + +import java.util.Vector; + +/** + * Dummy entity that indicates that the page should be broken when printing. + * + * @author pavelbraginskiy + */ +public class PageBreak extends Entity { + public PageBreak() { + setChassis("-PAGEBREAK-"); + setModel(""); + } + + @Override + public int getUnitType() { + return 0; + } + + @Override + public TechAdvancement getConstructionTechAdvancement() { + return null; + } + + @Override + public int locations() { + return 0; + } + + @Override + public boolean canChangeSecondaryFacing() { + return false; + } + + @Override + public boolean isValidSecondaryFacing(int dir) { + return false; + } + + @Override + public int clipSecondaryFacing(int dir) { + return 0; + } + + @Override + public String getMovementString(EntityMovementType mtype) { + return ""; + } + + @Override + public String getMovementAbbr(EntityMovementType mtype) { + return ""; + } + + @Override + public String[] getLocationNames() { + return new String[0]; + } + + @Override + public String[] getLocationAbbrs() { + return new String[0]; + } + + @Override + public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMode aimingMode, int cover) { + return null; + } + + @Override + public HitData rollHitLocation(int table, int side) { + return null; + } + + @Override + public HitData getTransferLocation(HitData hit) { + return null; + } + + @Override + public int getDependentLocation(int loc) { + return 0; + } + + @Override + public boolean hasRearArmor(int loc) { + return false; + } + + @Override + public void autoSetInternal() { + + } + + @Override + public int getWeaponArc(int wn) { + return 0; + } + + @Override + public boolean isSecondaryArcWeapon(int weaponId) { + return false; + } + + @Override + public int getHeatCapacity(boolean radicalHeatSink) { + return 0; + } + + @Override + public int getHeatCapacityWithWater() { + return 0; + } + + @Override + public int getEngineCritHeat() { + return 0; + } + + @Override + protected int[] getNoOfSlots() { + return new int[0]; + } + + @Override + public Vector victoryReport() { + return null; + } + + @Override + public PilotingRollData addEntityBonuses(PilotingRollData roll) { + return null; + } + + @Override + public int getMaxElevationChange() { + return 0; + } + + @Override + public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { + return 0; + } + + @Override + public boolean doomedInExtremeTemp() { + return false; + } + + @Override + public boolean doomedInVacuum() { + return false; + } + + @Override + public boolean doomedOnGround() { + return false; + } + + @Override + public boolean doomedInAtmosphere() { + return false; + } + + @Override + public boolean doomedInSpace() { + return false; + } + + @Override + public boolean isNuclearHardened() { + return false; + } + + @Override + public int getTotalCommGearTons() { + return 0; + } + + @Override + public int getEngineHits() { + return 0; + } + + @Override + public String getLocationDamage(int loc) { + return ""; + } + + @Override + public boolean isCrippled() { + return false; + } + + @Override + public boolean isCrippled(boolean checkCrew) { + return false; + } + + @Override + public boolean isDmgHeavy() { + return false; + } + + @Override + public boolean isDmgModerate() { + return false; + } + + @Override + public boolean isDmgLight() { + return false; + } + + @Override + public long getEntityType() { + return 0; + } + + @Override + protected void initTechAdvancement() { + } +} \ No newline at end of file diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index c80558e71..7bdbf5c1b 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -22,6 +22,7 @@ import megamek.client.ui.swing.UnitLoadingDialog; import megamek.common.Entity; import megamek.common.MechFileParser; +import megameklab.printing.PageBreak; import megameklab.util.UnitPrintManager; import org.apache.logging.log4j.LogManager; @@ -50,6 +51,7 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { private final boolean printToPdf; private final JButton addFromFileButton = new JButton("Add From File"); private final JButton addFromCacheButton = new JButton("Add From Cache"); + private final JButton addPageBreakButton = new JButton("Add Page Break"); private final JButton removeButton = new JButton("Remove Selected"); private final JCheckBox oneUnitPerSheetCheck = new JCheckBox("Print each unit to a separate page"); private final JFrame parent; @@ -69,6 +71,8 @@ protected Container createCenterPane() { addFromCacheButton.setMnemonic(KeyEvent.VK_A); addFromFileButton.addActionListener(e -> selectFromFile()); addFromFileButton.setMnemonic(KeyEvent.VK_F); + addPageBreakButton.addActionListener(e -> pageBreak()); + addPageBreakButton.setMnemonic(KeyEvent.VK_P); removeButton.addActionListener(e -> removeSelectedUnits()); removeButton.setEnabled(false); removeButton.setMnemonic(KeyEvent.VK_R); @@ -80,9 +84,10 @@ protected Container createCenterPane() { queuedUnitList.setVisibleRowCount(15); JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 1)); - buttonPanel.add(new JLabel()); + //buttonPanel.add(new JLabel()); buttonPanel.add(addFromCacheButton); buttonPanel.add(addFromFileButton); + buttonPanel.add(addPageBreakButton); buttonPanel.add(removeButton); buttonPanel.setAlignmentY(JComponent.TOP_ALIGNMENT); JScrollPane queuedUnitListScrollPane = new JScrollPane(queuedUnitList); @@ -140,6 +145,11 @@ protected void okButtonActionPerformed(ActionEvent evt) { super.okButtonActionPerformed(evt); } + private void pageBreak() { + units.add(new PageBreak()); + refresh(); + } + private void selectFromCache() { UnitLoadingDialog unitLoadingDialog = new UnitLoadingDialog(parent); unitLoadingDialog.setVisible(true); diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index 58de92de6..ca18ed65b 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -16,7 +16,9 @@ package megameklab.util; import megamek.client.ui.swing.UnitLoadingDialog; +import megamek.client.ui.swing.calculationReport.CalculationReport; import megamek.common.*; +import megamek.common.enums.AimingMode; import megameklab.printing.*; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; import org.apache.commons.io.FilenameUtils; @@ -197,7 +199,28 @@ private static List createSheets(List entities, boolea sheets.add(prs); protoList = new ArrayList<>(); } - } else { + } else if (unit instanceof PageBreak) { + if (!singlePrint) { + if (!baList.isEmpty()) { + PrintRecordSheet prs = new PrintSmallUnitSheet(baList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + baList = new ArrayList<>(); + } + if (!infList.isEmpty()) { + PrintRecordSheet prs = new PrintSmallUnitSheet(infList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + infList = new ArrayList<>(); + } + if (!protoList.isEmpty()) { + PrintRecordSheet prs = new PrintSmallUnitSheet(protoList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + protoList = new ArrayList<>(); + } + } + }else { unprintable.add(unit); } } From 72cfecd7ec8e3ae459678915f4bc2d612cb613cf Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Mon, 4 Mar 2024 00:19:12 -0800 Subject: [PATCH 2/5] Tanks are multipage units, too --- megameklab/src/megameklab/util/UnitPrintManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index ca18ed65b..258eebc0c 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -219,6 +219,10 @@ private static List createSheets(List entities, boolea sheets.add(prs); protoList = new ArrayList<>(); } + if (null != tank1) { + sheets.add(new PrintCompositeTankSheet(tank1, null, pageCount++, options)); + tank1 = null; + } } }else { unprintable.add(unit); From 1603395c95acc4d90b4086512afba09acaaeaf79 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Mon, 4 Mar 2024 21:26:18 -0800 Subject: [PATCH 3/5] typos --- megameklab/src/megameklab/printing/PageBreak.java | 2 +- megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java | 1 - megameklab/src/megameklab/util/UnitPrintManager.java | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/megameklab/src/megameklab/printing/PageBreak.java b/megameklab/src/megameklab/printing/PageBreak.java index adbe19b25..62626dd80 100644 --- a/megameklab/src/megameklab/printing/PageBreak.java +++ b/megameklab/src/megameklab/printing/PageBreak.java @@ -225,4 +225,4 @@ public long getEntityType() { @Override protected void initTechAdvancement() { } -} \ No newline at end of file +} diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 7bdbf5c1b..0cb101963 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -84,7 +84,6 @@ protected Container createCenterPane() { queuedUnitList.setVisibleRowCount(15); JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 1)); - //buttonPanel.add(new JLabel()); buttonPanel.add(addFromCacheButton); buttonPanel.add(addFromFileButton); buttonPanel.add(addPageBreakButton); diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index 258eebc0c..0043b5ef2 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -16,9 +16,7 @@ package megameklab.util; import megamek.client.ui.swing.UnitLoadingDialog; -import megamek.client.ui.swing.calculationReport.CalculationReport; import megamek.common.*; -import megamek.common.enums.AimingMode; import megameklab.printing.*; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; import org.apache.commons.io.FilenameUtils; @@ -224,7 +222,7 @@ private static List createSheets(List entities, boolea tank1 = null; } } - }else { + } else { unprintable.add(unit); } } From 559d1e77b1ab161db24a351fad31c80b56d86657 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 8 Mar 2024 02:43:16 -0800 Subject: [PATCH 4/5] Rework Pagebreak class to be a BTObject rather than a dummy Entity --- .../src/megameklab/printing/PageBreak.java | 215 +----------------- .../ui/dialog/PrintQueueDialog.java | 7 +- .../src/megameklab/util/UnitPrintManager.java | 137 ++++++----- 3 files changed, 84 insertions(+), 275 deletions(-) diff --git a/megameklab/src/megameklab/printing/PageBreak.java b/megameklab/src/megameklab/printing/PageBreak.java index 62626dd80..564239e57 100644 --- a/megameklab/src/megameklab/printing/PageBreak.java +++ b/megameklab/src/megameklab/printing/PageBreak.java @@ -1,228 +1,21 @@ package megameklab.printing; -import megamek.client.ui.swing.calculationReport.CalculationReport; import megamek.common.*; -import megamek.common.enums.AimingMode; - -import java.util.Vector; /** * Dummy entity that indicates that the page should be broken when printing. * * @author pavelbraginskiy */ -public class PageBreak extends Entity { - public PageBreak() { - setChassis("-PAGEBREAK-"); - setModel(""); - } - - @Override - public int getUnitType() { - return 0; - } - - @Override - public TechAdvancement getConstructionTechAdvancement() { - return null; - } - - @Override - public int locations() { - return 0; - } - - @Override - public boolean canChangeSecondaryFacing() { - return false; - } - - @Override - public boolean isValidSecondaryFacing(int dir) { - return false; - } - - @Override - public int clipSecondaryFacing(int dir) { - return 0; - } +public class PageBreak implements BTObject { @Override - public String getMovementString(EntityMovementType mtype) { - return ""; + public String generalName() { + return "-PAGE BREAK-"; } @Override - public String getMovementAbbr(EntityMovementType mtype) { + public String specificName() { return ""; } - - @Override - public String[] getLocationNames() { - return new String[0]; - } - - @Override - public String[] getLocationAbbrs() { - return new String[0]; - } - - @Override - public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMode aimingMode, int cover) { - return null; - } - - @Override - public HitData rollHitLocation(int table, int side) { - return null; - } - - @Override - public HitData getTransferLocation(HitData hit) { - return null; - } - - @Override - public int getDependentLocation(int loc) { - return 0; - } - - @Override - public boolean hasRearArmor(int loc) { - return false; - } - - @Override - public void autoSetInternal() { - - } - - @Override - public int getWeaponArc(int wn) { - return 0; - } - - @Override - public boolean isSecondaryArcWeapon(int weaponId) { - return false; - } - - @Override - public int getHeatCapacity(boolean radicalHeatSink) { - return 0; - } - - @Override - public int getHeatCapacityWithWater() { - return 0; - } - - @Override - public int getEngineCritHeat() { - return 0; - } - - @Override - protected int[] getNoOfSlots() { - return new int[0]; - } - - @Override - public Vector victoryReport() { - return null; - } - - @Override - public PilotingRollData addEntityBonuses(PilotingRollData roll) { - return null; - } - - @Override - public int getMaxElevationChange() { - return 0; - } - - @Override - public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { - return 0; - } - - @Override - public boolean doomedInExtremeTemp() { - return false; - } - - @Override - public boolean doomedInVacuum() { - return false; - } - - @Override - public boolean doomedOnGround() { - return false; - } - - @Override - public boolean doomedInAtmosphere() { - return false; - } - - @Override - public boolean doomedInSpace() { - return false; - } - - @Override - public boolean isNuclearHardened() { - return false; - } - - @Override - public int getTotalCommGearTons() { - return 0; - } - - @Override - public int getEngineHits() { - return 0; - } - - @Override - public String getLocationDamage(int loc) { - return ""; - } - - @Override - public boolean isCrippled() { - return false; - } - - @Override - public boolean isCrippled(boolean checkCrew) { - return false; - } - - @Override - public boolean isDmgHeavy() { - return false; - } - - @Override - public boolean isDmgModerate() { - return false; - } - - @Override - public boolean isDmgLight() { - return false; - } - - @Override - public long getEntityType() { - return 0; - } - - @Override - protected void initTechAdvancement() { - } } diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 0cb101963..055eef46a 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -20,6 +20,7 @@ import megamek.client.ui.baseComponents.MMButton; import megamek.client.ui.swing.UnitLoadingDialog; +import megamek.common.BTObject; import megamek.common.Entity; import megamek.common.MechFileParser; import megameklab.printing.PageBreak; @@ -55,7 +56,7 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { private final JButton removeButton = new JButton("Remove Selected"); private final JCheckBox oneUnitPerSheetCheck = new JCheckBox("Print each unit to a separate page"); private final JFrame parent; - private final List units = new ArrayList<>(); + private final List units = new ArrayList<>(); private final JList queuedUnitList = new JList<>(); public PrintQueueDialog(JFrame parent, boolean printToPdf) { @@ -121,7 +122,7 @@ protected JPanel createButtonPanel() { private void refresh() { List nameList = units.stream() - .map(unit -> " " + unit.getChassis() + " " + unit.getModel()) + .map(unit -> ' ' + unit.generalName() + ' ' + unit.specificName()) .collect(toList()); var replacementModel = new DefaultListModel(); @@ -202,7 +203,7 @@ private void selectFromFile() { } private void removeSelectedUnits() { - List newList = new ArrayList<>(); + List newList = new ArrayList<>(); for (int i = 0; i < units.size(); i++) { final int index = i; if (Arrays.stream(queuedUnitList.getSelectedIndices()).noneMatch(idx -> idx == index)) { diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index 0043b5ef2..bd04392f8 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -135,69 +135,72 @@ private static File getExportFile(Frame parent, String suggestedFileName) { return f.getSelectedFile(); } - private static List createSheets(List entities, boolean singlePrint, + private static List createSheets(List entities, boolean singlePrint, RecordSheetOptions options) { List sheets = new ArrayList<>(); List infList = new ArrayList<>(); List baList = new ArrayList<>(); List protoList = new ArrayList<>(); - List unprintable = new ArrayList<>(); + List unprintable = new ArrayList<>(); Tank tank1 = null; int pageCount = 0; - for (Entity unit : entities) { - if (unit instanceof Mech) { - UnitUtil.removeOneShotAmmo(unit); - MekUtil.expandUnitMounts((Mech) unit); - sheets.add(new PrintMech((Mech) unit, pageCount++, options)); - } else if ((unit instanceof Tank) && unit.getMovementMode().isMarine()) { - sheets.add(new PrintTank((Tank) unit, pageCount++, options)); - } else if (unit instanceof Tank) { - if (singlePrint || options.showReferenceCharts()) { - sheets.add(new PrintCompositeTankSheet((Tank) unit, null, pageCount++, options)); - } else if (null != tank1) { - sheets.add(new PrintCompositeTankSheet(tank1, (Tank) unit, pageCount++, options)); - tank1 = null; - } else { - tank1 = (Tank) unit; - } - } else if (unit.hasETypeFlag(Entity.ETYPE_AERO)) { - if (unit instanceof Jumpship) { - PrintCapitalShip pcs = new PrintCapitalShip((Jumpship) unit, pageCount, options); - pageCount += pcs.getPageCount(); - sheets.add(pcs); - } else if (unit instanceof Dropship) { - PrintDropship pds = new PrintDropship((Aero) unit, pageCount, options); - pageCount += pds.getPageCount(); - sheets.add(pds); - } else { - sheets.add(new PrintAero((Aero) unit, pageCount++, options)); - } - } else if (unit instanceof BattleArmor) { - baList.add((BattleArmor) unit); - if (singlePrint || baList.size() > 4) { - PrintRecordSheet prs = new PrintSmallUnitSheet(baList, pageCount, options); - pageCount += prs.getPageCount(); - sheets.add(prs); - baList = new ArrayList<>(); - } - } else if (unit instanceof Infantry) { - infList.add((Infantry) unit); - if (singlePrint || infList.size() > (options.showReferenceCharts() ? 2 : 3)) { - PrintRecordSheet prs = new PrintSmallUnitSheet(infList, pageCount, options); - pageCount += prs.getPageCount(); - sheets.add(prs); - infList = new ArrayList<>(); - } - } else if (unit instanceof Protomech) { - protoList.add((Protomech) unit); - if (singlePrint || protoList.size() > 4) { - PrintRecordSheet prs = new PrintSmallUnitSheet(protoList, pageCount, options); - pageCount += prs.getPageCount(); - sheets.add(prs); - protoList = new ArrayList<>(); + for (BTObject object : entities) { + if (object instanceof Entity) { + Entity unit = (Entity) object; + if (unit instanceof Mech) { + UnitUtil.removeOneShotAmmo(unit); + MekUtil.expandUnitMounts((Mech) unit); + sheets.add(new PrintMech((Mech) unit, pageCount++, options)); + } else if ((unit instanceof Tank) && unit.getMovementMode().isMarine()) { + sheets.add(new PrintTank((Tank) unit, pageCount++, options)); + } else if (unit instanceof Tank) { + if (singlePrint || options.showReferenceCharts()) { + sheets.add(new PrintCompositeTankSheet((Tank) unit, null, pageCount++, options)); + } else if (null != tank1) { + sheets.add(new PrintCompositeTankSheet(tank1, (Tank) unit, pageCount++, options)); + tank1 = null; + } else { + tank1 = (Tank) unit; + } + } else if (unit.hasETypeFlag(Entity.ETYPE_AERO)) { + if (unit instanceof Jumpship) { + PrintCapitalShip pcs = new PrintCapitalShip((Jumpship) unit, pageCount, options); + pageCount += pcs.getPageCount(); + sheets.add(pcs); + } else if (unit instanceof Dropship) { + PrintDropship pds = new PrintDropship((Aero) unit, pageCount, options); + pageCount += pds.getPageCount(); + sheets.add(pds); + } else { + sheets.add(new PrintAero((Aero) unit, pageCount++, options)); + } + } else if (unit instanceof BattleArmor) { + baList.add((BattleArmor) unit); + if (singlePrint || baList.size() > 4) { + PrintRecordSheet prs = new PrintSmallUnitSheet(baList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + baList = new ArrayList<>(); + } + } else if (unit instanceof Infantry) { + infList.add((Infantry) unit); + if (singlePrint || infList.size() > (options.showReferenceCharts() ? 2 : 3)) { + PrintRecordSheet prs = new PrintSmallUnitSheet(infList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + infList = new ArrayList<>(); + } + } else if (unit instanceof Protomech) { + protoList.add((Protomech) unit); + if (singlePrint || protoList.size() > 4) { + PrintRecordSheet prs = new PrintSmallUnitSheet(protoList, pageCount, options); + pageCount += prs.getPageCount(); + sheets.add(prs); + protoList = new ArrayList<>(); + } } - } else if (unit instanceof PageBreak) { + } else if (object instanceof PageBreak) { if (!singlePrint) { if (!baList.isEmpty()) { PrintRecordSheet prs = new PrintSmallUnitSheet(baList, pageCount, options); @@ -223,13 +226,13 @@ private static List createSheets(List entities, boolea } } } else { - unprintable.add(unit); + unprintable.add(object); } } if (!unprintable.isEmpty()) { JOptionPane.showMessageDialog(null, "Exporting is not currently supported for the following units:\n" - + unprintable.stream().map(en -> en.getChassis() + " " + en.getModel()) + + unprintable.stream().map(en -> en.generalName() + ' ' + en.specificName()) .collect(Collectors.joining("\n"))); } @@ -251,7 +254,7 @@ private static List createSheets(List entities, boolea return sheets; } - public static void exportUnits(List units, File exportFile, boolean singlePrint) { + public static void exportUnits(List units, File exportFile, boolean singlePrint) { RecordSheetOptions options = new RecordSheetOptions(); List sheets = createSheets(units, singlePrint, options); PageFormat pageFormat = new PageFormat(); @@ -266,7 +269,7 @@ public static void exportUnits(List units, File exportFile, boolean sing * @param loadedUnits The units to print * @param singlePrint Whether to limit each record sheet to a single unit */ - public static void printAllUnits(List loadedUnits, boolean singlePrint) { + public static void printAllUnits(List loadedUnits, boolean singlePrint) { printAllUnits(loadedUnits, singlePrint, new RecordSheetOptions()); } @@ -277,7 +280,7 @@ public static void printAllUnits(List loadedUnits, boolean singlePrint) * @param singlePrint Whether to limit each record sheet to a single unit * @param options The options to use for this print job */ - public static void printAllUnits(List loadedUnits, boolean singlePrint, + public static void printAllUnits(List loadedUnits, boolean singlePrint, RecordSheetOptions options) { HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(options.getPaperSize().sizeName); @@ -295,9 +298,21 @@ public static void printAllUnits(List loadedUnits, boolean singlePrint, List sheets = createSheets(loadedUnits, singlePrint, options); if (loadedUnits.size() > 1) { - masterPrintJob.setJobName(loadedUnits.get(0).getShortNameRaw() + " etc"); + String name; + if (loadedUnits.get(0) instanceof Entity) { + name = ((Entity) loadedUnits.get(0)).getShortNameRaw(); + } else { + name = loadedUnits.get(0).generalName(); + } + masterPrintJob.setJobName(name + " etc"); } else if (!loadedUnits.isEmpty()) { - masterPrintJob.setJobName(loadedUnits.get(0).getShortNameRaw()); + String name; + if (loadedUnits.get(0) instanceof Entity) { + name = ((Entity) loadedUnits.get(0)).getShortNameRaw(); + } else { + name = loadedUnits.get(0).generalName(); + } + masterPrintJob.setJobName(name); } RecordSheetTask task = RecordSheetTask.createPrintTask(sheets, masterPrintJob, aset, pageFormat); From e7f4fbe872982c15f5cef13b461d2858bb9f9e87 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 8 Mar 2024 02:56:03 -0800 Subject: [PATCH 5/5] typo --- megameklab/src/megameklab/util/UnitPrintManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index bd04392f8..b821d4f82 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -199,6 +199,8 @@ private static List createSheets(List enti sheets.add(prs); protoList = new ArrayList<>(); } + } else { + unprintable.add(unit); } } else if (object instanceof PageBreak) { if (!singlePrint) {