Deckeditor-related classes operate with paper cards.

CDetail and CPicture convert paper cards to in-game card by themselves if possible & if needed
This commit is contained in:
Maxmtg
2013-02-24 08:49:52 +00:00
parent 2712ebeec0
commit 299e69826b
5 changed files with 26 additions and 30 deletions

View File

@@ -45,7 +45,6 @@ import org.apache.commons.lang.StringUtils;
import com.google.common.primitives.Ints;
import forge.Card;
import forge.deck.DeckBase;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.SEditorIO.EditorPreference;
@@ -80,13 +79,6 @@ public enum CDeckEditorUI {
private CDeckEditorUI() {
}
//========== Overridden from CardContainer
public void setCard(final Card c) {
CDetail.SINGLETON_INSTANCE.showCard(c);
CPicture.SINGLETON_INSTANCE.showCard(c);
}
/**
* Set Pack, for when Packs can be shown in the CardPicturePanel.
* @param item

View File

@@ -42,13 +42,10 @@ import javax.swing.table.TableColumnModel;
import org.apache.commons.lang3.ArrayUtils;
import forge.Card;
import forge.gui.deckeditor.CDeckEditorUI;
import forge.gui.deckeditor.SEditorIO;
import forge.gui.deckeditor.tables.SColumnUtil.ColumnName;
import forge.gui.deckeditor.tables.SColumnUtil.SortState;
import forge.item.CardPrinted;
import forge.item.IPaperCard;
import forge.item.InventoryItem;
import forge.item.ItemPool;
import forge.item.ItemPoolView;
@@ -193,17 +190,7 @@ public final class EditorTableModel<T extends InventoryItem> extends AbstractTab
final int row = table.getSelectedRow();
if (row != -1) {
Entry<T, Integer> card = this.rowToCard(row);
if (null != card) {
T cp = card.getKey();
if (cp instanceof CardPrinted) {
CDeckEditorUI.SINGLETON_INSTANCE.setCard(((IPaperCard) cp).getMatchingForgeCard());
}
else {
CDeckEditorUI.SINGLETON_INSTANCE.setCard(cp);
}
} else {
CDeckEditorUI.SINGLETON_INSTANCE.setCard((Card)null);
}
CDeckEditorUI.SINGLETON_INSTANCE.setCard(null != card ? card.getKey() : null);
}
}

View File

@@ -179,7 +179,7 @@ public enum VProbabilities implements IVDoc<CProbabilities> {
if (name2.length() > name1.length()) { continue; }
if (name2.equals(name1.substring(0, name2.length()))) {
CDeckEditorUI.SINGLETON_INSTANCE.setCard(c.getMatchingForgeCard());
CDeckEditorUI.SINGLETON_INSTANCE.setCard(c);
break;
}
}

View File

@@ -24,6 +24,7 @@ import forge.Card;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VDetail;
import forge.item.IPaperCard;
import forge.item.InventoryItem;
/**
@@ -36,21 +37,31 @@ public enum CDetail implements ICDoc {
/** */
SINGLETON_INSTANCE;
private VDetail view = VDetail.SINGLETON_INSTANCE;
//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) {
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(c != null && c.isDoubleFaced());
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(c);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
view.getLblFlipcard().setVisible(c != null && c.isDoubleFaced());
view.getPnlDetail().setCard(c);
view.getParentCell().repaintSelf();
}
public void showCard(InventoryItem item) {
VDetail.SINGLETON_INSTANCE.getLblFlipcard().setVisible(false);
VDetail.SINGLETON_INSTANCE.getPnlDetail().setCard(null);
VDetail.SINGLETON_INSTANCE.getParentCell().repaintSelf();
if ( item instanceof IPaperCard ) {
showCard(((IPaperCard)item).getMatchingForgeCard());
return;
}
// TODO If we want to display an Items Written Text in the Detail Panel we need to add something into CardDetailPanel
//this.item = item;
view.getLblFlipcard().setVisible(false);
view.getPnlDetail().setCard(null);
view.getParentCell().repaintSelf();
}
/* (non-Javadoc)
@@ -66,7 +77,7 @@ public enum CDetail implements ICDoc {
*/
@Override
public void initialize() {
VDetail.SINGLETON_INSTANCE.getPnlDetail().addMouseListener(new MouseAdapter() {
view.getPnlDetail().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
CPicture.SINGLETON_INSTANCE.flipCard();

View File

@@ -24,6 +24,7 @@ import forge.CardCharacteristicName;
import forge.Command;
import forge.gui.framework.ICDoc;
import forge.gui.match.views.VPicture;
import forge.item.IPaperCard;
import forge.item.InventoryItem;
/**
@@ -53,6 +54,11 @@ public enum CPicture implements ICDoc {
}
public void showCard(final InventoryItem item) {
if ( item instanceof IPaperCard ) {
showCard(((IPaperCard)item).getMatchingForgeCard());
return;
}
this.currentCard = null;
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(false);
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(item);