mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Split cards (name contains "//") are now rotated 90 degrees in zoomer.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -14998,6 +14998,7 @@ src/main/java/forge/gui/toolbox/FTextArea.java -text
|
||||
src/main/java/forge/gui/toolbox/FTextField.java -text
|
||||
src/main/java/forge/gui/toolbox/SaveOpenDialog.java -text
|
||||
src/main/java/forge/gui/toolbox/imaging/FImagePanel.java -text
|
||||
src/main/java/forge/gui/toolbox/imaging/FImageUtil.java -text
|
||||
src/main/java/forge/gui/toolbox/imaging/ImageUtil.java -text
|
||||
src/main/java/forge/gui/toolbox/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/toolbox/special/CardViewer.java -text
|
||||
|
||||
@@ -8,6 +8,9 @@ Forge Beta: 0#-##-2013 ver 1.4.6
|
||||
Release Notes
|
||||
-------------
|
||||
|
||||
- Zoomer Updates -
|
||||
Split cards (name contains "//") are now rotated 90 degrees for easier viewing.
|
||||
|
||||
- Home Screen UI Improvements -
|
||||
The menu on the Home Screen is now scrollable using either a mouse wheel or arrow buttons that will appear at the top or bottom if scrolling can occur in that direction
|
||||
The Deck Editor and Exit Forge buttons are now laid out vertically to make it easier to add launch buttons for new screens coming down the pipeline (hint, hint...)
|
||||
|
||||
@@ -25,10 +25,9 @@ import javax.swing.JPanel;
|
||||
|
||||
import forge.Card;
|
||||
import forge.ImageCache;
|
||||
import forge.gui.toolbox.CardFaceSymbols;
|
||||
import forge.gui.toolbox.imaging.FImagePanel;
|
||||
import forge.gui.toolbox.imaging.FImageUtil;
|
||||
import forge.item.InventoryItem;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
/**
|
||||
* Displays image associated with a card or inventory item.
|
||||
@@ -78,31 +77,16 @@ public final class CardPicturePanel extends JPanel {
|
||||
public BufferedImage getImage() {
|
||||
|
||||
BufferedImage image = null;
|
||||
int foilIndex = 0;
|
||||
|
||||
if (displayed instanceof InventoryItem) {
|
||||
InventoryItem item = (InventoryItem) displayed;
|
||||
image = ImageCache.getOriginalImage(ImageCache.getImageKey(item, false), true);
|
||||
|
||||
} else if (displayed instanceof Card) {
|
||||
Card item = (Card) displayed;
|
||||
image = ImageCache.getOriginalImage(item.getImageKey(), true);
|
||||
foilIndex = ((Card)this.displayed).getFoil();
|
||||
image = FImageUtil.getImage((Card)displayed);
|
||||
}
|
||||
|
||||
if (image != null && foilIndex > 0) {
|
||||
image = getFoiledImage(image, foilIndex);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
private BufferedImage getFoiledImage(BufferedImage plainImage, int foilIndex) {
|
||||
ColorModel cm = plainImage.getColorModel();
|
||||
BufferedImage foilImage = new BufferedImage(cm, plainImage.copyData(null), cm.isAlphaPremultiplied(), null);
|
||||
final String fl = String.format("foil%02d", foilIndex);
|
||||
CardFaceSymbols.drawOther(foilImage.getGraphics(), fl, 0, 0, foilImage.getWidth(), foilImage.getHeight());
|
||||
return foilImage;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
64
src/main/java/forge/gui/toolbox/imaging/FImageUtil.java
Normal file
64
src/main/java/forge/gui/toolbox/imaging/FImageUtil.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2013 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package forge.gui.toolbox.imaging;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
import forge.Card;
|
||||
import forge.ImageCache;
|
||||
import forge.gui.toolbox.CardFaceSymbols;
|
||||
|
||||
/**
|
||||
* Common image-related routines specific to Forge images.
|
||||
*
|
||||
* @version $Id:$
|
||||
*
|
||||
*/
|
||||
public final class FImageUtil {
|
||||
private FImageUtil() {}
|
||||
|
||||
/**
|
||||
* Gets the image associated with a card.
|
||||
* <p>
|
||||
* Adds a random foil effect if enabled.
|
||||
* <p>
|
||||
* For double-sided cards, returns the front-side image.<br>
|
||||
* For flip cards, returns the un-flipped image.
|
||||
*/
|
||||
public static BufferedImage getImage(Card card) {
|
||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(), true);
|
||||
int foilIndex = card.getFoil();
|
||||
if (image != null && foilIndex > 0) {
|
||||
image = getImageWithFoilEffect(image, foilIndex);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a foil effect to a card image.
|
||||
*/
|
||||
private static BufferedImage getImageWithFoilEffect(BufferedImage plainImage, int foilIndex) {
|
||||
ColorModel cm = plainImage.getColorModel();
|
||||
BufferedImage foilImage = new BufferedImage(cm, plainImage.copyData(null), cm.isAlphaPremultiplied(), null);
|
||||
final String fl = String.format("foil%02d", foilIndex);
|
||||
CardFaceSymbols.drawOther(foilImage.getGraphics(), fl, 0, 0, foilImage.getWidth(), foilImage.getHeight());
|
||||
return foilImage;
|
||||
}
|
||||
}
|
||||
@@ -21,9 +21,9 @@ package forge.gui.toolbox.imaging;
|
||||
import java.awt.Dimension;
|
||||
|
||||
/**
|
||||
* Useful imaging routines.
|
||||
* Useful general imaging routines.
|
||||
*
|
||||
* @version $Id$
|
||||
* @version $Id:
|
||||
*
|
||||
*/
|
||||
public final class ImageUtil {
|
||||
|
||||
@@ -27,14 +27,17 @@ import java.awt.event.MouseWheelListener;
|
||||
import javax.swing.JPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Card;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.toolbox.FOverlay;
|
||||
import forge.gui.toolbox.imaging.FImagePanel;
|
||||
import forge.gui.toolbox.imaging.FImageUtil;
|
||||
import forge.gui.toolbox.imaging.FImagePanel.AutoSizeImageMode;
|
||||
|
||||
/**
|
||||
* Displays card image BIG.
|
||||
* Displays card image at its original size.
|
||||
*
|
||||
* @version $Id$
|
||||
* @version $Id:
|
||||
*
|
||||
*/
|
||||
public enum CardZoomer {
|
||||
@@ -95,16 +98,26 @@ public enum CardZoomer {
|
||||
thisCard = card;
|
||||
temporary = temp;
|
||||
setLayout();
|
||||
|
||||
CardPicturePanel picturePanel = new CardPicturePanel();
|
||||
picturePanel.setCard(thisCard);
|
||||
picturePanel.setOpaque(false);
|
||||
pnlMain.add(picturePanel, "w 80%!, h 80%!");
|
||||
|
||||
setImage();
|
||||
SOverlayUtils.showOverlay();
|
||||
zoomed = true;
|
||||
}
|
||||
|
||||
|
||||
private void setImage() {
|
||||
FImagePanel imagePanel = new FImagePanel();
|
||||
imagePanel.setImage(FImageUtil.getImage(thisCard), getInitialRotation(), AutoSizeImageMode.SOURCE);
|
||||
pnlMain.add(imagePanel, "w 80%!, h 80%!");
|
||||
}
|
||||
|
||||
private int getInitialRotation() {
|
||||
return (this.isSplitCardImage() ? 90 : 0);
|
||||
}
|
||||
|
||||
private boolean isSplitCardImage() {
|
||||
return (thisCard.getRules().getSplitType() == CardSplitType.Split);
|
||||
}
|
||||
|
||||
|
||||
private void setLayout() {
|
||||
overlay.removeAll();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user