Skip to content

Commit c1d4227

Browse files
authored
Merge pull request #8103 from IllianiBird/hrStrainFix
Fix: Fixed HR Strain Penalizing Complete Usage
2 parents 84a2c7b + 82fd63a commit c1d4227

9 files changed

+77
-29
lines changed

MekHQ/resources/mekhq/resources/AltAdvancedMedicalCampaignOptionsChangedConfirmationDialog.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Microsoft's "Game Content Usage Rules"
2929
# <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
3030
# affiliated with Microsoft.
31-
AdvancedScoutingCampaignOptionsChangedConfirmationDialog.description=<h1 style="text-align:center">Alternate \
31+
AltAdvancedMedicalCampaignOptionsChangedConfirmationDialog.description=<h1 style="text-align:center">Alternate \
3232
Advanced Medical (AAM)</h1>\
3333
You have just enabled <b>AAM</b> in a campaign that previously had it disabled. AAM uses the expanded hit \
3434
locations and injuries from ATOW:Companion to offer a more dynamic medical experience. It allows for prosthetics, \
@@ -39,5 +39,5 @@ AdvancedScoutingCampaignOptionsChangedConfirmationDialog.description=<h1 style="
3939
Would you like to gift any ProtoMek Pilots in your campaign the EI Neural Implant for free? This has no effect on \
4040
non-ProtoMek Pilots or in campaigns where Implants are disabled.\
4141
<p>For more information on Advanced Scouting, please see the Glossary.</p>
42-
AdvancedScoutingCampaignOptionsChangedConfirmationDialog.cancel=Decline
43-
AdvancedScoutingCampaignOptionsChangedConfirmationDialog.confirm=Accept
42+
AltAdvancedMedicalCampaignOptionsChangedConfirmationDialog.cancel=Decline
43+
AltAdvancedMedicalCampaignOptionsChangedConfirmationDialog.confirm=Accept

MekHQ/resources/mekhq/resources/CamOpsSalvage.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,6 @@ SalvagePostScenarioPicker.validation.valid=Valid
7474
SalvagePostScenarioPicker.validation.noTug=No Naval Tug
7575
SalvagePostScenarioPicker.validation.noCapacity.tow=Needs More Towage
7676
SalvagePostScenarioPicker.validation.noCapacity.cargo=Needs More Cargo
77+
SalvagePostScenarioPicker.confirmation.text=<h2 style="text-align:center;">Are You Sure?</h2>Please make sure that \
78+
you have ticked either the salvage or sell boxes for any unit you wish to keep (or sell). Otherwise, you are gifting\
79+
\ anything you salvage to Allied Command.

MekHQ/resources/mekhq/resources/FatigueTrackingCampaignOptionsChangedConfirmationDialog.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# affiliated with Microsoft.
3131
FatigueTrackingCampaignOptionsChangedConfirmationDialog.description=<h1 style="text-align:center">Fatigue</h1>\
3232
You have just enabled the tracking of <b>Fatigue</b> in a campaign that previously had it disabled.\
33-
<p>Would you like a complementary Field Kitchen-enabled unit? This unit will be fully crewed. However, if your \
33+
<p>Would you like a complementary Field Kitchen-equipped unit? This unit will be fully crewed. However, if your \
3434
campaign is particularly large, this may not be sufficient to cover all your needs.</p>\
3535
<p>Additional Field Kitchen-equipped units can be purchased from the <b>Unit Market</b>, or <b>Purchase Unit</b> \
3636
dialog.</p>

MekHQ/resources/mekhq/resources/PrisonerTrackingCampaignOptionsChangedConfirmationDialog.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# affiliated with Microsoft.
3131
PrisonerTrackingCampaignOptionsChangedConfirmationDialog.description=<h1 style="text-align:center">Prisoner \
3232
Tracking</h1>\
33-
You have just enabled the tracking of Prisoner Capacity in a campaign that previously had it disabled.\
33+
You have just enabled the tracking of <b>Prisoner Capacity</b> in a campaign that previously had it disabled.\
3434
<p>Would you like a complementary infantry unit to guard your prisoners? This unit will be fully crewed. However, \
3535
if your campaign is particularly large, this may not be sufficient to cover all your needs.</p>\
3636
<p>Additional infantry units can be purchased from the <b>Unit Market</b>, or <b>Purchase Unit</b> dialog.</p>

MekHQ/resources/mekhq/resources/VeterancyAwardsCampaignOptionsChangedConfirmationDialog.properties

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,38 @@
1+
# Copyright (C) 2025 The MegaMek Team. All Rights Reserved.
2+
#
3+
# This file is part of MekHQ.
4+
#
5+
# MekHQ is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License (GPL),
7+
# version 3 or (at your option) any later version,
8+
# as published by the Free Software Foundation.
9+
#
10+
# MekHQ is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty
12+
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13+
# See the GNU General Public License for more details.
14+
#
15+
# A copy of the GPL should have been included with this project;
16+
# if not, see <https://www.gnu.org/licenses/>.
17+
#
18+
# NOTICE: The MegaMek organization is a non-profit group of volunteers
19+
# creating free software for the BattleTech community.
20+
#
21+
# MechWarrior, BattleMech, `Mech and AeroTech are registered trademarks
22+
# of The Topps Company, Inc. All Rights Reserved.
23+
#
24+
# Catalyst Game Labs and the Catalyst Game Labs logo are trademarks of
25+
# InMediaRes Productions, LLC.
26+
#
27+
# MechWarrior Copyright Microsoft Corporation. MegaMek was created under
28+
# Microsoft's "Game Content Usage Rules"
29+
# <https://www.xbox.com/en-US/developers/rules> and it is not endorsed by or
30+
# affiliated with Microsoft.
131
VeterancyAwards.title=++ACCESSING TERMINAL++
232
VeterancyAwards.description=<h1 style="text-align:center">Veterancy Awards</h1>\
333
You have just enabled <b>Veterancy Awards</b> in a campaign that previously had it disabled. Veterancy Awards \
434
represent unique talents or flaws that emerge naturally as the character grows. They are not always positive, and \
5-
they are not always directly relevant to the character's professions. They are, however, free and create \
35+
they are not always directly relevant to the character''s professions. They are, however, free and create \
636
interesting narrative opportunities. Such as the tech that develops Natural Aptitude/Gunnery or the MekWarrior who \
737
turns out to be a bit of a Slow Learner after too many knocks on the head.\
838
<p>Would you like to update all personnel to account for missed awards? If you confirm this action, any character \

MekHQ/src/mekhq/campaign/personnel/Person.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5995,7 +5995,7 @@ public void resetMinutesLeft(boolean isTechsUseAdministration) {
59955995
}
59965996

59975997
// Personnel without tech or doctor roles have no available time
5998-
if (!isTech() && !isDoctor()) {
5998+
if (!isTechExpanded() && !isDoctor()) {
59995999
this.minutesLeft = 0;
60006000
this.overtimeLeft = 0;
60016001
return;

MekHQ/src/mekhq/campaign/personnel/turnoverAndRetention/RetirementDefectionTracker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
*/
3434
package mekhq.campaign.personnel.turnoverAndRetention;
3535

36+
import static java.lang.Math.max;
3637
import static java.lang.Math.min;
3738
import static java.lang.Math.round;
3839
import static mekhq.campaign.personnel.Person.getLoyaltyName;
@@ -268,7 +269,7 @@ public Map<UUID, TargetRoll> getTargetNumbers(final @Nullable Mission mission, f
268269
}
269270

270271
if (contract != null) {
271-
targetNumber.addModifier(-Math.max(0, ((contract.getSharesPercent() / 10) - 2)),
272+
targetNumber.addModifier(-max(0, ((contract.getSharesPercent() / 10) - 2)),
272273
resources.getString("shares.text"));
273274
}
274275
}
@@ -659,7 +660,7 @@ public static int getHRStrainModifier(Campaign campaign) {
659660
getCombinedSkillValues(campaign, SkillType.S_ADMIN);
660661

661662
if (maximumStrain != 0) {
662-
return personnel / maximumStrain;
663+
return 1 - (personnel / maximumStrain);
663664
} else {
664665
return personnel;
665666
}

MekHQ/src/mekhq/gui/BriefingTab.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -875,10 +875,6 @@ private void startScenario() {
875875
private boolean handleSalvageAssignments(Scenario scenario) {
876876
boolean hasSalvageOpportunity = isHasSalvageOpportunity(scenario.getMissionId());
877877
if (hasSalvageOpportunity) {
878-
// Reset old information
879-
scenario.clearSalvageForces();
880-
scenario.clearSalvageTechs();
881-
882878
if (!displaySalvageForcePicker(scenario)) {
883879
return true;
884880
}
@@ -1016,16 +1012,15 @@ private boolean displaySalvageTechPicker(Scenario scenario) {
10161012
techData.add(data);
10171013
}
10181014

1019-
SalvageTechPicker techPicker = new SalvageTechPicker(techData,
1020-
priorSelectedTechs,
1021-
getCampaign().isClanCampaign());
1022-
boolean wasConfirmed = techPicker.wasConfirmed();
1023-
if (wasConfirmed) {
1024-
List<UUID> selectedTechs = techPicker.getSelectedTechs();
1025-
for (UUID techId : selectedTechs) {
1026-
scenario.addSalvageTech(techId);
1027-
}
1015+
SalvageTechPicker techPicker = new SalvageTechPicker(techData, priorSelectedTechs,
1016+
getCampaign().isClanCampaign());
1017+
boolean wasConfirmed = techPicker.wasConfirmed();
1018+
if (wasConfirmed) {
1019+
List<UUID> selectedTechs = techPicker.getSelectedTechs();
1020+
for (UUID techId : selectedTechs) {
1021+
scenario.addSalvageTech(techId);
10281022
}
1023+
}
10291024

10301025
return techPicker.wasConfirmed();
10311026
}

MekHQ/src/mekhq/gui/dialog/SalvagePostScenarioPicker.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
import mekhq.campaign.personnel.Person;
8181
import mekhq.campaign.unit.TestUnit;
8282
import mekhq.campaign.unit.Unit;
83+
import mekhq.gui.baseComponents.immersiveDialogs.ImmersiveDialogSimple;
8384
import mekhq.gui.baseComponents.roundedComponents.RoundedJButton;
8485
import mekhq.gui.baseComponents.roundedComponents.RoundedLineBorder;
8586

@@ -258,7 +259,7 @@ public SalvagePostScenarioPicker(Campaign campaign, Mission mission, Scenario sc
258259
isExchangeRights = ((Contract) mission).isSalvageExchange();
259260
}
260261

261-
List<SalvageComboBoxGroup> selectedGroups = showSalvageDialog(isContract);
262+
List<SalvageComboBoxGroup> selectedGroups = showSalvageDialog(campaign, isContract);
262263
if (selectedGroups != null) {
263264
processSalvageAssignments(selectedGroups);
264265
}
@@ -428,14 +429,15 @@ private void processSalvageAssignments(List<SalvageComboBoxGroup> salvageComboBo
428429
* For contract missions, also displays salvage percentage information and enforces salvage limits. The dialog
429430
* validates all assignments and prevents confirmation if any assignments are invalid.</p>
430431
*
432+
* @param campaign the current campaign
431433
* @param isContract whether this is a contract mission (affects displayed information and validation)
432434
*
433435
* @return list of combo box groups with user selections, or null if the dialog was canceled
434436
*
435437
* @author Illiani
436438
* @since 0.50.10
437439
*/
438-
private List<SalvageComboBoxGroup> showSalvageDialog(boolean isContract) {
440+
private List<SalvageComboBoxGroup> showSalvageDialog(Campaign campaign, boolean isContract) {
439441
JDialog dialog = new JDialog((Frame) null, getText("accessingTerminal.title"), true);
440442
dialog.setLayout(new BorderLayout());
441443
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); // We don't want the player to cancel out
@@ -628,11 +630,11 @@ private List<SalvageComboBoxGroup> showSalvageDialog(boolean isContract) {
628630

629631
dialog.add(mainPanel, BorderLayout.CENTER);
630632

631-
confirmButton.addActionListener(e -> {
632-
confirmed[0] = true;
633-
resultHolder.groups = salvageComboBoxGroups;
634-
dialog.dispose();
635-
});
633+
confirmButton.addActionListener(e -> confirmationAction(campaign,
634+
dialog,
635+
confirmed,
636+
resultHolder,
637+
salvageComboBoxGroups));
636638

637639
buttonPanel.add(confirmButton);
638640

@@ -651,6 +653,23 @@ private List<SalvageComboBoxGroup> showSalvageDialog(boolean isContract) {
651653
return confirmed[0] ? resultHolder.groups : null;
652654
}
653655

656+
private static void confirmationAction(Campaign campaign, JDialog dialog, boolean[] confirmed,
657+
ResultHolder resultHolder,
658+
List<SalvageComboBoxGroup> salvageComboBoxGroups) {
659+
dialog.setVisible(false);
660+
ImmersiveDialogSimple confirmationDialog = new ImmersiveDialogSimple(campaign, null, null,
661+
getTextAt(RESOURCE_BUNDLE, "SalvagePostScenarioPicker.confirmation.text"),
662+
List.of(getText("Cancel.text"), getText("Confirm.text")), null, null, false);
663+
if (confirmationDialog.getDialogChoice() == 0) { // Cancelled
664+
dialog.setVisible(true);
665+
return;
666+
}
667+
668+
confirmed[0] = true;
669+
resultHolder.groups = salvageComboBoxGroups;
670+
dialog.dispose();
671+
}
672+
654673
/**
655674
* This is not currently implemented. The purpose of this method is to allow future developers and easy access point
656675
* to implement field stripping, without needing to grok where it should fit in the class (and gui).

0 commit comments

Comments
 (0)