This commit is contained in:
Alessandro Coli
2019-10-09 22:20:15 +02:00
8 changed files with 189 additions and 134 deletions

View File

@@ -34,11 +34,7 @@ public abstract class CachedCardImage implements ImageFetcher.Callback {
} }
public Texture getImage() { public Texture getImage() {
return ImageCache.getImage(key, true, false); return ImageCache.getImage(key, true);
}
public Texture getImage(boolean mask) {
return ImageCache.getImage(key, true, mask);
} }
public abstract void onImageFetched(); public abstract void onImageFetched();

View File

@@ -312,21 +312,21 @@ public class Graphics {
} }
//adjust width/height so rectangle covers equivalent filled area //adjust width/height so rectangle covers equivalent filled area
w = Math.round(w - 1); w = Math.round(w + 1);
h = Math.round(h - 1); h = Math.round(h + 1);
startShape(ShapeType.Line); startShape(ShapeType.Line);
shapeRenderer.setColor(color); shapeRenderer.setColor(color);
x = adjustX(x); shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 90f, 90f);
float y2 = adjustY(y, h); shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 0f, 90f);
float x2 = x + w; shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 270, 90f);
y = y2 + h; shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 180, 90f);
//TODO: draw arcs at corners
shapeRenderer.line(x, y, x, y2); shapeRenderer.rect(adjustX(x) + cornerRadius, adjustY(y, cornerRadius), w - 2*cornerRadius, cornerRadius);
shapeRenderer.line(x, y2, x2 + 1, y2); //+1 prevents corner not being filled shapeRenderer.rect(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, h - 2*cornerRadius), cornerRadius, h - 2*cornerRadius);
shapeRenderer.line(x2, y2, x2, y); shapeRenderer.rect(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, cornerRadius), w - 2*cornerRadius, cornerRadius);
shapeRenderer.line(x2 + 1, y, x, y); //+1 prevents corner not being filled shapeRenderer.rect(adjustX(x), adjustY(y + cornerRadius, h - 2*cornerRadius), cornerRadius, h - 2*cornerRadius);
endShape(); endShape();
@@ -343,6 +343,30 @@ public class Graphics {
batch.begin(); batch.begin();
} }
public void fillRoundRect(Color color, float x, float y, float w, float h, float radius) {
batch.end(); //must pause batch while rendering shapes
if (alphaComposite < 1) {
color = FSkinColor.alphaColor(color, color.a * alphaComposite);
}
if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL_BLEND);
}
startShape(ShapeType.Filled);
shapeRenderer.setColor(color);
shapeRenderer.circle(adjustX(x+radius), adjustY(y+radius, 0), radius);
shapeRenderer.circle(adjustX((x+w) - radius), adjustY(y+radius, 0), radius);
shapeRenderer.circle(adjustX(x+radius), adjustY((y+h) - radius, 0), radius);
shapeRenderer.circle(adjustX((x+w) - radius), adjustY((y+h) - radius, 0), radius);
shapeRenderer.rect(adjustX(x), adjustY(y+radius, h-radius*2), w, h-radius*2);
shapeRenderer.rect(adjustX(x+radius), adjustY(y, h), w-radius*2, h);
endShape();
if (color.a < 1) {
Gdx.gl.glDisable(GL_BLEND);
}
batch.begin();
}
public void drawRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h) { public void drawRect(float thickness, FSkinColor skinColor, float x, float y, float w, float h) {
drawRect(thickness, skinColor.getColor(), x, y, w, h); drawRect(thickness, skinColor.getColor(), x, y, w, h);
} }

View File

@@ -82,11 +82,7 @@ public class ImageCache {
} }
public static Texture getImage(InventoryItem ii) { public static Texture getImage(InventoryItem ii) {
return getImage(ii.getImageKey(false), true, false); return getImage(ii.getImageKey(false), true);
}
public static Texture getImage(InventoryItem ii, Boolean mask) {
return getImage(ii.getImageKey(false), true, mask);
} }
/** /**
@@ -112,9 +108,6 @@ public class ImageCache {
* </p> * </p>
*/ */
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound) { public static Texture getImage(String imageKey, boolean useDefaultIfNotFound) {
return getImage(imageKey, useDefaultIfNotFound, false);
}
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound, boolean maskCard) {
if (StringUtils.isEmpty(imageKey)) { if (StringUtils.isEmpty(imageKey)) {
return null; return null;
} }
@@ -133,8 +126,6 @@ public class ImageCache {
Texture image; Texture image;
if (useDefaultIfNotFound) { if (useDefaultIfNotFound) {
// Load from file and add to cache if not found in cache initially. // Load from file and add to cache if not found in cache initially.
if (maskCard)//if we add pixmap modification here, it will slow performance so we do this on the image loader lol :)...
imageKey += "#drawroundcorner#";
image = cache.get(imageKey); image = cache.get(imageKey);
if (image != null) { return image; } if (image != null) { return image; }

View File

@@ -3,11 +3,7 @@ package forge.assets;
import java.io.File; import java.io.File;
import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
import org.cache2k.integration.CacheLoader; import org.cache2k.integration.CacheLoader;
import forge.Forge; import forge.Forge;
@@ -16,21 +12,15 @@ import forge.ImageKeys;
final class ImageLoader extends CacheLoader<String, Texture> { final class ImageLoader extends CacheLoader<String, Texture> {
@Override @Override
public Texture load(String key) { public Texture load(String key) {
boolean mask = key.contains("#drawroundcorner#");
boolean alphaCard = false;
boolean textureFilter = Forge.isTextureFilteringEnabled(); boolean textureFilter = Forge.isTextureFilteringEnabled();
if (key.length() > 4){ File file = ImageKeys.getImageFile(key);
if ((key.substring(0,4).contains("LEA/")) || (key.substring(0,2).contains("A/")))
alphaCard = true;
//TODO dont add border on some sets???
}
File file = ImageKeys.getImageFile(key.replaceAll("#drawroundcorner#",""));
if (file != null) { if (file != null) {
FileHandle fh = new FileHandle(file); FileHandle fh = new FileHandle(file);
Texture t = new Texture(fh, textureFilter);
try { try {
return generateTexture(fh, t, mask, alphaCard, textureFilter); Texture t = new Texture(fh, textureFilter);
if (textureFilter)
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
return t;
} }
catch (Exception ex) { catch (Exception ex) {
Forge.log("Could not read image file " + fh.path() + "\n\nException:\n" + ex.toString()); Forge.log("Could not read image file " + fh.path() + "\n\nException:\n" + ex.toString());
@@ -38,81 +28,4 @@ final class ImageLoader extends CacheLoader<String, Texture> {
} }
return null; return null;
} }
public Texture generateTexture(FileHandle fh, Texture t, boolean mask, boolean alphaCard, boolean textureFilter) {
if (!mask) {
if (textureFilter)
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
return t;
}
Pixmap pImage = new Pixmap(fh);
int w = pImage.getWidth();
int h = pImage.getHeight();
int radius = alphaCard ? (h - w) / 6 : (h - w) / 8;
Pixmap pMask = createRoundedRectangle(w, h, radius, Color.RED);
drawPixelstoMask(pImage, pMask);
TextureData textureData = new PixmapTextureData(
pMask, //pixmap to use
Pixmap.Format.RGBA8888,
textureFilter, //use mipmaps
false, true);
t = new Texture(textureData);
if (textureFilter)
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
pImage.dispose();
pMask.dispose();
return t;
}
public Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
Pixmap ret = new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
//round corners
pixmap.fillCircle(cornerRadius, cornerRadius, cornerRadius);
pixmap.fillCircle(width - cornerRadius - 1, cornerRadius, cornerRadius);
pixmap.fillCircle(cornerRadius, height - cornerRadius - 1, cornerRadius);
pixmap.fillCircle(width - cornerRadius - 1, height - cornerRadius - 1, cornerRadius);
//two rectangle parts
pixmap.fillRectangle(cornerRadius, 0, width - cornerRadius * 2, height);
pixmap.fillRectangle(0, cornerRadius, width, height - cornerRadius * 2);
//draw rounded rectangle
ret.setColor(color);
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
if (pixmap.getPixel(x, y) != 0) ret.drawPixel(x, y);
}
}
pixmap.dispose();
return ret;
}
public void drawPixelstoMask(Pixmap pixmap, Pixmap mask){
int pixmapWidth = mask.getWidth();
int pixmapHeight = mask.getHeight();
Color pixelColor = new Color();
for (int x=0; x<pixmapWidth; x++){
for (int y=0; y<pixmapHeight; y++){
if (mask.getPixel(x, y) != 0) {
Color.rgba8888ToColor(pixelColor, pixmap.getPixel(x, y));
mask.setColor(pixelColor);
mask.drawPixel(x, y);
}
}
}
}
public void blendPixmaps(Pixmap pixmap, Pixmap mask, Pixmap model){
int pixmapWidth = pixmap.getWidth();
int pixmapHeight = pixmap.getHeight();
Color pixelColor = new Color();
Color maskPixelColor = new Color();
for (int x=0; x<pixmapWidth; x++){
for (int y=0; y<pixmapHeight; y++){
Color.rgba8888ToColor(pixelColor, pixmap.getPixel(x, y));
Color.rgba8888ToColor(maskPixelColor, mask.getPixel(x, y));
pixelColor.a = pixelColor.a * maskPixelColor.a;
model.setColor(pixelColor);
model.drawPixel(x, y);
}
}
}
} }

View File

@@ -1,7 +1,9 @@
package forge.card; package forge.card;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import forge.Graphics; import forge.Graphics;
import forge.assets.FImage; import forge.assets.FImage;
import forge.assets.ImageCache; import forge.assets.ImageCache;
@@ -22,6 +24,24 @@ public class CardImage implements FImage {
private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) { private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) {
return FModel.getPreferences().getPrefBoolean(preferenceName); return FModel.getPreferences().getPrefBoolean(preferenceName);
} }
public static TextureRegion croppedBorderImage(Texture image) {
float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale);
int rh = Math.round(image.getHeight()*rscale);
int rx = Math.round((image.getWidth() - rw)/2);
int ry = Math.round((image.getHeight() - rh)/2)-2;
TextureRegion rimage = new TextureRegion(image, rx, ry, rw, rh);
return rimage;
}
public static Color borderColor(PaperCard c) {
if (c == null)
return Color.valueOf("#1d1d1d");
CardEdition ed = FModel.getMagicDb().getEditions().get(c.getEdition());
if (ed != null && ed.isWhiteBorder())
return Color.valueOf("#fffffd");
return Color.valueOf("#1d1d1d");
}
@Override @Override
public float getWidth() { public float getWidth() {
@@ -38,9 +58,9 @@ 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) {
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
if (image == null) { //attempt to retrieve card image if needed if (image == null) { //attempt to retrieve card image if needed
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING); image = ImageCache.getImage(card);
image = ImageCache.getImage(card, mask);
if (image == null) { if (image == null) {
if (mask) //render this if mask is still loading if (mask) //render this if mask is still loading
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top);
@@ -53,7 +73,14 @@ public class CardImage implements FImage {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top);
} }
else { else {
g.drawImage(image, x, y, w, h); if (mask) {
float radius = (h - w)/8;
g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
g.drawImage(croppedBorderImage(image), x+radius/2.2f, y+radius/2, w*0.96f, h*0.96f);
}
else
g.drawImage(image, x, y, w, h);
} }
} }
} }

View File

@@ -2,6 +2,7 @@ package forge.card;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import forge.Graphics; import forge.Graphics;
@@ -323,10 +324,29 @@ public class CardImageRenderer {
x += pieceWidths[i]; x += pieceWidths[i];
} }
} }
public static TextureRegion croppedBorderImage(Texture image) {
float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale);
int rh = Math.round(image.getHeight()*rscale);
int rx = Math.round((image.getWidth() - rw)/2);
int ry = Math.round((image.getHeight() - rh)/2)-2;
TextureRegion rimage = new TextureRegion(image, rx, ry, rw, rh);
return rimage;
}
public static Color borderColor(CardView c) {
if (c == null)
return Color.valueOf("#1d1d1d");
CardStateView state = c.getCurrentState();
CardEdition ed = FModel.getMagicDb().getEditions().get(state.getSetCode());
if (ed != null && ed.isWhiteBorder() && state.getFoilIndex() == 0)
return Color.valueOf("#fffffd");
return Color.valueOf("#1d1d1d");
}
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 mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING); boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true, mask); //this one is currently using the mask, others are cropped and use generated borders from shaperenderer ...
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
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);
return; return;
@@ -343,21 +363,54 @@ public class CardImageRenderer {
drawCardImage(g, card, altState, x, y, w, h, CardStackPosition.Top); drawCardImage(g, card, altState, x, y, w, h, CardStackPosition.Top);
} }
else { else {
float radius = (h - w)/8;
float wh_Adj = ForgeConstants.isGdxPortLandscape && isCurrentCard ? 1.38f:1.0f; float wh_Adj = ForgeConstants.isGdxPortLandscape && isCurrentCard ? 1.38f:1.0f;
float new_w = w*wh_Adj; float new_w = w*wh_Adj;
float new_h = h*wh_Adj; float new_h = h*wh_Adj;
float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2:x; float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2:x;
float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2:y; float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2:y;
float new_xRotate = (dispW - new_h) /2;
float new_yRotate = (dispH - new_w) /2;
boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS); boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS);
boolean rotatePlane = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON); boolean rotatePlane = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON);
if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) { if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) {
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90); if (mask){
if (rotatePlane) {
g.drawRoundRect(3, borderColor(card), new_xRotate, new_yRotate, new_h, new_w, radius);
g.fillRoundRect(borderColor(card), new_xRotate, new_yRotate, new_h, new_w, radius);
}
else {
g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
}
g.drawRotatedImage(croppedBorderImage(image), new_x+radius/2.3f, new_y+radius/2, new_w*0.96f, new_h*0.96f, (new_x+radius/2.3f) + (new_w*0.96f) / 2, (new_y+radius/2) + (new_h*0.96f) / 2, -90);
}
else
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
} else if (rotateSplit && isCurrentCard && card.isSplitCard() && canLook) { } else if (rotateSplit && isCurrentCard && card.isSplitCard() && canLook) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath"); boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); if (mask){
if (rotateSplit) {
g.drawRoundRect(3, borderColor(card), new_xRotate, new_yRotate, new_h, new_w, radius);
g.fillRoundRect(borderColor(card), new_xRotate, new_yRotate, new_h, new_w, radius);
}
else {
g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
}
g.drawRotatedImage(croppedBorderImage(image), new_x+radius/2.3f, new_y+radius/2, new_w*0.96f, new_h*0.96f, (new_x+radius/2.3f) + (new_w*0.96f) / 2, (new_y+radius/2) + (new_h*0.96f) / 2, isAftermath ? 90 : -90);
}
else
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.drawImage(image, x, y, w, h); if (mask) {
g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
g.drawImage(croppedBorderImage(image), x+radius/2.4f, y+radius/2, w*0.96f, h*0.96f);
}
else
g.drawImage(image, x, y, w, h);
} }
} }
CardRenderer.drawFoilEffect(g, card, x, y, w, h, isCurrentCard && canLook && image != ImageCache.defaultImage); CardRenderer.drawFoilEffect(g, card, x, y, w, h, isCurrentCard && canLook && image != ImageCache.defaultImage);

View File

@@ -391,16 +391,51 @@ public class CardRenderer {
g.drawText(set, font, foreColor, x, y, w, h, false, Align.center, true); g.drawText(set, font, foreColor, x, y, w, h, false, Align.center, true);
} }
public static TextureRegion croppedBorderImage(Texture image) {
float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale);
int rh = Math.round(image.getHeight()*rscale);
int rx = Math.round((image.getWidth() - rw)/2);
int ry = Math.round((image.getHeight() - rh)/2)-2;
TextureRegion rimage = new TextureRegion(image, rx, ry, rw, rh);
return rimage;
}
public static Color borderColor(IPaperCard c) {
if (c == null)
return Color.valueOf("#1d1d1d");
CardEdition ed = FModel.getMagicDb().getEditions().get(c.getEdition());
if (ed != null && ed.isWhiteBorder())
return Color.valueOf("#fffffd");
return Color.valueOf("#1d1d1d");
}
public static Color borderColor(CardView c) {
if (c == null)
return Color.valueOf("#1d1d1d");
CardStateView state = c.getCurrentState();
CardEdition ed = FModel.getMagicDb().getEditions().get(state.getSetCode());
if (ed != null && ed.isWhiteBorder() && state.getFoilIndex() == 0)
return Color.valueOf("#fffffd");
return Color.valueOf("#1d1d1d");
}
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) {
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING); boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
Texture image = new RendererCachedCardImage(pc, false).getImage(mask); Texture image = new RendererCachedCardImage(pc, false).getImage();
if (image != null) { if (image != null) {
if (image == ImageCache.defaultImage) { if (image == ImageCache.defaultImage) {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos);
} }
else { else {
g.drawImage(image, x, y, w, h); if (mask) {
float radius = (h - w)/8;
g.drawRoundRect(3, borderColor(pc), x, y, w, h, radius);
g.fillRoundRect(borderColor(pc), x, y, w, h, radius);
g.drawImage(croppedBorderImage(image), x+radius/2.4f, y+radius/2, w*0.96f, h*0.96f);
}
else
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); final CardView card = CardView.getCardForUi(pc);
@@ -420,7 +455,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 mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING); boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
Texture image = new RendererCachedCardImage(card, false).getImage(mask); Texture image = new RendererCachedCardImage(card, false).getImage();
if (image != null) { if (image != null) {
if (image == ImageCache.defaultImage) { if (image == ImageCache.defaultImage) {
@@ -428,10 +463,26 @@ public class CardRenderer {
} }
else { else {
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()) && rotate) && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()) && rotate){
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90); if (mask) {
else float radius = (h - w)/8;
g.drawImage(image, x, y, w, h); g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
g.drawRotatedImage(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);
}
else
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
}
else {
if (mask) {
float radius = (h - w)/8;
g.drawRoundRect(3, borderColor(card), x, y, w, h, radius);
g.fillRoundRect(borderColor(card), x, y, w, h, radius);
g.drawImage(croppedBorderImage(image), x+radius/2.4f, y+radius/2, w*0.96f, h*0.96f);
}
else
g.drawImage(image, x, y, w, h);
}
} }
drawFoilEffect(g, card, x, y, w, h, false); drawFoilEffect(g, card, x, y, w, h, false);
} }

View File

@@ -302,8 +302,8 @@ public class SettingsPage extends TabPage<SettingsScreen> {
localizer.getMessage("nlDisableCardEffect")), localizer.getMessage("nlDisableCardEffect")),
4); 4);
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_BORDER_MASKING, lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_BORDER_MASKING,
"Experimental Round Border Mask", "Enable Round Border Mask",
"When enabled, the card corners are rounded (CPU/GPU Dependent atm)."), "When enabled, the card corners are rounded (Preferably Card with Full Borders)."),
4); 4);
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE, lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,