stronger highlighting for selectable cards

This commit is contained in:
Peter F. Patel-Schneider
2019-01-21 11:40:36 -05:00
parent afd1070850
commit e2ddcdda4d
4 changed files with 31 additions and 10 deletions

View File

@@ -253,6 +253,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
g2d.rotate(getTappedAngle(), cardXOffset + edgeOffset, (cardYOffset + cardHeight)
- edgeOffset);
}
boolean selectable = matchUI.isSelectable(getCard());
if ( titleText!=null ) { // selectable cards have colored names
titleText.setForeground(selectable?Color.cyan:Color.white);
}
// if ( imagePanel != null ) { // if selecting, darken non-selectable cards - needs more refreshing to do right
// imagePanel.setBrightness(selectable?1.0f:(matchUI.isSelecting()?0.5f:1.0f));
//}
super.paint(g2d);
}
@@ -268,25 +275,21 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
// Magenta outline for when card was chosen to pay
// Magenta outline for when card is chosen
if (matchUI.isUsedToPay(getCard())) {
g2d.setColor(Color.magenta);
final int n2 = Math.max(4, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
} else if (matchUI.isSelectable(getCard())) { // Cyan outline for selectable cards
g2d.setColor(Color.cyan);
final int n2 = Math.max(4, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
final int n2 = Math.max(1, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
}
// Green outline for hover
if (isSelected) {
g2d.setColor(Color.green);
final int n = Math.max(4, Math.round(cardWidth * CardPanel.SELECTED_BORDER_SIZE));
final int n = Math.max(1, Math.round(cardWidth * CardPanel.SELECTED_BORDER_SIZE));
g2d.fillRoundRect(cardXOffset - n, (cardYOffset - n) + offset, cardWidth + (n * 2), cardHeight + (n * 2), cornerSize + n , cornerSize + n);
}
// Black fill - (will become outline for white bordered cards)
// Black fill - (will become an outline for white bordered cards)
g2d.setColor(Color.black);
g2d.fillRoundRect(cardXOffset, cardYOffset + offset, cardWidth, cardHeight, cornerSize, cornerSize);
@@ -309,6 +312,13 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
g2d.fillRoundRect(cardXOffset + ins, cardYOffset + ins, cardWidth - ins*2, cardHeight - ins*2, cornerSize-ins, cornerSize-ins);
}
}
if (matchUI.isSelectable(getCard())) { // Replace border for selectable cards
g2d.setColor(Color.cyan);
// final int n2 = Math.max(2, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
g2d.fillRoundRect(cardXOffset, (cardYOffset) + offset, cardWidth, cardHeight, cornerSize, cornerSize);
// g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
}
}
private void drawManaCost(final Graphics g, final ManaCost cost, final int deltaY) {

View File

@@ -20,6 +20,7 @@ package forge.view.arcane;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
/**
* <p>
@@ -37,6 +38,10 @@ public class ScaledImagePanel extends JPanel {
*
*/
private volatile BufferedImage srcImage;
private float brightness = 1.0f;
public void setBrightness(final float bright) {
brightness = bright;
}
/**
* <p>
@@ -127,7 +132,9 @@ public class ScaledImagePanel extends JPanel {
} else {
int x = (sz.width / 2) - (img.getWidth() / 2);
int y = (sz.height / 2) - (img.getHeight() / 2);
g.drawImage(img, x, y, null);
Graphics2D g2d = (Graphics2D) g;
RescaleOp brighten = new RescaleOp(brightness,0,null);
g2d.drawImage(img, brighten, x, y);
}
}

View File

@@ -159,6 +159,7 @@ public interface IGuiGame {
void setUsedToPay(CardView card, boolean value);
void setSelectables(final Iterable<CardView> cards);
void clearSelectables();
boolean isSelecting();
void awaitNextInput();
void cancelAwaitNextInput();

View File

@@ -230,6 +230,9 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
public boolean isSelectable(final CardView card) {
return selectableCards.contains(card);
}
public boolean isSelecting() {
return !selectableCards.isEmpty();
}
/** Concede game, bring up WinLose UI. */
public boolean concede() {