From 75c4dd384b4597a05778728272a18bbeadab27ab Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sun, 25 Nov 2018 16:44:11 +0100 Subject: Make Map.get take a path relative to /subconscious/res/maps --- src/subconscious/Game.java | 2 +- src/subconscious/MapLoader.java | 8 +++++++- 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; -- cgit v1.2.1