mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Fix updating of revealed card in hand
This commit is contained in:
@@ -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,29 +54,30 @@ 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();
|
||||||
|
if (Forge.isLandscapeMode()) {
|
||||||
|
//for landscape mode, just show revealed card on top
|
||||||
|
for (CardAreaPanel cardPanel : cardPanels) {
|
||||||
|
if (cardPanel != revealedPanel) {
|
||||||
|
add(cardPanel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//for portrait mode, cascade cards back from revealed panel
|
||||||
int maxIdx = cardPanels.size() - 1;
|
int maxIdx = cardPanels.size() - 1;
|
||||||
int offset = Math.max(idx, maxIdx - idx);
|
int offset = Math.max(idx, maxIdx - idx);
|
||||||
for (int i = offset; i > 0; i--) {
|
for (int i = offset; i > 0; i--) {
|
||||||
@@ -77,7 +90,7 @@ public class VZoneDisplay extends VCardDisplayArea {
|
|||||||
add(cardPanels.get(idx2));
|
add(cardPanels.get(idx2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revealedPanel = cardPanels.get(idx);
|
}
|
||||||
add(revealedPanel);
|
add(revealedPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user