mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Merge pull request #4551 from spjspj/master
Adding in way to render Zendikar full art lands.
This commit is contained in:
commit
871b035bb4
5 changed files with 281 additions and 84 deletions
|
@ -302,7 +302,7 @@ public class CardPanelRenderImpl extends CardPanel {
|
|||
= new CardPanelAttributes(cardWidth, cardHeight, isChoosable(), isSelected());
|
||||
|
||||
// Draw card itself
|
||||
cardRenderer.draw(g2d, attribs);
|
||||
cardRenderer.draw(g2d, attribs, image);
|
||||
|
||||
// Done
|
||||
g2d.dispose();
|
||||
|
|
|
@ -17,10 +17,10 @@ import mage.view.PermanentView;
|
|||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RasterFormatException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* @author stravant@gmail.com
|
||||
|
@ -201,7 +201,8 @@ public abstract class CardRenderer {
|
|||
// The Draw Method
|
||||
// The draw method takes the information caculated by the constructor
|
||||
// and uses it to draw to a concrete size of card and graphics.
|
||||
public void draw(Graphics2D g, CardPanelAttributes attribs) {
|
||||
public void draw(Graphics2D g, CardPanelAttributes attribs, BufferedImage image) {
|
||||
|
||||
// Pre template method layout, to calculate shared layout info
|
||||
layout(attribs.cardWidth, attribs.cardHeight);
|
||||
isSelected = attribs.isSelected;
|
||||
|
@ -211,7 +212,7 @@ public abstract class CardRenderer {
|
|||
drawBorder(g);
|
||||
drawBackground(g);
|
||||
drawArt(g);
|
||||
drawFrame(g);
|
||||
drawFrame(g, image);
|
||||
if (!cardView.isAbility()) {
|
||||
drawOverlays(g);
|
||||
drawCounters(g);
|
||||
|
@ -226,7 +227,7 @@ public abstract class CardRenderer {
|
|||
|
||||
protected abstract void drawArt(Graphics2D g);
|
||||
|
||||
protected abstract void drawFrame(Graphics2D g);
|
||||
protected abstract void drawFrame(Graphics2D g, BufferedImage image);
|
||||
|
||||
// Template methods that are possible to override, but unlikely to be
|
||||
// overridden.
|
||||
|
@ -462,22 +463,44 @@ public abstract class CardRenderer {
|
|||
}
|
||||
} else {
|
||||
StringBuilder sbType = new StringBuilder();
|
||||
for (SuperType superType : cardView.getSuperTypes()) {
|
||||
sbType.append(superType).append(' ');
|
||||
}
|
||||
for (CardType cardType : cardView.getCardTypes()) {
|
||||
sbType.append(cardType.toString()).append(' ');
|
||||
}
|
||||
if (!cardView.getSubTypes().isEmpty()) {
|
||||
sbType.append("- ");
|
||||
for (SubType subType : cardView.getSubTypes()) {
|
||||
sbType.append(subType).append(' ');
|
||||
String spType = getCardSuperTypeLine();
|
||||
String subType = getCardSubTypeLine();
|
||||
if (spType.equalsIgnoreCase("")) {
|
||||
sbType.append(subType);
|
||||
} else {
|
||||
sbType.append(spType);
|
||||
if (!subType.equalsIgnoreCase("")) {
|
||||
sbType.append("- ");
|
||||
sbType.append(subType);
|
||||
}
|
||||
}
|
||||
|
||||
return sbType.toString();
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCardSuperTypeLine() {
|
||||
StringBuilder spType = new StringBuilder();
|
||||
for (SuperType superType : cardView.getSuperTypes()) {
|
||||
spType.append(superType).append(' ');
|
||||
}
|
||||
for (CardType cardType : cardView.getCardTypes()) {
|
||||
spType.append(cardType.toString()).append(' ');
|
||||
}
|
||||
return spType.toString();
|
||||
}
|
||||
|
||||
protected String getCardSubTypeLine() {
|
||||
StringBuilder subType = new StringBuilder();
|
||||
|
||||
if (!cardView.getSubTypes().isEmpty()) {
|
||||
for (SubType sType : cardView.getSubTypes()) {
|
||||
subType.append(sType).append(' ');
|
||||
}
|
||||
}
|
||||
return subType.toString();
|
||||
}
|
||||
|
||||
// Set the card art image (CardPanel will give it to us when it
|
||||
// is loaded and ready)
|
||||
public void setArtImage(Image image) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public final class CardRendererUtils {
|
|||
return bimage;
|
||||
}
|
||||
|
||||
private static Color abitbrighter(Color c) {
|
||||
public static Color abitbrighter(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
|
@ -68,7 +68,7 @@ public final class CardRendererUtils {
|
|||
alpha);
|
||||
}
|
||||
|
||||
private static Color abitdarker(Color c) {
|
||||
public static Color abitdarker(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
|
@ -107,6 +107,36 @@ public final class CardRendererUtils {
|
|||
g.setColor(abitdarker(g.getColor()));
|
||||
g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2);
|
||||
}
|
||||
|
||||
public static void drawZendikarLandBox(Graphics2D g, int x, int y, int w, int h, int bevel, Paint border, Paint fill) {
|
||||
g.setColor(new Color(0, 0, 0, 150));
|
||||
|
||||
g.drawOval(x - 1, y, 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);
|
||||
|
||||
// The big circle in the middle.. (diameter=2+1/4 of height) - 3/4 above line, 1/2 below 0.75 + .5 + 1= 2.25 = 9/4
|
||||
g.drawOval(x + w / 2 - h - h/8, y - 3*h/4, 9*h/4, 9*h/4);
|
||||
|
||||
g.drawRect(x + bevel, y, w - 2 * bevel, h - 1);
|
||||
g.drawRect(x + 1 + bevel, y + 1, w - 2 * bevel - 2, h - 3);
|
||||
g.setPaint(fill);
|
||||
g.setPaint(fill);
|
||||
g.setColor(abitbrighter(g.getColor()));
|
||||
g.drawLine(x + 1 + bevel, y + 1, x + 1 + bevel + w - 2 * bevel - 2, y + 1);
|
||||
g.setPaint(fill);
|
||||
g.setColor(abitdarker(g.getColor()));
|
||||
g.drawLine(x + 1 + bevel, y + h - 2, x + 1 + bevel + w - 2 * bevel - 2, y + h - 2);
|
||||
|
||||
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 + w / 2 - h - h/8, y - 3*h/4, 9*h/4, 9*h/4);
|
||||
}
|
||||
|
||||
// Get the width of a mana cost rendered with ManaSymbols.draw
|
||||
public static int getManaCostWidth(String manaCost, int symbolSize) {
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.mage.card.arcane;
|
|||
|
||||
import java.awt.*;
|
||||
import java.awt.font.*;
|
||||
import java.awt.geom.QuadCurve2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
|
@ -312,6 +313,8 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
Rectangle2D rect;
|
||||
if (useInventionFrame()) {
|
||||
rect = new Rectangle2D.Float(0, 0, 1, 1);
|
||||
} else if (cardView.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
rect = new Rectangle2D.Float(.079f, .11f, .84f, .84f);
|
||||
} else if (cardView.getFrameStyle().isFullArt() || (cardView.isToken())) {
|
||||
rect = new Rectangle2D.Float(.079f, .11f, .84f, .63f);
|
||||
} else {
|
||||
|
@ -352,7 +355,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
if (artImage != null && !cardView.isFaceDown()) {
|
||||
|
||||
boolean useFaceArt = false;
|
||||
if (faceArtImage != null) {
|
||||
if (faceArtImage != null && cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
useFaceArt = true;
|
||||
}
|
||||
|
||||
|
@ -395,17 +398,22 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
totalContentInset + 1, totalContentInset + boxHeight,
|
||||
contentWidth - 2, typeLineY - totalContentInset - boxHeight,
|
||||
sourceRect, shouldPreserveAspect);
|
||||
} else {
|
||||
} else if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
drawArtIntoRect(g,
|
||||
totalContentInset + 1, totalContentInset + boxHeight,
|
||||
contentWidth - 2, typeLineY - totalContentInset - boxHeight,
|
||||
sourceRect, shouldPreserveAspect);
|
||||
} else {
|
||||
/* drawArtIntoRect(g,
|
||||
totalContentInset + 1, totalContentInset + boxHeight,
|
||||
contentWidth - 2, typeLineY,
|
||||
sourceRect, shouldPreserveAspect);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawFrame(Graphics2D g) {
|
||||
protected void drawFrame(Graphics2D g, BufferedImage image) {
|
||||
// Get the card colors to base the frame on
|
||||
ObjectColor frameColors = getFrameObjectColor();
|
||||
|
||||
|
@ -421,12 +429,13 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
|
||||
// Draw the main card content border
|
||||
g.setPaint(borderPaint);
|
||||
|
||||
if (cardView.getFrameStyle() == FrameStyle.KLD_INVENTION) {
|
||||
g.drawImage(FRAME_INVENTION, 0, 0, cardWidth, cardHeight, null);
|
||||
g.drawRect(
|
||||
totalContentInset, typeLineY,
|
||||
contentWidth - 1, cardHeight - borderWidth * 3 - typeLineY - 1);
|
||||
} else {
|
||||
} else if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
g.drawRect(
|
||||
totalContentInset, totalContentInset,
|
||||
contentWidth - 1, cardHeight - borderWidth * 3 - totalContentInset - 1);
|
||||
|
@ -437,11 +446,13 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
g.setPaint(new Color(255, 255, 255, 150));
|
||||
} else {
|
||||
g.setPaint(textboxPaint);
|
||||
|
||||
}
|
||||
g.fillRect(
|
||||
totalContentInset + 1, typeLineY,
|
||||
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
|
||||
|
||||
if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
g.fillRect(
|
||||
totalContentInset + 1, typeLineY,
|
||||
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
|
||||
}
|
||||
|
||||
// If it's a planeswalker, extend the textbox left border by some
|
||||
if (cardView.isPlanesWalker()) {
|
||||
|
@ -451,7 +462,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
cardWidth / 16, cardHeight - typeLineY - boxHeight - borderWidth * 3);
|
||||
}
|
||||
|
||||
if (cardView.getFrameStyle() != FrameStyle.KLD_INVENTION) {
|
||||
if (cardView.getFrameStyle() != FrameStyle.KLD_INVENTION && cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
// Draw a shadow highlight at the right edge of the content frame
|
||||
g.setColor(new Color(0, 0, 0, 100));
|
||||
g.fillRect(
|
||||
|
@ -470,26 +481,31 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
cardWidth - 2 * borderWidth, boxHeight,
|
||||
contentInset,
|
||||
borderPaint, boxColor);
|
||||
|
||||
// Draw the type line box
|
||||
CardRendererUtils.drawRoundedBox(g,
|
||||
borderWidth, typeLineY,
|
||||
cardWidth - 2 * borderWidth, boxHeight,
|
||||
contentInset,
|
||||
borderPaint, boxColor);
|
||||
if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
CardRendererUtils.drawRoundedBox(g,
|
||||
borderWidth, typeLineY,
|
||||
cardWidth - 2 * borderWidth, boxHeight,
|
||||
contentInset,
|
||||
borderPaint, boxColor);
|
||||
|
||||
// Draw a small separator between the type line and box, and shadow
|
||||
// at the left of the texbox, and above the name line
|
||||
g.setColor(new Color(0, 0, 0, 150));
|
||||
g.fillRect(
|
||||
totalContentInset - 1, totalContentInset - 1,
|
||||
contentWidth + 1, 1);
|
||||
g.fillRect(
|
||||
totalContentInset + 1, typeLineY + boxHeight,
|
||||
contentWidth - 2, 1);
|
||||
g.fillRect(
|
||||
cardWidth - totalContentInset - 1, typeLineY + boxHeight,
|
||||
1, cardHeight - borderWidth * 3 - typeLineY - boxHeight);
|
||||
// Draw a small separator between the type line and box, and shadow
|
||||
// at the left of the texbox, and above the name line
|
||||
g.setColor(new Color(0, 0, 0, 150));
|
||||
g.fillRect(
|
||||
totalContentInset - 1, totalContentInset - 1,
|
||||
contentWidth + 1, 1);
|
||||
g.fillRect(
|
||||
totalContentInset + 1, typeLineY + boxHeight,
|
||||
contentWidth - 2, 1);
|
||||
g.fillRect(
|
||||
cardWidth - totalContentInset - 1, typeLineY + boxHeight,
|
||||
1, cardHeight - borderWidth * 3 - typeLineY - boxHeight);
|
||||
// Draw the type line
|
||||
drawTypeLine(g, getCardTypeLine(),
|
||||
totalContentInset, typeLineY,
|
||||
contentWidth, boxHeight, true);
|
||||
}
|
||||
|
||||
// Draw the transform circle
|
||||
int nameOffset = drawTransformationCircle(g, borderPaint);
|
||||
|
@ -502,20 +518,126 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
totalContentInset + nameOffset, totalContentInset,
|
||||
contentWidth - nameOffset, boxHeight);
|
||||
|
||||
// Draw the type line
|
||||
drawTypeLine(g, getCardTypeLine(),
|
||||
totalContentInset, typeLineY,
|
||||
contentWidth, boxHeight);
|
||||
|
||||
// Draw the textbox rules
|
||||
drawRulesText(g, textboxKeywords, textboxRules,
|
||||
totalContentInset + 2, typeLineY + boxHeight + 2,
|
||||
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3);
|
||||
if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
drawRulesText(g, textboxKeywords, textboxRules,
|
||||
totalContentInset + 2, typeLineY + boxHeight + 2,
|
||||
contentWidth - 4, cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3);
|
||||
} else {
|
||||
int x = totalContentInset;
|
||||
int y = typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset;
|
||||
int w = contentWidth - 2;
|
||||
int h = boxHeight - 4;
|
||||
|
||||
CardRendererUtils.drawZendikarLandBox(g,
|
||||
x, y, w, h,
|
||||
contentInset,
|
||||
borderPaint, boxColor);
|
||||
drawTypeLine(g, getCardSuperTypeLine(),
|
||||
totalContentInset + 2, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
|
||||
contentWidth / 2 - boxHeight, boxHeight - 4, false);
|
||||
drawTypeLine(g, getCardSubTypeLine(),
|
||||
totalContentInset + 4 * contentWidth / 7 + boxHeight, typeLineY + boxHeight + (cardHeight - typeLineY - boxHeight - 4 - borderWidth * 3) / 2 - contentInset,
|
||||
3 * contentWidth / 7 - boxHeight - contentInset, boxHeight - 4, true);
|
||||
|
||||
// Draw curved lines (old Zendikar land style) - bigger (around 6%) inset on curve on bottom than inset (around 4.5%) on top...
|
||||
int x2 = x;
|
||||
int y2 = y;
|
||||
int topxdelta = 45 * contentWidth / 1000;
|
||||
int botxdelta = 58 * contentWidth / 1000;
|
||||
int ctrlx = 0;
|
||||
int ctrly = (totalContentInset + y2) / 2;
|
||||
|
||||
drawZendikarCurvedFace(g, image, x + topxdelta, totalContentInset + boxHeight, ctrlx, ctrly, x2 + botxdelta, y2,
|
||||
x + contentWidth - topxdelta, totalContentInset + boxHeight, cardWidth, ctrly, x2 + contentWidth - botxdelta, y2,
|
||||
cardWidth, cardHeight);
|
||||
|
||||
QuadCurve2D q = new QuadCurve2D.Float();
|
||||
q.setCurve(x + topxdelta, totalContentInset + boxHeight, ctrlx, ctrly, x2 + botxdelta, y2);
|
||||
g.setColor(boxColor);
|
||||
g.setPaint(borderPaint);
|
||||
g.draw(q);
|
||||
q.setCurve(x + topxdelta - 1, totalContentInset + boxHeight, ctrlx, ctrly, x2 + botxdelta - 1, y2);
|
||||
g.draw(q);
|
||||
q.setCurve(x + contentWidth - topxdelta, totalContentInset + boxHeight, cardWidth, ctrly, x2 + contentWidth - botxdelta, y2);
|
||||
g.draw(q);
|
||||
q.setCurve(x + contentWidth - topxdelta + 1, totalContentInset + boxHeight, cardWidth, ctrly, x2 + contentWidth - botxdelta + 1, y2);
|
||||
g.draw(q);
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
q.setCurve(x + topxdelta + 1, totalContentInset + boxHeight, ctrlx, ctrly, x2 + botxdelta + 1, y2 - 1);
|
||||
g.draw(q);
|
||||
q.setCurve(x + contentWidth - topxdelta - 1, totalContentInset + boxHeight, cardWidth, ctrly, x2 + contentWidth - botxdelta - 1, y2 - 1);
|
||||
g.draw(q);
|
||||
|
||||
drawRulesText(g, textboxKeywords, textboxRules,
|
||||
x, y,
|
||||
w, h);
|
||||
}
|
||||
|
||||
// Draw the bottom right stuff
|
||||
drawBottomRight(g, borderPaint, boxColor);
|
||||
}
|
||||
|
||||
public void drawZendikarCurvedFace(Graphics2D g2, BufferedImage image, int x, int y, int ctrlx, int ctrly, int w, int h,
|
||||
int x2, int y2, int ctrlx2, int ctrly2, int w2, int h2,
|
||||
int cardWidth, int cardHeight) {
|
||||
|
||||
BufferedImage artToUse = faceArtImage;
|
||||
boolean hadToUseFullArt = false;
|
||||
if (faceArtImage == null) {
|
||||
if (artImage == null) {
|
||||
return;
|
||||
}
|
||||
hadToUseFullArt = true;
|
||||
artToUse = artImage;
|
||||
}
|
||||
int srcW = artToUse.getWidth();
|
||||
int srcH = artToUse.getHeight();
|
||||
|
||||
if (hadToUseFullArt) {
|
||||
// Get a box based on the standard scan from gatherer.
|
||||
// Width = 185/223 pixels (centered)
|
||||
// Height = 220/310, 38 pixels from top
|
||||
int subx = 19 * srcW / 223;
|
||||
int suby = 38 * srcH / 310;
|
||||
artToUse = artImage.getSubimage(subx, suby, 185*srcW / 223, 220*srcH / 310);
|
||||
}
|
||||
|
||||
Rectangle2D rect = new Rectangle2D.Float();
|
||||
rect.setRect(0, 0, srcW, srcH);
|
||||
g2.clip(rect);
|
||||
|
||||
QuadCurve2D q = new QuadCurve2D.Float();
|
||||
q.setCurve(x, y, ctrlx, ctrly, w, h);
|
||||
g2.setClip(null);
|
||||
g2.clip(q);
|
||||
//g2.drawImage(faceArtImage, x, y, (x2-x), (h2-y), null);
|
||||
Rectangle2D r = q.getBounds2D();
|
||||
int minX = (int) r.getX();
|
||||
g2.drawImage(artToUse, minX, y, (x2 - x) + (x - minX) * 2, h2 - y, null);
|
||||
|
||||
QuadCurve2D q2 = new QuadCurve2D.Float();
|
||||
q2.setCurve(x2, y2, ctrlx2, ctrly2, w2, h2);
|
||||
g2.setClip(null);
|
||||
g2.clip(q2);
|
||||
g2.drawImage(artToUse, minX, y, (x2 - x) + (x - minX) * 2, h2 - y, null);
|
||||
|
||||
Polygon p = new Polygon();
|
||||
//x = 10;
|
||||
//y = 0;
|
||||
p.addPoint(x, y);
|
||||
p.addPoint(x2, y);
|
||||
p.addPoint(w2, h2);
|
||||
p.addPoint(w, h2);
|
||||
p.addPoint(x, y);
|
||||
g2.setClip(null);
|
||||
g2.clip(p);
|
||||
|
||||
g2.drawImage(artToUse, minX, y, (x2 - x) + (x - minX) * 2, h2 - y, null);
|
||||
g2.setClip(null);
|
||||
}
|
||||
|
||||
// Draw the name line
|
||||
protected void drawNameLine(Graphics2D g, String baseName, String manaCost, int x, int y, int w, int h) {
|
||||
// Width of the mana symbols
|
||||
|
@ -566,13 +688,13 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
}
|
||||
|
||||
// Draw the type line (color indicator, types, and expansion symbol)
|
||||
protected void drawTypeLine(Graphics2D g, String baseTypeLine, int x, int y, int w, int h) {
|
||||
protected void drawTypeLine(Graphics2D g, String baseTypeLine, int x, int y, int w, int h, boolean withSymbol) {
|
||||
// Draw expansion symbol
|
||||
int expansionSymbolWidth;
|
||||
int expansionSymbolWidth = 0;
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_SET_SYMBOL, "false").equals("false")) {
|
||||
if (cardView.isAbility()) {
|
||||
expansionSymbolWidth = 0;
|
||||
} else {
|
||||
} else if (withSymbol) {
|
||||
expansionSymbolWidth = drawExpansionSymbol(g, x, y, w, h);
|
||||
}
|
||||
} else {
|
||||
|
@ -792,9 +914,20 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
}
|
||||
|
||||
// Basic mana draw mana symbol in textbox (for basic lands)
|
||||
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand()) {
|
||||
drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
|
||||
return;
|
||||
if (allRules.size() == 1 && (allRules.get(0) instanceof TextboxBasicManaRule) && cardView.isLand() || cardView.getFrameStyle() == FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
if (cardView.getFrameStyle() != FrameStyle.ZEN_FULL_ART_BASIC) {
|
||||
drawBasicManaTextbox(g, x, y, w, h, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
|
||||
return;
|
||||
} else // Big circle in the middle for Zendikar lands
|
||||
if (allRules.size() == 1) {
|
||||
drawBasicManaSymbol(g, x + w / 2 - h - h / 8, y - 3 * h / 4, 9 * h / 4, 9 * h / 4, ((TextboxBasicManaRule) allRules.get(0)).getBasicManaSymbol());
|
||||
return;
|
||||
} else {
|
||||
if (allRules.size() > 1) {
|
||||
drawBasicManaSymbol(g, x + w / 2 - h - h / 8, y - 3 * h / 4, 9 * h / 4, 9 * h / 4, cardView.getFrameColor().toString());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Go through possible font sizes in descending order to find the best fit
|
||||
|
@ -847,6 +980,11 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight, Color.black, 2);
|
||||
}
|
||||
|
||||
private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) {
|
||||
String symbs = symbol;
|
||||
ManaSymbols.draw(g, symbs, x, y, w, Color.black, 2);
|
||||
}
|
||||
|
||||
// Get the first line of the textbox, the keyword string
|
||||
private static String getKeywordRulesString(ArrayList<TextboxRule> keywords) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -8,6 +8,7 @@ import mage.view.CardView;
|
|||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,6 +18,7 @@ import java.util.List;
|
|||
public class ModernSplitCardRenderer extends ModernCardRenderer {
|
||||
|
||||
private class HalfCardProps {
|
||||
|
||||
int x, y, w, h, cw, ch;
|
||||
|
||||
String name;
|
||||
|
@ -27,7 +29,11 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
ArrayList<TextboxRule> keywords = new ArrayList<>();
|
||||
}
|
||||
|
||||
private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() {{add(CardType.LAND);}};
|
||||
private static ArrayList<CardType> ONLY_LAND_TYPE = new ArrayList<CardType>() {
|
||||
{
|
||||
add(CardType.LAND);
|
||||
}
|
||||
};
|
||||
|
||||
// Right and left halves of the card content
|
||||
private HalfCardProps rightHalf = new HalfCardProps();
|
||||
|
@ -88,20 +94,20 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
// Decide size of divider
|
||||
if (isAftermath()) {
|
||||
dividerSize = borderWidth;
|
||||
dividerAt = (int)(cardHeight*0.54);
|
||||
dividerAt = (int) (cardHeight * 0.54);
|
||||
} else {
|
||||
int availHeight = cardHeight - totalContentInset - 3*borderWidth;
|
||||
dividerSize = borderWidth*2;
|
||||
dividerAt = (int)(totalContentInset + availHeight * 0.5 - borderWidth);
|
||||
int availHeight = cardHeight - totalContentInset - 3 * borderWidth;
|
||||
dividerSize = borderWidth * 2;
|
||||
dividerAt = (int) (totalContentInset + availHeight * 0.5 - borderWidth);
|
||||
}
|
||||
|
||||
// Decide size of each halves box
|
||||
rightHalf.x = leftHalf.x = totalContentInset;
|
||||
rightHalf.w = leftHalf.w = cardWidth - 2*totalContentInset;
|
||||
rightHalf.w = leftHalf.w = cardWidth - 2 * totalContentInset;
|
||||
leftHalf.y = totalContentInset;
|
||||
leftHalf.h = dividerAt - totalContentInset;
|
||||
rightHalf.y = dividerAt + dividerSize;
|
||||
rightHalf.h = cardHeight - rightHalf.y - borderWidth*3;
|
||||
rightHalf.h = cardHeight - rightHalf.y - borderWidth * 3;
|
||||
|
||||
// Content width / height (Exchanged from width / height if the card part is rotated)
|
||||
if (isAftermath()) {
|
||||
|
@ -126,7 +132,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
private ObjectColor getColorFromManaCostHack(ManaCosts costs) {
|
||||
ObjectColor c = new ObjectColor();
|
||||
List<String> symbols = costs.getSymbols();
|
||||
for (String symbol: symbols) {
|
||||
for (String symbol : symbols) {
|
||||
if (symbol.contains("W")) {
|
||||
c.setWhite(true);
|
||||
} else if (symbol.contains("U")) {
|
||||
|
@ -154,18 +160,18 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
// Draw main part (most of card)
|
||||
g.fillRoundRect(
|
||||
borderWidth, borderWidth,
|
||||
cardWidth - 2*borderWidth, leftHalf.h + contentInset - borderWidth - 2*cornerRadius + (cornerRadius - 1),
|
||||
cardWidth - 2 * borderWidth, leftHalf.h + contentInset - borderWidth - 2 * cornerRadius + (cornerRadius - 1),
|
||||
cornerRadius - 1, cornerRadius - 1);
|
||||
|
||||
// Draw the M15 rounded "swoosh" at the bottom
|
||||
g.fillRoundRect(
|
||||
borderWidth, dividerAt - borderWidth - 4*cornerRadius,
|
||||
cardWidth - 2*borderWidth, cornerRadius * 4,
|
||||
borderWidth, dividerAt - borderWidth - 4 * cornerRadius,
|
||||
cardWidth - 2 * borderWidth, cornerRadius * 4,
|
||||
cornerRadius * 2, cornerRadius * 2);
|
||||
|
||||
// Draw the cutout into the "swoosh" for the textbox to lie over
|
||||
g.fillRect(
|
||||
borderWidth + contentInset, dividerAt - 2*borderWidth,
|
||||
borderWidth + contentInset, dividerAt - 2 * borderWidth,
|
||||
cardWidth - borderWidth * 2 - contentInset * 2, borderWidth * 2);
|
||||
}
|
||||
|
||||
|
@ -176,8 +182,8 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
// Draw the M15 rounded "swoosh"es at the top and bottom
|
||||
g.fillRoundRect(
|
||||
borderWidth, dividerAt + dividerSize + borderWidth,
|
||||
cardWidth - 2*borderWidth, rightHalf.h - 2*borderWidth,
|
||||
cornerRadius*2, cornerRadius*2);
|
||||
cardWidth - 2 * borderWidth, rightHalf.h - 2 * borderWidth,
|
||||
cornerRadius * 2, cornerRadius * 2);
|
||||
|
||||
// Draw the cutout into the "swoosh" for the textbox to lie over
|
||||
g.fillRect(
|
||||
|
@ -236,8 +242,8 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
// Background of textbox
|
||||
g.setPaint(textboxPaint);
|
||||
g.fillRect(
|
||||
1, typeLineY,
|
||||
half.cw - 2, half.ch - typeLineY - 1);
|
||||
1, typeLineY,
|
||||
half.cw - 2, half.ch - typeLineY - 1);
|
||||
|
||||
// Draw the name line box
|
||||
CardRendererUtils.drawRoundedBox(g,
|
||||
|
@ -261,7 +267,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
// Draw the type line
|
||||
drawTypeLine(g, half.typeLineString,
|
||||
0, typeLineY,
|
||||
half.cw, boxHeight - 4);
|
||||
half.cw, boxHeight - 4, true);
|
||||
|
||||
// Draw the textbox rules
|
||||
drawRulesText(g, half.keywords, half.rules,
|
||||
|
@ -270,13 +276,13 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
}
|
||||
|
||||
private Graphics2D getUnmodifiedHalfContext(Graphics2D g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.translate(leftHalf.x, leftHalf.y);
|
||||
return g2;
|
||||
}
|
||||
|
||||
private Graphics2D getAftermathHalfContext(Graphics2D g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.translate(rightHalf.x, rightHalf.y);
|
||||
g2.rotate(Math.PI / 2);
|
||||
g2.translate(0, -rightHalf.w);
|
||||
|
@ -284,7 +290,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
}
|
||||
|
||||
private Graphics2D getLeftHalfContext(Graphics2D g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.translate(leftHalf.x, leftHalf.y);
|
||||
g2.rotate(-Math.PI / 2);
|
||||
g2.translate(-leftHalf.cw, 0);
|
||||
|
@ -292,7 +298,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
}
|
||||
|
||||
private Graphics2D getRightHalfContext(Graphics2D g) {
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.translate(rightHalf.x, rightHalf.y);
|
||||
g2.rotate(-Math.PI / 2);
|
||||
g2.translate(-rightHalf.cw, 0);
|
||||
|
@ -300,13 +306,13 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void drawFrame(Graphics2D g) {
|
||||
protected void drawFrame(Graphics2D g, BufferedImage image) {
|
||||
if (isAftermath()) {
|
||||
drawSplitHalfFrame(getUnmodifiedHalfContext(g), leftHalf, (int)(leftHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
drawSplitHalfFrame(getUnmodifiedHalfContext(g), leftHalf, (int) (leftHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
drawSplitHalfFrame(getAftermathHalfContext(g), rightHalf, (rightHalf.ch - boxHeight) / 2);
|
||||
} else {
|
||||
drawSplitHalfFrame(getLeftHalfContext(g), leftHalf, (int)(leftHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
drawSplitHalfFrame(getRightHalfContext(g), rightHalf, (int)(rightHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
drawSplitHalfFrame(getLeftHalfContext(g), leftHalf, (int) (leftHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
drawSplitHalfFrame(getRightHalfContext(g), rightHalf, (int) (rightHalf.ch * TYPE_LINE_Y_FRAC));
|
||||
if (isFuse()) {
|
||||
Graphics2D g2 = getRightHalfContext(g);
|
||||
int totalFuseBoxWidth = rightHalf.cw * 2 + 2 * borderWidth + dividerSize;
|
||||
|
@ -319,7 +325,7 @@ public class ModernSplitCardRenderer extends ModernCardRenderer {
|
|||
borderPaint, boxColor);
|
||||
drawNameLine(g2, "Fuse (You may cast both halves from your hand)", "",
|
||||
0, rightHalf.ch,
|
||||
totalFuseBoxWidth - 2*borderWidth, boxHeight);
|
||||
totalFuseBoxWidth - 2 * borderWidth, boxHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue