summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-09 14:28:11 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-09 14:28:11 +0100
commit17ec9220007929f598b862b3e44eb3128ddf9003 (patch)
tree15e37eb9583cd723d3046ae8666c4728c997391a
parent15257cfb2750a439a55e993fd85b2c2ccd5478b8 (diff)
downloadRustAndDust-17ec9220007929f598b862b3e44eb3128ddf9003.zip
RustAndDust-17ec9220007929f598b862b3e44eb3128ddf9003.tar.gz
Config: add attribute int i to Graphics enum then replace switch code with String.format()
-rw-r--r--core/src/ch/asynk/tankontank/TankOnTank.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/Config.java21
-rw-r--r--core/src/ch/asynk/tankontank/game/battles/Factory.java13
3 files changed, 17 insertions, 43 deletions
diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java
index 70b118f..390fca2 100644
--- a/core/src/ch/asynk/tankontank/TankOnTank.java
+++ b/core/src/ch/asynk/tankontank/TankOnTank.java
@@ -89,16 +89,9 @@ public class TankOnTank extends Game
manager.load("data/map_a.png", Texture.class);
if (config.battle.getMapType() == Factory.MapType.MAP_B)
manager.load("data/map_b.png", Texture.class);
- switch (config.graphics) {
- case MINE:
- manager.load("data/units0.atlas", TextureAtlas.class);
- manager.load("data/unit-overlays0.atlas", TextureAtlas.class);
- break;
- case ORIGINAL:
- manager.load("data/units1.atlas", TextureAtlas.class);
- manager.load("data/unit-overlays1.atlas", TextureAtlas.class);
- break;
- }
+ int i = config.graphics.i;
+ manager.load(String.format("data/units%d.atlas",i), TextureAtlas.class);
+ manager.load(String.format("data/unit-overlays%d.atlas", i), TextureAtlas.class);
manager.load("data/hex.png", Texture.class);
manager.load("data/hud.atlas", TextureAtlas.class);
manager.load("data/hex-overlays.atlas", TextureAtlas.class);
@@ -125,16 +118,9 @@ public class TankOnTank extends Game
manager.unload("data/map_a.png");
if (config.battle.getMapType() == Factory.MapType.MAP_B)
manager.unload("data/map_b.png");
- switch (config.graphics) {
- case MINE:
- manager.unload("data/units0.atlas");
- manager.unload("data/unit-overlays0.atlas");
- break;
- case ORIGINAL:
- manager.unload("data/units1.atlas");
- manager.unload("data/unit-overlays1.atlas");
- break;
- }
+ int i = config.graphics.i;
+ manager.unload(String.format("data/units%d.atlas",i));
+ manager.unload(String.format("data/unit-overlays%d.atlas", i));
manager.unload("data/hex.png");
manager.unload("data/hud.atlas");
manager.unload("data/hex-overlays.atlas");
diff --git a/core/src/ch/asynk/tankontank/game/Config.java b/core/src/ch/asynk/tankontank/game/Config.java
index c949b54..976f1a6 100644
--- a/core/src/ch/asynk/tankontank/game/Config.java
+++ b/core/src/ch/asynk/tankontank/game/Config.java
@@ -3,25 +3,20 @@ package ch.asynk.tankontank.game;
public class Config
{
public enum Graphics {
- ORIGINAL("original"),
- MINE("mine");
+ MINE("mine", 0),
+ ORIGINAL("original", 1);
public String s;
- Graphics(String s)
+ public int i;
+ Graphics(String s, int i)
{
this.s = s;
+ this.i = i;
}
public Graphics next()
{
- Graphics next = null;
- switch(this) {
- case ORIGINAL:
- next = MINE;
- break;
- case MINE:
- next = ORIGINAL;
- break;
- }
- return next;
+ if (this == ORIGINAL)
+ return MINE;
+ return ORIGINAL;
}
};
diff --git a/core/src/ch/asynk/tankontank/game/battles/Factory.java b/core/src/ch/asynk/tankontank/game/battles/Factory.java
index 57328ad..7002e43 100644
--- a/core/src/ch/asynk/tankontank/game/battles/Factory.java
+++ b/core/src/ch/asynk/tankontank/game/battles/Factory.java
@@ -60,18 +60,11 @@ public class Factory implements Board.TileBuilder, Disposable
public void assetsLoaded()
{
if (assetsLoaded) return;
+ int i = game.config.graphics.i;
this.hudAtlas = game.manager.get("data/hud.atlas", TextureAtlas.class);
this.tileOverlaysAtlas = game.manager.get("data/hex-overlays.atlas", TextureAtlas.class);
- switch (game.config.graphics) {
- case MINE:
- this.pawnsAtlas = game.manager.get("data/units0.atlas", TextureAtlas.class);
- this.pawnOverlaysAtlas = game.manager.get("data/unit-overlays0.atlas", TextureAtlas.class);
- break;
- case ORIGINAL:
- this.pawnsAtlas = game.manager.get("data/units1.atlas", TextureAtlas.class);
- this.pawnOverlaysAtlas = game.manager.get("data/unit-overlays1.atlas", TextureAtlas.class);
- break;
- }
+ this.pawnsAtlas = game.manager.get(String.format("data/units%d.atlas", i), TextureAtlas.class);
+ this.pawnOverlaysAtlas = game.manager.get(String.format("data/unit-overlays%d.atlas", i), TextureAtlas.class);
this.assetsLoaded = true;
}