revert 20668

set Morphs visible to player flippable on CPicture and CDetail
If you mouse over a card with SHIFT pressed, MatchUI will attempt to show you the other side of a card.
This commit is contained in:
Maxmtg
2013-03-29 21:17:52 +00:00
parent 780ed417c7
commit 66afdd9c22
9 changed files with 32 additions and 34 deletions

View File

@@ -8426,14 +8426,6 @@ public class Card extends GameEntity implements Comparable<Card> {
public final String getImageKey() {
return this.getCharacteristics().getImageKey();
}
public final String getImageKey(CardCharacteristicName state) {
CardCharacteristics characteristics = characteristicsMap.get(state);
if (null == characteristics) {
return null;
}
return characteristics.getImageKey();
}
/**
* <p>

View File

@@ -99,29 +99,21 @@ public class ImageCache {
}
/**
* retrieve an image from the cache. returns a default image if the image is not found in the cache
* retrieve an image from the cache. returns null if the image is not found in the cache
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
*/
public static BufferedImage getImage(Card card, int width, int height) {
return getImage(card, width, height, false);
}
/**
* retrieve an image from the cache. returns a default image if the image is not found in the cache
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
*/
public static BufferedImage getImage(Card card, int width, int height, boolean ignoreFaceDown) {
final String key;
if (!card.canBeShownTo(Singletons.getControl().getPlayer()) || (!ignoreFaceDown && card.isFaceDown())) {
if (!card.canBeShownTo(Singletons.getControl().getPlayer()) || card.isFaceDown()) {
key = TOKEN_PREFIX + NewConstants.CACHE_MORPH_IMAGE_FILE;
} else {
key = ignoreFaceDown ? card.getImageKey(CardCharacteristicName.Original) : card.getImageKey();
key = card.getImageKey();
}
return scaleImage(key, width, height, true);
}
/**
* retrieve an image from the cache. returns a default image if the image is not found in the cache
* retrieve an image from the cache. returns null if the image is not found in the cache
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
*/
public static BufferedImage getImage(InventoryItem ii, int width, int height) {

View File

@@ -63,7 +63,6 @@ import forge.card.spellability.Target;
import forge.card.trigger.Trigger;
import forge.card.trigger.TriggerHandler;
import forge.card.trigger.TriggerType;
import forge.control.input.InputBase;
import forge.control.input.InputSelectCards;
import forge.control.input.InputSelectCardsFromList;
import forge.game.GameState;
@@ -78,9 +77,7 @@ import forge.game.zone.PlayerZone;
import forge.game.zone.Zone;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
import forge.gui.match.CMatchUI;
import forge.util.Aggregates;
import forge.view.ButtonUtil;
/**
* <p>

View File

@@ -86,9 +86,9 @@ public final class CardPicturePanel extends JPanel {
if (displayed instanceof InventoryItem) {
image = ImageCache.getImage((InventoryItem)this.displayed, this.getWidth() - i.left - i.right, this.getHeight()
- i.top - i.bottom);
} else if (displayed instanceof Card) {
image = ImageCache.getImage((Card)this.displayed,
this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top - i.bottom - 2, true);
} else if ( displayed instanceof Card ) {
image = ImageCache.getImage((Card)this.displayed, this.getWidth() - i.left - i.right - 2, this.getHeight() - i.top
- i.bottom - 2);
}
if (image != this.currentImage) {

View File

@@ -236,8 +236,12 @@ public enum CMatchUI {
}
public void setCard(final Card c) {
setCard(c, false);
}
public void setCard(final Card c, final boolean showFlipped ) {
CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c, showFlipped);
}
public void setCard(final InventoryItem c) {

View File

@@ -22,6 +22,7 @@ import java.awt.event.MouseEvent;
import forge.Card;
import forge.Command;
import forge.Singletons;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VDetail;
import forge.item.IPaperCard;
@@ -44,7 +45,7 @@ public enum CDetail implements ICDoc {
* @param c &emsp; Card object
*/
public void showCard(final Card c) {
view.getLblFlipcard().setVisible(c != null && (c.isDoubleFaced() || c.isFlipCard()));
view.getLblFlipcard().setVisible(c != null && (c.isDoubleFaced() || c.isFlipCard() || c.isFaceDown() && c.canBeShownTo(Singletons.getControl().getPlayer())));
view.getPnlDetail().setCard(c);
view.getParentCell().repaintSelf();
}

View File

@@ -22,6 +22,7 @@ import java.awt.event.MouseEvent;
import forge.Card;
import forge.CardCharacteristicName;
import forge.Command;
import forge.Singletons;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VPicture;
import forge.item.IPaperCard;
@@ -38,6 +39,7 @@ public enum CPicture implements ICDoc {
private Card currentCard = null;
private boolean flipped = false;
private boolean canFlip = false;
private boolean cameFaceDown = false;
/**
* Shows card details and/or picture in sidebar cardview tabber.
@@ -45,18 +47,22 @@ public enum CPicture implements ICDoc {
* @param c
* &emsp; Card object
*/
public void showCard(final Card c) {
canFlip = c != null && (c.isDoubleFaced() || c.isFlipCard());
public void showCard(final Card c, boolean showFlipped) {
cameFaceDown = c.isFaceDown() && c.canBeShownTo(Singletons.getControl().getPlayer());
canFlip = c != null && (c.isDoubleFaced() || c.isFlipCard() || cameFaceDown);
currentCard = c;
flipped = canFlip && (c.getCurState() == CardCharacteristicName.Transformed ||
c.getCurState() == CardCharacteristicName.Flipped);
c.getCurState() == CardCharacteristicName.Flipped || c.getCurState() == CardCharacteristicName.FaceDown);
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(canFlip);
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
if ( showFlipped && canFlip )
flipCard();
}
public void showCard(final InventoryItem item) {
if (item instanceof IPaperCard) {
showCard(((IPaperCard)item).getMatchingForgeCard());
showCard(((IPaperCard)item).getMatchingForgeCard(), false);
return;
}
@@ -101,6 +107,8 @@ public enum CPicture implements ICDoc {
newState = CardCharacteristicName.Transformed;
} else if (currentCard.isFlipCard()) {
newState = CardCharacteristicName.Flipped;
} else if ( cameFaceDown ) {
newState = CardCharacteristicName.FaceDown;
} else {
// if this is hit, then then showCard has been modified to handle additional types, but
// this function is missing an else if statement above

View File

@@ -17,6 +17,7 @@
*/
package forge.gui.match.nonsingleton;
import java.awt.Event;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@@ -99,9 +100,10 @@ public class CCommand implements ICDoc {
/** */
private void cardoverAction(MouseEvent e) {
boolean isShiftDown = (e.getModifiers() & Event.SHIFT_MASK) != 0;
final Card c = CCommand.this.view.getTabletop().getHoveredCard(e);
if (c != null) {
CMatchUI.SINGLETON_INSTANCE.setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c, isShiftDown);
}
}

View File

@@ -17,6 +17,7 @@
*/
package forge.gui.match.nonsingleton;
import java.awt.Event;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -375,9 +376,10 @@ public class CField implements ICDoc {
/** */
private void cardoverAction(MouseEvent e) {
boolean isShiftDown = (e.getModifiers() & Event.SHIFT_MASK) != 0;
final Card c = CField.this.view.getTabletop().getHoveredCard(e);
if (c != null) {
CMatchUI.SINGLETON_INSTANCE.setCard(c);
CMatchUI.SINGLETON_INSTANCE.setCard(c, isShiftDown);
}
}