Skip to content

Commit

Permalink
Merge pull request MegaMek#3937 from IllianiCBT/Medical_Nag
Browse files Browse the repository at this point in the history
Added Nag for Wounded Personnel without Doctor
  • Loading branch information
AaronGullickson authored Apr 3, 2024
2 parents 92c73a0 + b93674c commit 6e651c6
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 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 @@ -289,6 +289,10 @@ UnmaintainedUnitsNagDialog.text=You have unmaintained units. Do you really wish
PrisonersNagDialog.title=Prisoners of War
PrisonersNagDialog.text=You still have prisoners of war. Do you really wish to advance the day?

### UntreatedPersonnelNagDialog Class
UntreatedPersonnelNagDialog.title=Untreated Personnel
UntreatedPersonnelNagDialog.text=You have untreated personnel. 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 @@ -640,6 +644,8 @@ 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.
optionUntreatedPersonnelNag.text=Hide Untreated Personnel Nag
optionUntreatedPersonnelNag.toolTipText=This allows you to ignore the daily warning for when you have wounded personnel that have not been assigned to a doctor.
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 @@ -162,6 +162,7 @@ public final class MHQConstants extends SuiteConstants {
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_UNTREATED_PERSONNEL = "nagUntreatedPersonnel";
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 @@ -2387,6 +2387,11 @@ public void handleDayEnding(DayEndingEvent evt) {
return;
}

if (new UntreatedPersonnelNagDialog(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 @@ -145,6 +145,7 @@ public class MHQOptionsDialog extends AbstractMHQButtonDialog {
//region Nag Tab
private JCheckBox optionUnmaintainedUnitsNag;
private JCheckBox optionPrisonersNag;
private JCheckBox optionUntreatedPersonnelNag;
private JCheckBox optionInsufficientAstechsNag;
private JCheckBox optionInsufficientAstechTimeNag;
private JCheckBox optionInsufficientMedicsNag;
Expand Down Expand Up @@ -847,6 +848,10 @@ private JPanel createNagTab() {
optionPrisonersNag.setToolTipText(resources.getString("optionPrisonersNag.toolTipText"));
optionPrisonersNag.setName("optionPrisonersNag");

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

optionInsufficientAstechsNag = new JCheckBox(resources.getString("optionInsufficientAstechsNag.text"));
optionInsufficientAstechsNag.setToolTipText(resources.getString("optionInsufficientAstechsNag.toolTipText"));
optionInsufficientAstechsNag.setName("optionInsufficientAstechsNag");
Expand Down Expand Up @@ -883,6 +888,7 @@ private JPanel createNagTab() {
layout.createSequentialGroup()
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPrisonersNag)
.addComponent(optionUntreatedPersonnelNag)
.addComponent(optionInsufficientAstechsNag)
.addComponent(optionInsufficientAstechTimeNag)
.addComponent(optionInsufficientMedicsNag)
Expand All @@ -895,6 +901,7 @@ private JPanel createNagTab() {
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(optionUnmaintainedUnitsNag)
.addComponent(optionPrisonersNag)
.addComponent(optionUntreatedPersonnelNag)
.addComponent(optionInsufficientAstechsNag)
.addComponent(optionInsufficientAstechTimeNag)
.addComponent(optionInsufficientMedicsNag)
Expand Down Expand Up @@ -1148,6 +1155,7 @@ protected void okAction() {

MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS, optionUnmaintainedUnitsNag.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());
MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME, optionInsufficientAstechTimeNag.isSelected());
MekHQ.getMHQOptions().setNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS, optionInsufficientMedicsNag.isSelected());
Expand Down Expand Up @@ -1257,6 +1265,7 @@ private void setInitialState() {

optionUnmaintainedUnitsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_UNMAINTAINED_UNITS));
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));
optionInsufficientAstechTimeNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_ASTECH_TIME));
optionInsufficientMedicsNag.setSelected(MekHQ.getMHQOptions().getNagDialogIgnore(MHQConstants.NAG_INSUFFICIENT_MEDICS));
Expand Down
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 UntreatedPersonnelNagDialog extends AbstractMHQNagDialog {
private static boolean isUntreatedInjury (Campaign campaign) {
for (Person p : campaign.getActivePersonnel()) {
if((p.needsFixing()) && (p.getDoctorId() == null)) {
return true;
}
}
return false;
}

//region Constructors
public UntreatedPersonnelNagDialog(final JFrame frame, final Campaign campaign) {
super(frame, "UntreatedPersonnelNagDialog", "UntreatedPersonnelNagDialog.title",
"UntreatedPersonnelNagDialog.text", campaign, MHQConstants.NAG_UNTREATED_PERSONNEL);
}
//endregion Constructors

@Override
protected boolean checkNag() {
return !MekHQ.getMHQOptions().getNagDialogIgnore(getKey())
&& isUntreatedInjury(getCampaign());
}
}
3 changes: 0 additions & 3 deletions MekHQ/userdata/data/universe/ranks.xml

This file was deleted.

0 comments on commit 6e651c6

Please sign in to comment.