Add support for debug logging

Tweak assets path for android
This commit is contained in:
drdev
2014-05-08 13:26:25 +00:00
parent ae382760d0
commit 7a10e183ce
5 changed files with 19 additions and 8 deletions

View File

@@ -19,6 +19,6 @@ public class Main extends AndroidApplication {
this.setRequestedOrientation(7);
}
initialize(new Forge(getClipboard()), false);
initialize(new Forge(getClipboard(), getExternalFilesDir(null).getAbsolutePath()), false);
}
}

View File

@@ -7,6 +7,6 @@ import forge.Forge;
public class Main {
public static void main(String[] args) {
new LwjglApplication(new Forge(new LwjglClipboard()), "Forge", 320, 480, true);
new LwjglApplication(new Forge(new LwjglClipboard(), "../forge-gui/"), "Forge", 320, 480, true);
}
}

View File

@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Keys;
@@ -49,13 +50,13 @@ public class Forge implements ApplicationListener {
private static KeyInputAdapter keyInputAdapter;
private static final Stack<FScreen> screens = new Stack<FScreen>();
public Forge(Clipboard clipboard0) {
public Forge(Clipboard clipboard0, String assetDir0) {
if (game != null) {
throw new RuntimeException("Cannot initialize Forge more than once");
}
game = this;
clipboard = clipboard0;
GuiBase.setInterface(new GuiMobile());
GuiBase.setInterface(new GuiMobile(assetDir0));
}
@Override
@@ -211,6 +212,12 @@ public class Forge implements ApplicationListener {
shapeRenderer.dispose();
}
//special utility method to help with debugging
public static void debugPrint(String message) {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
Gdx.app.debug("Forge", message);
}
public static void startKeyInput(KeyInputAdapter adapter) {
if (keyInputAdapter == adapter) { return; }
if (keyInputAdapter != null) {

View File

@@ -51,6 +51,11 @@ import forge.util.WaitRunnable;
import forge.util.gui.SGuiChoose;
public class GuiMobile implements IGuiBase {
private final String assetsDir;
public GuiMobile(String assetsDir0) {
assetsDir = assetsDir0;
}
@Override
public void invokeInEdtLater(Runnable proc) {
Gdx.app.postRunnable(proc);
@@ -78,10 +83,7 @@ public class GuiMobile implements IGuiBase {
@Override
public String getAssetsDir() {
if (Gdx.app.getType() == ApplicationType.Desktop) {
return "../forge-gui/";
}
return Gdx.files.getLocalStoragePath();
return assetsDir;
}
@Override

View File

@@ -8,6 +8,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
import forge.Forge;
import forge.Forge.Graphics;
import forge.assets.FSkin;
import forge.assets.FSkinFont;
@@ -93,6 +94,7 @@ public class SplashScreen extends FContainer {
String versionStr = BuildInfo.getVersionString();
File versionFile = new File(ForgeConstants.ASSETS_DIR + "version.txt");
Forge.debugPrint("Version file: " + versionFile);
if (!versionFile.exists()) {
try {
versionFile.createNewFile();