Tweak logic for formatting reminder text in italics

This commit is contained in:
drdev
2013-11-23 06:39:42 +00:00
parent b2ecb3cb52
commit 800b3f8272

View File

@@ -626,25 +626,25 @@ public enum FSkin {
c.getBlue() * c.getBlue() * 0.068); c.getBlue() * c.getBlue() * 0.068);
return v >= 130; return v >= 130;
} }
public static Color getHighContrastColor(Color c) { public static Color getHighContrastColor(Color c) {
return isColorBright(c) ? Color.BLACK : Color.WHITE; return isColorBright(c) ? Color.BLACK : Color.WHITE;
} }
public static class SkinColor { public static class SkinColor {
private static final HashMap<Colors, SkinColor> baseColors = new HashMap<Colors, SkinColor>(); private static final HashMap<Colors, SkinColor> baseColors = new HashMap<Colors, SkinColor>();
private static final HashMap<String, SkinColor> derivedColors = new HashMap<String, SkinColor>(); private static final HashMap<String, SkinColor> derivedColors = new HashMap<String, SkinColor>();
private static final int NO_BRIGHTNESS_DELTA = 0; private static final int NO_BRIGHTNESS_DELTA = 0;
private static final int NO_STEP = -999; //needs to be large negative since small negative values are valid private static final int NO_STEP = -999; //needs to be large negative since small negative values are valid
private static final int NO_ALPHA = -1; private static final int NO_ALPHA = -1;
private final Colors baseColor; private final Colors baseColor;
private final int brightnessDelta; private final int brightnessDelta;
private final int step; private final int step;
private final int contrastStep; private final int contrastStep;
private final int alpha; private final int alpha;
protected Color color; protected Color color;
public Color getColor() { return color; } public Color getColor() { return color; }
//private constructors for color that changes with skin (use FSkin.getColor()) //private constructors for color that changes with skin (use FSkin.getColor())
@@ -1654,15 +1654,20 @@ public enum FSkin {
} }
public static String encodeSymbols(String str) { public static String encodeSymbols(String str) {
String pattern = "\\{([A-Z0-9]+)\\}|\\{([A-Z0-9]+)/([A-Z0-9]+)\\}"; //fancy pattern needed so "/" can be omitted from replacement //format reminder text in italics
String replacement; String pattern = "\\((.+)\\)";
String replacement = "<i>\\($1\\)</i>"; //TODO: Consider setting to hide reminder text, in which case replace with "" here
str = str.replaceAll(pattern, replacement);
//format mana symbols to display as icons
pattern = "\\{([A-Z0-9]+)\\}|\\{([A-Z0-9]+)/([A-Z0-9]+)\\}"; //fancy pattern needed so "/" can be omitted from replacement
try { try {
replacement = "<img src='" + new File(NewConstants.CACHE_SYMBOLS_DIR + "/$1$2$3.png").toURI().toURL().toString() + "'>"; replacement = "<img src='" + new File(NewConstants.CACHE_SYMBOLS_DIR + "/$1$2$3.png").toURI().toURL().toString() + "'>";
str = str.replaceAll(pattern, replacement); str = str.replaceAll(pattern, replacement);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
} }
str = str.replace("(", "<i>(").replace(")", ")</i>"); //format reminder text in italics
return "<html>" + str + "</html>"; //must wrap in <html> tag for images to appear return "<html>" + str + "</html>"; //must wrap in <html> tag for images to appear
} }
@@ -1876,7 +1881,7 @@ public enum FSkin {
FSkin.bimPreferredSprite = null; FSkin.bimPreferredSprite = null;
FSkin.bimDefaultAvatars = null; FSkin.bimDefaultAvatars = null;
FSkin.bimPreferredAvatars = null; FSkin.bimPreferredAvatars = null;
//establish encoding symbols //establish encoding symbols
File dir = new File(NewConstants.CACHE_SYMBOLS_DIR); File dir = new File(NewConstants.CACHE_SYMBOLS_DIR);
if (!dir.mkdir()) { //ensure symbols directory exists and is empty if (!dir.mkdir()) { //ensure symbols directory exists and is empty