From b4bd1eda14fea277ce38b33671b1199e3bbcc131 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 15 Mar 2024 00:57:45 -0700 Subject: [PATCH 1/6] Add buttons to move units selected in print queue --- .../ui/dialog/PrintQueueDialog.java | 136 +++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 055eef46a..d3930ff68 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -30,6 +30,8 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.awt.event.ActionEvent; @@ -38,6 +40,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.stream.IntStream; import static java.util.stream.Collectors.toList; @@ -54,6 +57,13 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { 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"); + + // todo: replace these with pretty up/down arrow symbols + private final JButton moveTopButton = new JButton("Move Top"); + private final JButton moveUpButton = new JButton("Move Up"); + private final JButton moveDownButton = new JButton("Move Down"); + private final JButton moveBottomButton = new JButton("Move Bottom"); + private final JCheckBox oneUnitPerSheetCheck = new JCheckBox("Print each unit to a separate page"); private final JFrame parent; private final List units = new ArrayList<>(); @@ -77,18 +87,36 @@ protected Container createCenterPane() { removeButton.addActionListener(e -> removeSelectedUnits()); removeButton.setEnabled(false); removeButton.setMnemonic(KeyEvent.VK_R); + + moveTopButton.addActionListener(e -> moveTop()); + moveTopButton.setMnemonic(KeyEvent.VK_PAGE_UP); + moveTopButton.setEnabled(false); + moveBottomButton.addActionListener(e -> moveBottom()); + moveBottomButton.setMnemonic(KeyEvent.VK_PAGE_DOWN); + moveBottomButton.setEnabled(false); + moveUpButton.addActionListener(e -> moveUp()); + moveUpButton.setMnemonic(KeyEvent.VK_UP); + moveUpButton.setEnabled(false); + moveDownButton.addActionListener(e -> moveDown()); + moveDownButton.setMnemonic(KeyEvent.VK_DOWN); + moveDownButton.setEnabled(false); + oneUnitPerSheetCheck.setAlignmentX(JComponent.CENTER_ALIGNMENT); oneUnitPerSheetCheck.setToolTipText("When unchecked, the record sheets for some unit types may be printed on the same page. " + "Note that the result may depend on whether reference tables are printed. This can be changed in the Settings."); queuedUnitList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - queuedUnitList.addListSelectionListener(e -> removeButton.setEnabled(!queuedUnitList.isSelectionEmpty())); + queuedUnitList.addListSelectionListener(new OnSelectionChanged()); queuedUnitList.setVisibleRowCount(15); - JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 1)); + JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 2)); buttonPanel.add(addFromCacheButton); + buttonPanel.add(moveTopButton); buttonPanel.add(addFromFileButton); + buttonPanel.add(moveUpButton); buttonPanel.add(addPageBreakButton); + buttonPanel.add(moveDownButton); buttonPanel.add(removeButton); + buttonPanel.add(moveBottomButton); buttonPanel.setAlignmentY(JComponent.TOP_ALIGNMENT); JScrollPane queuedUnitListScrollPane = new JScrollPane(queuedUnitList); queuedUnitListScrollPane.setAlignmentY(JComponent.TOP_ALIGNMENT); @@ -215,6 +243,110 @@ private void removeSelectedUnits() { refresh(); } + private void moveTop() { + List newListTop = new ArrayList<>(); + List newListBottom = new ArrayList<>(); + boolean state = false; + for (int i = 0; i < units.size(); i++) { + if (i == topSelectedIndex()) { + state = true; + } else if (i > bottomSelectedIndex()) { + state = false; + } + (state ? newListTop : newListBottom).add(units.get(i)); + } + units.clear(); + units.addAll(newListTop); + units.addAll(newListBottom); + refresh(); + queuedUnitList.setSelectedIndices(IntStream.range(0, newListTop.size()).toArray()); + } + + private void moveBottom() { + List newListBottom = new ArrayList<>(); + List newListTop = new ArrayList<>(); + boolean state = false; + for (int i = 0; i < units.size(); i++) { + if (i == topSelectedIndex()) { + state = true; + } else if (i > bottomSelectedIndex()) { + state = false; + } + (state ? newListBottom : newListTop).add(units.get(i)); + } + units.clear(); + units.addAll(newListTop); + units.addAll(newListBottom); + refresh(); + queuedUnitList.setSelectedIndices(IntStream.range(newListTop.size(), newListTop.size() + newListBottom.size()).toArray()); + } + + private void moveUp() { + var unit = units.remove(topSelectedIndex() - 1); + units.add(bottomSelectedIndex(), unit); + var indices = queuedUnitList.getSelectedIndices(); + refresh(); + queuedUnitList.setSelectedIndices(Arrays.stream(indices).map(i -> i - 1).toArray()); + } + + private void moveDown() { + var unit = units.remove(bottomSelectedIndex() + 1); + units.add(topSelectedIndex(), unit); + var indices = queuedUnitList.getSelectedIndices(); + refresh(); + queuedUnitList.setSelectedIndices(Arrays.stream(indices).map(i -> i + 1).toArray()); + } + + private int topSelectedIndex() { + return queuedUnitList.getSelectedIndex(); + } + + private int bottomSelectedIndex() { + var indices = queuedUnitList.getSelectedIndices(); + return indices[indices.length - 1]; + } + + private class OnSelectionChanged implements ListSelectionListener { + @Override + public void valueChanged(ListSelectionEvent e) { + removeButton.setEnabled(!queuedUnitList.isSelectionEmpty()); + + if (!isSelectionContiguous()) { + moveTopButton.setEnabled(false); + moveUpButton.setEnabled(false); + moveDownButton.setEnabled(false); + moveBottomButton.setEnabled(false); + } else { + if (topSelectedIndex() == 0) { + moveTopButton.setEnabled(false); + moveUpButton.setEnabled(false); + } else { + moveTopButton.setEnabled(true); + moveUpButton.setEnabled(true); + } + if (bottomSelectedIndex() == units.size() - 1) { + moveBottomButton.setEnabled(false); + moveDownButton.setEnabled(false); + } else { + moveBottomButton.setEnabled(true); + moveDownButton.setEnabled(true); + } + } + } + + private boolean isSelectionContiguous() { + // getSelectedIndices is guaranteed to return the indices in ascending order + var indices = queuedUnitList.getSelectedIndices(); + if (indices.length == 0) { + return false; + } + + var start = indices[0]; + var end = indices[indices.length - 1]; + return end - start == indices.length - 1; + } + } + // TODO: Move to UIUtil public static class FixedXYPanel extends JPanel { From 559038a562c081e2eb94529b26385ace9dfca868 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 15 Mar 2024 15:07:23 -0700 Subject: [PATCH 2/6] Set icons for selection move buttons --- megameklab/data/images/widgets/moveBottom.png | Bin 0 -> 390 bytes megameklab/data/images/widgets/moveDown.png | Bin 0 -> 333 bytes megameklab/data/images/widgets/moveTop.png | Bin 0 -> 410 bytes megameklab/data/images/widgets/moveUp.png | Bin 0 -> 337 bytes .../ui/dialog/PrintQueueDialog.java | 33 +++++++++++++----- 5 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 megameklab/data/images/widgets/moveBottom.png create mode 100644 megameklab/data/images/widgets/moveDown.png create mode 100644 megameklab/data/images/widgets/moveTop.png create mode 100644 megameklab/data/images/widgets/moveUp.png diff --git a/megameklab/data/images/widgets/moveBottom.png b/megameklab/data/images/widgets/moveBottom.png new file mode 100644 index 0000000000000000000000000000000000000000..5c21f674fffec731fa8c541aac57991d820e617a GIT binary patch literal 390 zcmeAS@N?(olHy`uVBq!ia0vp^f*>{r8<6y`Y?T61jKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r=85sBugD~Uq{1quc4bq-2jv*HQXD{y8ZY>l!{_%aN(&8z9IJ-7| zWRLjcVdSC1*38)I*mbq{Q*yAES+nQOC;U4uug#vIqo%Ap@lol#*Kvp67UkM~t+RV> z^W0|n<;o)F@J!>SSDL3DN~n6kd$K$>hrircPI-olXX2dyTD8em!ag&g;+daFwc# zG&$CLZ$o3PP9nGNj)PnJy={WeCO+MGl22?=pZXT%l8(??{a>rvdlgw7?d1%YKb&(s z?6A(Gv^~jAZ=2k8`Ko*PMCxtUM8(O}Kk(V7_WynR-%qP}vR-U>x@FBQMN!GH?;GkT iIac0L&I@(dtYwN8&*!n&{ly;`b_|}belF{r5}E)aP@ZW3 literal 0 HcmV?d00001 diff --git a/megameklab/data/images/widgets/moveDown.png b/megameklab/data/images/widgets/moveDown.png new file mode 100644 index 0000000000000000000000000000000000000000..53d73286eb354528ad12689e1878e999e5b6bd2d GIT binary patch literal 333 zcmeAS@N?(olHy`uVBq!ia0vp^fNn{1`ISV`@iy0XB4ude`@%$AjK*2|zE{-7@!BZ#Lb2}D_w4I--w0Tm$!jy~b z34uCB1*dZiCU~CdTI6#oZKI}q!`&t89K$9b^--xjw^t>w;`Pq=@6TJlxBc7m!$(R< zsO^@LqV*s3i{b}%Z7BSB(m_r~@6wO(!0Cs=5}d-+IX6i-3WYFVSlM^(n`YMD2=-G6 z2V}Z-UGSc}f=Tzo0Vyt)$Q`;_i*86L6|||9tlW7^kv~x4@D>9W^%c(YU(V-V@H9)f zwC70f-j)>{pAvs1sQz|H;jc^AbY3A;P_V7Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0WV2JK~y+TwbD&1 zL~#_y@jFUnDJ3sKVeEJTHY_Zx#KyvcLNP^(t%>rmQ%ZKytmI)MFJOwMY$O{iOP1uJ z_?(%ErqRU0ufF}xx##@Pz4zRk)Kc$xlEocX%a?vss_a#AaDW}69`6{+_a(=?N>xJ~ zZe(kiLewA8jL#3np=?FU`MHd=eMK<6yjdJjo44 z-Lb%n($mfM(T*6nh%G%IDaE+c9{Lg5!K~twT2?%aoP0svBwoh^LT4C@A$dU$9x$#s zmRWPLYJ+SSEhxm0WkCn#G~LU8wOD;^;tkwZd>w^YY`k|2eZ>+sF@qH};2I+aUGbv+ zf3cPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0Om} z0dXA1@!u&Wqm;*B;A}hq3xmOGF&HQYT`7-1l(H!$n`Dwdi#&iUy4mItFp? selectFromCache()); @@ -110,14 +120,18 @@ protected Container createCenterPane() { JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 2)); buttonPanel.add(addFromCacheButton); - buttonPanel.add(moveTopButton); buttonPanel.add(addFromFileButton); - buttonPanel.add(moveUpButton); buttonPanel.add(addPageBreakButton); - buttonPanel.add(moveDownButton); buttonPanel.add(removeButton); - buttonPanel.add(moveBottomButton); buttonPanel.setAlignmentY(JComponent.TOP_ALIGNMENT); + + JPanel moveButtonPanel = new FixedXYPanel(new GridLayout(4, 1)); + moveButtonPanel.add(moveTopButton); + moveButtonPanel.add(moveUpButton); + moveButtonPanel.add(moveDownButton); + moveButtonPanel.add(moveBottomButton); + moveButtonPanel.setAlignmentY(JComponent.TOP_ALIGNMENT); + JScrollPane queuedUnitListScrollPane = new JScrollPane(queuedUnitList); queuedUnitListScrollPane.setAlignmentY(JComponent.TOP_ALIGNMENT); queuedUnitListScrollPane.setBorder(new TitledBorder("Selected Units:")); @@ -125,6 +139,7 @@ protected Container createCenterPane() { Box centerPanel = Box.createHorizontalBox(); centerPanel.add(buttonPanel); centerPanel.add(Box.createHorizontalStrut(30)); + centerPanel.add(moveButtonPanel); centerPanel.add(queuedUnitListScrollPane); centerPanel.setBorder(new EmptyBorder(20, 30, 20, 30)); From aad692c5a1b80796916c6259f8acda367bf05e55 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 15 Mar 2024 15:13:12 -0700 Subject: [PATCH 3/6] Remove todo --- megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 87714880f..209ce142d 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -58,8 +58,7 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { 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"); - - // todo: replace these with pretty up/down arrow symbols + private final JButton moveTopButton = new JButton(icon("moveTop.png")); private final JButton moveUpButton = new JButton(icon("moveUp.png")); private final JButton moveDownButton = new JButton(icon("moveDown.png")); From 20ab7ba69715807e1c14a321d69bfa3d26465e9b Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Fri, 15 Mar 2024 15:16:49 -0700 Subject: [PATCH 4/6] typo --- megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 209ce142d..025cd9746 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -117,7 +117,7 @@ protected Container createCenterPane() { queuedUnitList.addListSelectionListener(new OnSelectionChanged()); queuedUnitList.setVisibleRowCount(15); - JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 2)); + JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 1)); buttonPanel.add(addFromCacheButton); buttonPanel.add(addFromFileButton); buttonPanel.add(addPageBreakButton); From 108eda2ea6bfd7846feaba78b7fb563a76a662a4 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Sat, 16 Mar 2024 19:04:43 -0700 Subject: [PATCH 5/6] Use print queue dialog for printing mul files --- megameklab/src/megameklab/ui/MenuBar.java | 15 +------- .../ui/dialog/PrintQueueDialog.java | 30 ++++++++++++--- .../src/megameklab/util/UnitPrintManager.java | 38 ++----------------- 3 files changed, 29 insertions(+), 54 deletions(-) diff --git a/megameklab/src/megameklab/ui/MenuBar.java b/megameklab/src/megameklab/ui/MenuBar.java index 22dad71f4..7603ddf6a 100644 --- a/megameklab/src/megameklab/ui/MenuBar.java +++ b/megameklab/src/megameklab/ui/MenuBar.java @@ -23,7 +23,6 @@ import megamek.common.annotations.Nullable; import megamek.common.loaders.BLKFile; import megamek.common.templates.TROView; -import megamek.common.util.ImageUtil; import megameklab.MMLConstants; import megameklab.ui.dialog.MMLFileChooser; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; @@ -394,15 +393,9 @@ private JMenu createPDFUnitExportMenu() { final JMenuItem miExportUnitsFromMULFileToPDF = new JMenuItem(resources.getString("FromMUL.text")); miExportUnitsFromMULFileToPDF.setName("miExportUnitsFromMULFileToPDF"); miExportUnitsFromMULFileToPDF.setMnemonic(KeyEvent.VK_M); - miExportUnitsFromMULFileToPDF.addActionListener(evt -> UnitPrintManager.exportMUL(owner.getFrame(), false)); + miExportUnitsFromMULFileToPDF.addActionListener(evt -> UnitPrintManager.printMUL(owner.getFrame(), true)); pdfUnitExportMenu.add(miExportUnitsFromMULFileToPDF); - final JMenuItem miExportUnitsFromMULFileToSinglePDFPages = new JMenuItem(resources.getString("FromMULSingle.text")); - miExportUnitsFromMULFileToSinglePDFPages.setName("miExportUnitsFromMULFileToSinglePDFPages"); - miExportUnitsFromMULFileToSinglePDFPages.setMnemonic(KeyEvent.VK_L); - miExportUnitsFromMULFileToSinglePDFPages.addActionListener(evt -> UnitPrintManager.exportMUL(owner.getFrame(), true)); - pdfUnitExportMenu.add(miExportUnitsFromMULFileToSinglePDFPages); - return pdfUnitExportMenu; } @@ -509,12 +502,6 @@ private JMenu createPrintMenu() { miPrintUnitsFromMULFile.addActionListener(evt -> UnitPrintManager.printMUL(owner.getFrame(), false)); printMenu.add(miPrintUnitsFromMULFile); - final JMenuItem miPrintUnitsFromMULFileToSinglePages = new JMenuItem(resources.getString("FromMULSingle.text")); - miPrintUnitsFromMULFileToSinglePages.setName("miPrintUnitsFromMULFileToSinglePages"); - miPrintUnitsFromMULFileToSinglePages.setMnemonic(KeyEvent.VK_L); - miPrintUnitsFromMULFileToSinglePages.addActionListener(evt -> UnitPrintManager.printMUL(owner.getFrame(), true)); - printMenu.add(miPrintUnitsFromMULFileToSinglePages); - return printMenu; } diff --git a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java index 025cd9746..b92fc0ba8 100644 --- a/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java +++ b/megameklab/src/megameklab/ui/dialog/PrintQueueDialog.java @@ -58,7 +58,7 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { 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 JButton moveTopButton = new JButton(icon("moveTop.png")); private final JButton moveUpButton = new JButton(icon("moveUp.png")); private final JButton moveDownButton = new JButton(icon("moveDown.png")); @@ -69,11 +69,22 @@ public class PrintQueueDialog extends AbstractMMLButtonDialog { private final List units = new ArrayList<>(); private final JList queuedUnitList = new JList<>(); - public PrintQueueDialog(JFrame parent, boolean printToPdf) { + private final boolean fromMul; + + public PrintQueueDialog(JFrame parent, boolean printToPdf, List units, boolean fromMul) { super(parent, true, "PrintQueueDialog", "PrintQueueDialog.windowName.text"); this.parent = parent; this.printToPdf = printToPdf; + this.fromMul = fromMul; initialize(); + if (units != null) { + this.units.addAll(units); + refresh(); + } + } + + public PrintQueueDialog(JFrame parent, boolean printToPdf) { + this(parent, printToPdf, null, false); } private static ImageIcon icon(String name) { @@ -118,8 +129,10 @@ protected Container createCenterPane() { queuedUnitList.setVisibleRowCount(15); JPanel buttonPanel = new FixedXYPanel(new GridLayout(4, 1)); - buttonPanel.add(addFromCacheButton); - buttonPanel.add(addFromFileButton); + if (!fromMul) { + buttonPanel.add(addFromCacheButton); + buttonPanel.add(addFromFileButton); + } buttonPanel.add(addPageBreakButton); buttonPanel.add(removeButton); buttonPanel.setAlignmentY(JComponent.TOP_ALIGNMENT); @@ -164,7 +177,14 @@ protected JPanel createButtonPanel() { private void refresh() { List nameList = units.stream() - .map(unit -> ' ' + unit.generalName() + ' ' + unit.specificName()) + .map(unit -> { + String title = String.format(" %s %s", unit.generalName(), unit.specificName()); + if (fromMul && unit instanceof Entity) { + var crew = ((Entity) unit).getCrew(); + title += String.format(" {%s %d/%d}", crew.getName(), crew.getGunnery(), crew.getPiloting()); + } + return title; + }) .collect(toList()); var replacementModel = new DefaultListModel(); diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index b821d4f82..b18ee81cb 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -19,7 +19,7 @@ import megamek.common.*; import megameklab.printing.*; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; -import org.apache.commons.io.FilenameUtils; +import megameklab.ui.dialog.PrintQueueDialog; import org.apache.logging.log4j.LogManager; import javax.print.attribute.HashPrintRequestAttributeSet; @@ -50,7 +50,7 @@ public static void exportEntity(Entity entity, JFrame parent) { } } - public static void printMUL(Frame parent, boolean singlePrint) { + public static void printMUL(JFrame parent, boolean printToPdf) { JFileChooser f = new JFileChooser(System.getProperty("user.dir")); f.setLocation(parent.getLocation().x + 150, parent.getLocation().y + 100); f.setDialogTitle("Print From MUL"); @@ -75,39 +75,7 @@ public static void printMUL(Frame parent, boolean singlePrint) { return; } - printAllUnits(loadedUnits, singlePrint); - } - - public static void exportMUL(Frame parent, boolean singlePrint) { - JFileChooser f = new JFileChooser(System.getProperty("user.dir")); - f.setLocation(parent.getLocation().x + 150, parent.getLocation().y + 100); - f.setDialogTitle("Export from MUL"); - f.setMultiSelectionEnabled(false); - - FileNameExtensionFilter filter = new FileNameExtensionFilter("Mul Files", "mul"); - - // Add a filter for mul files - f.setFileFilter(filter); - - int returnVal = f.showOpenDialog(parent); - if ((returnVal != JFileChooser.APPROVE_OPTION) || (f.getSelectedFile() == null)) { - // I want a file, y'know! - return; - } - File mulFile = f.getSelectedFile(); - final Vector loadedUnits; - try { - loadedUnits = new MULParser(mulFile, null).getEntities(); - loadedUnits.trimToSize(); - } catch (Exception ex) { - LogManager.getLogger().error("", ex); - return; - } - - File exportFile = getExportFile(parent, FilenameUtils.removeExtension(mulFile.getPath()) + ".pdf"); - if (exportFile != null) { - exportUnits(loadedUnits, exportFile, singlePrint); - } + new PrintQueueDialog(parent, printToPdf, loadedUnits, true).setVisible(true); } public static File getExportFile(Frame parent) { From 2973298f60c404a5973df101b11b1178f73ceb88 Mon Sep 17 00:00:00 2001 From: Pavel Braginskiy Date: Sun, 17 Mar 2024 22:54:26 -0400 Subject: [PATCH 6/6] Calculate force modifiers (Tag/C3) when printing from MUL --- .../resources/megameklab/resources/Dialogs.properties | 2 +- megameklab/src/megameklab/util/UnitPrintManager.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/megameklab/resources/megameklab/resources/Dialogs.properties b/megameklab/resources/megameklab/resources/Dialogs.properties index 1593b1b72..16267f956 100644 --- a/megameklab/resources/megameklab/resources/Dialogs.properties +++ b/megameklab/resources/megameklab/resources/Dialogs.properties @@ -36,7 +36,7 @@ ConfigurationDialog.chkShowCondensedTables.text=Print Mech hit location and clus ConfigurationDialog.chkShowCondensedTables.tooltip=Include hit location and cluster hits tables in the space where the fluff image normally goes. ConfigurationDialog.chkShowQuirks.text=Print design quirks ConfigurationDialog.chkShowQuirks.tooltip=Displays featured design quirks -ConfigurationDialog.chkShowPilotData.text=Include pilot data when printing from a MUL +ConfigurationDialog.chkShowPilotData.text=Include pilot and force data when printing from a MUL ConfigurationDialog.chkShowPilotData.tooltip=When using a MUL file for batch printing, unchecking this option ignores the generated crew information. ConfigurationDialog.chkShowEraIcon.text=Print era icon ConfigurationDialog.chkShowEraIcon.tooltip=Includes the icon associated with the era the unit was constructed. diff --git a/megameklab/src/megameklab/util/UnitPrintManager.java b/megameklab/src/megameklab/util/UnitPrintManager.java index b18ee81cb..b09c7c479 100644 --- a/megameklab/src/megameklab/util/UnitPrintManager.java +++ b/megameklab/src/megameklab/util/UnitPrintManager.java @@ -17,6 +17,7 @@ import megamek.client.ui.swing.UnitLoadingDialog; import megamek.common.*; +import megamek.common.util.C3Util; import megameklab.printing.*; import megameklab.ui.dialog.MegaMekLabUnitSelectorDialog; import megameklab.ui.dialog.PrintQueueDialog; @@ -75,6 +76,15 @@ 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); }