mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
fix PW Crop
This commit is contained in:
committed by
leriomaggio
parent
32fda05aed
commit
ee9133be3d
@@ -32,7 +32,7 @@ public class CardAvatarImage implements FImage {
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||||
//force to get the avatar since the the cardartcache & loadingcache is always cleared on screen change or the battle bar will display black
|
//force to get the avatar since the the cardartcache & loadingcache is always cleared on screen change or the battle bar will display black
|
||||||
image = CardRenderer.getCardArt(imageKey, false, false, false, false, false, false, false);
|
image = CardRenderer.getCardArt(imageKey, false, false, false, false, false, false, false, false);
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
return; //can't draw anything if can't be loaded yet
|
return; //can't draw anything if can't be loaded yet
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public class CardImageRenderer {
|
|||||||
g.drawImage(cardArt, x, y, w, h);
|
g.drawImage(cardArt, x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
if (altState) {
|
if (altState) {
|
||||||
FImageComplex altArt = CardRenderer.getAlternateCardArt(cv.getAlternateState().getImageKey());
|
FImageComplex altArt = CardRenderer.getAlternateCardArt(cv.getAlternateState().getImageKey(), cv.getAlternateState().isPlaneswalker());
|
||||||
g.drawImage(altArt, x, y, w, h);
|
g.drawImage(altArt, x, y, w, h);
|
||||||
} else {
|
} else {
|
||||||
g.drawImage(cardArt, x, y, w, h);
|
g.drawImage(cardArt, x, y, w, h);
|
||||||
|
|||||||
@@ -207,15 +207,15 @@ public class CardRenderer {
|
|||||||
|
|
||||||
public static FImageComplex getCardArt(IPaperCard pc, boolean backFace) {
|
public static FImageComplex getCardArt(IPaperCard pc, boolean backFace) {
|
||||||
CardType type = pc.getRules().getType();
|
CardType type = pc.getRules().getType();
|
||||||
return getCardArt(pc.getImageKey(backFace), pc.getRules().getSplitType() == CardSplitType.Split, type.isPlane() || type.isPhenomenon(),pc.getRules().getOracleText().contains("Aftermath"), type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), CardSplitType.Flip.equals(pc.getRules().getSplitType()));
|
return getCardArt(pc.getImageKey(backFace), pc.getRules().getSplitType() == CardSplitType.Split, type.isPlane() || type.isPhenomenon(),pc.getRules().getOracleText().contains("Aftermath"), type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), CardSplitType.Flip.equals(pc.getRules().getSplitType()), type.isPlaneswalker());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FImageComplex getCardArt(CardView card) {
|
public static FImageComplex getCardArt(CardView card) {
|
||||||
CardTypeView type = card.getCurrentState().getType();
|
CardTypeView type = card.getCurrentState().getType();
|
||||||
return getCardArt(card.getCurrentState().getImageKey(), card.isSplitCard(), type.isPlane() || type.isPhenomenon(),card.getText().contains("Aftermath"), type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), card.isFlipCard());
|
return getCardArt(card.getCurrentState().getImageKey(), card.isSplitCard(), type.isPlane() || type.isPhenomenon(),card.getText().contains("Aftermath"), type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), card.isFlipCard(), type.isPlaneswalker());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard, boolean isHorizontalCard, boolean isAftermathCard, boolean isSaga, boolean isClass, boolean isDungeon, boolean isFlipCard) {
|
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard, boolean isHorizontalCard, boolean isAftermathCard, boolean isSaga, boolean isClass, boolean isDungeon, boolean isFlipCard, boolean isPlanesWalker) {
|
||||||
FImageComplex cardArt = cardArtCache.get(imageKey);
|
FImageComplex cardArt = cardArtCache.get(imageKey);
|
||||||
if (cardArt == null) {
|
if (cardArt == null) {
|
||||||
Texture image = new RendererCachedCardImage(imageKey, true).getImage();
|
Texture image = new RendererCachedCardImage(imageKey, true).getImage();
|
||||||
@@ -227,7 +227,12 @@ public class CardRenderer {
|
|||||||
float x, y;
|
float x, y;
|
||||||
float w = image.getWidth();
|
float w = image.getWidth();
|
||||||
float h = image.getHeight();
|
float h = image.getHeight();
|
||||||
if (isFlipCard) {
|
if (isPlanesWalker) {
|
||||||
|
x = w * 0.09f;
|
||||||
|
y = h * 0.11f;
|
||||||
|
w -= 2f * x;
|
||||||
|
h -= 5.71f * y;
|
||||||
|
} else if (isFlipCard) {
|
||||||
x = w * 0.09f;
|
x = w * 0.09f;
|
||||||
y = h * 0.32f;
|
y = h * 0.32f;
|
||||||
w -= 2f * x;
|
w -= 2f * x;
|
||||||
@@ -306,8 +311,7 @@ public class CardRenderer {
|
|||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (image == ImageCache.defaultImage) {
|
if (image == ImageCache.defaultImage) {
|
||||||
cardArt = CardImageRenderer.forgeArt;
|
cardArt = CardImageRenderer.forgeArt;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
float x, y;
|
float x, y;
|
||||||
float w = image.getWidth();
|
float w = image.getWidth();
|
||||||
float h = image.getHeight();
|
float h = image.getHeight();
|
||||||
@@ -326,7 +330,7 @@ public class CardRenderer {
|
|||||||
return cardArt;
|
return cardArt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FImageComplex getAlternateCardArt(final String imageKey) {
|
public static FImageComplex getAlternateCardArt(final String imageKey, boolean isPlanesWalker) {
|
||||||
FImageComplex cardArt = cardArtCache.get("Alternate_"+imageKey);
|
FImageComplex cardArt = cardArtCache.get("Alternate_"+imageKey);
|
||||||
if (cardArt == null) {
|
if (cardArt == null) {
|
||||||
Texture image = new CachedCardImage(imageKey) {
|
Texture image = new CachedCardImage(imageKey) {
|
||||||
@@ -339,24 +343,30 @@ public class CardRenderer {
|
|||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (image == ImageCache.defaultImage) {
|
if (image == ImageCache.defaultImage) {
|
||||||
cardArt = CardImageRenderer.forgeArt;
|
cardArt = CardImageRenderer.forgeArt;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
float x, y;
|
float x, y;
|
||||||
float w = image.getWidth();
|
float w = image.getWidth();
|
||||||
float h = image.getHeight();
|
float h = image.getHeight();
|
||||||
x = w * 0.1f;
|
if (isPlanesWalker) {
|
||||||
y = h * 0.11f;
|
x = w * 0.09f;
|
||||||
w -= 2 * x;
|
y = h * 0.11f;
|
||||||
h *= CARD_ART_HEIGHT_PERCENTAGE;
|
w -= 2f * x;
|
||||||
float ratioRatio = w / h / CARD_ART_RATIO;
|
h -= 5.71f * y;
|
||||||
if (ratioRatio > 1) { //if too wide, shrink width
|
} else {
|
||||||
float dw = w * (ratioRatio - 1);
|
x = w * 0.1f;
|
||||||
w -= dw;
|
y = h * 0.11f;
|
||||||
x += dw / 2;
|
w -= 2 * x;
|
||||||
} else { //if too tall, shrink height
|
h *= CARD_ART_HEIGHT_PERCENTAGE;
|
||||||
float dh = h * (1 - ratioRatio);
|
float ratioRatio = w / h / CARD_ART_RATIO;
|
||||||
h -= dh;
|
if (ratioRatio > 1) { //if too wide, shrink width
|
||||||
y += dh / 2;
|
float dw = w * (ratioRatio - 1);
|
||||||
|
w -= dw;
|
||||||
|
x += dw / 2;
|
||||||
|
} else { //if too tall, shrink height
|
||||||
|
float dh = h * (1 - ratioRatio);
|
||||||
|
h -= dh;
|
||||||
|
y += dh / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
|
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user