diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index b92fc0ba8..d7512b0a0 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -20,12 +20,11 @@ import megamek.client.ui.baseComponents.MMButton; import megamek.client.ui.swing.UnitLoadingDialog; -import megamek.common.BTObject; -import megamek.common.Configuration; -import megamek.common.Entity; -import megamek.common.MechFileParser; +import megamek.common.*; +import megamek.common.util.C3Util; import megameklab.printing.PageBreak; import megameklab.util.UnitPrintManager; +import org.apache.commons.io.FilenameUtils; import org.apache.logging.log4j.LogManager; import javax.swing.*; @@ -65,17 +64,21 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { private final JButton moveBottomButton = new JButton(icon("moveBottom.png")); private final JCheckBox oneUnitPerSheetCheck = new JCheckBox("Print each unit to a separate page"); + private final JCheckBox adjustedBvCheck = new JCheckBox("Print force-adjusted BV"); private final JFrame parent; private final List units = new ArrayList<>(); private final JList queuedUnitList = new JList<>(); private final boolean fromMul; - public PrintQueueDialog(JFrame parent, boolean printToPdf, List units, boolean fromMul) { + private final String mulFileName; + + public PrintQueueDialog(JFrame parent, boolean printToPdf, List units, boolean fromMul, String mulFileName) { super(parent, true, "PrintQueueDialog", "PrintQueueDialog.windowName.text"); this.parent = parent; this.printToPdf = printToPdf; this.fromMul = fromMul; + this.mulFileName = mulFileName; initialize(); if (units != null) { this.units.addAll(units); @@ -84,7 +87,7 @@ public PrintQueueDialog(JFrame parent, boolean printToPdf, List i instanceof Entity).map(i -> (Entity) i).toList()) { + e.setOwner(p); + g.addEntity(e); + C3Util.wireC3(g, e); + } + } + } + if (printToPdf) { - File exportFile = UnitPrintManager.getExportFile(parent); + File exportFile; + if (mulFileName.isBlank()) { + exportFile = UnitPrintManager.getExportFile(parent); + } else { + exportFile = UnitPrintManager.getExportFile(parent, FilenameUtils.removeExtension(mulFileName) + ".pdf"); + } if (exportFile != null) { UnitPrintManager.exportUnits(units, exportFile, oneUnitPerSheetCheck.isSelected()); } else { diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index 5f7b52b5a..51be9371b 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -76,23 +76,14 @@ public static void printMUL(JFrame parent, boolean printToPdf) { return; } - // Dummy player and game allow bonus BV from C3 and TAG to be calculated - Game g = new Game(); - Player p = new Player(1, "Nobody"); - for (Entity e : loadedUnits) { - e.setOwner(p); - g.addEntity(e); - C3Util.wireC3(g, e); - } - - new PrintQueueDialog(parent, printToPdf, loadedUnits, true).setVisible(true); + new PrintQueueDialog(parent, printToPdf, loadedUnits, true, f.getSelectedFile().getName()).setVisible(true); } public static File getExportFile(Frame parent) { return getExportFile(parent, ""); } - private static File getExportFile(Frame parent, String suggestedFileName) { + public static File getExportFile(Frame parent, String suggestedFileName) { JFileChooser f = new JFileChooser(System.getProperty("user.dir")); f.setLocation(parent.getLocation().x + 150, parent.getLocation().y + 100); f.setDialogTitle("Choose export file name");