| 12 | import forge.toolbox.FCardPanel; |
| 13 | |
| 14 | public class CardImage implements FImage { |
| 15 | private final PaperCard card; |
| 16 | private Texture image; |
| 17 | |
| 18 | public CardImage(PaperCard card0) { |
| 19 | card = card0; |
| 20 | } |
| 21 | |
| 22 | @Override |
| 23 | public float getWidth() { |
| 24 | if (image != null) { |
| 25 | return image.getWidth(); |
| 26 | } |
| 27 | return ImageCache.getInstance().getDefaultImage().getWidth(); |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public float getHeight() { |
| 32 | return getWidth() * FCardPanel.ASPECT_RATIO; |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public void draw(Graphics g, float x, float y, float w, float h) { |
| 37 | CardView cv = CardView.getCardForUi(card); |
| 38 | if (image == null) { //attempt to retrieve card image if needed |
| 39 | image = ImageCache.getInstance().getImage(card); |
| 40 | if (image == null) { |
| 41 | if (!Forge.enableUIMask.equals("Off")) //render this if mask is still loading |
| 42 | CardImageRenderer.drawCardImage(g, cv, false, x, y, w, h, CardStackPosition.Top, Forge.enableUIMask.equals("Art"), true); |
| 43 | |
| 44 | return; //can't draw anything if can't be loaded yet |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | if (image == ImageCache.getInstance().getDefaultImage() || Forge.enableUIMask.equals("Art")) { |
| 49 | CardImageRenderer.drawCardImage(g, cv, false, x, y, w, h, CardStackPosition.Top, true, true); |
| 50 | } else { |
| 51 | if (Forge.enableUIMask.equals("Full")) { |
| 52 | if (ImageCache.getInstance().isFullBorder(image)) |
| 53 | g.drawCardRoundRect(image, null, x, y, w, h, false, false, false); |
| 54 | else { |
| 55 | float radius = (h - w) / 8; |
| 56 | g.drawborderImage(ImageCache.getInstance().borderColor(image), x, y, w, h); |
| 57 | g.drawImage(ImageCache.getInstance().croppedBorderImage(image), x + radius / 2.2f, y + radius / 2, w * 0.96f, h * 0.96f); |
| 58 | } |
| 59 | } else if (Forge.enableUIMask.equals("Crop")) { |
| 60 | g.drawImage(ImageCache.getInstance().croppedBorderImage(image), x, y, w, h); |
| 61 | } else |
| 62 | g.drawImage(image, x, y, w, h); |
| 63 | } |
| 64 | } |
| 65 | } |
nothing calls this directly
no outgoing calls
no test coverage detected