From 5cf9b56c37b85cbd800e5d4a8c6f53a3802cc54d Mon Sep 17 00:00:00 2001 From: IllianiCBT Date: Mon, 25 Nov 2024 16:54:26 -0600 Subject: [PATCH] Remove redundant logging and simplify condition handling Removed an unnecessary log statement that printed the force name. Simplified the conditional check for reinforcement restrictions, ensuring better readability and maintainability. --- .../stratcon/StratconRulesManager.java | 21 +++++++++---------- .../mekhq/gui/adapter/TOEMouseAdapter.java | 14 ++++++++----- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java index 2d2393b148..47a4e44edd 100644 --- a/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java +++ b/MekHQ/src/mekhq/campaign/stratcon/StratconRulesManager.java @@ -1459,20 +1459,19 @@ public static List getAvailableForceIDs(int unitType, Campaign campaign continue; } - logger.info(force.getName()); - int primaryUnitType = force.getPrimaryUnitType(campaign); - boolean noReinforcementRestriction = !reinforcements || (reinforcements - && (getReinforcementType(force.getId(), currentTrack, campaign, - campaignState) != ReinforcementEligibilityType.None)); - if ((force.getScenarioId() <= 0) && !force.getAllUnits(true).isEmpty() - && !forcesInTracks.contains(force.getId()) - && forceCompositionMatchesDeclaredUnitType(primaryUnitType, unitType, reinforcements) - && noReinforcementRestriction - && !subElementsOrSelfDeployed(force, campaign)) { + boolean noReinforcementRestriction = !reinforcements || + (getReinforcementType(force.getId(), currentTrack, campaign, campaignState) != ReinforcementEligibilityType.None); + + if ((force.getScenarioId() <= 0) + && !force.getAllUnits(true).isEmpty() + && !forcesInTracks.contains(force.getId()) + && forceCompositionMatchesDeclaredUnitType(primaryUnitType, unitType, reinforcements) + && noReinforcementRestriction + && !subElementsOrSelfDeployed(force, campaign)) { + retVal.add(force.getId()); } - retVal.add(force.getId()); } return retVal; diff --git a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java index 3a55420aed..c1602fabc3 100644 --- a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java @@ -438,14 +438,18 @@ public void actionPerformed(ActionEvent action) { } gui.undeployForces(forces); gui.getTOETab().refreshForceView(); + + for (Force formation : gui.getCampaign().getAllForces()) { + MekHQ.triggerEvent(new OrganizationChangedEvent(formation)); + } } else if (command.contains(CHANGE_STRATEGIC_FORCE_OVERRIDE)) { if (singleForce == null) { return; } - boolean overrideState = singleForce.getOverrideStrategicFormation() == STRATEGIC_FORMATION_OVERRIDE_TRUE; - singleForce.setStrategicFormation(!overrideState); - singleForce.setOverrideStrategicFormation(!overrideState ? STRATEGIC_FORMATION_OVERRIDE_TRUE : STRATEGIC_FORMATION_OVERRIDE_FALSE); + boolean formationState = singleForce.isStrategicFormation(); + singleForce.setStrategicFormation(!formationState); + singleForce.setOverrideStrategicFormation(!formationState ? STRATEGIC_FORMATION_OVERRIDE_TRUE : STRATEGIC_FORMATION_OVERRIDE_FALSE); for (Force formation : gui.getCampaign().getAllForces()) { MekHQ.triggerEvent(new OrganizationChangedEvent(formation)); @@ -1048,8 +1052,8 @@ protected Optional createPopupMenu() { menuItem.addActionListener(this); popup.add(menuItem); - JMenuItem optionStrategicForceOverride = new JMenuItem(force.isStrategicFormation() ? - "Remove Strategic Formation Assignment" : "Assign as Strategic Formation"); + JMenuItem optionStrategicForceOverride = new JMenuItem((force.isStrategicFormation() ? + "Never" : "Always") + " Consider Force a Strategic Formation"); optionStrategicForceOverride.setActionCommand(COMMAND_CHANGE_STRATEGIC_FORCE_OVERRIDE + forceIds); optionStrategicForceOverride.addActionListener(this); popup.add(optionStrategicForceOverride);