mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
New Faster Cache for Mobile - Cache2k, Add Border Masking Option
This commit is contained in:
@@ -11,6 +11,7 @@ import forge.game.Game;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.trigger.TriggerType;
|
import forge.game.trigger.TriggerType;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -106,7 +107,7 @@ public class BlockEffect extends SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(String.join(", ", blockers)).append(" block ").append(String.join(", ", attackers));
|
sb.append(StringUtils.join(blockers.toArray(), ", ")).append(" block ").append(StringUtils.join(attackers.toArray(), ", "));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,24 @@
|
|||||||
<artifactId>gdx-backend-android</artifactId>
|
<artifactId>gdx-backend-android</artifactId>
|
||||||
<version>1.9.10</version>
|
<version>1.9.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-base-bom</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-core</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-api</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|||||||
@@ -28,6 +28,20 @@
|
|||||||
-dontwarn org.slf4j.**
|
-dontwarn org.slf4j.**
|
||||||
-dontwarn javax.**
|
-dontwarn javax.**
|
||||||
|
|
||||||
|
# mandatory proguard rules for cache2k to keep the core implementation
|
||||||
|
-dontwarn org.cache2k.impl.xmlConfiguration.**
|
||||||
|
-dontwarn org.cache2k.impl.serverSide.**
|
||||||
|
-keep interface org.cache2k.spi.Cache2kCoreProvider
|
||||||
|
-keep public class * extends org.cache2k.spi.Cache2kCoreProvider
|
||||||
|
# optional proguard rules for cache2k, to keep XML configuration code
|
||||||
|
# if only programmatic configuration is used, these rules may be ommitted
|
||||||
|
-keep interface org.cache2k.core.spi.CacheConfigurationProvider
|
||||||
|
-keep public class * extends org.cache2k.core.spi.CacheConfigurationProvider
|
||||||
|
-keepclassmembers public class * extends org.cache2k.configuration.ConfigurationBean {
|
||||||
|
public void set*(...);
|
||||||
|
public ** get*();
|
||||||
|
}
|
||||||
|
|
||||||
-keep class forge.** { *; }
|
-keep class forge.** { *; }
|
||||||
-keep class com.thoughtworks.xstream.** { *; }
|
-keep class com.thoughtworks.xstream.** { *; }
|
||||||
-keep class org.apache.commons.lang3.** { *; }
|
-keep class org.apache.commons.lang3.** { *; }
|
||||||
|
|||||||
@@ -75,5 +75,23 @@
|
|||||||
<artifactId>gdx-backend-robovm</artifactId>
|
<artifactId>gdx-backend-robovm</artifactId>
|
||||||
<version>1.9.10</version>
|
<version>1.9.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-base-bom</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-core</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-api</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -80,5 +80,23 @@
|
|||||||
<artifactId>commons-cli</artifactId>
|
<artifactId>commons-cli</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-base-bom</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-core</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-api</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -70,6 +70,24 @@
|
|||||||
<artifactId>gdx-freetype</artifactId>
|
<artifactId>gdx-freetype</artifactId>
|
||||||
<version>1.9.10</version>
|
<version>1.9.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-base-bom</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-core</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.cache2k</groupId>
|
||||||
|
<artifactId>cache2k-api</artifactId>
|
||||||
|
<version>1.2.4.Final</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -34,7 +34,11 @@ public abstract class CachedCardImage implements ImageFetcher.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Texture getImage() {
|
public Texture getImage() {
|
||||||
return ImageCache.getImage(key, true);
|
return ImageCache.getImage(key, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture getImage(boolean mask) {
|
||||||
|
return ImageCache.getImage(key, true, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onImageFetched();
|
public abstract void onImageFetched();
|
||||||
|
|||||||
@@ -20,18 +20,17 @@ package forge.assets;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
import forge.game.player.IHasIcon;
|
import forge.game.player.IHasIcon;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.properties.ForgeConstants;
|
import forge.properties.ForgeConstants;
|
||||||
import forge.util.ImageUtil;
|
import forge.util.ImageUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.cache2k.Cache;
|
||||||
|
import org.cache2k.Cache2kBuilder;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,10 +51,14 @@ public class ImageCache {
|
|||||||
// short prefixes to save memory
|
// short prefixes to save memory
|
||||||
|
|
||||||
private static final Set<String> missingIconKeys = new HashSet<>();
|
private static final Set<String> missingIconKeys = new HashSet<>();
|
||||||
private static final LoadingCache<String, Texture> cache = CacheBuilder.newBuilder()
|
private static final Cache<String, Texture> cache = new Cache2kBuilder<String, Texture>() {}
|
||||||
.maximumSize(400)
|
.name("cache")
|
||||||
.expireAfterAccess(15,TimeUnit.MINUTES)
|
.entryCapacity(500)
|
||||||
.build(new ImageLoader());
|
.expireAfterWrite(15, TimeUnit.MINUTES)
|
||||||
|
.refreshAhead(true)
|
||||||
|
.permitNullValues(true)
|
||||||
|
.loader(new ImageLoader())
|
||||||
|
.build();
|
||||||
public static final Texture defaultImage;
|
public static final Texture defaultImage;
|
||||||
|
|
||||||
private static boolean imageLoaded, delayLoadRequested;
|
private static boolean imageLoaded, delayLoadRequested;
|
||||||
@@ -76,12 +79,16 @@ public class ImageCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
cache.invalidateAll();
|
cache.clear();
|
||||||
missingIconKeys.clear();
|
missingIconKeys.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Texture getImage(InventoryItem ii) {
|
public static Texture getImage(InventoryItem ii) {
|
||||||
return getImage(ii.getImageKey(false), true);
|
return getImage(ii.getImageKey(false), true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Texture getImage(InventoryItem ii, Boolean mask) {
|
||||||
|
return getImage(ii.getImageKey(false), true, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,6 +114,9 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -125,7 +135,10 @@ 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.
|
||||||
image = cache.getIfPresent(imageKey);
|
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);
|
||||||
|
|
||||||
if (image != null) { return image; }
|
if (image != null) { return image; }
|
||||||
|
|
||||||
if (imageLoaded) { //prevent loading more than one image each render for performance
|
if (imageLoaded) { //prevent loading more than one image each render for performance
|
||||||
@@ -139,15 +152,7 @@ public class ImageCache {
|
|||||||
imageLoaded = true;
|
imageLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try { image = cache.get(imageKey); }
|
||||||
image = cache.get(imageKey);
|
|
||||||
}
|
|
||||||
catch (final ExecutionException ex) {
|
|
||||||
if (!(ex.getCause() instanceof NullPointerException)) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
image = null;
|
|
||||||
}
|
|
||||||
catch (final Exception ex) {
|
catch (final Exception ex) {
|
||||||
image = null;
|
image = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,12 @@ 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.google.common.cache.CacheLoader;
|
import com.badlogic.gdx.graphics.TextureData;
|
||||||
|
import com.badlogic.gdx.graphics.glutils.PixmapTextureData;
|
||||||
|
import org.cache2k.integration.CacheLoader;
|
||||||
|
|
||||||
import forge.Forge;
|
import forge.Forge;
|
||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
@@ -12,27 +16,49 @@ 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) {
|
||||||
File file = ImageKeys.getImageFile(key);
|
boolean mask = key.contains("#drawroundcorner#");
|
||||||
|
boolean alphaCard = false;
|
||||||
|
boolean textureFilter = Forge.isTextureFilteringEnabled();
|
||||||
|
if (key.length() > 4){
|
||||||
|
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);
|
||||||
try {
|
try {
|
||||||
if (Forge.isTextureFilteringEnabled()) {
|
Texture t;
|
||||||
Texture t = new Texture(fh, true);
|
if (mask) {
|
||||||
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
Pixmap pImage = new Pixmap(fh);
|
||||||
|
int w = pImage.getWidth();
|
||||||
/* // Optional experimental feature: Anisotropic filtering
|
int h = pImage.getHeight();
|
||||||
GL20 gl = Gdx.gl20;
|
int radius = alphaCard ? (h - w) / 6 : (h - w) / 8;
|
||||||
if (gl != null && Gdx.graphics.supportsExtension("GL_EXT_texture_filter_anisotropic")) {
|
Pixmap pMask = createRoundedRectangle(w, h, radius, Color.RED);
|
||||||
FloatBuffer buffer = BufferUtils.newFloatBuffer(16);
|
drawPixelstoMask(pImage, pMask);
|
||||||
gl.glGetFloatv(GL20.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, buffer);
|
TextureData textureData = new PixmapTextureData(
|
||||||
float maxAniso = buffer.get(0);
|
pMask, //pixmap to use
|
||||||
|
Pixmap.Format.RGBA8888,
|
||||||
t.bind();
|
textureFilter, //use mipmaps
|
||||||
gl.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAniso);
|
false, true);
|
||||||
} */
|
if (textureFilter)
|
||||||
|
{
|
||||||
|
t = new Texture(textureData);
|
||||||
|
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||||
|
} else {
|
||||||
|
t = new Texture(textureData);
|
||||||
|
}
|
||||||
|
pImage.dispose();
|
||||||
|
pMask.dispose();
|
||||||
return t;
|
return t;
|
||||||
} else {
|
} else {
|
||||||
return new Texture(fh);
|
if (textureFilter) {
|
||||||
|
t = new Texture(fh, true);
|
||||||
|
t.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return new Texture(fh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
@@ -41,4 +67,57 @@ final class ImageLoader extends CacheLoader<String, Texture> {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import forge.assets.ImageCache;
|
|||||||
import forge.card.CardRenderer.CardStackPosition;
|
import forge.card.CardRenderer.CardStackPosition;
|
||||||
import forge.game.card.CardView;
|
import forge.game.card.CardView;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
|
import forge.model.FModel;
|
||||||
|
import forge.properties.ForgePreferences;
|
||||||
import forge.toolbox.FCardPanel;
|
import forge.toolbox.FCardPanel;
|
||||||
|
|
||||||
public class CardImage implements FImage {
|
public class CardImage implements FImage {
|
||||||
@@ -17,6 +19,9 @@ public class CardImage implements FImage {
|
|||||||
public CardImage(PaperCard card0) {
|
public CardImage(PaperCard card0) {
|
||||||
card = card0;
|
card = card0;
|
||||||
}
|
}
|
||||||
|
private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) {
|
||||||
|
return FModel.getPreferences().getPrefBoolean(preferenceName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getWidth() {
|
public float getWidth() {
|
||||||
@@ -34,8 +39,12 @@ 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) {
|
||||||
if (image == null) { //attempt to retrieve card image if needed
|
if (image == null) { //attempt to retrieve card image if needed
|
||||||
image = ImageCache.getImage(card);
|
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
|
image = ImageCache.getImage(card, mask);
|
||||||
if (image == null) {
|
if (image == null) {
|
||||||
|
if (mask) //render this if mask is still loading
|
||||||
|
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top);
|
||||||
|
|
||||||
return; //can't draw anything if can't be loaded yet
|
return; //can't draw anything if can't be loaded yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,7 +325,8 @@ 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) {
|
||||||
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true);
|
boolean mask = isPreferenceEnabled(ForgePreferences.FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
|
final Texture image = ImageCache.getImage(card.getState(altState).getImageKey(MatchController.instance.getLocalPlayers()), true, mask);
|
||||||
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;
|
||||||
@@ -521,4 +522,8 @@ public class CardImageRenderer {
|
|||||||
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
||||||
g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, Align.center, true);
|
g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, Align.center, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isPreferenceEnabled(ForgePreferences.FPref preferenceName) {
|
||||||
|
return FModel.getPreferences().getPrefBoolean(preferenceName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,7 +392,8 @@ 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();
|
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
|
Texture image = new RendererCachedCardImage(pc, false).getImage(mask);
|
||||||
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (image == ImageCache.defaultImage) {
|
if (image == ImageCache.defaultImage) {
|
||||||
@@ -409,13 +410,17 @@ public class CardRenderer {
|
|||||||
drawFoilEffect(g, card, x, y, w, h, false);
|
drawFoilEffect(g, card, x, y, w, h, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { //draw cards without textures as just a black rectangle
|
else {
|
||||||
g.fillRect(Color.BLACK, x, y, w, h);
|
if (mask) //render this if mask is still loading
|
||||||
|
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos);
|
||||||
|
else //draw cards without textures as just a black rectangle
|
||||||
|
g.fillRect(Color.BLACK, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
Texture image = new RendererCachedCardImage(card, false).getImage();
|
boolean mask = isPreferenceEnabled(FPref.UI_ENABLE_BORDER_MASKING);
|
||||||
|
Texture image = new RendererCachedCardImage(card, false).getImage(mask);
|
||||||
|
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
if (image == ImageCache.defaultImage) {
|
if (image == ImageCache.defaultImage) {
|
||||||
@@ -430,8 +435,11 @@ public class CardRenderer {
|
|||||||
}
|
}
|
||||||
drawFoilEffect(g, card, x, y, w, h, false);
|
drawFoilEffect(g, card, x, y, w, h, false);
|
||||||
}
|
}
|
||||||
else { //draw cards without textures as just a black rectangle
|
else {
|
||||||
g.fillRect(Color.BLACK, x, y, w, h);
|
if (mask) //render this if mask is still loading
|
||||||
|
CardImageRenderer.drawCardImage(g, card, false, x, y, w, h, pos);
|
||||||
|
else //draw cards without textures as just a black rectangle
|
||||||
|
g.fillRect(Color.BLACK, x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,6 +301,10 @@ public class SettingsPage extends TabPage<SettingsScreen> {
|
|||||||
localizer.getMessage("lblDisableCardEffect"),
|
localizer.getMessage("lblDisableCardEffect"),
|
||||||
localizer.getMessage("nlDisableCardEffect")),
|
localizer.getMessage("nlDisableCardEffect")),
|
||||||
4);
|
4);
|
||||||
|
lstSettings.addItem(new BooleanSetting(FPref.UI_ENABLE_BORDER_MASKING,
|
||||||
|
"Enable Round Border Mask",
|
||||||
|
"When enabled, the card corners are rounded (Longer Caching)."),
|
||||||
|
4);
|
||||||
|
|
||||||
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,
|
lstSettings.addItem(new CustomSelectSetting(FPref.UI_CARD_COUNTER_DISPLAY_TYPE,
|
||||||
localizer.getMessage("cbpCounterDisplayType"),
|
localizer.getMessage("cbpCounterDisplayType"),
|
||||||
|
|||||||
@@ -134,6 +134,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
|||||||
UI_ROTATE_SPLIT_CARDS("true"),
|
UI_ROTATE_SPLIT_CARDS("true"),
|
||||||
UI_DYNAMIC_PLANECHASE_BG("false"),
|
UI_DYNAMIC_PLANECHASE_BG("false"),
|
||||||
UI_DISABLE_IMAGES_EFFECT_CARDS("false"),
|
UI_DISABLE_IMAGES_EFFECT_CARDS("false"),
|
||||||
|
UI_ENABLE_BORDER_MASKING("false"),
|
||||||
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
UI_ALLOW_ORDER_GRAVEYARD_WHEN_NEEDED ("Never"),
|
||||||
UI_DEFAULT_FONT_SIZE("12"),
|
UI_DEFAULT_FONT_SIZE("12"),
|
||||||
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
UI_SELECT_FROM_CARD_DISPLAYS("true"),
|
||||||
|
|||||||
Reference in New Issue
Block a user