mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Much better implementation to make 1 tap on start button (Constructed)
on Android (Should prevent issue loading a double match on single view)
This commit is contained in:
@@ -51,7 +51,8 @@ public class Forge implements ApplicationListener {
|
|||||||
private static boolean textureFiltering = false;
|
private static boolean textureFiltering = false;
|
||||||
private static boolean destroyThis = false;
|
private static boolean destroyThis = false;
|
||||||
public static String extrawide = "default";
|
public static String extrawide = "default";
|
||||||
public static float heigtModifier = 0.0f;
|
public static float heigtModifier = 0.0f;
|
||||||
|
private static boolean isloadingaMatch = false;
|
||||||
|
|
||||||
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
|
public static ApplicationListener getApp(Clipboard clipboard0, IDeviceAdapter deviceAdapter0, String assetDir0) {
|
||||||
if (GuiBase.getInterface() == null) {
|
if (GuiBase.getInterface() == null) {
|
||||||
@@ -307,6 +308,14 @@ public class Forge implements ApplicationListener {
|
|||||||
return screenWidth > screenHeight;
|
return screenWidth > screenHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isLoadingaMatch() {
|
||||||
|
return isloadingaMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLoadingaMatch(boolean value) {
|
||||||
|
isloadingaMatch = value;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getScreenWidth() {
|
public static int getScreenWidth() {
|
||||||
return screenWidth;
|
return screenWidth;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package forge.screens;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
|
|
||||||
|
import forge.Forge;
|
||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.assets.FSkinImage;
|
import forge.assets.FSkinImage;
|
||||||
import forge.menu.FPopupMenu;
|
import forge.menu.FPopupMenu;
|
||||||
@@ -41,9 +42,6 @@ public abstract class LaunchScreen extends FScreen {
|
|||||||
|
|
||||||
protected class StartButton extends FDisplayObject {
|
protected class StartButton extends FDisplayObject {
|
||||||
private boolean pressed;
|
private boolean pressed;
|
||||||
private long lastTap;
|
|
||||||
private int tapCount;
|
|
||||||
private float lastX, lastY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new FButton.
|
* Instantiates a new FButton.
|
||||||
@@ -65,13 +63,9 @@ public abstract class LaunchScreen extends FScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean tap(float x, float y, int count) {
|
public final boolean tap(float x, float y, int count) {
|
||||||
tapCount = count;
|
if (count == 1) {
|
||||||
lastX = x;
|
btnStart.setEnabled(false);
|
||||||
lastY = y;
|
|
||||||
lastTap = System.currentTimeMillis(); //try prevent rapid tap on start button causing issues
|
|
||||||
if (tapCount == 1 && System.currentTimeMillis() - lastTap < 10 && lastX == x && lastY == y) {
|
|
||||||
startMatch();
|
startMatch();
|
||||||
tapCount++;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -80,6 +74,11 @@ public abstract class LaunchScreen extends FScreen {
|
|||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
g.drawImage(pressed ? FSkinImage.BTN_START_DOWN : FSkinImage.BTN_START_UP,
|
g.drawImage(pressed ? FSkinImage.BTN_START_DOWN : FSkinImage.BTN_START_UP,
|
||||||
0, 0, getWidth(), getHeight());
|
0, 0, getWidth(), getHeight());
|
||||||
|
//its must be enabled or you can't start any game modes
|
||||||
|
if (!Forge.isLoadingaMatch()) {
|
||||||
|
if(!btnStart.isEnabled())
|
||||||
|
btnStart.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public class LoadingOverlay extends FOverlay {
|
|||||||
public void run() {
|
public void run() {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
loader.hide();
|
loader.hide();
|
||||||
|
loader.finishedloading(); //setLoadingaMatch to false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ public abstract class LobbyScreen extends LaunchScreen implements ILobbyView {
|
|||||||
for (int i = 0; i < getNumPlayers(); i++) {
|
for (int i = 0; i < getNumPlayers(); i++) {
|
||||||
updateDeck(i);
|
updateDeck(i);
|
||||||
}
|
}
|
||||||
|
//set this so we cant get any multi/rapid tap on start button
|
||||||
|
Forge.setLoadingaMatch(true);
|
||||||
FThreads.invokeInBackgroundThread(new Runnable() { //must call startGame in background thread in case there are alerts
|
FThreads.invokeInBackgroundThread(new Runnable() { //must call startGame in background thread in case there are alerts
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
@@ -85,6 +85,10 @@ public abstract class FOverlay extends FContainer {
|
|||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void finishedloading() {
|
||||||
|
Forge.setLoadingaMatch(false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isVisibleOnScreen(FScreen screen) {
|
public boolean isVisibleOnScreen(FScreen screen) {
|
||||||
return (openedOnScreen == screen); //by default, only show overlay on the same screen it's opened on
|
return (openedOnScreen == screen); //by default, only show overlay on the same screen it's opened on
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user