mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
make flippable cards flippable in VPicture and VDetail
This commit is contained in:
@@ -234,7 +234,7 @@ public class CardFactory {
|
|||||||
if (c.hasAlternateState()) {
|
if (c.hasAlternateState()) {
|
||||||
if (c.isFlipCard()) {
|
if (c.isFlipCard()) {
|
||||||
c.setState(CardCharacteristicName.Flipped);
|
c.setState(CardCharacteristicName.Flipped);
|
||||||
c.setImageKey(originalPicture); // should assign a 180 degrees rotated picture here?
|
c.setImageKey(ImageCache.getImageKey(cp, true));
|
||||||
}
|
}
|
||||||
else if (c.isDoubleFaced() && cp instanceof CardPrinted) {
|
else if (c.isDoubleFaced() && cp instanceof CardPrinted) {
|
||||||
c.setState(CardCharacteristicName.Transformed);
|
c.setState(CardCharacteristicName.Transformed);
|
||||||
|
|||||||
@@ -29,13 +29,11 @@ import forge.item.InventoryItem;
|
|||||||
import forge.item.InventoryItemFromSet;
|
import forge.item.InventoryItemFromSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Controls the card detail area in the match UI.
|
* Controls the card detail area in the match UI.
|
||||||
*
|
*
|
||||||
* <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 CDetail implements ICDoc {
|
public enum CDetail implements ICDoc {
|
||||||
/** */
|
|
||||||
SINGLETON_INSTANCE;
|
SINGLETON_INSTANCE;
|
||||||
|
|
||||||
private VDetail view = VDetail.SINGLETON_INSTANCE;
|
private VDetail view = VDetail.SINGLETON_INSTANCE;
|
||||||
@@ -46,7 +44,7 @@ public enum CDetail implements ICDoc {
|
|||||||
* @param c   Card object
|
* @param c   Card object
|
||||||
*/
|
*/
|
||||||
public void showCard(final Card c) {
|
public void showCard(final Card c) {
|
||||||
view.getLblFlipcard().setVisible(c != null && c.isDoubleFaced());
|
view.getLblFlipcard().setVisible(c != null && (c.isDoubleFaced() || c.isFlipCard()));
|
||||||
view.getPnlDetail().setCard(c);
|
view.getPnlDetail().setCard(c);
|
||||||
view.getParentCell().repaintSelf();
|
view.getParentCell().repaintSelf();
|
||||||
}
|
}
|
||||||
@@ -63,17 +61,11 @@ public enum CDetail implements ICDoc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Command getCommandOnSelect() {
|
public Command getCommandOnSelect() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#initialize()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
view.getPnlDetail().addMouseListener(new MouseAdapter() {
|
view.getPnlDetail().addMouseListener(new MouseAdapter() {
|
||||||
@@ -84,9 +76,6 @@ public enum CDetail implements ICDoc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#update()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ 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 CPicture implements ICDoc {
|
public enum CPicture implements ICDoc {
|
||||||
/** */
|
|
||||||
SINGLETON_INSTANCE;
|
SINGLETON_INSTANCE;
|
||||||
|
|
||||||
private Card currentCard = null;
|
private Card currentCard = null;
|
||||||
private boolean flipped = false;
|
private boolean flipped = false;
|
||||||
|
private boolean canFlip = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows card details and/or picture in sidebar cardview tabber.
|
* Shows card details and/or picture in sidebar cardview tabber.
|
||||||
@@ -46,15 +46,16 @@ public enum CPicture implements ICDoc {
|
|||||||
*   Card object
|
*   Card object
|
||||||
*/
|
*/
|
||||||
public void showCard(final Card c) {
|
public void showCard(final Card c) {
|
||||||
boolean canFlip = c != null && c.isDoubleFaced();
|
canFlip = c != null && (c.isDoubleFaced() || c.isFlipCard());
|
||||||
this.currentCard = c;
|
this.currentCard = c;
|
||||||
flipped = canFlip && c.getCurState() == CardCharacteristicName.Transformed;
|
flipped = canFlip && (c.getCurState() == CardCharacteristicName.Transformed ||
|
||||||
|
c.getCurState() == CardCharacteristicName.Flipped);
|
||||||
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(canFlip);
|
VPicture.SINGLETON_INSTANCE.getLblFlipcard().setVisible(canFlip);
|
||||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
|
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showCard(final InventoryItem item) {
|
public void showCard(final InventoryItem item) {
|
||||||
if ( item instanceof IPaperCard ) {
|
if (item instanceof IPaperCard) {
|
||||||
showCard(((IPaperCard)item).getMatchingForgeCard());
|
showCard(((IPaperCard)item).getMatchingForgeCard());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -64,26 +65,15 @@ public enum CPicture implements ICDoc {
|
|||||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(item);
|
VPicture.SINGLETON_INSTANCE.getPnlPicture().setCard(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current card.
|
|
||||||
*
|
|
||||||
* @return Card
|
|
||||||
*/
|
|
||||||
public Card getCurrentCard() {
|
public Card getCurrentCard() {
|
||||||
return this.currentCard;
|
return this.currentCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Command getCommandOnSelect() {
|
public Command getCommandOnSelect() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#initialize()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
VPicture.SINGLETON_INSTANCE.getPnlPicture().addMouseListener(new MouseAdapter() {
|
VPicture.SINGLETON_INSTANCE.getPnlPicture().addMouseListener(new MouseAdapter() {
|
||||||
@@ -94,26 +84,36 @@ public enum CPicture implements ICDoc {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see forge.gui.framework.ICDoc#update()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** */
|
|
||||||
public void flipCard() {
|
public void flipCard() {
|
||||||
flipped = !flipped;
|
if (!canFlip || null == currentCard) { return; }
|
||||||
if ( null == currentCard ) return;
|
|
||||||
|
|
||||||
CardCharacteristicName newState = flipped && currentCard.isDoubleFaced() ? CardCharacteristicName.Transformed : CardCharacteristicName.Original;
|
flipped = !flipped;
|
||||||
|
|
||||||
|
final CardCharacteristicName newState;
|
||||||
|
if (flipped) {
|
||||||
|
if (currentCard.isDoubleFaced()) {
|
||||||
|
newState = CardCharacteristicName.Transformed;
|
||||||
|
} else if (currentCard.isFlipCard()) {
|
||||||
|
newState = CardCharacteristicName.Flipped;
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("unhandled flippable card");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newState = CardCharacteristicName.Original;
|
||||||
|
}
|
||||||
|
|
||||||
CardCharacteristicName oldState = currentCard.getCurState();
|
CardCharacteristicName oldState = currentCard.getCurState();
|
||||||
if ( oldState != newState ) {
|
if (oldState != newState) {
|
||||||
currentCard.setState(newState);
|
currentCard.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 ) {
|
if (oldState != newState) {
|
||||||
currentCard.setState(oldState);
|
currentCard.setState(oldState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user