mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Prevent card panel being selected if finger not on rendered card
This commit is contained in:
@@ -208,16 +208,19 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread in case a dialog needs to be shown
|
||||
@Override
|
||||
public void run() {
|
||||
if (!selectCard()) {
|
||||
//if no cards in stack can be selected, just show zoom/details for card
|
||||
CardZoom.show(getCard());
|
||||
if (renderedCardContains(x, y)) {
|
||||
ThreadUtil.invokeInGameThread(new Runnable() { //must invoke in game thread in case a dialog needs to be shown
|
||||
@Override
|
||||
public void run() {
|
||||
if (!selectCard()) {
|
||||
//if no cards in stack can be selected, just show zoom/details for card
|
||||
CardZoom.show(getCard());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean selectCard() {
|
||||
@@ -239,8 +242,11 @@ public abstract class VCardDisplayArea extends VDisplayArea {
|
||||
|
||||
@Override
|
||||
public boolean longPress(float x, float y) {
|
||||
CardZoom.show(getCard());
|
||||
return true;
|
||||
if (renderedCardContains(x, y)) {
|
||||
CardZoom.show(getCard());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,15 +52,31 @@ public class FCardPanel extends FDisplayObject {
|
||||
tappedAngle = tappedAngle0;
|
||||
}
|
||||
|
||||
protected boolean renderedCardContains(float x, float y) {
|
||||
float left = PADDING;
|
||||
float top = PADDING;
|
||||
float w = getWidth() - 2 * PADDING;
|
||||
float h = getHeight() - 2 * PADDING;
|
||||
if (w == h) { //adjust width if needed to make room for tapping
|
||||
w = h / ASPECT_RATIO;
|
||||
}
|
||||
|
||||
if (tapped) { //rotate box if tapped
|
||||
top += h - w;
|
||||
float temp = w;
|
||||
w = h;
|
||||
h = temp;
|
||||
}
|
||||
|
||||
return x >= left && x <= left + w && y >= top && y <= top + h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics g) {
|
||||
draw(g, 0, 0);
|
||||
}
|
||||
public void draw(Graphics g, float x, float y) {
|
||||
if (card == null) { return; }
|
||||
|
||||
x += PADDING;
|
||||
y += PADDING;
|
||||
float x = PADDING;
|
||||
float y = PADDING;
|
||||
float w = getWidth() - 2 * PADDING;
|
||||
float h = getHeight() - 2 * PADDING;
|
||||
if (w == h) { //adjust width if needed to make room for tapping
|
||||
|
||||
Reference in New Issue
Block a user