mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Prevent being able to see certain cards when modal opened
This commit is contained in:
@@ -58,7 +58,6 @@ import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.io.QuestDataIO;
|
||||
import forge.sound.SoundSystem;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.FFrame;
|
||||
import forge.view.FView;
|
||||
|
||||
@@ -364,8 +363,8 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean mayShowCard(Card c) { //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
return game == null || !gameHasHumanPlayer || FDialog.isModalOpen() || c.canBeShownTo(getCurrentPlayer());
|
||||
public boolean mayShowCard(Card c) {
|
||||
return game == null || !gameHasHumanPlayer || c.canBeShownTo(getCurrentPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,6 +36,8 @@ import forge.item.InventoryItemFromSet;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.util.Lang;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -192,7 +194,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.typeLabel.setText("Creature");
|
||||
}
|
||||
}
|
||||
else if (Singletons.getControl().mayShowCard(card)) {
|
||||
else if (Singletons.getControl().mayShowCard(card) || FDialog.isModalOpen()) { //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
canShowThis = true;
|
||||
|
||||
if (card.getManaCost().isNoCost()) {
|
||||
|
||||
@@ -47,6 +47,7 @@ public final class CardPicturePanel extends JPanel {
|
||||
|
||||
private final FImagePanel panel;
|
||||
private BufferedImage currentImage;
|
||||
private boolean mayShowCard;
|
||||
|
||||
public CardPicturePanel() {
|
||||
super(new BorderLayout());
|
||||
@@ -57,12 +58,14 @@ public final class CardPicturePanel extends JPanel {
|
||||
|
||||
public void setCard(final InventoryItem cp) {
|
||||
this.displayed = cp;
|
||||
this.mayShowCard = true;
|
||||
this.setImage();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setCard(final Card c) {
|
||||
public void setCard(final Card c, boolean mayShowCard) {
|
||||
this.displayed = c;
|
||||
this.mayShowCard = mayShowCard;
|
||||
this.setImage();
|
||||
}
|
||||
|
||||
@@ -83,17 +86,17 @@ public final class CardPicturePanel extends JPanel {
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
BufferedImage image = null;
|
||||
|
||||
if (displayed instanceof InventoryItem) {
|
||||
InventoryItem item = (InventoryItem) displayed;
|
||||
image = ImageCache.getOriginalImage(ImageKeys.getImageKey(item, false), true);
|
||||
|
||||
} else if (displayed instanceof Card) {
|
||||
image = FImageUtil.getImage((Card)displayed);
|
||||
return ImageCache.getOriginalImage(ImageKeys.getImageKey(item, false), true);
|
||||
}
|
||||
|
||||
return image;
|
||||
else if (displayed instanceof Card) {
|
||||
if (mayShowCard) {
|
||||
return FImageUtil.getImage((Card)displayed);
|
||||
}
|
||||
return ImageCache.getOriginalImage(ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private AutoSizeImageMode getAutoSizeImageMode() {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FDeckViewer extends FDialog {
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
cardPicture.setCard(card);
|
||||
cardPicture.setCard(card, true);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class FDeckViewer extends FDialog {
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
cardPicture.setCard(card);
|
||||
cardPicture.setCard(card, true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -28,8 +28,10 @@ import forge.gui.toolbox.FMouseAdapter;
|
||||
import forge.gui.toolbox.special.CardZoomer;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
@@ -57,6 +59,12 @@ public enum CPicture implements ICDoc {
|
||||
private Card currentCard = null;
|
||||
private CardCharacteristicName displayedState = CardCharacteristicName.Original;
|
||||
|
||||
private boolean mayShowCurrentCard() {
|
||||
if (currentCard == null) { return false; }
|
||||
if (FDialog.isModalOpen()) { return true; } //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
return Singletons.getControl().mayShowCard(currentCard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
*
|
||||
@@ -70,7 +78,7 @@ public enum CPicture implements ICDoc {
|
||||
displayedState = c.getCurState();
|
||||
boolean isFlippable = isCurrentCardFlippable();
|
||||
flipIndicator.setVisible(isFlippable);
|
||||
picturePanel.setCard(c);
|
||||
picturePanel.setCard(c, mayShowCurrentCard());
|
||||
if (showFlipped && isFlippable) {
|
||||
flipCard();
|
||||
}
|
||||
@@ -196,10 +204,9 @@ public enum CPicture implements ICDoc {
|
||||
}
|
||||
|
||||
private boolean isCurrentCardFlippable() {
|
||||
if (currentCard == null || !Singletons.getControl().mayShowCard(currentCard)) { return false; }
|
||||
if (!mayShowCurrentCard()) { return false; }
|
||||
|
||||
return currentCard.isDoubleFaced() || currentCard.isFlipCard() ||
|
||||
(currentCard.isFaceDown() && isAuthorizedToViewFaceDownCard(currentCard));
|
||||
return currentCard.isDoubleFaced() || currentCard.isFlipCard() || currentCard.isFaceDown();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -156,7 +156,7 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
.fontAlign(SwingConstants.CENTER).build(), "w 160px, h 20px");
|
||||
CardPicturePanel picPanel = new CardPicturePanel();
|
||||
add(picPanel, "w 160px, h 230px");
|
||||
picPanel.setCard(c0);
|
||||
picPanel.setCard(c0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package forge.gui.toolbox.imaging;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.card.Card;
|
||||
@@ -56,9 +55,6 @@ public final class FImageUtil {
|
||||
* For flip cards, returns the un-flipped image.
|
||||
*/
|
||||
public static BufferedImage getImage(Card card) {
|
||||
if (!Singletons.getControl().mayShowCard(card)) {
|
||||
return ImageCache.getOriginalImage(ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE, true);
|
||||
}
|
||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(), true);
|
||||
int foilIndex = card.getFoil();
|
||||
if (image != null && foilIndex > 0) {
|
||||
|
||||
Reference in New Issue
Block a user