mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Fix so card stacks work properly so newer cards appear on top and tapping the same land multiple times will tap lands under it automatically
This commit is contained in:
@@ -54,8 +54,13 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
addCardPanelToDisplayArea(attachedPanels.get(i));
|
addCardPanelToDisplayArea(attachedPanels.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cardPanel.displayArea = this;
|
cardPanel.displayArea = this;
|
||||||
add(cardPanel);
|
add(cardPanel);
|
||||||
|
|
||||||
|
if (cardPanel.getNextPanelInStack() != null) {
|
||||||
|
addCardPanelToDisplayArea(cardPanel.getNextPanelInStack());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void removeCardPanel(final CardAreaPanel fromPanel) {
|
public final void removeCardPanel(final CardAreaPanel fromPanel) {
|
||||||
@@ -76,9 +81,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
super.clear();
|
super.clear();
|
||||||
if (!cardPanels.isEmpty()) {
|
if (!cardPanels.isEmpty()) {
|
||||||
for (CardAreaPanel panel : cardPanels) {
|
for (CardAreaPanel panel : cardPanels) {
|
||||||
panel.attachedPanels.clear();
|
panel.reset();
|
||||||
panel.attachedToPanel = null;
|
|
||||||
panel.displayArea = null;
|
|
||||||
}
|
}
|
||||||
cardPanels.clear();
|
cardPanels.clear();
|
||||||
}
|
}
|
||||||
@@ -94,8 +97,14 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
totalCount += count;
|
totalCount += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orderedCards.add(cardPanel.getCard());
|
orderedCards.add(cardPanel.getCard());
|
||||||
cardPanel.setBounds(x, y, cardWidth, cardHeight);
|
cardPanel.setBounds(x, y, cardWidth, cardHeight);
|
||||||
|
|
||||||
|
if (cardPanel.getNextPanelInStack() != null) { //add next panel in stack if needed
|
||||||
|
x += cardWidth * CARD_STACK_OFFSET;
|
||||||
|
totalCount += addCards(cardPanel.getNextPanelInStack(), x, y, cardWidth, cardHeight);
|
||||||
|
}
|
||||||
return totalCount + 1;
|
return totalCount + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,6 +146,8 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
cardPanel.displayArea = null;
|
cardPanel.displayArea = null;
|
||||||
cardPanel.attachedToPanel = null;
|
cardPanel.attachedToPanel = null;
|
||||||
cardPanel.attachedPanels.clear();
|
cardPanel.attachedPanels.clear();
|
||||||
|
cardPanel.prevPanelInStack = null;
|
||||||
|
cardPanel.nextPanelInStack = null;
|
||||||
}
|
}
|
||||||
allCardPanels.clear();
|
allCardPanels.clear();
|
||||||
}
|
}
|
||||||
@@ -144,6 +155,7 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
private VCardDisplayArea displayArea;
|
private VCardDisplayArea displayArea;
|
||||||
private CardAreaPanel attachedToPanel;
|
private CardAreaPanel attachedToPanel;
|
||||||
private final List<CardAreaPanel> attachedPanels = new ArrayList<CardAreaPanel>();
|
private final List<CardAreaPanel> attachedPanels = new ArrayList<CardAreaPanel>();
|
||||||
|
private CardAreaPanel nextPanelInStack, prevPanelInStack;
|
||||||
|
|
||||||
//use static get(card) function instead
|
//use static get(card) function instead
|
||||||
private CardAreaPanel(Card card0) {
|
private CardAreaPanel(Card card0) {
|
||||||
@@ -167,6 +179,32 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
public List<CardAreaPanel> getAttachedPanels() {
|
public List<CardAreaPanel> getAttachedPanels() {
|
||||||
return attachedPanels;
|
return attachedPanels;
|
||||||
}
|
}
|
||||||
|
public CardAreaPanel getNextPanelInStack() {
|
||||||
|
return nextPanelInStack;
|
||||||
|
}
|
||||||
|
public void setNextPanelInStack(CardAreaPanel nextPanelInStack0) {
|
||||||
|
nextPanelInStack = nextPanelInStack0;
|
||||||
|
}
|
||||||
|
public CardAreaPanel getPrevPanelInStack() {
|
||||||
|
return prevPanelInStack;
|
||||||
|
}
|
||||||
|
public void setPrevPanelInStack(CardAreaPanel prevPanelInStack0) {
|
||||||
|
prevPanelInStack = prevPanelInStack0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//clear and reset all pointers from this panel
|
||||||
|
public void reset() {
|
||||||
|
if (!attachedPanels.isEmpty()) {
|
||||||
|
attachedPanels.clear();
|
||||||
|
}
|
||||||
|
if (nextPanelInStack != null) {
|
||||||
|
nextPanelInStack.reset();
|
||||||
|
nextPanelInStack = null;
|
||||||
|
}
|
||||||
|
attachedToPanel = null;
|
||||||
|
prevPanelInStack = null;
|
||||||
|
displayArea = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tap(float x, float y, int count) {
|
public boolean tap(float x, float y, int count) {
|
||||||
@@ -186,7 +224,11 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
|||||||
if (FControl.getInputProxy().selectCard(getCard(), null)) {
|
if (FControl.getInputProxy().selectCard(getCard(), null)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//if panel can't do anything with card selection, try selecting an attached panel
|
//if panel can't do anything with card selection, try selecting previous panel in stack
|
||||||
|
if (prevPanelInStack != null && prevPanelInStack.selectCard()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//as a last resort try to select attached panels
|
||||||
for (CardAreaPanel panel : attachedPanels) {
|
for (CardAreaPanel panel : attachedPanels) {
|
||||||
if (panel.selectCard()) {
|
if (panel.selectCard()) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -102,9 +102,12 @@ public class VField extends FContainer {
|
|||||||
card.getName().equals(c.getName()) &&
|
card.getName().equals(c.getName()) &&
|
||||||
card.getCounters().equals(card.getCounters())) {
|
card.getCounters().equals(card.getCounters())) {
|
||||||
CardAreaPanel cPanel = CardAreaPanel.get(c);
|
CardAreaPanel cPanel = CardAreaPanel.get(c);
|
||||||
|
while (cPanel.getNextPanelInStack() != null) {
|
||||||
|
cPanel = cPanel.getNextPanelInStack();
|
||||||
|
}
|
||||||
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
CardAreaPanel cardPanel = CardAreaPanel.get(card);
|
||||||
cPanel.getAttachedPanels().add(cardPanel);
|
cPanel.setNextPanelInStack(cardPanel);
|
||||||
cardPanel.setAttachedToPanel(cPanel);
|
cardPanel.setPrevPanelInStack(cPanel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user