Add support for ".fullborder" cards

(to differentiate full image cards and full image cards with full borders,
so it will only crop full image cards with full borders)
This commit is contained in:
Anthony Calosa
2019-11-16 17:36:30 +08:00
parent f50ee0ba36
commit d0a23fbf14
5 changed files with 20 additions and 9 deletions

View File

@@ -111,7 +111,11 @@ public final class ImageKeys {
file = findFile(dir, TextUtil.fastReplace(filename, "AE", "Ae")); file = findFile(dir, TextUtil.fastReplace(filename, "AE", "Ae"));
if (file != null) { return file; } if (file != null) { return file; }
} }
//try fullborder...
if (filename.contains(".full")) {
file = findFile(dir, TextUtil.fastReplace(filename, ".full", ".fullborder"));
if (file != null) { return file; }
}
// some S00 cards are really part of 6ED // some S00 cards are really part of 6ED
String s2kAlias = getSetFolder("S00"); String s2kAlias = getSetFolder("S00");
if (filename.startsWith(s2kAlias)) { if (filename.startsWith(s2kAlias)) {

View File

@@ -167,7 +167,9 @@ public class ImageCache {
public static void preloadCache(Iterable keys) { public static void preloadCache(Iterable keys) {
cache.getAll(keys); cache.getAll(keys);
} }
public static TextureRegion croppedBorderImage(Texture image) { public static TextureRegion croppedBorderImage(Texture image, boolean fullborder) {
if (!fullborder)
return new TextureRegion(image);
float rscale = 0.96f; float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale); int rw = Math.round(image.getWidth()*rscale);
int rh = Math.round(image.getHeight()*rscale); int rh = Math.round(image.getHeight()*rscale);

View File

@@ -49,12 +49,13 @@ public class CardImage implements FImage {
} }
else { else {
if (Forge.enableUIMask) { if (Forge.enableUIMask) {
boolean fullborder = image.toString().contains(".fullborder.");
if (ImageCache.isExtendedArt(card)) if (ImageCache.isExtendedArt(card))
g.drawImage(image, x, y, w, h); g.drawImage(image, x, y, w, h);
else { else {
float radius = (h - w)/8; float radius = (h - w)/8;
g.drawfillBorder(3, ImageCache.borderColor(card), x, y, w, h, radius); g.drawfillBorder(3, ImageCache.borderColor(card), x, y, w, h, radius);
g.drawImage(ImageCache.croppedBorderImage(image), x+radius/2.2f, y+radius/2, w*0.96f, h*0.96f); g.drawImage(ImageCache.croppedBorderImage(image, fullborder), x+radius/2.2f, y+radius/2, w*0.96f, h*0.96f);
} }
} }
else else

View File

@@ -332,6 +332,7 @@ public class CardImageRenderer {
public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) { public static void drawZoom(Graphics g, CardView card, GameView gameView, boolean altState, float x, float y, float w, float h, float dispW, float dispH, boolean isCurrentCard) {
boolean canshow = MatchController.instance.mayView(card); boolean canshow = MatchController.instance.mayView(card);
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true); final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
boolean fullborder = image.toString().contains(".fullborder.");
FImage sleeves = MatchController.getPlayerSleeve(card.getOwner()); FImage sleeves = MatchController.getPlayerSleeve(card.getOwner());
if (image == null) { //draw details if can't draw zoom if (image == null) { //draw details if can't draw zoom
drawDetails(g, card, gameView, altState, x, y, w, h); drawDetails(g, card, gameView, altState, x, y, w, h);
@@ -363,7 +364,7 @@ public class CardImageRenderer {
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90); g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
else { else {
g.drawRotatedImage(FSkin.getBorders().get(0), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90); g.drawRotatedImage(FSkin.getBorders().get(0), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x+radius/2, new_y+radius/2, new_w*0.96f, new_h*0.96f, (new_x+radius/2) + (new_w*0.96f) / 2, (new_y+radius/2) + (new_h*0.96f) / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image, fullborder), new_x+radius/2, new_y+radius/2, new_w*0.96f, new_h*0.96f, (new_x+radius/2) + (new_w*0.96f) / 2, (new_y+radius/2) + (new_h*0.96f) / 2, -90);
} }
} }
else else
@@ -375,7 +376,7 @@ public class CardImageRenderer {
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
else { else {
g.drawRotatedImage(FSkin.getBorders().get(ImageCache.getFSkinBorders(card)), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawRotatedImage(FSkin.getBorders().get(ImageCache.getFSkinBorders(card)), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x + radius / 2, new_y + radius / 2, new_w * 0.96f, new_h * 0.96f, (new_x + radius / 2) + (new_w * 0.96f) / 2, (new_y + radius / 2) + (new_h * 0.96f) / 2, isAftermath ? 90 : -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image, fullborder), new_x + radius / 2, new_y + radius / 2, new_w * 0.96f, new_h * 0.96f, (new_x + radius / 2) + (new_w * 0.96f) / 2, (new_y + radius / 2) + (new_h * 0.96f) / 2, isAftermath ? 90 : -90);
} }
} }
else else
@@ -387,7 +388,7 @@ public class CardImageRenderer {
g.drawImage(image, x, y, w, h); g.drawImage(image, x, y, w, h);
else { else {
g.drawImage(ImageCache.getBorderImage(card, canshow), x, y, w, h); g.drawImage(ImageCache.getBorderImage(card, canshow), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f); g.drawImage(ImageCache.croppedBorderImage(image, fullborder), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f);
} }
} }
else { else {

View File

@@ -53,6 +53,7 @@ import forge.util.CardTranslation;
import forge.util.Utils; import forge.util.Utils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import forge.util.TextBounds; import forge.util.TextBounds;
import java.util.Arrays; import java.util.Arrays;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -400,6 +401,7 @@ public class CardRenderer {
public static void drawCard(Graphics g, IPaperCard pc, float x, float y, float w, float h, CardStackPosition pos) { public static void drawCard(Graphics g, IPaperCard pc, float x, float y, float w, float h, CardStackPosition pos) {
Texture image = new RendererCachedCardImage(pc, false).getImage(); Texture image = new RendererCachedCardImage(pc, false).getImage();
boolean fullborder = image.toString().contains(".fullborder.");
float radius = (h - w)/8; float radius = (h - w)/8;
if (image != null) { if (image != null) {
@@ -412,7 +414,7 @@ public class CardRenderer {
g.drawImage(image, x, y, w, h); g.drawImage(image, x, y, w, h);
else { else {
g.drawImage(ImageCache.getBorderImage(pc), x, y, w, h); g.drawImage(ImageCache.getBorderImage(pc), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f); g.drawImage(ImageCache.croppedBorderImage(image, fullborder), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f);
} }
} }
else else
@@ -436,6 +438,7 @@ public class CardRenderer {
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) { public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate) {
boolean canshow = MatchController.instance.mayView(card) && !ImageKeys.getTokenKey(ImageKeys.MORPH_IMAGE).equals(card.getCurrentState().getImageKey()); boolean canshow = MatchController.instance.mayView(card) && !ImageKeys.getTokenKey(ImageKeys.MORPH_IMAGE).equals(card.getCurrentState().getImageKey());
Texture image = new RendererCachedCardImage(card, false).getImage(); Texture image = new RendererCachedCardImage(card, false).getImage();
boolean fullborder = image.toString().contains(".fullborder.");
FImage sleeves = MatchController.getPlayerSleeve(card.getOwner()); FImage sleeves = MatchController.getPlayerSleeve(card.getOwner());
float radius = (h - w)/8; float radius = (h - w)/8;
@@ -451,7 +454,7 @@ public class CardRenderer {
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90); g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
else { else {
g.drawRotatedImage(FSkin.getBorders().get(0), x, y, w, h, x + w / 2, y + h / 2, -90); g.drawRotatedImage(FSkin.getBorders().get(0), x, y, w, h, x + w / 2, y + h / 2, -90);
g.drawRotatedImage(ImageCache.croppedBorderImage(image), x+radius/2.3f, y+radius/2, w*0.96f, h*0.96f, (x+radius/2.3f) + (w*0.96f) / 2, (y+radius/2) + (h*0.96f) / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image, fullborder), x+radius/2.3f, y+radius/2, w*0.96f, h*0.96f, (x+radius/2.3f) + (w*0.96f) / 2, (y+radius/2) + (h*0.96f) / 2, -90);
} }
} }
else else
@@ -464,7 +467,7 @@ public class CardRenderer {
else { else {
boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors(); boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors();
g.drawBorderImage(ImageCache.getBorderImage(card, canshow), ImageCache.getTint(card), x, y, w, h, t); //tint check for changed colors g.drawBorderImage(ImageCache.getBorderImage(card, canshow), ImageCache.getTint(card), x, y, w, h, t); //tint check for changed colors
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f); g.drawImage(ImageCache.croppedBorderImage(image, fullborder), x + radius / 2.4f, y + radius / 2, w * 0.96f, h * 0.96f);
} }
} }
else { else {