Flip button in CardDetailPanel no longer flips the card ingame

This commit is contained in:
Maxmtg
2013-02-24 08:17:57 +00:00
parent 372d293d7c
commit 4ba9901958
7 changed files with 22 additions and 71 deletions

View File

@@ -52,14 +52,12 @@ import forge.gui.toolbox.FTextArea;
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 17.02.2010 * @version V0.0 17.02.2010
*/ */
public class CardDetailPanel extends FPanel implements CardContainer { public class CardDetailPanel extends FPanel {
/** Constant <code>serialVersionUID=-8461473263764812323L</code>. */ /** Constant <code>serialVersionUID=-8461473263764812323L</code>. */
private static final long serialVersionUID = -8461473263764812323L; private static final long serialVersionUID = -8461473263764812323L;
private static Color purple = new Color(14381203); private static Color purple = new Color(14381203);
private Card card;
private final FLabel nameCostLabel; private final FLabel nameCostLabel;
private final FLabel typeLabel; private final FLabel typeLabel;
private final FLabel powerToughnessLabel; private final FLabel powerToughnessLabel;
@@ -157,7 +155,6 @@ public class CardDetailPanel extends FPanel implements CardContainer {
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public final void setCard(final Card card) { public final void setCard(final Card card) {
this.nameCostLabel.setText(""); this.nameCostLabel.setText("");
this.typeLabel.setText(""); this.typeLabel.setText("");
@@ -170,10 +167,8 @@ public class CardDetailPanel extends FPanel implements CardContainer {
this.cdArea.setText(""); this.cdArea.setText("");
this.setBorder(GuiDisplayUtil.getBorder(card)); this.setBorder(GuiDisplayUtil.getBorder(card));
this.card = card; if ( null == card )
if (card == null) {
return; return;
}
final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer()); final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer());
if (canShowThis) { if (canShowThis) {
@@ -508,18 +503,6 @@ public class CardDetailPanel extends FPanel implements CardContainer {
return area.toString(); return area.toString();
} }
/**
* <p>
* Getter for the field <code>card</code>.
* </p>
*
* @return a {@link forge.Card} object.
*/
@Override
public final Card getCard() {
return this.card;
}
/** @return JLabel */ /** @return JLabel */
public JLabel getNameCostLabel() { public JLabel getNameCostLabel() {
return this.nameCostLabel; return this.nameCostLabel;

View File

@@ -102,7 +102,6 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
} }
} }
@Override
public Card getCard() { public Card getCard() {
if ( displayed instanceof Card ) if ( displayed instanceof Card )
return (Card)displayed; return (Card)displayed;

View File

@@ -47,7 +47,6 @@ import com.google.common.primitives.Ints;
import forge.Card; import forge.Card;
import forge.deck.DeckBase; import forge.deck.DeckBase;
import forge.gui.CardContainer;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.gui.deckeditor.SEditorIO.EditorPreference; import forge.gui.deckeditor.SEditorIO.EditorPreference;
import forge.gui.deckeditor.controllers.ACEditorBase; import forge.gui.deckeditor.controllers.ACEditorBase;
@@ -71,7 +70,7 @@ import forge.item.InventoryItem;
* *
* <br><br><i>(C at beginning of class name denotes a control class.)</i> * <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/ */
public enum CDeckEditorUI implements CardContainer { public enum CDeckEditorUI {
/** */ /** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
@@ -83,17 +82,11 @@ public enum CDeckEditorUI implements CardContainer {
//========== Overridden from CardContainer //========== Overridden from CardContainer
@Override
public void setCard(final Card c) { public void setCard(final Card c) {
CDetail.SINGLETON_INSTANCE.showCard(c); CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c); CPicture.SINGLETON_INSTANCE.showCard(c);
} }
@Override
public Card getCard() {
return CDetail.SINGLETON_INSTANCE.getCurrentCard();
}
/** /**
* Set Pack, for when Packs can be shown in the CardPicturePanel. * Set Pack, for when Packs can be shown in the CardPicturePanel.
* @param item * @param item

View File

@@ -31,7 +31,6 @@ import forge.GameEntity;
import forge.Singletons; import forge.Singletons;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
import forge.game.player.Player; import forge.game.player.Player;
import forge.gui.CardContainer;
import forge.gui.framework.EDocID; import forge.gui.framework.EDocID;
import forge.gui.match.controllers.CDetail; import forge.gui.match.controllers.CDetail;
import forge.gui.match.controllers.CMessage; import forge.gui.match.controllers.CMessage;
@@ -54,7 +53,7 @@ import forge.properties.NewConstants;
* *
* <br><br><i>(C at beginning of class name denotes a control class.)</i> * <br><br><i>(C at beginning of class name denotes a control class.)</i>
*/ */
public enum CMatchUI implements CardContainer { public enum CMatchUI {
/** */ /** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
@@ -125,7 +124,7 @@ public enum CMatchUI implements CardContainer {
newHand.getLayoutControl().initialize(); newHand.getLayoutControl().initialize();
hands.add(newHand); hands.add(newHand);
// Max: 2+ hand are needed at 2HG (but this is quite far now) - yet it's nice to have this possibility // Max: 2+ hands are needed at 2HG (but this is quite far from now) - yet it's nice to have this possibility
// for (int i = 0; i < numHandPanels; i++) { // for (int i = 0; i < numHandPanels; i++) {
// switch (i) { // switch (i) {
// hands.add(i, new VHand(EDocID.valueOf("HAND_" + i), null)); // hands.add(i, new VHand(EDocID.valueOf("HAND_" + i), null));
@@ -234,7 +233,6 @@ public enum CMatchUI implements CardContainer {
return true; return true;
} }
@Override
public void setCard(final Card c) { public void setCard(final Card c) {
CDetail.SINGLETON_INSTANCE.showCard(c); CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c); CPicture.SINGLETON_INSTANCE.showCard(c);
@@ -244,9 +242,4 @@ public enum CMatchUI implements CardContainer {
CDetail.SINGLETON_INSTANCE.showCard(c); CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c); CPicture.SINGLETON_INSTANCE.showCard(c);
} }
@Override
public Card getCard() {
return CDetail.SINGLETON_INSTANCE.getCurrentCard();
}
} }

View File

@@ -36,40 +36,23 @@ public enum CDetail implements ICDoc {
/** */ /** */
SINGLETON_INSTANCE; SINGLETON_INSTANCE;
private Card currentCard = null;
//private InventoryItem item = null;
/** /**
* Shows card details and/or picture in sidebar cardview tabber. * Shows card details and/or picture in sidebar cardview tabber.
* *
* @param c &emsp; Card object * @param c &emsp; Card object
*/ */
public void showCard(final Card c) { public void showCard(final Card c) {
//this.item = null;
this.currentCard = c;
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c != null && c.isDoubleFaced()); VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c != null && c.isDoubleFaced());
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c); VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf(); VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
} }
public void showCard(InventoryItem item) { public void showCard(InventoryItem item) {
// TODO If we want to display an Items Written Text in the Detail Panel we need to add something into CardDetailPanel
//this.item = item;
this.currentCard = null;
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(false); VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(false);
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(null); VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(null);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf(); VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
} }
/**
* Gets the current card.
*
* @return Card
*/
public Card getCurrentCard() {
return this.currentCard;
}
/* (non-Javadoc) /* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect() * @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/ */
@@ -86,11 +69,7 @@ public enum CDetail implements ICDoc {
VDetail.SINGLETON_INSTANCE.getPnlDetail().addMouseListener(new MouseAdapter() { VDetail.SINGLETON_INSTANCE.getPnlDetail().addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(final MouseEvent e) { public void mouseClicked(final MouseEvent e) {
if (VDetail.SINGLETON_INSTANCE.getPnlDetail().getCard() == null) { return; } CPicture.SINGLETON_INSTANCE.flipCard();
if (VDetail.SINGLETON_INSTANCE.getPnlDetail().getCard().isDoubleFaced()) {
CPicture.SINGLETON_INSTANCE.flipCard();
}
} }
}); });
} }

View File

@@ -45,8 +45,10 @@ public enum CPicture implements ICDoc {
* &emsp; Card object * &emsp; Card object
*/ */
public void showCard(final Card c) { public void showCard(final Card c) {
boolean canFlip = c != null && c.isDoubleFaced();
this.currentCard = c; this.currentCard = c;
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c != null && c.isDoubleFaced() ? true : false); flipped = canFlip && c.getCurState() == CardCharacteristicName.Transformed;
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(canFlip);
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c); VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
} }
@@ -99,16 +101,19 @@ public enum CPicture implements ICDoc {
/** */ /** */
public void flipCard() { public void flipCard() {
if (flipped) { flipped = !flipped;
flipped = false; Card cd = VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard();
VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard().setState(CardCharacteristicName.Original); if ( null == cd ) return;
CDetail.SINGLETON_INSTANCE.showCard(this.currentCard);
} CardCharacteristicName newState = flipped && cd.isDoubleFaced() ? CardCharacteristicName.Transformed : CardCharacteristicName.Original;
else { CardCharacteristicName oldState = cd.getCurState();
flipped = true; if ( oldState != newState ) {
VPicture.SINGLETON_INSTANCE.getPnlPicture().getCard().setState(CardCharacteristicName.Transformed); cd.setState(newState);
CDetail.SINGLETON_INSTANCE.showCard(this.currentCard);
} }
CDetail.SINGLETON_INSTANCE.showCard(this.currentCard);
VPicture.SINGLETON_INSTANCE.getPnlPicture().setImage(); VPicture.SINGLETON_INSTANCE.getPnlPicture().setImage();
if ( oldState != newState ) {
cd.setState(oldState);
}
} }
} }

View File

@@ -612,7 +612,6 @@ public class CardPanel extends JPanel implements CardContainer {
* *
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
@Override
public final Card getCard() { public final Card getCard() {
return this.getGameCard(); return this.getGameCard();
} }