mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Support apply foil effect to card images in CardManager Image View
This commit is contained in:
@@ -1062,6 +1062,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
g.setColor(Color.black);
|
||||
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, cornerSize, cornerSize);
|
||||
|
||||
InventoryItem item = itemInfo.item;
|
||||
BufferedImage img = ImageCache.getImage(itemInfo.item, bounds.width - 2 * borderSize, bounds.height - 2 * borderSize);
|
||||
if (img != null) {
|
||||
g.drawImage(img, null, bounds.x + borderSize, bounds.y + borderSize);
|
||||
@@ -1073,6 +1074,12 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
g.drawString(itemInfo.item.getName(), bounds.x + 10, bounds.y + 20);
|
||||
g.setClip(clip);
|
||||
}
|
||||
|
||||
//draw foil effect if needed
|
||||
if (item instanceof IPaperCard) {
|
||||
CardPanel.drawFoilEffect(g, Card.getCardForUi((IPaperCard)item),
|
||||
bounds.x, bounds.y, bounds.width, bounds.height, borderSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public class ForgePreferences extends PreferencesStore<ForgePreferences.FPref> {
|
||||
UI_OVERLAY_CARD_POWER ("true"),
|
||||
UI_OVERLAY_CARD_MANA_COST ("true"),
|
||||
UI_OVERLAY_CARD_ID ("true"),
|
||||
UI_OVERLAY_FOIL_EFFECT ("true"),
|
||||
UI_HIDE_REMINDER_TEXT ("false"),
|
||||
UI_UPLOAD_DRAFT ("false"),
|
||||
UI_SCALE_LARGER ("true"),
|
||||
|
||||
@@ -412,11 +412,17 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
(this.cardYOffset + (this.cardHeight / 2)) - 20);
|
||||
}
|
||||
|
||||
if (card.getFoil() > 0) {
|
||||
final String fl = String.format("foil%02d", card.getFoil());
|
||||
final int z = Math.round(this.cardWidth * CardPanel.BLACK_BORDER_SIZE);
|
||||
CardFaceSymbols.drawOther(g, fl, this.cardXOffset + z, this.cardYOffset + z, this.cardWidth - (2 * z),
|
||||
this.cardHeight - (2 * z));
|
||||
drawFoilEffect(g, card, this.cardXOffset, this.cardYOffset,
|
||||
this.cardWidth, this.cardHeight, Math.round(this.cardWidth * BLACK_BORDER_SIZE));
|
||||
}
|
||||
|
||||
public static void drawFoilEffect(Graphics g, Card card, int x, int y, int width, int height, int borderSize) {
|
||||
if (isPreferenceEnabled(FPref.UI_OVERLAY_FOIL_EFFECT)) {
|
||||
int foil = card.getFoil();
|
||||
if (foil > 0) {
|
||||
CardFaceSymbols.drawOther(g, String.format("foil%02d", foil),
|
||||
x + borderSize, y + borderSize, width - 2 * borderSize, height - 2 * borderSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,7 +787,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
return BLACK_BORDER_SIZE;
|
||||
}
|
||||
|
||||
private boolean isPreferenceEnabled(FPref preferenceName) {
|
||||
private static boolean isPreferenceEnabled(FPref preferenceName) {
|
||||
return Singletons.getModel().getPreferences().getPrefBoolean(preferenceName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user