Skip to content

Commit

Permalink
Merge pull request #4900 from kuronekochomusuke/advancedSearchMounted…
Browse files Browse the repository at this point in the history
…Infantry

advanced search for mounted infantry
  • Loading branch information
neoancient authored Nov 18, 2023
2 parents 13f90dd + fb150ec commit 69c5351
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2142,6 +2142,7 @@ MechSelectorDialog.Search.FailedToLoadEquipment=Failed to load equipment:
MechSelectorDialog.Search.TechBase=Tech Base:
MechSelectorDialog.Search.Patchwork=Patchwork:
MechSelectorDialog.Search.Industrial=Industrial
MechSelectorDialog.Search.MountedInfantry=Mounted Infantry
MechSelectorDialog.Search.WaterOnly=Water Only
MechSelectorDialog.Search.SupportVehicle=Support Vehicle
MechSelectorDialog.Search.AerospaceFighter=Aerospace Fighter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/MechSearchFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
9 changes: 9 additions & 0 deletions megamek/src/megamek/common/MechSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -337,6 +338,10 @@ public boolean getMilitary() {
return military;
}

public boolean getMountedInfantry() {
return mountedInfantry;
}

public int getTankTurrets() {
return tankTurrets;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions megamek/src/megamek/common/MechSummaryCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 69c5351

Please sign in to comment.