diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/RustAndDust.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/util/DB.java | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java index c25862f..af6dcee 100644 --- a/core/src/ch/asynk/rustanddust/RustAndDust.java +++ b/core/src/ch/asynk/rustanddust/RustAndDust.java @@ -65,6 +65,7 @@ public class RustAndDust extends Game public static final String DOM = "RustAndDust"; public static final String DB_FILE = "rustanddust.sqlite"; + public static final String CONFIG_PATH = ".config/rustanddust"; public AssetManager manager; public Factory factory; @@ -122,7 +123,11 @@ public class RustAndDust extends Game { switch (Gdx.app.getType()) { case Desktop: - return String.format("data/%s", DB_FILE); + if (!System.getProperty("os.name").startsWith("Windo")) { + final String dir = String.format("%s/%s", System.getProperty("user.home"), CONFIG_PATH); + new java.io.File(dir).mkdir(); + return String.format("%s/%s", dir, DB_FILE); + } } return DB_FILE; } @@ -135,7 +140,6 @@ public class RustAndDust extends Game debug("create() [" + Gdx.graphics.getWidth() + ";" + Gdx.graphics.getHeight() + "] " + Gdx.graphics.getDensity() + " -> " + hudCorrection); db = new DB(Gdx.files.internal(dbFile()).path(), false); - db.setup(); manager = new AssetManager(); factory = new Factory(this); diff --git a/core/src/ch/asynk/rustanddust/util/DB.java b/core/src/ch/asynk/rustanddust/util/DB.java index 21d87ed..25e3dfb 100644 --- a/core/src/ch/asynk/rustanddust/util/DB.java +++ b/core/src/ch/asynk/rustanddust/util/DB.java @@ -69,17 +69,16 @@ public class DB this.db = DatabaseFactory.getNewDatabase(dbPath, DB_SCHEMA_VERSION, null, null); this.db.setupDatabase(); this.debug = debug; - } - public void setup() - { try { - md = MessageDigest.getInstance(DIGEST); - } catch (java.security.NoSuchAlgorithmException e) { RustAndDust.error("NoSuchAlgorithm"); } + db.openOrCreateDatabase(); + } catch (SQLiteGdxException e) { + RustAndDust.error(String.format("openOrCreateDatabase : %s", dbPath)); + } try { - db.openOrCreateDatabase(); - } catch (SQLiteGdxException e) { RustAndDust.error("openOrCreateDatabase"); } + md = MessageDigest.getInstance(DIGEST); + } catch (java.security.NoSuchAlgorithmException e) { RustAndDust.error("NoSuchAlgorithm"); } Boolean version = checkVersion(); if(version == null) |