From b602ee8176de2384e514f41ac07c8d27aaa85304 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:01:43 -0500 Subject: [PATCH] Issue 3650: More Dev Review Fixes --- .../AssignForceToTransport.properties | 9 + MekHQ/src/mekhq/AtBGameThread.java | 31 +- MekHQ/src/mekhq/Utilities.java | 6 +- .../campaign/enums/CampaignTransportType.java | 10 - .../campaign/unit/ITransportAssignment.java | 11 +- .../campaign/unit/TransportAssignment.java | 17 +- MekHQ/src/mekhq/campaign/unit/Unit.java | 8 +- .../utilities/CampaignTransportUtilities.java | 313 +++++++++--------- .../gui/menus/AssignForceToTransportMenu.java | 6 +- 9 files changed, 208 insertions(+), 203 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties b/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties index f4b4263c90..1cf8625d64 100644 --- a/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties +++ b/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties @@ -33,3 +33,12 @@ TOEMouseAdapter.unassign.SHIP_TRANSPORT.text=Unassign Force from Ship Transport AtBGameThread.loadTransportDialog.TACTICAL_TRANSPORT.title=Load Units onto Transport? AtBGameThread.loadTransportDialog.TACTICAL_TRANSPORT.text=Would you like the units assigned to {0} to deploy loaded? +AtBGameThread.loadTransportDialog.LOAD_DROPSHIP_DIALOG_TITLE.title =Load DropShips onto Transport? +AtBGameThread.loadTransportDialog.LOAD_DROPSHIP_DIALOG_TEXT.text =Would you like the DropShip(s) assigned to {0} to deploy loaded into its bays? +AtBGameThread.loadTransportDialog.LOAD_SMALL_CRAFT_DIALOG_TITLE.title =Load Small Craft onto Transport? +AtBGameThread.loadTransportDialog.LOAD_SMALL_CRAFT_DIALOG_TEXT.text =Would you like the small craft assigned to {0} to deploy loaded into its bays? +AtBGameThread.loadTransportDialog.LOAD_FTR_DIALOG_TEXT.text =Would you like the fighter(s) assigned to {0} to deploy loaded into its bays? +AtBGameThread.loadTransportDialog.LOAD_FTR_DIALOG_TITLE.title =Load Fighters onto Transport? +AtBGameThread.loadTransportDialog.LOAD_GND_DIALOG_TEXT.text =Would you like the ground unit(s) assigned to {0} to deploy loaded into its bays? +AtBGameThread.loadTransportDialog.LOAD_GND_DIALOG_TITLE.title =Load Ground Units onto Transport? + diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index 84ebe39d19..73b47991a3 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -92,17 +92,6 @@ public AtBGameThread(String name, String password, Client client, MekHQ app, Lis this.autoResolveBehaviorSettings = autoResolveBehaviorSettings; } - // String tokens for dialog boxes used for transport loading - // FIXME : I'm not localized! - private static final String LOAD_DROPSHIP_DIALOG_TITLE = "Load DropShips onto Transport?"; - private static final String LOAD_DROPSHIP_DIALOG_TEXT = "Would you like the DropShip(s) assigned to %s to deploy loaded into its bays?"; - private static final String LOAD_SMALL_CRAFT_DIALOG_TITLE = "Load Small Craft onto Transport?"; - private static final String LOAD_SMALL_CRAFT_DIALOG_TEXT = "Would you like the small craft assigned to %s to deploy loaded into its bays?"; - private static final String LOAD_FTR_DIALOG_TEXT = "Would you like the fighter(s) assigned to %s to deploy loaded into its bays?"; - private static final String LOAD_FTR_DIALOG_TITLE = "Load Fighters onto Transport?"; - private static final String LOAD_GND_DIALOG_TEXT = "Would you like the ground unit(s) assigned to %s to deploy loaded into its bays?"; - private static final String LOAD_GND_DIALOG_TITLE = "Load Ground Units onto Transport?"; - @Override public void run() { client.addCloseClientListener(this); @@ -400,27 +389,27 @@ public void run() { if (transportShip.getShipTransportedUnits().stream() .anyMatch(unit -> unit.getEntity().getUnitType() == UnitType.DROPSHIP)) { loadDropShips = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - String.format(AtBGameThread.LOAD_DROPSHIP_DIALOG_TEXT, transportShip.getName()), - AtBGameThread.LOAD_DROPSHIP_DIALOG_TITLE, JOptionPane.YES_NO_OPTION); + MHQInternationalization.getFormattedTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_DROPSHIP_DIALOG_TEXT.text", transportShip.getName()), + MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_DROPSHIP_DIALOG_TITLE.title"), JOptionPane.YES_NO_OPTION); } if (transportShip.getShipTransportedUnits().stream() .anyMatch(unit -> unit.getEntity().getUnitType() == UnitType.SMALL_CRAFT)) { loadSmallCraft = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - String.format(AtBGameThread.LOAD_SMALL_CRAFT_DIALOG_TEXT, transportShip.getName()), - AtBGameThread.LOAD_SMALL_CRAFT_DIALOG_TITLE, JOptionPane.YES_NO_OPTION); + MHQInternationalization.getFormattedTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_SMALL_CRAFT_DIALOG_TEXT.text", transportShip.getName()), + MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_SMALL_CRAFT_DIALOG_TITLE.title"), JOptionPane.YES_NO_OPTION); } if (transportShip.isCarryingSmallerAero()) { loadFighters = JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - String.format(AtBGameThread.LOAD_FTR_DIALOG_TEXT, transportShip.getName()), - AtBGameThread.LOAD_FTR_DIALOG_TITLE, JOptionPane.YES_NO_OPTION); + MHQInternationalization.getFormattedTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_FTR_DIALOG_TEXT.text", transportShip.getName()), + MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_FTR_DIALOG_TITLE.title"), JOptionPane.YES_NO_OPTION); } if (transportShip.isCarryingGround()) { loadGround = (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - String.format(AtBGameThread.LOAD_GND_DIALOG_TEXT, transportShip.getName()), - AtBGameThread.LOAD_GND_DIALOG_TITLE, JOptionPane.YES_NO_OPTION)); + MHQInternationalization.getFormattedTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_GND_DIALOG_TEXT.text", transportShip.getName()), + MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AtBGameThread.loadTransportDialog.LOAD_GND_DIALOG_TITLE.title"), JOptionPane.YES_NO_OPTION)); } // Now, send the load commands @@ -479,8 +468,8 @@ public void run() { if (scenario.getPlayerTransportLinkages().containsKey(transportId)) { scenario.addPlayerTransportRelationship(transportId, transportedUnit.getId()); } - if (transportedUnit.getTech() != null && transportedUnit.getTacticalTransportAssignment().hasTransporterType() - && Bay.class.isAssignableFrom(transportedUnit.getTacticalTransportAssignment().getTransporterType().getTransporterClass())) { + if (transportedUnit.getTech() != null && transportedUnit.hasTransportAssignment(TACTICAL_TRANSPORT) + && transportedUnit.getTransportAssignment(TACTICAL_TRANSPORT).isTransportedInBay()){ cargoTechs.add(transportedUnit.getTech()); } } diff --git a/MekHQ/src/mekhq/Utilities.java b/MekHQ/src/mekhq/Utilities.java index 2abf2b5f50..5d0e1ebdf2 100644 --- a/MekHQ/src/mekhq/Utilities.java +++ b/MekHQ/src/mekhq/Utilities.java @@ -1328,12 +1328,10 @@ public static void loadPlayerTransports(int trnId, Map getTransportedUnitsSummaryType() { return transportedUnitsSummaryType; } // endregion Getters - - - public String getName() { - return this.toString(); - } } diff --git a/MekHQ/src/mekhq/campaign/unit/ITransportAssignment.java b/MekHQ/src/mekhq/campaign/unit/ITransportAssignment.java index c1cb28b3da..643860cf9b 100644 --- a/MekHQ/src/mekhq/campaign/unit/ITransportAssignment.java +++ b/MekHQ/src/mekhq/campaign/unit/ITransportAssignment.java @@ -22,7 +22,6 @@ package mekhq.campaign.unit; import megamek.common.Transporter; -import megamek.common.annotations.Nullable; import mekhq.campaign.Campaign; import mekhq.campaign.unit.enums.TransporterType; @@ -73,4 +72,14 @@ public interface ITransportAssignment { */ void fixReferences(Campaign campaign, Unit unit); + /** + * Bays have some extra functionality other transporters don't have, like + * having a tech crew, which will matter for boarding actions against + * dropships and other Ship Transports. This method determines if this + * transport assignment is for a Bay. + * @return true if the unit is transported in a Bay or a subclass + * @see megamek.common.Bay + */ + boolean isTransportedInBay(); + } diff --git a/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java b/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java index a2674b23b4..921f8690d8 100644 --- a/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java +++ b/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java @@ -19,6 +19,7 @@ package mekhq.campaign.unit; +import megamek.common.Bay; import megamek.common.Transporter; import megamek.common.annotations.Nullable; import megamek.logging.MMLogger; @@ -26,9 +27,7 @@ import mekhq.campaign.enums.CampaignTransportType; import mekhq.campaign.unit.enums.TransporterType; -import java.util.HashSet; import java.util.Optional; -import java.util.Set; /** * Represents an assignment on a transport. Currently only used by TACTICAL_TRANSPORT @@ -183,4 +182,18 @@ public void fixReferences(Campaign campaign, Unit unit) { } } } + + /** + * Bays have some extra functionality other transporters don't have, like + * having a tech crew, which will matter for boarding actions against + * dropships and other Ship Transports. This method determines if this + * transport assignment is for a Bay. + * + * @return true if the unit is transported in a Bay or a subclass + * @see Bay + */ + @Override + public boolean isTransportedInBay() { + return (hasTransporterType() && Bay.class.isAssignableFrom(getTransporterType().getTransporterClass())); + } } diff --git a/MekHQ/src/mekhq/campaign/unit/Unit.java b/MekHQ/src/mekhq/campaign/unit/Unit.java index b10b145d36..53538e40b8 100644 --- a/MekHQ/src/mekhq/campaign/unit/Unit.java +++ b/MekHQ/src/mekhq/campaign/unit/Unit.java @@ -367,13 +367,13 @@ public void initializeTransportSpace(CampaignTransportType campaignTransportType Constructor constructor = campaignTransportType.getTransportedUnitsSummaryType().getConstructor(new Class[]{Unit.class}); addTransportedUnitType(constructor.newInstance(this)); } catch (NoSuchMethodException e) { - logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.getName(), e.toString(), e.getCause())); + logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.name(), e.toString(), e.getCause())); } catch (InvocationTargetException e) { - logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.getName(), e.toString(), e.getCause())); + logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.name(), e.toString(), e.getCause())); } catch (InstantiationException e) { - logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.getName(), e.toString(), e.getCause())); + logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.name(), e.toString(), e.getCause())); } catch (IllegalAccessException e) { - logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.getName(), e.toString(), e.getCause())); + logger.error(String.format("Could not find constructor to initialize transport space for %s Error: %s Cause: %s", campaignTransportType.name(), e.toString(), e.getCause())); } } } diff --git a/MekHQ/src/mekhq/campaign/utilities/CampaignTransportUtilities.java b/MekHQ/src/mekhq/campaign/utilities/CampaignTransportUtilities.java index cacb68044f..c24c7d3084 100644 --- a/MekHQ/src/mekhq/campaign/utilities/CampaignTransportUtilities.java +++ b/MekHQ/src/mekhq/campaign/utilities/CampaignTransportUtilities.java @@ -26,7 +26,6 @@ import java.util.*; import static mekhq.campaign.unit.enums.TransporterType.*; -import static mekhq.campaign.utilities.CampaignTransportUtilities.Visitor.visitors; public class CampaignTransportUtilities { // region Static Helpers @@ -35,161 +34,6 @@ interface Visitor { boolean isInterestedIn(Entity entity); EnumSet getTransporterTypes(T entity, CampaignTransportType campaignTransportType); - - - List visitors = List.of( - - new Visitor() { - @Override - public boolean isInterestedIn(Entity entity) { - return entity instanceof ProtoMek; - } - - @Override - public EnumSet getTransporterTypes(ProtoMek entity, CampaignTransportType campaignTransportType) { - Set transporters = new HashSet<>(); - transporters.add(PROTO_MEK_BAY); - - //Ship transports can't use some transport types - if (!(campaignTransportType.isShipTransport())) { - transporters.add(PROTO_MEK_CLAMP_MOUNT); - } - - return EnumSet.copyOf(transporters); - } - }, - new Visitor() { - - @Override - public boolean isInterestedIn(Entity entity) { - return entity instanceof Aero; - } - - @Override - public EnumSet getTransporterTypes(Aero entity, CampaignTransportType campaignTransportType) { - Set transporters = new HashSet<>(); - if (entity.isFighter()) { - transporters.add(ASF_BAY); - } - if ((entity.isFighter()) || entity.isSmallCraft()) { - transporters.add(SMALL_CRAFT_BAY); - } - if (entity.hasETypeFlag(Entity.ETYPE_DROPSHIP) && (entity.getWeight() <= 5000)) { - transporters.add(DROPSHUTTLE_BAY); - } - if (entity.hasETypeFlag(Entity.ETYPE_DROPSHIP) || entity.hasETypeFlag(Entity.ETYPE_JUMPSHIP)) { - transporters.add(NAVAL_REPAIR_FACILITY); - transporters.add(REINFORCED_REPAIR_FACILITY); - } - if (entity instanceof Dropship && !((Dropship) entity).isDockCollarDamaged()) { - transporters.add(DOCKING_COLLAR); - } - - return EnumSet.copyOf(transporters); - } - }, - new Visitor() { - - @Override - public boolean isInterestedIn(Entity entity) { - return entity instanceof Tank; - } - - @Override - public EnumSet getTransporterTypes(Tank entity, CampaignTransportType campaignTransportType) { - - Set transporters = new HashSet<>(); - - if (entity.getWeight() <= 50) { - transporters.add(LIGHT_VEHICLE_BAY); - } - - if (entity.getWeight() <= 100) { - transporters.add(HEAVY_VEHICLE_BAY); - } - - if (entity.getWeight() <= 150) { - transporters.add(SUPER_HEAVY_VEHICLE_BAY); - } - return EnumSet.copyOf(transporters); - } - }, - new Visitor() { - - @Override - public boolean isInterestedIn(Entity entity) { - return entity instanceof Mek; - } - - @Override - public EnumSet getTransporterTypes(Mek entity, CampaignTransportType campaignTransportType) { - Set transporters = new HashSet<>(); - boolean loadableQuadVee = (entity instanceof QuadVee) && (entity.getConversionMode() == QuadVee.CONV_MODE_MEK); - boolean loadableLAM = (entity instanceof LandAirMek) && (entity.getConversionMode() != LandAirMek.CONV_MODE_FIGHTER); - boolean loadableOtherMek = (entity != null) && !(entity instanceof QuadVee) && !(entity instanceof LandAirMek); - if (loadableQuadVee || loadableLAM || loadableOtherMek) { - transporters.add(MEK_BAY); - - } else { - if ((entity instanceof QuadVee) && (entity.getConversionMode() == QuadVee.CONV_MODE_VEHICLE)) { - if (entity.getWeight() <= 50) { - transporters.add(LIGHT_VEHICLE_BAY); - } - - if (entity.getWeight() <= 100) { - transporters.add(HEAVY_VEHICLE_BAY); - } - - if (entity.getWeight() <= 100) { - transporters.add(SUPER_HEAVY_VEHICLE_BAY); - } - } - } - return EnumSet.copyOf(transporters); - } - }, - new Visitor() { - - @Override - public boolean isInterestedIn(Entity entity) { - return entity instanceof Infantry; - } - - @Override - public EnumSet getTransporterTypes(Infantry entity, CampaignTransportType campaignTransportType) { - Set transporters = new HashSet<>(); - - //Ship transports can't use some transport types - if (!(campaignTransportType.isShipTransport())) { - transporters.add(INFANTRY_COMPARTMENT); - } - - if (entity instanceof BattleArmor baEntity) { - transporters.add(BATTLE_ARMOR_BAY); - - //Ship transports can't use some transport types - if (baEntity.canDoMechanizedBA() && !campaignTransportType.isShipTransport()) { - transporters.add(BATTLE_ARMOR_HANDLES); - transporters.add(BATTLE_ARMOR_HANDLES_TANK); - - if (baEntity.hasMagneticClamps()) { - transporters.add(CLAMP_MOUNT_MEK); - transporters.add(CLAMP_MOUNT_TANK); - } - - } - - } else { - transporters.add(INFANTRY_BAY); - } - - return EnumSet.copyOf(transporters); - } - }); - } - - private static Optional getTransportTypeClassifier(Entity entity) { - return visitors.stream().filter(v -> v.isInterestedIn(entity)).findFirst(); } /** @@ -219,7 +63,7 @@ public static EnumSet mapEntityToTransporters(CampaignTransport */ public static double transportCapacityUsage(TransporterType transporterType, Entity transportedUnit) { if (transporterType == INFANTRY_BAY || transporterType == INFANTRY_COMPARTMENT) { - if (Infantry.class.isAssignableFrom(transportedUnit.getClass())) { + if (transportedUnit instanceof Infantry) { return calcInfantryBayWeight(transportedUnit); } } @@ -240,5 +84,160 @@ public static double calcInfantryBayWeight(Entity unit) { return type.getWeight(); } } + + + private static final List visitors = List.of( + + new Visitor() { + @Override + public boolean isInterestedIn(Entity entity) { + return entity instanceof ProtoMek; + } + + @Override + public EnumSet getTransporterTypes(ProtoMek entity, CampaignTransportType campaignTransportType) { + EnumSet transporters = EnumSet.noneOf(TransporterType.class); + transporters.add(PROTO_MEK_BAY); + + //Ship transports can't use some transport types + if (!(campaignTransportType.isShipTransport())) { + transporters.add(PROTO_MEK_CLAMP_MOUNT); + } + + return transporters; + } + }, + new Visitor() { + + @Override + public boolean isInterestedIn(Entity entity) { + return entity instanceof Aero; + } + + @Override + public EnumSet getTransporterTypes(Aero entity, CampaignTransportType campaignTransportType) { + EnumSet transporters = EnumSet.noneOf(TransporterType.class); + if (entity.isFighter()) { + transporters.add(ASF_BAY); + } + if ((entity.isFighter()) || entity.isSmallCraft()) { + transporters.add(SMALL_CRAFT_BAY); + } + if (entity.hasETypeFlag(Entity.ETYPE_DROPSHIP) && (entity.getWeight() <= 5000)) { + transporters.add(DROPSHUTTLE_BAY); + } + if (entity.hasETypeFlag(Entity.ETYPE_DROPSHIP) || entity.hasETypeFlag(Entity.ETYPE_JUMPSHIP)) { + transporters.add(NAVAL_REPAIR_FACILITY); + transporters.add(REINFORCED_REPAIR_FACILITY); + } + if (entity instanceof Dropship && !((Dropship) entity).isDockCollarDamaged()) { + transporters.add(DOCKING_COLLAR); + } + + return transporters; + } + }, + new Visitor() { + + @Override + public boolean isInterestedIn(Entity entity) { + return entity instanceof Tank; + } + + @Override + public EnumSet getTransporterTypes(Tank entity, CampaignTransportType campaignTransportType) { + + EnumSet transporters = EnumSet.noneOf(TransporterType.class); + + if (entity.getWeight() <= 50) { + transporters.add(LIGHT_VEHICLE_BAY); + } + + if (entity.getWeight() <= 100) { + transporters.add(HEAVY_VEHICLE_BAY); + } + + if (entity.getWeight() <= 150) { + transporters.add(SUPER_HEAVY_VEHICLE_BAY); + } + return transporters; + } + }, + new Visitor() { + + @Override + public boolean isInterestedIn(Entity entity) { + return entity instanceof Mek; + } + + @Override + public EnumSet getTransporterTypes(Mek entity, CampaignTransportType campaignTransportType) { + EnumSet transporters = EnumSet.noneOf(TransporterType.class); + boolean loadableQuadVee = (entity instanceof QuadVee) && (entity.getConversionMode() == QuadVee.CONV_MODE_MEK); + boolean loadableLAM = (entity instanceof LandAirMek) && (entity.getConversionMode() != LandAirMek.CONV_MODE_FIGHTER); + boolean loadableOtherMek = (entity != null) && !(entity instanceof QuadVee) && !(entity instanceof LandAirMek); + if (loadableQuadVee || loadableLAM || loadableOtherMek) { + transporters.add(MEK_BAY); + + } else { + if ((entity instanceof QuadVee) && (entity.getConversionMode() == QuadVee.CONV_MODE_VEHICLE)) { + if (entity.getWeight() <= 50) { + transporters.add(LIGHT_VEHICLE_BAY); + } + + if (entity.getWeight() <= 100) { + transporters.add(HEAVY_VEHICLE_BAY); + } + + if (entity.getWeight() <= 100) { + transporters.add(SUPER_HEAVY_VEHICLE_BAY); + } + } + } + return transporters; + } + }, + new Visitor() { + + @Override + public boolean isInterestedIn(Entity entity) { + return entity instanceof Infantry; + } + + @Override + public EnumSet getTransporterTypes(Infantry entity, CampaignTransportType campaignTransportType) { + EnumSet transporters = EnumSet.noneOf(TransporterType.class); + + //Ship transports can't use some transport types + if (!(campaignTransportType.isShipTransport())) { + transporters.add(INFANTRY_COMPARTMENT); + } + + if (entity instanceof BattleArmor baEntity) { + transporters.add(BATTLE_ARMOR_BAY); + + //Ship transports can't use some transport types + if (baEntity.canDoMechanizedBA() && !campaignTransportType.isShipTransport()) { + transporters.add(BATTLE_ARMOR_HANDLES); + transporters.add(BATTLE_ARMOR_HANDLES_TANK); + + if (baEntity.hasMagneticClamps()) { + transporters.add(CLAMP_MOUNT_MEK); + transporters.add(CLAMP_MOUNT_TANK); + } + + } + + } else { + transporters.add(INFANTRY_BAY); + } + + return transporters; + } + }); + + private static Optional getTransportTypeClassifier(Entity entity) { + return visitors.stream().filter(v -> v.isInterestedIn(entity)).findFirst(); + } // endregion Static Helpers } diff --git a/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java b/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java index f9d373fc64..d421fb0a19 100644 --- a/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java +++ b/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java @@ -19,7 +19,6 @@ package mekhq.gui.menus; -import megamek.common.*; import mekhq.campaign.Campaign; import mekhq.campaign.enums.CampaignTransportType; import mekhq.campaign.unit.Unit; @@ -32,7 +31,6 @@ import java.awt.event.ActionEvent; import java.util.HashSet; import java.util.Set; -import java.util.stream.Stream; /** * Generic menu for displaying transports for the units in the force selected (or an individual unit). @@ -56,7 +54,7 @@ public abstract class AssignForceToTransportMenu extends JScrollableMenu { * @see CampaignTransportType */ public AssignForceToTransportMenu(CampaignTransportType campaignTransportType, final Campaign campaign, final Set units) { - super(campaignTransportType.getName()); + super(campaignTransportType.name()); this.campaign = campaign; this.campaignTransportType = campaignTransportType; initialize(units); @@ -81,7 +79,7 @@ private void initialize(final Set units) { } //Assign Unit to {campaignTransportTypeName} - setText(MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AssignForceToTransportMenu." + campaignTransportType.getName() + ".text")); + setText(MHQInternationalization.getTextAt("mekhq.resources.AssignForceToTransport", "AssignForceToTransportMenu." + campaignTransportType.name() + ".text")); for (JScrollableMenu transporterTypeMenu : transporterTypeMenus) { add(transporterTypeMenu); }