mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Fixed that the render frame of copies of normal cards got the normal card rule box size.
This commit is contained in:
parent
a175ac3a1d
commit
05940aa481
3 changed files with 35 additions and 30 deletions
|
@ -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
|
||||
|
|
|
@ -19,14 +19,16 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* @author stravant@gmail.com
|
||||
*
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
@ -35,7 +37,7 @@ public class CardRendererUtils {
|
|||
if (img == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Already a buffered image?
|
||||
if (img instanceof BufferedImage) {
|
||||
return (BufferedImage) img;
|
||||
|
@ -52,25 +54,25 @@ public class CardRendererUtils {
|
|||
// Return the buffered image
|
||||
return bimage;
|
||||
}
|
||||
|
||||
|
||||
// Draw a rounded box with a 2-pixel border
|
||||
// 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
|
||||
public static int getManaCostWidth(String manaCost, int symbolSize) {
|
||||
int width = 0;
|
||||
|
@ -82,18 +84,19 @@ public class CardRendererUtils {
|
|||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
// 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");
|
||||
abbreviations.put("less than", "<");
|
||||
abbreviations.put("greater than", ">");
|
||||
|
||||
|
||||
// Compile into regex
|
||||
String patternString = "(";
|
||||
Iterator<String> it = abbreviations.keySet().iterator();
|
||||
|
@ -105,10 +108,11 @@ public class CardRendererUtils {
|
|||
}
|
||||
patternString += ")";
|
||||
abbreviationPattern = Pattern.compile(patternString);
|
||||
|
||||
|
||||
// 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("");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue