diff options
21 files changed, 122 insertions, 130 deletions
diff --git a/android/assets/data/menu.atlas b/android/assets/data/menu.atlas deleted file mode 100644 index f771f88..0000000 --- a/android/assets/data/menu.atlas +++ /dev/null @@ -1,48 +0,0 @@ - -menu.png -size: 1024,256 -format: RGBA8888 -filter: Nearest,Nearest -repeat: none -from - rotate: false - xy: 2, 2 - size: 190, 217 - orig: 190, 217 - offset: 0, 0 - index: -1 -ge-flag - rotate: false - xy: 516, 118 - size: 153, 101 - orig: 153, 101 - offset: 0, 0 - index: -1 -move - rotate: false - xy: 826, 105 - size: 100, 114 - orig: 100, 114 - offset: 0, 0 - index: -1 -to - rotate: false - xy: 194, 2 - size: 190, 217 - orig: 190, 217 - offset: 0, 0 - index: -1 -unit - rotate: false - xy: 386, 91 - size: 128, 128 - orig: 128, 128 - offset: 0, 0 - index: -1 -us-flag - rotate: false - xy: 671, 121 - size: 153, 98 - orig: 153, 98 - offset: 0, 0 - index: -1 diff --git a/android/assets/data/menu.png b/android/assets/data/menu.png Binary files differdeleted file mode 100644 index ff069da..0000000 --- a/android/assets/data/menu.png +++ /dev/null diff --git a/android/assets/data/ui.atlas b/android/assets/data/ui.atlas index 04e8940..2271124 100644 --- a/android/assets/data/ui.atlas +++ b/android/assets/data/ui.atlas @@ -1,36 +1,78 @@ ui.png -size: 256,128 +size: 1024,256 format: RGBA8888 filter: Nearest,Nearest repeat: none cancel rotate: false - xy: 2, 52 + xy: 386, 26 size: 64, 63 orig: 64, 63 offset: 0, 0 index: -1 disabled rotate: false - xy: 2, 2 + xy: 452, 41 size: 48, 48 orig: 48, 48 offset: 0, 0 index: -1 +from + rotate: false + xy: 2, 2 + size: 190, 217 + orig: 190, 217 + offset: 0, 0 + index: -1 +ge-flag + rotate: false + xy: 516, 118 + size: 153, 101 + orig: 153, 101 + offset: 0, 0 + index: -1 +move + rotate: false + xy: 826, 105 + size: 100, 114 + orig: 100, 114 + offset: 0, 0 + index: -1 ok rotate: false - xy: 68, 52 + xy: 928, 156 size: 64, 63 orig: 64, 63 offset: 0, 0 index: -1 +to + rotate: false + xy: 194, 2 + size: 190, 217 + orig: 190, 217 + offset: 0, 0 + index: -1 typewriter rotate: false - xy: 134, 67 + xy: 928, 106 size: 48, 48 split: 23, 23, 23, 23 pad: 11, 11, 12, 12 orig: 48, 48 offset: 0, 0 index: -1 +unit + rotate: false + xy: 386, 91 + size: 128, 128 + orig: 128, 128 + offset: 0, 0 + index: -1 +us-flag + rotate: false + xy: 671, 121 + size: 153, 98 + orig: 153, 98 + offset: 0, 0 + index: -1 diff --git a/android/assets/data/ui.png b/android/assets/data/ui.png Binary files differindex 9f06845..5aa721d 100644 --- a/android/assets/data/ui.png +++ b/android/assets/data/ui.png diff --git a/assets/build.gradle b/assets/build.gradle index a2defc5..d44de99 100644 --- a/assets/build.gradle +++ b/assets/build.gradle @@ -36,12 +36,6 @@ task packUi(type: JavaExec) { args = ['../assets/ui', '../android/assets/data', 'ui'] } -task packMenu(type: JavaExec) { - main = 'com.badlogic.gdx.tools.texturepacker.TexturePacker' - classpath = configurations.texturePacker - args = ['../assets/menu', '../android/assets/data', 'menu'] -} - task packHud(type: JavaExec) { main = 'com.badlogic.gdx.tools.texturepacker.TexturePacker' classpath = configurations.texturePacker diff --git a/assets/menu/from.png b/assets/ui/from.png Binary files differindex 11e5178..11e5178 100644 --- a/assets/menu/from.png +++ b/assets/ui/from.png diff --git a/assets/menu/ge-flag.png b/assets/ui/ge-flag.png Binary files differindex 076be81..076be81 100644 --- a/assets/menu/ge-flag.png +++ b/assets/ui/ge-flag.png diff --git a/assets/menu/move.png b/assets/ui/move.png Binary files differindex ec975d6..ec975d6 100644 --- a/assets/menu/move.png +++ b/assets/ui/move.png diff --git a/assets/menu/to.png b/assets/ui/to.png Binary files differindex e076771..e076771 100644 --- a/assets/menu/to.png +++ b/assets/ui/to.png diff --git a/assets/menu/unit.png b/assets/ui/unit.png Binary files differindex b8eedd0..b8eedd0 100644 --- a/assets/menu/unit.png +++ b/assets/ui/unit.png diff --git a/assets/menu/us-flag.png b/assets/ui/us-flag.png Binary files differindex 1f4b754..1f4b754 100644 --- a/assets/menu/us-flag.png +++ b/assets/ui/us-flag.png diff --git a/core/src/ch/asynk/rustanddust/RustAndDust.java b/core/src/ch/asynk/rustanddust/RustAndDust.java index 3985379..5a63c70 100644 --- a/core/src/ch/asynk/rustanddust/RustAndDust.java +++ b/core/src/ch/asynk/rustanddust/RustAndDust.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; @@ -20,9 +21,9 @@ import ch.asynk.rustanddust.ui.Bg; public class RustAndDust extends Game { + public static final String NINEPATCH = "typewriter"; public static final String TTF_FONT = "skin/veteran-typewriter.ttf"; public static final String ATLAS_UI = "data/ui.atlas"; - public static final String ATLAS_MENU = "data/menu.atlas"; public static final String ATLAS_HUD = "data/hud.atlas"; public static final String ATLAS_UNITS = "data/units%d.atlas"; public static final String ATLAS_UNIT_OVERLAYS = "data/unit-overlays%d.atlas"; @@ -44,6 +45,15 @@ public class RustAndDust extends Game public static final String SND_PROMOTE_US = "sounds/promote_us.mp3"; public static final String SND_PROMOTE_GE = "sounds/promote_ge.mp3"; + public static final String UI_OK = "ok"; + public static final String UI_CANCEL = "cancel"; + public static final String UI_FROM = "from"; + public static final String UI_TO = "to"; + public static final String UI_MOVE = "move"; + public static final String UI_UNIT = "unit"; + public static final String UI_US_FLAG = "us-flag"; + public static final String UI_GE_FLAG = "ge-flag"; + public AssetManager manager; public Factory factory; public Ctrl ctrl; @@ -51,8 +61,8 @@ public class RustAndDust extends Game public int hudCorrection; public TextureAtlas uiAtlas; - public TextureAtlas menuAtlas; public BitmapFont font; + public NinePatch ninePatch; public enum State { @@ -72,6 +82,11 @@ public class RustAndDust extends Game Gdx.app.debug(dom, msg); } + public TextureAtlas.AtlasRegion getUiRegion(String s) + { + return uiAtlas.findRegion(s); + } + @Override public void create () { @@ -115,7 +130,7 @@ public class RustAndDust extends Game if (config.battle.getMapType() == Factory.MapType.MAP_00) manager.load(PNG_MAP_00, Texture.class); int i = config.graphics.i; - manager.load(String.format(ATLAS_UNITS,i), TextureAtlas.class); + manager.load(String.format(ATLAS_UNITS, i), TextureAtlas.class); manager.load(String.format(ATLAS_UNIT_OVERLAYS, i), TextureAtlas.class); manager.load(ATLAS_HUD, TextureAtlas.class); manager.load(ATLAS_HEX_OVERLAYS, TextureAtlas.class); @@ -142,8 +157,8 @@ public class RustAndDust extends Game if (config.battle.getMapType() == Factory.MapType.MAP_00) manager.unload(PNG_MAP_00); int i = config.graphics.i; - manager.unload(String.format(ATLAS_UNITS,i)); - manager.unload(String.format(ATLAS_UNIT_OVERLAYS)); + manager.unload(String.format(ATLAS_UNITS, i)); + manager.unload(String.format(ATLAS_UNIT_OVERLAYS, i)); manager.unload(ATLAS_HUD); manager.unload(ATLAS_HEX_OVERLAYS); manager.unload(PNG_SELECTED); @@ -177,6 +192,7 @@ public class RustAndDust extends Game parameter.size = Math.max((int) (h * 0.04f), 16); parameter.color = Color.BLACK; font = generator.generateFont(parameter); + ninePatch = uiAtlas.createPatch(NINEPATCH); } private void unloadUiAssets() @@ -188,15 +204,12 @@ public class RustAndDust extends Game private void loadMenuAssets() { manager.load(PNG_MAP_00, Texture.class); - manager.load(ATLAS_MENU, TextureAtlas.class); manager.finishLoading(); - menuAtlas = manager.get(ATLAS_MENU, TextureAtlas.class); } private void unloadMenuAssets() { manager.unload(PNG_MAP_00); - manager.unload(ATLAS_MENU); } // @Override diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index bd2d600..a60d125 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -65,8 +65,8 @@ public class Hud implements Disposable, Animation playerInfo = new PlayerInfo(ctrl, game.font, game.uiAtlas, hudAtlas); actionButtons = new ActionButtons(ctrl, game.uiAtlas, hudAtlas); actionButtons.hide(); - msg = new Msg(game.font, game.uiAtlas); - okCancel = new OkCancel(game.font, game.uiAtlas); + msg = new Msg(game.font, game.ninePatch, 20f); + okCancel = new OkCancel(game.font, game.ninePatch, game.getUiRegion(game.UI_OK), game.getUiRegion(game.UI_CANCEL)); stats = new StatisticsPanel(game.font, game.uiAtlas, hudAtlas); engagement = new EngagementPanel(game.font, game.uiAtlas, hudAtlas); } diff --git a/core/src/ch/asynk/rustanddust/menu/MainMenu.java b/core/src/ch/asynk/rustanddust/menu/MainMenu.java index ff65d50..620205a 100644 --- a/core/src/ch/asynk/rustanddust/menu/MainMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/MainMenu.java @@ -1,9 +1,8 @@ package ch.asynk.rustanddust.menu; import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import ch.asynk.rustanddust.RustAndDust; import ch.asynk.rustanddust.ui.Menu; public class MainMenu extends Menu @@ -24,9 +23,9 @@ public class MainMenu extends Menu public int last() { return NONE.i; } }; - public MainMenu(BitmapFont font, TextureAtlas atlas) + public MainMenu(RustAndDust game) { - super(Items.NONE, font, atlas.createPatch("typewriter")); + super(Items.NONE, game.font, game.ninePatch); label(Items.PLAY).write("Play"); label(Items.TUTORIALS).write("Tutorials"); diff --git a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java index e2b3b1e..4499405 100644 --- a/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/OptionsMenu.java @@ -3,7 +3,6 @@ package ch.asynk.rustanddust.menu; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.rustanddust.ui.Label; import ch.asynk.rustanddust.ui.Bg; @@ -44,14 +43,14 @@ public class OptionsMenu extends Patch protected Bg okBtn; protected Bg cancelBtn; - public OptionsMenu(RustAndDust game, BitmapFont font, TextureAtlas atlas) + public OptionsMenu(RustAndDust game) { - super(atlas.createPatch("typewriter")); + super(game.ninePatch); this.game = game; - this.font = font; - this.okCancel = new OkCancel(font, atlas); - this.okBtn = new Bg(atlas.findRegion("ok")); - this.cancelBtn = new Bg(atlas.findRegion("cancel")); + this.font = game.font; + this.okCancel = new OkCancel(font, game.ninePatch, game.getUiRegion(game.UI_OK), game.getUiRegion(game.UI_CANCEL)); + this.okBtn = new Bg(game.getUiRegion(game.UI_OK)); + this.cancelBtn = new Bg(game.getUiRegion(game.UI_CANCEL)); this.title = new Label(font); this.title.write("- Options"); this.fxVolume = new Label(font); diff --git a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java index cbf182d..866a647 100644 --- a/core/src/ch/asynk/rustanddust/menu/PlayMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/PlayMenu.java @@ -1,8 +1,6 @@ package ch.asynk.rustanddust.menu; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.rustanddust.ui.Label; import ch.asynk.rustanddust.ui.Bg; @@ -17,7 +15,6 @@ public class PlayMenu extends Patch public static int VSPACING = 30; private final RustAndDust game; - private final BitmapFont font; private Label title; private Label gameMode; @@ -32,22 +29,21 @@ public class PlayMenu extends Patch public boolean launch; - public PlayMenu(RustAndDust game, BitmapFont font, TextureAtlas atlas) + public PlayMenu(RustAndDust game) { - super(atlas.createPatch("typewriter")); + super(game.ninePatch); this.game = game; - this.font = font; - this.title = new Label(font); + this.title = new Label(game.font); this.title.write("- Play"); - this.gameMode = new Label(font); + this.gameMode = new Label(game.font); this.gameMode.write("Game mode : "); - this.gameModeValue = new Label(font); - this.okBtn = new Bg(atlas.findRegion("ok")); - this.cancelBtn = new Bg(atlas.findRegion("cancel")); - this.battle = new Label(font); + this.gameModeValue = new Label(game.font); + this.okBtn = new Bg(game.getUiRegion(game.UI_OK)); + this.cancelBtn = new Bg(game.getUiRegion(game.UI_CANCEL)); + this.battle = new Label(game.font); this.battle.write("Scenario : "); - this.battleValue = new Label(font); - this.okCancel = new OkCancel(font, atlas); + this.battleValue = new Label(game.font); + this.okCancel = new OkCancel(game.font, game.ninePatch, game.getUiRegion(game.UI_OK), game.getUiRegion(game.UI_CANCEL)); if (game.config.battle == null) { battleIdx = 0; diff --git a/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java b/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java index 7140e48..cb1fcef 100644 --- a/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/ScenariosMenu.java @@ -31,13 +31,13 @@ public class ScenariosMenu extends Patch public boolean launch; - public ScenariosMenu(RustAndDust game, BitmapFont font, TextureAtlas atlas) + public ScenariosMenu(RustAndDust game) { - super(atlas.createPatch("typewriter")); + super(game.ninePatch); this.game = game; - this.font = font; - this.okBtn = new Bg(atlas.findRegion("ok")); - this.cancelBtn = new Bg(atlas.findRegion("cancel")); + this.font = game.font; + this.okBtn = new Bg(game.getUiRegion(game.UI_OK)); + this.cancelBtn = new Bg(game.getUiRegion(game.UI_CANCEL)); this.title = new Label(font); this.title.write("- Scenarios"); this.battleLabels = new Label[game.factory.battles.length]; diff --git a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java index 53dd29f..87e2765 100644 --- a/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java +++ b/core/src/ch/asynk/rustanddust/menu/TutorialsMenu.java @@ -1,8 +1,6 @@ package ch.asynk.rustanddust.menu; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; import ch.asynk.rustanddust.ui.Label; import ch.asynk.rustanddust.ui.Bg; @@ -15,21 +13,19 @@ public class TutorialsMenu extends Patch public static int TITLE_PADDING = 30; private final RustAndDust game; - private final BitmapFont font; private Label title; private Label msg; protected Bg okBtn; - public TutorialsMenu(RustAndDust game, BitmapFont font, TextureAtlas atlas) + public TutorialsMenu(RustAndDust game) { - super(atlas.createPatch("typewriter")); + super(game.ninePatch); this.game = game; - this.font = font; - this.okBtn = new Bg(atlas.findRegion("ok")); - this.title = new Label(font); + this.okBtn = new Bg(game.getUiRegion(game.UI_OK)); + this.title = new Label(game.font); this.title.write("- Tutorials"); - this.msg = new Label(font); + this.msg = new Label(game.font); this.msg.write("Not implemented yet."); this.visible = false; diff --git a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java index d9d2221..48f9656 100644 --- a/core/src/ch/asynk/rustanddust/screens/MenuScreen.java +++ b/core/src/ch/asynk/rustanddust/screens/MenuScreen.java @@ -69,19 +69,19 @@ public class MenuScreen implements Screen this.gameAssetsLoading = false; - this.bg = game.manager.get("data/map_00.png", Texture.class); - - this.unit = new Sprite(game.menuAtlas.findRegion("unit")); - this.move = new Sprite(game.menuAtlas.findRegion("move")); - this.from = new Sprite(game.menuAtlas.findRegion("from")); - this.to = new Sprite(game.menuAtlas.findRegion("to")); - this.usFlag = new Sprite(game.menuAtlas.findRegion("us-flag")); - this.geFlag = new Sprite(game.menuAtlas.findRegion("ge-flag")); - - this.mainMenu = new MainMenu(game.font, game.uiAtlas); - this.playMenu = new PlayMenu(game, game.font, game.uiAtlas); - this.optionsMenu = new OptionsMenu(game, game.font, game.uiAtlas); - this.tutorialsMenu = new TutorialsMenu(game, game.font, game.uiAtlas); + this.bg = game.manager.get(game.PNG_MAP_00, Texture.class); + + this.unit = new Sprite(game.getUiRegion(game.UI_UNIT)); + this.move = new Sprite(game.getUiRegion(game.UI_MOVE)); + this.from = new Sprite(game.getUiRegion(game.UI_FROM)); + this.to = new Sprite(game.getUiRegion(game.UI_TO)); + this.usFlag = new Sprite(game.getUiRegion(game.UI_US_FLAG)); + this.geFlag = new Sprite(game.getUiRegion(game.UI_GE_FLAG)); + + this.mainMenu = new MainMenu(game); + this.playMenu = new PlayMenu(game); + this.optionsMenu = new OptionsMenu(game); + this.tutorialsMenu = new TutorialsMenu(game); Gdx.input.setInputProcessor(new InputAdapter() { @Override diff --git a/core/src/ch/asynk/rustanddust/ui/Msg.java b/core/src/ch/asynk/rustanddust/ui/Msg.java index e1e7c13..16c4e2d 100644 --- a/core/src/ch/asynk/rustanddust/ui/Msg.java +++ b/core/src/ch/asynk/rustanddust/ui/Msg.java @@ -2,17 +2,17 @@ package ch.asynk.rustanddust.ui; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class Msg extends Patch { private LabelStack label; - public Msg(BitmapFont font, TextureAtlas atlas) + public Msg(BitmapFont font, NinePatch patch, float fontSize) { - super(atlas.createPatch("typewriter")); - label = new LabelStack(font, 20f); + super(patch); + label = new LabelStack(font, fontSize); } @Override diff --git a/core/src/ch/asynk/rustanddust/ui/OkCancel.java b/core/src/ch/asynk/rustanddust/ui/OkCancel.java index c064102..7b0bd1c 100644 --- a/core/src/ch/asynk/rustanddust/ui/OkCancel.java +++ b/core/src/ch/asynk/rustanddust/ui/OkCancel.java @@ -1,8 +1,9 @@ package ch.asynk.rustanddust.ui; import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.NinePatch; import com.badlogic.gdx.graphics.g2d.BitmapFont; -import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class OkCancel extends Patch @@ -16,12 +17,12 @@ public class OkCancel extends Patch protected Bg okBtn; protected Bg cancelBtn; - public OkCancel(BitmapFont font, TextureAtlas atlas) + public OkCancel(BitmapFont font, NinePatch patch, AtlasRegion okRegion, AtlasRegion cancelRegion) { - super(atlas.createPatch("typewriter")); + super(patch); this.label = new Label(font); - this.okBtn = new Bg(atlas.findRegion("ok")); - this.cancelBtn = new Bg(atlas.findRegion("cancel")); + this.okBtn = new Bg(okRegion); + this.cancelBtn = new Bg(cancelRegion); this.visible = false; } |