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.ImageKey, imageKey);
}
public PlayerView getOwner() {
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*/
imageLoaded = false;
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;
@@ -349,7 +349,7 @@ public class ImageCache {
radius = 22;
updateImageRecord(cardTexture.toString(),
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;
}
@@ -444,8 +444,8 @@ public class ImageCache {
return 1;
return 0;
}
public void updateImageRecord(String textureString, String colorValue, Boolean isClosertoWhite, int radius) {
imageRecord.get().put(textureString, new ImageRecord(colorValue, isClosertoWhite, radius));
public void updateImageRecord(String textureString, String colorValue, Boolean isClosertoWhite, int radius, boolean fullborder) {
imageRecord.get().put(textureString, new ImageRecord(colorValue, isClosertoWhite, radius, fullborder));
}
public int getRadius(Texture t) {
@@ -460,6 +460,15 @@ public class ImageCache {
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) {
ImageRecord record = imageRecord.get().get(textureString);
if (record == null)
@@ -544,11 +553,13 @@ public class ImageCache {
String colorValue;
Boolean isCloserToWhite;
Integer cardRadius;
boolean isFullBorder;
ImageRecord(String colorString, Boolean closetoWhite, int radius) {
ImageRecord(String colorString, Boolean closetoWhite, int radius, boolean fullborder) {
colorValue = colorString;
isCloserToWhite = closetoWhite;
cardRadius = radius;
isFullBorder = fullborder;
}
}
}

View File

@@ -34,21 +34,22 @@ public class CardImage implements FImage {
@Override
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
image = ImageCache.getInstance().getImage(card);
if (image == null) {
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
}
}
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 {
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);
else {
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 (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);
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);
@@ -827,7 +827,7 @@ public class CardImageRenderer {
} else if (rotateSplit && isCurrentCard && card.isSplitCard() && canshow && !card.isFaceDown()) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
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);
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);
@@ -843,7 +843,7 @@ public class CardImageRenderer {
if (card.isSplitCard() && rotateSplit && isCurrentCard) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
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);
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);
@@ -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);
} else {
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);
else {
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);
}
} 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);
else {
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) {
Texture image = new RendererCachedCardImage(pc, false).getImage();
final CardView card = CardView.getCardForUi(pc);
float radius = (h - w) / 8;
float croppedArea = isModernFrame(pc) ? CROP_MULTIPLIER : 0.97f;
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);
} else {
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);
else {
//tint the border
@@ -622,7 +623,6 @@ public class CardRenderer {
g.drawImage(image, x, y, w, h);
}
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
card.getCurrentState().setFoilIndexOverride(-1);
}
@@ -630,7 +630,7 @@ public class CardRenderer {
}
} else {
//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)
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane() || (card.getCurrentState().isBattle() && !showAltState) || (card.getAlternateState() != null && card.getAlternateState().isBattle() && showAltState)) && rotate) {
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);
else {
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);
} else {
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);
else {
//boolean t = (card.getCurrentState().getOriginalColors() != card.getCurrentState().getColors()) || card.getCurrentState().hasChangeColors();