Skip to content

Commit

Permalink
Merge pull request #3944 from IllianiCBT/Nag_Pregnant
Browse files Browse the repository at this point in the history
Added Nag Dialog for Pregnant Combatants
  • Loading branch information
HammerGS authored Apr 6, 2024
2 parents fc618f5 + eca200a commit e3ac419
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MekHQ/resources/mekhq/resources/GUI.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions MekHQ/src/mekhq/MHQConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
5 changes: 5 additions & 0 deletions MekHQ/src/mekhq/gui/CampaignGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -887,6 +892,7 @@ private JPanel createNagTab() {
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPregnantCombatantNag)
.addComponent(optionPrisonersNag)
.addComponent(optionUntreatedPersonnelNag)
.addComponent(optionInsufficientAstechsNag)
Expand All @@ -900,6 +906,7 @@ private JPanel createNagTab() {
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPregnantCombatantNag)
.addComponent(optionPrisonersNag)
.addComponent(optionUntreatedPersonnelNag)
.addComponent(optionInsufficientAstechsNag)
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
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());
}
}

0 comments on commit e3ac419

Please sign in to comment.