From 488c7a5e1bcac1a27e98a8dde7544b321e039ad8 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 12 Jul 2024 20:36:29 -0500 Subject: [PATCH 1/3] Updated bonus payout logic and added a threshold setting The logic for bonus payout in the RetirementTableModel was updated to consider whether the turnover target number meets a given threshold. A new field for setting this threshold was added in the CampaignOptions class and its related GUI components. --- .../CampaignOptionsDialog.properties | 6 ++-- MekHQ/src/mekhq/campaign/CampaignOptions.java | 13 ++++++++ .../mekhq/gui/model/RetirementTableModel.java | 7 ++-- .../mekhq/gui/panes/CampaignOptionsPane.java | 32 +++++++++++++++---- 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties index f8d89ddd9f..602e13129b 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=Pay Bonuses by Default +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 5483fababb..166fc19447 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(); @@ -244,7 +247,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..b7c340965d 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"); @@ -4458,9 +4476,6 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblTurnoverFixedTargetNumber) .addComponent(spnTurnoverFixedTargetNumber, Alignment.LEADING)) - .addGroup(layout.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTurnoverFrequency) - .addComponent(comboTurnoverFrequency, Alignment.LEADING)) .addComponent(chkUseContractCompletionRandomRetirement) .addComponent(chkUseRandomFounderTurnover) .addComponent(chkUseFounderRetirement) @@ -4474,6 +4489,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( @@ -4487,9 +4505,6 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblTurnoverFixedTargetNumber) .addComponent(spnTurnoverFixedTargetNumber)) - .addGroup(layout.createSequentialGroup() - .addComponent(lblTurnoverFrequency) - .addComponent(comboTurnoverFrequency)) .addComponent(chkUseContractCompletionRandomRetirement) .addComponent(chkUseRandomFounderTurnover) .addComponent(chkUseFounderRetirement) @@ -4503,6 +4518,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 +8028,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 +8716,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()); From 62ed9714332e224e5b9660a645654f5263eff6d3 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 12 Jul 2024 20:43:17 -0500 Subject: [PATCH 2/3] Restored turnover frequency to CampaignOptionsPane --- MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java index b7c340965d..180b460870 100644 --- a/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java +++ b/MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java @@ -4476,6 +4476,9 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createParallelGroup(Alignment.BASELINE) .addComponent(lblTurnoverFixedTargetNumber) .addComponent(spnTurnoverFixedTargetNumber, Alignment.LEADING)) + .addGroup(layout.createParallelGroup(Alignment.BASELINE) + .addComponent(lblTurnoverFrequency) + .addComponent(comboTurnoverFrequency, Alignment.LEADING)) .addComponent(chkUseContractCompletionRandomRetirement) .addComponent(chkUseRandomFounderTurnover) .addComponent(chkUseFounderRetirement) @@ -4505,6 +4508,9 @@ public Component getListCellRendererComponent(final JList list, final Object .addGroup(layout.createSequentialGroup() .addComponent(lblTurnoverFixedTargetNumber) .addComponent(spnTurnoverFixedTargetNumber)) + .addGroup(layout.createSequentialGroup() + .addComponent(lblTurnoverFrequency) + .addComponent(comboTurnoverFrequency)) .addComponent(chkUseContractCompletionRandomRetirement) .addComponent(chkUseRandomFounderTurnover) .addComponent(chkUseFounderRetirement) From 1c69c932b8bc30ee6d501c8261339bc16a996998 Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Fri, 12 Jul 2024 21:01:53 -0500 Subject: [PATCH 3/3] Updated text for retention bonuses option The existing description for the retention bonuses option in the campaign options dialog was modified. "Pay Bonuses by Default" was replaced with "Automate Retention Bonuses" for clearer understanding. --- .../resources/mekhq/resources/CampaignOptionsDialog.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties index 602e13129b..aca938ef35 100644 --- a/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties +++ b/MekHQ/resources/mekhq/resources/CampaignOptionsDialog.properties @@ -157,7 +157,7 @@ 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=Pay Bonuses by Default +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).