[Mobile] Fix cards hovered on MatchScreen

This commit is contained in:
Anthony Calosa
2021-09-30 08:49:15 +08:00
parent 4939e18d2c
commit c943386ca8
3 changed files with 7 additions and 4 deletions

View File

@@ -83,6 +83,7 @@ public class Forge implements ApplicationListener {
public static boolean autoCache = false;
public static int lastButtonIndex = 0;
public static String CJK_Font = "";
public static int hoveredCount = 0;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) {
if (GuiBase.getInterface() == null) {
@@ -920,11 +921,11 @@ public class Forge implements ApplicationListener {
//mouseMoved and scrolled events for desktop version
private int mouseMovedX, mouseMovedY;
@Override
public boolean mouseMoved(int screenX, int screenY) {
mouseMovedX = screenX;
mouseMovedY = screenY;
hoveredCount = 0;
//reset
try {
for (FDisplayObject listener : potentialListeners) {

View File

@@ -96,7 +96,6 @@ public class FCardPanel extends FDisplayObject {
public void draw(Graphics g) {
if (card == null) { return; }
boolean animate = Forge.animatedCardTapUntap;
//TODO: FCardPanel ishovered and CardStackPosition is BehindHorz or BehindVert...
float mod = isHighlighted()||isHovered() ? getWidth()/16f : 0f;
float padding = getPadding();
float x = padding-mod/2;

View File

@@ -4,6 +4,7 @@ import java.util.List;
import com.badlogic.gdx.math.Rectangle;
import forge.Forge;
import forge.Graphics;
public abstract class FDisplayObject {
@@ -130,8 +131,10 @@ public abstract class FDisplayObject {
if (enabled && visible && screenPos.contains(screenX, screenY)) {
listeners.add(this);
}
//TODO: needs better logic, it must be the only current selectable
setHovered(this.enabled && this.visible && this.screenPos.contains(screenX, screenY));
Forge.hoveredCount = listeners.size();
if (!Forge.getCurrentScreen().toString().contains("Match"))
Forge.hoveredCount = 1;
setHovered(this.enabled && this.visible && this.screenPos.contains(screenX, screenY) && Forge.hoveredCount < 2);
scrX = screenX;
scrY = screenY;
}