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
* @version V0.0 17.02.2010
*/
public class CardDetailPanel extends FPanel implements CardContainer {
public class CardDetailPanel extends FPanel {
/** Constant <code>serialVersionUID=-8461473263764812323L</code>. */
private static final long serialVersionUID = -8461473263764812323L;
private static Color purple = new Color(14381203);
private Card card;
private final FLabel nameCostLabel;
private final FLabel typeLabel;
private final FLabel powerToughnessLabel;
@@ -157,7 +155,6 @@ public class CardDetailPanel extends FPanel implements CardContainer {
}
/** {@inheritDoc} */
@Override
public final void setCard(final Card card) {
this.nameCostLabel.setText("");
this.typeLabel.setText("");
@@ -170,10 +167,8 @@ public class CardDetailPanel extends FPanel implements CardContainer {
this.cdArea.setText("");
this.setBorder(GuiDisplayUtil.getBorder(card));
this.card = card;
if (card == null) {
if ( null == card )
return;
}
final boolean canShowThis = card.canBeShownTo(Singletons.getControl().getPlayer());
if (canShowThis) {
@@ -508,18 +503,6 @@ public class CardDetailPanel extends FPanel implements CardContainer {
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 */
public JLabel getNameCostLabel() {
return this.nameCostLabel;

View File

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

View File

@@ -47,7 +47,6 @@ import com.google.common.primitives.Ints;
import forge.Card;
import forge.deck.DeckBase;
import forge.gui.CardContainer;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
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>
*/
public enum CDeckEditorUI implements CardContainer {
public enum CDeckEditorUI {
/** */
SINGLETON_INSTANCE;
@@ -83,17 +82,11 @@ public enum CDeckEditorUI implements CardContainer {
//========== Overridden from CardContainer
@Override
public void setCard(final Card c) {
CDetail.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.
* @param item

View File

@@ -31,7 +31,6 @@ import forge.GameEntity;
import forge.Singletons;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.gui.CardContainer;
import forge.gui.framework.EDocID;
import forge.gui.match.controllers.CDetail;
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>
*/
public enum CMatchUI implements CardContainer {
public enum CMatchUI {
/** */
SINGLETON_INSTANCE;
@@ -125,7 +124,7 @@ public enum CMatchUI implements CardContainer {
newHand.getLayoutControl().initialize();
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++) {
// switch (i) {
// hands.add(i, new VHand(EDocID.valueOf("HAND_" + i), null));
@@ -234,7 +233,6 @@ public enum CMatchUI implements CardContainer {
return true;
}
@Override
public void setCard(final Card c) {
CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c);
@@ -244,9 +242,4 @@ public enum CMatchUI implements CardContainer {
CDetail.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;
private Card currentCard = null;
//private InventoryItem item = null;
/**
* Shows card details and/or picture in sidebar cardview tabber.
*
* @param c &emsp; Card object
*/
public void showCard(final Card c) {
//this.item = null;
this.currentCard = c;
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c != null && c.isDoubleFaced());
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
}
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.getPnlDetail().setCard(null);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
}
/**
* Gets the current card.
*
* @return Card
*/
public Card getCurrentCard() {
return this.currentCard;
}
/* (non-Javadoc)
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
*/
@@ -86,11 +69,7 @@ public enum CDetail implements ICDoc {
VDetail.SINGLETON_INSTANCE.getPnlDetail().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (VDetail.SINGLETON_INSTANCE.getPnlDetail().getCard() == null) { return; }
if (VDetail.SINGLETON_INSTANCE.getPnlDetail().getCard().isDoubleFaced()) {
CPicture.SINGLETON_INSTANCE.flipCard();
}
CPicture.SINGLETON_INSTANCE.flipCard();
}
});
}

View File

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