mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +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.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Looper;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
@@ -36,8 +35,6 @@ public class Main extends AndroidApplication {
|
||||
return;
|
||||
}
|
||||
|
||||
Forge app = new Forge();
|
||||
app.initialize(Looper.getMainLooper().getThread(), getClipboard(), assetsDir);
|
||||
initialize(app, true);
|
||||
initialize(new Forge(getClipboard(), assetsDir), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,6 @@ import forge.util.Utils;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
new ForgeApplication(new Forge());
|
||||
}
|
||||
|
||||
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/");
|
||||
}
|
||||
new LwjglApplication(new Forge(new LwjglClipboard(), "../forge-gui/"), "Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import forge.toolbox.FOverlay;
|
||||
import forge.util.Utils;
|
||||
|
||||
public class Forge implements ApplicationListener {
|
||||
private static boolean initialized;
|
||||
private static Clipboard clipboard;
|
||||
private static int screenWidth;
|
||||
private static int screenHeight;
|
||||
@@ -51,16 +50,12 @@ public class Forge implements ApplicationListener {
|
||||
private static KeyInputAdapter keyInputAdapter;
|
||||
private static final Stack<FScreen> screens = new Stack<FScreen>();
|
||||
|
||||
public Forge() {
|
||||
}
|
||||
|
||||
public void initialize(Thread guiThread, Clipboard clipboard0, String assetDir0) {
|
||||
if (initialized) {
|
||||
public Forge(Clipboard clipboard0, String assetDir0) {
|
||||
if (GuiBase.getInterface() != null) {
|
||||
throw new RuntimeException("Cannot initialize Forge more than once");
|
||||
}
|
||||
clipboard = clipboard0;
|
||||
GuiBase.setInterface(new GuiMobile(guiThread, assetDir0));
|
||||
initialized = true;
|
||||
GuiBase.setInterface(new GuiMobile(assetDir0));
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
||||
@@ -46,15 +46,14 @@ import forge.sound.IAudioClip;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.GuiChoose;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.util.ThreadUtil;
|
||||
import forge.util.WaitCallback;
|
||||
import forge.util.WaitRunnable;
|
||||
import forge.util.gui.SGuiChoose;
|
||||
|
||||
public class GuiMobile implements IGuiBase {
|
||||
private final Thread guiThread;
|
||||
private final String assetsDir;
|
||||
public GuiMobile(Thread guiThread0, String assetsDir0) {
|
||||
guiThread = guiThread0;
|
||||
public GuiMobile(String assetsDir0) {
|
||||
assetsDir = assetsDir0;
|
||||
}
|
||||
|
||||
@@ -80,7 +79,7 @@ public class GuiMobile implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public boolean isGuiThread() {
|
||||
return Thread.currentThread() == guiThread;
|
||||
return !ThreadUtil.isGameThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user