Skip to content

Commit

Permalink
Fonts for CounterDetailViewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent committed Sep 15, 2023
1 parent e28e44b commit 137c641
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
30 changes: 26 additions & 4 deletions vassal-app/src/main/java/VASSAL/build/module/PlayerRoster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -358,6 +360,18 @@ public List<String> getSides() {
return new ArrayList<>(sides);
}

public List<String> 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)
Expand Down Expand Up @@ -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)
*/
Expand Down Expand Up @@ -757,7 +778,8 @@ public List<String> getAvailableSides() {
}

protected String promptForSide() {
final ArrayList<String> availableSides = new ArrayList<>(sides);
// availableSides and alreadyTaken are Translated side names
final ArrayList<String> availableSides = new ArrayList<>(getSides());
final ArrayList<String> alreadyTaken = new ArrayList<>();

for (final PlayerInfo p : players) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 137c641

Please sign in to comment.