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

Fixed Used Parts Value Multipliers Incorrectly Resetting to 0 #4141

Merged
merged 2 commits into from
Jun 6, 2024
Merged
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 @@ -35,7 +35,7 @@ spnMaintenanceBonus.toolTipText=When checking by parts, Strat Ops applies a -1 b
useQualityMaintenance.text=Use quality modifiers in maintenance checks
useQualityMaintenance.toolTipText=If checked, quality modifiers will be added to maintenance checks (WARNING: this will lead to unstable quality ratings over time)
reverseQualityNames.text=Reverse quality names
reverseQualityNames.toolTipText=If checked, quality name reporting will be reversed so that A is the best and F is the worst
reverseQualityNames.toolTipText=<html>If checked, quality name reporting will be reversed so that A is the best and F is the worst. <b>Warning:</b> toggling this option will reset the Finances tab.
useUnofficialMaintenance.text=Only damage parts that are already at worst quality (Unofficial)
useUnofficialMaintenance.toolTipText=<html>When this option is checked and you are using quality maintenance, <br>the margin of failure rolls for damaging parts only happen for parts that are already rated at the lowest level.</html>
logMaintenance.text=Log maintenance rolls in log file
Expand Down Expand Up @@ -567,7 +567,7 @@ lblClanPartPriceMultiplier.toolTipText=Multiplies the buy/sell price of Clan tec
lblMixedTechUnitPriceMultiplier.text=Mixed Tech Unit Price Multiplier
lblMixedTechUnitPriceMultiplier.toolTipText=Multiplies the buy/sell price of Mixed Tech units by the specified number.
usedPartsValueMultipliersPanel.title=Used Parts Value Multipliers
lblUsedPartPriceMultiplier.toolTipText=Multiplies the value and thus the sell price of used parts by the specified number. The quality is the original Quality letter and does not change based on the Reverse Quality Names option.
lblUsedPartPriceMultiplier.toolTipText=Multiplies the value and thus the sell price of used parts by the specified number.
lblDamagedPartsValueMultiplier.text=Damaged Parts Value Multiplier
lblDamagedPartsValueMultiplier.toolTipText=Multiplies the value and thus the sell price of damaged parts by the specified number.
lblUnrepairablePartsValueMultiplier.text=Unrepairable Damaged Parts Value Multiplier
Expand Down
52 changes: 45 additions & 7 deletions MekHQ/src/mekhq/gui/panes/CampaignOptionsPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,7 @@ private JScrollPane createRepairAndMaintenanceTab() {
panSubMaintenance.add(reverseQualityNames, gridBagConstraints);

reverseQualityNames.addActionListener(evt -> {
if (reverseQualityNames.isSelected()) {
recreateFinancesPanel(true);
} else {
recreateFinancesPanel(false);
}
recreateFinancesPanel(reverseQualityNames.isSelected());
});

useUnofficialMaintenance = new JCheckBox(resources.getString("useUnofficialMaintenance.text"));
Expand Down Expand Up @@ -1636,7 +1632,7 @@ private JScrollPane createFinancesTab(boolean reverseQualities) {
gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
panFinances.add(usePercentageMaintBox, gridBagConstraints);

// Unofficial infantry don't count for contract pay
// Unofficial infantry doesn't count for contract pay
useInfantryDontCountBox = new JCheckBox(resources.getString("infantryDontCount.text"));
useInfantryDontCountBox.setToolTipText(resources.getString("infantryDontCount.toolTipText"));
gridBagConstraints = new GridBagConstraints();
Expand Down Expand Up @@ -6368,6 +6364,7 @@ private JPanel createUsedPartsValueMultipliersPanel(boolean reverseQualities) {
panel.setName("usedPartsValueMultipliersPanel");

spnUsedPartPriceMultipliers = new JSpinner[Part.QUALITY_F + 1];

for (int i = Part.QUALITY_A; i <= Part.QUALITY_F; i++) {
final String qualityLevel = Part.getQualityName(i, reverseQualities);

Expand Down Expand Up @@ -8226,13 +8223,54 @@ public void recreateSPAPanel(boolean enableAddSPA) {
}

/**
* Recreates the finances panel to reverse the qualities labels.
* Recreates the finances panel to reverse the quality labels.
* @param reverseQualities boolean for if the qualities are reversed.
*/
private void recreateFinancesPanel(boolean reverseQualities) {
int financesTabIndex = indexOfTab(resources.getString("financesPanel.title"));
removeTabAt(financesTabIndex);
insertTab(resources.getString("financesPanel.title"), null, createFinancesTab(reverseQualities), null, financesTabIndex);

// The following setters and getter calls are so that recreating the tab doesn't reset all
// options to their default values

// General finances panel options
payForPartsBox.setSelected(options.isPayForParts());
payForRepairsBox.setSelected(options.isPayForRepairs());
payForUnitsBox.setSelected(options.isPayForUnits());
payForSalariesBox.setSelected(options.isPayForSalaries());
payForOverheadBox.setSelected(options.isPayForOverhead());
payForMaintainBox.setSelected(options.isPayForMaintain());
payForTransportBox.setSelected(options.isPayForTransport());
sellUnitsBox.setSelected(options.isSellUnits());
sellPartsBox.setSelected(options.isSellParts());
payForRecruitmentBox.setSelected(options.isPayForRecruitment());
useLoanLimitsBox.setSelected(options.isUseLoanLimits());

usePercentageMaintBox.setSelected(options.isUsePercentageMaint());
useInfantryDontCountBox.setSelected(options.isInfantryDontCount());

usePeacetimeCostBox.setSelected(options.isUsePeacetimeCost());
useExtendedPartsModifierBox.setSelected(options.isUseExtendedPartsModifier());
showPeacetimeCostBox.setSelected(options.isShowPeacetimeCost());
comboFinancialYearDuration.setSelectedItem(options.getFinancialYearDuration());
newFinancialYearFinancesToCSVExportBox.setSelected(options.isNewFinancialYearFinancesToCSVExport());

// Price Modifiers Panel
spnCommonPartPriceMultiplier.setValue(options.getCommonPartPriceMultiplier());
spnInnerSphereUnitPriceMultiplier.setValue(options.getInnerSphereUnitPriceMultiplier());
spnInnerSpherePartPriceMultiplier.setValue(options.getInnerSpherePartPriceMultiplier());
spnClanUnitPriceMultiplier.setValue(options.getClanUnitPriceMultiplier());
spnClanPartPriceMultiplier.setValue(options.getClanPartPriceMultiplier());
spnMixedTechUnitPriceMultiplier.setValue(options.getMixedTechUnitPriceMultiplier());
spnDamagedPartsValueMultiplier.setValue(options.getDamagedPartsValueMultiplier());
spnUnrepairablePartsValueMultiplier.setValue(options.getUnrepairablePartsValueMultiplier());
spnCancelledOrderRefundMultiplier.setValue(options.getCancelledOrderRefundMultiplier());

// Used Parts Multiplier Panel
for (int index = Part.QUALITY_A; index <= Part.QUALITY_F; index++) {
spnUsedPartPriceMultipliers[index].setValue(options.getUsedPartPriceMultipliers()[index]);
}
}

private void enableAtBComponents(JPanel panel, boolean enabled) {
Expand Down
Loading