Skip to content

Commit

Permalink
Improve message box text when not able to place sea units. (#11813)
Browse files Browse the repository at this point in the history
* Improve message box text when not able to place sea units.

* Formatting.
  • Loading branch information
asvitkine committed Jul 25, 2023
1 parent caf296c commit ac6b7f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ac6b7f1

Please sign in to comment.