From 24d97922c4f5f3a4a73b16778cfdfd96bba3c974 Mon Sep 17 00:00:00 2001 From: galaxyoyo Date: Thu, 8 Jan 2015 18:24:59 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=C3=A9=20taille=20dans=20la=20map?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../galaxyoyo/unknown/api/editor/EditorAPI.java | 2 +- .../galaxyoyo/unknown/api/editor/RawMap.java | 16 +++++++++++++++- src/main/java/galaxyoyo/unknown/editor/Map.java | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/galaxyoyo/unknown/api/editor/EditorAPI.java b/src/main/java/galaxyoyo/unknown/api/editor/EditorAPI.java index f652587..cee093b 100644 --- a/src/main/java/galaxyoyo/unknown/api/editor/EditorAPI.java +++ b/src/main/java/galaxyoyo/unknown/api/editor/EditorAPI.java @@ -32,7 +32,7 @@ public class EditorAPI } } - return RawMap.create(cases); + return RawMap.create(cases, width, height); } private static Gson createGson() diff --git a/src/main/java/galaxyoyo/unknown/api/editor/RawMap.java b/src/main/java/galaxyoyo/unknown/api/editor/RawMap.java index a01f397..7c5fad9 100644 --- a/src/main/java/galaxyoyo/unknown/api/editor/RawMap.java +++ b/src/main/java/galaxyoyo/unknown/api/editor/RawMap.java @@ -5,16 +5,30 @@ import java.util.List; public class RawMap { private List cases; + private int width; + private int height; public List getCases() { return cases; } - public static RawMap create(List cases) + public int getWidth() + { + return width; + } + + public int getHeight() + { + return height; + } + + public static RawMap create(List cases, int width, int height) { RawMap rm = new RawMap(); rm.cases = cases; + rm.width = width; + rm.height = height; return rm; } } diff --git a/src/main/java/galaxyoyo/unknown/editor/Map.java b/src/main/java/galaxyoyo/unknown/editor/Map.java index 9af4503..1ff0853 100644 --- a/src/main/java/galaxyoyo/unknown/editor/Map.java +++ b/src/main/java/galaxyoyo/unknown/editor/Map.java @@ -13,11 +13,16 @@ import java.util.List; public class Map { private final EditorFrame frame; + private int width; + private int height; private List cases = new ArrayList(); private java.util.Map casesMap = new HashMap(); public Map(RawMap raw) { + this.width = raw.getWidth(); + this.height = raw.getHeight(); + for (RawCase rc : raw.getCases()) { cases.add(Case.create(rc.getPosX(), rc.getPosY(), SpriteRegister.getCategory(rc.getCoucheOne().getPrimaryIndex()).get(rc.getCoucheOne().getSecondaryIndex()), SpriteRegister.getCategory(rc.getCoucheTwo().getPrimaryIndex()).get(rc.getCoucheTwo().getSecondaryIndex()), SpriteRegister.getCategory(rc.getCoucheThree().getPrimaryIndex()).get(rc.getCoucheThree().getSecondaryIndex()))); @@ -33,6 +38,16 @@ public class Map return frame; } + public int getWidth() + { + return width; + } + + public int getHeight() + { + return height; + } + public Case getCase(int x, int y) { if (casesMap.isEmpty())