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