Merge pull request #1997 from kevlahnota/newmaster2

update ImageCache, CardImageRenderer, CardRenderer, CardZoom and Rewa…
This commit is contained in:
Anthony Calosa
2022-12-02 17:23:17 +08:00
committed by GitHub
12 changed files with 813 additions and 483 deletions

View File

@@ -21,6 +21,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
import forge.assets.FImage; import forge.assets.FImage;
import forge.assets.FSkinColor; import forge.assets.FSkinColor;
import forge.assets.FSkinFont; import forge.assets.FSkinFont;
import forge.assets.ImageCache;
import forge.toolbox.FDisplayObject; import forge.toolbox.FDisplayObject;
import forge.util.TextBounds; import forge.util.TextBounds;
import forge.util.Utils; import forge.util.Utils;
@@ -49,6 +50,7 @@ public class Graphics {
private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp); private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp);
private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation); private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation);
private final ShaderProgram shaderHueShift = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragHueShift); private final ShaderProgram shaderHueShift = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragHueShift);
private final ShaderProgram shaderRoundedRect = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragRoundedRect);
private Texture dummyTexture = null; private Texture dummyTexture = null;
@@ -64,6 +66,10 @@ public class Graphics {
return shaderGrayscale; return shaderGrayscale;
} }
public ShaderProgram getShaderRoundedRect() {
return shaderRoundedRect;
}
public ShaderProgram getShaderWarp() { public ShaderProgram getShaderWarp() {
return shaderWarp; return shaderWarp;
} }
@@ -879,6 +885,44 @@ public class Graphics {
batch.begin(); batch.begin();
} }
public void drawCardRoundRect(Texture image, TextureRegion damage_overlay, float x, float y, float w, float h, boolean drawGray, boolean damaged) {
if (image == null)
return;
batch.end();
shaderRoundedRect.bind();
shaderRoundedRect.setUniformf("u_resolution", image.getWidth(), image.getHeight());
shaderRoundedRect.setUniformf("edge_radius", (image.getHeight() / image.getWidth()) * ImageCache.getRadius(image));
shaderRoundedRect.setUniformf("u_gray", drawGray ? 0.8f : 0f);
batch.setShader(shaderRoundedRect);
batch.begin();
//draw
batch.draw(image, adjustX(x), adjustY(y, h), w, h);
//reset
batch.end();
batch.setShader(null);
batch.begin();
if (damage_overlay != null && damaged)
batch.draw(damage_overlay, adjustX(x), adjustY(y, h), w, h);
}
public void drawCardRoundRect(Texture image, float x, float y, float w, float h, float originX, float originY, float rotation) {
if (image == null)
return;
batch.end();
shaderRoundedRect.bind();
shaderRoundedRect.setUniformf("u_resolution", image.getWidth(), image.getHeight());
shaderRoundedRect.setUniformf("edge_radius", (image.getHeight() / image.getWidth()) * ImageCache.getRadius(image));
shaderRoundedRect.setUniformf("u_gray", 0f);
batch.setShader(shaderRoundedRect);
batch.begin();
//draw
drawRotatedImage(image, x, y, w, h, originX, originY, 0, 0, image.getWidth(), image.getHeight(), rotation);
//reset
batch.end();
batch.setShader(null);
batch.begin();
}
public void drawHueShift(Texture image, float x, float y, float w, float h, Float time) { public void drawHueShift(Texture image, float x, float y, float w, float h, Float time) {
if (image == null) if (image == null)
return; return;
@@ -1287,6 +1331,7 @@ public class Graphics {
bitmapFont.setColor(color.r, color.g, color.b, alpha); bitmapFont.setColor(color.r, color.g, color.b, alpha);
bitmapFont.draw(batch, text, x, y); bitmapFont.draw(batch, text, x, y);
} }
public void drawText(BitmapFont bitmapFont, GlyphLayout layout, float x, float y) { public void drawText(BitmapFont bitmapFont, GlyphLayout layout, float x, float y) {
if (bitmapFont == null || layout == null) if (bitmapFont == null || layout == null)
return; return;

View File

@@ -42,6 +42,42 @@ public class Shaders {
" v_texCoords = a_texCoord0;\n" + " v_texCoords = a_texCoord0;\n" +
" gl_Position = u_projTrans * a_position;\n" + " gl_Position = u_projTrans * a_position;\n" +
"}"; "}";
public static final String fragRoundedRect = "#ifdef GL_ES\n" +
"#define LOWP lowp\n" +
"precision mediump float;\n" +
"#else\n" +
"#define LOWP \n" +
"#endif\n" +
"varying vec2 v_texCoords;\n" +
"uniform sampler2D u_texture;\n" +
"uniform vec2 u_resolution;\n" +
"uniform float edge_radius;\n" +
"uniform float u_gray;\n" +
"vec4 color = vec4(1.0,1.0,1.0,1.0);\n" +
"float gradientIntensity = 0.5;\n" +
"\n" +
"void main() {\n" +
" vec2 uv = v_texCoords;\n" +
" vec2 uv_base_center = uv * 2.0 - 1.0;\n" +
"\n" +
" vec2 half_resolution = u_resolution.xy * 0.5;\n" +
" vec2 abs_rounded_center = half_resolution.xy - edge_radius;\n" +
" vec2 abs_pixel_coord = vec2( abs(uv_base_center.x * half_resolution.x), abs(uv_base_center.y * half_resolution.y) );\n" +
"\n" +
" float alpha = 1.0;\n" +
" vec4 col = color * texture2D(u_texture, uv);\n" +
" if (abs_pixel_coord.x > abs_rounded_center.x && abs_pixel_coord.y > abs_rounded_center.y) {\n" +
" float r = length(abs_pixel_coord - abs_rounded_center);\n" +
" alpha = smoothstep(edge_radius, edge_radius - gradientIntensity, r);\n" +
" \n" +
" }\n" +
"\tif (u_gray > 0.0) {\n" +
"\t float grey = dot( col.rgb, vec3(0.22, 0.707, 0.071) );\n" +
"\t\tvec3 blendedColor = mix(col.rgb, vec3(grey), 1.0);\n" +
"\t\tcol = vec4(blendedColor.rgb, col.a);\n" +
"\t}\n" +
" gl_FragColor = col*alpha;\n" +
"}";
public static final String fragHueShift = "#ifdef GL_ES\n" + public static final String fragHueShift = "#ifdef GL_ES\n" +
"#define LOWP lowp\n" + "#define LOWP lowp\n" +
"precision mediump float;\n" + "precision mediump float;\n" +

View File

@@ -1,6 +1,8 @@
package forge.adventure.scene; package forge.adventure.scene;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.controllers.Controller;
import com.badlogic.gdx.controllers.Controllers;
import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
@@ -54,11 +56,26 @@ public class RewardScene extends UIScene {
ui.onButtonPress("done", () -> RewardScene.this.done()); ui.onButtonPress("done", () -> RewardScene.this.done());
ui.onButtonPress("detail",()->RewardScene.this.toggleToolTip()); ui.onButtonPress("detail",()->RewardScene.this.toggleToolTip());
detailButton = ui.findActor("detail"); detailButton = ui.findActor("detail");
if (Forge.getDeviceAdapter().getGamepads().isEmpty())
detailButton.setVisible(false); detailButton.setVisible(false);
doneButton = ui.findActor("done"); doneButton = ui.findActor("done");
} }
@Override
public void connected(Controller controller) {
super.connected(controller);
updateDetailButton();
}
@Override
public void disconnected(Controller controller) {
super.disconnected(controller);
updateDetailButton();
}
private void updateDetailButton() {
detailButton.setVisible(Controllers.getCurrent() != null);
detailButton.layout();
}
private void toggleToolTip() { private void toggleToolTip() {
Selectable selectable=getSelected(); Selectable selectable=getSelected();
@@ -159,6 +176,13 @@ public class RewardScene extends UIScene {
} }
} }
} }
@Override
public void enter() {
updateDetailButton();
super.enter();
}
private void showLootOrDone() { private void showLootOrDone() {
boolean exit = true; boolean exit = true;
for (Actor actor : new Array.ArrayIterator<>(generated)) { for (Actor actor : new Array.ArrayIterator<>(generated)) {

View File

@@ -17,51 +17,51 @@ public abstract class Scene implements Disposable {
@Override @Override
public void connected(Controller controller) { public void connected(Controller controller) {
Forge.getCurrentScene().connected(controller); Forge.getCurrentScene().connected(controller);
} }
@Override @Override
public void disconnected(Controller controller) { public void disconnected(Controller controller) {
Forge.getCurrentScene().disconnected(controller); Forge.getCurrentScene().disconnected(controller);
} }
@Override @Override
public boolean buttonDown(Controller controller, int i) { public boolean buttonDown(Controller controller, int i) {
return Forge.getCurrentScene().buttonDown(controller,i); return Forge.getCurrentScene().buttonDown(controller, i);
} }
@Override @Override
public boolean buttonUp(Controller controller, int i) { public boolean buttonUp(Controller controller, int i) {
return Forge.getCurrentScene().buttonUp(controller,i); return Forge.getCurrentScene().buttonUp(controller, i);
} }
@Override @Override
public boolean axisMoved(Controller controller, int i, float v) { public boolean axisMoved(Controller controller, int i, float v) {
return Forge.getCurrentScene().axisMoved(controller,i,v); return Forge.getCurrentScene().axisMoved(controller, i, v);
} }
} }
static private SceneControllerListener listener=null;
static private SceneControllerListener listener = null;
public Scene() { public Scene() {
if(listener==null) if (listener == null) {
{ listener = new SceneControllerListener();
listener=new SceneControllerListener();
Controllers.addListener(listener); Controllers.addListener(listener);
} }
} }
public static int getIntendedWidth() { public static int getIntendedWidth() {
return Forge.isLandscapeMode()? Config.instance().getConfigData().screenWidth:Config.instance().getConfigData().screenHeight; return Forge.isLandscapeMode() ? Config.instance().getConfigData().screenWidth : Config.instance().getConfigData().screenHeight;
} }
public static int getIntendedHeight() { public static int getIntendedHeight() {
return Forge.isLandscapeMode()? Config.instance().getConfigData().screenHeight:Config.instance().getConfigData().screenWidth; return Forge.isLandscapeMode() ? Config.instance().getConfigData().screenHeight : Config.instance().getConfigData().screenWidth;
} }
public abstract void act(float delta); public abstract void act(float delta);
public abstract void render();
public boolean leave() {
public abstract void render();
public boolean leave() {
return true; return true;
} }
@@ -91,5 +91,4 @@ public abstract class Scene implements Disposable {
} }
} }

View File

@@ -25,6 +25,7 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable; import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.Scaling;
import com.github.tommyettinger.textra.TextraButton; import com.github.tommyettinger.textra.TextraButton;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
@@ -54,6 +55,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
HoldTooltip holdTooltip; HoldTooltip holdTooltip;
Reward reward; Reward reward;
ShaderProgram shaderGrayscale = Forge.getGraphics().getShaderGrayscale(); ShaderProgram shaderGrayscale = Forge.getGraphics().getShaderGrayscale();
ShaderProgram shaderRoundRect = Forge.getGraphics().getShaderRoundedRect();
final int preview_w = 488; //Width and height for generated images. final int preview_w = 488; //Width and height for generated images.
final int preview_h = 680; final int preview_h = 680;
@@ -73,7 +75,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
public static int renderedCount = 0; //Counter for cards that require rendering a preview. public static int renderedCount = 0; //Counter for cards that require rendering a preview.
static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher(); static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher();
Image toolTipImage; RewardImage toolTipImage;
@Override @Override
public void dispose() { public void dispose() {
@@ -124,7 +126,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
((TextureRegionDrawable) toolTipImage.getDrawable()).getRegion().getTexture().dispose(); ((TextureRegionDrawable) toolTipImage.getDrawable()).getRegion().getTexture().dispose();
} }
toolTipImage.remove(); toolTipImage.remove();
toolTipImage = new Image(processDrawable(image)); toolTipImage = new RewardImage(processDrawable(image));
if (GuiBase.isAndroid() || Forge.hasGamepad()) { if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip.tooltip_image.getDrawable() instanceof TextureRegionDrawable) { if (holdTooltip.tooltip_image.getDrawable() instanceof TextureRegionDrawable) {
((TextureRegionDrawable) holdTooltip.tooltip_image.getDrawable()).getRegion().getTexture().dispose(); ((TextureRegionDrawable) holdTooltip.tooltip_image.getDrawable()).getRegion().getTexture().dispose();
@@ -328,12 +330,12 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (alternate) { if (alternate) {
if (alt != null) { if (alt != null) {
holdTooltip.tooltip_actor.clear(); holdTooltip.tooltip_actor.clear();
holdTooltip.tooltip_actor.add(new Image(processDrawable(alt))); holdTooltip.tooltip_actor.add(new RewardImage(processDrawable(alt)));
} else { } else {
if (T == null) if (T == null)
T = renderPlaceholder(getGraphics(), altCard); T = renderPlaceholder(getGraphics(), altCard);
holdTooltip.tooltip_actor.clear(); holdTooltip.tooltip_actor.clear();
holdTooltip.tooltip_actor.add(new Image(processDrawable(T))); holdTooltip.tooltip_actor.add(new RewardImage(processDrawable(T)));
} }
} else { } else {
if (toolTipImage != null) { if (toolTipImage != null) {
@@ -345,11 +347,11 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (hover) { if (hover) {
if (alternate) { if (alternate) {
if (alt != null) { if (alt != null) {
tooltip.setActor(new Image(processDrawable(alt))); tooltip.setActor(new RewardImage(processDrawable(alt)));
} else { } else {
if (T == null) if (T == null)
T = renderPlaceholder(getGraphics(), altCard); T = renderPlaceholder(getGraphics(), altCard);
tooltip.setActor(new Image(processDrawable(T))); tooltip.setActor(new RewardImage(processDrawable(T)));
} }
} else { } else {
if (toolTipImage != null) if (toolTipImage != null)
@@ -414,7 +416,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (Forge.isTextureFilteringEnabled()) if (Forge.isTextureFilteringEnabled())
image.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear); image.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
if (toolTipImage == null) if (toolTipImage == null)
toolTipImage = new Image(processDrawable(image)); toolTipImage = new RewardImage(processDrawable(image));
if (GuiBase.isAndroid() || Forge.hasGamepad()) { if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip == null) if (holdTooltip == null)
holdTooltip = new HoldTooltip(toolTipImage); holdTooltip = new HoldTooltip(toolTipImage);
@@ -502,7 +504,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
//Rendering code ends here. //Rendering code ends here.
if (toolTipImage == null) if (toolTipImage == null)
toolTipImage = new Image(processDrawable(generatedTooltip)); toolTipImage = new RewardImage(processDrawable(generatedTooltip));
if (GuiBase.isAndroid() || Forge.hasGamepad()) { if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip == null) if (holdTooltip == null)
@@ -631,6 +633,21 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
private void drawCard(Batch batch, Texture image, float x, float width) { private void drawCard(Batch batch, Texture image, float x, float width) {
if (image != null) { if (image != null) {
if (image.toString().contains(".fullborder.") && Forge.enableUIMask.equals("Full")) {
batch.end();
shaderRoundRect.bind();
shaderRoundRect.setUniformf("u_resolution", image.getWidth(), image.getHeight());
shaderRoundRect.setUniformf("edge_radius", (image.getHeight()/image.getWidth())*20);
shaderRoundRect.setUniformf("u_gray", sold ? 1f : 0f);
batch.setShader(shaderRoundRect);
batch.begin();
//draw rounded
batch.draw(image, x, -getHeight() / 2, width, getHeight());
//reset
batch.end();
batch.setShader(null);
batch.begin();
} else {
if (!sold) if (!sold)
batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight()); batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
else { else {
@@ -649,6 +666,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
} }
} }
}
private Graphics getGraphics() { private Graphics getGraphics() {
if (graphics == null) if (graphics == null)
@@ -725,18 +743,20 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} }
class HoldTooltip extends ActorGestureListener { class HoldTooltip extends ActorGestureListener {
Image tooltip_image; RewardImage tooltip_image;
Table tooltip_actor; Table tooltip_actor;
float height; float height;
TextraButton switchButton; TextraButton switchButton;
//Vector2 tmp = new Vector2(); //Vector2 tmp = new Vector2();
public HoldTooltip(Image tooltip_image) { public HoldTooltip(RewardImage tooltip_image) {
this.tooltip_image = tooltip_image; this.tooltip_image = tooltip_image;
tooltip_actor = new Table(); tooltip_actor = new Table();
tooltip_actor.add(this.tooltip_image); tooltip_actor.add(this.tooltip_image);
tooltip_actor.align(Align.center); tooltip_actor.align(Align.center);
tooltip_actor.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight()); tooltip_actor.setSize(this.tooltip_image.getPrefWidth(), this.tooltip_image.getPrefHeight());
tooltip_actor.setX(Scene.getIntendedWidth() / 2 - tooltip_actor.getWidth() / 2);
tooltip_actor.setY(Scene.getIntendedHeight() / 2 - tooltip_actor.getHeight() / 2);
this.height = tooltip_actor.getHeight(); this.height = tooltip_actor.getHeight();
switchButton = Controls.newTextButton("Flip"); switchButton = Controls.newTextButton("Flip");
switchButton.addListener(new ClickListener() { switchButton.addListener(new ClickListener() {
@@ -760,17 +780,6 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (reward.getCard().hasBackFace()) if (reward.getCard().hasBackFace())
actor.getStage().addActor(switchButton); actor.getStage().addActor(switchButton);
} }
//Vector2 point = actor.localToStageCoordinates(tmp.set(x, y));
if (Forge.isLandscapeMode()) {
//right if poosible, if exceeds width, draw left
tooltip_actor.setX(actor.getRight());
if (tooltip_actor.getX() + tooltip_actor.getWidth() > Scene.getIntendedWidth())
tooltip_actor.setX(Math.max(0, actor.getX() - tooltip_actor.getWidth()));
} else {
//middle
tooltip_actor.setX(Scene.getIntendedWidth() / 2 - tooltip_actor.getWidth() / 2);
}
tooltip_actor.setY(Scene.getIntendedHeight() / 2 - tooltip_actor.getHeight() / 2);
actor.getStage().addActor(tooltip_actor); actor.getStage().addActor(tooltip_actor);
return super.longPress(actor, x, y); return super.longPress(actor, x, y);
@@ -807,4 +816,58 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
shown = false; shown = false;
} }
} }
class RewardImage extends Image {
public RewardImage(TextureRegionDrawable processDrawable) {
setDrawable(processDrawable);
setScaling(Scaling.stretch);
setAlign(Align.center);
}
@Override
public void draw(Batch batch, float parentAlpha) {
try {
if (getDrawable() instanceof TextureRegionDrawable) {
Texture t = ((TextureRegionDrawable) getDrawable()).getRegion().getTexture();
if (t != null) {
float x = GuiBase.isAndroid() || Forge.hasGamepad() ? Scene.getIntendedWidth() / 2 - holdTooltip.tooltip_actor.getWidth() / 2: tooltip.getActor().getImageX();
float y = GuiBase.isAndroid() || Forge.hasGamepad() ? Scene.getIntendedHeight() / 2 - holdTooltip.tooltip_actor.getHeight() / 2 : tooltip.getActor().getImageY();
float w = GuiBase.isAndroid() || Forge.hasGamepad() ? holdTooltip.tooltip_actor.getPrefWidth() : tooltip.getActor().getPrefWidth();
float h = GuiBase.isAndroid() || Forge.hasGamepad() ? holdTooltip.tooltip_actor.getPrefHeight() : tooltip.getActor().getPrefHeight();
if (t.toString().contains(".fullborder.") && Forge.enableUIMask.equals("Full")) {
batch.end();
shaderRoundRect.bind();
shaderRoundRect.setUniformf("u_resolution", t.getWidth(), t.getHeight());
shaderRoundRect.setUniformf("edge_radius", (t.getHeight()/t.getWidth())*ImageCache.getRadius(t));
shaderRoundRect.setUniformf("u_gray", sold ? 0.8f : 0f);
batch.setShader(shaderRoundRect);
batch.begin();
//draw rounded
batch.draw(t, x, y, w, h);
//reset
batch.end();
batch.setShader(null);
batch.begin();
} else {
batch.end();
shaderGrayscale.bind();
shaderGrayscale.setUniformf("u_grayness", sold ? 1f : 0f);
shaderGrayscale.setUniformf("u_bias", sold ? 0.8f : 1f);
batch.setShader(shaderGrayscale);
batch.begin();
//draw gray
batch.draw(t, x, y, w, h);
//reset
batch.end();
batch.setShader(null);
batch.begin();
}
return;
}
}
} catch (Exception e) {
e.printStackTrace();
}
super.draw(batch, parentAlpha);
}
}
} }

View File

@@ -82,6 +82,7 @@ public class ImageCache {
static EvictingQueue<String> q; static EvictingQueue<String> q;
static Set<String> cardsLoaded; static Set<String> cardsLoaded;
static Queue<String> syncQ; static Queue<String> syncQ;
public static void initCache(int capacity) { public static void initCache(int capacity) {
//override maxCardCapacity //override maxCardCapacity
maxCardCapacity = capacity; maxCardCapacity = capacity;
@@ -90,17 +91,17 @@ public class ImageCache {
//init syncQ for threadsafe use //init syncQ for threadsafe use
syncQ = Queues.synchronizedQueue(q); syncQ = Queues.synchronizedQueue(q);
//cap //cap
int cl = GuiBase.isAndroid() ? maxCardCapacity+(capacity/3) : 400; int cl = GuiBase.isAndroid() ? maxCardCapacity + (capacity / 3) : 400;
cardsLoaded = new HashSet<>(cl); cardsLoaded = new HashSet<>(cl);
} }
public static Texture getDefaultImage() { public static Texture getDefaultImage() {
return Forge.getAssets().getDefaultImage(); return Forge.getAssets().getDefaultImage();
} }
public static FImage BlackBorder = FSkinImage.IMG_BORDER_BLACK;
public static FImage WhiteBorder = FSkinImage.IMG_BORDER_WHITE;
private static final HashMap<String, Pair<String, Boolean>> imageBorder = new HashMap<>(1024);
private static final HashMap<String, ImageRecord> imageRecord = new HashMap<>(1024);
private static boolean imageLoaded, delayLoadRequested; private static boolean imageLoaded, delayLoadRequested;
public static void allowSingleLoad() { public static void allowSingleLoad() {
imageLoaded = false; //reset at the beginning of each render imageLoaded = false; //reset at the beginning of each render
delayLoadRequested = false; delayLoadRequested = false;
@@ -110,10 +111,12 @@ public class ImageCache {
missingIconKeys.clear(); missingIconKeys.clear();
ImageKeys.clearMissingCards(); ImageKeys.clearMissingCards();
} }
public static void clearGeneratedCards() { public static void clearGeneratedCards() {
Forge.getAssets().generatedCards().clear(); Forge.getAssets().generatedCards().clear();
} }
public static void disposeTextures(){
public static void disposeTextures() {
CardRenderer.clearcardArtCache(); CardRenderer.clearcardArtCache();
//unload all cardsLoaded //unload all cardsLoaded
for (String fileName : cardsLoaded) { for (String fileName : cardsLoaded) {
@@ -122,8 +125,9 @@ public class ImageCache {
} }
} }
cardsLoaded.clear(); cardsLoaded.clear();
((Forge)Gdx.app.getApplicationListener()).needsUpdate = true; ((Forge) Gdx.app.getApplicationListener()).needsUpdate = true;
} }
/** /**
* Update counter for use with adventure mode since it uses direct loading for assetmanager for loot and shops * Update counter for use with adventure mode since it uses direct loading for assetmanager for loot and shops
*/ */
@@ -132,14 +136,14 @@ public class ImageCache {
return; return;
syncQ.add(file.getPath()); syncQ.add(file.getPath());
cardsLoaded.add(file.getPath()); cardsLoaded.add(file.getPath());
counter+=count; counter += count;
} }
public static Texture getImage(InventoryItem ii) { public static Texture getImage(InventoryItem ii) {
boolean useDefault = ii instanceof DeckProxy; boolean useDefault = ii instanceof DeckProxy;
String imageKey = ii.getImageKey(false); String imageKey = ii.getImageKey(false);
if (imageKey != null) { if (imageKey != null) {
if(imageKey.startsWith(ImageKeys.CARD_PREFIX) || imageKey.startsWith(ImageKeys.TOKEN_PREFIX)) if (imageKey.startsWith(ImageKeys.CARD_PREFIX) || imageKey.startsWith(ImageKeys.TOKEN_PREFIX))
return getImage(ii.getImageKey(false), useDefault, false); return getImage(ii.getImageKey(false), useDefault, false);
} }
return getImage(ii.getImageKey(false), true, true); return getImage(ii.getImageKey(false), true, true);
@@ -209,6 +213,7 @@ public class ImageCache {
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound) { public static Texture getImage(String imageKey, boolean useDefaultIfNotFound) {
return getImage(imageKey, useDefaultIfNotFound, false); return getImage(imageKey, useDefaultIfNotFound, false);
} }
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound, boolean others) { public static Texture getImage(String imageKey, boolean useDefaultIfNotFound, boolean others) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES)) if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return null; return null;
@@ -239,7 +244,9 @@ public class ImageCache {
// 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 = getAsset(imageKey, imageFile, others); image = getAsset(imageKey, imageFile, others);
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
if (!delayLoadRequested) { if (!delayLoadRequested) {
@@ -266,19 +273,21 @@ public class ImageCache {
/*fix not loading image file since we intentionally not to update the cache in order for the /*fix not loading image file since we intentionally not to update the cache in order for the
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 && imageBorder.get(image.toString()) == null) if (image != null && imageRecord.get(image.toString()) == null)
imageBorder.put(image.toString(), Pair.of(Color.valueOf("#171717").toString(), false)); //black border imageRecord.put(image.toString(), new ImageRecord(Color.valueOf("#171717").toString(), false, getRadius(image))); //black border
} }
} }
return image; return image;
} }
static Texture getAsset(String imageKey, File file, boolean others) { static Texture getAsset(String imageKey, File file, boolean others) {
if (file == null) if (file == null)
return null; return null;
if (!others && Forge.enableUIMask.equals("Full") && isBorderless(imageKey)) /*if (!others && Forge.enableUIMask.equals("Full") && isBorderless(imageKey))
return Forge.getAssets().generatedCards().get(imageKey); return Forge.getAssets().generatedCards().get(imageKey);*/
return Forge.getAssets().manager().get(file.getPath(), Texture.class, false); return Forge.getAssets().manager().get(file.getPath(), Texture.class, false);
} }
static Texture loadAsset(String imageKey, File file, boolean others) { static Texture loadAsset(String imageKey, File file, boolean others) {
if (file == null) if (file == null)
return null; return null;
@@ -300,7 +309,7 @@ public class ImageCache {
counter += 1; counter += 1;
} }
} catch (Exception e) { } catch (Exception e) {
System.err.println("Failed to load image: "+fileName); System.err.println("Failed to load image: " + fileName);
} }
//return loaded assets //return loaded assets
@@ -309,17 +318,28 @@ public class ImageCache {
} else { } else {
Texture cardTexture = Forge.getAssets().manager().get(fileName, Texture.class, false); Texture cardTexture = Forge.getAssets().manager().get(fileName, Texture.class, false);
//if full bordermasking is enabled, update the border color //if full bordermasking is enabled, update the border color
if (cardTexture != null && Forge.enableUIMask.equals("Full")) { if (cardTexture != null) {
boolean borderless = isBorderless(imageKey); boolean borderless = isBorderless(imageKey);
updateBorders(cardTexture.toString(), borderless ? Pair.of(Color.valueOf("#171717").toString(), false): isCloserToWhite(getpixelColor(cardTexture))); String setCode = imageKey.split("/")[0].trim().toUpperCase();
int radius;
if (setCode.equals("A") || setCode.equals("LEA") || setCode.equals("B") || setCode.equals("LEB"))
radius = 28;
else if (setCode.equals("MED") || setCode.equals("ME2") || setCode.equals("ME3") || setCode.equals("ME4") || setCode.equals("TD0") || setCode.equals("TD1"))
radius = 25;
else
radius = 22;
updateImageRecord(cardTexture.toString(),
borderless ? Color.valueOf("#171717").toString() : isCloserToWhite(getpixelColor(cardTexture)).getLeft(),
borderless ? false : isCloserToWhite(getpixelColor(cardTexture)).getRight(), radius);
//if borderless, generate new texture from the asset and store //if borderless, generate new texture from the asset and store
if (borderless) { /*if (borderless) {
Forge.getAssets().generatedCards().put(imageKey, generateTexture(new FileHandle(file), cardTexture, Forge.isTextureFilteringEnabled())); Forge.getAssets().generatedCards().put(imageKey, generateTexture(new FileHandle(file), cardTexture, Forge.isTextureFilteringEnabled()));
} }*/
} }
return cardTexture; return cardTexture;
} }
} }
public static void unloadCardTextures(boolean removeAll) { public static void unloadCardTextures(boolean removeAll) {
if (removeAll) { if (removeAll) {
try { try {
@@ -359,45 +379,50 @@ public class ImageCache {
//e.printstacktrace //e.printstacktrace
} }
} }
public static void preloadCache(Iterable<String> keys) { public static void preloadCache(Iterable<String> keys) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES)) if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return; return;
for (String imageKey : keys){ for (String imageKey : keys) {
if(getImage(imageKey, false) == null) if (getImage(imageKey, false) == null)
System.err.println("could not load card image:"+imageKey); System.err.println("could not load card image:" + imageKey);
} }
} }
public static void preloadCache(Deck deck) { public static void preloadCache(Deck deck) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES)) if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return; return;
if(deck == null||!Forge.enablePreloadExtendedArt) if (deck == null || !Forge.enablePreloadExtendedArt)
return; return;
if (deck.getAllCardsInASinglePool().toFlatList().size() <= 100) { if (deck.getAllCardsInASinglePool().toFlatList().size() <= 100) {
for (PaperCard p : deck.getAllCardsInASinglePool().toFlatList()) { for (PaperCard p : deck.getAllCardsInASinglePool().toFlatList()) {
if (getImage(p.getImageKey(false),false) == null) if (getImage(p.getImageKey(false), false) == null)
System.err.println("could not load card image:"+p.toString()); System.err.println("could not load card image:" + p.toString());
} }
} }
} }
public static TextureRegion croppedBorderImage(Texture image) { public static TextureRegion croppedBorderImage(Texture image) {
if (!image.toString().contains(".fullborder.")) if (!image.toString().contains(".fullborder."))
return new TextureRegion(image); return new TextureRegion(image);
float rscale = 0.96f; float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale); int rw = Math.round(image.getWidth() * rscale);
int rh = Math.round(image.getHeight()*rscale); int rh = Math.round(image.getHeight() * rscale);
int rx = Math.round((image.getWidth() - rw)/2f); int rx = Math.round((image.getWidth() - rw) / 2f);
int ry = Math.round((image.getHeight() - rh)/2f)-2; int ry = Math.round((image.getHeight() - rh) / 2f) - 2;
return new TextureRegion(image, rx, ry, rw, rh); return new TextureRegion(image, rx, ry, rw, rh);
} }
public static Color borderColor(Texture t) { public static Color borderColor(Texture t) {
if (t == null) if (t == null)
return Color.valueOf("#171717"); return Color.valueOf("#171717");
try { try {
return Color.valueOf(imageBorder.get(t.toString()).getLeft()); return Color.valueOf(imageRecord.get(t.toString()).colorValue);
} catch (Exception e) { } catch (Exception e) {
return Color.valueOf("#171717"); return Color.valueOf("#171717");
} }
} }
public static int getFSkinBorders(CardView c) { public static int getFSkinBorders(CardView c) {
if (c == null) if (c == null)
return 0; return 0;
@@ -409,25 +434,44 @@ public class ImageCache {
return 1; return 1;
return 0; return 0;
} }
public static boolean isBorderlessCardArt(Texture t) {
/*public static boolean isBorderlessCardArt(Texture t) {
return isBorderless(t); return isBorderless(t);
}*/
public static void updateImageRecord(String textureString, String colorValue, Boolean isClosertoWhite, int radius) {
imageRecord.put(textureString, new ImageRecord(colorValue, isClosertoWhite, radius));
} }
public static void updateBorders(String textureString, Pair<String, Boolean> colorPair){
imageBorder.put(textureString, colorPair); public static int getRadius(Texture t) {
ImageRecord record = imageRecord.get(t.toString());
if (record == null)
return 20;
Integer i = record.cardRadius;
if (i == null)
return 20;
return i;
} }
public static FImage getBorder(String textureString) { public static FImage getBorder(String textureString) {
if (imageBorder.get(textureString) == null) ImageRecord record = imageRecord.get(textureString);
return BlackBorder; if (record == null)
return imageBorder.get(textureString).getRight() ? WhiteBorder : BlackBorder; return FSkinImage.IMG_BORDER_BLACK;
Boolean border = record.isCloserToWhite;
if (border == null)
return FSkinImage.IMG_BORDER_BLACK;
return border ? FSkinImage.IMG_BORDER_WHITE : FSkinImage.IMG_BORDER_BLACK;
} }
public static FImage getBorderImage(String textureString, boolean canshow) { public static FImage getBorderImage(String textureString, boolean canshow) {
if (!canshow) if (!canshow)
return BlackBorder; return FSkinImage.IMG_BORDER_BLACK;
return getBorder(textureString); return getBorder(textureString);
} }
public static FImage getBorderImage(String textureString) { public static FImage getBorderImage(String textureString) {
return getBorder(textureString); return getBorder(textureString);
} }
public static Color getTint(CardView c, Texture t) { public static Color getTint(CardView c, Texture t) {
if (c == null) if (c == null)
return borderColor(t); return borderColor(t);
@@ -439,8 +483,7 @@ public class ImageCache {
if (state.hasDevoid()) //devoid is colorless at all zones so return its corresponding border color... if (state.hasDevoid()) //devoid is colorless at all zones so return its corresponding border color...
return borderColor(t); return borderColor(t);
return Color.valueOf("#A0A6A4"); return Color.valueOf("#A0A6A4");
} } else if (state.getColors().isMonoColor()) {
else if (state.getColors().isMonoColor()) {
if (state.getColors().hasBlack()) if (state.getColors().hasBlack())
return Color.valueOf("#48494a"); return Color.valueOf("#48494a");
else if (state.getColors().hasBlue()) else if (state.getColors().hasBlue())
@@ -451,12 +494,12 @@ public class ImageCache {
return Color.valueOf("#66cb35"); return Color.valueOf("#66cb35");
else if (state.getColors().hasWhite()) else if (state.getColors().hasWhite())
return Color.valueOf("#EEEBE1"); return Color.valueOf("#EEEBE1");
} } else if (state.getColors().isMulticolor())
else if (state.getColors().isMulticolor())
return Color.valueOf("#F9E084"); return Color.valueOf("#F9E084");
return borderColor(t); return borderColor(t);
} }
public static Texture generateTexture(FileHandle fh, Texture cardTexture, boolean textureFilter) { public static Texture generateTexture(FileHandle fh, Texture cardTexture, boolean textureFilter) {
if (cardTexture == null || fh == null) if (cardTexture == null || fh == null)
return cardTexture; return cardTexture;
@@ -481,6 +524,7 @@ public class ImageCache {
}); });
return placeholder[0]; return placeholder[0];
} }
public static Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) { public static Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) {
Pixmap pixmap = new Pixmap(width, height, Format.RGBA4444); Pixmap pixmap = new Pixmap(width, height, Format.RGBA4444);
Pixmap ret = new Pixmap(width, height, Format.RGBA4444); Pixmap ret = new Pixmap(width, height, Format.RGBA4444);
@@ -503,12 +547,13 @@ public class ImageCache {
pixmap.dispose(); pixmap.dispose();
return ret; return ret;
} }
public static void drawPixelstoMask(Pixmap pixmap, Pixmap mask){
public static void drawPixelstoMask(Pixmap pixmap, Pixmap mask) {
int pixmapWidth = mask.getWidth(); int pixmapWidth = mask.getWidth();
int pixmapHeight = mask.getHeight(); int pixmapHeight = mask.getHeight();
Color pixelColor = new Color(); Color pixelColor = new Color();
for (int x=0; x<pixmapWidth; x++){ for (int x = 0; x < pixmapWidth; x++) {
for (int y=0; y<pixmapHeight; y++){ for (int y = 0; y < pixmapHeight; y++) {
if (mask.getPixel(x, y) != 0) { if (mask.getPixel(x, y) != 0) {
Color.rgba8888ToColor(pixelColor, pixmap.getPixel(x, y)); Color.rgba8888ToColor(pixelColor, pixmap.getPixel(x, y));
mask.setColor(pixelColor); mask.setColor(pixelColor);
@@ -519,17 +564,17 @@ public class ImageCache {
} }
public static boolean isBorderless(String imagekey) { public static boolean isBorderless(String imagekey) {
if(borderlessCardlistKey.isEmpty()) if (borderlessCardlistKey.isEmpty())
return false; return false;
if (imagekey.length() > 7) { if (imagekey.length() > 7) {
if ((!imagekey.substring(0, 7).contains("MPS_KLD"))&&(imagekey.substring(0, 4).contains("MPS_"))) //MPS_ sets except MPD_KLD if ((!imagekey.substring(0, 7).contains("MPS_KLD")) && (imagekey.substring(0, 4).contains("MPS_"))) //MPS_ sets except MPD_KLD
return true; return true;
} }
return borderlessCardlistKey.contains(TextUtil.fastReplace(imagekey,".full",".fullborder")); return borderlessCardlistKey.contains(TextUtil.fastReplace(imagekey, ".full", ".fullborder"));
} }
public static boolean isBorderless(Texture t) { public static boolean isBorderless(Texture t) {
if(borderlessCardlistKey.isEmpty()) if (borderlessCardlistKey.isEmpty())
return false; return false;
//generated texture/pixmap? //generated texture/pixmap?
if (t.toString().contains("com.badlogic.gdx.graphics.Texture@")) if (t.toString().contains("com.badlogic.gdx.graphics.Texture@"))
@@ -544,17 +589,30 @@ public class ImageCache {
//get pixmap from texture data //get pixmap from texture data
Pixmap pixmap = i.getTextureData().consumePixmap(); Pixmap pixmap = i.getTextureData().consumePixmap();
//get pixel color from x,y texture coordinate based on the image fullborder or not //get pixel color from x,y texture coordinate based on the image fullborder or not
Color color = new Color(pixmap.getPixel(croppedBorderImage(i).getRegionX()+1, croppedBorderImage(i).getRegionY()+1)); Color color = new Color(pixmap.getPixel(croppedBorderImage(i).getRegionX() + 1, croppedBorderImage(i).getRegionY() + 1));
pixmap.dispose(); pixmap.dispose();
return color.toString(); return color.toString();
} }
public static Pair<String, Boolean> isCloserToWhite(String c){
public static Pair<String, Boolean> isCloserToWhite(String c) {
if (c == null || c == "") if (c == null || c == "")
return Pair.of(Color.valueOf("#171717").toString(), false); return Pair.of(Color.valueOf("#171717").toString(), false);
int c_r = Integer.parseInt(c.substring(0,2),16); int c_r = Integer.parseInt(c.substring(0, 2), 16);
int c_g = Integer.parseInt(c.substring(2,4),16); int c_g = Integer.parseInt(c.substring(2, 4), 16);
int c_b = Integer.parseInt(c.substring(4,6),16); int c_b = Integer.parseInt(c.substring(4, 6), 16);
int brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000; int brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
return Pair.of(c,brightness > 155); return Pair.of(c, brightness > 155);
}
static class ImageRecord {
String colorValue;
Boolean isCloserToWhite;
Integer cardRadius;
ImageRecord(String colorString, Boolean closetoWhite, int radius) {
colorValue = colorString;
isCloserToWhite = closetoWhite;
cardRadius = radius;
}
} }
} }

View File

@@ -46,15 +46,14 @@ public class CardImage implements FImage {
if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) { if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top, true, true); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top, true, true);
} } else {
else {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawImage(image, x, y, w, h); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
float radius = (h - w)/8; float radius = (h - w) / 8;
g.drawborderImage(ImageCache.borderColor(image), x, y, w, h); g.drawborderImage(ImageCache.borderColor(image), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x+radius/2.2f, y+radius/2, w*0.96f, h*0.96f); g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.2f, y + radius / 2, w * 0.96f, h * 0.96f);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h); g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);

View File

@@ -88,6 +88,7 @@ public class CardImageRenderer {
public static void drawCardImage(Graphics g, CardView card, boolean altState, float x, float y, float w, float h, CardStackPosition pos, boolean useCardBGTexture, boolean showArtist) { public static void drawCardImage(Graphics g, CardView card, boolean altState, float x, float y, float w, float h, CardStackPosition pos, boolean useCardBGTexture, boolean showArtist) {
drawCardImage(g, card, altState, x, y, w, h, pos, useCardBGTexture, false, false, showArtist); drawCardImage(g, card, altState, x, y, w, h, pos, useCardBGTexture, false, false, showArtist);
} }
public static void drawCardImage(Graphics g, CardView card, boolean altState, float x, float y, float w, float h, CardStackPosition pos, boolean useCardBGTexture, boolean noText, boolean isChoiceList, boolean showArtist) { public static void drawCardImage(Graphics g, CardView card, boolean altState, float x, float y, float w, float h, CardStackPosition pos, boolean useCardBGTexture, boolean noText, boolean isChoiceList, boolean showArtist) {
updateStaticFields(w, h); updateStaticFields(w, h);
@@ -134,7 +135,9 @@ public class CardImageRenderer {
Color[] headerColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.NAME_BOX_TINT); Color[] headerColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.NAME_BOX_TINT);
drawHeader(g, card, state, headerColors, x, y, w, headerHeight, isFaceDown && !altState, false); drawHeader(g, card, state, headerColors, x, y, w, headerHeight, isFaceDown && !altState, false);
if (pos == CardStackPosition.BehindVert) { return; } //remaining rendering not needed if card is behind another card in a vertical stack if (pos == CardStackPosition.BehindVert) {
return;
} //remaining rendering not needed if card is behind another card in a vertical stack
boolean onTop = (pos == CardStackPosition.Top); boolean onTop = (pos == CardStackPosition.Top);
y += headerHeight; y += headerHeight;
@@ -169,16 +172,15 @@ public class CardImageRenderer {
//draw art box with Forge icon //draw art box with Forge icon
if (artHeight > 0) { if (artHeight > 0) {
if (isSaga) if (isSaga)
drawArt(card, g, x + artInset+(artWidth/2), y, artWidth/2, artHeight+textBoxHeight, altState, isFaceDown); drawArt(card, g, x + artInset + (artWidth / 2), y, artWidth / 2, artHeight + textBoxHeight, altState, isFaceDown);
else if (isClass) else if (isClass)
drawArt(card, g, x + artInset, y, artWidth/2, artHeight+textBoxHeight, altState, isFaceDown); drawArt(card, g, x + artInset, y, artWidth / 2, artHeight + textBoxHeight, altState, isFaceDown);
else if (isDungeon) { else if (isDungeon) {
if (drawDungeon) { if (drawDungeon) {
drawArt(card, g, x + artInset, y, artWidth, artHeight+textBoxHeight, altState, isFaceDown); drawArt(card, g, x + artInset, y, artWidth, artHeight + textBoxHeight, altState, isFaceDown);
y += textBoxHeight; y += textBoxHeight;
} }
} } else
else
drawArt(card, g, x + artInset, y, artWidth, artHeight, altState, isFaceDown); drawArt(card, g, x + artInset, y, artWidth, artHeight, altState, isFaceDown);
y += artHeight; y += artHeight;
} }
@@ -186,7 +188,7 @@ public class CardImageRenderer {
if (isSaga) { if (isSaga) {
//draw text box //draw text box
Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT); Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT);
drawTextBox(g, card, state, textBoxColors, x + artInset, y-artHeight, (w - 2 * artInset)/2, textBoxHeight+artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList); drawTextBox(g, card, state, textBoxColors, x + artInset, y - artHeight, (w - 2 * artInset) / 2, textBoxHeight + artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList);
y += textBoxHeight; y += textBoxHeight;
//draw type line //draw type line
@@ -195,7 +197,7 @@ public class CardImageRenderer {
} else if (isClass) { } else if (isClass) {
//draw text box //draw text box
Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT); Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT);
drawTextBox(g, card, state, textBoxColors, x + artInset+(artWidth/2), y-artHeight, (w - 2 * artInset)/2, textBoxHeight+artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList); drawTextBox(g, card, state, textBoxColors, x + artInset + (artWidth / 2), y - artHeight, (w - 2 * artInset) / 2, textBoxHeight + artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList);
y += textBoxHeight; y += textBoxHeight;
//draw type line //draw type line
@@ -205,7 +207,7 @@ public class CardImageRenderer {
if (!drawDungeon) { if (!drawDungeon) {
//draw textbox //draw textbox
Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT); Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT);
drawTextBox(g, card, state, textBoxColors, x + artInset, y-artHeight, (w - 2 * artInset), textBoxHeight+artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList); drawTextBox(g, card, state, textBoxColors, x + artInset, y - artHeight, (w - 2 * artInset), textBoxHeight + artHeight, onTop, useCardBGTexture, noText, altState, isFaceDown, canShow, isChoiceList);
y += textBoxHeight; y += textBoxHeight;
} }
drawTypeLine(g, state, canShow, headerColors, x, y, w, typeBoxHeight, noText, false, false); drawTypeLine(g, state, canShow, headerColors, x, y, w, typeBoxHeight, noText, false, false);
@@ -229,7 +231,7 @@ public class CardImageRenderer {
} }
//draw artist //draw artist
if (showArtist) if (showArtist)
g.drawOutlinedText(artist, TEXT_FONT, Color.WHITE, Color.DARK_GRAY, x+(TYPE_FONT.getCapHeight()/2), y+(TYPE_FONT.getCapHeight()/2), w, h, false, Align.left, false); g.drawOutlinedText(artist, TEXT_FONT, Color.WHITE, Color.DARK_GRAY, x + (TYPE_FONT.getCapHeight() / 2), y + (TYPE_FONT.getCapHeight() / 2), w, h, false, Align.left, false);
} }
private static void drawHeader(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean noText, boolean isAdventure) { private static void drawHeader(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean noText, boolean isAdventure) {
@@ -269,6 +271,7 @@ public class CardImageRenderer {
public static final FBufferedImage forgeArt; public static final FBufferedImage forgeArt;
private static final FBufferedImage stretchedArt; private static final FBufferedImage stretchedArt;
static { static {
final float logoWidth = FSkinImage.LOGO.getWidth(); final float logoWidth = FSkinImage.LOGO.getWidth();
final float logoHeight = FSkinImage.LOGO.getHeight(); final float logoHeight = FSkinImage.LOGO.getHeight();
@@ -287,7 +290,7 @@ public class CardImageRenderer {
protected void draw(Graphics g, float w, float h) { protected void draw(Graphics g, float w, float h) {
g.drawImage(Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_TEXTURE : FSkinTexture.BG_TEXTURE, 0, 0, w, h); g.drawImage(Forge.isMobileAdventureMode ? FSkinTexture.ADV_BG_TEXTURE : FSkinTexture.BG_TEXTURE, 0, 0, w, h);
g.fillRect(FScreen.getTextureOverlayColor(), 0, 0, w, h); g.fillRect(FScreen.getTextureOverlayColor(), 0, 0, w, h);
g.drawImage(FSkinImage.LOGO, (w - logoWidth) / 2, ((h - logoHeight) / 2)+h/3.5f, logoWidth, logoHeight/3); g.drawImage(FSkinImage.LOGO, (w - logoWidth) / 2, ((h - logoHeight) / 2) + h / 3.5f, logoWidth, logoHeight / 3);
} }
}; };
} }
@@ -371,39 +374,42 @@ public class CardImageRenderer {
} }
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h); g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
} }
private static void drawSplitCard(CardView card, FImageComplex cardArt, Graphics g, float x, float y, float w, float h, boolean altState, boolean isFaceDown) { private static void drawSplitCard(CardView card, FImageComplex cardArt, Graphics g, float x, float y, float w, float h, boolean altState, boolean isFaceDown) {
CardView alt = card.getBackup(); CardView alt = card.getBackup();
if (alt == null) if (alt == null)
alt = card.getAlternateState().getCard(); alt = card.getAlternateState().getCard();
CardView cv = altState && isFaceDown ? alt : card; CardView cv = altState && isFaceDown ? alt : card;
boolean isAftermath = altState ? cv.getAlternateState().hasHasAftermath(): cv.getRightSplitState().hasHasAftermath(); boolean isAftermath = altState ? cv.getAlternateState().hasHasAftermath() : cv.getRightSplitState().hasHasAftermath();
if (!isAftermath) { if (!isAftermath) {
CardEdition ed = FModel.getMagicDb().getEditions().get(cv.getCurrentState().getSetCode()); CardEdition ed = FModel.getMagicDb().getEditions().get(cv.getCurrentState().getSetCode());
boolean isOldFrame = ed != null && !ed.isModern(); boolean isOldFrame = ed != null && !ed.isModern();
float modH = isOldFrame ? cardArt.getHeight()/12f : 0f; float modH = isOldFrame ? cardArt.getHeight() / 12f : 0f;
float modW = !isOldFrame ? cardArt.getWidth()/12f : 0f; float modW = !isOldFrame ? cardArt.getWidth() / 12f : 0f;
float modW2 = !isOldFrame ? cardArt.getWidth()/6f : 0f; float modW2 = !isOldFrame ? cardArt.getWidth() / 6f : 0f;
float srcY = cardArt.getHeight() * 13f / 354f; float srcY = cardArt.getHeight() * 13f / 354f;
float srcHeight = cardArt.getHeight() * 190f / 354f; float srcHeight = cardArt.getHeight() * 190f / 354f;
float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CardRenderer.CARD_ART_RATIO); float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CardRenderer.CARD_ART_RATIO);
srcHeight -= dh; srcHeight -= dh;
srcY += dh / 2; srcY += dh / 2;
g.drawRotatedImage(cardArt.getTexture(), x, y, h+modH, w / 2, x + w / 2, y + w / 2, cardArt.getRegionX()+(int)modW, (int)srcY, (int)(cardArt.getWidth()-modW2), (int)srcHeight, -90); g.drawRotatedImage(cardArt.getTexture(), x, y, h + modH, w / 2, x + w / 2, y + w / 2, cardArt.getRegionX() + (int) modW, (int) srcY, (int) (cardArt.getWidth() - modW2), (int) srcHeight, -90);
g.drawRotatedImage(cardArt.getTexture(), x, y + w / 2, h+modH, w / 2, x + w / 2, y + w / 2, cardArt.getRegionX()+(int)modW, (int)cardArt.getHeight() - (int)(srcY + srcHeight), (int)(cardArt.getWidth()-modW2), (int)srcHeight, -90); g.drawRotatedImage(cardArt.getTexture(), x, y + w / 2, h + modH, w / 2, x + w / 2, y + w / 2, cardArt.getRegionX() + (int) modW, (int) cardArt.getHeight() - (int) (srcY + srcHeight), (int) (cardArt.getWidth() - modW2), (int) srcHeight, -90);
g.drawLine(BORDER_THICKNESS, Color.BLACK, x+w/2, y, x+w/2, y+h); g.drawLine(BORDER_THICKNESS, Color.BLACK, x + w / 2, y, x + w / 2, y + h);
} else { } else {
FImageComplex secondArt = CardRenderer.getAftermathSecondCardArt(cv.getCurrentState().getImageKey()); FImageComplex secondArt = CardRenderer.getAftermathSecondCardArt(cv.getCurrentState().getImageKey());
g.drawRotatedImage(cardArt.getTexture(), x, y, w, h / 2, x + w, y + h / 2, cardArt.getRegionX(), cardArt.getRegionY(), (int)cardArt.getWidth(), (int)cardArt.getHeight() /2, 0); g.drawRotatedImage(cardArt.getTexture(), x, y, w, h / 2, x + w, y + h / 2, cardArt.getRegionX(), cardArt.getRegionY(), (int) cardArt.getWidth(), (int) cardArt.getHeight() / 2, 0);
g.drawRotatedImage(secondArt.getTexture(), x - h / 2 , y + h / 2, h /2, w, x, y + h / 2, secondArt.getRegionX(), secondArt.getRegionY(), (int)secondArt.getWidth(), (int)secondArt.getHeight(), 90); g.drawRotatedImage(secondArt.getTexture(), x - h / 2, y + h / 2, h / 2, w, x, y + h / 2, secondArt.getRegionX(), secondArt.getRegionY(), (int) secondArt.getWidth(), (int) secondArt.getHeight(), 90);
g.drawLine(BORDER_THICKNESS, Color.BLACK, x, y+h/2, x+w, y+h/2); g.drawLine(BORDER_THICKNESS, Color.BLACK, x, y + h / 2, x + w, y + h / 2);
} }
} }
private static void drawFlipCard(FImageComplex cardArt, Graphics g, float x, float y, float w, float h, boolean altState) { private static void drawFlipCard(FImageComplex cardArt, Graphics g, float x, float y, float w, float h, boolean altState) {
if (altState) if (altState)
g.drawRotatedImage(cardArt.getTextureRegion(), x, y, w, h, x + w / 2, y + h / 2, 180); g.drawRotatedImage(cardArt.getTextureRegion(), x, y, w, h, x + w / 2, y + h / 2, 180);
else else
g.drawImage(cardArt, x, y, w, h); g.drawImage(cardArt, x, y, w, h);
} }
private static void drawTypeLine(Graphics g, CardStateView state, boolean canShow, Color[] colors, float x, float y, float w, float h, boolean noText, boolean noRarity, boolean isAdventure) { private static void drawTypeLine(Graphics g, CardStateView state, boolean canShow, Color[] colors, float x, float y, float w, float h, boolean noText, boolean noRarity, boolean isAdventure) {
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
if (isAdventure) if (isAdventure)
@@ -422,7 +428,7 @@ public class CardImageRenderer {
//g.fillRect(CardRenderer.getRarityColor(state.getRarity()), x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize); //g.fillRect(CardRenderer.getRarityColor(state.getRarity()), x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize);
if (state.getRarity() == null) { if (state.getRarity() == null) {
g.drawImage(FSkinImage.SET_SPECIAL, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize); g.drawImage(FSkinImage.SET_SPECIAL, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize);
} else if (state.getRarity() == CardRarity.Special ) { } else if (state.getRarity() == CardRarity.Special) {
g.drawImage(FSkinImage.SET_SPECIAL, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize); g.drawImage(FSkinImage.SET_SPECIAL, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize);
} else if (state.getRarity() == CardRarity.MythicRare) { } else if (state.getRarity() == CardRarity.MythicRare) {
g.drawImage(FSkinImage.SET_MYTHIC, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize); g.drawImage(FSkinImage.SET_MYTHIC, x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize);
@@ -465,6 +471,7 @@ public class CardImageRenderer {
setTextBox(g, card, state, colors, x, y, w, h, onTop, useCardBGTexture, noText, 0f, 0f, false, altstate, isFacedown); setTextBox(g, card, state, colors, x, y, w, h, onTop, useCardBGTexture, noText, 0f, 0f, false, altstate, isFacedown);
} }
} }
private static void setTextBox(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean onTop, boolean useCardBGTexture, boolean noText, float adventureHeaderHeight, float adventureTypeHeight, boolean drawAdventure, boolean altstate, boolean isFaceDown) { private static void setTextBox(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean onTop, boolean useCardBGTexture, boolean noText, float adventureHeaderHeight, float adventureTypeHeight, boolean drawAdventure, boolean altstate, boolean isFaceDown) {
boolean fakeDuals = false; boolean fakeDuals = false;
//update land bg colors //update land bg colors
@@ -481,7 +488,8 @@ public class CardImageRenderer {
modColors = DetailColors.BLACK; modColors = DetailColors.BLACK;
else if (state.isPlains()) else if (state.isPlains())
modColors = DetailColors.LAND; modColors = DetailColors.LAND;
} if (state.origCanProduceColoredMana() == 2) { }
if (state.origCanProduceColoredMana() == 2) {
//dual colors //dual colors
Color[] colorPairs = new Color[2]; Color[] colorPairs = new Color[2];
//init Color //init Color
@@ -577,7 +585,9 @@ public class CardImageRenderer {
} }
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h); g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
if (!onTop) { return; } //remaining rendering only needed if card on top if (!onTop) {
return;
} //remaining rendering only needed if card on top
if (state.isBasicLand()) { if (state.isBasicLand()) {
//draw watermark //draw watermark
@@ -649,30 +659,31 @@ public class CardImageRenderer {
cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, Align.left, true); cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, Align.left, true);
} }
} }
private static void drawAlphaLines(Graphics g, float x, float y, float w, float h) { private static void drawAlphaLines(Graphics g, float x, float y, float w, float h) {
if (FSkin.overlay_alpha != null) { if (FSkin.overlay_alpha != null) {
g.drawImage(FSkin.overlay_alpha, x, y, w, h); g.drawImage(FSkin.overlay_alpha, x, y, w, h);
} }
} }
private static void drawPtBox(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean noText) { private static void drawPtBox(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean noText) {
List<String> pieces = new ArrayList<>(); List<String> pieces = new ArrayList<>();
if (state.isCreature()) { if (state.isCreature()) {
pieces.add(String.valueOf(state.getPower())); pieces.add(String.valueOf(state.getPower()));
pieces.add("/"); pieces.add("/");
pieces.add(String.valueOf(state.getToughness())); pieces.add(String.valueOf(state.getToughness()));
} } else if (state.isPlaneswalker()) {
else if (state.isPlaneswalker()) {
pieces.add(String.valueOf(state.getLoyalty())); pieces.add(String.valueOf(state.getLoyalty()));
} } else if (state.getType().hasSubtype("Vehicle")) {
else if (state.getType().hasSubtype("Vehicle")) {
// TODO Invert color box for Vehicles? // TODO Invert color box for Vehicles?
pieces.add("["); pieces.add("[");
pieces.add(String.valueOf(state.getPower())); pieces.add(String.valueOf(state.getPower()));
pieces.add("/"); pieces.add("/");
pieces.add(String.valueOf(state.getToughness())); pieces.add(String.valueOf(state.getToughness()));
pieces.add("]"); pieces.add("]");
} else {
return;
} }
else { return; }
float padding = Math.round(PT_FONT.getCapHeight() / 4); float padding = Math.round(PT_FONT.getCapHeight() / 4);
float totalPieceWidth = -padding; float totalPieceWidth = -padding;
@@ -728,29 +739,29 @@ public class CardImageRenderer {
if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) { //support drawing card image manually if card image not found if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) { //support drawing card image manually if card image not found
drawCardImage(g, card, altState, x, y, w, h, CardStackPosition.Top, true, true); drawCardImage(g, card, altState, x, y, w, h, CardStackPosition.Top, true, true);
} else { } else {
float radius = (h - w)/8; 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_xRotate = (dispW - new_h) / 2;
float new_yRotate = (dispH - new_w) /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);
float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f; float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f;
float minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius; float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) { if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f; croppedArea = 0.975f;
minusxy = 0.135f*radius; minusxy = 0.135f * radius;
} }
if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) { if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) {
if (Forge.enableUIMask.equals("Full")){ if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawRotatedImage(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);
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x+radius/2-minusxy, new_y+radius/2-minusxy, new_w*croppedArea, new_h*croppedArea, (new_x+radius/2-minusxy) + (new_w*croppedArea) / 2, (new_y+radius/2-minusxy) + (new_h*croppedArea) / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x + radius / 2 - minusxy, new_y + radius / 2 - minusxy, new_w * croppedArea, new_h * croppedArea, (new_x + radius / 2 - minusxy) + (new_w * croppedArea) / 2, (new_y + radius / 2 - minusxy) + (new_h * croppedArea) / 2, -90);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
@@ -759,11 +770,11 @@ 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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
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.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.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.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(ImageCache.croppedBorderImage(image), new_x + radius / 2-minusxy, new_y + radius / 2-minusxy, new_w * croppedArea, new_h * croppedArea, (new_x + radius / 2-minusxy) + (new_w * croppedArea) / 2, (new_y + radius / 2-minusxy) + (new_h * croppedArea) / 2, isAftermath ? 90 : -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x + radius / 2 - minusxy, new_y + radius / 2 - minusxy, new_w * croppedArea, new_h * croppedArea, (new_x + radius / 2 - minusxy) + (new_w * croppedArea) / 2, (new_y + radius / 2 - minusxy) + (new_h * croppedArea) / 2, isAftermath ? 90 : -90);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
@@ -775,11 +786,11 @@ 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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
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.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.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.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(ImageCache.croppedBorderImage(image), new_x + radius / 2-minusxy, new_y + radius / 2-minusxy, new_w * croppedArea, new_h * croppedArea, (new_x + radius / 2-minusxy) + (new_w * croppedArea) / 2, (new_y + radius / 2-minusxy) + (new_h * croppedArea) / 2, isAftermath ? 90 : -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x + radius / 2 - minusxy, new_y + radius / 2 - minusxy, new_w * croppedArea, new_h * croppedArea, (new_x + radius / 2 - minusxy) + (new_w * croppedArea) / 2, (new_y + radius / 2 - minusxy) + (new_h * croppedArea) / 2, isAftermath ? 90 : -90);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
@@ -787,11 +798,11 @@ 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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawImage(image, x, y, w, h); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h); g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f-minusxy, y + radius / 2-minusxy, w * croppedArea, h * croppedArea); g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f - minusxy, y + radius / 2 - minusxy, w * croppedArea, h * croppedArea);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h); g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);
@@ -804,11 +815,11 @@ 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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawImage(image, x, y, w, h); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h); g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f-minusxy, y + radius / 2-minusxy, w * croppedArea, h * croppedArea); g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f - minusxy, y + radius / 2 - minusxy, w * croppedArea, h * croppedArea);
} }
} else if (Forge.enableUIMask.equals("Crop") && canshow) { } else if (Forge.enableUIMask.equals("Crop") && canshow) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h); g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);
@@ -841,8 +852,7 @@ public class CardImageRenderer {
final boolean isFaceDown = card.isFaceDown(); final boolean isFaceDown = card.isFaceDown();
if (isFaceDown) { if (isFaceDown) {
borderColors = ImmutableList.of(DetailColors.FACE_DOWN); borderColors = ImmutableList.of(DetailColors.FACE_DOWN);
} } else {
else {
borderColors = CardDetailUtil.getBorderColors(state, canShow); borderColors = CardDetailUtil.getBorderColors(state, canShow);
} }
Color[] colors = fillColorBackground(g, borderColors, x, y, w, h); Color[] colors = fillColorBackground(g, borderColors, x, y, w, h);
@@ -881,6 +891,7 @@ public class CardImageRenderer {
fillColorBackground(g, colors, x, y, w, h); fillColorBackground(g, colors, x, y, w, h);
return colors; return colors;
} }
public static Color[] drawCardBackgroundTexture(CardStateView state, Graphics g, List<DetailColors> backColors, float x, float y, float w, float h) { public static Color[] drawCardBackgroundTexture(CardStateView state, Graphics g, List<DetailColors> backColors, float x, float y, float w, float h) {
boolean isHybrid = state.getManaCost().hasHybrid(); boolean isHybrid = state.getManaCost().hasHybrid();
boolean isPW = state.isPlaneswalker(); boolean isPW = state.isPlaneswalker();
@@ -893,43 +904,43 @@ public class CardImageRenderer {
switch (backColors.size()) { switch (backColors.size()) {
case 1: case 1:
if (backColors.get(0) == DetailColors.FACE_DOWN) { if (backColors.get(0) == DetailColors.FACE_DOWN) {
g.drawImage(FSkinImage.CARDBG_C, x, y, w,h); g.drawImage(FSkinImage.CARDBG_C, x, y, w, h);
} else if (backColors.get(0) == DetailColors.LAND) { } else if (backColors.get(0) == DetailColors.LAND) {
g.drawImage(isPW ? FSkinImage.PWBG_C : FSkinImage.CARDBG_L, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_C : FSkinImage.CARDBG_L, x, y, w, h);
}else if (backColors.get(0) == DetailColors.MULTICOLOR) { } else if (backColors.get(0) == DetailColors.MULTICOLOR) {
g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_M, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_M, x, y, w, (h / 2) + (h / 5));
} else if (backColors.get(0) == DetailColors.COLORLESS) { } else if (backColors.get(0) == DetailColors.COLORLESS) {
if (isPW) if (isPW)
g.drawImage(FSkinImage.PWBG_C, x, y, w,h); g.drawImage(FSkinImage.PWBG_C, x, y, w, h);
else if (state.isVehicle()) else if (state.isVehicle())
g.drawImage(FSkinImage.CARDBG_V, x, y, w,h); g.drawImage(FSkinImage.CARDBG_V, x, y, w, h);
else if (state.isArtifact()) else if (state.isArtifact())
g.drawImage(FSkinImage.CARDBG_A, x, y, w,h); g.drawImage(FSkinImage.CARDBG_A, x, y, w, h);
else else
g.drawImage(FSkinImage.CARDBG_C, x, y, w,h); g.drawImage(FSkinImage.CARDBG_C, x, y, w, h);
//todo add NYX for colorless? //todo add NYX for colorless?
} else if (backColors.get(0) == DetailColors.GREEN) { } else if (backColors.get(0) == DetailColors.GREEN) {
g.drawImage(isPW ? FSkinImage.PWBG_G : FSkinImage.CARDBG_G, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_G : FSkinImage.CARDBG_G, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_G, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_G, x, y, w, (h / 2) + (h / 5));
} else if (backColors.get(0) == DetailColors.RED) { } else if (backColors.get(0) == DetailColors.RED) {
g.drawImage(isPW ? FSkinImage.PWBG_R : FSkinImage.CARDBG_R, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_R : FSkinImage.CARDBG_R, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_R, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_R, x, y, w, (h / 2) + (h / 5));
} else if (backColors.get(0) == DetailColors.BLACK) { } else if (backColors.get(0) == DetailColors.BLACK) {
g.drawImage(isPW ? FSkinImage.PWBG_B : FSkinImage.CARDBG_B, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_B : FSkinImage.CARDBG_B, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_B, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_B, x, y, w, (h / 2) + (h / 5));
} else if (backColors.get(0) == DetailColors.BLUE) { } else if (backColors.get(0) == DetailColors.BLUE) {
g.drawImage(isPW ? FSkinImage.PWBG_U : FSkinImage.CARDBG_U, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_U : FSkinImage.CARDBG_U, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_U, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_U, x, y, w, (h / 2) + (h / 5));
} else if (backColors.get(0) == DetailColors.WHITE) { } else if (backColors.get(0) == DetailColors.WHITE) {
g.drawImage(isPW ? FSkinImage.PWBG_W : FSkinImage.CARDBG_W, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_W : FSkinImage.CARDBG_W, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_W, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_W, x, y, w, (h / 2) + (h / 5));
} }
break; break;
case 2: case 2:
@@ -957,19 +968,20 @@ public class CardImageRenderer {
g.drawImage(isPW ? FSkinImage.PWBG_RG : FSkinImage.CARDBG_RG, x, y, w, h); g.drawImage(isPW ? FSkinImage.PWBG_RG : FSkinImage.CARDBG_RG, x, y, w, h);
} }
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_M, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_M, x, y, w, (h / 2) + (h / 5));
break; break;
case 3: case 3:
g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w, h); g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w, h);
if (isNyx) if (isNyx)
g.drawImage(FSkinImage.NYX_M, x, y, w, (h/2)+(h/5)); g.drawImage(FSkinImage.NYX_M, x, y, w, (h / 2) + (h / 5));
break; break;
default: default:
g.drawImage(isPW ? FSkinImage.PWBG_C : FSkinImage.CARDBG_C, x, y, w,h); g.drawImage(isPW ? FSkinImage.PWBG_C : FSkinImage.CARDBG_C, x, y, w, h);
break; break;
} }
return colors; return colors;
} }
public static void fillColorBackground(Graphics g, Color[] colors, float x, float y, float w, float h) { public static void fillColorBackground(Graphics g, Color[] colors, float x, float y, float w, float h) {
switch (colors.length) { switch (colors.length) {
case 1: case 1:
@@ -1059,7 +1071,9 @@ public class CardImageRenderer {
} }
String ptText = CardDetailUtil.formatPowerToughness(state, canShow); String ptText = CardDetailUtil.formatPowerToughness(state, canShow);
if (StringUtils.isEmpty(ptText)) { return; } if (StringUtils.isEmpty(ptText)) {
return;
}
float padding = PT_FONT.getCapHeight() / 2; float padding = PT_FONT.getCapHeight() / 2;
float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding, float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding,

View File

@@ -125,7 +125,7 @@ public class CardRenderer {
public static Color getRarityColor(CardRarity rarity) { public static Color getRarityColor(CardRarity rarity) {
if (rarity == null)// NPE from Rarity weird... if (rarity == null)// NPE from Rarity weird...
return Color.CLEAR; return Color.CLEAR;
switch(rarity) { switch (rarity) {
case Uncommon: case Uncommon:
return fromDetailColor(DetailColors.UNCOMMON); return fromDetailColor(DetailColors.UNCOMMON);
case Rare: case Rare:
@@ -193,7 +193,7 @@ public class CardRenderer {
public static final float CARD_ART_HEIGHT_PERCENTAGE = 0.43f; public static final float CARD_ART_HEIGHT_PERCENTAGE = 0.43f;
private static List<String> classicModuleCardtoCrop = FileUtil.readFile(ForgeConstants.CLASSIC_MODULE_CARD_TO_CROP_FILE); private static List<String> classicModuleCardtoCrop = FileUtil.readFile(ForgeConstants.CLASSIC_MODULE_CARD_TO_CROP_FILE);
public static void clearcardArtCache(){ public static void clearcardArtCache() {
Forge.getAssets().cardArtCache().clear(); Forge.getAssets().cardArtCache().clear();
} }
@@ -205,7 +205,7 @@ public class CardRenderer {
public static FImageComplex getCardArt(IPaperCard pc, boolean backFace) { public static FImageComplex getCardArt(IPaperCard pc, boolean backFace) {
CardType type = pc.getRules().getType(); CardType type = pc.getRules().getType();
return getCardArt(pc.getImageKey(backFace), pc.getRules().getSplitType() == CardSplitType.Split, return getCardArt(pc.getImageKey(backFace), pc.getRules().getSplitType() == CardSplitType.Split,
type.isPlane() || type.isPhenomenon(),pc.getRules().getOracleText().contains("Aftermath"), type.isPlane() || type.isPhenomenon(), pc.getRules().getOracleText().contains("Aftermath"),
type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), CardSplitType.Flip.equals(pc.getRules().getSplitType()), type.hasSubtype("Saga"), type.hasSubtype("Class"), type.isDungeon(), CardSplitType.Flip.equals(pc.getRules().getSplitType()),
type.isPlaneswalker(), isModernFrame(pc)); type.isPlaneswalker(), isModernFrame(pc));
} }
@@ -225,8 +225,7 @@ public class CardRenderer {
if (image != null) { if (image != null) {
if (image == ImageCache.getDefaultImage()) { if (image == ImageCache.getDefaultImage()) {
cardArt = CardImageRenderer.forgeArt; cardArt = CardImageRenderer.forgeArt;
} } else {
else {
float x, y; float x, y;
float w = image.getWidth(); float w = image.getWidth();
float h = image.getHeight(); float h = image.getHeight();
@@ -235,7 +234,7 @@ public class CardRenderer {
y = h * 0.2f; y = h * 0.2f;
w -= 2f * x; w -= 2f * x;
h -= 3f * y; h -= 3f * y;
}else if (isPlanesWalker) { } else if (isPlanesWalker) {
x = w * 0.09f; x = w * 0.09f;
y = h * 0.11f; y = h * 0.11f;
w -= 2f * x; w -= 2f * x;
@@ -284,7 +283,7 @@ public class CardRenderer {
} }
} else { } else {
//adjust smaller crop //adjust smaller crop
x = isModernFrame ? w * 0.1f :w * 0.12f; x = isModernFrame ? w * 0.1f : w * 0.12f;
y = isModernFrame ? h * 0.12f : h * 0.11f; y = isModernFrame ? h * 0.12f : h * 0.11f;
w -= isModernFrame ? 2 * x : 2.1f * x; w -= isModernFrame ? 2 * x : 2.1f * x;
h *= CARD_ART_HEIGHT_PERCENTAGE; h *= CARD_ART_HEIGHT_PERCENTAGE;
@@ -312,7 +311,7 @@ public class CardRenderer {
} }
public static FImageComplex getAftermathSecondCardArt(final String imageKey) { public static FImageComplex getAftermathSecondCardArt(final String imageKey) {
FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Aftermath_second_"+imageKey); FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Aftermath_second_" + imageKey);
if (cardArt == null) { if (cardArt == null) {
Texture image = new CachedCardImage(imageKey) { Texture image = new CachedCardImage(imageKey) {
@Override @Override
@@ -338,14 +337,14 @@ public class CardRenderer {
} }
if (!CardImageRenderer.forgeArt.equals(cardArt)) if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Aftermath_second_"+imageKey, cardArt); Forge.getAssets().cardArtCache().put("Aftermath_second_" + imageKey, cardArt);
} }
} }
return cardArt; return cardArt;
} }
public static FImageComplex getAlternateCardArt(final String imageKey, boolean isPlanesWalker) { public static FImageComplex getAlternateCardArt(final String imageKey, boolean isPlanesWalker) {
FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Alternate_"+imageKey); FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Alternate_" + imageKey);
if (cardArt == null) { if (cardArt == null) {
Texture image = new CachedCardImage(imageKey) { Texture image = new CachedCardImage(imageKey) {
@Override @Override
@@ -385,7 +384,7 @@ public class CardRenderer {
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h))); cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
} }
if (!CardImageRenderer.forgeArt.equals(cardArt)) if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Alternate_"+imageKey, cardArt); Forge.getAssets().cardArtCache().put("Alternate_" + imageKey, cardArt);
} }
} }
return cardArt; return cardArt;
@@ -394,9 +393,9 @@ public class CardRenderer {
public static FImageComplex getMeldCardParts(final String imageKey, boolean bottom) { public static FImageComplex getMeldCardParts(final String imageKey, boolean bottom) {
FImageComplex cardArt; FImageComplex cardArt;
if (!bottom) { if (!bottom) {
cardArt = Forge.getAssets().cardArtCache().get("Meld_primary_"+imageKey); cardArt = Forge.getAssets().cardArtCache().get("Meld_primary_" + imageKey);
} else { } else {
cardArt = Forge.getAssets().cardArtCache().get("Meld_secondary_"+imageKey); cardArt = Forge.getAssets().cardArtCache().get("Meld_secondary_" + imageKey);
} }
if (cardArt == null) { if (cardArt == null) {
@@ -414,15 +413,15 @@ public class CardRenderer {
} else { } else {
float x = 0; float x = 0;
float w = image.getWidth(); float w = image.getWidth();
float h = image.getHeight()/2f; float h = image.getHeight() / 2f;
float y = bottom ? h : 0; float y = bottom ? h : 0;
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h))); cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
} }
if (!bottom && !CardImageRenderer.forgeArt.equals(cardArt)) if (!bottom && !CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Meld_primary_"+imageKey, cardArt); Forge.getAssets().cardArtCache().put("Meld_primary_" + imageKey, cardArt);
else if (!CardImageRenderer.forgeArt.equals(cardArt)) else if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Meld_secondary_"+imageKey, cardArt); Forge.getAssets().cardArtCache().put("Meld_secondary_" + imageKey, cardArt);
} }
} }
return cardArt; return cardArt;
@@ -434,8 +433,7 @@ public class CardRenderer {
drawCardListItem(g, font, foreColor, getCardArt(card), card, state.getSetCode(), drawCardListItem(g, font, foreColor, getCardArt(card), card, state.getSetCode(),
state.getRarity(), state.getPower(), state.getToughness(), state.getRarity(), state.getPower(), state.getToughness(),
state.getLoyalty(), count, suffix, x, y, w, h, compactMode); state.getLoyalty(), count, suffix, x, y, w, h, compactMode);
} } else { //if fake card, just draw card name centered
else { //if fake card, just draw card name centered
String name = CardTranslation.getTranslatedName(state.getName()); String name = CardTranslation.getTranslatedName(state.getName());
if (count > 0) { //preface name with count if applicable if (count > 0) { //preface name with count if applicable
name = count + " " + name; name = count + " " + name;
@@ -469,15 +467,13 @@ public class CardRenderer {
float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CARD_ART_RATIO); float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CARD_ART_RATIO);
srcHeight -= dh; srcHeight -= dh;
srcY += dh / 2; srcY += dh / 2;
g.drawRotatedImage(cardArt.getTexture(), artX, artY, cardArtHeight, cardArtWidth / 2, artX + cardArtWidth / 2, artY + cardArtWidth / 2, cardArt.getRegionX(), (int)srcY, (int)cardArt.getWidth(), (int)srcHeight, -90); g.drawRotatedImage(cardArt.getTexture(), artX, artY, cardArtHeight, cardArtWidth / 2, artX + cardArtWidth / 2, artY + cardArtWidth / 2, cardArt.getRegionX(), (int) srcY, (int) cardArt.getWidth(), (int) srcHeight, -90);
g.drawRotatedImage(cardArt.getTexture(), artX, artY + cardArtWidth / 2, cardArtHeight, cardArtWidth / 2, artX + cardArtWidth / 2, artY + cardArtWidth / 2, cardArt.getRegionX(), (int)cardArt.getHeight() - (int)(srcY + srcHeight), (int)cardArt.getWidth(), (int)srcHeight, -90); g.drawRotatedImage(cardArt.getTexture(), artX, artY + cardArtWidth / 2, cardArtHeight, cardArtWidth / 2, artX + cardArtWidth / 2, artY + cardArtWidth / 2, cardArt.getRegionX(), (int) cardArt.getHeight() - (int) (srcY + srcHeight), (int) cardArt.getWidth(), (int) srcHeight, -90);
} } else if (card.getText().contains("Aftermath")) {
else if (card.getText().contains("Aftermath")) {
FImageComplex secondArt = CardRenderer.getAftermathSecondCardArt(card.getCurrentState().getImageKey()); FImageComplex secondArt = CardRenderer.getAftermathSecondCardArt(card.getCurrentState().getImageKey());
g.drawRotatedImage(cardArt.getTexture(), artX, artY, cardArtWidth, cardArtHeight / 2, artX + cardArtWidth, artY + cardArtHeight / 2, cardArt.getRegionX(), cardArt.getRegionY(), (int)cardArt.getWidth(), (int)cardArt.getHeight() /2, 0); g.drawRotatedImage(cardArt.getTexture(), artX, artY, cardArtWidth, cardArtHeight / 2, artX + cardArtWidth, artY + cardArtHeight / 2, cardArt.getRegionX(), cardArt.getRegionY(), (int) cardArt.getWidth(), (int) cardArt.getHeight() / 2, 0);
g.drawRotatedImage(secondArt.getTexture(), artX - cardArtHeight / 2 , artY + cardArtHeight / 2, cardArtHeight /2, cardArtWidth, artX, artY + cardArtHeight / 2, secondArt.getRegionX(), secondArt.getRegionY(), (int)secondArt.getWidth(), (int)secondArt.getHeight(), 90); g.drawRotatedImage(secondArt.getTexture(), artX - cardArtHeight / 2, artY + cardArtHeight / 2, cardArtHeight / 2, cardArtWidth, artX, artY + cardArtHeight / 2, secondArt.getRegionX(), secondArt.getRegionY(), (int) secondArt.getWidth(), (int) secondArt.getHeight(), 90);
} } else {
else {
g.drawImage(cardArt, artX, artY, cardArtWidth, cardArtHeight); g.drawImage(cardArt, artX, artY, cardArtWidth, cardArtHeight);
} }
} }
@@ -526,11 +522,9 @@ public class CardRenderer {
String type = CardDetailUtil.formatCardType(card.getCurrentState(), true); String type = CardDetailUtil.formatCardType(card.getCurrentState(), true);
if (card.getCurrentState().isCreature()) { //include P/T or Loyalty at end of type if (card.getCurrentState().isCreature()) { //include P/T or Loyalty at end of type
type += " (" + power + " / " + toughness + ")"; type += " (" + power + " / " + toughness + ")";
} } else if (card.getCurrentState().isPlaneswalker()) {
else if (card.getCurrentState().isPlaneswalker()) {
type += " (" + loyalty + ")"; type += " (" + loyalty + ")";
} } else if (card.getCurrentState().getType().hasSubtype("Vehicle")) {
else if (card.getCurrentState().getType().hasSubtype("Vehicle")) {
type += String.format(" [%s / %s]", power, toughness); type += String.format(" [%s / %s]", power, toughness);
} }
g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, Align.left, true); g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, Align.left, true);
@@ -567,24 +561,24 @@ 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();
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;
if (pc.getEdition().equals("LEA")||pc.getEdition().equals("LEB")) { if (pc.getEdition().equals("LEA") || pc.getEdition().equals("LEB")) {
croppedArea = 0.975f; croppedArea = 0.975f;
minusxy = 0.135f*radius; minusxy = 0.135f * radius;
} }
if (image != null) { if (image != null) {
if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) { if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) {
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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawImage(image, x, y, w, h); g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else { else {
//tint the border //tint the border
g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h); g.drawImage(ImageCache.getBorderImage(image.toString()), ImageCache.borderColor(image), x, y, w, h);
g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f-minusxy, y + radius / 2-minusxy, w * croppedArea, h * croppedArea); g.drawImage(ImageCache.croppedBorderImage(image), x + radius / 2.4f - minusxy, y + radius / 2 - minusxy, w * croppedArea, h * croppedArea);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h); g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);
@@ -603,21 +597,23 @@ public class CardRenderer {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, Forge.enableUIMask.equals("Art"), true); CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, Forge.enableUIMask.equals("Art"), true);
} }
} }
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) {
drawCard(g, card, x, y, w, h, pos, rotate, false, false, false); drawCard(g, card, x, y, w, h, pos, rotate, false, false, false);
} }
public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate, boolean showAltState, boolean isChoiceList, boolean magnify) { public static void drawCard(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean rotate, boolean showAltState, boolean isChoiceList, boolean magnify) {
boolean canshow = MatchController.instance.mayView(card); boolean canshow = MatchController.instance.mayView(card);
boolean showsleeves = card.isFaceDown() && card.isInZone(EnumSet.of(ZoneType.Exile)); //fix facedown card image ie gonti lord of luxury boolean showsleeves = card.isFaceDown() && card.isInZone(EnumSet.of(ZoneType.Exile)); //fix facedown card image ie gonti lord of luxury
Texture image = new RendererCachedCardImage(card, false).getImage( showAltState ? card.getAlternateState().getImageKey() : card.getCurrentState().getImageKey()); Texture image = new RendererCachedCardImage(card, false).getImage(showAltState ? card.getAlternateState().getImageKey() : card.getCurrentState().getImageKey());
TextureRegion crack_overlay = FSkin.getCracks().get(card.getCrackOverlayInt()); TextureRegion crack_overlay = FSkin.getCracks().get(card.getCrackOverlayInt());
FImage sleeves = MatchController.getPlayerSleeve(card.getOwner()); FImage sleeves = MatchController.getPlayerSleeve(card.getOwner());
float radius = (h - w)/8; float radius = (h - w) / 8;
float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f; float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f;
float minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius; float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) { if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f; croppedArea = 0.975f;
minusxy = 0.135f*radius; minusxy = 0.135f * radius;
} }
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
if (card.isPhasedOut() && !magnify) if (card.isPhasedOut() && !magnify)
@@ -631,23 +627,23 @@ public class CardRenderer {
else else
g.drawCardImage(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0); g.drawCardImage(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0);
} 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) {
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawRotatedImage(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);
g.drawRotatedImage(ImageCache.croppedBorderImage(image), x+radius/2.3f-minusxy, y+radius/2-minusxy, w*croppedArea, h*croppedArea, (x+radius/2.3f-minusxy) + (w*croppedArea) / 2, (y+radius/2-minusxy) + (h*croppedArea) / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), x + radius / 2.3f - minusxy, y + radius / 2 - minusxy, w * croppedArea, h * croppedArea, (x + radius / 2.3f - minusxy) + (w * croppedArea) / 2, (y + radius / 2 - minusxy) + (h * croppedArea) / 2, -90);
} }
} else if (Forge.enableUIMask.equals("Crop")) { } else if (Forge.enableUIMask.equals("Crop")) {
g.drawRotatedImage(ImageCache.croppedBorderImage(image),x, y, w, h, x + w / 2, y + h / 2, -90); g.drawRotatedImage(ImageCache.croppedBorderImage(image), x, y, w, h, x + w / 2, y + h / 2, -90);
} else } else
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 (ImageCache.isBorderlessCardArt(image)) if (image.toString().contains(".fullborder."))
g.drawCardImage(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0); g.drawCardRoundRect(image, crack_overlay, x, y, w, h, card.wasDestroyed(), 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();
g.drawBorderImage(ImageCache.getBorderImage(image.toString(), canshow), ImageCache.borderColor(image), ImageCache.getTint(card, image), x, y, w, h, t); //tint check for changed colors g.drawBorderImage(ImageCache.getBorderImage(image.toString(), canshow), ImageCache.borderColor(image), ImageCache.getTint(card, image), x, y, w, h, t); //tint check for changed colors
@@ -674,13 +670,18 @@ public class CardRenderer {
public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos) { public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos) {
drawCardWithOverlays(g, card, x, y, w, h, pos, false, false, false); drawCardWithOverlays(g, card, x, y, w, h, pos, false, false, false);
} }
static float markersHeight = 0f; static float markersHeight = 0f;
public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean stackview, boolean showAltState, boolean isChoiceList) { public static void drawCardWithOverlays(Graphics g, CardView card, float x, float y, float w, float h, CardStackPosition pos, boolean stackview, boolean showAltState, boolean isChoiceList) {
boolean canShow = MatchController.instance.mayView(card); boolean canShow = MatchController.instance.mayView(card);
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
boolean unselectable = !MatchController.instance.isSelectable(card) && MatchController.instance.isSelecting(); boolean unselectable = !MatchController.instance.isSelectable(card) && MatchController.instance.isSelecting();
float cx, cy, cw, ch; float cx, cy, cw, ch;
cx = x; cy = y; cw = w; ch = h; cx = x;
cy = y;
cw = w;
ch = h;
drawCard(g, card, x, y, w, h, pos, false, showAltState, isChoiceList, false); drawCard(g, card, x, y, w, h, pos, false, showAltState, isChoiceList, false);
float padding = w * PADDING_MULTIPLIER; //adjust for card border float padding = w * PADDING_MULTIPLIER; //adjust for card border
@@ -700,7 +701,9 @@ public class CardRenderer {
if (stackview) if (stackview)
return; //override return; //override
if (pos == CardStackPosition.BehindVert) { return; } //remaining rendering not needed if card is behind another card in a vertical stack if (pos == CardStackPosition.BehindVert) {
return;
} //remaining rendering not needed if card is behind another card in a vertical stack
boolean onTop = (pos == CardStackPosition.Top); boolean onTop = (pos == CardStackPosition.Top);
if (canShow && showCardIdOverlay(card)) { if (canShow && showCardIdOverlay(card)) {
@@ -736,7 +739,7 @@ public class CardRenderer {
//Class level //Class level
if (card.getCurrentState().getType().hasStringType("Class") && ZoneType.Battlefield.equals(card.getZone())) { if (card.getCurrentState().getType().hasStringType("Class") && ZoneType.Battlefield.equals(card.getZone())) {
List<String> markers = new ArrayList<>(); List<String> markers = new ArrayList<>();
markers.add("LV:"+card.getClassLevel()); markers.add("LV:" + card.getClassLevel());
drawMarkersTabs(markers, g, x, y - markersHeight, w, h, true); drawMarkersTabs(markers, g, x, y - markersHeight, w, h, true);
} }
@@ -747,8 +750,7 @@ public class CardRenderer {
if (card.isAttacking()) { if (card.isAttacking()) {
CardFaceSymbols.drawSymbol("attack", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize); CardFaceSymbols.drawSymbol("attack", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
} } else if (card.isBlocking()) {
else if (card.isBlocking()) {
CardFaceSymbols.drawSymbol("defend", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize); CardFaceSymbols.drawSymbol("defend", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
} }
@@ -771,29 +773,31 @@ public class CardRenderer {
drawPtBox(g, card, details, color, x, y, w, h); drawPtBox(g, card, details, color, x, y, w, h);
} }
//Darken unselectable cards //Darken unselectable cards
if (unselectable){ if (unselectable) {
g.setAlphaComposite(0.6f); g.setAlphaComposite(0.6f);
g.fillRect(Color.BLACK, cx, cy, cw, ch); g.fillRect(Color.BLACK, cx, cy, cw, ch);
g.setAlphaComposite(oldAlpha); g.setAlphaComposite(oldAlpha);
} }
//Magenta outline when card is chosen //Magenta outline when card is chosen
if (MatchController.instance.isUsedToPay(card)){ if (MatchController.instance.isUsedToPay(card)) {
g.drawRect(BORDER_THICKNESS, Color.MAGENTA, cx, cy, cw, ch); g.drawRect(BORDER_THICKNESS, Color.MAGENTA, cx, cy, cw, ch);
} }
//Ability Icons //Ability Icons
boolean onbattlefield = ZoneType.Battlefield.equals(card.getZone()); boolean onbattlefield = ZoneType.Battlefield.equals(card.getZone());
if (unselectable){ g.setAlphaComposite(0.6f); } if (unselectable) {
g.setAlphaComposite(0.6f);
}
if (onbattlefield && onTop && showAbilityIcons(card)) { if (onbattlefield && onTop && showAbilityIcons(card)) {
drawAbilityIcons(g,card, cx, cy, cw, cx + ((cw*2)/2.3f), cy, cw / 5.5f, cw / 5.7f); drawAbilityIcons(g, card, cx, cy, cw, cx + ((cw * 2) / 2.3f), cy, cw / 5.5f, cw / 5.7f);
} else if (canShow && !onbattlefield && showAbilityIcons(card)) { } else if (canShow && !onbattlefield && showAbilityIcons(card)) {
//draw indicator for flash or can be cast at instant speed, enabled if show ability icons is enabled //draw indicator for flash or can be cast at instant speed, enabled if show ability icons is enabled
String keywordKey = card.getCurrentState().getKeywordKey(); String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText(); String abilityText = card.getCurrentState().getAbilityText();
if ((keywordKey.indexOf("Flash") != -1) if ((keywordKey.indexOf("Flash") != -1)
|| ((abilityText.indexOf("May be played by") != -1) || ((abilityText.indexOf("May be played by") != -1)
&& (abilityText.indexOf("and as though it has flash") != -1))){ && (abilityText.indexOf("and as though it has flash") != -1))) {
if (keywordKey.indexOf("Flashback") == -1) if (keywordKey.indexOf("Flashback") == -1)
CardFaceSymbols.drawSymbol("flash", g, cx + ((cw*2)/2.3f), cy, cw / 5.5f, cw / 5.5f); CardFaceSymbols.drawSymbol("flash", g, cx + ((cw * 2) / 2.3f), cy, cw / 5.5f, cw / 5.5f);
} }
} }
//draw name and mana cost overlays if card is small or default card image being used //draw name and mana cost overlays if card is small or default card image being used
@@ -814,7 +818,7 @@ public class CardRenderer {
multiplier = 0.150f; multiplier = 0.150f;
break; break;
} }
g.drawOutlinedText(CardTranslation.getTranslatedName(details.getName()), FSkinFont.forHeight(h * multiplier), Color.WHITE, Color.BLACK, x + padding -1f, y + padding, w - 2 * padding, h * 0.4f, true, Align.left, false, true); g.drawOutlinedText(CardTranslation.getTranslatedName(details.getName()), FSkinFont.forHeight(h * multiplier), Color.WHITE, Color.BLACK, x + padding - 1f, y + padding, w - 2 * padding, h * 0.4f, true, Align.left, false, true);
} }
if (showCardManaCostOverlay(card)) { if (showCardManaCostOverlay(card)) {
float manaSymbolSize = w / 4.5f; float manaSymbolSize = w / 4.5f;
@@ -829,8 +833,7 @@ public class CardRenderer {
drawManaCost(g, card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize); drawManaCost(g, card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize);
} }
} }
} } else {
else {
drawManaCost(g, showAltState ? card.getAlternateState().getManaCost() : card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize); drawManaCost(g, showAltState ? card.getAlternateState().getManaCost() : card.getCurrentState().getManaCost(), x - padding, y, w + 2 * padding, h, manaSymbolSize);
} }
} }
@@ -841,7 +844,7 @@ public class CardRenderer {
public static void drawAbilityIcons(Graphics g, CardView card, float cx, float cy, float cw, float abiX, float abiY, float abiScale, float abiSpace) { public static void drawAbilityIcons(Graphics g, CardView card, float cx, float cy, float cw, float abiX, float abiY, float abiScale, float abiSpace) {
float abiCount = 0; float abiCount = 0;
if (card.isToken()){ if (card.isToken()) {
CardFaceSymbols.drawSymbol("token", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("token", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
@@ -865,50 +868,70 @@ public class CardRenderer {
CardFaceSymbols.drawSymbol("doublestrike", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("doublestrike", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().hasFirstStrike()) {
else if (card.getCurrentState().hasFirstStrike()) {
CardFaceSymbols.drawSymbol("firststrike", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("firststrike", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasDeathtouch()) { if (card.getCurrentState().hasDeathtouch()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("deathtouch", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("deathtouch", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasIndestructible()) { if (card.getCurrentState().hasIndestructible()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("indestructible", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("indestructible", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasMenace()) { if (card.getCurrentState().hasMenace()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("menace", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("menace", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasFear()) { if (card.getCurrentState().hasFear()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("fear", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("fear", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasIntimidate()) { if (card.getCurrentState().hasIntimidate()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("intimidate", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("intimidate", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasShadow()) { if (card.getCurrentState().hasShadow()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("shadow", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("shadow", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasHorsemanship()) { if (card.getCurrentState().hasHorsemanship()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("horsemanship", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("horsemanship", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
@@ -919,8 +942,11 @@ public class CardRenderer {
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasHexproof()) { if (card.getCurrentState().hasHexproof()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
if (!card.getCurrentState().getHexproofKey().isEmpty()){ abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
if (!card.getCurrentState().getHexproofKey().isEmpty()) {
String[] splitK = card.getCurrentState().getHexproofKey().split(":"); String[] splitK = card.getCurrentState().getHexproofKey().split(":");
List<String> listHK = Arrays.asList(splitK); List<String> listHK = Arrays.asList(splitK);
if (listHK.contains("generic")) { if (listHK.contains("generic")) {
@@ -963,138 +989,142 @@ public class CardRenderer {
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
} else if (card.getCurrentState().hasShroud()) {
if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
} }
else if (card.getCurrentState().hasShroud()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); }
CardFaceSymbols.drawSymbol("shroud", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("shroud", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasVigilance()) { if (card.getCurrentState().hasVigilance()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("vigilance", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("vigilance", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasTrample()) { if (card.getCurrentState().hasTrample()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("trample", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("trample", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasReach()) { if (card.getCurrentState().hasReach()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("reach", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("reach", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasLifelink()) { if (card.getCurrentState().hasLifelink()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("lifelink", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("lifelink", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
if (card.getCurrentState().hasDefender()) { if (card.getCurrentState().hasDefender()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
CardFaceSymbols.drawSymbol("defender", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("defender", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
//Protection Icons //Protection Icons
if (!card.getCurrentState().getProtectionKey().isEmpty()){ if (!card.getCurrentState().getProtectionKey().isEmpty()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); } if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
if (card.getCurrentState().getProtectionKey().contains("everything") || card.getCurrentState().getProtectionKey().contains("allcolors")) { if (card.getCurrentState().getProtectionKey().contains("everything") || card.getCurrentState().getProtectionKey().contains("allcolors")) {
CardFaceSymbols.drawSymbol("protectAll", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectAll", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().contains("coloredspells")) {
else if (card.getCurrentState().getProtectionKey().contains("coloredspells")) {
CardFaceSymbols.drawSymbol("protectColoredSpells", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectColoredSpells", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("R")) {
else if (card.getCurrentState().getProtectionKey().equals("R")) {
CardFaceSymbols.drawSymbol("protectR", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectR", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("G")) {
else if (card.getCurrentState().getProtectionKey().equals("G")) {
CardFaceSymbols.drawSymbol("protectG", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectG", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("B")) {
else if (card.getCurrentState().getProtectionKey().equals("B")) {
CardFaceSymbols.drawSymbol("protectB", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectB", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("U")) {
else if (card.getCurrentState().getProtectionKey().equals("U")) {
CardFaceSymbols.drawSymbol("protectU", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectU", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("W")) {
else if (card.getCurrentState().getProtectionKey().equals("W")) {
CardFaceSymbols.drawSymbol("protectW", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("RG") || card.getCurrentState().getProtectionKey().equals("GR")) {
else if (card.getCurrentState().getProtectionKey().equals("RG")||card.getCurrentState().getProtectionKey().equals("GR")) {
CardFaceSymbols.drawSymbol("protectRG", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectRG", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("RB") || card.getCurrentState().getProtectionKey().equals("BR")) {
else if (card.getCurrentState().getProtectionKey().equals("RB")||card.getCurrentState().getProtectionKey().equals("BR")) {
CardFaceSymbols.drawSymbol("protectRB", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectRB", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("RU") || card.getCurrentState().getProtectionKey().equals("UR")) {
else if (card.getCurrentState().getProtectionKey().equals("RU")||card.getCurrentState().getProtectionKey().equals("UR")) {
CardFaceSymbols.drawSymbol("protectRU", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectRU", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("RW") || card.getCurrentState().getProtectionKey().equals("WR")) {
else if (card.getCurrentState().getProtectionKey().equals("RW")||card.getCurrentState().getProtectionKey().equals("WR")) {
CardFaceSymbols.drawSymbol("protectRW", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectRW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("GB") || card.getCurrentState().getProtectionKey().equals("BG")) {
else if (card.getCurrentState().getProtectionKey().equals("GB")||card.getCurrentState().getProtectionKey().equals("BG")) {
CardFaceSymbols.drawSymbol("protectGB", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectGB", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("GU") || card.getCurrentState().getProtectionKey().equals("UG")) {
else if (card.getCurrentState().getProtectionKey().equals("GU")||card.getCurrentState().getProtectionKey().equals("UG")) {
CardFaceSymbols.drawSymbol("protectGU", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectGU", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("GW") || card.getCurrentState().getProtectionKey().equals("WG")) {
else if (card.getCurrentState().getProtectionKey().equals("GW")||card.getCurrentState().getProtectionKey().equals("WG")) {
CardFaceSymbols.drawSymbol("protectGW", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectGW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("BU") || card.getCurrentState().getProtectionKey().equals("UB")) {
else if (card.getCurrentState().getProtectionKey().equals("BU")||card.getCurrentState().getProtectionKey().equals("UB")) {
CardFaceSymbols.drawSymbol("protectBU", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectBU", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("BW") || card.getCurrentState().getProtectionKey().equals("WB")) {
else if (card.getCurrentState().getProtectionKey().equals("BW")||card.getCurrentState().getProtectionKey().equals("WB")) {
CardFaceSymbols.drawSymbol("protectBW", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectBW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().equals("UW") || card.getCurrentState().getProtectionKey().equals("WU")) {
else if (card.getCurrentState().getProtectionKey().equals("UW")||card.getCurrentState().getProtectionKey().equals("WU")) {
CardFaceSymbols.drawSymbol("protectUW", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectUW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} } else if (card.getCurrentState().getProtectionKey().contains("generic") || card.getCurrentState().getProtectionKey().length() > 2) {
else if (card.getCurrentState().getProtectionKey().contains("generic") || card.getCurrentState().getProtectionKey().length() > 2) {
CardFaceSymbols.drawSymbol("protectGeneric", g, abiX, abiY, abiScale, abiScale); CardFaceSymbols.drawSymbol("protectGeneric", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace; abiY += abiSpace;
abiCount += 1; abiCount += 1;
} }
} }
} }
private static void drawCounterTabs(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) { private static void drawCounterTabs(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) {
int fontSize = Math.max(11, Math.min(22, (int) (h * 0.08))); int fontSize = Math.max(11, Math.min(22, (int) (h * 0.08)));
@@ -1122,7 +1152,7 @@ public class CardRenderer {
} }
//if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) { //if (counterBoxBaseWidth + font.getBounds(String.valueOf(maxCounters)).width > w) {
if(font != null && !String.valueOf(maxCounters).isEmpty()){ if (font != null && !String.valueOf(maxCounters).isEmpty()) {
layout.setText(font, String.valueOf(maxCounters)); layout.setText(font, String.valueOf(maxCounters));
if (counterBoxBaseWidth + layout.width > w) { if (counterBoxBaseWidth + layout.width > w) {
drawCounterImage(card, g, x, y, w, h); drawCounterImage(card, g, x, y, w, h);
@@ -1135,7 +1165,7 @@ public class CardRenderer {
final CounterType counter = counterEntry.getKey(); final CounterType counter = counterEntry.getKey();
final int numberOfCounters = counterEntry.getValue(); final int numberOfCounters = counterEntry.getValue();
//final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4; //final float counterBoxRealWidth = counterBoxBaseWidth + font.getBounds(String.valueOf(numberOfCounters)).width + 4;
if(font != null && !String.valueOf(numberOfCounters).isEmpty()){ if (font != null && !String.valueOf(numberOfCounters).isEmpty()) {
layout.setText(font, String.valueOf(numberOfCounters)); layout.setText(font, String.valueOf(numberOfCounters));
final float counterBoxRealWidth = counterBoxBaseWidth + layout.width + 4; final float counterBoxRealWidth = counterBoxBaseWidth + layout.width + 4;
@@ -1164,7 +1194,7 @@ public class CardRenderer {
if (color.a < 1) { //enable blending so alpha colored shapes work properly if (color.a < 1) { //enable blending so alpha colored shapes work properly
Gdx.gl.glEnable(GL_BLEND); Gdx.gl.glEnable(GL_BLEND);
} }
if(font != null && !text.isEmpty()) { if (font != null && !text.isEmpty()) {
layout.setText(font, text); layout.setText(font, text);
TextBounds textBounds = new TextBounds(layout.width, layout.height); TextBounds textBounds = new TextBounds(layout.width, layout.height);
@@ -1199,14 +1229,11 @@ public class CardRenderer {
if (counters == 1) { if (counters == 1) {
CardFaceSymbols.drawSymbol("counters1", g, xCounters, yCounters, countersSize, countersSize); CardFaceSymbols.drawSymbol("counters1", g, xCounters, yCounters, countersSize, countersSize);
} } else if (counters == 2) {
else if (counters == 2) {
CardFaceSymbols.drawSymbol("counters2", g, xCounters, yCounters, countersSize, countersSize); CardFaceSymbols.drawSymbol("counters2", g, xCounters, yCounters, countersSize, countersSize);
} } else if (counters == 3) {
else if (counters == 3) {
CardFaceSymbols.drawSymbol("counters3", g, xCounters, yCounters, countersSize, countersSize); CardFaceSymbols.drawSymbol("counters3", g, xCounters, yCounters, countersSize, countersSize);
} } else if (counters > 3) {
else if (counters > 3) {
CardFaceSymbols.drawSymbol("countersMulti", g, xCounters, yCounters, countersSize, countersSize); CardFaceSymbols.drawSymbol("countersMulti", g, xCounters, yCounters, countersSize, countersSize);
} }
@@ -1231,7 +1258,7 @@ public class CardRenderer {
int markerCounter = markers.size() - 1; int markerCounter = markers.size() - 1;
for (String marker : markers) { for (String marker : markers) {
if(font != null && !marker.isEmpty()) { if (font != null && !marker.isEmpty()) {
layout.setText(font, marker); layout.setText(font, marker);
final float markerBoxRealWidth = markerBoxBaseWidth + layout.width + 4; final float markerBoxRealWidth = markerBoxBaseWidth + layout.width + 4;
@@ -1254,8 +1281,7 @@ public class CardRenderer {
pieces.add(String.valueOf(details.getPower())); pieces.add(String.valueOf(details.getPower()));
pieces.add("/"); pieces.add("/");
pieces.add(String.valueOf(details.getToughness())); pieces.add(String.valueOf(details.getToughness()));
} } else if (details.getType().hasSubtype("Vehicle")) {
else if (details.getType().hasSubtype("Vehicle")) {
pieces.add("["); pieces.add("[");
pieces.add(String.valueOf(details.getPower())); pieces.add(String.valueOf(details.getPower()));
pieces.add("/"); pieces.add("/");
@@ -1265,13 +1291,14 @@ public class CardRenderer {
if (details.isPlaneswalker()) { if (details.isPlaneswalker()) {
if (pieces.isEmpty()) { if (pieces.isEmpty()) {
pieces.add(String.valueOf(details.getLoyalty())); pieces.add(String.valueOf(details.getLoyalty()));
} } else {
else {
pieces.add("(" + details.getLoyalty() + ")"); pieces.add("(" + details.getLoyalty() + ")");
} }
} }
if (pieces.isEmpty()) { return; } if (pieces.isEmpty()) {
return;
}
FSkinFont font = FSkinFont.forHeight(h * 0.15f); FSkinFont font = FSkinFont.forHeight(h * 0.15f);
float padding = Math.round(font.getCapHeight() / 4); float padding = Math.round(font.getCapHeight() / 4);
@@ -1314,15 +1341,22 @@ public class CardRenderer {
} }
public static void drawFoilEffect(Graphics g, CardView card, float x, float y, float w, float h, boolean inZoomer) { public static void drawFoilEffect(Graphics g, CardView card, float x, float y, float w, float h, boolean inZoomer) {
float new_x = x; float new_y = y; float new_w = w; float new_h = h; float radius = (h - w)/8; float new_x = x;
float new_y = y;
float new_w = w;
float new_h = h;
float radius = (h - w) / 8;
float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f; float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f;
float minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius; float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) { if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f; croppedArea = 0.975f;
minusxy = 0.135f*radius; minusxy = 0.135f * radius;
} }
if (Forge.enableUIMask.equals("Full")) { if (Forge.enableUIMask.equals("Full")) {
new_x += radius/2.4f-minusxy; new_y += radius/2-minusxy; new_w = w * croppedArea; new_h = h * croppedArea; new_x += radius / 2.4f - minusxy;
new_y += radius / 2 - minusxy;
new_w = w * croppedArea;
new_h = h * croppedArea;
} }
if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT) && MatchController.instance.mayView(card)) { if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT) && MatchController.instance.mayView(card)) {
boolean rotateSplit = isPreferenceEnabled(FPref.UI_ROTATE_SPLIT_CARDS) && card.isSplitCard() && inZoomer; boolean rotateSplit = isPreferenceEnabled(FPref.UI_ROTATE_SPLIT_CARDS) && card.isSplitCard() && inZoomer;
@@ -1367,7 +1401,9 @@ public class CardRenderer {
FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.COMMON_FONTS_DIR).child("Roboto-Bold.ttf"); FileHandle ttfFile = Gdx.files.absolute(ForgeConstants.COMMON_FONTS_DIR).child("Roboto-Bold.ttf");
if (!ttfFile.exists()) { return; } if (!ttfFile.exists()) {
return;
}
final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile); final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile);

View File

@@ -53,15 +53,18 @@ public class CardZoom extends FOverlay {
public static void show(Object item) { public static void show(Object item) {
show(item, false); show(item, false);
} }
public static void show(Object item, boolean showbackside) { public static void show(Object item, boolean showbackside) {
List<Object> items0 = new ArrayList<>(); List<Object> items0 = new ArrayList<>();
items0.add(item); items0.add(item);
showBackSide = showbackside; //reverse the displayed zoomed card for the choice list showBackSide = showbackside; //reverse the displayed zoomed card for the choice list
show(items0, 0, null); show(items0, 0, null);
} }
public static void show(FCollectionView<?> items0, int currentIndex0, ActivateHandler activateHandler0) { public static void show(FCollectionView<?> items0, int currentIndex0, ActivateHandler activateHandler0) {
show((List<?>)items0, currentIndex0, activateHandler0); show((List<?>) items0, currentIndex0, activateHandler0);
} }
public static void show(final List<?> items0, int currentIndex0, ActivateHandler activateHandler0) { public static void show(final List<?> items0, int currentIndex0, ActivateHandler activateHandler0) {
items = items0; items = items0;
activateHandler = activateHandler0; activateHandler = activateHandler0;
@@ -89,7 +92,9 @@ public class CardZoom extends FOverlay {
@Override @Override
public void setVisible(boolean visible0) { public void setVisible(boolean visible0) {
if (this.isVisible() == visible0) { return; } if (this.isVisible() == visible0) {
return;
}
super.setVisible(visible0); super.setVisible(visible0);
@@ -101,7 +106,9 @@ public class CardZoom extends FOverlay {
private static void incrementCard(int dir) { private static void incrementCard(int dir) {
if (dir > 0) { if (dir > 0) {
if (currentIndex == items.size() - 1) { return; } if (currentIndex == items.size() - 1) {
return;
}
currentIndex++; currentIndex++;
prevCard = currentCard; prevCard = currentCard;
@@ -130,7 +137,7 @@ public class CardZoom extends FOverlay {
flipIconBounds = null; flipIconBounds = null;
} }
if (currentCard != null) { if (currentCard != null) {
if (currentCard.getMergedCardsCollection() != null ) if (currentCard.getMergedCardsCollection() != null)
if (currentCard.getMergedCardsCollection().size() > 0) if (currentCard.getMergedCardsCollection().size() > 0)
mutateIconBounds = new Rectangle(); mutateIconBounds = new Rectangle();
} }
@@ -139,29 +146,29 @@ public class CardZoom extends FOverlay {
private static CardView getCardView(Object item) { private static CardView getCardView(Object item) {
if (item instanceof Entry) { if (item instanceof Entry) {
item = ((Entry<?, ?>)item).getKey(); item = ((Entry<?, ?>) item).getKey();
} }
if (item instanceof CardView) { if (item instanceof CardView) {
return (CardView)item; return (CardView) item;
} }
if (item instanceof DeckProxy) { if (item instanceof DeckProxy) {
if (item instanceof CardThemedDeckGenerator){ if (item instanceof CardThemedDeckGenerator) {
return CardView.getCardForUi(((CardThemedDeckGenerator)item).getPaperCard()); return CardView.getCardForUi(((CardThemedDeckGenerator) item).getPaperCard());
}else if (item instanceof CommanderDeckGenerator){ } else if (item instanceof CommanderDeckGenerator) {
return CardView.getCardForUi(((CommanderDeckGenerator)item).getPaperCard()); return CardView.getCardForUi(((CommanderDeckGenerator) item).getPaperCard());
}else if (item instanceof ArchetypeDeckGenerator){ } else if (item instanceof ArchetypeDeckGenerator) {
return CardView.getCardForUi(((ArchetypeDeckGenerator)item).getPaperCard()); return CardView.getCardForUi(((ArchetypeDeckGenerator) item).getPaperCard());
}else{ } else {
DeckProxy deck = ((DeckProxy)item); DeckProxy deck = ((DeckProxy) item);
return new CardView(-1, null, deck.getName(), null, deck.getImageKey(false)); return new CardView(-1, null, deck.getName(), null, deck.getImageKey(false));
} }
} }
if (item instanceof IPaperCard) { if (item instanceof IPaperCard) {
return CardView.getCardForUi((IPaperCard)item); return CardView.getCardForUi((IPaperCard) item);
} }
if (item instanceof ConquestCommander) { if (item instanceof ConquestCommander) {
return CardView.getCardForUi(((ConquestCommander)item).getCard()); return CardView.getCardForUi(((ConquestCommander) item).getCard());
} }
if (item instanceof InventoryItem) { if (item instanceof InventoryItem) {
InventoryItem ii = (InventoryItem)item; InventoryItem ii = (InventoryItem)item;
@@ -173,7 +180,7 @@ public class CardZoom extends FOverlay {
@Override @Override
public boolean tap(float x, float y, int count) { public boolean tap(float x, float y, int count) {
if (mutateIconBounds != null && mutateIconBounds.contains(x, y)) { if (mutateIconBounds != null && mutateIconBounds.contains(x, y)) {
if(showMerged) { if (showMerged) {
showMerged = false; showMerged = false;
} else { } else {
showMerged = true; showMerged = true;
@@ -226,7 +233,9 @@ public class CardZoom extends FOverlay {
} }
private void setOneCardView(boolean oneCardView0) { private void setOneCardView(boolean oneCardView0) {
if (oneCardView == oneCardView0 || Forge.isLandscapeMode()) { return; } //don't allow changing this when in landscape mode if (oneCardView == oneCardView0 || Forge.isLandscapeMode()) {
return;
} //don't allow changing this when in landscape mode
oneCardView = oneCardView0; oneCardView = oneCardView0;
prefs.setPref(FPref.UI_SINGLE_CARD_ZOOM, oneCardView0); prefs.setPref(FPref.UI_SINGLE_CARD_ZOOM, oneCardView0);
@@ -240,8 +249,7 @@ public class CardZoom extends FOverlay {
if (totalZoomAmount >= REQ_AMOUNT) { if (totalZoomAmount >= REQ_AMOUNT) {
setOneCardView(true); setOneCardView(true);
totalZoomAmount = 0; totalZoomAmount = 0;
} } else if (totalZoomAmount <= -REQ_AMOUNT) {
else if (totalZoomAmount <= -REQ_AMOUNT) {
setOneCardView(false); setOneCardView(false);
totalZoomAmount = 0; totalZoomAmount = 0;
} }
@@ -288,14 +296,12 @@ public class CardZoom extends FOverlay {
boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS); boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS);
if (currentCard != null && currentCard.isSplitCard() && rotateSplit) { if (currentCard != null && currentCard.isSplitCard() && rotateSplit) {
// card will be rotated. Make sure that the height does not exceed the width of the view // card will be rotated. Make sure that the height does not exceed the width of the view
if (cardHeight > Gdx.graphics.getWidth()) if (cardHeight > Gdx.graphics.getWidth()) {
{
cardHeight = Gdx.graphics.getWidth(); cardHeight = Gdx.graphics.getWidth();
cardWidth = cardHeight / FCardPanel.ASPECT_RATIO; cardWidth = cardHeight / FCardPanel.ASPECT_RATIO;
} }
} }
} } else {
else {
cardWidth = w * 0.5f; cardWidth = w * 0.5f;
cardHeight = FCardPanel.ASPECT_RATIO * cardWidth; cardHeight = FCardPanel.ASPECT_RATIO * cardWidth;
@@ -326,7 +332,7 @@ public class CardZoom extends FOverlay {
if (zoomMode) { if (zoomMode) {
CardImageRenderer.drawZoom(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight, getWidth(), getHeight(), true); CardImageRenderer.drawZoom(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight, getWidth(), getHeight(), true);
} else { } else {
CardImageRenderer.drawDetails(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight); CardImageRenderer.drawDetails(g, currentCard, gameView, showBackSide ? showBackSide : showAltState, x, y, cardWidth, cardHeight);
} }
if (!showMerged) { if (!showMerged) {
@@ -370,18 +376,20 @@ public class CardZoom extends FOverlay {
public interface ActivateHandler { public interface ActivateHandler {
String getActivateAction(int index); String getActivateAction(int index);
void setSelectedIndex(int index); void setSelectedIndex(int index);
void activate(int index); void activate(int index);
} }
public void interrupt(boolean resume) { public void interrupt(boolean resume) {
if (MatchController.instance.hasLocalPlayers()) if (MatchController.instance.hasLocalPlayers())
return; return;
if(resume && MatchController.instance.isGamePaused()) { if (resume && MatchController.instance.isGamePaused()) {
MatchController.instance.resumeMatch(); MatchController.instance.resumeMatch();
return; return;
} }
if(!MatchController.instance.isGamePaused()) if (!MatchController.instance.isGamePaused())
MatchController.instance.pauseMatch(); MatchController.instance.pauseMatch();
} }
@@ -403,8 +411,7 @@ public class CardZoom extends FOverlay {
if (flipIconBounds != null) { if (flipIconBounds != null) {
tap(flipIconBounds.x, flipIconBounds.y, 1); tap(flipIconBounds.x, flipIconBounds.y, 1);
} }
} } else if (keyCode == Input.Keys.BUTTON_Y)
else if (keyCode == Input.Keys.BUTTON_Y)
fling(0, 300f); fling(0, 300f);
return true; return true;
} }

View File

@@ -40,14 +40,17 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private static final float PADDING = Utils.scale(5); private static final float PADDING = Utils.scale(5);
private static final float PILE_SPACING_Y = 0.1f; private static final float PILE_SPACING_Y = 0.1f;
private static final FSkinFont LABEL_FONT = FSkinFont.get(12); private static final FSkinFont LABEL_FONT = FSkinFont.get(12);
private static FSkinColor getGroupHeaderForeColor() { private static FSkinColor getGroupHeaderForeColor() {
if (Forge.isMobileAdventureMode) if (Forge.isMobileAdventureMode)
return FSkinColor.get(Colors.ADV_CLR_TEXT); return FSkinColor.get(Colors.ADV_CLR_TEXT);
return FSkinColor.get(Colors.CLR_TEXT); return FSkinColor.get(Colors.CLR_TEXT);
} }
private static FSkinColor getGroupHeaderLineColor() { private static FSkinColor getGroupHeaderLineColor() {
return getGroupHeaderForeColor().alphaColor(0.5f); return getGroupHeaderForeColor().alphaColor(0.5f);
} }
private static final FSkinFont GROUP_HEADER_FONT = LABEL_FONT; private static final FSkinFont GROUP_HEADER_FONT = LABEL_FONT;
private static final float GROUP_HEADER_HEIGHT = Utils.scale(19); private static final float GROUP_HEADER_HEIGHT = Utils.scale(19);
private static final float GROUP_HEADER_GLYPH_WIDTH = Utils.scale(6); private static final float GROUP_HEADER_GLYPH_WIDTH = Utils.scale(6);
@@ -73,7 +76,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private ExpandCollapseButton() { private ExpandCollapseButton() {
super(new FLabel.ButtonBuilder()); super(new FLabel.ButtonBuilder());
setCommand(e -> { setCommand(e -> {
if (groupBy == null || model.getItems().isEmpty()) { return; } if (groupBy == null || model.getItems().isEmpty()) {
return;
}
boolean collapsed = !isAllCollapsed; boolean collapsed = !isAllCollapsed;
for (Group group : groups) { for (Group group : groups) {
@@ -109,8 +114,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
float y = Math.round((h - squareSize) / 2 - offset); float y = Math.round((h - squareSize) / 2 - offset);
if (pressed) { if (pressed) {
y += lineThickness; y += lineThickness;
} } else {
else {
x -= lineThickness; x -= lineThickness;
} }
@@ -132,6 +136,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
} }
} }
private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton(); private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton();
private final FComboBox<Object> cbGroupByOptions = new FComboBox<>(Forge.getLocalizer().getMessage("lblGroups") + " "); private final FComboBox<Object> cbGroupByOptions = new FComboBox<>(Forge.getLocalizer().getMessage("lblGroups") + " ");
private final FComboBox<Object> cbPileByOptions = new FComboBox<>(Forge.getLocalizer().getMessage("lblPiles") + " "); private final FComboBox<Object> cbPileByOptions = new FComboBox<>(Forge.getLocalizer().getMessage("lblPiles") + " ");
@@ -144,16 +149,14 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
cbGroupByOptions.setChangedHandler(e -> { cbGroupByOptions.setChangedHandler(e -> {
if (cbGroupByOptions.getSelectedIndex() > 0) { if (cbGroupByOptions.getSelectedIndex() > 0) {
setGroupBy((GroupDef) cbGroupByOptions.getSelectedItem()); setGroupBy((GroupDef) cbGroupByOptions.getSelectedItem());
} } else {
else {
setGroupBy(null); setGroupBy(null);
} }
}); });
cbPileByOptions.setChangedHandler(e -> { cbPileByOptions.setChangedHandler(e -> {
if (cbPileByOptions.getSelectedIndex() > 0) { if (cbPileByOptions.getSelectedIndex() > 0) {
setPileBy((ColumnDef) cbPileByOptions.getSelectedItem()); setPileBy((ColumnDef) cbPileByOptions.getSelectedItem());
} } else {
else {
setPileBy(null); setPileBy(null);
} }
}); });
@@ -179,17 +182,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public GroupDef getGroupBy() { public GroupDef getGroupBy() {
return groupBy; return groupBy;
} }
public void setGroupBy(GroupDef groupBy0) { public void setGroupBy(GroupDef groupBy0) {
setGroupBy(groupBy0, false); setGroupBy(groupBy0, false);
} }
private void setGroupBy(GroupDef groupBy0, boolean forSetup) { private void setGroupBy(GroupDef groupBy0, boolean forSetup) {
if (groupBy == groupBy0) { return; } if (groupBy == groupBy0) {
return;
}
groupBy = groupBy0; groupBy = groupBy0;
if (groupBy == null) { if (groupBy == null) {
cbGroupByOptions.setSelectedIndex(0); cbGroupByOptions.setSelectedIndex(0);
} } else {
else {
cbGroupByOptions.setSelectedItem(groupBy); cbGroupByOptions.setSelectedItem(groupBy);
} }
@@ -198,8 +204,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
if (groupBy == null) { if (groupBy == null) {
groups.add(new Group("")); groups.add(new Group(""));
btnExpandCollapseAll.updateIsAllCollapsed(); btnExpandCollapseAll.updateIsAllCollapsed();
} } else {
else {
for (String groupName : groupBy.getGroups()) { for (String groupName : groupBy.getGroups()) {
groups.add(new Group(groupName)); groups.add(new Group(groupName));
} }
@@ -228,17 +233,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public ColumnDef getPileBy() { public ColumnDef getPileBy() {
return pileBy; return pileBy;
} }
public void setPileBy(ColumnDef pileBy0) { public void setPileBy(ColumnDef pileBy0) {
setPileBy(pileBy0, false); setPileBy(pileBy0, false);
} }
private void setPileBy(ColumnDef pileBy0, boolean forSetup) { private void setPileBy(ColumnDef pileBy0, boolean forSetup) {
if (pileBy == pileBy0) { return; } if (pileBy == pileBy0) {
return;
}
pileBy = pileBy0; pileBy = pileBy0;
if (pileBy == null) { if (pileBy == null) {
cbPileByOptions.setSelectedIndex(0); cbPileByOptions.setSelectedIndex(0);
} } else {
else {
cbPileByOptions.setSelectedItem(pileBy); cbPileByOptions.setSelectedItem(pileBy);
} }
@@ -263,14 +271,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public void setColumnCount(int columnCount0) { public void setColumnCount(int columnCount0) {
setColumnCount(columnCount0, false); setColumnCount(columnCount0, false);
} }
private void setColumnCount(int columnCount0, boolean forSetup) { private void setColumnCount(int columnCount0, boolean forSetup) {
if (columnCount0 < MIN_COLUMN_COUNT) { if (columnCount0 < MIN_COLUMN_COUNT) {
columnCount0 = MIN_COLUMN_COUNT; columnCount0 = MIN_COLUMN_COUNT;
} } else if (columnCount0 > MAX_COLUMN_COUNT) {
else if (columnCount0 > MAX_COLUMN_COUNT) {
columnCount0 = MAX_COLUMN_COUNT; columnCount0 = MAX_COLUMN_COUNT;
} }
if (columnCount == columnCount0) { return; } if (columnCount == columnCount0) {
return;
}
columnCount = columnCount0; columnCount = columnCount0;
if (!forSetup) { if (!forSetup) {
@@ -342,14 +352,12 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
Group group; Group group;
if (groupIndex >= 0) { if (groupIndex >= 0) {
group = groups.get(groupIndex); group = groups.get(groupIndex);
} } else {
else {
if (otherItems == null) { if (otherItems == null) {
//reuse existing Other group if possible //reuse existing Other group if possible
if (groups.size() > groupBy.getGroups().length) { if (groups.size() > groupBy.getGroups().length) {
otherItems = groups.get(groups.size() - 1); otherItems = groups.get(groups.size() - 1);
} } else {
else {
otherItems = new Group(Forge.getLocalizer().getMessage("lblOther")); otherItems = new Group(Forge.getLocalizer().getMessage("lblOther"));
otherItems.isCollapsed = btnExpandCollapseAll.isAllCollapsed; otherItems.isCollapsed = btnExpandCollapseAll.isAllCollapsed;
groups.add(otherItems); groups.add(otherItems);
@@ -389,7 +397,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
private void updateLayout(boolean forRefresh) { private void updateLayout(boolean forRefresh) {
if (updatingLayout) { return; } //prevent infinite loop if (updatingLayout) {
return;
} //prevent infinite loop
updatingLayout = true; updatingLayout = true;
focalItem = null; //clear cached focalItem when layout changes focalItem = null; //clear cached focalItem when layout changes
@@ -471,8 +481,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
y += itemHeight; y += itemHeight;
group.scrollWidth = groupWidth; group.scrollWidth = groupWidth;
} } else {
else {
x = 0; x = 0;
pileY = y; pileY = y;
maxPileHeight = 0; maxPileHeight = 0;
@@ -505,7 +514,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
int index = 0; int index = 0;
orderedItems.clear(); orderedItems.clear();
for (Group group : groups) { for (Group group : groups) {
if (group.isCollapsed || group.items.isEmpty()) { continue; } if (group.isCollapsed || group.items.isEmpty()) {
continue;
}
for (Pile pile : group.piles) { for (Pile pile : group.piles) {
for (ItemInfo itemInfo : pile.items) { for (ItemInfo itemInfo : pile.items) {
@@ -558,8 +569,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private ItemInfo getItemAtPoint(float x, float y) { private ItemInfo getItemAtPoint(float x, float y) {
//check selected items first since they appear on top //check selected items first since they appear on top
for (int i = selectedIndices.size() - 1; i >= 0; i--) { for (int i = selectedIndices.size() - 1; i >= 0; i--) {
int currentIndex=selectedIndices.get(i); int currentIndex = selectedIndices.get(i);
if(currentIndex<0||orderedItems.size()<=currentIndex) if (currentIndex < 0 || orderedItems.size() <= currentIndex)
continue; continue;
ItemInfo item = orderedItems.get(currentIndex); ItemInfo item = orderedItems.get(currentIndex);
float relX = x + item.group.getScrollLeft() - item.group.getLeft(); float relX = x + item.group.getScrollLeft() - item.group.getLeft();
@@ -715,7 +726,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
if (item.selected) { //unselect item if already selected if (item.selected) { //unselect item if already selected
if (selectedIndices.size() > minSelections) { if (selectedIndices.size() > minSelections) {
item.selected = false; item.selected = false;
selectedIndices.remove((Object)item.index); selectedIndices.remove((Object) item.index);
onSelectionChange(); onSelectionChange();
item.group.scrollIntoView(item); item.group.scrollIntoView(item);
} }
@@ -736,9 +747,13 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
public void scrollSelectionIntoView() { public void scrollSelectionIntoView() {
if (selectedIndices.isEmpty()) { return; } if (selectedIndices.isEmpty()) {
int index=selectedIndices.get(0); return;
if(index<0||orderedItems.size()<=index) { return ; } }
int index = selectedIndices.get(0);
if (index < 0 || orderedItems.size() <= index) {
return;
}
ItemInfo itemInfo = orderedItems.get(index); ItemInfo itemInfo = orderedItems.get(index);
getScroller().scrollIntoView(itemInfo); getScroller().scrollIntoView(itemInfo);
@@ -746,10 +761,14 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
public Rectangle getSelectionBounds() { public Rectangle getSelectionBounds() {
if (selectedIndices.isEmpty()) { return new Rectangle(); } if (selectedIndices.isEmpty()) {
return new Rectangle();
}
int index=selectedIndices.get(0); int index = selectedIndices.get(0);
if(index<0||orderedItems.size()<=index) { return new Rectangle(); } if (index < 0 || orderedItems.size() <= index) {
return new Rectangle();
}
ItemInfo itemInfo = orderedItems.get(index); ItemInfo itemInfo = orderedItems.get(index);
Vector2 relPos = itemInfo.group.getChildRelativePosition(itemInfo); Vector2 relPos = itemInfo.group.getChildRelativePosition(itemInfo);
return new Rectangle(itemInfo.group.screenPos.x + relPos.x - SEL_BORDER_SIZE + itemInfo.group.getLeft(), return new Rectangle(itemInfo.group.screenPos.x + relPos.x - SEL_BORDER_SIZE + itemInfo.group.getLeft(),
@@ -759,15 +778,19 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
public void zoomSelected() { public void zoomSelected() {
if (selectedIndices.isEmpty()) { return; } if (selectedIndices.isEmpty()) {
int index=selectedIndices.get(0); return;
if(index<0||orderedItems.size()<=index) { return ; } }
int index = selectedIndices.get(0);
if (index < 0 || orderedItems.size() <= index) {
return;
}
ItemInfo itemInfo = orderedItems.get(index); ItemInfo itemInfo = orderedItems.get(index);
if (itemInfo != null) { if (itemInfo != null) {
if(itemInfo.getKey() instanceof CardThemedDeckGenerator || itemInfo.getKey() instanceof CommanderDeckGenerator if (itemInfo.getKey() instanceof CardThemedDeckGenerator || itemInfo.getKey() instanceof CommanderDeckGenerator
|| itemInfo.getKey() instanceof ArchetypeDeckGenerator || itemInfo.getKey() instanceof DeckProxy){ || itemInfo.getKey() instanceof ArchetypeDeckGenerator || itemInfo.getKey() instanceof DeckProxy) {
FDeckViewer.show(((DeckProxy)itemInfo.getKey()).getDeck()); FDeckViewer.show(((DeckProxy) itemInfo.getKey()).getDeck());
} }
CardZoom.show(orderedItems, orderedItems.indexOf(itemInfo), itemManager); CardZoom.show(orderedItems, orderedItems.indexOf(itemInfo), itemManager);
} }
@@ -795,7 +818,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
if (items.isEmpty()) { return; } if (items.isEmpty()) {
return;
}
if (groupBy != null) { if (groupBy != null) {
//draw group name and horizontal line //draw group name and horizontal line
@@ -816,15 +841,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
x, y - offset, x, y - offset,
x + offset, y, x + offset, y,
x, y + offset); x, y + offset);
} } else {
else {
g.fillTriangle(getGroupHeaderLineColor(), g.fillTriangle(getGroupHeaderLineColor(),
x - offset + 2, y + offset - 1, x - offset + 2, y + offset - 1,
x + offset, y + offset - 1, x + offset, y + offset - 1,
x + offset, y - offset + 1); x + offset, y - offset + 1);
} }
if (isCollapsed) { return; } if (isCollapsed) {
return;
}
float visibleLeft = getScrollLeft(); float visibleLeft = getScrollLeft();
float visibleRight = visibleLeft + getWidth(); float visibleRight = visibleLeft + getWidth();
@@ -862,8 +888,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public boolean tap(float x, float y, int count) { public boolean tap(float x, float y, int count) {
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop()); ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
if (item != null) { if (item != null) {
if(item.getKey() instanceof DeckProxy) { if (item.getKey() instanceof DeckProxy) {
DeckProxy dp = (DeckProxy)item.getKey(); DeckProxy dp = (DeckProxy) item.getKey();
if (count >= 2 && !dp.isGeneratedDeck()) { if (count >= 2 && !dp.isGeneratedDeck()) {
//double tap to add to favorites or remove.... //double tap to add to favorites or remove....
if (DeckPreferences.getPrefs(dp).getStarCount() > 0) if (DeckPreferences.getPrefs(dp).getStarCount() > 0)
@@ -889,9 +915,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public boolean longPress(float x, float y) { public boolean longPress(float x, float y) {
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop()); ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
if (item != null) { if (item != null) {
if(item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator if (item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator
|| item.getKey() instanceof ArchetypeDeckGenerator || item.getKey() instanceof DeckProxy){ || item.getKey() instanceof ArchetypeDeckGenerator || item.getKey() instanceof DeckProxy) {
FDeckViewer.show(((DeckProxy)item.getKey()).getDeck()); FDeckViewer.show(((DeckProxy) item.getKey()).getDeck());
return true; return true;
} }
CardZoom.show(orderedItems, orderedItems.indexOf(item), itemManager); CardZoom.show(orderedItems, orderedItems.indexOf(item), itemManager);
@@ -906,6 +932,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
return new Vector2(child.getLeft() - getScrollLeft() + offsetX - getLeft(), child.getTop() - getScrollValue() + offsetY - getTop()); return new Vector2(child.getLeft() - getScrollLeft() + offsetX - getLeft(), child.getTop() - getScrollValue() + offsetY - getTop());
} }
} }
private class Pile extends FDisplayObject { private class Pile extends FDisplayObject {
private final List<ItemInfo> items = new ArrayList<>(); private final List<ItemInfo> items = new ArrayList<>();
@@ -924,8 +951,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
if (itemInfo.selected) { if (itemInfo.selected) {
skippedItem = itemInfo; skippedItem = itemInfo;
} } else {
else {
itemInfo.draw(g); itemInfo.draw(g);
} }
} }
@@ -937,6 +963,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
} }
} }
private class ItemInfo extends FDisplayObject implements Entry<InventoryItem, Integer> { private class ItemInfo extends FDisplayObject implements Entry<InventoryItem, Integer> {
private final T item; private final T item;
private final Group group; private final Group group;
@@ -990,8 +1017,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE, (h - w) / 10); g.fillRoundRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE, (h - w) / 10);
//drawroundrect has GL_SMOOTH to `smoothen/faux` the aliased corner //drawroundrect has GL_SMOOTH to `smoothen/faux` the aliased corner
g.drawRoundRect(1f, Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 1.5f * SEL_BORDER_SIZE, h + 1.5f * SEL_BORDER_SIZE, (h - w) / 10); g.drawRoundRect(1f, Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 1.5f * SEL_BORDER_SIZE, h + 1.5f * SEL_BORDER_SIZE, (h - w) / 10);
} } else //default rectangle highlight
else //default rectangle highlight
g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE); g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE);
} }
} }
@@ -1001,22 +1027,22 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
if (itemManager.getShowRanking() && FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_OVERLAY_DRAFT_RANKING)) { if (itemManager.getShowRanking() && FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_OVERLAY_DRAFT_RANKING)) {
double score = CardRanker.getRawScore((PaperCard) item); double score = CardRanker.getRawScore((PaperCard) item);
int draftRank = score <= 0 ? 0 : score > 99 ? 99 : (int) Math.round(CardRanker.getRawScore((PaperCard) item)); int draftRank = score <= 0 ? 0 : score > 99 ? 99 : (int) Math.round(CardRanker.getRawScore((PaperCard) item));
float rankSize = w/2; float rankSize = w / 2;
float y2 = y+(rankSize-(rankSize*0.1f)); float y2 = y + (rankSize - (rankSize * 0.1f));
float x2 = x+rankSize/2; float x2 = x + rankSize / 2;
if (draftRank >= 90) { if (draftRank >= 90) {
g.drawImage(FSkinImage.DRAFTRANK_S, x2, y2+1, rankSize, rankSize); g.drawImage(FSkinImage.DRAFTRANK_S, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 80 && draftRank <= 89 ) { } else if (draftRank >= 80 && draftRank <= 89) {
g.drawImage(FSkinImage.DRAFTRANK_A, x2, y2+1, rankSize, rankSize); g.drawImage(FSkinImage.DRAFTRANK_A, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 60 && draftRank <= 79 ) { } else if (draftRank >= 60 && draftRank <= 79) {
g.drawImage(FSkinImage.DRAFTRANK_B, x2, y2+1, rankSize, rankSize); g.drawImage(FSkinImage.DRAFTRANK_B, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 25 && draftRank <= 59 ) { } else if (draftRank >= 25 && draftRank <= 59) {
g.drawImage(FSkinImage.DRAFTRANK_C, x2, y2+1, rankSize, rankSize); g.drawImage(FSkinImage.DRAFTRANK_C, x2, y2 + 1, rankSize, rankSize);
} else { } else {
g.drawImage(FSkinImage.DRAFTRANK_D, x2, y2+1, rankSize, rankSize); g.drawImage(FSkinImage.DRAFTRANK_D, x2, y2 + 1, rankSize, rankSize);
} }
String value = String.valueOf(draftRank); String value = String.valueOf(draftRank);
g.drawText(value, FSkinFont.forHeight(rankSize/4), Color.WHITE, x, y, w, h, true, Align.center, true); g.drawText(value, FSkinFont.forHeight(rankSize / 4), Color.WHITE, x, y, w, h, true, Align.center, true);
} }
} else if (item instanceof ConquestCommander) { } else if (item instanceof ConquestCommander) {
CardRenderer.drawCard(g, ((ConquestCommander) item).getCard(), x, y, w, h, pos); CardRenderer.drawCard(g, ((ConquestCommander) item).getCard(), x, y, w, h, pos);
@@ -1026,7 +1052,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
float scale = 0.75f; float scale = 0.75f;
if (dpImg != null) {//generated decks have missing info... if (dpImg != null) {//generated decks have missing info...
if (Forge.enableUIMask.equals("Off")){ if (Forge.enableUIMask.equals("Off")) {
if (selected) if (selected)
g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE); g.fillRect(Color.GREEN, x - SEL_BORDER_SIZE, y - SEL_BORDER_SIZE, w + 2 * SEL_BORDER_SIZE, h + 2 * SEL_BORDER_SIZE);
g.drawImage(dpImg, x, y, w, h); g.drawImage(dpImg, x, y, w, h);
@@ -1049,28 +1075,28 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
} }
} }
//fake labelname shadow //fake labelname shadow
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.BLACK, (x + PADDING)-1f, (y + PADDING*2)+1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false); g.drawText(item.getName(), GROUP_HEADER_FONT, Color.BLACK, (x + PADDING) - 1f, (y + PADDING * 2) + 1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
//labelname //labelname
g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING*2, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false); g.drawText(item.getName(), GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + PADDING * 2, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, false);
} else { } else {
if (!dp.isGeneratedDeck()) { if (!dp.isGeneratedDeck()) {
if (dp.getDeck().isEmpty()) { if (dp.getDeck().isEmpty()) {
g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y-(h*0.25f), w, h, Color.RED, selected); g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y - (h * 0.25f), w, h, Color.RED, selected);
} else { } else {
//If deck has Commander, use it as cardArt reference //If deck has Commander, use it as cardArt reference
PaperCard paperCard = dp.getDeck().getCommanders().isEmpty() ? dp.getHighestCMCCard() : dp.getDeck().getCommanders().get(0); PaperCard paperCard = dp.getDeck().getCommanders().isEmpty() ? dp.getHighestCMCCard() : dp.getDeck().getCommanders().get(0);
FImageComplex cardArt = CardRenderer.getCardArt(paperCard); FImageComplex cardArt = CardRenderer.getCardArt(paperCard);
//draw the deckbox //draw the deckbox
if (cardArt == null){ if (cardArt == null) {
//draw generic box if null or still loading //draw generic box if null or still loading
g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y-(h*0.25f), w, h, Color.GREEN, selected); g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y - (h * 0.25f), w, h, Color.GREEN, selected);
} else { } else {
g.drawDeckBox(cardArt, scale, FSkin.getDeckbox().get(1), FSkin.getDeckbox().get(2), x, y, w, h, Color.GREEN, selected); g.drawDeckBox(cardArt, scale, FSkin.getDeckbox().get(1), FSkin.getDeckbox().get(2), x, y, w, h, Color.GREEN, selected);
} }
} }
} else { } else {
//generic box //generic box
g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y-(h*0.25f), w, h, Color.GREEN, selected); g.drawImage(FSkin.getDeckbox().get(2), FSkin.getDeckbox().get(2), x, y - (h * 0.25f), w, h, Color.GREEN, selected);
} }
if (deckColor != null) { if (deckColor != null) {
//deck color identity //deck color identity
@@ -1089,8 +1115,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
symbolSize = IMAGE_SIZE * (0.5f); symbolSize = IMAGE_SIZE * (0.5f);
} }
//vertical mana icons //vertical mana icons
CardFaceSymbols.drawColorSet(g, deckColor, x +(w-symbolSize), y+(h/8), symbolSize, true); CardFaceSymbols.drawColorSet(g, deckColor, x + (w - symbolSize), y + (h / 8), symbolSize, true);
if(!dp.isGeneratedDeck()) { if (!dp.isGeneratedDeck()) {
if (dp.getDeck().isEmpty()) { if (dp.getDeck().isEmpty()) {
g.drawImage(Forge.hdbuttons ? FSkinImage.HDYIELD : FSkinImage.WARNING, x, y, symbolSize, symbolSize); g.drawImage(Forge.hdbuttons ? FSkinImage.HDYIELD : FSkinImage.WARNING, x, y, symbolSize, symbolSize);
} else { } else {
@@ -1099,15 +1125,15 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
else else
g.drawImage(DeckPreferences.getPrefs(dp).getStarCount() > 0 ? FSkinImage.STAR_FILLED : FSkinImage.STAR_OUTLINE, x, y, symbolSize, symbolSize); g.drawImage(DeckPreferences.getPrefs(dp).getStarCount() > 0 ? FSkinImage.STAR_FILLED : FSkinImage.STAR_OUTLINE, x, y, symbolSize, symbolSize);
//AI Icon //AI Icon
g.drawImage(dp.getAI().inMainDeck == 0 ? FSkinImage.AI_ACTIVE : FSkinImage.AI_INACTIVE, x, y+symbolSize, symbolSize, symbolSize); g.drawImage(dp.getAI().inMainDeck == 0 ? FSkinImage.AI_ACTIVE : FSkinImage.AI_INACTIVE, x, y + symbolSize, symbolSize, symbolSize);
} }
} }
} }
String deckname = TextUtil.fastReplace(item.getName(),"] #", "]\n#"); String deckname = TextUtil.fastReplace(item.getName(), "] #", "]\n#");
//deckname fakeshadow //deckname fakeshadow
g.drawText(deckname, GROUP_HEADER_FONT, Color.BLACK, (x + PADDING)-1f, (y + (h/10) + PADDING)+1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true); g.drawText(deckname, GROUP_HEADER_FONT, Color.BLACK, (x + PADDING) - 1f, (y + (h / 10) + PADDING) + 1f, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true);
//deck name //deck name
g.drawText(deckname, GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + (h/10) + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true); g.drawText(deckname, GROUP_HEADER_FONT, Color.WHITE, x + PADDING, y + (h / 10) + PADDING, w - 2 * PADDING, h - 2 * PADDING, true, Align.center, true);
} }
} else { } else {
Texture img = ImageCache.getImage(item); Texture img = ImageCache.getImage(item);

View File

@@ -32,6 +32,7 @@ public class FCardPanel extends FDisplayObject {
public FCardPanel() { public FCardPanel() {
this(null); this(null);
} }
public FCardPanel(CardView card0) { public FCardPanel(CardView card0) {
card = card0; card = card0;
tapAnimation = new CardTapAnimation(); tapAnimation = new CardTapAnimation();
@@ -43,6 +44,7 @@ public class FCardPanel extends FDisplayObject {
public CardView getCard() { public CardView getCard() {
return card; return card;
} }
public void setCard(CardView card0) { public void setCard(CardView card0) {
card = card0; card = card0;
} }
@@ -50,6 +52,7 @@ public class FCardPanel extends FDisplayObject {
public boolean isHighlighted() { public boolean isHighlighted() {
return highlighted; return highlighted;
} }
public void setHighlighted(boolean highlighted0) { public void setHighlighted(boolean highlighted0) {
highlighted = highlighted0; highlighted = highlighted0;
} }
@@ -57,6 +60,7 @@ public class FCardPanel extends FDisplayObject {
public boolean isTapped() { public boolean isTapped() {
return tapped; return tapped;
} }
public void setTapped(final boolean tapped0) { public void setTapped(final boolean tapped0) {
tapped = tapped0; tapped = tapped0;
} }
@@ -95,14 +99,16 @@ public class FCardPanel extends FDisplayObject {
@Override @Override
public void draw(Graphics g) { public void draw(Graphics g) {
if (card == null) { return; } if (card == null) {
return;
}
boolean animate = Forge.animatedCardTapUntap; boolean animate = Forge.animatedCardTapUntap;
float mod = (isHighlighted()||isHovered()) && !Forge.hasGamepad() ? getWidth()/16f : 0f; float mod = (isHighlighted() || isHovered()) && !Forge.hasGamepad() ? getWidth() / 16f : 0f;
float padding = getPadding(); float padding = getPadding();
float x = padding-mod/2; float x = padding - mod / 2;
float y = padding-mod/2; float y = padding - mod / 2;
float w = (getWidth() - 2 * padding)+mod; float w = (getWidth() - 2 * padding) + mod;
float h = (getHeight() - 2 * padding)+mod; float h = (getHeight() - 2 * padding) + mod;
if (w == h) { //adjust width if needed to make room for tapping if (w == h) { //adjust width if needed to make room for tapping
w = h / ASPECT_RATIO; w = h / ASPECT_RATIO;
} }
@@ -152,6 +158,7 @@ public class FCardPanel extends FDisplayObject {
} }
} }
} }
private void rotateTransform(Graphics g, float x, float y, float w, float h, float edgeOffset, boolean animate) { private void rotateTransform(Graphics g, float x, float y, float w, float h, float edgeOffset, boolean animate) {
if (tapped) { if (tapped) {
g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, getTappedAngle()); g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, getTappedAngle());
@@ -168,10 +175,12 @@ public class FCardPanel extends FDisplayObject {
g.endTransform(); g.endTransform();
} }
} }
private class CardDestroyedAnimation extends ForgeAnimation { private class CardDestroyedAnimation extends ForgeAnimation {
private static final float DURATION = 0.6f; private static final float DURATION = 0.6f;
private float progress = 0; private float progress = 0;
private Texture splatter = FSkin.splatter; private Texture splatter = FSkin.splatter;
private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset) { private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset) {
float percentage = progress / DURATION; float percentage = progress / DURATION;
if (percentage < 0) { if (percentage < 0) {
@@ -180,30 +189,33 @@ public class FCardPanel extends FDisplayObject {
percentage = 1; percentage = 1;
progress = 0; progress = 0;
} }
float mod = w*percentage; float mod = w * percentage;
float oldAlpha = g.getfloatAlphaComposite(); float oldAlpha = g.getfloatAlphaComposite();
if (tapped) { if (tapped) {
g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, getTappedAngle()); g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, getTappedAngle());
} }
CardRenderer.drawCardWithOverlays(g, card, x-mod/2, y-mod/2, w+mod, h+mod, getStackPosition()); CardRenderer.drawCardWithOverlays(g, card, x - mod / 2, y - mod / 2, w + mod, h + mod, getStackPosition());
if (splatter != null) { if (splatter != null) {
g.setAlphaComposite(0.6f); g.setAlphaComposite(0.6f);
g.drawCardImage(splatter, null,x-mod/2, y-mod/2, w+mod, h+mod, true, false); g.drawCardImage(splatter, null, x - mod / 2, y - mod / 2, w + mod, h + mod, true, false);
g.setAlphaComposite(oldAlpha); g.setAlphaComposite(oldAlpha);
} }
if (tapped) { if (tapped) {
g.endTransform(); g.endTransform();
} }
} }
@Override @Override
protected boolean advance(float dt) { protected boolean advance(float dt) {
progress += dt; progress += dt;
return progress < DURATION; return progress < DURATION;
} }
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
} }
} }
private class CardTransformAnimation extends ForgeAnimation { private class CardTransformAnimation extends ForgeAnimation {
private float DURATION = 0.18f; private float DURATION = 0.18f;
private float progress = 0; private float progress = 0;
@@ -217,11 +229,11 @@ public class FCardPanel extends FDisplayObject {
progress = 0; progress = 0;
} }
float mod = percentage; float mod = percentage;
float y2 = y + (h - (h*mod))/2; float y2 = y + (h - (h * mod)) / 2;
float x2 = x + (w - (w*mod))/2; float x2 = x + (w - (w * mod)) / 2;
float w2 = w*mod; float w2 = w * mod;
float h2 = h*mod; float h2 = h * mod;
float gap = (h/2) - (percentage*(h/2)); float gap = (h / 2) - (percentage * (h / 2));
if (card.getCurrentState().getState() == CardStateName.Original) { if (card.getCurrentState().getState() == CardStateName.Original) {
DURATION = 0.16f; DURATION = 0.16f;
//rollback //rollback
@@ -239,26 +251,30 @@ public class FCardPanel extends FDisplayObject {
//Meld Animation merging //Meld Animation merging
DURATION = 0.25f; DURATION = 0.25f;
//top card //top card
g.drawImage(CardRenderer.getMeldCardParts(card.getCurrentState().getImageKey(), false), x, y-gap, w, h/2); g.drawImage(CardRenderer.getMeldCardParts(card.getCurrentState().getImageKey(), false), x, y - gap, w, h / 2);
//bottom card //bottom card
g.drawImage(CardRenderer.getMeldCardParts(card.getCurrentState().getImageKey(), true), x, y+h/2+gap, w, h/2); g.drawImage(CardRenderer.getMeldCardParts(card.getCurrentState().getImageKey(), true), x, y + h / 2 + gap, w, h / 2);
} }
} }
} }
} }
@Override @Override
protected boolean advance(float dt) { protected boolean advance(float dt) {
progress += dt; progress += dt;
return progress < DURATION; return progress < DURATION;
} }
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
card.updateNeedsTransformAnimation(false); card.updateNeedsTransformAnimation(false);
} }
} }
private class CardUnTapAnimation extends ForgeAnimation { private class CardUnTapAnimation extends ForgeAnimation {
private static final float DURATION = 0.18f; private static final float DURATION = 0.18f;
private float progress = 0; private float progress = 0;
private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset) { private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset) {
float percentage = progress / DURATION; float percentage = progress / DURATION;
if (percentage < 0) { if (percentage < 0) {
@@ -267,24 +283,28 @@ public class FCardPanel extends FDisplayObject {
percentage = 1; percentage = 1;
progress = 0; progress = 0;
} }
float angle = -90 + (percentage*90); float angle = -90 + (percentage * 90);
g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, angle); g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, angle);
CardRenderer.drawCardWithOverlays(g, card, x, y, w, h, getStackPosition()); CardRenderer.drawCardWithOverlays(g, card, x, y, w, h, getStackPosition());
g.endTransform(); g.endTransform();
} }
@Override @Override
protected boolean advance(float dt) { protected boolean advance(float dt) {
progress += dt; progress += dt;
return progress < DURATION; return progress < DURATION;
} }
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
card.updateNeedsUntapAnimation(false); card.updateNeedsUntapAnimation(false);
} }
} }
private class CardTapAnimation extends ForgeAnimation { private class CardTapAnimation extends ForgeAnimation {
private static final float DURATION = 0.18f; private static final float DURATION = 0.18f;
private float progress = 0; private float progress = 0;
private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset, float angle) { private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset, float angle) {
float percentage = progress / DURATION; float percentage = progress / DURATION;
if (percentage < 0) { if (percentage < 0) {
@@ -293,20 +313,23 @@ public class FCardPanel extends FDisplayObject {
percentage = 1; percentage = 1;
progress = 0; progress = 0;
} }
g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, percentage*angle); g.startRotateTransform(x + edgeOffset, y + h - edgeOffset, percentage * angle);
CardRenderer.drawCardWithOverlays(g, card, x, y, w, h, getStackPosition()); CardRenderer.drawCardWithOverlays(g, card, x, y, w, h, getStackPosition());
g.endTransform(); g.endTransform();
} }
@Override @Override
protected boolean advance(float dt) { protected boolean advance(float dt) {
progress += dt; progress += dt;
return progress < DURATION; return progress < DURATION;
} }
@Override @Override
protected void onEnd(boolean endingAll) { protected void onEnd(boolean endingAll) {
card.updateNeedsTapAnimation(false); card.updateNeedsTapAnimation(false);
} }
} }
public String toString() { public String toString() {
return card == null ? "" : card.toString(); return card == null ? "" : card.toString();
} }