From a77d89be6c969d5b1f6b81b51f88ac2dcd233ea0 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke Date: Sat, 18 Feb 2023 11:35:04 -0500 Subject: [PATCH 1/2] add fileters invalid and Failed to load equipment --- .../i18n/megamek/client/messages.properties | 2 + .../unitSelector/TWAdvancedSearchPanel.java | 53 ++++++++++++------- .../src/megamek/common/MechSearchFilter.java | 11 +++- megamek/src/megamek/common/MechSummary.java | 18 +++++++ .../src/megamek/common/MechSummaryCache.java | 5 ++ 5 files changed, 70 insertions(+), 19 deletions(-) diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 62b9e571b8..61791112d0 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -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 diff --git a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java index e8e2e3d150..ffe4cad337 100644 --- a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java @@ -119,6 +119,10 @@ public class TWAdvancedSearchPanel extends JPanel implements ActionListener, Ite private JComboBox cOfficial = new JComboBox<>(); private JLabel lblCanon = new JLabel(Messages.getString("MechSelectorDialog.Search.Canon")); private JComboBox cCanon = new JComboBox<>(); + private JLabel lblInvalid = new JLabel(Messages.getString("MechSelectorDialog.Search.Invalid")); + private JComboBox cInvalid = new JComboBox<>(); + private JLabel lblFailedToLoadEquipment = new JLabel(Messages.getString("MechSelectorDialog.Search.FailedToLoadEquipment")); + private JComboBox cFailedToLoadEquipment= new JComboBox<>(); private JLabel lblClanEngine = new JLabel(Messages.getString("MechSelectorDialog.Search.ClanEngine")); private JComboBox cClanEngine = new JComboBox<>(); private JLabel lblTableFilters = new JLabel(Messages.getString("MechSelectorDialog.Search.TableFilters")); @@ -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); @@ -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); @@ -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; @@ -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); @@ -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(); diff --git a/megamek/src/megamek/common/MechSearchFilter.java b/megamek/src/megamek/common/MechSearchFilter.java index fb00607abd..6f082aa506 100644 --- a/megamek/src/megamek/common/MechSearchFilter.java +++ b/megamek/src/megamek/common/MechSearchFilter.java @@ -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; @@ -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; } diff --git a/megamek/src/megamek/common/MechSummary.java b/megamek/src/megamek/common/MechSummary.java index 0cfff71158..0173554a56 100644 --- a/megamek/src/megamek/common/MechSummary.java +++ b/megamek/src/megamek/common/MechSummary.java @@ -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; @@ -241,6 +243,14 @@ public File getSourceFile() { return sourceFile; } + public boolean getInvalid() { + return invalid; + } + + public boolean getFailedToLoadEquipment() { + return failedToLoadEquipment; + } + public String getSource() { return source; } @@ -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; } diff --git a/megamek/src/megamek/common/MechSummaryCache.java b/megamek/src/megamek/common/MechSummaryCache.java index 244c9edbf6..1fc2bd6317 100644 --- a/megamek/src/megamek/common/MechSummaryCache.java +++ b/megamek/src/megamek/common/MechSummaryCache.java @@ -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()); From 6289a1fa68ffeffc3373d17668728b913c871d00 Mon Sep 17 00:00:00 2001 From: kuronekochomusuke <116095479+kuronekochomusuke@users.noreply.github.com> Date: Sun, 19 Feb 2023 10:07:15 -0500 Subject: [PATCH 2/2] Update megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java Co-authored-by: Justin Bowen <39067288+Windchild292@users.noreply.github.com> --- .../client/ui/swing/unitSelector/TWAdvancedSearchPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java index ffe4cad337..e0333476ca 100644 --- a/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java +++ b/megamek/src/megamek/client/ui/swing/unitSelector/TWAdvancedSearchPanel.java @@ -122,7 +122,7 @@ public class TWAdvancedSearchPanel extends JPanel implements ActionListener, Ite private JLabel lblInvalid = new JLabel(Messages.getString("MechSelectorDialog.Search.Invalid")); private JComboBox cInvalid = new JComboBox<>(); private JLabel lblFailedToLoadEquipment = new JLabel(Messages.getString("MechSelectorDialog.Search.FailedToLoadEquipment")); - private JComboBox cFailedToLoadEquipment= new JComboBox<>(); + private JComboBox cFailedToLoadEquipment = new JComboBox<>(); private JLabel lblClanEngine = new JLabel(Messages.getString("MechSelectorDialog.Search.ClanEngine")); private JComboBox cClanEngine = new JComboBox<>(); private JLabel lblTableFilters = new JLabel(Messages.getString("MechSelectorDialog.Search.TableFilters"));