summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-11-25 16:44:11 +0100
committerNao Pross <naopross@thearcway.org>2018-11-25 16:44:11 +0100
commit75c4dd384b4597a05778728272a18bbeadab27ab (patch)
tree7d7f9e91134c3950eb1d3d6371325c1f9ca8fd1f /src
parentAdd jar recipe in Makefile, move res folder inside package (diff)
downloadSubconscious-java-75c4dd384b4597a05778728272a18bbeadab27ab.tar.gz
Subconscious-java-75c4dd384b4597a05778728272a18bbeadab27ab.zip
Make Map.get take a path relative to /subconscious/res/maps
Diffstat (limited to 'src')
-rw-r--r--src/subconscious/Game.java2
-rw-r--r--src/subconscious/MapLoader.java8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/subconscious/Game.java b/src/subconscious/Game.java
index 7ef3e8d..a7493b3 100644
--- a/src/subconscious/Game.java
+++ b/src/subconscious/Game.java
@@ -45,7 +45,7 @@ public class Game {
// TODO: this will be replaced with a dynamic mechanism based
// on the progress within the game
- Map testMap = this.mapLoader.get("/subconscious/res/maps/testmap.json");
+ Map testMap = this.mapLoader.get("testmap.json");
this.currentMap = testMap;
this.maps.add(testMap);
diff --git a/src/subconscious/MapLoader.java b/src/subconscious/MapLoader.java
index b7e97d2..b89f8b0 100644
--- a/src/subconscious/MapLoader.java
+++ b/src/subconscious/MapLoader.java
@@ -19,6 +19,8 @@ import java.lang.UnsupportedOperationException;
// TODO: this class loads AND saves classes, refractor name
public class MapLoader {
+ public static final String MAPS_RESOURCES_PATH = "/subconscious/res/maps/";
+
private Gson gson = new GsonBuilder().setPrettyPrinting().create();;
public MapLoader() {
@@ -30,7 +32,11 @@ public class MapLoader {
throw new UnsupportedOperationException();
}
- public Map get(final String resourceName) {
+ public Map get(final String mapName) {
+ return this.getAbsolute(MAPS_RESOURCES_PATH + mapName);
+ }
+
+ public Map getAbsolute(final String resourceName) {
InputStream is = MapLoader.class.getResourceAsStream(resourceName);
assert is != null;