Skip to content

Commit ecec7a4

Browse files
authored
Merge pull request #6570 from IllianiBird/prisonerCapacityReset
Added Option To Reset Temporary Prisoner Capacity
2 parents 8c89ac6 + 27be72f commit ecec7a4

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties

+3
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,9 @@ lblPrisonersPanel.text=Prisoners
555555
lblPrisonerCaptureStyle.text=Capture Style \u2728
556556
lblPrisonerCaptureStyle.tooltip=This is the ruleset to use when determining if a person has been\
557557
\ captured by the force following a scenario.
558+
lblResetTemporaryPrisonerCapacity.text=Reset Prisoner Capacity Reductions \uD83C\uDF1F
559+
lblResetTemporaryPrisonerCapacity.tooltip=This option removes any penalties to Prisoner Capacity that might have been\
560+
\ added by Prisoner Events.
558561
# createDependentsPanel
559562
lblDependentsPanel.text=Dependents
560563
lblUseRandomDependentAddition.text=Random Addition

MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY;
3939
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.MANEUVERING_ABILITY;
4040
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.UTILITY_ABILITY;
41-
import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY;
42-
import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_PILOTING;
43-
import static mekhq.campaign.personnel.skills.enums.SkillSubType.ROLEPLAY_GENERAL;
44-
import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT;
4541
import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.ABRIDGED;
4642
import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP_ABRIDGED;
4743
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createSubTabs;
@@ -484,7 +480,7 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset, bool
484480
generalTab.applyCampaignOptionsToCampaign(options, isStartUp, isSaveAction);
485481

486482
// Human Resources
487-
personnelTab.applyCampaignOptionsToCampaign(options);
483+
personnelTab.applyCampaignOptionsToCampaign(campaign, options);
488484
biographyTab.applyCampaignOptionsToCampaign(options);
489485
relationshipsTab.applyCampaignOptionsToCampaign(options);
490486
turnoverAndRetentionTab.applyCampaignOptionsToCampaign(options);

MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
package mekhq.gui.campaignOptions.contents;
2929

3030
import static megamek.client.ui.WrapLayout.wordWrap;
31+
import static mekhq.campaign.randomEvents.prisoners.PrisonerEventManager.DEFAULT_TEMPORARY_CAPACITY;
3132
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createGroupLayout;
3233
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel;
3334
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory;
@@ -49,8 +50,8 @@
4950
import megamek.client.ui.swing.util.UIUtil;
5051
import megamek.common.annotations.Nullable;
5152
import megamek.common.enums.SkillLevel;
53+
import mekhq.campaign.Campaign;
5254
import mekhq.campaign.CampaignOptions;
53-
import mekhq.campaign.personnel.skills.Skills;
5455
import mekhq.campaign.personnel.enums.AwardBonus;
5556
import mekhq.campaign.personnel.enums.PersonnelRole;
5657
import mekhq.campaign.personnel.enums.TimeInDisplayFormat;
@@ -195,6 +196,7 @@ public class PersonnelTab {
195196
private JPanel prisonerPanel;
196197
private JLabel lblPrisonerCaptureStyle;
197198
private MMComboBox<PrisonerCaptureStyle> comboPrisonerCaptureStyle;
199+
private JCheckBox chkResetTemporaryPrisonerCapacity;
198200

199201
private JPanel dependentsPanel;
200202
private JCheckBox chkUseRandomDependentAddition;
@@ -276,6 +278,7 @@ private void initializePrisonersAndDependentsTab() {
276278
prisonerPanel = new JPanel();
277279
lblPrisonerCaptureStyle = new JLabel();
278280
comboPrisonerCaptureStyle = new MMComboBox<>("comboPrisonerCaptureStyle", PrisonerCaptureStyle.values());
281+
chkResetTemporaryPrisonerCapacity = new JCheckBox();
279282

280283
dependentsPanel = new JPanel();
281284
chkUseRandomDependentAddition = new JCheckBox();
@@ -673,7 +676,7 @@ JPanel createAwardsGeneralOptionsPanel() {
673676
comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() {
674677
@Override
675678
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index,
676-
final boolean isSelected, final boolean cellHasFocus) {
679+
final boolean isSelected, final boolean cellHasFocus) {
677680
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
678681
if (value instanceof AwardBonus) {
679682
list.setToolTipText(((AwardBonus) value).getToolTipText());
@@ -1054,7 +1057,7 @@ private JPanel createPrisonersPanel() {
10541057
comboPrisonerCaptureStyle.setRenderer(new DefaultListCellRenderer() {
10551058
@Override
10561059
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index,
1057-
final boolean isSelected, final boolean cellHasFocus) {
1060+
final boolean isSelected, final boolean cellHasFocus) {
10581061
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
10591062
if (value instanceof PrisonerCaptureStyle) {
10601063
list.setToolTipText(wordWrap(((PrisonerCaptureStyle) value).getTooltip()));
@@ -1063,6 +1066,8 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
10631066
}
10641067
});
10651068

1069+
chkResetTemporaryPrisonerCapacity = new CampaignOptionsCheckBox("ResetTemporaryPrisonerCapacity");
1070+
10661071
// Layout the Panel
10671072
final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, "PrisonersPanel");
10681073
final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel);
@@ -1074,6 +1079,11 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
10741079
layout.gridx++;
10751080
panel.add(comboPrisonerCaptureStyle, layout);
10761081

1082+
layout.gridy++;
1083+
layout.gridx = 0;
1084+
layout.gridwidth = 2;
1085+
panel.add(chkResetTemporaryPrisonerCapacity, layout);
1086+
10771087
return panel;
10781088
}
10791089

@@ -1455,9 +1465,10 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai
14551465
* Applies the modified personnel tab settings to the repository's campaign options. If no preset
14561466
* {@link CampaignOptions} is provided, the changes are applied to the current options.
14571467
*
1468+
* @param campaign the {@link Campaign} object, representing the current campaign state.
14581469
* @param presetCampaignOptions optional custom {@link CampaignOptions} to apply changes to.
14591470
*/
1460-
public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampaignOptions) {
1471+
public void applyCampaignOptionsToCampaign(Campaign campaign, @Nullable CampaignOptions presetCampaignOptions) {
14611472
CampaignOptions options = presetCampaignOptions;
14621473
if (presetCampaignOptions == null) {
14631474
options = this.campaignOptions;
@@ -1534,6 +1545,9 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampa
15341545

15351546
// Prisoners and Dependents
15361547
options.setPrisonerCaptureStyle(comboPrisonerCaptureStyle.getSelectedItem());
1548+
if (chkResetTemporaryPrisonerCapacity.isSelected()) {
1549+
campaign.setTemporaryPrisonerCapacity(DEFAULT_TEMPORARY_CAPACITY);
1550+
}
15371551
options.setUseRandomDependentAddition(chkUseRandomDependentAddition.isSelected());
15381552
options.setUseRandomDependentRemoval(chkUseRandomDependentRemoval.isSelected());
15391553

0 commit comments

Comments
 (0)