diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index f182392be0..e50d850482 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -285,6 +285,10 @@ ShortDeploymentNagDialog.text=You have not met the deployment levels required by UnmaintainedUnitsNagDialog.title=Unmaintained Units UnmaintainedUnitsNagDialog.text=You have unmaintained units. Do you really wish to advance the day? +### PregnantCombatantNagDialog Class +PregnantCombatantNagDialog.title=Pregnant Combat Personnel +PregnantCombatantNagDialog.text=You have pregnant personnel assigned to a combat unit. Do you really wish to advance the day? + ### PrisonersNagDialog Class PrisonersNagDialog.title=Prisoners of War PrisonersNagDialog.text=You still have prisoners of war. Do you really wish to advance the day? @@ -642,6 +646,8 @@ optionSaveMothballState.toolTipText=This option allows you to disable saving of nagTab.title=Nag Options optionUnmaintainedUnitsNag.text=Hide Unmaintained Units Nag optionUnmaintainedUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have unmaintained units. +optionPregnantCombatantNag.text=Hide Pregnant Combat Personnel Nag +optionPregnantCombatantNag.toolTipText=This allows you to ignore the daily warning for when you have pregnant combat personnel assigned to a unit. optionPrisonersNag.text=Hide Prisoners of War Nag optionPrisonersNag.toolTipText=This allows you to ignore the daily warning for when you have prisoners of war outside of a contract. optionUntreatedPersonnelNag.text=Hide Untreated Personnel Nag diff --git a/MekHQ/src/mekhq/MHQConstants.java b/MekHQ/src/mekhq/MHQConstants.java index b85d61a8ed..2091cd51ca 100644 --- a/MekHQ/src/mekhq/MHQConstants.java +++ b/MekHQ/src/mekhq/MHQConstants.java @@ -161,6 +161,7 @@ public final class MHQConstants extends SuiteConstants { //region Nag Tab public static final String NAG_NODE = "mekhq/prefs/nags"; public static final String NAG_UNMAINTAINED_UNITS = "nagUnmaintainedUnits"; + public static final String NAG_PREGNANT_COMBATANT = "nagPregnantCombatant"; public static final String NAG_PRISONERS = "nagPrisoners"; public static final String NAG_UNTREATED_PERSONNEL = "nagUntreatedPersonnel"; public static final String NAG_INSUFFICIENT_ASTECHS = "nagInsufficientAstechs"; diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index 82518178ba..7d8cee355a 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -2382,6 +2382,11 @@ public void handleDayEnding(DayEndingEvent evt) { return; } + if (new PregnantCombatantNagDialog(getFrame(), getCampaign()).showDialog().isCancelled()) { + evt.cancel(); + return; + } + if (new PrisonersNagDialog(getFrame(), getCampaign()).showDialog().isCancelled()) { evt.cancel(); return; diff --git a/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java b/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java index e5d42cb3bc..a1141fe806 100644 --- a/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java @@ -144,6 +144,7 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog { //region Nag Tab private JCheckBox optionUnmaintainedUnitsNag; + private JCheckBox optionPregnantCombatantNag; private JCheckBox optionPrisonersNag; private JCheckBox optionUntreatedPersonnelNag; private JCheckBox optionInsufficientAstechsNag; @@ -844,6 +845,10 @@ private JPanel createNagTab() { optionUnmaintainedUnitsNag.setToolTipText(resources.getString("optionUnmaintainedUnitsNag.toolTipText")); optionUnmaintainedUnitsNag.setName("optionUnmaintainedUnitsNag"); + optionPregnantCombatantNag = new JCheckBox(resources.getString("optionPregnantCombatantNag.text")); + optionPregnantCombatantNag.setToolTipText(resources.getString("optionPregnantCombatantNag.toolTipText")); + optionPregnantCombatantNag.setName("optionPregnantCombatantNag"); + optionPrisonersNag = new JCheckBox(resources.getString("optionPrisonersNag.text")); optionPrisonersNag.setToolTipText(resources.getString("optionPrisonersNag.toolTipText")); optionPrisonersNag.setName("optionPrisonersNag"); @@ -887,6 +892,7 @@ private JPanel createNagTab() { layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(optionUnmaintainedUnitsNag) + .addComponent(optionPregnantCombatantNag) .addComponent(optionPrisonersNag) .addComponent(optionUntreatedPersonnelNag) .addComponent(optionInsufficientAstechsNag) @@ -900,6 +906,7 @@ private JPanel createNagTab() { layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(optionUnmaintainedUnitsNag) + .addComponent(optionPregnantCombatantNag) .addComponent(optionPrisonersNag) .addComponent(optionUntreatedPersonnelNag) .addComponent(optionInsufficientAstechsNag) @@ -1154,6 +1161,7 @@ protected void okAction() { MekHQ.getMHQOptions().setSaveMothballState(optionSaveMothballState.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS, optionUnmaintainedUnitsNag.isSelected()); + MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_PREGNANT_COMBATANT, optionPregnantCombatantNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_PRISONERS, optionPrisonersNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_UNTREATED_PERSONNEL, optionUntreatedPersonnelNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS, optionInsufficientAstechsNag.isSelected()); @@ -1264,6 +1272,7 @@ private void setInitialState() { optionSaveMothballState.setSelected(MekHQ.getMHQOptions().getSaveMothballState()); optionUnmaintainedUnitsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS)); + optionPregnantCombatantNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PREGNANT_COMBATANT)); optionPrisonersNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PRISONERS)); optionUntreatedPersonnelNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNTREATED_PERSONNEL)); optionInsufficientAstechsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS)); diff --git a/MekHQ/src/mekhq/gui/dialog/nagDialogs/PregnantCombatantNagDialog.java b/MekHQ/src/mekhq/gui/dialog/nagDialogs/PregnantCombatantNagDialog.java new file mode 100644 index 0000000000..97dd1f2cbf --- /dev/null +++ b/MekHQ/src/mekhq/gui/dialog/nagDialogs/PregnantCombatantNagDialog.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 - The MegaMek Team. All Rights Reserved. + * + * This file is part of MekHQ. + * + * MekHQ is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * MekHQ is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MekHQ. If not, see . + */ +package mekhq.gui.dialog.nagDialogs; + +import mekhq.MHQConstants; +import mekhq.MekHQ; +import mekhq.campaign.Campaign; +import mekhq.campaign.personnel.Person; +import mekhq.gui.baseComponents.AbstractMHQNagDialog; + +import javax.swing.*; + +public class PregnantCombatantNagDialog extends AbstractMHQNagDialog { + private static boolean isPregnantCombatant (Campaign campaign) { + if (campaign.hasActiveContract()) { + for (Person p : campaign.getActivePersonnel()) { + if (p.isPregnant()) { + if (p.hasCombatRole()) { + if(p.getUnit() != null) { + return true; + } + } + } + } + } + return false; + } + //region Constructors + public PregnantCombatantNagDialog(final JFrame frame, final Campaign campaign) { + super(frame, "PregnantCombatantNagDialog", "PregnantCombatantNagDialog.title", + "PregnantCombatantNagDialog.text", campaign, MHQConstants.NAG_PREGNANT_COMBATANT); + } + //endregion Constructors + + @Override + protected boolean checkNag() { + return !MekHQ.getMHQOptions().getNagDialogIgnore(getKey()) + && isPregnantCombatant(getCampaign()); + } +}