From 4fc144ac42e229d922e821f0cd93d31bb602c6b3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 31 Mar 2024 10:34:46 -0500 Subject: [PATCH 1/3] Initial commit --- MekHQ/resources/mekhq/resources/GUI.properties | 10 ++++++++-- MekHQ/src/mekhq/MHQConstants.java | 1 + MekHQ/src/mekhq/gui/CampaignGUI.java | 5 +++++ MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java | 9 +++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index 3887fde1ce..d23d72590a 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? +### PregnantToeNagDialog Class +PregnantToeNagDialog.title=Pregnant Combat Personnel +PregnantToeNagDialog.text=You have pregnant personnel in your TOE. Do you really wish to advance the day? + ### UnresolvedStratConContactsNagDialog Class UnresolvedStratConContactsNagDialog.title=Unresolved StratCon Contacts UnresolvedStratConContactsNagDialog.text=You have unresolved contacts on the StratCon interface:\n%s\nAdvance day anyway? @@ -632,8 +636,10 @@ optionSaveMothballState.text=Save Unit State Before Mothballing optionSaveMothballState.toolTipText=This option allows you to disable saving of the unit's crew and force before being mothballed for restoration post-mothball. ## Nag Tab 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. +optionUnmaintainedUnitsNag.text=Hide Pregnant Combat Personnel Nag +optionUnmaintainedUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have pregnant personnel deployed to your TOE. +optionPregnantToeUnitsNag.text=Hide Unmaintained Units Nag +optionPregnantToeUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have unmaintained units. optionInsufficientAstechsNag.text=Hide Insufficient Astechs Nag optionInsufficientAstechsNag.toolTipText=This allows you to ignore the daily warning for when you don't have enough astechs to support your techs. optionInsufficientAstechTimeNag.text=Hide Insufficient Astech Time Nag diff --git a/MekHQ/src/mekhq/MHQConstants.java b/MekHQ/src/mekhq/MHQConstants.java index 9ab4e4bdf9..24b0126f7a 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_TOE = "nagPregnantToe"; public static final String NAG_INSUFFICIENT_ASTECHS = "nagInsufficientAstechs"; public static final String NAG_INSUFFICIENT_ASTECH_TIME = "nagInsufficientAstechTime"; public static final String NAG_INSUFFICIENT_MEDICS = "nagInsufficientMedics"; diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index 0f563482ac..ba57ee6836 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -2371,6 +2371,11 @@ public void handleDayEnding(DayEndingEvent evt) { return; } + if (new PregnantToeNagDialog(getFrame(), getCampaign()).showDialog().isCancelled()) { + evt.cancel(); + return; + } + if (new InsufficientAstechsNagDialog(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 a2d3c006c7..f530682e8c 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 optionPregnantToeNag; private JCheckBox optionInsufficientAstechsNag; private JCheckBox optionInsufficientAstechTimeNag; private JCheckBox optionInsufficientMedicsNag; @@ -842,6 +843,10 @@ private JPanel createNagTab() { optionUnmaintainedUnitsNag.setToolTipText(resources.getString("optionUnmaintainedUnitsNag.toolTipText")); optionUnmaintainedUnitsNag.setName("optionUnmaintainedUnitsNag"); + optionPregnantToeNag = new JCheckBox(resources.getString("optionPregnantToeNag.text")); + optionPregnantToeNag.setToolTipText(resources.getString("optionPregnantToeNag.toolTipText")); + optionPregnantToeNag.setName("optionPregnantToeNag"); + optionInsufficientAstechsNag = new JCheckBox(resources.getString("optionInsufficientAstechsNag.text")); optionInsufficientAstechsNag.setToolTipText(resources.getString("optionInsufficientAstechsNag.toolTipText")); optionInsufficientAstechsNag.setName("optionInsufficientAstechsNag"); @@ -877,6 +882,7 @@ private JPanel createNagTab() { layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(optionUnmaintainedUnitsNag) + .addComponent(optionPregnantToeNag) .addComponent(optionInsufficientAstechsNag) .addComponent(optionInsufficientAstechTimeNag) .addComponent(optionInsufficientMedicsNag) @@ -888,6 +894,7 @@ private JPanel createNagTab() { layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(optionUnmaintainedUnitsNag) + .addComponent(optionPregnantToeNag) .addComponent(optionInsufficientAstechsNag) .addComponent(optionInsufficientAstechTimeNag) .addComponent(optionInsufficientMedicsNag) @@ -1140,6 +1147,7 @@ protected void okAction() { MekHQ.getMHQOptions().setSaveMothballState(optionSaveMothballState.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS, optionUnmaintainedUnitsNag.isSelected()); + MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_PREGNANT_TOE, optionPregnantToeNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS, optionInsufficientAstechsNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME, optionInsufficientAstechTimeNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS, optionInsufficientMedicsNag.isSelected()); @@ -1248,6 +1256,7 @@ private void setInitialState() { optionSaveMothballState.setSelected(MekHQ.getMHQOptions().getSaveMothballState()); optionUnmaintainedUnitsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS)); + optionPregnantToeNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PREGNANT_TOE)); optionInsufficientAstechsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS)); optionInsufficientAstechTimeNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME)); optionInsufficientMedicsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS)); From e3a519ce90500e9f6a54f5ea830c65a3fc1dfb7b Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 31 Mar 2024 14:31:05 -0500 Subject: [PATCH 2/3] Final functionality --- .../resources/mekhq/resources/GUI.properties | 12 ++-- MekHQ/src/mekhq/MHQConstants.java | 2 +- MekHQ/src/mekhq/gui/CampaignGUI.java | 2 +- .../mekhq/gui/dialog/MHQOptionsDialog.java | 16 +++--- .../PregnantCombatantNagDialog.java | 56 +++++++++++++++++++ 5 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 MekHQ/src/mekhq/gui/dialog/nagDialogs/PregnantCombatantNagDialog.java diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index d23d72590a..013f6b6225 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -285,9 +285,9 @@ 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? -### PregnantToeNagDialog Class -PregnantToeNagDialog.title=Pregnant Combat Personnel -PregnantToeNagDialog.text=You have pregnant personnel in your TOE. 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? ### UnresolvedStratConContactsNagDialog Class UnresolvedStratConContactsNagDialog.title=Unresolved StratCon Contacts @@ -637,9 +637,9 @@ optionSaveMothballState.toolTipText=This option allows you to disable saving of ## Nag Tab nagTab.title=Nag Options optionUnmaintainedUnitsNag.text=Hide Pregnant Combat Personnel Nag -optionUnmaintainedUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have pregnant personnel deployed to your TOE. -optionPregnantToeUnitsNag.text=Hide Unmaintained Units Nag -optionPregnantToeUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have unmaintained units. +optionUnmaintainedUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have pregnant combat personnel assigned to a unit. +optionPregnantCombatantNag.text=Hide Unmaintained Units Nag +optionPregnantCombatantNag.toolTipText=This allows you to ignore the daily warning for when you have unmaintained units. optionInsufficientAstechsNag.text=Hide Insufficient Astechs Nag optionInsufficientAstechsNag.toolTipText=This allows you to ignore the daily warning for when you don't have enough astechs to support your techs. optionInsufficientAstechTimeNag.text=Hide Insufficient Astech Time Nag diff --git a/MekHQ/src/mekhq/MHQConstants.java b/MekHQ/src/mekhq/MHQConstants.java index 24b0126f7a..45f63812d4 100644 --- a/MekHQ/src/mekhq/MHQConstants.java +++ b/MekHQ/src/mekhq/MHQConstants.java @@ -161,7 +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_TOE = "nagPregnantToe"; + public static final String NAG_PREGNANT_COMBATANT = "nagPregnantCombatant"; public static final String NAG_INSUFFICIENT_ASTECHS = "nagInsufficientAstechs"; public static final String NAG_INSUFFICIENT_ASTECH_TIME = "nagInsufficientAstechTime"; public static final String NAG_INSUFFICIENT_MEDICS = "nagInsufficientMedics"; diff --git a/MekHQ/src/mekhq/gui/CampaignGUI.java b/MekHQ/src/mekhq/gui/CampaignGUI.java index ba57ee6836..ec07a33dca 100644 --- a/MekHQ/src/mekhq/gui/CampaignGUI.java +++ b/MekHQ/src/mekhq/gui/CampaignGUI.java @@ -2371,7 +2371,7 @@ public void handleDayEnding(DayEndingEvent evt) { return; } - if (new PregnantToeNagDialog(getFrame(), getCampaign()).showDialog().isCancelled()) { + if (new PregnantCombatantNagDialog(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 f530682e8c..43dc9c1272 100644 --- a/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/MHQOptionsDialog.java @@ -144,7 +144,7 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog { //region Nag Tab private JCheckBox optionUnmaintainedUnitsNag; - private JCheckBox optionPregnantToeNag; + private JCheckBox optionPregnantCombatantNag; private JCheckBox optionInsufficientAstechsNag; private JCheckBox optionInsufficientAstechTimeNag; private JCheckBox optionInsufficientMedicsNag; @@ -843,9 +843,9 @@ private JPanel createNagTab() { optionUnmaintainedUnitsNag.setToolTipText(resources.getString("optionUnmaintainedUnitsNag.toolTipText")); optionUnmaintainedUnitsNag.setName("optionUnmaintainedUnitsNag"); - optionPregnantToeNag = new JCheckBox(resources.getString("optionPregnantToeNag.text")); - optionPregnantToeNag.setToolTipText(resources.getString("optionPregnantToeNag.toolTipText")); - optionPregnantToeNag.setName("optionPregnantToeNag"); + optionPregnantCombatantNag = new JCheckBox(resources.getString("optionPregnantCombatantNag.text")); + optionPregnantCombatantNag.setToolTipText(resources.getString("optionPregnantCombatantNag.toolTipText")); + optionPregnantCombatantNag.setName("optionPregnantCombatantNag"); optionInsufficientAstechsNag = new JCheckBox(resources.getString("optionInsufficientAstechsNag.text")); optionInsufficientAstechsNag.setToolTipText(resources.getString("optionInsufficientAstechsNag.toolTipText")); @@ -882,7 +882,7 @@ private JPanel createNagTab() { layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(optionUnmaintainedUnitsNag) - .addComponent(optionPregnantToeNag) + .addComponent(optionPregnantCombatantNag) .addComponent(optionInsufficientAstechsNag) .addComponent(optionInsufficientAstechTimeNag) .addComponent(optionInsufficientMedicsNag) @@ -894,7 +894,7 @@ private JPanel createNagTab() { layout.setHorizontalGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(optionUnmaintainedUnitsNag) - .addComponent(optionPregnantToeNag) + .addComponent(optionPregnantCombatantNag) .addComponent(optionInsufficientAstechsNag) .addComponent(optionInsufficientAstechTimeNag) .addComponent(optionInsufficientMedicsNag) @@ -1147,7 +1147,7 @@ protected void okAction() { MekHQ.getMHQOptions().setSaveMothballState(optionSaveMothballState.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS, optionUnmaintainedUnitsNag.isSelected()); - MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_PREGNANT_TOE, optionPregnantToeNag.isSelected()); + MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_PREGNANT_COMBATANT, optionPregnantCombatantNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS, optionInsufficientAstechsNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME, optionInsufficientAstechTimeNag.isSelected()); MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS, optionInsufficientMedicsNag.isSelected()); @@ -1256,7 +1256,7 @@ private void setInitialState() { optionSaveMothballState.setSelected(MekHQ.getMHQOptions().getSaveMothballState()); optionUnmaintainedUnitsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS)); - optionPregnantToeNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PREGNANT_TOE)); + optionPregnantCombatantNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PREGNANT_COMBATANT)); optionInsufficientAstechsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECHS)); optionInsufficientAstechTimeNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME)); optionInsufficientMedicsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS)); 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()); + } +} From 8a187204e8fda9d7cd5b0b3dfd3f94bd9c5c454a Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Sun, 31 Mar 2024 14:38:52 -0500 Subject: [PATCH 3/3] Fixed dirty edit --- MekHQ/resources/mekhq/resources/GUI.properties | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/GUI.properties b/MekHQ/resources/mekhq/resources/GUI.properties index 013f6b6225..b92b0e51b1 100644 --- a/MekHQ/resources/mekhq/resources/GUI.properties +++ b/MekHQ/resources/mekhq/resources/GUI.properties @@ -636,10 +636,10 @@ optionSaveMothballState.text=Save Unit State Before Mothballing optionSaveMothballState.toolTipText=This option allows you to disable saving of the unit's crew and force before being mothballed for restoration post-mothball. ## Nag Tab nagTab.title=Nag Options -optionUnmaintainedUnitsNag.text=Hide Pregnant Combat Personnel Nag -optionUnmaintainedUnitsNag.toolTipText=This allows you to ignore the daily warning for when you have pregnant combat personnel assigned to a unit. -optionPregnantCombatantNag.text=Hide Unmaintained Units Nag -optionPregnantCombatantNag.toolTipText=This allows you to ignore the daily warning for when you have unmaintained units. +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. optionInsufficientAstechsNag.text=Hide Insufficient Astechs Nag optionInsufficientAstechsNag.toolTipText=This allows you to ignore the daily warning for when you don't have enough astechs to support your techs. optionInsufficientAstechTimeNag.text=Hide Insufficient Astech Time Nag