[Mobile] Disable mouse events for Android

- should have a mouse hotplug detection
This commit is contained in:
Anthony Calosa
2021-09-30 13:47:19 +08:00
parent 52c78eca90
commit e06a97a6db
2 changed files with 13 additions and 7 deletions

View File

@@ -84,6 +84,7 @@ public class Forge implements ApplicationListener {
public static int lastButtonIndex = 0; public static int lastButtonIndex = 0;
public static String CJK_Font = ""; public static String CJK_Font = "";
public static int hoveredCount = 0; public static int hoveredCount = 0;
public static boolean afterDBloaded = false;
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0, boolean value, boolean androidOrientation, int totalRAM, boolean isTablet, int AndroidAPI, String AndroidRelease, String deviceName) { 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) { if (GuiBase.getInterface() == null) {
@@ -251,6 +252,7 @@ public class Forge implements ApplicationListener {
Gdx.input.setCatchKey(Keys.MENU, true); Gdx.input.setCatchKey(Keys.MENU, true);
openHomeScreen(-1, null); //default for startup openHomeScreen(-1, null); //default for startup
splashScreen = null; splashScreen = null;
afterDBloaded = true;
boolean isLandscapeMode = isLandscapeMode(); boolean isLandscapeMode = isLandscapeMode();
if (isLandscapeMode) { //open preferred new game screen by default if landscape mode if (isLandscapeMode) { //open preferred new game screen by default if landscape mode
@@ -925,6 +927,9 @@ public class Forge implements ApplicationListener {
public boolean mouseMoved(int screenX, int screenY) { public boolean mouseMoved(int screenX, int screenY) {
mouseMovedX = screenX; mouseMovedX = screenX;
mouseMovedY = screenY; mouseMovedY = screenY;
//todo: mouse listener for android?
if (GuiBase.isAndroid())
return true;
hoveredCount = 0; hoveredCount = 0;
//reset //reset
try { try {

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Rectangle;
import forge.Forge; import forge.Forge;
import forge.Graphics; import forge.Graphics;
import forge.gui.GuiBase;
public abstract class FDisplayObject { public abstract class FDisplayObject {
protected static final float DISABLED_COMPOSITE = 0.25f; protected static final float DISABLED_COMPOSITE = 0.25f;
@@ -126,17 +127,17 @@ public abstract class FDisplayObject {
} }
public abstract void draw(Graphics g); public abstract void draw(Graphics g);
public float scrX, scrY;
public void buildTouchListeners(float screenX, float screenY, List<FDisplayObject> listeners) { public void buildTouchListeners(float screenX, float screenY, List<FDisplayObject> listeners) {
if (enabled && visible && screenPos.contains(screenX, screenY)) { if (enabled && visible && screenPos.contains(screenX, screenY)) {
listeners.add(this); listeners.add(this);
} }
//TODO: mouse detection on android?
if (Forge.afterDBloaded && !GuiBase.isAndroid()) {
Forge.hoveredCount = listeners.size(); Forge.hoveredCount = listeners.size();
if (!Forge.getCurrentScreen().toString().contains("Match")) if (!Forge.getCurrentScreen().toString().contains("Match"))
Forge.hoveredCount = 1; Forge.hoveredCount = 1;
setHovered(this.enabled && this.visible && this.screenPos.contains(screenX, screenY) && Forge.hoveredCount < 2); setHovered(this.enabled && this.visible && this.screenPos.contains(screenX, screenY) && Forge.hoveredCount < 2);
scrX = screenX; }
scrY = screenY;
} }
public boolean press(float x, float y) { public boolean press(float x, float y) {