forked from External/mage
Merge branch 'master' into svg-mana-icons-support
This commit is contained in:
commit
efee0b5328
37 changed files with 1134 additions and 193 deletions
|
|
@ -327,6 +327,10 @@ public abstract class CardRenderer {
|
|||
= faceArtImage.getSubimage(
|
||||
(int) (artRect.getX() * fullCardImgWidth), (int) (artRect.getY() * fullCardImgHeight),
|
||||
(int) artWidth, (int) artHeight);*/
|
||||
RenderingHints rh = new RenderingHints(
|
||||
RenderingHints.KEY_INTERPOLATION,
|
||||
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
g.setRenderingHints(rh);
|
||||
g.drawImage(faceArtImage,
|
||||
x, y,
|
||||
(int) targetWidth, (int) targetHeight,
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* @author stravant@gmail.com
|
||||
* <p>
|
||||
* Various static utilities for use in the card renderer
|
||||
* <p>
|
||||
* Various static utilities for use in the card renderer
|
||||
*/
|
||||
public final class CardRendererUtils {
|
||||
|
||||
|
|
@ -51,6 +51,38 @@ public final class CardRendererUtils {
|
|||
// Return the buffered image
|
||||
return bimage;
|
||||
}
|
||||
|
||||
private static Color abitbrighter(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
int alpha = c.getAlpha();
|
||||
|
||||
int plus_r = (int) ((255 - r) / 2);
|
||||
int plus_g = (int) ((255 - g) / 2);
|
||||
int plus_b = (int) ((255 - b) / 2);
|
||||
|
||||
return new Color(r + plus_r,
|
||||
g + plus_g,
|
||||
b + plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
private static Color abitdarker(Color c) {
|
||||
int r = c.getRed();
|
||||
int g = c.getGreen();
|
||||
int b = c.getBlue();
|
||||
int alpha = c.getAlpha();
|
||||
|
||||
int plus_r = (int) (Math.min (255 - r, r) / 2);
|
||||
int plus_g = (int) (Math.min (255 - g, g) / 2);
|
||||
int plus_b = (int) (Math.min (255 - b, b) / 2);
|
||||
|
||||
return new Color(r - plus_r,
|
||||
g - plus_g,
|
||||
b - plus_b,
|
||||
alpha);
|
||||
}
|
||||
|
||||
// Draw a rounded box with a 2-pixel border
|
||||
// Used on various card parts.
|
||||
|
|
@ -68,6 +100,12 @@ public final class CardRendererUtils {
|
|||
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.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);
|
||||
}
|
||||
|
||||
// Get the width of a mana cost rendered with ManaSymbols.draw
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
public static final Color BORDER_RED = new Color(201, 71, 58);
|
||||
public static final Color BORDER_GREEN = new Color(4, 136, 69);
|
||||
public static final Color BORDER_GOLD = new Color(255, 228, 124);
|
||||
public static final Color BORDER_COLORLESS = new Color(238, 242, 242);
|
||||
public static final Color BORDER_COLORLESS = new Color(208, 212, 212);
|
||||
public static final Color BORDER_LAND = new Color(190, 173, 115);
|
||||
|
||||
public static final Color BOX_WHITE = new Color(244, 245, 239);
|
||||
|
|
@ -115,7 +115,7 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
public static final Color BOX_RED = new Color(246, 208, 185);
|
||||
public static final Color BOX_GREEN = new Color(205, 221, 213);
|
||||
public static final Color BOX_GOLD = new Color(223, 195, 136);
|
||||
public static final Color BOX_COLORLESS = new Color(220, 228, 232);
|
||||
public static final Color BOX_COLORLESS = new Color(200, 208, 212);
|
||||
public static final Color BOX_LAND = new Color(220, 215, 213);
|
||||
public static final Color BOX_INVENTION = new Color(209, 97, 33);
|
||||
public static final Color BOX_VEHICLE = new Color(155, 105, 60);
|
||||
|
|
@ -128,21 +128,21 @@ public class ModernCardRenderer extends CardRenderer {
|
|||
public static final Color BOX_GOLD_NIGHT = new Color(171, 134, 70);
|
||||
public static final Color BOX_COLORLESS_NIGHT = new Color(118, 147, 158);
|
||||
|
||||
public static final Color LAND_TEXTBOX_WHITE = new Color(248, 232, 188, 244);
|
||||
public static final Color LAND_TEXTBOX_BLUE = new Color(189, 212, 236, 244);
|
||||
public static final Color LAND_TEXTBOX_BLACK = new Color(174, 164, 162, 244);
|
||||
public static final Color LAND_TEXTBOX_RED = new Color(242, 168, 133, 244);
|
||||
public static final Color LAND_TEXTBOX_GREEN = new Color(198, 220, 198, 244);
|
||||
public static final Color LAND_TEXTBOX_GOLD = new Color(236, 229, 207, 244);
|
||||
public static final Color LAND_TEXTBOX_WHITE = new Color(248, 232, 188, 234);
|
||||
public static final Color LAND_TEXTBOX_BLUE = new Color(189, 212, 236, 234);
|
||||
public static final Color LAND_TEXTBOX_BLACK = new Color(174, 164, 162, 234);
|
||||
public static final Color LAND_TEXTBOX_RED = new Color(242, 168, 133, 234);
|
||||
public static final Color LAND_TEXTBOX_GREEN = new Color(198, 220, 198, 234);
|
||||
public static final Color LAND_TEXTBOX_GOLD = new Color(236, 229, 207, 234);
|
||||
|
||||
public static final Color TEXTBOX_WHITE = new Color(252, 249, 244, 244);
|
||||
public static final Color TEXTBOX_BLUE = new Color(229, 238, 247, 244);
|
||||
public static final Color TEXTBOX_BLACK = new Color(241, 241, 240, 244);
|
||||
public static final Color TEXTBOX_RED = new Color(243, 224, 217, 244);
|
||||
public static final Color TEXTBOX_GREEN = new Color(217, 232, 223, 244);
|
||||
public static final Color TEXTBOX_GOLD = new Color(240, 234, 209, 244);
|
||||
public static final Color TEXTBOX_COLORLESS = new Color(219, 229, 233, 244);
|
||||
public static final Color TEXTBOX_LAND = new Color(218, 214, 212, 244);
|
||||
public static final Color TEXTBOX_WHITE = new Color(252, 249, 244, 234);
|
||||
public static final Color TEXTBOX_BLUE = new Color(229, 238, 247, 234);
|
||||
public static final Color TEXTBOX_BLACK = new Color(241, 241, 240, 234);
|
||||
public static final Color TEXTBOX_RED = new Color(243, 224, 217, 234);
|
||||
public static final Color TEXTBOX_GREEN = new Color(217, 232, 223, 234);
|
||||
public static final Color TEXTBOX_GOLD = new Color(240, 234, 209, 234);
|
||||
public static final Color TEXTBOX_COLORLESS = new Color(199, 209, 213, 234);
|
||||
public static final Color TEXTBOX_LAND = new Color(218, 214, 212, 234);
|
||||
|
||||
public static final Color ERROR_COLOR = new Color(255, 0, 255);
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ public final class ImageCache {
|
|||
if (exists) {
|
||||
LOGGER.debug("loading thumbnail for " + key + ", path=" + thumbnailPath);
|
||||
BufferedImage thumbnailImage = loadImage(thumbnailFile);
|
||||
|
||||
if (thumbnailImage == null) { // thumbnail exists but broken for some reason
|
||||
LOGGER.warn("failed loading thumbnail for " + key + ", path=" + thumbnailPath
|
||||
+ ", thumbnail file is probably broken, attempting to recreate it...");
|
||||
|
|
@ -361,6 +360,23 @@ public final class ImageCache {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isFaceImagePresent(CardView card) {
|
||||
String path;
|
||||
path = CardImageUtils.generateFaceImagePath(card.getName(), card.getExpansionSetCode());
|
||||
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
TFile file = getTFile(path);
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
if (file.exists()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static BufferedImage getThumbnail(CardView card) {
|
||||
return getImage(getKey(card, card.getName(), "#thumb"));
|
||||
}
|
||||
|
|
@ -464,7 +480,6 @@ public final class ImageCache {
|
|||
// return alternateName + "#" + card.getExpansionSetCode() + "#" +card.getType()+ "#" + card.getCardNumber() + "#"
|
||||
// + (card.getTokenSetCode() == null ? "":card.getTokenSetCode());
|
||||
// }
|
||||
|
||||
/**
|
||||
* Load image from file
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue