diff --git a/forge-gui-mobile/src/forge/CachedCardImage.java b/forge-gui-mobile/src/forge/CachedCardImage.java index 91fad648edd..a58ffff4a27 100644 --- a/forge-gui-mobile/src/forge/CachedCardImage.java +++ b/forge-gui-mobile/src/forge/CachedCardImage.java @@ -34,11 +34,7 @@ public abstract class CachedCardImage implements ImageFetcher.Callback { } public Texture getImage() { - return ImageCache.getImage(key, true, false); - } - - public Texture getImage(boolean mask) { - return ImageCache.getImage(key, true, mask); + return ImageCache.getImage(key, true); } public abstract void onImageFetched(); diff --git a/forge-gui-mobile/src/forge/Graphics.java b/forge-gui-mobile/src/forge/Graphics.java index fd314326040..474560e16ee 100644 --- a/forge-gui-mobile/src/forge/Graphics.java +++ b/forge-gui-mobile/src/forge/Graphics.java @@ -312,21 +312,21 @@ public class Graphics { } //adjust width/height so rectangle covers equivalent filled area - w = Math.round(w - 1); - h = Math.round(h - 1); + w = Math.round(w + 1); + h = Math.round(h + 1); startShape(ShapeType.Line); shapeRenderer.setColor(color); - x = adjustX(x); - float y2 = adjustY(y, h); - float x2 = x + w; - y = y2 + h; - //TODO: draw arcs at corners - shapeRenderer.line(x, y, x, y2); - shapeRenderer.line(x, y2, x2 + 1, y2); //+1 prevents corner not being filled - shapeRenderer.line(x2, y2, x2, y); - shapeRenderer.line(x2 + 1, y, x, y); //+1 prevents corner not being filled + shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 90f, 90f); + shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, 0), cornerRadius, 0f, 90f); + shapeRenderer.arc(adjustX(x) + w - cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 270, 90f); + shapeRenderer.arc(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, 0), cornerRadius, 180, 90f); + + shapeRenderer.rect(adjustX(x) + cornerRadius, adjustY(y, cornerRadius), w - 2*cornerRadius, cornerRadius); + shapeRenderer.rect(adjustX(x) + w - cornerRadius, adjustY(y + cornerRadius, h - 2*cornerRadius), cornerRadius, h - 2*cornerRadius); + shapeRenderer.rect(adjustX(x) + cornerRadius, adjustY(y + h - cornerRadius, cornerRadius), w - 2*cornerRadius, cornerRadius); + shapeRenderer.rect(adjustX(x), adjustY(y + cornerRadius, h - 2*cornerRadius), cornerRadius, h - 2*cornerRadius); endShape(); @@ -343,6 +343,30 @@ public class Graphics { 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) { drawRect(thickness, skinColor.getColor(), x, y, w, h); } diff --git a/forge-gui-mobile/src/forge/assets/ImageCache.java b/forge-gui-mobile/src/forge/assets/ImageCache.java index 280771ac490..97d7e6845f7 100644 --- a/forge-gui-mobile/src/forge/assets/ImageCache.java +++ b/forge-gui-mobile/src/forge/assets/ImageCache.java @@ -82,11 +82,7 @@ public class ImageCache { } public static Texture getImage(InventoryItem ii) { - return getImage(ii.getImageKey(false), true, false); - } - - public static Texture getImage(InventoryItem ii, Boolean mask) { - return getImage(ii.getImageKey(false), true, mask); + return getImage(ii.getImageKey(false), true); } /** @@ -112,9 +108,6 @@ public class ImageCache { *
*/ 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)) { return null; } @@ -133,8 +126,6 @@ public class ImageCache { Texture image; if (useDefaultIfNotFound) { // 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); if (image != null) { return image; } diff --git a/forge-gui-mobile/src/forge/assets/ImageLoader.java b/forge-gui-mobile/src/forge/assets/ImageLoader.java index e1d59279273..ef26a9eced0 100644 --- a/forge-gui-mobile/src/forge/assets/ImageLoader.java +++ b/forge-gui-mobile/src/forge/assets/ImageLoader.java @@ -3,11 +3,7 @@ package forge.assets; import java.io.File; 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.TextureData; -import com.badlogic.gdx.graphics.glutils.PixmapTextureData; import org.cache2k.integration.CacheLoader; import forge.Forge; @@ -16,21 +12,15 @@ import forge.ImageKeys; final class ImageLoader extends CacheLoader