28
28
package mekhq .gui .campaignOptions .contents ;
29
29
30
30
import static megamek .client .ui .WrapLayout .wordWrap ;
31
+ import static mekhq .campaign .randomEvents .prisoners .PrisonerEventManager .DEFAULT_TEMPORARY_CAPACITY ;
31
32
import static mekhq .gui .campaignOptions .CampaignOptionsUtilities .createGroupLayout ;
32
33
import static mekhq .gui .campaignOptions .CampaignOptionsUtilities .createParentPanel ;
33
34
import static mekhq .gui .campaignOptions .CampaignOptionsUtilities .getImageDirectory ;
49
50
import megamek .client .ui .swing .util .UIUtil ;
50
51
import megamek .common .annotations .Nullable ;
51
52
import megamek .common .enums .SkillLevel ;
53
+ import mekhq .campaign .Campaign ;
52
54
import mekhq .campaign .CampaignOptions ;
53
- import mekhq .campaign .personnel .skills .Skills ;
54
55
import mekhq .campaign .personnel .enums .AwardBonus ;
55
56
import mekhq .campaign .personnel .enums .PersonnelRole ;
56
57
import mekhq .campaign .personnel .enums .TimeInDisplayFormat ;
@@ -195,6 +196,7 @@ public class PersonnelTab {
195
196
private JPanel prisonerPanel ;
196
197
private JLabel lblPrisonerCaptureStyle ;
197
198
private MMComboBox <PrisonerCaptureStyle > comboPrisonerCaptureStyle ;
199
+ private JCheckBox chkResetTemporaryPrisonerCapacity ;
198
200
199
201
private JPanel dependentsPanel ;
200
202
private JCheckBox chkUseRandomDependentAddition ;
@@ -276,6 +278,7 @@ private void initializePrisonersAndDependentsTab() {
276
278
prisonerPanel = new JPanel ();
277
279
lblPrisonerCaptureStyle = new JLabel ();
278
280
comboPrisonerCaptureStyle = new MMComboBox <>("comboPrisonerCaptureStyle" , PrisonerCaptureStyle .values ());
281
+ chkResetTemporaryPrisonerCapacity = new JCheckBox ();
279
282
280
283
dependentsPanel = new JPanel ();
281
284
chkUseRandomDependentAddition = new JCheckBox ();
@@ -673,7 +676,7 @@ JPanel createAwardsGeneralOptionsPanel() {
673
676
comboAwardBonusStyle .setRenderer (new DefaultListCellRenderer () {
674
677
@ Override
675
678
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 ) {
677
680
super .getListCellRendererComponent (list , value , index , isSelected , cellHasFocus );
678
681
if (value instanceof AwardBonus ) {
679
682
list .setToolTipText (((AwardBonus ) value ).getToolTipText ());
@@ -1054,7 +1057,7 @@ private JPanel createPrisonersPanel() {
1054
1057
comboPrisonerCaptureStyle .setRenderer (new DefaultListCellRenderer () {
1055
1058
@ Override
1056
1059
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 ) {
1058
1061
super .getListCellRendererComponent (list , value , index , isSelected , cellHasFocus );
1059
1062
if (value instanceof PrisonerCaptureStyle ) {
1060
1063
list .setToolTipText (wordWrap (((PrisonerCaptureStyle ) value ).getTooltip ()));
@@ -1063,6 +1066,8 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
1063
1066
}
1064
1067
});
1065
1068
1069
+ chkResetTemporaryPrisonerCapacity = new CampaignOptionsCheckBox ("ResetTemporaryPrisonerCapacity" );
1070
+
1066
1071
// Layout the Panel
1067
1072
final JPanel panel = new CampaignOptionsStandardPanel ("PrisonersPanel" , true , "PrisonersPanel" );
1068
1073
final GridBagConstraints layout = new CampaignOptionsGridBagConstraints (panel );
@@ -1074,6 +1079,11 @@ public Component getListCellRendererComponent(final JList<?> list, final Object
1074
1079
layout .gridx ++;
1075
1080
panel .add (comboPrisonerCaptureStyle , layout );
1076
1081
1082
+ layout .gridy ++;
1083
+ layout .gridx = 0 ;
1084
+ layout .gridwidth = 2 ;
1085
+ panel .add (chkResetTemporaryPrisonerCapacity , layout );
1086
+
1077
1087
return panel ;
1078
1088
}
1079
1089
@@ -1455,9 +1465,10 @@ public void loadValuesFromCampaignOptions(@Nullable CampaignOptions presetCampai
1455
1465
* Applies the modified personnel tab settings to the repository's campaign options. If no preset
1456
1466
* {@link CampaignOptions} is provided, the changes are applied to the current options.
1457
1467
*
1468
+ * @param campaign the {@link Campaign} object, representing the current campaign state.
1458
1469
* @param presetCampaignOptions optional custom {@link CampaignOptions} to apply changes to.
1459
1470
*/
1460
- public void applyCampaignOptionsToCampaign (@ Nullable CampaignOptions presetCampaignOptions ) {
1471
+ public void applyCampaignOptionsToCampaign (Campaign campaign , @ Nullable CampaignOptions presetCampaignOptions ) {
1461
1472
CampaignOptions options = presetCampaignOptions ;
1462
1473
if (presetCampaignOptions == null ) {
1463
1474
options = this .campaignOptions ;
@@ -1534,6 +1545,9 @@ public void applyCampaignOptionsToCampaign(@Nullable CampaignOptions presetCampa
1534
1545
1535
1546
// Prisoners and Dependents
1536
1547
options .setPrisonerCaptureStyle (comboPrisonerCaptureStyle .getSelectedItem ());
1548
+ if (chkResetTemporaryPrisonerCapacity .isSelected ()) {
1549
+ campaign .setTemporaryPrisonerCapacity (DEFAULT_TEMPORARY_CAPACITY );
1550
+ }
1537
1551
options .setUseRandomDependentAddition (chkUseRandomDependentAddition .isSelected ());
1538
1552
options .setUseRandomDependentRemoval (chkUseRandomDependentRemoval .isSelected ());
1539
1553
0 commit comments