mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Adjust previous fix to make it work properly
This commit is contained in:
@@ -4,7 +4,6 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Looper;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||||
@@ -36,8 +35,6 @@ public class Main extends AndroidApplication {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Forge app = new Forge();
|
initialize(new Forge(getClipboard(), assetsDir), true);
|
||||||
app.initialize(Looper.getMainLooper().getThread(), getClipboard(), assetsDir);
|
|
||||||
initialize(app, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,13 +8,6 @@ import forge.util.Utils;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new ForgeApplication(new Forge());
|
new LwjglApplication(new Forge(new LwjglClipboard(), "../forge-gui/"), "Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true);
|
||||||
}
|
|
||||||
|
|
||||||
private static class ForgeApplication extends LwjglApplication {
|
|
||||||
private ForgeApplication(Forge app) {
|
|
||||||
super(app, "Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true);
|
|
||||||
app.initialize(mainLoopThread, new LwjglClipboard(), "../forge-gui/");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ import forge.toolbox.FOverlay;
|
|||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class Forge implements ApplicationListener {
|
public class Forge implements ApplicationListener {
|
||||||
private static boolean initialized;
|
|
||||||
private static Clipboard clipboard;
|
private static Clipboard clipboard;
|
||||||
private static int screenWidth;
|
private static int screenWidth;
|
||||||
private static int screenHeight;
|
private static int screenHeight;
|
||||||
@@ -51,16 +50,12 @@ public class Forge implements ApplicationListener {
|
|||||||
private static KeyInputAdapter keyInputAdapter;
|
private static KeyInputAdapter keyInputAdapter;
|
||||||
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
||||||
|
|
||||||
public Forge() {
|
public Forge(Clipboard clipboard0, String assetDir0) {
|
||||||
}
|
if (GuiBase.getInterface() != null) {
|
||||||
|
|
||||||
public void initialize(Thread guiThread, Clipboard clipboard0, String assetDir0) {
|
|
||||||
if (initialized) {
|
|
||||||
throw new RuntimeException("Cannot initialize Forge more than once");
|
throw new RuntimeException("Cannot initialize Forge more than once");
|
||||||
}
|
}
|
||||||
clipboard = clipboard0;
|
clipboard = clipboard0;
|
||||||
GuiBase.setInterface(new GuiMobile(guiThread, assetDir0));
|
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||||
initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,7 +88,7 @@ public class Forge implements ApplicationListener {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).start();
|
}, "Game Startup").start(); //use thread name that starts with "Game" so GuiMobile.isGuiThread() returns false
|
||||||
}
|
}
|
||||||
|
|
||||||
private void afterDbLoaded() {
|
private void afterDbLoaded() {
|
||||||
|
|||||||
@@ -46,15 +46,14 @@ import forge.sound.IAudioClip;
|
|||||||
import forge.toolbox.FOptionPane;
|
import forge.toolbox.FOptionPane;
|
||||||
import forge.toolbox.GuiChoose;
|
import forge.toolbox.GuiChoose;
|
||||||
import forge.util.ITriggerEvent;
|
import forge.util.ITriggerEvent;
|
||||||
|
import forge.util.ThreadUtil;
|
||||||
import forge.util.WaitCallback;
|
import forge.util.WaitCallback;
|
||||||
import forge.util.WaitRunnable;
|
import forge.util.WaitRunnable;
|
||||||
import forge.util.gui.SGuiChoose;
|
import forge.util.gui.SGuiChoose;
|
||||||
|
|
||||||
public class GuiMobile implements IGuiBase {
|
public class GuiMobile implements IGuiBase {
|
||||||
private final Thread guiThread;
|
|
||||||
private final String assetsDir;
|
private final String assetsDir;
|
||||||
public GuiMobile(Thread guiThread0, String assetsDir0) {
|
public GuiMobile(String assetsDir0) {
|
||||||
guiThread = guiThread0;
|
|
||||||
assetsDir = assetsDir0;
|
assetsDir = assetsDir0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +79,7 @@ public class GuiMobile implements IGuiBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGuiThread() {
|
public boolean isGuiThread() {
|
||||||
return Thread.currentThread() == guiThread;
|
return !ThreadUtil.isGameThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user