Merge pull request #7933 from kevlahnota/master2

fix rounded borders for tokens since it gets the full bordered image …
This commit is contained in:
kevlahnota
2025-07-04 23:05:21 +08:00
committed by GitHub
5 changed files with 30 additions and 19 deletions

View File

@@ -101,7 +101,6 @@ public class CardView extends GameEntityView {
set(TrackableProperty.Controller, ownerAndController); set(TrackableProperty.Controller, ownerAndController);
set(TrackableProperty.ImageKey, imageKey); set(TrackableProperty.ImageKey, imageKey);
} }
public PlayerView getOwner() { public PlayerView getOwner() {
return get(TrackableProperty.Owner); return get(TrackableProperty.Owner);
} }

View File

@@ -295,7 +295,7 @@ public class ImageCache {
image fetcher to update automatically after the card image/s are downloaded*/ image fetcher to update automatically after the card image/s are downloaded*/
imageLoaded = false; imageLoaded = false;
if (image != null && imageRecord.get().get(image.toString()) == null) if (image != null && imageRecord.get().get(image.toString()) == null)
imageRecord.get().put(image.toString(), new ImageRecord(Color.valueOf("#171717").toString(), false, getRadius(image))); //black border imageRecord.get().put(image.toString(), new ImageRecord(Color.valueOf("#171717").toString(), false, getRadius(image), image.toString().contains(".fullborder.") || image.toString().contains("tokens"))); //black border
} }
} }
return image; return image;
@@ -349,7 +349,7 @@ public class ImageCache {
radius = 22; radius = 22;
updateImageRecord(cardTexture.toString(), updateImageRecord(cardTexture.toString(),
borderless ? Color.valueOf("#171717").toString() : isCloserToWhite(getpixelColor(cardTexture)).getLeft(), borderless ? Color.valueOf("#171717").toString() : isCloserToWhite(getpixelColor(cardTexture)).getLeft(),
!borderless && isCloserToWhite(getpixelColor(cardTexture)).getRight(), radius); !borderless && isCloserToWhite(getpixelColor(cardTexture)).getRight(), radius, cardTexture.toString().contains(".fullborder.") || cardTexture.toString().contains("tokens"));
} }
return cardTexture; return cardTexture;
} }
@@ -444,8 +444,8 @@ public class ImageCache {
return 1; return 1;
return 0; return 0;
} }
public void updateImageRecord(String textureString, String colorValue, Boolean isClosertoWhite, int radius) { public void updateImageRecord(String textureString, String colorValue, Boolean isClosertoWhite, int radius, boolean fullborder) {
imageRecord.get().put(textureString, new ImageRecord(colorValue, isClosertoWhite, radius)); imageRecord.get().put(textureString, new ImageRecord(colorValue, isClosertoWhite, radius, fullborder));
} }
public int getRadius(Texture t) { public int getRadius(Texture t) {
@@ -460,6 +460,15 @@ public class ImageCache {
return i; return i;
} }
public boolean isFullBorder(Texture image) {
if (image == null)
return false;
ImageRecord record = imageRecord.get().get(image.toString());
if (record == null)
return false;
return record.isFullBorder;
}
public FImage getBorder(String textureString) { public FImage getBorder(String textureString) {
ImageRecord record = imageRecord.get().get(textureString); ImageRecord record = imageRecord.get().get(textureString);
if (record == null) if (record == null)
@@ -544,11 +553,13 @@ public class ImageCache {
String colorValue; String colorValue;
Boolean isCloserToWhite; Boolean isCloserToWhite;
Integer cardRadius; Integer cardRadius;
boolean isFullBorder;
ImageRecord(String colorString, Boolean closetoWhite, int radius) { ImageRecord(String colorString, Boolean closetoWhite, int radius, boolean fullborder) {
colorValue = colorString; colorValue = colorString;
isCloserToWhite = closetoWhite; isCloserToWhite = closetoWhite;
cardRadius = radius; cardRadius = radius;
isFullBorder = fullborder;
} }
} }
} }

View File

@@ -34,21 +34,22 @@ public class CardImage 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) {
CardView cv = CardView.getCardForUi(card);
if (image == null) { //attempt to retrieve card image if needed if (image == null) { //attempt to retrieve card image if needed
image = ImageCache.getInstance().getImage(card); image = ImageCache.getInstance().getImage(card);
if (image == null) { if (image == null) {
if (!Forge.enableUIMask.equals("Off")) //render this if mask is still loading if (!Forge.enableUIMask.equals("Off")) //render this if mask is still loading
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top, Forge.enableUIMask.equals("Art"), true); CardImageRenderer.drawCardImage(g, cv, false, x, y, w, h, CardStackPosition.Top, Forge.enableUIMask.equals("Art"), true);
return; //can't draw anything if can't be loaded yet return; //can't draw anything if can't be loaded yet
} }
} }
if (image == ImageCache.getInstance().getDefaultImage() || Forge.enableUIMask.equals("Art")) { if (image == ImageCache.getInstance().getDefaultImage() || Forge.enableUIMask.equals("Art")) {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top, true, true); CardImageRenderer.drawCardImage(g, cv, false, x, y, w, h, CardStackPosition.Top, true, true);
} else { } else {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, null, x, y, w, h, false, false); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
float radius = (h - w) / 8; float radius = (h - w) / 8;

View File

@@ -814,7 +814,7 @@ public class CardImageRenderer {
} }
if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane() || (card.getCurrentState().isBattle() && !altState) || (card.getAlternateState() != null && card.getAlternateState().isBattle() && altState))) { if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane() || (card.getCurrentState().isBattle() && !altState) || (card.getAlternateState() != null && card.getAlternateState().isBattle() && altState))) {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90); g.drawCardRoundRect(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);
@@ -827,7 +827,7 @@ public class CardImageRenderer {
} else if (rotateSplit && isCurrentCard && card.isSplitCard() && canshow && !card.isFaceDown()) { } else if (rotateSplit && isCurrentCard && card.isSplitCard() && canshow && !card.isFaceDown()) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath"); boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawCardRoundRect(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.getInstance().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.getInstance().getFSkinBorders(card)), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
@@ -843,7 +843,7 @@ public class CardImageRenderer {
if (card.isSplitCard() && rotateSplit && isCurrentCard) { if (card.isSplitCard() && rotateSplit && isCurrentCard) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath"); boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawCardRoundRect(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.getInstance().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.getInstance().getFSkinBorders(card)), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
@@ -855,7 +855,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 {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, null, x, y, w, h, false, false); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
g.drawImage(ImageCache.getInstance().getBorderImage(image.toString()), ImageCache.getInstance().borderColor(image), x, y, w, h); g.drawImage(ImageCache.getInstance().getBorderImage(image.toString()), ImageCache.getInstance().borderColor(image), x, y, w, h);
@@ -872,7 +872,7 @@ public class CardImageRenderer {
g.drawImage(sleeves, x, y, w, h); g.drawImage(sleeves, x, y, w, h);
} }
} else if (Forge.enableUIMask.equals("Full") && canshow) { } else if (Forge.enableUIMask.equals("Full") && canshow) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, null, x, y, w, h, false, false); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
g.drawImage(ImageCache.getInstance().getBorderImage(image.toString()), ImageCache.getInstance().borderColor(image), x, y, w, h); g.drawImage(ImageCache.getInstance().getBorderImage(image.toString()), ImageCache.getInstance().borderColor(image), x, y, w, h);

View File

@@ -597,6 +597,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();
final CardView card = CardView.getCardForUi(pc);
float radius = (h - w) / 8; float radius = (h - w) / 8;
float croppedArea = isModernFrame(pc) ? CROP_MULTIPLIER : 0.97f; float croppedArea = isModernFrame(pc) ? CROP_MULTIPLIER : 0.97f;
float minusxy = isModernFrame(pc) ? 0.0f : 0.13f * radius; float minusxy = isModernFrame(pc) ? 0.0f : 0.13f * radius;
@@ -609,7 +610,7 @@ public class CardRenderer {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, true, true); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, true, true);
} else { } else {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, null, x, y, w, h, false, false); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
//tint the border //tint the border
@@ -622,7 +623,6 @@ public class CardRenderer {
g.drawImage(image, x, y, w, h); g.drawImage(image, x, y, w, h);
} }
if (pc.isFoil()) { //draw foil effect if needed if (pc.isFoil()) { //draw foil effect if needed
final CardView card = CardView.getCardForUi(pc);
if (card.getCurrentState().getFoilIndex() == 0) { //if foil finish not yet established, assign a random one if (card.getCurrentState().getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
card.getCurrentState().setFoilIndexOverride(-1); card.getCurrentState().setFoilIndexOverride(-1);
} }
@@ -630,7 +630,7 @@ public class CardRenderer {
} }
} else { } else {
//if card has invalid or no texture due to sudden changes in ImageCache, draw CardImageRenderer instead and wait for it to refresh automatically //if card has invalid or no texture due to sudden changes in ImageCache, draw CardImageRenderer instead and wait for it to refresh automatically
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, true, true); CardImageRenderer.drawCardImage(g, card, false, x, y, w, h, pos, true, true);
} }
} }
@@ -663,7 +663,7 @@ public class CardRenderer {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON) if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane() || (card.getCurrentState().isBattle() && !showAltState) || (card.getAlternateState() != null && card.getAlternateState().isBattle() && showAltState)) && rotate) { && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane() || (card.getCurrentState().isBattle() && !showAltState) || (card.getAlternateState() != null && card.getAlternateState().isBattle() && showAltState)) && rotate) {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, x, y, w, h, x + w / 2, y + h / 2, -90); g.drawCardRoundRect(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);
@@ -675,7 +675,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 {
if (Forge.enableUIMask.equals("Full") && canshow) { if (Forge.enableUIMask.equals("Full") && canshow) {
if (image.toString().contains(".fullborder.")) if (ImageCache.getInstance().isFullBorder(image))
g.drawCardRoundRect(image, crack_overlay, x, y, w, h, drawGray(card), magnify ? false : card.getDamage() > 0); g.drawCardRoundRect(image, crack_overlay, x, y, w, h, drawGray(card), magnify ? false : card.getDamage() > 0);
else { else {
//boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors(); //boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors();