diff --git a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java index 87cbb9b1d58..23ad3a33fb1 100644 --- a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java @@ -335,6 +335,8 @@ public class TWAdvancedSearchPanel extends JPanel implements ActionListener, Ite private JButton btnFilterMilitary = new JButton("\u2610"); private JLabel lblFilterIndustrial = new JLabel(Messages.getString("MechSelectorDialog.Search.Industrial")); private JButton btnFilterIndustrial = new JButton("\u2610"); + private JLabel lblFilterMountedInfantry = new JLabel(Messages.getString("MechSelectorDialog.Search.MountedInfantry")); + private JButton btnFilterMountedInfantry = new JButton("\u2610"); private JLabel lblFilterWaterOnly = new JLabel(Messages.getString("MechSelectorDialog.Search.WaterOnly")); private JButton btnFilterWaterOnly = new JButton("\u2610"); private JLabel lblFilterSupportVehicle = new JLabel(Messages.getString("MechSelectorDialog.Search.SupportVehicle")); @@ -989,6 +991,8 @@ private JPanel createUnitTypePanel() { btnFilterMilitary.addActionListener(this); btnFilterIndustrial.setBorder(emptyBorder); btnFilterIndustrial.addActionListener(this); + btnFilterMountedInfantry.setBorder(emptyBorder); + btnFilterMountedInfantry.addActionListener(this); btnFilterWaterOnly.setBorder(emptyBorder); btnFilterWaterOnly.addActionListener(this); btnFilterSupportVehicle.setBorder(emptyBorder); @@ -1182,6 +1186,8 @@ private JPanel createUnitTypePanel() { filter1Panel.add(lblFilterMilitary); filter1Panel.add(btnFilterIndustrial); filter1Panel.add(lblFilterIndustrial); + filter1Panel.add(btnFilterMountedInfantry); + filter1Panel.add(lblFilterMountedInfantry); filter1Panel.add(btnFilterSupportVehicle); filter1Panel.add(lblFilterSupportVehicle); unitTypePanel.add(filter1Panel, c); @@ -1694,6 +1700,8 @@ public void actionPerformed(java.awt.event.ActionEvent ev) { toggleText(btnFilterMilitary); } else if (ev.getSource().equals(btnFilterIndustrial)) { toggleText(btnFilterIndustrial); + } else if (ev.getSource().equals(btnFilterMountedInfantry)) { + toggleText(btnFilterMountedInfantry); } else if (ev.getSource().equals(btnFilterWaterOnly)) { toggleText(btnFilterWaterOnly); } else if (ev.getSource().equals(btnFilterSupportVehicle)) { @@ -2052,6 +2060,7 @@ private void clearUnitType() { btnFilterOmni.setText("\u2610"); btnFilterMilitary.setText("\u2610"); btnFilterIndustrial.setText("\u2610"); + btnFilterMountedInfantry.setText("\u2610"); btnFilterWaterOnly.setText("\u2610"); btnFilterSupportVehicle.setText("\u2610"); btnFilterAerospaceFighter.setText("\u2610"); @@ -2319,6 +2328,7 @@ private void updateUnitTypes() { mechFilter.iOmni = getValue(btnFilterOmni); mechFilter.iMilitary = getValue(btnFilterMilitary); mechFilter.iIndustrial = getValue(btnFilterIndustrial); + mechFilter.iMountedInfantry = getValue(btnFilterMountedInfantry); mechFilter.iWaterOnly = getValue(btnFilterWaterOnly); mechFilter.iSupportVehicle = getValue(btnFilterSupportVehicle); mechFilter.iAerospaceFighter = getValue(btnFilterAerospaceFighter); diff --git a/megamek/src/megamek/common/MechSearchFilter.java b/megamek/src/megamek/common/MechSearchFilter.java index 379acf11e40..7b30067cf47 100644 --- a/megamek/src/megamek/common/MechSearchFilter.java +++ b/megamek/src/megamek/common/MechSearchFilter.java @@ -41,6 +41,7 @@ public enum BoolOp { AND, OR, NOP } public int iOmni; public int iMilitary; public int iIndustrial; + public int iMountedInfantry; public int iWaterOnly; public int iDoomedOnGround; public int iDoomedInAtmosphere; @@ -470,6 +471,10 @@ public static boolean isMatch(MechSummary mech, MechSearchFilter f) { return false; } + if (!isMatch(f.iMountedInfantry, mech.getMountedInfantry())) { + return false; + } + if (!isMatch(f.iWaterOnly, (mech.hasWaterMovement() && !mech.hasAirMovement() && !mech.hasGroundMovement()))) { return false; } diff --git a/megamek/src/megamek/common/MechSummary.java b/megamek/src/megamek/common/MechSummary.java index 225a04e43a1..aaa36263fba 100644 --- a/megamek/src/megamek/common/MechSummary.java +++ b/megamek/src/megamek/common/MechSummary.java @@ -39,6 +39,7 @@ public class MechSummary implements Serializable, ASCardDisplayable { private Long entityType; private boolean omni; private boolean military; + private boolean mountedInfantry; private int tankTurrets; private File sourceFile; private String source; @@ -337,6 +338,10 @@ public boolean getMilitary() { return military; } + public boolean getMountedInfantry() { + return mountedInfantry; + } + public int getTankTurrets() { return tankTurrets; } @@ -656,6 +661,10 @@ public void setMilitary(boolean b) { military = b; } + public void setMountedInfantry(boolean b) { + mountedInfantry = b; + } + public void setTankTurrets(int i) { tankTurrets = i; } diff --git a/megamek/src/megamek/common/MechSummaryCache.java b/megamek/src/megamek/common/MechSummaryCache.java index 15bc6a51c39..125afe79eb7 100644 --- a/megamek/src/megamek/common/MechSummaryCache.java +++ b/megamek/src/megamek/common/MechSummaryCache.java @@ -390,6 +390,8 @@ private MechSummary getSummary(Entity e, File f, String entry) { ms.setEntityType(e.getEntityType()); ms.setOmni(e.isOmni()); ms.setMilitary(e.isMilitary()); + ms.setMountedInfantry((e instanceof Infantry) && ((Infantry) e).getMount() != null); + int tankTurrets = 0; if (e instanceof Tank) { tankTurrets = ((Tank) e).getTurretCount();