Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filters invalid and Failed to load equipment #4190

Merged
merged 2 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,8 @@ MechSelectorDialog.Search.Military=Military:
MechSelectorDialog.Search.TankTurrets=Tank Turrets:
MechSelectorDialog.Search.LowerArms=Lower Arms:
MechSelectorDialog.Search.Hands=Hands:
MechSelectorDialog.Search.Invalid=Invalid:
MechSelectorDialog.Search.FailedToLoadEquipment=Failed to load equipment:

#Mechview (Lobby, MHQ, Etc)
MechView.ActiveFighters=Active Fighters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public class TWAdvancedSearchPanel extends JPanel implements ActionListener, Ite
private JComboBox<String> cOfficial = new JComboBox<>();
private JLabel lblCanon = new JLabel(Messages.getString("MechSelectorDialog.Search.Canon"));
private JComboBox<String> cCanon = new JComboBox<>();
private JLabel lblInvalid = new JLabel(Messages.getString("MechSelectorDialog.Search.Invalid"));
private JComboBox<String> cInvalid = new JComboBox<>();
private JLabel lblFailedToLoadEquipment = new JLabel(Messages.getString("MechSelectorDialog.Search.FailedToLoadEquipment"));
private JComboBox<String> cFailedToLoadEquipment = new JComboBox<>();
private JLabel lblClanEngine = new JLabel(Messages.getString("MechSelectorDialog.Search.ClanEngine"));
private JComboBox<String> cClanEngine = new JComboBox<>();
private JLabel lblTableFilters = new JLabel(Messages.getString("MechSelectorDialog.Search.TableFilters"));
Expand Down Expand Up @@ -434,6 +438,8 @@ private JPanel createBasePanel() {
loadYesNo(cOfficial);
loadYesNo(cCanon);
loadYesNo(cClanEngine);
loadYesNo(cInvalid);
loadYesNo(cFailedToLoadEquipment);

loadTriStateItem(EquipmentType.armorNames, listArmorType, 7);
loadTriStateItem(Mech.COCKPIT_STRING, listCockpitType, 7);
Expand Down Expand Up @@ -478,26 +484,12 @@ private JPanel createBasePanel() {
basePanel.add(p1Panel, c);
c.gridx = 1;
JPanel p1bPanel = new JPanel();
p1bPanel.add(lblTankTurrets);
p1bPanel.add(tStartTankTurrets);
p1bPanel.add(new JLabel("-"));
p1bPanel.add(tEndTankTurrets);
p1bPanel.add(lblInvalid);
p1bPanel.add(cInvalid);
p1bPanel.add(lblFailedToLoadEquipment);
p1bPanel.add(cFailedToLoadEquipment);
basePanel.add(p1bPanel, c);
c.gridx = 0; c.gridy++;
JPanel lowerArmsPanel = new JPanel();
lowerArmsPanel.add(lblLowerArms);
lowerArmsPanel.add(tStartLowerArms);
lowerArmsPanel.add(new JLabel("-"));
lowerArmsPanel.add(tEndLowerArms);
basePanel.add(lowerArmsPanel, c);
c.gridx = 1;
JPanel handsPanel = new JPanel();
handsPanel.add(lblHands);
handsPanel.add(tStartHands);
handsPanel.add(new JLabel("-"));
handsPanel.add(tEndHands);
basePanel.add(handsPanel, c);
c.gridx = 0; c.gridy++;
JPanel yearPanel = new JPanel();
yearPanel.add(lblYear);
yearPanel.add(tStartYear);
Expand Down Expand Up @@ -537,6 +529,27 @@ private JPanel createBasePanel() {
jumpPanel.add(new JLabel("-"));
jumpPanel.add(tEndJump);
basePanel.add(jumpPanel, c);
c.gridx = 0; c.gridy++;
JPanel lowerArmsPanel = new JPanel();
lowerArmsPanel.add(lblLowerArms);
lowerArmsPanel.add(tStartLowerArms);
lowerArmsPanel.add(new JLabel("-"));
lowerArmsPanel.add(tEndLowerArms);
basePanel.add(lowerArmsPanel, c);
c.gridx = 1;
JPanel handsPanel = new JPanel();
handsPanel.add(lblHands);
handsPanel.add(tStartHands);
handsPanel.add(new JLabel("-"));
handsPanel.add(tEndHands);
basePanel.add(handsPanel, c);
c.gridx = 0; c.gridy++;
JPanel p2Panel = new JPanel();
p2Panel.add(lblTankTurrets);
p2Panel.add(tStartTankTurrets);
p2Panel.add(new JLabel("-"));
p2Panel.add(tEndTankTurrets);
basePanel.add(p2Panel, c);

c.gridx = 0; c.gridy++;;
c.gridwidth = 1;
Expand Down Expand Up @@ -1761,6 +1774,8 @@ private void clearBase() {
cArmor.setSelectedIndex(0);
cOfficial.setSelectedIndex(0);
cCanon.setSelectedIndex(0);
cInvalid.setSelectedIndex(0);
cFailedToLoadEquipment.setSelectedIndex(0);
cClanEngine.setSelectedIndex(0);
cOmni.setSelectedIndex(0);
cMilitary.setSelectedIndex(0);
Expand Down Expand Up @@ -1992,6 +2007,8 @@ private void updateBase() {

mechFilter.iOfficial = cOfficial.getSelectedIndex();
mechFilter.iCanon = cCanon.getSelectedIndex();
mechFilter.iInvalid = cInvalid.getSelectedIndex();
mechFilter.iFailedToLoadEquipment = cFailedToLoadEquipment.getSelectedIndex();
mechFilter.iClanEngine = cClanEngine.getSelectedIndex();

mechFilter.source = tSource.getText();
Expand Down
11 changes: 10 additions & 1 deletion megamek/src/megamek/common/MechSearchFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ public enum BoolOp { AND, OR, NOP }
public int iClanEngine;
public int iOfficial;
public int iCanon;

public String source;
public int iInvalid;
public int iFailedToLoadEquipment;
public String sStartTroopSpace;
public String sEndTroopSpace;
public String sStartASFBays;
Expand Down Expand Up @@ -433,6 +434,14 @@ public static boolean isMatch(MechSummary mech, MechSearchFilter f) {
return false;
}

if (!isMatch(f.iInvalid, mech.getInvalid())) {
return false;
}

if (!isMatch(f.iFailedToLoadEquipment, mech.getFailedToLoadEquipment())) {
return false;
}

if (!isMatch(f.iOmni, mech.getOmni())) {
return false;
}
Expand Down
18 changes: 18 additions & 0 deletions megamek/src/megamek/common/MechSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class MechSummary implements Serializable, ASCardDisplayable {
private int tankTurrets;
private File sourceFile;
private String source;
private boolean invalid;
private boolean failedToLoadEquipment;
private String entryName; // for files in zips
private int year;
private int type;
Expand Down Expand Up @@ -241,6 +243,14 @@ public File getSourceFile() {
return sourceFile;
}

public boolean getInvalid() {
return invalid;
}

public boolean getFailedToLoadEquipment() {
return failedToLoadEquipment;
}

public String getSource() {
return source;
}
Expand Down Expand Up @@ -781,6 +791,14 @@ public void setSourceFile(File sSourceFile) {
this.sourceFile = sSourceFile;
}

public void setInvalid(boolean b) {
this.invalid = b;
}

public void setFailedToLoadEquipment(boolean b) {
this.failedToLoadEquipment = b;
}

public void setSource(String sSource) {
this.source = sSource;
}
Expand Down
5 changes: 5 additions & 0 deletions megamek/src/megamek/common/MechSummaryCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,13 @@ private MechSummary getSummary(Entity e, File f, String entry) {
if (testEntity != null &&
!testEntity.correctEntity(new StringBuffer())) {
ms.setLevel("F");
ms.setInvalid(true);
} else {
ms.setInvalid(false);
}

ms.setFailedToLoadEquipment(e.getFailedEquipment().hasNext());

ms.setGyroType(e.getGyroType());
if (e.hasEngine()) {
ms.setEngineName(e.getEngine().getEngineName());
Expand Down