mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +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 destroyThis = false;
|
||||
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) {
|
||||
if (GuiBase.getInterface() == null) {
|
||||
@@ -307,6 +308,14 @@ public class Forge implements ApplicationListener {
|
||||
return screenWidth > screenHeight;
|
||||
}
|
||||
|
||||
public static boolean isLoadingaMatch() {
|
||||
return isloadingaMatch;
|
||||
}
|
||||
|
||||
public static void setLoadingaMatch(boolean value) {
|
||||
isloadingaMatch = value;
|
||||
}
|
||||
|
||||
public static int getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.screens;
|
||||
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.assets.FSkinImage;
|
||||
import forge.menu.FPopupMenu;
|
||||
@@ -41,9 +42,6 @@ public abstract class LaunchScreen extends FScreen {
|
||||
|
||||
protected class StartButton extends FDisplayObject {
|
||||
private boolean pressed;
|
||||
private long lastTap;
|
||||
private int tapCount;
|
||||
private float lastX, lastY;
|
||||
|
||||
/**
|
||||
* Instantiates a new FButton.
|
||||
@@ -65,13 +63,9 @@ public abstract class LaunchScreen extends FScreen {
|
||||
|
||||
@Override
|
||||
public final boolean tap(float x, float y, int count) {
|
||||
tapCount = count;
|
||||
lastX = x;
|
||||
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) {
|
||||
if (count == 1) {
|
||||
btnStart.setEnabled(false);
|
||||
startMatch();
|
||||
tapCount++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -80,6 +74,11 @@ public abstract class LaunchScreen extends FScreen {
|
||||
public void draw(Graphics g) {
|
||||
g.drawImage(pressed ? FSkinImage.BTN_START_DOWN : FSkinImage.BTN_START_UP,
|
||||
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() {
|
||||
runnable.run();
|
||||
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++) {
|
||||
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
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -85,6 +85,10 @@ public abstract class FOverlay extends FContainer {
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
public void finishedloading() {
|
||||
Forge.setLoadingaMatch(false);
|
||||
}
|
||||
|
||||
public boolean isVisibleOnScreen(FScreen screen) {
|
||||
return (openedOnScreen == screen); //by default, only show overlay on the same screen it's opened on
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user