From ac6b7f181af396fc6abfdf5890f4f87917e4dca6 Mon Sep 17 00:00:00 2001 From: asvitkine Date: Tue, 25 Jul 2023 00:50:28 -0400 Subject: [PATCH] Improve message box text when not able to place sea units. (#11813) * Improve message box text when not able to place sea units. * Formatting. --- .../triplea/delegate/AbstractPlaceDelegate.java | 11 ++++------- .../java/games/strategy/triplea/ui/PlacePanel.java | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java index 88252155560..532c6deb399 100644 --- a/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java +++ b/game-app/game-core/src/main/java/games/strategy/triplea/delegate/AbstractPlaceDelegate.java @@ -612,18 +612,15 @@ protected String canProduce( if (errorP != null) { failingProducers.add(producer); // do not include the error for same territory, if water, because users do not want to see - // this error report for - // 99.9% of games + // this error report for 99.9% of games if (!(producer.equals(to) && producer.isWater())) { - error.append(", ").append(errorP); + error.append(errorP).append(".\n"); } } } if (producers.size() == failingProducers.size()) { - return "Adjacent territories to " - + to.getName() - + " cannot produce, due to: \n " - + error.toString().replaceFirst(", ", ""); + return String.format( + "Adjacent territories to %s cannot produce because:\n\n%s", to.getName(), error); } return null; } diff --git a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java index 10115eb8eb2..521b950778e 100644 --- a/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java +++ b/game-app/game-headed/src/main/java/games/strategy/triplea/ui/PlacePanel.java @@ -243,8 +243,8 @@ private PlaceableUnits getUnitsToPlace(final Territory territory) { if (production.isError()) { JOptionPane.showMessageDialog( getTopLevelAncestor(), - production.getErrorMessage(), - "No units", + production.getErrorMessage() + "\n\n", + "Cannot produce units", JOptionPane.INFORMATION_MESSAGE); } return production;