* Fixed that the render frame of copies of normal cards got the normal card rule box size.

This commit is contained in:
LevelX2 2017-01-19 23:50:20 +01:00
parent a175ac3a1d
commit 05940aa481
3 changed files with 35 additions and 30 deletions

View file

@ -14,7 +14,6 @@ import java.awt.Paint;
import java.awt.Polygon;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import mage.client.dialog.PreferencesDialog;
import mage.constants.AbilityType;
import mage.constants.CardType;
@ -171,11 +170,12 @@ public abstract class CardRenderer {
}
/**
* How far does a card have to be spaced down from
* a rendered card to show it's entire name line?
* This function is a bit of a hack, as different card faces need
* slightly different spacing, but we need it in a static context
* so that spacing is consistent in GY / deck views etc.
* How far does a card have to be spaced down from a rendered card to show
* it's entire name line? This function is a bit of a hack, as different
* card faces need slightly different spacing, but we need it in a static
* context so that spacing is consistent in GY / deck views etc.
*
* @param cardWidth
* @return
*/
public static int getCardTopHeight(int cardWidth) {
@ -186,7 +186,7 @@ public abstract class CardRenderer {
BOX_HEIGHT_MIN,
BOX_HEIGHT_FRAC * cardWidth * 1.4f);
int borderWidth = getBorderWidth(cardWidth);
return 2*borderWidth + boxHeight;
return 2 * borderWidth + boxHeight;
}
// The Draw Method

View file

@ -23,10 +23,12 @@ import java.util.regex.Pattern;
* Various static utilities for use in the card renderer
*/
public class CardRendererUtils {
/**
* Convert an abstract image, whose underlying implementation may or may
* not be a BufferedImage into a BufferedImage by creating one and coping
* the contents if it is not, and simply up-casting if it is.
* Convert an abstract image, whose underlying implementation may or may not
* be a BufferedImage into a BufferedImage by creating one and coping the
* contents if it is not, and simply up-casting if it is.
*
* @param img The image to convert
* @return The converted image
*/
@ -57,18 +59,18 @@ public class CardRendererUtils {
// Used on various card parts.
public static void drawRoundedBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Color fill) {
g.setColor(new Color(0, 0, 0, 150));
g.drawOval(x-1, y-1, bevel*2, h);
g.drawOval(x - 1, y - 1, bevel * 2, h);
g.setPaint(border);
g.drawOval(x, y, bevel*2-1, h-1);
g.drawOval(x + w - bevel*2, y, bevel*2-1, h-1);
g.drawOval(x+1, y+1, bevel*2-3, h-3);
g.drawOval(x+1 + w - bevel*2, y+1, bevel*2-3, h-3);
g.drawRect(x + bevel, y, w - 2*bevel, h-1);
g.drawRect(x+1 + bevel, y+1, w - 2*bevel-2, h-3);
g.drawOval(x, y, bevel * 2 - 1, h - 1);
g.drawOval(x + w - bevel * 2, y, bevel * 2 - 1, h - 1);
g.drawOval(x + 1, y + 1, bevel * 2 - 3, h - 3);
g.drawOval(x + 1 + w - bevel * 2, y + 1, bevel * 2 - 3, h - 3);
g.drawRect(x + bevel, y, w - 2 * bevel, h - 1);
g.drawRect(x + 1 + bevel, y + 1, w - 2 * bevel - 2, h - 3);
g.setColor(fill);
g.fillOval(x+2, y+2, bevel*2-4, h-4);
g.fillOval(x+2 + w - bevel*2, y+2, bevel*2-4, h-4);
g.fillRect(x + bevel, y+2, w - 2*bevel, h-4);
g.fillOval(x + 2, y + 2, bevel * 2 - 4, h - 4);
g.fillOval(x + 2 + w - bevel * 2, y + 2, bevel * 2 - 4, h - 4);
g.fillRect(x + bevel, y + 2, w - 2 * bevel, h - 4);
}
// Get the width of a mana cost rendered with ManaSymbols.draw
@ -86,8 +88,9 @@ public class CardRendererUtils {
// Abbreviate a piece of rules text, making substitutions to decrease its
// length. Also abbreviate reminder text.
private static final Pattern abbreviationPattern;
private static final Map<String, String> abbreviations = new HashMap<String, String>();
private static final Map<String, String> abbreviations = new HashMap<>();
private static final Pattern killReminderTextPattern;
static {
// Available abbreviations
abbreviations.put("enters the battlefield", "ETB");
@ -109,6 +112,7 @@ public class CardRendererUtils {
// Reminder text killing
killReminderTextPattern = Pattern.compile("\\([^\\)]*\\)");
}
public static String abbreviateRule(String rule) {
StringBuffer build = new StringBuffer();
Matcher match = abbreviationPattern.matcher(rule);
@ -118,6 +122,7 @@ public class CardRendererUtils {
match.appendTail(build);
return build.toString();
}
public static String killReminderText(String rule) {
return killReminderTextPattern.matcher(rule).replaceAll("");
}

View file

@ -311,7 +311,7 @@ public class ModernCardRenderer extends CardRenderer {
Rectangle2D rect;
if (useInventionFrame()) {
rect = new Rectangle2D.Float(0, 0, 1, 1);
} else if (cardView.getFrameStyle().isFullArt() || cardView.isToken()) {
} else if (cardView.getFrameStyle().isFullArt() || (cardView.isToken())) {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .63f);
} else {
rect = new Rectangle2D.Float(.079f, .11f, .84f, .42f);
@ -320,7 +320,7 @@ public class ModernCardRenderer extends CardRenderer {
}
private float getTypeLineYFrac() {
if (cardView.isToken()) {
if (cardView.isToken() && cardView.getCardNumber() == null) {
return TYPE_LINE_Y_FRAC_TOKEN;
} else if (cardView.getFrameStyle().isFullArt()) {
return TYPE_LINE_Y_FRAC_FULL_ART;