From e4088531dd004c39e707fe46450bcd0219a883b7 Mon Sep 17 00:00:00 2001 From: psikomonkie <189469115+psikomonkie@users.noreply.github.com> Date: Thu, 9 Jan 2025 12:14:56 -0500 Subject: [PATCH] Issue 3650: Updating & Adding Internationalization Keys & Messages --- .../mekhq/resources/AssignForceToTransport.properties | 8 ++++++++ MekHQ/src/mekhq/AtBGameThread.java | 5 +++-- MekHQ/src/mekhq/campaign/Campaign.java | 4 ++-- .../campaign/unit/TacticalTransportedUnitsSummary.java | 8 +------- MekHQ/src/mekhq/campaign/unit/TransportAssignment.java | 4 +--- MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java | 5 +++-- .../mekhq/gui/menus/AssignForceToShipTransportMenu.java | 6 ++++-- .../gui/menus/AssignForceToTacticalTransportMenu.java | 6 ++++-- MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java | 4 +++- 9 files changed, 29 insertions(+), 21 deletions(-) diff --git a/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties b/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties index c3d5e313ef..252a8f454f 100644 --- a/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties +++ b/MekHQ/resources/mekhq/resources/AssignForceToTransport.properties @@ -1,4 +1,5 @@ AssignForceToTransportMenu.transportSpaceRemaining.text={0} | Space Remaining: {1} + AssignForceToTransportMenu.TACTICAL_TRANSPORT.text=Assign Force to Tactical Transport AssignForceToTransportMenu.SHIP_TRANSPORT.text=Assign Force to Ship Transport AssignForceToTransportMenu.ASFBay.text=ASF Bay @@ -19,3 +20,10 @@ AssignForceToTransportMenu.ClampMountTank.text=Clamp Mount Tank AssignForceToTransportMenu.ProtoMekClampMount=ProtoMek Clamp Mount AssignForceToTransportMenu.DockingCollar=Docking Collar AssignForceToTransportMenu.TrailerHitch=Trailer Hitch + +TOEMouseAdapter.unassign.TACTICAL_TRANSPORT.text=Unassign Force from Tactical Transport +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? + diff --git a/MekHQ/src/mekhq/AtBGameThread.java b/MekHQ/src/mekhq/AtBGameThread.java index ee2c548066..c0f8938f29 100644 --- a/MekHQ/src/mekhq/AtBGameThread.java +++ b/MekHQ/src/mekhq/AtBGameThread.java @@ -38,6 +38,7 @@ import mekhq.campaign.unit.TransportAssignment; import mekhq.campaign.unit.TransportShipAssignment; import mekhq.campaign.unit.Unit; +import mekhq.utilities.Internationalization; import javax.swing.*; import java.io.File; @@ -488,8 +489,8 @@ public void run() { if (transport.hasTacticalTransportedUnits()) { loadTactical = (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null, - String.format(AtBGameThread.LOAD_GND_DIALOG_TEXT, transport.getName()), - AtBGameThread.LOAD_GND_DIALOG_TITLE, JOptionPane.YES_NO_OPTION)); + Internationalization.getFormattedTextAt("AssignForceToTransport", "AtBGameThread.loadTransportDialog.TACTICAL_TRANSPORT.text", transport.getName()), + Internationalization.getFormattedTextAt("AssignForceToTransport", "AtBGameThread.loadTransportDialog.TACTICAL_TRANSPORT.title"), JOptionPane.YES_NO_OPTION)); } // Now, send the load commands diff --git a/MekHQ/src/mekhq/campaign/Campaign.java b/MekHQ/src/mekhq/campaign/Campaign.java index 7a9874bc0d..a65ee7d226 100644 --- a/MekHQ/src/mekhq/campaign/Campaign.java +++ b/MekHQ/src/mekhq/campaign/Campaign.java @@ -1430,9 +1430,9 @@ public void removeShipTransporter(Unit unit) { } /** - * Deletes an entry from the list of transit-capable transport ships. This gets + * Deletes an entry from the list of transit-capable transport units. This gets * updated when - * the ship is removed from the campaign for one reason or another + * the unit is removed from the campaign for one reason or another * * @param unit - The ship we want to remove from this Set */ diff --git a/MekHQ/src/mekhq/campaign/unit/TacticalTransportedUnitsSummary.java b/MekHQ/src/mekhq/campaign/unit/TacticalTransportedUnitsSummary.java index 42de649e53..90d1ab02f6 100644 --- a/MekHQ/src/mekhq/campaign/unit/TacticalTransportedUnitsSummary.java +++ b/MekHQ/src/mekhq/campaign/unit/TacticalTransportedUnitsSummary.java @@ -123,13 +123,7 @@ else if (transporterType != null){ } addTransportedUnit(Objects.requireNonNull(transportedUnit)); - //if ((transportedUnit.getEntity() != null)) { - // if (transport.getEntity() != null) { - // loadEntity(transportedUnit.getEntity()); - // } - //} - - // If the old transport was TODO + // Update Transport Capacities if (!Objects.equals(oldTransport, transport) && (transportedUnit.getTacticalTransportAssignment().getTransporterType() != oldTransporterType)) { setCurrentTransportCapacity(transporterType, diff --git a/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java b/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java index 144d37a2ff..27da7753cb 100644 --- a/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java +++ b/MekHQ/src/mekhq/campaign/unit/TransportAssignment.java @@ -132,11 +132,9 @@ public void fixReferences(Campaign campaign, Unit unit) { if (transport != null) { if (hasTransportedLocation()) { setTransport(transport); - //setTransportedLocation(getTransportedLocation()); - //setTransporterType(hasTransportedLocation() ? getTransportedLocation().getClass() : null); + } else if (hasTransporterType()) { setTransport(transport); - //setTransporterType(getTransporterType()); } else { setTransport(transport); diff --git a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java index 7ee03bd3b1..dab2b97ba9 100644 --- a/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java +++ b/MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java @@ -51,6 +51,7 @@ import mekhq.gui.menus.ExportUnitSpriteMenu; import mekhq.gui.utilities.JMenuHelpers; import mekhq.gui.utilities.StaticChecks; +import mekhq.utilities.Internationalization; import javax.swing.*; import javax.swing.tree.TreePath; @@ -1461,7 +1462,7 @@ private void clearTransportAssignment(@Nullable Unit currentUnit) { private void unassignShipTransportMenuClass(Vector units, JPopupMenu popup) { if (units.stream().allMatch(Unit::hasTransportShipAssignment) && !StaticChecks.areAnyUnitsDeployed(units)) { - JMenuItem menuItem = new JMenuItem("Unassign Unit from Transport Ship"); + JMenuItem menuItem = new JMenuItem(Internationalization.getTextAt("AssignForceToTransport", "TOEMouseAdapter.unassign.SHIP_TRANSPORT.text")); menuItem.addActionListener(evt -> { unassignTransportAction(SHIP_TRANSPORT, units.toArray(new Unit[0]));}); menuItem.setEnabled(true); @@ -1471,7 +1472,7 @@ private void unassignShipTransportMenuClass(Vector units, JPopupMenu popup private void unassignTacticalTransportMenuClass(Vector units, JPopupMenu popup) { if (units.stream().allMatch(Unit::hasTacticalTransportAssignment) && !StaticChecks.areAnyUnitsDeployed(units)) { - JMenuItem menuItem = new JMenuItem("Unassign Unit from Tactical Transport"); + JMenuItem menuItem = new JMenuItem(Internationalization.getTextAt("AssignForceToTransport", "TOEMouseAdapter.unassign.TACTICAL_TRANSPORT.text")); menuItem.addActionListener(evt -> { unassignTransportAction(TACTICAL_TRANSPORT, units.toArray(new Unit[0])); }); diff --git a/MekHQ/src/mekhq/gui/menus/AssignForceToShipTransportMenu.java b/MekHQ/src/mekhq/gui/menus/AssignForceToShipTransportMenu.java index ecf7298bf6..0f2b97fdd0 100644 --- a/MekHQ/src/mekhq/gui/menus/AssignForceToShipTransportMenu.java +++ b/MekHQ/src/mekhq/gui/menus/AssignForceToShipTransportMenu.java @@ -4,7 +4,6 @@ import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.event.UnitChangedEvent; -import mekhq.campaign.unit.ShipTransportedUnitsSummary; import mekhq.campaign.unit.Unit; import java.awt.event.ActionEvent; @@ -13,6 +12,9 @@ import static mekhq.campaign.enums.CampaignTransportType.SHIP_TRANSPORT; +/** + * Menu for assigning a unit to a specific Ship Transport + */ public class AssignForceToShipTransportMenu extends AssignForceToTransportMenu { public AssignForceToShipTransportMenu(Campaign campaign, Unit... units) { @@ -42,7 +44,7 @@ protected Set> filterTransporterTypeMenus(final Uni protected void transportMenuAction(ActionEvent evt, Class transporterType, Unit transport, Unit... units) { for (Unit unit : units) { if (!transport.getEntity().canLoad(unit.getEntity(), false)) { - return; //TODO error popup + return; } } diff --git a/MekHQ/src/mekhq/gui/menus/AssignForceToTacticalTransportMenu.java b/MekHQ/src/mekhq/gui/menus/AssignForceToTacticalTransportMenu.java index 8957cc522a..43cb0397fc 100644 --- a/MekHQ/src/mekhq/gui/menus/AssignForceToTacticalTransportMenu.java +++ b/MekHQ/src/mekhq/gui/menus/AssignForceToTacticalTransportMenu.java @@ -4,7 +4,6 @@ import mekhq.MekHQ; import mekhq.campaign.Campaign; import mekhq.campaign.event.UnitChangedEvent; -import mekhq.campaign.unit.TacticalTransportedUnitsSummary; import mekhq.campaign.unit.Unit; import java.awt.event.ActionEvent; @@ -13,6 +12,9 @@ import static mekhq.campaign.enums.CampaignTransportType.TACTICAL_TRANSPORT; +/** + * Menu for assigning a force to a specific Tactical transport + */ public class AssignForceToTacticalTransportMenu extends AssignForceToTransportMenu { public AssignForceToTacticalTransportMenu(Campaign campaign, Unit... units) { @@ -42,7 +44,7 @@ protected Set> filterTransporterTypeMenus(final Uni protected void transportMenuAction(ActionEvent evt, Class transporterType, Unit transport, Unit... units) { for (Unit unit : units) { if (!transport.getEntity().canLoad(unit.getEntity(), false)) { - return; //TODO error popup + return; } } diff --git a/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java b/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java index cb6e0c4c29..1ed7b18262 100644 --- a/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java +++ b/MekHQ/src/mekhq/gui/menus/AssignForceToTransportMenu.java @@ -13,6 +13,9 @@ 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) + */ public abstract class AssignForceToTransportMenu extends JScrollableMenu { final Campaign campaign; @@ -70,7 +73,6 @@ calculation methods (an infantry and tank were both selected) Set transports = campaign.getTransportsByType(campaignTransportType, transporterType, requiredTransportCapacity); if (!transports.isEmpty()) { - //TODO JScrollableMenu transporterTypeMenu = new JScrollableMenu(transporterType.getName(), transporterType.getName()); Set transportMenus = createTransportMenus(transporterType, transports, units); for (JMenuItem transportMenu : transportMenus) {