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.FSkinColor;
import forge.assets.FSkinFont;
import forge.assets.ImageCache;
import forge.toolbox.FDisplayObject;
import forge.util.TextBounds;
import forge.util.Utils;
@@ -49,6 +50,7 @@ public class Graphics {
private final ShaderProgram shaderPixelateWarp = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragPixelateShaderWarp);
private final ShaderProgram shaderChromaticAbberation = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragChromaticAbberation);
private final ShaderProgram shaderHueShift = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragHueShift);
private final ShaderProgram shaderRoundedRect = new ShaderProgram(Shaders.vertPixelateShader, Shaders.fragRoundedRect);
private Texture dummyTexture = null;
@@ -64,6 +66,10 @@ public class Graphics {
return shaderGrayscale;
}
public ShaderProgram getShaderRoundedRect() {
return shaderRoundedRect;
}
public ShaderProgram getShaderWarp() {
return shaderWarp;
}
@@ -879,6 +885,44 @@ public class Graphics {
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) {
if (image == null)
return;
@@ -1287,6 +1331,7 @@ public class Graphics {
bitmapFont.setColor(color.r, color.g, color.b, alpha);
bitmapFont.draw(batch, text, x, y);
}
public void drawText(BitmapFont bitmapFont, GlyphLayout layout, float x, float y) {
if (bitmapFont == null || layout == null)
return;

View File

@@ -42,6 +42,42 @@ public class Shaders {
" v_texCoords = a_texCoord0;\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" +
"#define LOWP lowp\n" +
"precision mediump float;\n" +

View File

@@ -1,6 +1,8 @@
package forge.adventure.scene;
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.InputEvent;
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("detail",()->RewardScene.this.toggleToolTip());
detailButton = ui.findActor("detail");
if (Forge.getDeviceAdapter().getGamepads().isEmpty())
detailButton.setVisible(false);
detailButton.setVisible(false);
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() {
Selectable selectable=getSelected();
@@ -159,6 +176,13 @@ public class RewardScene extends UIScene {
}
}
}
@Override
public void enter() {
updateDetailButton();
super.enter();
}
private void showLootOrDone() {
boolean exit = true;
for (Actor actor : new Array.ArrayIterator<>(generated)) {

View File

@@ -17,51 +17,51 @@ public abstract class Scene implements Disposable {
@Override
public void connected(Controller controller) {
Forge.getCurrentScene().connected(controller);
}
@Override
public void disconnected(Controller controller) {
Forge.getCurrentScene().disconnected(controller);
}
@Override
public boolean buttonDown(Controller controller, int i) {
return Forge.getCurrentScene().buttonDown(controller,i);
return Forge.getCurrentScene().buttonDown(controller, i);
}
@Override
public boolean buttonUp(Controller controller, int i) {
return Forge.getCurrentScene().buttonUp(controller,i);
return Forge.getCurrentScene().buttonUp(controller, i);
}
@Override
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() {
if(listener==null)
{
listener=new SceneControllerListener();
if (listener == null) {
listener = new SceneControllerListener();
Controllers.addListener(listener);
}
}
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() {
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 render();
public boolean leave() {
public abstract void render();
public boolean leave() {
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.utils.Align;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.Scaling;
import com.github.tommyettinger.textra.TextraButton;
import forge.Forge;
import forge.Graphics;
@@ -54,6 +55,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
HoldTooltip holdTooltip;
Reward reward;
ShaderProgram shaderGrayscale = Forge.getGraphics().getShaderGrayscale();
ShaderProgram shaderRoundRect = Forge.getGraphics().getShaderRoundedRect();
final int preview_w = 488; //Width and height for generated images.
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.
static final ImageFetcher fetcher = GuiBase.getInterface().getImageFetcher();
Image toolTipImage;
RewardImage toolTipImage;
@Override
public void dispose() {
@@ -124,7 +126,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
((TextureRegionDrawable) toolTipImage.getDrawable()).getRegion().getTexture().dispose();
}
toolTipImage.remove();
toolTipImage = new Image(processDrawable(image));
toolTipImage = new RewardImage(processDrawable(image));
if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip.tooltip_image.getDrawable() instanceof TextureRegionDrawable) {
((TextureRegionDrawable) holdTooltip.tooltip_image.getDrawable()).getRegion().getTexture().dispose();
@@ -328,12 +330,12 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (alternate) {
if (alt != null) {
holdTooltip.tooltip_actor.clear();
holdTooltip.tooltip_actor.add(new Image(processDrawable(alt)));
holdTooltip.tooltip_actor.add(new RewardImage(processDrawable(alt)));
} else {
if (T == null)
T = renderPlaceholder(getGraphics(), altCard);
holdTooltip.tooltip_actor.clear();
holdTooltip.tooltip_actor.add(new Image(processDrawable(T)));
holdTooltip.tooltip_actor.add(new RewardImage(processDrawable(T)));
}
} else {
if (toolTipImage != null) {
@@ -345,11 +347,11 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (hover) {
if (alternate) {
if (alt != null) {
tooltip.setActor(new Image(processDrawable(alt)));
tooltip.setActor(new RewardImage(processDrawable(alt)));
} else {
if (T == null)
T = renderPlaceholder(getGraphics(), altCard);
tooltip.setActor(new Image(processDrawable(T)));
tooltip.setActor(new RewardImage(processDrawable(T)));
}
} else {
if (toolTipImage != null)
@@ -414,7 +416,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (Forge.isTextureFilteringEnabled())
image.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.Linear);
if (toolTipImage == null)
toolTipImage = new Image(processDrawable(image));
toolTipImage = new RewardImage(processDrawable(image));
if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip == null)
holdTooltip = new HoldTooltip(toolTipImage);
@@ -502,7 +504,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
//Rendering code ends here.
if (toolTipImage == null)
toolTipImage = new Image(processDrawable(generatedTooltip));
toolTipImage = new RewardImage(processDrawable(generatedTooltip));
if (GuiBase.isAndroid() || Forge.hasGamepad()) {
if (holdTooltip == null)
@@ -631,21 +633,37 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
private void drawCard(Batch batch, Texture image, float x, float width) {
if (image != null) {
if (!sold)
batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
else {
if (image.toString().contains(".fullborder.") && Forge.enableUIMask.equals("Full")) {
batch.end();
shaderGrayscale.bind();
shaderGrayscale.setUniformf("u_grayness", 1f);
shaderGrayscale.setUniformf("u_bias", 0.7f);
batch.setShader(shaderGrayscale);
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 gray
batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
//draw rounded
batch.draw(image, x, -getHeight() / 2, width, getHeight());
//reset
batch.end();
batch.setShader(null);
batch.begin();
} else {
if (!sold)
batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
else {
batch.end();
shaderGrayscale.bind();
shaderGrayscale.setUniformf("u_grayness", 1f);
shaderGrayscale.setUniformf("u_bias", 0.7f);
batch.setShader(shaderGrayscale);
batch.begin();
//draw gray
batch.draw(ImageCache.croppedBorderImage(image), x, -getHeight() / 2, width, getHeight());
//reset
batch.end();
batch.setShader(null);
batch.begin();
}
}
}
}
@@ -725,18 +743,20 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
}
class HoldTooltip extends ActorGestureListener {
Image tooltip_image;
RewardImage tooltip_image;
Table tooltip_actor;
float height;
TextraButton switchButton;
//Vector2 tmp = new Vector2();
public HoldTooltip(Image tooltip_image) {
public HoldTooltip(RewardImage tooltip_image) {
this.tooltip_image = tooltip_image;
tooltip_actor = new Table();
tooltip_actor.add(this.tooltip_image);
tooltip_actor.align(Align.center);
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();
switchButton = Controls.newTextButton("Flip");
switchButton.addListener(new ClickListener() {
@@ -760,17 +780,6 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
if (reward.getCard().hasBackFace())
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);
return super.longPress(actor, x, y);
@@ -807,4 +816,58 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
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 Set<String> cardsLoaded;
static Queue<String> syncQ;
public static void initCache(int capacity) {
//override maxCardCapacity
maxCardCapacity = capacity;
@@ -90,17 +91,17 @@ public class ImageCache {
//init syncQ for threadsafe use
syncQ = Queues.synchronizedQueue(q);
//cap
int cl = GuiBase.isAndroid() ? maxCardCapacity+(capacity/3) : 400;
int cl = GuiBase.isAndroid() ? maxCardCapacity + (capacity / 3) : 400;
cardsLoaded = new HashSet<>(cl);
}
public static Texture 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;
public static void allowSingleLoad() {
imageLoaded = false; //reset at the beginning of each render
delayLoadRequested = false;
@@ -110,10 +111,12 @@ public class ImageCache {
missingIconKeys.clear();
ImageKeys.clearMissingCards();
}
public static void clearGeneratedCards() {
Forge.getAssets().generatedCards().clear();
}
public static void disposeTextures(){
public static void disposeTextures() {
CardRenderer.clearcardArtCache();
//unload all cardsLoaded
for (String fileName : cardsLoaded) {
@@ -122,8 +125,9 @@ public class ImageCache {
}
}
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
*/
@@ -132,14 +136,14 @@ public class ImageCache {
return;
syncQ.add(file.getPath());
cardsLoaded.add(file.getPath());
counter+=count;
counter += count;
}
public static Texture getImage(InventoryItem ii) {
boolean useDefault = ii instanceof DeckProxy;
String imageKey = ii.getImageKey(false);
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), true, true);
@@ -209,6 +213,7 @@ public class ImageCache {
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound) {
return getImage(imageKey, useDefaultIfNotFound, false);
}
public static Texture getImage(String imageKey, boolean useDefaultIfNotFound, boolean others) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return null;
@@ -239,7 +244,9 @@ public class ImageCache {
// Load from file and add to cache if not found in cache initially.
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 (!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
image fetcher to update automatically after the card image/s are downloaded*/
imageLoaded = false;
if (image != null && imageBorder.get(image.toString()) == null)
imageBorder.put(image.toString(), Pair.of(Color.valueOf("#171717").toString(), false)); //black border
if (image != null && imageRecord.get(image.toString()) == null)
imageRecord.put(image.toString(), new ImageRecord(Color.valueOf("#171717").toString(), false, getRadius(image))); //black border
}
}
return image;
}
static Texture getAsset(String imageKey, File file, boolean others) {
if (file == null)
return null;
if (!others && Forge.enableUIMask.equals("Full") && isBorderless(imageKey))
return Forge.getAssets().generatedCards().get(imageKey);
/*if (!others && Forge.enableUIMask.equals("Full") && isBorderless(imageKey))
return Forge.getAssets().generatedCards().get(imageKey);*/
return Forge.getAssets().manager().get(file.getPath(), Texture.class, false);
}
static Texture loadAsset(String imageKey, File file, boolean others) {
if (file == null)
return null;
@@ -300,7 +309,7 @@ public class ImageCache {
counter += 1;
}
} catch (Exception e) {
System.err.println("Failed to load image: "+fileName);
System.err.println("Failed to load image: " + fileName);
}
//return loaded assets
@@ -309,17 +318,28 @@ public class ImageCache {
} else {
Texture cardTexture = Forge.getAssets().manager().get(fileName, Texture.class, false);
//if full bordermasking is enabled, update the border color
if (cardTexture != null && Forge.enableUIMask.equals("Full")) {
if (cardTexture != null) {
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) {
/*if (borderless) {
Forge.getAssets().generatedCards().put(imageKey, generateTexture(new FileHandle(file), cardTexture, Forge.isTextureFilteringEnabled()));
}
}*/
}
return cardTexture;
}
}
public static void unloadCardTextures(boolean removeAll) {
if (removeAll) {
try {
@@ -359,45 +379,50 @@ public class ImageCache {
//e.printstacktrace
}
}
public static void preloadCache(Iterable<String> keys) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return;
for (String imageKey : keys){
if(getImage(imageKey, false) == null)
System.err.println("could not load card image:"+imageKey);
for (String imageKey : keys) {
if (getImage(imageKey, false) == null)
System.err.println("could not load card image:" + imageKey);
}
}
public static void preloadCache(Deck deck) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
return;
if(deck == null||!Forge.enablePreloadExtendedArt)
if (deck == null || !Forge.enablePreloadExtendedArt)
return;
if (deck.getAllCardsInASinglePool().toFlatList().size() <= 100) {
for (PaperCard p : deck.getAllCardsInASinglePool().toFlatList()) {
if (getImage(p.getImageKey(false),false) == null)
System.err.println("could not load card image:"+p.toString());
if (getImage(p.getImageKey(false), false) == null)
System.err.println("could not load card image:" + p.toString());
}
}
}
public static TextureRegion croppedBorderImage(Texture image) {
if (!image.toString().contains(".fullborder."))
return new TextureRegion(image);
float rscale = 0.96f;
int rw = Math.round(image.getWidth()*rscale);
int rh = Math.round(image.getHeight()*rscale);
int rx = Math.round((image.getWidth() - rw)/2f);
int ry = Math.round((image.getHeight() - rh)/2f)-2;
int rw = Math.round(image.getWidth() * rscale);
int rh = Math.round(image.getHeight() * rscale);
int rx = Math.round((image.getWidth() - rw) / 2f);
int ry = Math.round((image.getHeight() - rh) / 2f) - 2;
return new TextureRegion(image, rx, ry, rw, rh);
}
public static Color borderColor(Texture t) {
if (t == null)
return Color.valueOf("#171717");
try {
return Color.valueOf(imageBorder.get(t.toString()).getLeft());
return Color.valueOf(imageRecord.get(t.toString()).colorValue);
} catch (Exception e) {
return Color.valueOf("#171717");
}
}
public static int getFSkinBorders(CardView c) {
if (c == null)
return 0;
@@ -409,25 +434,44 @@ public class ImageCache {
return 1;
return 0;
}
public static boolean isBorderlessCardArt(Texture t) {
/*public static boolean isBorderlessCardArt(Texture 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) {
if (imageBorder.get(textureString) == null)
return BlackBorder;
return imageBorder.get(textureString).getRight() ? WhiteBorder : BlackBorder;
ImageRecord record = imageRecord.get(textureString);
if (record == null)
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) {
if (!canshow)
return BlackBorder;
return FSkinImage.IMG_BORDER_BLACK;
return getBorder(textureString);
}
public static FImage getBorderImage(String textureString) {
return getBorder(textureString);
}
public static Color getTint(CardView c, Texture t) {
if (c == null)
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...
return borderColor(t);
return Color.valueOf("#A0A6A4");
}
else if (state.getColors().isMonoColor()) {
} else if (state.getColors().isMonoColor()) {
if (state.getColors().hasBlack())
return Color.valueOf("#48494a");
else if (state.getColors().hasBlue())
@@ -451,12 +494,12 @@ public class ImageCache {
return Color.valueOf("#66cb35");
else if (state.getColors().hasWhite())
return Color.valueOf("#EEEBE1");
}
else if (state.getColors().isMulticolor())
} else if (state.getColors().isMulticolor())
return Color.valueOf("#F9E084");
return borderColor(t);
}
public static Texture generateTexture(FileHandle fh, Texture cardTexture, boolean textureFilter) {
if (cardTexture == null || fh == null)
return cardTexture;
@@ -481,6 +524,7 @@ public class ImageCache {
});
return placeholder[0];
}
public static Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) {
Pixmap pixmap = new Pixmap(width, height, Format.RGBA4444);
Pixmap ret = new Pixmap(width, height, Format.RGBA4444);
@@ -503,12 +547,13 @@ public class ImageCache {
pixmap.dispose();
return ret;
}
public static void drawPixelstoMask(Pixmap pixmap, Pixmap mask){
public static void drawPixelstoMask(Pixmap pixmap, Pixmap mask) {
int pixmapWidth = mask.getWidth();
int pixmapHeight = mask.getHeight();
Color pixelColor = new Color();
for (int x=0; x<pixmapWidth; x++){
for (int y=0; y<pixmapHeight; y++){
for (int x = 0; x < pixmapWidth; x++) {
for (int y = 0; y < pixmapHeight; y++) {
if (mask.getPixel(x, y) != 0) {
Color.rgba8888ToColor(pixelColor, pixmap.getPixel(x, y));
mask.setColor(pixelColor);
@@ -519,17 +564,17 @@ public class ImageCache {
}
public static boolean isBorderless(String imagekey) {
if(borderlessCardlistKey.isEmpty())
if (borderlessCardlistKey.isEmpty())
return false;
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 borderlessCardlistKey.contains(TextUtil.fastReplace(imagekey,".full",".fullborder"));
return borderlessCardlistKey.contains(TextUtil.fastReplace(imagekey, ".full", ".fullborder"));
}
public static boolean isBorderless(Texture t) {
if(borderlessCardlistKey.isEmpty())
if (borderlessCardlistKey.isEmpty())
return false;
//generated texture/pixmap?
if (t.toString().contains("com.badlogic.gdx.graphics.Texture@"))
@@ -544,17 +589,30 @@ public class ImageCache {
//get pixmap from texture data
Pixmap pixmap = i.getTextureData().consumePixmap();
//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();
return color.toString();
}
public static Pair<String, Boolean> isCloserToWhite(String c){
public static Pair<String, Boolean> isCloserToWhite(String c) {
if (c == null || c == "")
return Pair.of(Color.valueOf("#171717").toString(), false);
int c_r = Integer.parseInt(c.substring(0,2),16);
int c_g = Integer.parseInt(c.substring(2,4),16);
int c_b = Integer.parseInt(c.substring(4,6),16);
int c_r = Integer.parseInt(c.substring(0, 2), 16);
int c_g = Integer.parseInt(c.substring(2, 4), 16);
int c_b = Integer.parseInt(c.substring(4, 6), 16);
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")) {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(card), false, x, y, w, h, CardStackPosition.Top, true, true);
}
else {
} else {
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawImage(image, x, y, w, h);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else {
float radius = (h - w)/8;
float radius = (h - w) / 8;
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")) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);

View File

@@ -85,9 +85,10 @@ public class CardImageRenderer {
drawArt(null, g, x, y, w, h, false, true);
}
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);
}
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);
@@ -110,7 +111,7 @@ public class CardImageRenderer {
boolean drawDungeon = isDungeon && CardRenderer.getCardArt(card) != null;
if (!canShow) {
drawFaceDownCard(card, g, x, y, w, h);
drawFaceDownCard(card, g, x, y, w, h);
return;
}
@@ -134,7 +135,9 @@ public class CardImageRenderer {
Color[] headerColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.NAME_BOX_TINT);
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);
y += headerHeight;
@@ -169,16 +172,15 @@ public class CardImageRenderer {
//draw art box with Forge icon
if (artHeight > 0) {
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)
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) {
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;
}
}
else
} else
drawArt(card, g, x + artInset, y, artWidth, artHeight, altState, isFaceDown);
y += artHeight;
}
@@ -186,7 +188,7 @@ public class CardImageRenderer {
if (isSaga) {
//draw text box
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;
//draw type line
@@ -195,7 +197,7 @@ public class CardImageRenderer {
} else if (isClass) {
//draw text box
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;
//draw type line
@@ -205,7 +207,7 @@ public class CardImageRenderer {
if (!drawDungeon) {
//draw textbox
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;
}
drawTypeLine(g, state, canShow, headerColors, x, y, w, typeBoxHeight, noText, false, false);
@@ -229,7 +231,7 @@ public class CardImageRenderer {
}
//draw artist
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) {
@@ -269,6 +271,7 @@ public class CardImageRenderer {
public static final FBufferedImage forgeArt;
private static final FBufferedImage stretchedArt;
static {
final float logoWidth = FSkinImage.LOGO.getWidth();
final float logoHeight = FSkinImage.LOGO.getHeight();
@@ -287,7 +290,7 @@ public class CardImageRenderer {
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.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);
}
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();
if (alt == null)
alt = card.getAlternateState().getCard();
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) {
CardEdition ed = FModel.getMagicDb().getEditions().get(cv.getCurrentState().getSetCode());
boolean isOldFrame = ed != null && !ed.isModern();
float modH = isOldFrame ? cardArt.getHeight()/12f : 0f;
float modW = !isOldFrame ? cardArt.getWidth()/12f : 0f;
float modW2 = !isOldFrame ? cardArt.getWidth()/6f : 0f;
float modH = isOldFrame ? cardArt.getHeight() / 12f : 0f;
float modW = !isOldFrame ? cardArt.getWidth() / 12f : 0f;
float modW2 = !isOldFrame ? cardArt.getWidth() / 6f : 0f;
float srcY = cardArt.getHeight() * 13f / 354f;
float srcHeight = cardArt.getHeight() * 190f / 354f;
float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CardRenderer.CARD_ART_RATIO);
srcHeight -= dh;
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 + 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.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.drawLine(BORDER_THICKNESS, Color.BLACK, x + w / 2, y, x + w / 2, y + h);
} else {
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(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.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.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) {
if (altState)
g.drawRotatedImage(cardArt.getTextureRegion(), x, y, w, h, x + w / 2, y + h / 2, 180);
else
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) {
float oldAlpha = g.getfloatAlphaComposite();
if (isAdventure)
@@ -422,7 +428,7 @@ public class CardImageRenderer {
//g.fillRect(CardRenderer.getRarityColor(state.getRarity()), x + w + iconPadding, y + (h - iconSize) / 2, iconSize, iconSize);
if (state.getRarity() == null) {
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);
} else if (state.getRarity() == CardRarity.MythicRare) {
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);
}
}
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;
//update land bg colors
@@ -481,7 +488,8 @@ public class CardImageRenderer {
modColors = DetailColors.BLACK;
else if (state.isPlains())
modColors = DetailColors.LAND;
} if (state.origCanProduceColoredMana() == 2) {
}
if (state.origCanProduceColoredMana() == 2) {
//dual colors
Color[] colorPairs = new Color[2];
//init Color
@@ -577,7 +585,9 @@ public class CardImageRenderer {
}
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()) {
//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);
}
}
private static void drawAlphaLines(Graphics g, float x, float y, float w, float h) {
if (FSkin.overlay_alpha != null) {
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) {
List<String> pieces = new ArrayList<>();
if (state.isCreature()) {
pieces.add(String.valueOf(state.getPower()));
pieces.add("/");
pieces.add(String.valueOf(state.getToughness()));
}
else if (state.isPlaneswalker()) {
} else if (state.isPlaneswalker()) {
pieces.add(String.valueOf(state.getLoyalty()));
}
else if (state.getType().hasSubtype("Vehicle")) {
} else if (state.getType().hasSubtype("Vehicle")) {
// TODO Invert color box for Vehicles?
pieces.add("[");
pieces.add(String.valueOf(state.getPower()));
pieces.add("/");
pieces.add(String.valueOf(state.getToughness()));
pieces.add("]");
} else {
return;
}
else { return; }
float padding = Math.round(PT_FONT.getCapHeight() / 4);
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
drawCardImage(g, card, altState, x, y, w, h, CardStackPosition.Top, true, true);
} else {
float radius = (h - w)/8;
float wh_Adj = ForgeConstants.isGdxPortLandscape && isCurrentCard ? 1.38f:1.0f;
float new_w = w*wh_Adj;
float new_h = h*wh_Adj;
float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2:x;
float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2:y;
float new_xRotate = (dispW - new_h) /2;
float new_yRotate = (dispH - new_w) /2;
float radius = (h - w) / 8;
float wh_Adj = ForgeConstants.isGdxPortLandscape && isCurrentCard ? 1.38f : 1.0f;
float new_w = w * wh_Adj;
float new_h = h * wh_Adj;
float new_x = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispW - new_w) / 2 : x;
float new_y = ForgeConstants.isGdxPortLandscape && isCurrentCard ? (dispH - new_h) / 2 : y;
float new_xRotate = (dispW - new_h) / 2;
float new_yRotate = (dispH - new_w) / 2;
boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS);
boolean rotatePlane = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON);
float croppedArea = isModernFrame(card) ? CROP_MULTIPLIER : 0.97f;
float minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) {
float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f;
minusxy = 0.135f*radius;
minusxy = 0.135f * radius;
}
if (rotatePlane && (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane())) {
if (Forge.enableUIMask.equals("Full")){
if (ImageCache.isBorderlessCardArt(image))
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
if (Forge.enableUIMask.equals("Full")) {
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
else {
g.drawRotatedImage(FSkin.getBorders().get(0), new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, -90);
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")) {
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()) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
else {
g.drawRotatedImage(FSkin.getBorders().get(ImageCache.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")) {
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) {
boolean isAftermath = card.getText().contains("Aftermath") || card.getAlternateState().getOracleText().contains("Aftermath");
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawRotatedImage(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, new_x, new_y, new_w, new_h, new_x + new_w / 2, new_y + new_h / 2, isAftermath ? 90 : -90);
else {
g.drawRotatedImage(FSkin.getBorders().get(ImageCache.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")) {
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);
} else {
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawImage(image, x, y, w, h);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else {
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")) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);
@@ -800,15 +811,15 @@ public class CardImageRenderer {
}
}
} else {
//show sleeves instead
//show sleeves instead
g.drawImage(sleeves, x, y, w, h);
}
} else if (Forge.enableUIMask.equals("Full") && canshow) {
if (ImageCache.isBorderlessCardArt(image))
g.drawImage(image, x, y, w, h);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else {
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) {
g.drawImage(ImageCache.croppedBorderImage(image), x, y, w, h);
@@ -841,8 +852,7 @@ public class CardImageRenderer {
final boolean isFaceDown = card.isFaceDown();
if (isFaceDown) {
borderColors = ImmutableList.of(DetailColors.FACE_DOWN);
}
else {
} else {
borderColors = CardDetailUtil.getBorderColors(state, canShow);
}
Color[] colors = fillColorBackground(g, borderColors, x, y, w, h);
@@ -861,7 +871,7 @@ public class CardImageRenderer {
float innerBorderThickness = outerBorderThickness / 2;
float ptBoxHeight = 2 * PT_FONT.getCapHeight();
float textBoxHeight = h - cardNameBoxHeight - ptBoxHeight - outerBorderThickness - 3 * innerBorderThickness;
float textBoxHeight = h - cardNameBoxHeight - ptBoxHeight - outerBorderThickness - 3 * innerBorderThickness;
y += cardNameBoxHeight + innerBorderThickness;
Color[] textBoxColors = FSkinColor.tintColors(Color.WHITE, colors, CardRenderer.TEXT_BOX_TINT);
@@ -881,6 +891,7 @@ public class CardImageRenderer {
fillColorBackground(g, colors, x, y, w, h);
return colors;
}
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 isPW = state.isPlaneswalker();
@@ -893,43 +904,43 @@ public class CardImageRenderer {
switch (backColors.size()) {
case 1:
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) {
g.drawImage(isPW ? FSkinImage.PWBG_C : FSkinImage.CARDBG_L, x, y, w,h);
}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_C : FSkinImage.CARDBG_L, x, y, w, h);
} else if (backColors.get(0) == DetailColors.MULTICOLOR) {
g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w, h);
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) {
if (isPW)
g.drawImage(FSkinImage.PWBG_C, x, y, w,h);
g.drawImage(FSkinImage.PWBG_C, x, y, w, h);
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())
g.drawImage(FSkinImage.CARDBG_A, x, y, w,h);
g.drawImage(FSkinImage.CARDBG_A, x, y, w, h);
else
g.drawImage(FSkinImage.CARDBG_C, x, y, w,h);
g.drawImage(FSkinImage.CARDBG_C, x, y, w, h);
//todo add NYX for colorless?
} 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)
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) {
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)
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) {
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)
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) {
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)
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) {
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)
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;
case 2:
@@ -957,32 +968,33 @@ public class CardImageRenderer {
g.drawImage(isPW ? FSkinImage.PWBG_RG : FSkinImage.CARDBG_RG, x, y, w, h);
}
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;
case 3:
g.drawImage(isPW ? FSkinImage.PWBG_M : FSkinImage.CARDBG_M, x, y, w, h);
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;
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;
}
return colors;
}
public static void fillColorBackground(Graphics g, Color[] colors, float x, float y, float w, float h) {
switch (colors.length) {
case 1:
g.fillRect(colors[0], x, y, w, h);
break;
case 2:
g.fillGradientRect(colors[0], colors[1], false, x, y, w, h);
break;
case 3:
float halfWidth = w / 2;
g.fillGradientRect(colors[0], colors[1], false, x, y, halfWidth, h);
g.fillGradientRect(colors[1], colors[2], false, x + halfWidth, y, halfWidth, h);
break;
case 1:
g.fillRect(colors[0], x, y, w, h);
break;
case 2:
g.fillGradientRect(colors[0], colors[1], false, x, y, w, h);
break;
case 3:
float halfWidth = w / 2;
g.fillGradientRect(colors[0], colors[1], false, x, y, halfWidth, h);
g.fillGradientRect(colors[1], colors[2], false, x + halfWidth, y, halfWidth, h);
break;
}
}
@@ -1059,7 +1071,9 @@ public class CardImageRenderer {
}
String ptText = CardDetailUtil.formatPowerToughness(state, canShow);
if (StringUtils.isEmpty(ptText)) { return; }
if (StringUtils.isEmpty(ptText)) {
return;
}
float padding = PT_FONT.getCapHeight() / 2;
float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding,

View File

@@ -125,17 +125,17 @@ public class CardRenderer {
public static Color getRarityColor(CardRarity rarity) {
if (rarity == null)// NPE from Rarity weird...
return Color.CLEAR;
switch(rarity) {
case Uncommon:
return fromDetailColor(DetailColors.UNCOMMON);
case Rare:
return fromDetailColor(DetailColors.RARE);
case MythicRare:
return fromDetailColor(DetailColors.MYTHIC);
case Special: //"Timeshifted" or other Special Rarity Cards
return fromDetailColor(DetailColors.SPECIAL);
default: //case BasicLand: + case Common:
return fromDetailColor(DetailColors.COMMON);
switch (rarity) {
case Uncommon:
return fromDetailColor(DetailColors.UNCOMMON);
case Rare:
return fromDetailColor(DetailColors.RARE);
case MythicRare:
return fromDetailColor(DetailColors.MYTHIC);
case Special: //"Timeshifted" or other Special Rarity Cards
return fromDetailColor(DetailColors.SPECIAL);
default: //case BasicLand: + case Common:
return fromDetailColor(DetailColors.COMMON);
}
}
@@ -193,7 +193,7 @@ public class CardRenderer {
public static final float CARD_ART_HEIGHT_PERCENTAGE = 0.43f;
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();
}
@@ -205,7 +205,7 @@ public class CardRenderer {
public static FImageComplex getCardArt(IPaperCard pc, boolean backFace) {
CardType type = pc.getRules().getType();
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.isPlaneswalker(), isModernFrame(pc));
}
@@ -225,17 +225,16 @@ public class CardRenderer {
if (image != null) {
if (image == ImageCache.getDefaultImage()) {
cardArt = CardImageRenderer.forgeArt;
}
else {
} else {
float x, y;
float w = image.getWidth();
float h = image.getHeight();
if (isClassicModule) {
if (isClassicModule) {
x = w * 0.09f;
y = h * 0.2f;
w -= 2f * x;
h -= 3f * y;
}else if (isPlanesWalker) {
} else if (isPlanesWalker) {
x = w * 0.09f;
y = h * 0.11f;
w -= 2f * x;
@@ -283,8 +282,8 @@ public class CardRenderer {
return cardArt;
}
} else {
//adjust smaller crop
x = isModernFrame ? w * 0.1f :w * 0.12f;
//adjust smaller crop
x = isModernFrame ? w * 0.1f : w * 0.12f;
y = isModernFrame ? h * 0.12f : h * 0.11f;
w -= isModernFrame ? 2 * x : 2.1f * x;
h *= CARD_ART_HEIGHT_PERCENTAGE;
@@ -312,7 +311,7 @@ public class CardRenderer {
}
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) {
Texture image = new CachedCardImage(imageKey) {
@Override
@@ -338,14 +337,14 @@ public class CardRenderer {
}
if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Aftermath_second_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Aftermath_second_" + imageKey, cardArt);
}
}
return cardArt;
}
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) {
Texture image = new CachedCardImage(imageKey) {
@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)));
}
if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache().put("Alternate_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Alternate_" + imageKey, cardArt);
}
}
return cardArt;
@@ -394,9 +393,9 @@ public class CardRenderer {
public static FImageComplex getMeldCardParts(final String imageKey, boolean bottom) {
FImageComplex cardArt;
if (!bottom) {
cardArt = Forge.getAssets().cardArtCache().get("Meld_primary_"+imageKey);
cardArt = Forge.getAssets().cardArtCache().get("Meld_primary_" + imageKey);
} else {
cardArt = Forge.getAssets().cardArtCache().get("Meld_secondary_"+imageKey);
cardArt = Forge.getAssets().cardArtCache().get("Meld_secondary_" + imageKey);
}
if (cardArt == null) {
@@ -414,15 +413,15 @@ public class CardRenderer {
} else {
float x = 0;
float w = image.getWidth();
float h = image.getHeight()/2f;
float h = image.getHeight() / 2f;
float y = bottom ? h : 0;
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
}
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))
Forge.getAssets().cardArtCache().put("Meld_secondary_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Meld_secondary_" + imageKey, cardArt);
}
}
return cardArt;
@@ -434,8 +433,7 @@ public class CardRenderer {
drawCardListItem(g, font, foreColor, getCardArt(card), card, state.getSetCode(),
state.getRarity(), state.getPower(), state.getToughness(),
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());
if (count > 0) { //preface name with count if applicable
name = count + " " + name;
@@ -469,15 +467,13 @@ public class CardRenderer {
float dh = srcHeight * (1 - cardArt.getWidth() / srcHeight / CARD_ART_RATIO);
srcHeight -= dh;
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 + 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")) {
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);
} else if (card.getText().contains("Aftermath")) {
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(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 {
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);
} else {
g.drawImage(cardArt, artX, artY, cardArtWidth, cardArtHeight);
}
}
@@ -526,11 +522,9 @@ public class CardRenderer {
String type = CardDetailUtil.formatCardType(card.getCurrentState(), true);
if (card.getCurrentState().isCreature()) { //include P/T or Loyalty at end of type
type += " (" + power + " / " + toughness + ")";
}
else if (card.getCurrentState().isPlaneswalker()) {
} else if (card.getCurrentState().isPlaneswalker()) {
type += " (" + loyalty + ")";
}
else if (card.getCurrentState().getType().hasSubtype("Vehicle")) {
} else if (card.getCurrentState().getType().hasSubtype("Vehicle")) {
type += String.format(" [%s / %s]", power, toughness);
}
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) {
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 minusxy = isModernFrame(pc) ? 0.0f : 0.13f*radius;
if (pc.getEdition().equals("LEA")||pc.getEdition().equals("LEB")) {
float minusxy = isModernFrame(pc) ? 0.0f : 0.13f * radius;
if (pc.getEdition().equals("LEA") || pc.getEdition().equals("LEB")) {
croppedArea = 0.975f;
minusxy = 0.135f*radius;
minusxy = 0.135f * radius;
}
if (image != null) {
if (image == ImageCache.getDefaultImage() || Forge.enableUIMask.equals("Art")) {
CardImageRenderer.drawCardImage(g, CardView.getCardForUi(pc), false, x, y, w, h, pos, true, true);
} else {
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawImage(image, x, y, w, h);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, null, x, y, w, h, false, false);
else {
//tint the border
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")) {
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);
}
}
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);
}
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 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());
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 minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) {
float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f;
minusxy = 0.135f*radius;
minusxy = 0.135f * radius;
}
float oldAlpha = g.getfloatAlphaComposite();
if (card.isPhasedOut() && !magnify)
@@ -631,23 +627,23 @@ public class CardRenderer {
else
g.drawCardImage(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0);
} else {
if(FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()) && rotate){
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_PLANE_OR_PHENOMENON)
&& (card.getCurrentState().isPhenomenon() || card.getCurrentState().isPlane()) && rotate) {
if (Forge.enableUIMask.equals("Full")) {
if (ImageCache.isBorderlessCardArt(image))
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, x, y, w, h, x + w / 2, y + h / 2, -90);
else {
g.drawRotatedImage(FSkin.getBorders().get(0), x, y, w, h, x + w / 2, y + h / 2, -90);
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")) {
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
g.drawRotatedImage(image, x, y, w, h, x + w / 2, y + h / 2, -90);
} else {
if (Forge.enableUIMask.equals("Full") && canshow) {
if (ImageCache.isBorderlessCardArt(image))
g.drawCardImage(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0);
if (image.toString().contains(".fullborder."))
g.drawCardRoundRect(image, crack_overlay, x, y, w, h, card.wasDestroyed(), magnify ? false : card.getDamage() > 0);
else {
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
@@ -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) {
drawCardWithOverlays(g, card, x, y, w, h, pos, false, false, false);
}
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) {
boolean canShow = MatchController.instance.mayView(card);
float oldAlpha = g.getfloatAlphaComposite();
boolean unselectable = !MatchController.instance.isSelectable(card) && MatchController.instance.isSelecting();
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);
float padding = w * PADDING_MULTIPLIER; //adjust for card border
@@ -700,7 +701,9 @@ public class CardRenderer {
if (stackview)
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);
if (canShow && showCardIdOverlay(card)) {
@@ -736,7 +739,7 @@ public class CardRenderer {
//Class level
if (card.getCurrentState().getType().hasStringType("Class") && ZoneType.Battlefield.equals(card.getZone())) {
List<String> markers = new ArrayList<>();
markers.add("LV:"+card.getClassLevel());
markers.add("LV:" + card.getClassLevel());
drawMarkersTabs(markers, g, x, y - markersHeight, w, h, true);
}
@@ -747,8 +750,7 @@ public class CardRenderer {
if (card.isAttacking()) {
CardFaceSymbols.drawSymbol("attack", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
}
else if (card.isBlocking()) {
} else if (card.isBlocking()) {
CardFaceSymbols.drawSymbol("defend", g, combatXSymbols, ySymbols, otherSymbolsSize, otherSymbolsSize);
}
@@ -771,29 +773,31 @@ public class CardRenderer {
drawPtBox(g, card, details, color, x, y, w, h);
}
//Darken unselectable cards
if (unselectable){
if (unselectable) {
g.setAlphaComposite(0.6f);
g.fillRect(Color.BLACK, cx, cy, cw, ch);
g.setAlphaComposite(oldAlpha);
}
//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);
}
//Ability Icons
boolean onbattlefield = ZoneType.Battlefield.equals(card.getZone());
if (unselectable){ g.setAlphaComposite(0.6f); }
if (unselectable) {
g.setAlphaComposite(0.6f);
}
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)) {
//draw indicator for flash or can be cast at instant speed, enabled if show ability icons is enabled
String keywordKey = card.getCurrentState().getKeywordKey();
String abilityText = card.getCurrentState().getAbilityText();
if ((keywordKey.indexOf("Flash") != -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)
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
@@ -814,7 +818,7 @@ public class CardRenderer {
multiplier = 0.150f;
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)) {
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);
}
}
}
else {
} else {
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) {
float abiCount = 0;
if (card.isToken()){
if (card.isToken()) {
CardFaceSymbols.drawSymbol("token", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
@@ -865,50 +868,70 @@ public class CardRenderer {
CardFaceSymbols.drawSymbol("doublestrike", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().hasFirstStrike()) {
} else if (card.getCurrentState().hasFirstStrike()) {
CardFaceSymbols.drawSymbol("firststrike", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
@@ -919,8 +942,11 @@ public class CardRenderer {
abiCount += 1;
}
if (card.getCurrentState().hasHexproof()) {
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); }
if (!card.getCurrentState().getHexproofKey().isEmpty()){
if (abiCount > 5) {
abiY = cy + (abiSpace * (abiCount - 6));
abiX = cx + ((cw * 2) / 1.92f);
}
if (!card.getCurrentState().getHexproofKey().isEmpty()) {
String[] splitK = card.getCurrentState().getHexproofKey().split(":");
List<String> listHK = Arrays.asList(splitK);
if (listHK.contains("generic")) {
@@ -963,138 +989,142 @@ public class CardRenderer {
abiY += abiSpace;
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
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);
abiY += abiSpace;
abiCount += 1;
}
//Protection Icons
if (!card.getCurrentState().getProtectionKey().isEmpty()){
if (abiCount > 5 ) { abiY = cy + (abiSpace * (abiCount - 6)); abiX = cx + ((cw*2)/1.92f); }
if (!card.getCurrentState().getProtectionKey().isEmpty()) {
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")) {
CardFaceSymbols.drawSymbol("protectAll", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().contains("coloredspells")) {
} else if (card.getCurrentState().getProtectionKey().contains("coloredspells")) {
CardFaceSymbols.drawSymbol("protectColoredSpells", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().equals("R")) {
} else if (card.getCurrentState().getProtectionKey().equals("R")) {
CardFaceSymbols.drawSymbol("protectR", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().equals("G")) {
} else if (card.getCurrentState().getProtectionKey().equals("G")) {
CardFaceSymbols.drawSymbol("protectG", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().equals("B")) {
} else if (card.getCurrentState().getProtectionKey().equals("B")) {
CardFaceSymbols.drawSymbol("protectB", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().equals("U")) {
} else if (card.getCurrentState().getProtectionKey().equals("U")) {
CardFaceSymbols.drawSymbol("protectU", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
abiCount += 1;
}
else if (card.getCurrentState().getProtectionKey().equals("W")) {
} else if (card.getCurrentState().getProtectionKey().equals("W")) {
CardFaceSymbols.drawSymbol("protectW", g, abiX, abiY, abiScale, abiScale);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
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);
abiY += abiSpace;
abiCount += 1;
}
}
}
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)));
@@ -1122,7 +1152,7 @@ public class CardRenderer {
}
//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));
if (counterBoxBaseWidth + layout.width > w) {
drawCounterImage(card, g, x, y, w, h);
@@ -1135,7 +1165,7 @@ public class CardRenderer {
final CounterType counter = counterEntry.getKey();
final int numberOfCounters = counterEntry.getValue();
//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));
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
Gdx.gl.glEnable(GL_BLEND);
}
if(font != null && !text.isEmpty()) {
if (font != null && !text.isEmpty()) {
layout.setText(font, text);
TextBounds textBounds = new TextBounds(layout.width, layout.height);
@@ -1199,14 +1229,11 @@ public class CardRenderer {
if (counters == 1) {
CardFaceSymbols.drawSymbol("counters1", g, xCounters, yCounters, countersSize, countersSize);
}
else if (counters == 2) {
} else if (counters == 2) {
CardFaceSymbols.drawSymbol("counters2", g, xCounters, yCounters, countersSize, countersSize);
}
else if (counters == 3) {
} else if (counters == 3) {
CardFaceSymbols.drawSymbol("counters3", g, xCounters, yCounters, countersSize, countersSize);
}
else if (counters > 3) {
} else if (counters > 3) {
CardFaceSymbols.drawSymbol("countersMulti", g, xCounters, yCounters, countersSize, countersSize);
}
@@ -1231,7 +1258,7 @@ public class CardRenderer {
int markerCounter = markers.size() - 1;
for (String marker : markers) {
if(font != null && !marker.isEmpty()) {
if (font != null && !marker.isEmpty()) {
layout.setText(font, marker);
final float markerBoxRealWidth = markerBoxBaseWidth + layout.width + 4;
@@ -1254,8 +1281,7 @@ public class CardRenderer {
pieces.add(String.valueOf(details.getPower()));
pieces.add("/");
pieces.add(String.valueOf(details.getToughness()));
}
else if (details.getType().hasSubtype("Vehicle")) {
} else if (details.getType().hasSubtype("Vehicle")) {
pieces.add("[");
pieces.add(String.valueOf(details.getPower()));
pieces.add("/");
@@ -1265,13 +1291,14 @@ public class CardRenderer {
if (details.isPlaneswalker()) {
if (pieces.isEmpty()) {
pieces.add(String.valueOf(details.getLoyalty()));
}
else {
} else {
pieces.add("(" + details.getLoyalty() + ")");
}
}
if (pieces.isEmpty()) { return; }
if (pieces.isEmpty()) {
return;
}
FSkinFont font = FSkinFont.forHeight(h * 0.15f);
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) {
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 minusxy = isModernFrame(card) ? 0.0f : 0.13f*radius;
if (card.getCurrentState().getSetCode().equals("LEA")||card.getCurrentState().getSetCode().equals("LEB")) {
float minusxy = isModernFrame(card) ? 0.0f : 0.13f * radius;
if (card.getCurrentState().getSetCode().equals("LEA") || card.getCurrentState().getSetCode().equals("LEB")) {
croppedArea = 0.975f;
minusxy = 0.135f*radius;
minusxy = 0.135f * radius;
}
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)) {
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");
if (!ttfFile.exists()) { return; }
if (!ttfFile.exists()) {
return;
}
final FreeTypeFontGenerator generator = new FreeTypeFontGenerator(ttfFile);

View File

@@ -53,15 +53,18 @@ public class CardZoom extends FOverlay {
public static void show(Object item) {
show(item, false);
}
public static void show(Object item, boolean showbackside) {
List<Object> items0 = new ArrayList<>();
items0.add(item);
showBackSide = showbackside; //reverse the displayed zoomed card for the choice list
show(items0, 0, null);
}
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) {
items = items0;
activateHandler = activateHandler0;
@@ -89,7 +92,9 @@ public class CardZoom extends FOverlay {
@Override
public void setVisible(boolean visible0) {
if (this.isVisible() == visible0) { return; }
if (this.isVisible() == visible0) {
return;
}
super.setVisible(visible0);
@@ -101,7 +106,9 @@ public class CardZoom extends FOverlay {
private static void incrementCard(int dir) {
if (dir > 0) {
if (currentIndex == items.size() - 1) { return; }
if (currentIndex == items.size() - 1) {
return;
}
currentIndex++;
prevCard = currentCard;
@@ -130,7 +137,7 @@ public class CardZoom extends FOverlay {
flipIconBounds = null;
}
if (currentCard != null) {
if (currentCard.getMergedCardsCollection() != null )
if (currentCard.getMergedCardsCollection() != null)
if (currentCard.getMergedCardsCollection().size() > 0)
mutateIconBounds = new Rectangle();
}
@@ -139,29 +146,29 @@ public class CardZoom extends FOverlay {
private static CardView getCardView(Object item) {
if (item instanceof Entry) {
item = ((Entry<?, ?>)item).getKey();
item = ((Entry<?, ?>) item).getKey();
}
if (item instanceof CardView) {
return (CardView)item;
return (CardView) item;
}
if (item instanceof DeckProxy) {
if (item instanceof CardThemedDeckGenerator){
return CardView.getCardForUi(((CardThemedDeckGenerator)item).getPaperCard());
}else if (item instanceof CommanderDeckGenerator){
return CardView.getCardForUi(((CommanderDeckGenerator)item).getPaperCard());
}else if (item instanceof ArchetypeDeckGenerator){
return CardView.getCardForUi(((ArchetypeDeckGenerator)item).getPaperCard());
}else{
DeckProxy deck = ((DeckProxy)item);
if (item instanceof CardThemedDeckGenerator) {
return CardView.getCardForUi(((CardThemedDeckGenerator) item).getPaperCard());
} else if (item instanceof CommanderDeckGenerator) {
return CardView.getCardForUi(((CommanderDeckGenerator) item).getPaperCard());
} else if (item instanceof ArchetypeDeckGenerator) {
return CardView.getCardForUi(((ArchetypeDeckGenerator) item).getPaperCard());
} else {
DeckProxy deck = ((DeckProxy) item);
return new CardView(-1, null, deck.getName(), null, deck.getImageKey(false));
}
}
if (item instanceof IPaperCard) {
return CardView.getCardForUi((IPaperCard)item);
return CardView.getCardForUi((IPaperCard) item);
}
if (item instanceof ConquestCommander) {
return CardView.getCardForUi(((ConquestCommander)item).getCard());
return CardView.getCardForUi(((ConquestCommander) item).getCard());
}
if (item instanceof InventoryItem) {
InventoryItem ii = (InventoryItem)item;
@@ -173,7 +180,7 @@ public class CardZoom extends FOverlay {
@Override
public boolean tap(float x, float y, int count) {
if (mutateIconBounds != null && mutateIconBounds.contains(x, y)) {
if(showMerged) {
if (showMerged) {
showMerged = false;
} else {
showMerged = true;
@@ -226,7 +233,9 @@ public class CardZoom extends FOverlay {
}
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;
prefs.setPref(FPref.UI_SINGLE_CARD_ZOOM, oneCardView0);
@@ -240,8 +249,7 @@ public class CardZoom extends FOverlay {
if (totalZoomAmount >= REQ_AMOUNT) {
setOneCardView(true);
totalZoomAmount = 0;
}
else if (totalZoomAmount <= -REQ_AMOUNT) {
} else if (totalZoomAmount <= -REQ_AMOUNT) {
setOneCardView(false);
totalZoomAmount = 0;
}
@@ -279,24 +287,22 @@ public class CardZoom extends FOverlay {
float maxCardHeight = h - AspectRatioMultiplier * messageHeight; //maxheight of currently zoomed card
float cardWidth, cardHeight, y;
if (oneCardView && !Forge.isLandscapeMode()) {
cardWidth = w;
cardHeight = FCardPanel.ASPECT_RATIO * cardWidth;
boolean rotateSplit = FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ROTATE_SPLIT_CARDS);
if (currentCard != null && currentCard.isSplitCard() && rotateSplit) {
// 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();
cardWidth = cardHeight / FCardPanel.ASPECT_RATIO;
}
}
}
else {
} else {
cardWidth = w * 0.5f;
cardHeight = FCardPanel.ASPECT_RATIO * cardWidth;
@@ -326,7 +332,7 @@ public class CardZoom extends FOverlay {
if (zoomMode) {
CardImageRenderer.drawZoom(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight, getWidth(), getHeight(), true);
} 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) {
@@ -370,18 +376,20 @@ public class CardZoom extends FOverlay {
public interface ActivateHandler {
String getActivateAction(int index);
void setSelectedIndex(int index);
void activate(int index);
}
public void interrupt(boolean resume) {
if (MatchController.instance.hasLocalPlayers())
return;
if(resume && MatchController.instance.isGamePaused()) {
if (resume && MatchController.instance.isGamePaused()) {
MatchController.instance.resumeMatch();
return;
}
if(!MatchController.instance.isGamePaused())
if (!MatchController.instance.isGamePaused())
MatchController.instance.pauseMatch();
}
@@ -403,8 +411,7 @@ public class CardZoom extends FOverlay {
if (flipIconBounds != null) {
tap(flipIconBounds.x, flipIconBounds.y, 1);
}
}
else if (keyCode == Input.Keys.BUTTON_Y)
} else if (keyCode == Input.Keys.BUTTON_Y)
fling(0, 300f);
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 PILE_SPACING_Y = 0.1f;
private static final FSkinFont LABEL_FONT = FSkinFont.get(12);
private static FSkinColor getGroupHeaderForeColor() {
if (Forge.isMobileAdventureMode)
return FSkinColor.get(Colors.ADV_CLR_TEXT);
return FSkinColor.get(Colors.CLR_TEXT);
}
private static FSkinColor getGroupHeaderLineColor() {
return getGroupHeaderForeColor().alphaColor(0.5f);
}
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_GLYPH_WIDTH = Utils.scale(6);
@@ -73,7 +76,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
private ExpandCollapseButton() {
super(new FLabel.ButtonBuilder());
setCommand(e -> {
if (groupBy == null || model.getItems().isEmpty()) { return; }
if (groupBy == null || model.getItems().isEmpty()) {
return;
}
boolean collapsed = !isAllCollapsed;
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);
if (pressed) {
y += lineThickness;
}
else {
} else {
x -= lineThickness;
}
@@ -132,6 +136,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
}
}
private final ExpandCollapseButton btnExpandCollapseAll = new ExpandCollapseButton();
private final FComboBox<Object> cbGroupByOptions = new FComboBox<>(Forge.getLocalizer().getMessage("lblGroups") + " ");
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 -> {
if (cbGroupByOptions.getSelectedIndex() > 0) {
setGroupBy((GroupDef) cbGroupByOptions.getSelectedItem());
}
else {
} else {
setGroupBy(null);
}
});
cbPileByOptions.setChangedHandler(e -> {
if (cbPileByOptions.getSelectedIndex() > 0) {
setPileBy((ColumnDef) cbPileByOptions.getSelectedItem());
}
else {
} else {
setPileBy(null);
}
});
@@ -179,17 +182,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public GroupDef getGroupBy() {
return groupBy;
}
public void setGroupBy(GroupDef groupBy0) {
setGroupBy(groupBy0, false);
}
private void setGroupBy(GroupDef groupBy0, boolean forSetup) {
if (groupBy == groupBy0) { return; }
if (groupBy == groupBy0) {
return;
}
groupBy = groupBy0;
if (groupBy == null) {
cbGroupByOptions.setSelectedIndex(0);
}
else {
} else {
cbGroupByOptions.setSelectedItem(groupBy);
}
@@ -198,8 +204,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
if (groupBy == null) {
groups.add(new Group(""));
btnExpandCollapseAll.updateIsAllCollapsed();
}
else {
} else {
for (String groupName : groupBy.getGroups()) {
groups.add(new Group(groupName));
}
@@ -228,17 +233,20 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public ColumnDef getPileBy() {
return pileBy;
}
public void setPileBy(ColumnDef pileBy0) {
setPileBy(pileBy0, false);
}
private void setPileBy(ColumnDef pileBy0, boolean forSetup) {
if (pileBy == pileBy0) { return; }
if (pileBy == pileBy0) {
return;
}
pileBy = pileBy0;
if (pileBy == null) {
cbPileByOptions.setSelectedIndex(0);
}
else {
} else {
cbPileByOptions.setSelectedItem(pileBy);
}
@@ -263,14 +271,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public void setColumnCount(int columnCount0) {
setColumnCount(columnCount0, false);
}
private void setColumnCount(int columnCount0, boolean forSetup) {
if (columnCount0 < MIN_COLUMN_COUNT) {
columnCount0 = MIN_COLUMN_COUNT;
}
else if (columnCount0 > MAX_COLUMN_COUNT) {
} else if (columnCount0 > MAX_COLUMN_COUNT) {
columnCount0 = MAX_COLUMN_COUNT;
}
if (columnCount == columnCount0) { return; }
if (columnCount == columnCount0) {
return;
}
columnCount = columnCount0;
if (!forSetup) {
@@ -342,14 +352,12 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
Group group;
if (groupIndex >= 0) {
group = groups.get(groupIndex);
}
else {
} else {
if (otherItems == null) {
//reuse existing Other group if possible
if (groups.size() > groupBy.getGroups().length) {
otherItems = groups.get(groups.size() - 1);
}
else {
} else {
otherItems = new Group(Forge.getLocalizer().getMessage("lblOther"));
otherItems.isCollapsed = btnExpandCollapseAll.isAllCollapsed;
groups.add(otherItems);
@@ -389,7 +397,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
private void updateLayout(boolean forRefresh) {
if (updatingLayout) { return; } //prevent infinite loop
if (updatingLayout) {
return;
} //prevent infinite loop
updatingLayout = true;
focalItem = null; //clear cached focalItem when layout changes
@@ -471,8 +481,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
y += itemHeight;
group.scrollWidth = groupWidth;
}
else {
} else {
x = 0;
pileY = y;
maxPileHeight = 0;
@@ -505,7 +514,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
int index = 0;
orderedItems.clear();
for (Group group : groups) {
if (group.isCollapsed || group.items.isEmpty()) { continue; }
if (group.isCollapsed || group.items.isEmpty()) {
continue;
}
for (Pile pile : group.piles) {
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) {
//check selected items first since they appear on top
for (int i = selectedIndices.size() - 1; i >= 0; i--) {
int currentIndex=selectedIndices.get(i);
if(currentIndex<0||orderedItems.size()<=currentIndex)
int currentIndex = selectedIndices.get(i);
if (currentIndex < 0 || orderedItems.size() <= currentIndex)
continue;
ItemInfo item = orderedItems.get(currentIndex);
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 (selectedIndices.size() > minSelections) {
item.selected = false;
selectedIndices.remove((Object)item.index);
selectedIndices.remove((Object) item.index);
onSelectionChange();
item.group.scrollIntoView(item);
}
@@ -736,9 +747,13 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override
public void scrollSelectionIntoView() {
if (selectedIndices.isEmpty()) { return; }
int index=selectedIndices.get(0);
if(index<0||orderedItems.size()<=index) { return ; }
if (selectedIndices.isEmpty()) {
return;
}
int index = selectedIndices.get(0);
if (index < 0 || orderedItems.size() <= index) {
return;
}
ItemInfo itemInfo = orderedItems.get(index);
getScroller().scrollIntoView(itemInfo);
@@ -746,10 +761,14 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override
public Rectangle getSelectionBounds() {
if (selectedIndices.isEmpty()) { return new Rectangle(); }
if (selectedIndices.isEmpty()) {
return new Rectangle();
}
int index=selectedIndices.get(0);
if(index<0||orderedItems.size()<=index) { return new Rectangle(); }
int index = selectedIndices.get(0);
if (index < 0 || orderedItems.size() <= index) {
return new Rectangle();
}
ItemInfo itemInfo = orderedItems.get(index);
Vector2 relPos = itemInfo.group.getChildRelativePosition(itemInfo);
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
public void zoomSelected() {
if (selectedIndices.isEmpty()) { return; }
int index=selectedIndices.get(0);
if(index<0||orderedItems.size()<=index) { return ; }
if (selectedIndices.isEmpty()) {
return;
}
int index = selectedIndices.get(0);
if (index < 0 || orderedItems.size() <= index) {
return;
}
ItemInfo itemInfo = orderedItems.get(index);
if (itemInfo != null) {
if(itemInfo.getKey() instanceof CardThemedDeckGenerator || itemInfo.getKey() instanceof CommanderDeckGenerator
|| itemInfo.getKey() instanceof ArchetypeDeckGenerator || itemInfo.getKey() instanceof DeckProxy){
FDeckViewer.show(((DeckProxy)itemInfo.getKey()).getDeck());
if (itemInfo.getKey() instanceof CardThemedDeckGenerator || itemInfo.getKey() instanceof CommanderDeckGenerator
|| itemInfo.getKey() instanceof ArchetypeDeckGenerator || itemInfo.getKey() instanceof DeckProxy) {
FDeckViewer.show(((DeckProxy) itemInfo.getKey()).getDeck());
}
CardZoom.show(orderedItems, orderedItems.indexOf(itemInfo), itemManager);
}
@@ -795,7 +818,9 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
@Override
public void draw(Graphics g) {
if (items.isEmpty()) { return; }
if (items.isEmpty()) {
return;
}
if (groupBy != null) {
//draw group name and horizontal line
@@ -816,15 +841,16 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
x, y - offset,
x + offset, y,
x, y + offset);
}
else {
} else {
g.fillTriangle(getGroupHeaderLineColor(),
x - offset + 2, y + offset - 1,
x + offset, y + offset - 1,
x + offset, y - offset + 1);
}
if (isCollapsed) { return; }
if (isCollapsed) {
return;
}
float visibleLeft = getScrollLeft();
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) {
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
if (item != null) {
if(item.getKey() instanceof DeckProxy) {
DeckProxy dp = (DeckProxy)item.getKey();
if (item.getKey() instanceof DeckProxy) {
DeckProxy dp = (DeckProxy) item.getKey();
if (count >= 2 && !dp.isGeneratedDeck()) {
//double tap to add to favorites or remove....
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) {
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
if (item != null) {
if(item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator
|| item.getKey() instanceof ArchetypeDeckGenerator || item.getKey() instanceof DeckProxy){
FDeckViewer.show(((DeckProxy)item.getKey()).getDeck());
if (item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator
|| item.getKey() instanceof ArchetypeDeckGenerator || item.getKey() instanceof DeckProxy) {
FDeckViewer.show(((DeckProxy) item.getKey()).getDeck());
return true;
}
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());
}
}
private class Pile extends FDisplayObject {
private final List<ItemInfo> items = new ArrayList<>();
@@ -924,8 +951,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
if (itemInfo.selected) {
skippedItem = itemInfo;
}
else {
} else {
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 final T item;
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);
//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);
}
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);
}
}
@@ -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)) {
double score = CardRanker.getRawScore((PaperCard) item);
int draftRank = score <= 0 ? 0 : score > 99 ? 99 : (int) Math.round(CardRanker.getRawScore((PaperCard) item));
float rankSize = w/2;
float y2 = y+(rankSize-(rankSize*0.1f));
float x2 = x+rankSize/2;
float rankSize = w / 2;
float y2 = y + (rankSize - (rankSize * 0.1f));
float x2 = x + rankSize / 2;
if (draftRank >= 90) {
g.drawImage(FSkinImage.DRAFTRANK_S, x2, y2+1, rankSize, rankSize);
} else if (draftRank >= 80 && draftRank <= 89 ) {
g.drawImage(FSkinImage.DRAFTRANK_A, x2, y2+1, rankSize, rankSize);
} else if (draftRank >= 60 && draftRank <= 79 ) {
g.drawImage(FSkinImage.DRAFTRANK_B, x2, y2+1, rankSize, rankSize);
} else if (draftRank >= 25 && draftRank <= 59 ) {
g.drawImage(FSkinImage.DRAFTRANK_C, x2, y2+1, rankSize, rankSize);
g.drawImage(FSkinImage.DRAFTRANK_S, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 80 && draftRank <= 89) {
g.drawImage(FSkinImage.DRAFTRANK_A, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 60 && draftRank <= 79) {
g.drawImage(FSkinImage.DRAFTRANK_B, x2, y2 + 1, rankSize, rankSize);
} else if (draftRank >= 25 && draftRank <= 59) {
g.drawImage(FSkinImage.DRAFTRANK_C, x2, y2 + 1, rankSize, rankSize);
} 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);
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) {
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;
if (dpImg != null) {//generated decks have missing info...
if (Forge.enableUIMask.equals("Off")){
if (Forge.enableUIMask.equals("Off")) {
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.drawImage(dpImg, x, y, w, h);
@@ -1049,28 +1075,28 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
}
}
//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
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 {
if (!dp.isGeneratedDeck()) {
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 {
//If deck has Commander, use it as cardArt reference
PaperCard paperCard = dp.getDeck().getCommanders().isEmpty() ? dp.getHighestCMCCard() : dp.getDeck().getCommanders().get(0);
FImageComplex cardArt = CardRenderer.getCardArt(paperCard);
//draw the deckbox
if (cardArt == null){
if (cardArt == null) {
//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 {
g.drawDeckBox(cardArt, scale, FSkin.getDeckbox().get(1), FSkin.getDeckbox().get(2), x, y, w, h, Color.GREEN, selected);
}
}
} else {
//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) {
//deck color identity
@@ -1089,8 +1115,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
symbolSize = IMAGE_SIZE * (0.5f);
}
//vertical mana icons
CardFaceSymbols.drawColorSet(g, deckColor, x +(w-symbolSize), y+(h/8), symbolSize, true);
if(!dp.isGeneratedDeck()) {
CardFaceSymbols.drawColorSet(g, deckColor, x + (w - symbolSize), y + (h / 8), symbolSize, true);
if (!dp.isGeneratedDeck()) {
if (dp.getDeck().isEmpty()) {
g.drawImage(Forge.hdbuttons ? FSkinImage.HDYIELD : FSkinImage.WARNING, x, y, symbolSize, symbolSize);
} else {
@@ -1099,15 +1125,15 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
else
g.drawImage(DeckPreferences.getPrefs(dp).getStarCount() > 0 ? FSkinImage.STAR_FILLED : FSkinImage.STAR_OUTLINE, x, y, symbolSize, symbolSize);
//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
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
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 {
Texture img = ImageCache.getImage(item);

View File

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