mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Fixed tooltips not displayed for tokens.
This commit is contained in:
parent
8e788f3b32
commit
78bc920ba7
2 changed files with 116 additions and 113 deletions
|
@ -93,7 +93,7 @@ public class CardView implements Serializable {
|
||||||
this.manaCost = card.getManaCost().getSymbols();
|
this.manaCost = card.getManaCost().getSymbols();
|
||||||
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
this.convertedManaCost = card.getManaCost().convertedManaCost();
|
||||||
if (card instanceof PermanentToken) {
|
if (card instanceof PermanentToken) {
|
||||||
this.rarity = Rarity.NA;
|
this.rarity = Rarity.COMMON;
|
||||||
} else {
|
} else {
|
||||||
this.rarity = card.getRarity();
|
this.rarity = card.getRarity();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.mage.plugins.card.info;
|
||||||
|
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
import mage.components.CardInfoPane;
|
import mage.components.CardInfoPane;
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.utils.CardUtil;
|
import mage.utils.CardUtil;
|
||||||
import mage.utils.ThreadUtils;
|
import mage.utils.ThreadUtils;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
|
@ -39,30 +38,31 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
|
|
||||||
ThreadUtils.threadPool.submit(new Runnable() {
|
ThreadUtils.threadPool.submit(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!card.equals(currentCard)) return;
|
|
||||||
|
|
||||||
String manaCost = "";
|
|
||||||
for (String m : card.getManaCost()) {
|
|
||||||
manaCost += m;
|
|
||||||
}
|
|
||||||
String castingCost = UI.getDisplayManaCost(manaCost);
|
|
||||||
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false);
|
|
||||||
|
|
||||||
int symbolCount = 0;
|
|
||||||
int offset = 0;
|
|
||||||
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0)
|
|
||||||
symbolCount++;
|
|
||||||
|
|
||||||
List<String> rules = card.getRules();
|
|
||||||
List<String> rulings = new ArrayList<String>(rules);
|
|
||||||
try {
|
try {
|
||||||
|
if (!card.equals(currentCard)) return;
|
||||||
|
|
||||||
|
String manaCost = "";
|
||||||
|
for (String m : card.getManaCost()) {
|
||||||
|
manaCost += m;
|
||||||
|
}
|
||||||
|
String castingCost = UI.getDisplayManaCost(manaCost);
|
||||||
|
castingCost = ManaSymbols.replaceSymbolsWithHTML(castingCost, false);
|
||||||
|
|
||||||
|
int symbolCount = 0;
|
||||||
|
int offset = 0;
|
||||||
|
while ((offset = castingCost.indexOf("<img", offset) + 1) != 0)
|
||||||
|
symbolCount++;
|
||||||
|
|
||||||
|
List<String> rules = card.getRules();
|
||||||
|
List<String> rulings = new ArrayList<String>(rules);
|
||||||
|
|
||||||
if (card instanceof PermanentView) {
|
if (card instanceof PermanentView) {
|
||||||
List<CounterView> counters = ((PermanentView)card).getCounters();
|
List<CounterView> counters = ((PermanentView) card).getCounters();
|
||||||
int count = counters != null ? counters.size() : 0;
|
int count = counters != null ? counters.size() : 0;
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (CounterView counter: ((PermanentView)card).getCounters()) {
|
for (CounterView counter : ((PermanentView) card).getCounters()) {
|
||||||
if (counter.getCount() > 0) {
|
if (counter.getCount() > 0) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
sb.append("<b>Counters:</b> ");
|
sb.append("<b>Counters:</b> ");
|
||||||
|
@ -76,102 +76,105 @@ public class CardInfoPaneImpl extends JEditorPane implements CardInfoPane {
|
||||||
rulings.add(sb.toString());
|
rulings.add(sb.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boolean smallImages = true;
|
||||||
|
int fontSize = 11;
|
||||||
|
|
||||||
|
String fontFamily = "tahoma";
|
||||||
|
/*if (prefs.fontFamily == CardFontFamily.arial)
|
||||||
|
fontFamily = "arial";
|
||||||
|
else if (prefs.fontFamily == CardFontFamily.verdana) {
|
||||||
|
fontFamily = "verdana";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
final StringBuffer buffer = new StringBuffer(512);
|
||||||
|
buffer.append("<html><body style='font-family:");
|
||||||
|
buffer.append(fontFamily);
|
||||||
|
buffer.append(";font-size:");
|
||||||
|
buffer.append(fontSize);
|
||||||
|
buffer.append("pt;margin:0px 1px 0px 1px'>");
|
||||||
|
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
||||||
|
buffer.append("<tr><td valign='top'><b>");
|
||||||
|
buffer.append(card.getName());
|
||||||
|
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
||||||
|
buffer.append(symbolCount * 11 + 1);
|
||||||
|
buffer.append("px'>");
|
||||||
|
buffer.append(castingCost);
|
||||||
|
buffer.append("</td></tr></table>");
|
||||||
|
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
|
||||||
|
buffer.append(getTypes(card));
|
||||||
|
buffer.append("</td><td align='right'>");
|
||||||
|
switch (card.getRarity()) {
|
||||||
|
case RARE:
|
||||||
|
buffer.append("<b color='#FFBF00'>");
|
||||||
|
break;
|
||||||
|
case UNCOMMON:
|
||||||
|
buffer.append("<b color='silver'>");
|
||||||
|
break;
|
||||||
|
case COMMON:
|
||||||
|
buffer.append("<b color='black'>");
|
||||||
|
break;
|
||||||
|
case MYTHIC:
|
||||||
|
buffer.append("<b color='#D5330B'>");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String rarity = card.getRarity().getCode();
|
||||||
|
if (card.getExpansionSetCode() != null) {
|
||||||
|
buffer.append(ManaSymbols.replaceSetCodeWithHTML(card.getExpansionSetCode().toUpperCase(), rarity));
|
||||||
|
}
|
||||||
|
buffer.append("</td></tr></table>");
|
||||||
|
|
||||||
|
String pt = "";
|
||||||
|
if (CardUtil.isCreature(card)) {
|
||||||
|
pt = card.getPower() + "/" + card.getToughness();
|
||||||
|
} else if (CardUtil.isPlaneswalker(card)) {
|
||||||
|
pt = card.getLoyalty().toString();
|
||||||
|
}
|
||||||
|
if (pt.length() > 0) {
|
||||||
|
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%' valign='bottom'><tr><td>");
|
||||||
|
buffer.append("<b>");
|
||||||
|
buffer.append(pt);
|
||||||
|
buffer.append("</b>");
|
||||||
|
buffer.append("</td></tr></table>");
|
||||||
|
}
|
||||||
|
|
||||||
|
String legal = "";
|
||||||
|
if (rulings.size() > 0) {
|
||||||
|
legal = legal.replaceAll("#([^#]+)#", "<i>$1</i>");
|
||||||
|
legal = legal.replaceAll("\\s*//\\s*", "<hr width='50%'>");
|
||||||
|
legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
|
||||||
|
legal += "<br>";
|
||||||
|
for (String ruling : rulings) {
|
||||||
|
legal += "<p style='margin: 2px'>";
|
||||||
|
legal += ruling;
|
||||||
|
legal += "</p>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (legal.length() > 0) {
|
||||||
|
//buffer.append("<br>");
|
||||||
|
legal = legal.replaceAll("\\{this\\}", card.getName());
|
||||||
|
legal = legal.replaceAll("\\{source\\}", card.getName());
|
||||||
|
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, smallImages));
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.append("<br></body></html>");
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
if (!card.equals(currentCard)) return;
|
||||||
|
setText(buffer.toString());
|
||||||
|
//System.out.println(buffer.toString());
|
||||||
|
setCaretPosition(0);
|
||||||
|
//ThreadUtils.sleep(300);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean smallImages = true;
|
|
||||||
int fontSize = 11;
|
|
||||||
|
|
||||||
String fontFamily = "tahoma";
|
|
||||||
/*if (prefs.fontFamily == CardFontFamily.arial)
|
|
||||||
fontFamily = "arial";
|
|
||||||
else if (prefs.fontFamily == CardFontFamily.verdana) {
|
|
||||||
fontFamily = "verdana";
|
|
||||||
}*/
|
|
||||||
|
|
||||||
final StringBuffer buffer = new StringBuffer(512);
|
|
||||||
buffer.append("<html><body style='font-family:");
|
|
||||||
buffer.append(fontFamily);
|
|
||||||
buffer.append(";font-size:");
|
|
||||||
buffer.append(fontSize);
|
|
||||||
buffer.append("pt;margin:0px 1px 0px 1px'>");
|
|
||||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'>");
|
|
||||||
buffer.append("<tr><td valign='top'><b>");
|
|
||||||
buffer.append(card.getName());
|
|
||||||
buffer.append("</b></td><td align='right' valign='top' style='width:");
|
|
||||||
buffer.append(symbolCount * 11 + 1);
|
|
||||||
buffer.append("px'>");
|
|
||||||
buffer.append(castingCost);
|
|
||||||
buffer.append("</td></tr></table>");
|
|
||||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%'><tr><td style='margin-left: 1px'>");
|
|
||||||
buffer.append(getTypes(card));
|
|
||||||
buffer.append("</td><td align='right'>");
|
|
||||||
switch (card.getRarity()) {
|
|
||||||
case RARE:
|
|
||||||
buffer.append("<b color='#FFBF00'>");
|
|
||||||
break;
|
|
||||||
case UNCOMMON:
|
|
||||||
buffer.append("<b color='silver'>");
|
|
||||||
break;
|
|
||||||
case COMMON:
|
|
||||||
buffer.append("<b color='black'>");
|
|
||||||
break;
|
|
||||||
case MYTHIC:
|
|
||||||
buffer.append("<b color='#D5330B'>");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
String rarity = card.getRarity().getCode();
|
|
||||||
buffer.append(ManaSymbols.replaceSetCodeWithHTML(card.getExpansionSetCode().toUpperCase(), rarity));
|
|
||||||
buffer.append("</td></tr></table>");
|
|
||||||
|
|
||||||
String pt = "";
|
|
||||||
if (CardUtil.isCreature(card)) {
|
|
||||||
pt = card.getPower() + "/" + card.getToughness();
|
|
||||||
} else if (CardUtil.isPlaneswalker(card)) {
|
|
||||||
pt = card.getLoyalty().toString();
|
|
||||||
}
|
|
||||||
if (pt.length() > 0) {
|
|
||||||
buffer.append("<table cellspacing=0 cellpadding=0 border=0 width='100%' valign='bottom'><tr><td>");
|
|
||||||
buffer.append("<b>");
|
|
||||||
buffer.append(pt);
|
|
||||||
buffer.append("</b>");
|
|
||||||
buffer.append("</td></tr></table>");
|
|
||||||
}
|
|
||||||
|
|
||||||
String legal = "";
|
|
||||||
if (rulings.size() > 0) {
|
|
||||||
legal = legal.replaceAll("#([^#]+)#", "<i>$1</i>");
|
|
||||||
legal = legal.replaceAll("\\s*//\\s*", "<hr width='50%'>");
|
|
||||||
legal = legal.replace("\r\n", "<div style='font-size:5pt'></div>");
|
|
||||||
legal += "<br>";
|
|
||||||
for (String ruling : rulings) {
|
|
||||||
legal += "<p style='margin: 2px'>";
|
|
||||||
legal += ruling;
|
|
||||||
legal += "</p>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (legal.length() > 0) {
|
|
||||||
//buffer.append("<br>");
|
|
||||||
legal = legal.replaceAll("\\{this\\}", card.getName());
|
|
||||||
legal = legal.replaceAll("\\{source\\}", card.getName());
|
|
||||||
buffer.append(ManaSymbols.replaceSymbolsWithHTML(legal, smallImages));
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.append("<br></body></html>");
|
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (!card.equals(currentCard)) return;
|
|
||||||
setText(buffer.toString());
|
|
||||||
//System.out.println(buffer.toString());
|
|
||||||
setCaretPosition(0);
|
|
||||||
//ThreadUtils.sleep(300);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue