Fix updating of revealed card in hand

This commit is contained in:
drdev
2015-05-24 22:36:03 +00:00
parent 805993c060
commit 34c2552b56

View File

@@ -33,7 +33,19 @@ public class VZoneDisplay extends VCardDisplayArea {
super.buildTouchListeners(screenX, screenY, listeners); super.buildTouchListeners(screenX, screenY, listeners);
if (revealedPanel != null) { if (revealedPanel != null) {
updateRevealedPanel(screenToLocalX(screenX), screenToLocalY(screenY)); float x = screenToLocalX(screenX);
float y = screenToLocalY(screenY);
if (revealedPanel.contains(x, y)) { return; }
int idx = cardPanels.size() - 1;
for (int i = getChildCount() - 2; i >= 0; i--) {
final FDisplayObject cardPanel = getChildAt(i);
if (cardPanel.contains(x, y)) {
idx = cardPanels.indexOf(cardPanel);
break;
}
}
setRevealedPanel(idx);
} }
} }
@@ -42,42 +54,43 @@ public class VZoneDisplay extends VCardDisplayArea {
if (revealedPanel == null) { //if no overlapping panels, just pan scroll as normal if (revealedPanel == null) { //if no overlapping panels, just pan scroll as normal
return super.pan(x, y, deltaX, deltaY, moreVertical); return super.pan(x, y, deltaX, deltaY, moreVertical);
} }
updateRevealedPanel(x, y); int idx = cardPanels.size() - 1;
return true; for (int i = idx - 1; i >= 0; i--) {
} if (cardPanels.get(i).contains(x, y)) {
idx = i;
private void updateRevealedPanel(float x, float y) {
if (revealedPanel.contains(x, y)) { return; }
int idx = -1;
for (int i = getChildCount() - 2; i >= 0; i--) {
final FDisplayObject cardPanel = getChildAt(i);
if (cardPanel.contains(x, y)) {
idx = cardPanels.indexOf(cardPanel);
break; break;
} }
} }
if (idx >= 0) { setRevealedPanel(idx);
setRevealedPanel(idx); return true;
}
} }
private void setRevealedPanel(int idx) { private void setRevealedPanel(int idx) {
//cascade cards back from revealed panel revealedPanel = cardPanels.get(idx);
clearChildren(); clearChildren();
int maxIdx = cardPanels.size() - 1; if (Forge.isLandscapeMode()) {
int offset = Math.max(idx, maxIdx - idx); //for landscape mode, just show revealed card on top
for (int i = offset; i > 0; i--) { for (CardAreaPanel cardPanel : cardPanels) {
int idx1 = idx - i; if (cardPanel != revealedPanel) {
int idx2 = idx + i; add(cardPanel);
if (idx1 >= 0) { }
add(cardPanels.get(idx1)); }
} }
if (idx2 <= maxIdx) { else {
add(cardPanels.get(idx2)); //for portrait mode, cascade cards back from revealed panel
int maxIdx = cardPanels.size() - 1;
int offset = Math.max(idx, maxIdx - idx);
for (int i = offset; i > 0; i--) {
int idx1 = idx - i;
int idx2 = idx + i;
if (idx1 >= 0) {
add(cardPanels.get(idx1));
}
if (idx2 <= maxIdx) {
add(cardPanels.get(idx2));
}
} }
} }
revealedPanel = cardPanels.get(idx);
add(revealedPanel); add(revealedPanel);
} }