mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Fix logic for determining which card panel to bring to front
This commit is contained in:
@@ -55,20 +55,21 @@ public class VZoneDisplay extends VCardDisplayArea {
|
|||||||
private void updateRevealedPanel(float x, float y) {
|
private void updateRevealedPanel(float x, float y) {
|
||||||
if (revealedPanel.contains(x, y)) { return; }
|
if (revealedPanel.contains(x, y)) { return; }
|
||||||
|
|
||||||
int i;
|
int idx = -1;
|
||||||
for (i = cardPanels.size() - 1; i >= 0; i--) {
|
for (int i = getChildCount() - 2; i >= 0; i--) {
|
||||||
final FCardPanel cardPanel = cardPanels.get(i);
|
final FDisplayObject cardPanel = getChildAt(i);
|
||||||
if (cardPanel.contains(x, y)) {
|
if (cardPanel.contains(x, y)) {
|
||||||
|
idx = cardPanels.indexOf(cardPanel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i >= 0) { //cascade cards back from revealed panel
|
if (idx >= 0) { //cascade cards back from revealed panel
|
||||||
clearChildren();
|
clearChildren();
|
||||||
int maxIdx = cardPanels.size() - 1;
|
int maxIdx = cardPanels.size() - 1;
|
||||||
int offset = Math.max(i, maxIdx - i);
|
int offset = Math.max(idx, maxIdx - idx);
|
||||||
for (int j = offset; j > 0; j--) {
|
for (int i = offset; i > 0; i--) {
|
||||||
int idx1 = i - j;
|
int idx1 = idx - i;
|
||||||
int idx2 = i + j;
|
int idx2 = idx + i;
|
||||||
if (idx1 >= 0) {
|
if (idx1 >= 0) {
|
||||||
add(cardPanels.get(idx1));
|
add(cardPanels.get(idx1));
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,7 @@ public class VZoneDisplay extends VCardDisplayArea {
|
|||||||
add(cardPanels.get(idx2));
|
add(cardPanels.get(idx2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revealedPanel = cardPanels.get(i);
|
revealedPanel = cardPanels.get(idx);
|
||||||
add(revealedPanel);
|
add(revealedPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ public abstract class FContainer extends FDisplayObject {
|
|||||||
children.clear();
|
children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FDisplayObject getChildAt(int index) {
|
||||||
|
return children.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
public int getChildCount() {
|
public int getChildCount() {
|
||||||
return children.size();
|
return children.size();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user