make color names translatable for displaying in UI.

master
lodici 2016-02-11 21:36:21 +00:00
parent 120905aed9
commit e9efece076
4 changed files with 36 additions and 11 deletions

View File

@ -5,14 +5,15 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.EnumSet;
import magic.translate.UiString;
public enum MagicColor {
White("white",'w'),
Blue("blue",'u'),
Black("black",'b'),
Red("red",'r'),
Green("green",'g')
White(MagicColorStrings._S1, 'w'),
Blue(MagicColorStrings._S2, 'u'),
Black(MagicColorStrings._S3, 'b'),
Red(MagicColorStrings._S4, 'r'),
Green(MagicColorStrings._S5, 'g')
;
public static final int NR_COLORS=values().length;
@ -20,11 +21,20 @@ public enum MagicColor {
private final String name;
private final char symbol;
private final int mask;
private final String displayName;
private MagicColor(final String name,final char symbol) {
this.name=name;
this.symbol=symbol;
this.mask=1<<ordinal();
private MagicColor(final String name, final char symbol) {
this.name = name;
this.symbol = symbol;
this.mask = 1 << ordinal();
this.displayName = UiString.get(name);
}
/**
* Translatable color name.
*/
public String getDisplayName() {
return displayName;
}
public String getName() {

View File

@ -0,0 +1,15 @@
package magic.model;
/**
* Translatable strings used by MagicColor enum.
*/
final class MagicColorStrings {
private MagicColorStrings() {}
// do not change case - see MagicColor.getName() usage.
static final String _S1 = "white";
static final String _S2 = "blue";
static final String _S3 = "black";
static final String _S4 = "red";
static final String _S5 = "green";
}

View File

@ -119,7 +119,7 @@ public class DuelPlayerDeckPanel extends TexturedPanel implements IThemeStyle {
private String getVerboseColors(final String colorCodes) {
String colors = "";
for (char ch: colorCodes.toCharArray()) {
colors += MagicColor.getColor(ch).name() + ", ";
colors += MagicColor.getColor(ch).getDisplayName() + ", ";
}
return colors.trim().substring(0, colors.trim().length() - 1);
}

View File

@ -62,7 +62,7 @@ public class PlayerStatsViewerInfo implements IPlayerStatsViewerInfo {
@Override
public String getMostUsedColor() {
return stats.getMostUsedColor().getName();
return stats.getMostUsedColor().getDisplayName();
}
}