From de6405bdb62467bd2b029ff10ee07170fe87db3c Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sat, 30 Mar 2024 23:59:52 -0500 Subject: [PATCH 1/3] Closes #646 --- .../nagDialogs/UnmaintainedUnitsNagDialog.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java index 458d9348d8..b36a7a6adb 100644 --- a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java @@ -27,6 +27,19 @@ import javax.swing.*; public class UnmaintainedUnitsNagDialog extends AbstractMHQNagDialog { + private boolean checkHanger() { + int countUnmaintained = 0; + + for (Unit u : getCampaign().getHangar().getUnits()) { + if(u.isUnmaintained()) { + if(!u.isSalvage()) { + countUnmaintained += 1; + } + } + } + return countUnmaintained > 0; + } + //region Constructors public UnmaintainedUnitsNagDialog(final JFrame frame, final Campaign campaign) { super(frame, "UnmaintainedUnitsNagDialog", "UnmaintainedUnitsNagDialog.title", @@ -37,6 +50,6 @@ public UnmaintainedUnitsNagDialog(final JFrame frame, final Campaign campaign) { @Override protected boolean checkNag() { return !MekHQ.getMHQOptions().getNagDialogIgnore(getKey()) - && getCampaign().getHangar().getUnitsStream().anyMatch(Unit::isUnmaintained); + && checkHanger(); } } From 83c46b9473a1429f0bc5adfa479ec11cc730f554 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 31 Mar 2024 00:04:13 -0500 Subject: [PATCH 2/3] Refactoring --- .../gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java index b36a7a6adb..73230577ef 100644 --- a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java @@ -28,16 +28,14 @@ public class UnmaintainedUnitsNagDialog extends AbstractMHQNagDialog { private boolean checkHanger() { - int countUnmaintained = 0; - for (Unit u : getCampaign().getHangar().getUnits()) { if(u.isUnmaintained()) { if(!u.isSalvage()) { - countUnmaintained += 1; + return true; } } } - return countUnmaintained > 0; + return false; } //region Constructors From bf3cc5fbed0cdf9cd1002e0668053c2b256f21f5 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Tue, 2 Apr 2024 23:29:57 -0500 Subject: [PATCH 3/3] Requested change --- .../gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java index 73230577ef..37fd808b0a 100644 --- a/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/nagDialogs/UnmaintainedUnitsNagDialog.java @@ -29,10 +29,8 @@ public class UnmaintainedUnitsNagDialog extends AbstractMHQNagDialog { private boolean checkHanger() { for (Unit u : getCampaign().getHangar().getUnits()) { - if(u.isUnmaintained()) { - if(!u.isSalvage()) { + if((u.isUnmaintained()) && (!u.isSalvage())) { return true; - } } } return false;