Make ability menu items consistent regardless of containing mana symbol icons and make them respect menu item height

This commit is contained in:
drdev
2013-11-15 09:40:47 +00:00
parent 8d79ed527f
commit ae5cb7a17a
2 changed files with 6 additions and 7 deletions

View File

@@ -109,7 +109,10 @@ public final class GuiUtils {
} }
public static JMenuItem createMenuItem(String label, KeyStroke accelerator, final Runnable onClick, boolean enabled, boolean bold) { public static JMenuItem createMenuItem(String label, KeyStroke accelerator, final Runnable onClick, boolean enabled, boolean bold) {
JMenuItem item = new JMenuItem(label); if (label.startsWith("<html>")) { //adjust label if HTML
label = "<html>" + "<div style='height: " + itemHeight + "px; margin-top: 6px;'>" + label.substring(6, label.length() - 7) + "</div></html>";
}
JMenuItem item = new JMenuItem(label);
item.addActionListener(new ActionListener() { item.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {

View File

@@ -1657,15 +1657,11 @@ public enum FSkin {
String replacement; String 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);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
return str;
} }
String encodedStr = str.replaceAll(pattern, replacement); return "<html>" + str + "</html>"; //must wrap in <html> tag for images to appear
if (encodedStr.length() != str.length()) {
encodedStr = "<html>" + encodedStr + "</html>"; //need to wrap in HTML tags to ensure text rendered as HTML so symbols appear
}
return encodedStr;
} }
private static final String private static final String