-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
320 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
*.war | ||
*.ear | ||
hs_err_pid* | ||
|
||
*.db | ||
## GWT | ||
war/ | ||
html/war/gwt_bree/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<component inheritJdk="true"> | ||
<output-test url="file://$MODULE_DIR$/build"/> | ||
<exclude-output/> | ||
<contentEntry url="file://$MODULE_DIR$"> | ||
<excludeFolder url="file://$MODULE_DIR$/.gradle"/> | ||
<excludeFolder url="file://$MODULE_DIR$/build"/> | ||
</contentEntry> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,3 @@ sourceCompatibility = 1.6 | |
|
||
sourceSets.main.java.srcDirs = [ "src/" ] | ||
|
||
|
||
eclipse.project { | ||
name = appName + "-core" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<component inheritJdk="true"> | ||
<output-test url="file://$MODULE_DIR$/build/classes/test"/> | ||
<exclude-output/> | ||
<contentEntry url="file://$MODULE_DIR$"> | ||
<testFolder url="file://$MODULE_DIR$/src/test/java"/> | ||
<testFolder url="file://$MODULE_DIR$/src/test/resources"/> | ||
<excludeFolder url="file://$MODULE_DIR$/.gradle"/> | ||
<excludeFolder url="file://$MODULE_DIR$/build"/> | ||
</contentEntry> | ||
<levels> | ||
<level name="Gradle: com.badlogicgames.ashley:ashley:1.3.1" value="project"/> | ||
<level name="Gradle: com.esotericsoftware.kryo:kryo:2.10" value="project"/> | ||
<level name="Gradle: com.esotericsoftware.reflectasm:reflectasm:1.03" value="project"/> | ||
<level name="Gradle: com.esotericsoftware.minlog:minlog:1.2" value="project"/> | ||
<level name="Gradle: org.objenesis:objenesis:1.2" value="project"/> | ||
<level name="Gradle: org.ow2.asm:asm:4.0" value="project"/> | ||
<level name="Gradle: com.badlogicgames.gdx:gdx:1.4.1" value="project"/> | ||
<level name="Gradle: com.badlogicgames.gdx:gdx-freetype:1.4.1" value="project"/> | ||
</levels> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
package macbury.forge.db; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
|
||
/** | ||
* Created by macbury on 07.11.14. | ||
*/ | ||
public class GameDatabase extends Kryo { | ||
public class GameDatabase { | ||
public static final String FILE_NAME = "game.db"; | ||
public String title; | ||
public int currentyUID = 0; | ||
|
||
/** | ||
* Create int uuid | ||
* @return unique id | ||
*/ | ||
public int uid() { | ||
return currentyUID += 1; | ||
} | ||
|
||
/** | ||
* Bootstrap db with default values | ||
*/ | ||
public void bootstrap() { | ||
title = "ForgE Project"; | ||
currentyUID = 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package macbury.forge.storage; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.files.FileHandle; | ||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.io.Input; | ||
import com.esotericsoftware.kryo.io.Output; | ||
import macbury.forge.db.GameDatabase; | ||
import macbury.forge.storage.serializers.GameDatabseSerializer; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
|
||
/** | ||
* Created by macbury on 07.11.14. | ||
*/ | ||
public class StorageManager extends Kryo { | ||
public StorageManager() { | ||
super(); | ||
register(GameDatabase.class, new GameDatabseSerializer()); | ||
} | ||
|
||
public GameDatabase loadOrInitializeDB() { | ||
FileHandle dbFile = Gdx.files.internal(GameDatabase.FILE_NAME); | ||
GameDatabase db = null; | ||
if (dbFile.exists()) { | ||
db = readObject(new Input(dbFile.read()), GameDatabase.class); | ||
} else { | ||
db = new GameDatabase(); | ||
db.bootstrap(); | ||
saveDB(db); | ||
} | ||
|
||
return db; | ||
} | ||
|
||
public void saveDB(GameDatabase db) { | ||
FileHandle dbFile = Gdx.files.internal(GameDatabase.FILE_NAME); | ||
try { | ||
Output output = new Output(new FileOutputStream(dbFile.file(), false)); | ||
writeObject(output, db); | ||
output.close(); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
core/src/macbury/forge/storage/serializers/GameDatabseSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package macbury.forge.storage.serializers; | ||
|
||
import com.esotericsoftware.kryo.Kryo; | ||
import com.esotericsoftware.kryo.Serializer; | ||
import com.esotericsoftware.kryo.io.Input; | ||
import com.esotericsoftware.kryo.io.Output; | ||
import macbury.forge.db.GameDatabase; | ||
|
||
/** | ||
* Created by macbury on 10.11.14. | ||
*/ | ||
public class GameDatabseSerializer extends Serializer<GameDatabase> { | ||
@Override | ||
public void write(Kryo kryo, Output output, GameDatabase gameDatabase) { | ||
output.writeInt(gameDatabase.currentyUID); | ||
output.writeString(gameDatabase.title); | ||
} | ||
|
||
@Override | ||
public GameDatabase read(Kryo kryo, Input input, Class<GameDatabase> type) { | ||
GameDatabase db = new GameDatabase(); | ||
db.bootstrap(); | ||
db.currentyUID = input.readInt(); | ||
db.title = input.readString(); | ||
return db; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.