diff --git a/vassal-app/src/main/java/VASSAL/build/module/ChessClockControl.java b/vassal-app/src/main/java/VASSAL/build/module/ChessClockControl.java index 5f0da93290..b47100985f 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/ChessClockControl.java +++ b/vassal-app/src/main/java/VASSAL/build/module/ChessClockControl.java @@ -196,7 +196,7 @@ public void build(Element e) { final PlayerRoster r = GameModule.getGameModule().getPlayerRoster(); int added = 0; if (r != null) { - for (final String s : r.sides) { + for (final String s : r.getUntranslatedSideList()) { if (!r.isSoloSide(s)) { addChild(new ChessClock(s)); added++; diff --git a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java index e496c2e3db..04de2070e8 100644 --- a/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java +++ b/vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java @@ -320,10 +320,12 @@ protected static PlayerRoster getInstance() { return GameModule.getGameModule().getPlayerRoster(); } + /** Return my Untranslatted side */ public static String getMySide() { return getMySide(false); } + /** Return my Translated Side */ public static String getMyLocalizedSide() { return getMySide(true); } @@ -358,6 +360,18 @@ public List getSides() { return new ArrayList<>(sides); } + public List getUntranslatedSideList() { + return Arrays.asList(getUntranslatedSides()); + } + + public String[] getUntranslatedSides() { + // If the module is loaded in the editor, the module translation step does not run, so the untranslated side + // list will not have been set + if (untranslatedSides == null) { + untranslatedSides = sides.toArray(new String[0]); + } + return untranslatedSides; + } /** * Adds a player to the list of active players occupying sides * @param playerId player unique id (password) @@ -624,13 +638,20 @@ protected boolean allSidesAllocated() { * @param side Name of a side to see if it's a "solo side" * @return True if the side is "Solitaire", "Solo", "Moderator", or "Referee" */ - public static boolean isSoloSide(String side) { + public static boolean isTranslatedSoloSide(String side) { return Resources.getString("PlayerRoster.solitaire").equals(side) || Resources.getString("PlayerRoster.solo").equals(side) || Resources.getString("PlayerRoster.moderator").equals(side) || Resources.getString("PlayerRoster.referee").equals(side); } + public static boolean isSoloSide(String side) { + return SOLITAIRE.equals(side) || + SOLO.equals(side) || + MODERATOR.equals(side) || + REFEREE.equals(side); + } + /** * @return True if this is currently a multiPlayer game (either connected to a server, or more than one player side allocated) */ @@ -757,7 +778,8 @@ public List getAvailableSides() { } protected String promptForSide() { - final ArrayList availableSides = new ArrayList<>(sides); + // availableSides and alreadyTaken are Translated side names + final ArrayList availableSides = new ArrayList<>(getSides()); final ArrayList alreadyTaken = new ArrayList<>(); for (final PlayerInfo p : players) { @@ -771,12 +793,12 @@ protected String promptForSide() { // Common names for Solitaire players (Solitaire, Solo, Referee) do not count as "real" player sides, and will be skipped. // If we have no "next" side available to offer, we stay with the observer side as our default offering. boolean found = false; // If we find a usable side - final String mySide = translateSide(getMySide()); // Get our own side, so we can find the "next" one + final String mySide = getMyLocalizedSide(); // Get our own side, so we can find the "next" one final int myidx = (mySide != null) ? sides.indexOf(mySide) : -1; // See if we have a current non-observe side. int i = (myidx >= 0) ? ((myidx + 1) % sides.size()) : 0; // If we do, start looking in the "next" slot, otherwise start at beginning. for (int tries = 0; i != myidx && tries < sides.size(); i = (i + 1) % sides.size(), tries++) { // Wrap-around search of sides final String s = sides.get(i); - if (!alreadyTaken.contains(s) && !isSoloSide(s)) { + if (!alreadyTaken.contains(s) && !isSoloSide(untranslateSide(s))) { found = true; // Found an available slot that's not our current one and not a "solo" slot. break; }