mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Fixed set codes and mana symbols in pay and tooltips.
This commit is contained in:
parent
4fad2ede12
commit
818d601cbb
3 changed files with 35 additions and 10 deletions
|
|
@ -31,7 +31,6 @@ public class MageTextArea extends JEditorPane {
|
|||
public void setText(String text, CardView source) {
|
||||
if (text == null) return;
|
||||
|
||||
boolean smallImages = false;
|
||||
int fontSize = 16;
|
||||
|
||||
String fontFamily = "arial";
|
||||
|
|
@ -52,7 +51,7 @@ public class MageTextArea extends JEditorPane {
|
|||
//buffer.append("<br>");
|
||||
//text = text.replaceAll("\\{this\\}", card.getName());
|
||||
//text = text.replaceAll("\\{source\\}", card.getName());
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, smallImages));
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(text, ManaSymbols.Type.PAY));
|
||||
}
|
||||
|
||||
buffer.append("</b></center></body></html>");
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class ManaSymbols {
|
|||
int height = image.getHeight(null);
|
||||
if (height > 0) {
|
||||
int dx = 0;
|
||||
if (set.equals("M10") || set.equals("M11")) {
|
||||
if (set.equals("M10") || set.equals("M11") || set.equals("M12")) {
|
||||
dx = 6;
|
||||
}
|
||||
Rectangle r = new Rectangle(15 + dx, (int) (height * (15.0f + dx) / width));
|
||||
|
|
@ -104,6 +104,22 @@ public class ManaSymbols {
|
|||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
File file;
|
||||
for (String set : CardsStorage.getSetCodes()) {
|
||||
file = new File(Constants.RESOURCE_PATH_SET_SMALL);
|
||||
if (!file.exists()) {
|
||||
break;
|
||||
}
|
||||
file = new File(Constants.RESOURCE_PATH_SET_SMALL + set + "-C.png");
|
||||
try {
|
||||
Image image = UI.getImageIcon(file.getAbsolutePath()).getImage();
|
||||
int width = image.getWidth(null);
|
||||
int height = image.getHeight(null);
|
||||
setImagesExist.put(set, new Dimension(width, height));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static public Image getManaSymbolImage(String symbol) {
|
||||
|
|
@ -148,13 +164,23 @@ public class ManaSymbols {
|
|||
return width;
|
||||
}
|
||||
|
||||
static public synchronized String replaceSymbolsWithHTML(String value, boolean small) {
|
||||
if (small) {
|
||||
public enum Type {
|
||||
CARD,
|
||||
TOOLTIP,
|
||||
PAY
|
||||
}
|
||||
|
||||
static public synchronized String replaceSymbolsWithHTML(String value, Type type) {
|
||||
if (type.equals(Type.TOOLTIP)) {
|
||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/small/$1$2.jpg' alt='$1$2' width=11 height=11>");
|
||||
} else {
|
||||
value = value.replace("{slash}", "<img src='file:plugins/images/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/medium/$1$2.jpg' alt='$1$2' width=13 height=13>");
|
||||
} else if (type.equals(Type.CARD)) {
|
||||
value = value.replace("{slash}", "<img src='file:plugins/images/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/medium/$1$2.jpg' alt='$1$2' width=12 height=12>");
|
||||
} else if (type.equals(Type.PAY)) {
|
||||
value = value.replace("{slash}", "<img src='file:plugins/images/symbols/medium/slash.jpg' alt='slash' width=10 height=13>");
|
||||
return replaceSymbolsPattern.matcher(value).replaceAll("<img src='file:plugins/images/symbols/medium/$1$2.jpg' alt='$1$2' width=15 height=15>");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
static public String replaceSetCodeWithHTML(String set, String rarity) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
|||
manaCost += m;
|
||||
}
|
||||
String castingCost = UI.getDisplayManaCost(manaCost);
|
||||
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false);
|
||||
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, ManaSymbols.Type.CARD);
|
||||
|
||||
int symbolCount = 0;
|
||||
int offset = 0;
|
||||
|
|
@ -162,7 +162,7 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
|||
//buffer.append("<br>");
|
||||
legal = legal.replaceAll("\\{this\\}", card.getName());
|
||||
legal = legal.replaceAll("\\{source\\}", card.getName());
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, smallImages));
|
||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, ManaSymbols.Type.CARD));
|
||||
}
|
||||
|
||||
buffer.append("<br></body></html>");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue