mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Fix so canceled spells return to same place in your hand as they were cast from
This commit is contained in:
@@ -87,7 +87,6 @@ public class CHand implements ICDoc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Rectangle rctLibraryLabel = vf.getDetailsPanel().getLblLibrary().getBounds();
|
final Rectangle rctLibraryLabel = vf.getDetailsPanel().getLblLibrary().getBounds();
|
||||||
final List<Card> cc = player.getZone(ZoneType.Hand).getCards();
|
|
||||||
|
|
||||||
// Animation starts from the library label and runs to the hand panel.
|
// Animation starts from the library label and runs to the hand panel.
|
||||||
// This check prevents animation running if label hasn't been realized yet.
|
// This check prevents animation running if label hasn't been realized yet.
|
||||||
@@ -95,24 +94,24 @@ public class CHand implements ICDoc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Card> tmp, diff;
|
//update card panels in hand area
|
||||||
tmp = new ArrayList<Card>();
|
final List<Card> cards = player.getZone(ZoneType.Hand).getCards();
|
||||||
for (final forge.view.arcane.CardPanel cpa : p.getCardPanels()) {
|
final List<CardPanel> placeholders = new ArrayList<CardPanel>();
|
||||||
tmp.add(cpa.getGameCard());
|
final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||||
}
|
|
||||||
diff = new ArrayList<Card>(tmp);
|
|
||||||
diff.removeAll(cc);
|
|
||||||
if (diff.size() == p.getCardPanels().size()) {
|
|
||||||
p.clear();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (final Card card : diff) {
|
|
||||||
p.removeCardPanel(p.getCardPanel(card.getUniqueNumber()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff = new ArrayList<Card>(cc);
|
|
||||||
diff.removeAll(tmp);
|
|
||||||
|
|
||||||
|
for (Card card : cards) {
|
||||||
|
CardPanel cardPanel = p.getCardPanel(card.getUniqueNumber());
|
||||||
|
if (cardPanel == null) { //create placeholders for new cards
|
||||||
|
cardPanel = new CardPanel(card);
|
||||||
|
cardPanel.setDisplayEnabled(false);
|
||||||
|
placeholders.add(cardPanel);
|
||||||
|
}
|
||||||
|
cardPanels.add(cardPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.setCardPanels(cardPanels);
|
||||||
|
|
||||||
|
//animate new cards into positions defined by placeholders
|
||||||
JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane();
|
JLayeredPane layeredPane = Singletons.getView().getFrame().getLayeredPane();
|
||||||
int fromZoneX = 0, fromZoneY = 0;
|
int fromZoneX = 0, fromZoneY = 0;
|
||||||
|
|
||||||
@@ -127,20 +126,19 @@ public class CHand implements ICDoc {
|
|||||||
|
|
||||||
int endWidth, endX, endY;
|
int endWidth, endX, endY;
|
||||||
|
|
||||||
for (final Card card : diff) {
|
for (final CardPanel placeholder : placeholders) {
|
||||||
CardPanel toPanel = p.addCard(card);
|
endWidth = placeholder.getCardWidth();
|
||||||
endWidth = toPanel.getCardWidth();
|
final Point toPos = SwingUtilities.convertPoint(view.getHandArea(), placeholder.getCardLocation(), layeredPane);
|
||||||
final Point toPos = SwingUtilities.convertPoint(view.getHandArea(), toPanel.getCardLocation(), layeredPane);
|
|
||||||
endX = toPos.x;
|
endX = toPos.x;
|
||||||
endY = toPos.y;
|
endY = toPos.y;
|
||||||
|
|
||||||
final forge.view.arcane.CardPanel animationPanel = new forge.view.arcane.CardPanel(card);
|
final CardPanel animationPanel = new CardPanel(placeholder.getGameCard());
|
||||||
if (Singletons.getView().getFrame().isShowing()) {
|
if (Singletons.getView().getFrame().isShowing()) {
|
||||||
Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, toPanel,
|
Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, placeholder,
|
||||||
layeredPane, 500);
|
layeredPane, 500);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Animation.moveCard(toPanel);
|
Animation.moveCard(placeholder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,31 @@ public abstract class CardPanelContainer extends JPanel {
|
|||||||
CardPanelContainer.this.repaint();
|
CardPanelContainer.this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* setCardPanels.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param cardPanels
|
||||||
|
*/
|
||||||
|
public final void setCardPanels(List<CardPanel> cardPanels) {
|
||||||
|
if (cardPanels.size() == 0) {
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getCardPanels().clear();
|
||||||
|
this.removeAll();
|
||||||
|
this.getCardPanels().addAll(cardPanels);
|
||||||
|
for (CardPanel cardPanel : cardPanels) {
|
||||||
|
this.add(cardPanel);
|
||||||
|
}
|
||||||
|
this.doLayout();
|
||||||
|
this.invalidate();
|
||||||
|
this.getParent().validate();
|
||||||
|
this.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* clear.
|
* clear.
|
||||||
|
|||||||
Reference in New Issue
Block a user