diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties index 47cb39c573..2d261de318 100644 --- a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties @@ -157,8 +157,10 @@ lblServiceContractDuration.text=Service Contract Duration lblServiceContractDuration.toolTipText=Once recruited, this is the minimum amount of months personnel will remain with the unit (set to 0 to disable service contracts). lblServiceContractModifier.text=Service Contract Modifier lblServiceContractModifier.toolTipText=While personnel are under contract, this value reduces their Turnover target number. -chkPayBonusDefault.text=Enable Default Bonuses -chkPayBonusDefault.toolTipText=Selecting this option defaults Pay Bonus to true in the turnover dialog. Otherwise, Pay Bonus defaults to false. +chkPayBonusDefault.text=Automate Retention Bonuses +chkPayBonusDefault.toolTipText=Personnel with a turnover target number equal (or exceeding) the below threshold will have their retention bonus paid by default. +lblPayBonusDefaultThreshold.text=Bonus Threshold +lblPayBonusDefaultThreshold.toolTipText=This option sets the threshold for default bonus payouts (if the above option is enabled). ## Modifiers turnoverAndRetentionModifiersPanel.title=Modifiers diff --git a/MekHQ/src/mekhq/campaign/CampaignOptions.java b/MekHQ/src/mekhq/campaign/CampaignOptions.java index 4f03995984..1c74e6510b 100644 --- a/MekHQ/src/mekhq/campaign/CampaignOptions.java +++ b/MekHQ/src/mekhq/campaign/CampaignOptions.java @@ -284,6 +284,7 @@ public static String getTransitUnitName(final int unit) { private int serviceContractDuration; private int serviceContractModifier; private boolean payBonusDefault; + private int payBonusDefaultThreshold; private boolean useCustomRetirementModifiers; private boolean useFatigueModifiers; @@ -955,6 +956,7 @@ public CampaignOptions() { setServiceContractDuration(36); setServiceContractModifier(3); setPayBonusDefault(false); + setPayBonusDefaultThreshold(3); setUseCustomRetirementModifiers(true); setUseFatigueModifiers(true); @@ -2089,6 +2091,14 @@ public boolean isPayBonusDefault() { public void setPayBonusDefault(final boolean payBonusDefault) { this.payBonusDefault = payBonusDefault; } + + public int getPayBonusDefaultThreshold() { + return payBonusDefaultThreshold; + } + + public void setPayBonusDefaultThreshold(final int payBonusDefaultThreshold) { + this.payBonusDefaultThreshold = payBonusDefaultThreshold; + } //endregion Retirement //region Family @@ -4584,6 +4594,7 @@ public void writeToXml(final PrintWriter pw, int indent) { MHQXMLUtility.writeSimpleXMLTag(pw, indent, "serviceContractDuration", getServiceContractDuration()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "serviceContractModifier", getServiceContractModifier()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "payBonusDefault", isPayBonusDefault()); + MHQXMLUtility.writeSimpleXMLTag(pw, indent, "payBonusDefaultThreshold", getPayBonusDefaultThreshold()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "useCustomRetirementModifiers", isUseCustomRetirementModifiers()); MHQXMLUtility.writeSimpleXMLTag(pw, indent, "useFatigueModifiers", isUseFatigueModifiers()); @@ -5566,6 +5577,8 @@ public static CampaignOptions generateCampaignOptionsFromXml(Node wn, Version ve retVal.setServiceContractModifier(Integer.parseInt(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("payBonusDefault")) { retVal.setPayBonusDefault(Boolean.parseBoolean(wn2.getTextContent().trim())); + } else if (wn2.getNodeName().equalsIgnoreCase("payBonusDefaultThreshold")) { + retVal.setPayBonusDefaultThreshold(Integer.parseInt(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("useCustomRetirementModifiers")) { retVal.setUseCustomRetirementModifiers(Boolean.parseBoolean(wn2.getTextContent().trim())); } else if (wn2.getNodeName().equalsIgnoreCase("useFatigueModifiers")) { diff --git a/MekHQ/src/mekhq/gui/model/RetirementTableModel.java b/MekHQ/src/mekhq/gui/model/RetirementTableModel.java index 188f11831a..16d41ef0d5 100644 --- a/MekHQ/src/mekhq/gui/model/RetirementTableModel.java +++ b/MekHQ/src/mekhq/gui/model/RetirementTableModel.java @@ -88,9 +88,12 @@ public void setData(List list, Map unitAssignments) { public void setData(Map targets) { this.targets = targets; data.clear(); + for (UUID id : targets.keySet()) { data.add(id); - payBonus.put(id, campaign.getCampaignOptions().isPayBonusDefault()); + payBonus.put(id, + ((campaign.getCampaignOptions().isPayBonusDefault()) + && (targets.get(id).getValue() >= campaign.getCampaignOptions().getPayBonusDefaultThreshold()))); miscMods.put(id, 0); } fireTableDataChanged(); @@ -221,7 +224,7 @@ public Object getValueAt(int row, int col) { return bonusCost; } case COL_PAY_BONUS: - return payBonus.getOrDefault(p.getId(), campaign.getCampaignOptions().isPayBonusDefault()); + return payBonus.getOrDefault(p.getId(), false); case COL_MISC_MOD: return miscMods.getOrDefault(p.getId(), 0); case COL_SHARES: diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java index 0f485fa375..180b460870 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java @@ -283,6 +283,8 @@ public class CampaignOptionsPane extends AbstractMHQTabbedPane { private JLabel lblServiceContractModifier; private JSpinner spnServiceContractModifier; private JCheckBox chkPayBonusDefault; + private JLabel lblPayBonusDefaultThreshold; + private JSpinner spnPayBonusDefaultThreshold; // Modifiers private JPanel turnoverAndRetentionModifiersPanel = new JPanel(); @@ -4437,6 +4439,22 @@ public Component getListCellRendererComponent(final JList list, final Object chkPayBonusDefault.setToolTipText(resources.getString("chkPayBonusDefault.toolTipText")); chkPayBonusDefault.setName("chkPayBonusDefault"); chkPayBonusDefault.setEnabled(isUseTurnover); + chkPayBonusDefault.addActionListener(evt -> { + boolean isEnabled = chkPayBonusDefault.isSelected(); + + lblPayBonusDefaultThreshold.setEnabled(isEnabled); + spnPayBonusDefaultThreshold.setEnabled(isEnabled); + }); + + lblPayBonusDefaultThreshold = new JLabel(resources.getString("lblPayBonusDefaultThreshold.text")); + lblPayBonusDefaultThreshold.setToolTipText(resources.getString("lblPayBonusDefaultThreshold.toolTipText")); + lblPayBonusDefaultThreshold.setName("lblPayBonusDefaultThreshold"); + lblPayBonusDefaultThreshold.setEnabled((isUseTurnover) && (campaign.getCampaignOptions().isPayBonusDefault())); + + spnPayBonusDefaultThreshold = new JSpinner(new SpinnerNumberModel(3, 0, 12, 1)); + spnPayBonusDefaultThreshold.setToolTipText(resources.getString("lblPayBonusDefaultThreshold.toolTipText")); + spnPayBonusDefaultThreshold.setName("spnPayBonusDefaultThreshold"); + spnPayBonusDefaultThreshold.setEnabled((isUseTurnover) && (campaign.getCampaignOptions().isPayBonusDefault())); turnoverAndRetentionSettingsPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("turnoverAndRetentionSettingsPanel.title"))); turnoverAndRetentionSettingsPanel.setName("turnoverAndRetentionSettingsPanel"); @@ -4474,6 +4492,9 @@ public Component getListCellRendererComponent(final JList list, final Object .addComponent(lblServiceContractModifier) .addComponent(spnServiceContractModifier, Alignment.LEADING)) .addComponent(chkPayBonusDefault) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblPayBonusDefaultThreshold) + .addComponent(spnPayBonusDefaultThreshold, Alignment.LEADING)) ); layout.setHorizontalGroup( @@ -4503,6 +4524,9 @@ public Component getListCellRendererComponent(final JList list, final Object .addComponent(lblServiceContractModifier) .addComponent(spnServiceContractModifier)) .addComponent(chkPayBonusDefault) + .addGroup(layout.createSequentialGroup() + .addComponent(lblPayBonusDefaultThreshold) + .addComponent(spnPayBonusDefaultThreshold)) ); return turnoverAndRetentionSettingsPanel; @@ -8010,6 +8034,7 @@ public void setOptions(@Nullable CampaignOptions options, spnServiceContractDuration.setValue(options.getServiceContractDuration()); spnServiceContractModifier.setValue(options.getServiceContractModifier()); chkPayBonusDefault.setSelected(options.isPayBonusDefault()); + spnPayBonusDefaultThreshold.setValue(options.getPayBonusDefaultThreshold()); // Modifiers chkUseCustomRetirementModifiers.setSelected(options.isUseCustomRetirementModifiers()); @@ -8697,6 +8722,7 @@ public void updateOptions() { options.setServiceContractDuration((Integer) spnServiceContractDuration.getValue()); options.setServiceContractModifier((Integer) spnServiceContractModifier.getValue()); options.setPayBonusDefault(chkPayBonusDefault.isSelected()); + options.setPayBonusDefaultThreshold((Integer) spnPayBonusDefaultThreshold.getValue()); // Modifiers options.setUseCustomRetirementModifiers(chkUseCustomRetirementModifiers.isSelected());