Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Nag Dialog for Prisoners of War Outside of Contracts #3942

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?

### PrisonersNagDialog Class
PrisonersNagDialog.title=Prisoners of War
PrisonersNagDialog.text=You still have prisoners of war. 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?
Expand Down Expand Up @@ -634,6 +638,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.
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.
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
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_PRISONERS = "nagPrisoners";
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";
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 @@ -2371,6 +2371,11 @@ public void handleDayEnding(DayEndingEvent evt) {
return;
}

if (new PrisonersNagDialog(getFrame(), getCampaign()).showDialog().isCancelled()) {
evt.cancel();
return;
}

if (new InsufficientAstechsNagDialog(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 optionPrisonersNag;
private JCheckBox optionInsufficientAstechsNag;
private JCheckBox optionInsufficientAstechTimeNag;
private JCheckBox optionInsufficientMedicsNag;
Expand Down Expand Up @@ -842,6 +843,10 @@ private JPanel createNagTab() {
optionUnmaintainedUnitsNag.setToolTipText(resources.getString("optionUnmaintainedUnitsNag.toolTipText"));
optionUnmaintainedUnitsNag.setName("optionUnmaintainedUnitsNag");

optionPrisonersNag = new JCheckBox(resources.getString("optionPrisonersNag.text"));
optionPrisonersNag.setToolTipText(resources.getString("optionPrisonersNag.toolTipText"));
optionPrisonersNag.setName("optionPrisonersNag");

optionInsufficientAstechsNag = new JCheckBox(resources.getString("optionInsufficientAstechsNag.text"));
optionInsufficientAstechsNag.setToolTipText(resources.getString("optionInsufficientAstechsNag.toolTipText"));
optionInsufficientAstechsNag.setName("optionInsufficientAstechsNag");
Expand Down Expand Up @@ -877,6 +882,7 @@ private JPanel createNagTab() {
layout.setVerticalGroup(
layout.createSequentialGroup()
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPrisonersNag)
.addComponent(optionInsufficientAstechsNag)
.addComponent(optionInsufficientAstechTimeNag)
.addComponent(optionInsufficientMedicsNag)
Expand All @@ -888,6 +894,7 @@ private JPanel createNagTab() {
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPrisonersNag)
.addComponent(optionInsufficientAstechsNag)
.addComponent(optionInsufficientAstechTimeNag)
.addComponent(optionInsufficientMedicsNag)
Expand Down Expand Up @@ -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_PRISONERS, optionPrisonersNag.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());
Expand Down Expand Up @@ -1248,6 +1256,7 @@ private void setInitialState() {
optionSaveMothballState.setSelected(MekHQ.getMHQOptions().getSaveMothballState());

optionUnmaintainedUnitsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS));
optionPrisonersNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_PRISONERS));
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));
Expand Down
51 changes: 51 additions & 0 deletions MekHQ/src/mekhq/gui/dialog/nagDialogs/PrisonersNagDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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 PrisonersNagDialog extends AbstractMHQNagDialog {
private static boolean hasPrisoners (Campaign campaign) {
if (!campaign.hasActiveContract()) {
for (Person p : campaign.getActivePersonnel()) {
if (p.getPrisonerStatus().isCurrentPrisoner()) {
return true;
}
}
}
return false;
}
//region Constructors
public PrisonersNagDialog(final JFrame frame, final Campaign campaign) {
super(frame, "PrisonersNagDialog", "PrisonersNagDialog.title",
"PrisonersNagDialog.text", campaign, MHQConstants.NAG_PRISONERS);
}

//endregion Constructors
@Override
protected boolean checkNag() {
return !MekHQ.getMHQOptions().getNagDialogIgnore(getKey()) && hasPrisoners(getCampaign());
}
}
Loading