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 Option To Reset Temporary Prisoner Capacity #6570

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ lblPrisonersPanel.text=Prisoners
lblPrisonerCaptureStyle.text=Capture Style \u2728
lblPrisonerCaptureStyle.tooltip=This is the ruleset to use when determining if a person has been\
\ captured by the force following a scenario.
lblResetTemporaryPrisonerCapacity.text=Reset Prisoner Capacity Reductions \uD83C\uDF1F
lblResetTemporaryPrisonerCapacity.tooltip=This option removes any penalties to Prisoner Capacity that might have been\
\ added by Prisoner Events.
# createDependentsPanel
lblDependentsPanel.text=Dependents
lblUseRandomDependentAddition.text=Random Addition
Expand Down
6 changes: 1 addition & 5 deletions MekHQ/src/mekhq/gui/campaignOptions/CampaignOptionsPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.COMBAT_ABILITY;
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.MANEUVERING_ABILITY;
import static mekhq.gui.campaignOptions.CampaignOptionsAbilityInfo.AbilityCategory.UTILITY_ABILITY;
import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_GUNNERY;
import static mekhq.campaign.personnel.skills.enums.SkillSubType.COMBAT_PILOTING;
import static mekhq.campaign.personnel.skills.enums.SkillSubType.ROLEPLAY_GENERAL;
import static mekhq.campaign.personnel.skills.enums.SkillSubType.SUPPORT;
import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.ABRIDGED;
import static mekhq.gui.campaignOptions.CampaignOptionsDialog.CampaignOptionsDialogMode.STARTUP_ABRIDGED;
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createSubTabs;
Expand Down Expand Up @@ -484,7 +480,7 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignPreset preset, bool
generalTab.applyCampaignOptionsToCampaign(options, isStartUp, isSaveAction);

// Human Resources
personnelTab.applyCampaignOptionsToCampaign(options);
personnelTab.applyCampaignOptionsToCampaign(campaign, options);
biographyTab.applyCampaignOptionsToCampaign(options);
relationshipsTab.applyCampaignOptionsToCampaign(options);
turnoverAndRetentionTab.applyCampaignOptionsToCampaign(options);
Expand Down
22 changes: 18 additions & 4 deletions MekHQ/src/mekhq/gui/campaignOptions/contents/PersonnelTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package mekhq.gui.campaignOptions.contents;

import static megamek.client.ui.WrapLayout.wordWrap;
import static mekhq.campaign.randomEvents.prisoners.PrisonerEventManager.DEFAULT_TEMPORARY_CAPACITY;
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createGroupLayout;
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.createParentPanel;
import static mekhq.gui.campaignOptions.CampaignOptionsUtilities.getImageDirectory;
Expand All @@ -49,8 +50,8 @@
import megamek.client.ui.swing.util.UIUtil;
import megamek.common.annotations.Nullable;
import megamek.common.enums.SkillLevel;
import mekhq.campaign.Campaign;
import mekhq.campaign.CampaignOptions;
import mekhq.campaign.personnel.skills.Skills;
import mekhq.campaign.personnel.enums.AwardBonus;
import mekhq.campaign.personnel.enums.PersonnelRole;
import mekhq.campaign.personnel.enums.TimeInDisplayFormat;
Expand Down Expand Up @@ -195,6 +196,7 @@ public class PersonnelTab {
private JPanel prisonerPanel;
private JLabel lblPrisonerCaptureStyle;
private MMComboBox<PrisonerCaptureStyle> comboPrisonerCaptureStyle;
private JCheckBox chkResetTemporaryPrisonerCapacity;

private JPanel dependentsPanel;
private JCheckBox chkUseRandomDependentAddition;
Expand Down Expand Up @@ -276,6 +278,7 @@ private void initializePrisonersAndDependentsTab() {
prisonerPanel = new JPanel();
lblPrisonerCaptureStyle = new JLabel();
comboPrisonerCaptureStyle = new MMComboBox<>("comboPrisonerCaptureStyle", PrisonerCaptureStyle.values());
chkResetTemporaryPrisonerCapacity = new JCheckBox();

dependentsPanel = new JPanel();
chkUseRandomDependentAddition = new JCheckBox();
Expand Down Expand Up @@ -673,7 +676,7 @@ JPanel createAwardsGeneralOptionsPanel() {
comboAwardBonusStyle.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index,
final boolean isSelected, final boolean cellHasFocus) {
final boolean isSelected, final boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof AwardBonus) {
list.setToolTipText(((AwardBonus) value).getToolTipText());
Expand Down Expand Up @@ -1054,7 +1057,7 @@ private JPanel createPrisonersPanel() {
comboPrisonerCaptureStyle.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(final JList<?> list, final Object value, final int index,
final boolean isSelected, final boolean cellHasFocus) {
final boolean isSelected, final boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof PrisonerCaptureStyle) {
list.setToolTipText(wordWrap(((PrisonerCaptureStyle) value).getTooltip()));
Expand All @@ -1063,6 +1066,8 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
}
});

chkResetTemporaryPrisonerCapacity = new CampaignOptionsCheckBox("ResetTemporaryPrisonerCapacity");

// Layout the Panel
final JPanel panel = new CampaignOptionsStandardPanel("PrisonersPanel", true, "PrisonersPanel");
final GridBagConstraints layout = new CampaignOptionsGridBagConstraints(panel);
Expand All @@ -1074,6 +1079,11 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
layout.gridx++;
panel.add(comboPrisonerCaptureStyle, layout);

layout.gridy++;
layout.gridx = 0;
layout.gridwidth = 2;
panel.add(chkResetTemporaryPrisonerCapacity, layout);

return panel;
}

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

// Prisoners and Dependents
options.setPrisonerCaptureStyle(comboPrisonerCaptureStyle.getSelectedItem());
if (chkResetTemporaryPrisonerCapacity.isSelected()) {
campaign.setTemporaryPrisonerCapacity(DEFAULT_TEMPORARY_CAPACITY);
}
options.setUseRandomDependentAddition(chkUseRandomDependentAddition.isSelected());
options.setUseRandomDependentRemoval(chkUseRandomDependentRemoval.isSelected());

Expand Down
Loading