Skip to content

Commit

Permalink
Refined scenario state handling in Stratcon Wizard
Browse files Browse the repository at this point in the history
Adjusted logic to ensure objective translations and scaling occur only when appropriate scenario states are active. This prevents unnecessary processing after reinforcements are committed. Cleaned up state references for improved consistency and readability.
  • Loading branch information
IllianiCBT committed Jan 15, 2025
1 parent f4b7479 commit 7dcf890
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions MekHQ/src/mekhq/gui/stratcon/StratconScenarioWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import mekhq.campaign.stratcon.StratconCampaignState;
import mekhq.campaign.stratcon.StratconRulesManager;
import mekhq.campaign.stratcon.StratconScenario;
import mekhq.campaign.stratcon.StratconScenario.ScenarioState;
import mekhq.campaign.stratcon.StratconTrackState;
import mekhq.campaign.unit.Unit;
import mekhq.gui.utilities.JScrollPaneWithSpeed;
Expand All @@ -51,9 +50,8 @@
import static mekhq.campaign.stratcon.StratconRulesManager.*;
import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementResultsType.DELAYED;
import static mekhq.campaign.stratcon.StratconRulesManager.ReinforcementResultsType.FAILED;
import static mekhq.campaign.stratcon.StratconRulesManager.calculateReinforcementTargetNumber;
import static mekhq.campaign.stratcon.StratconRulesManager.getEligibleLeadershipUnits;
import static mekhq.campaign.stratcon.StratconRulesManager.processReinforcementDeployment;
import static mekhq.campaign.stratcon.StratconScenario.ScenarioState.PRIMARY_FORCES_COMMITTED;
import static mekhq.campaign.stratcon.StratconScenario.ScenarioState.REINFORCEMENTS_COMMITTED;
import static mekhq.gui.baseComponents.MHQDialogImmersive.getSpeakerDescription;
import static mekhq.gui.dialog.resupplyAndCaches.ResupplyDialogUtilities.getSpeakerIcon;
import static mekhq.utilities.ImageUtilities.scaleImageIconToWidth;
Expand Down Expand Up @@ -851,7 +849,7 @@ private void btnCommitClicked(ActionEvent evt, @Nullable Integer reinforcementTa
// go through all the force lists and add the selected forces to the scenario
for (String templateID : availableForceLists.keySet()) {
for (Force force : availableForceLists.get(templateID).getSelectedValuesList()) {
if (currentScenario.getCurrentState() == ScenarioState.PRIMARY_FORCES_COMMITTED) {
if (currentScenario.getCurrentState() == PRIMARY_FORCES_COMMITTED) {
ReinforcementEligibilityType reinforcementType = getReinforcementType(
force.getId(), currentTrackState, campaign, currentCampaignState);

Expand Down Expand Up @@ -904,8 +902,10 @@ private void btnCommitClicked(ActionEvent evt, @Nullable Integer reinforcementTa

currentScenario.updateMinefieldCount(Minefield.TYPE_CONVENTIONAL, getNumMinefields());

translateTemplateObjectives(currentScenario.getBackingScenario(), campaign);
scaleObjectiveTimeLimits(currentScenario.getBackingScenario(), campaign);
if (currentScenario.getCurrentState().ordinal() < REINFORCEMENTS_COMMITTED.ordinal()) {
translateTemplateObjectives(currentScenario.getBackingScenario(), campaign);
scaleObjectiveTimeLimits(currentScenario.getBackingScenario(), campaign);
}

this.getParent().repaint();

Expand Down

0 comments on commit 7dcf890

Please sign in to comment.