From 0ea9d33211299d3dee998296875c76b55664beb8 Mon Sep 17 00:00:00 2001 From: Mark Langen Date: Tue, 6 Sep 2016 18:15:37 -0600 Subject: [PATCH] Fixed card highlighting * Changed CardPanelRenderImpl to correctly invalidate its render when its panel has its isChoosable / isSelected override set. Before things like selecting cards in a draft view would not visibly have an effect as the render wasn't invalidated. --- .../mage/card/arcane/CardPanelRenderImpl.java | 18 ++++++++++++++++++ .../mage/card/arcane/ModernCardRenderer.java | 13 ++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderImpl.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderImpl.java index e84d2aec7c..43a467d92f 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderImpl.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderImpl.java @@ -377,6 +377,24 @@ public class CardPanelRenderImpl extends CardPanel { return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename)); } } + + @Override + public void setSelected(boolean selected) { + if (selected != isSelected()) { + super.setSelected(selected); + // Invalidate our render + cardImage = null; + } + } + + @Override + public void setChoosable(boolean choosable) { + if (choosable != isChoosable()) { + super.setChoosable(choosable); + // Invalidate our render + cardImage = null; + } + } @Override public Image getImage() { diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java index 82f3bb7140..9f9fbec7f4 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/ModernCardRenderer.java @@ -227,10 +227,6 @@ public class ModernCardRenderer extends CardRenderer { @Override protected void drawBorder(Graphics2D g) { - // Draw border as one rounded rectangle - g.setColor(Color.black); - g.fillRoundRect(0, 0, cardWidth, cardHeight, cornerRadius, cornerRadius); - // Selection Borders Color borderColor; if (isSelected) { @@ -242,8 +238,14 @@ public class ModernCardRenderer extends CardRenderer { } else if (cardView instanceof PermanentView && ((PermanentView) cardView).isCanAttack()) { borderColor = new Color(0, 0, 255, 230); } else { - borderColor = null; + borderColor = Color.BLACK; } + + // Draw border as one rounded rectangle + g.setColor(borderColor); + g.fillRoundRect(0, 0, cardWidth, cardHeight, cornerRadius, cornerRadius); + + /* // Separate selection highlight border from card itself. Not used right now if (borderColor != null) { float hwidth = borderWidth / 2.0f; Graphics2D g2 = (Graphics2D) g.create(); @@ -257,6 +259,7 @@ public class ModernCardRenderer extends CardRenderer { g2.draw(rect); g2.dispose(); } + */ } @Override