summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/TankOnTank.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java21
2 files changed, 31 insertions, 16 deletions
diff --git a/core/src/ch/asynk/tankontank/TankOnTank.java b/core/src/ch/asynk/tankontank/TankOnTank.java
index 0d28391..95c7d6b 100644
--- a/core/src/ch/asynk/tankontank/TankOnTank.java
+++ b/core/src/ch/asynk/tankontank/TankOnTank.java
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
+import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import ch.asynk.tankontank.screens.LoadScreen;
@@ -21,6 +22,10 @@ public class TankOnTank extends Game
public Ctrl ctrl;
public Config config;
+ public TextureAtlas uiAtlas;
+ public BitmapFont fontB;
+ public BitmapFont fontW;
+
public static void debug(String msg)
{
debug("", msg);
@@ -41,6 +46,7 @@ public class TankOnTank extends Game
factory = new Factory(this);
config = new Config();
+ loadUiAssets();
this.setScreen(new LoadScreen(this));
}
@@ -50,7 +56,6 @@ public class TankOnTank extends Game
manager.load("data/map_a.png", Texture.class);
manager.load("data/map_b.png", Texture.class);
manager.load("data/hex.png", Texture.class);
- manager.load("data/ui.atlas", TextureAtlas.class);
manager.load("data/hud.atlas", TextureAtlas.class);
manager.load("data/units.atlas", TextureAtlas.class);
manager.load("data/unit-overlays.atlas", TextureAtlas.class);
@@ -76,7 +81,6 @@ public class TankOnTank extends Game
manager.unload("data/map_a.png");
manager.unload("data/map_b.png");
manager.unload("data/hex.png");
- manager.unload("data/ui.atlas");
manager.unload("data/hud.atlas");
manager.unload("data/units.atlas");
manager.unload("data/unit-overlays.atlas");
@@ -96,6 +100,23 @@ public class TankOnTank extends Game
debug("TankOnTank", "diagnostics:\n" + manager.getDiagnostics() );
}
+ public void loadUiAssets()
+ {
+ manager.load("data/ui.atlas", TextureAtlas.class);
+ manager.finishLoading();
+ uiAtlas = manager.get("data/ui.atlas", TextureAtlas.class);
+ fontB = new BitmapFont(Gdx.files.internal("skin/veteran.fnt"), uiAtlas.findRegion("veteran-black"));
+ fontW = new BitmapFont(Gdx.files.internal("skin/veteran.fnt"), uiAtlas.findRegion("veteran-white"));
+ }
+
+ public void unloadUiAssets()
+ {
+ fontB.dispose();
+ fontW.dispose();
+ uiAtlas.dispose();
+ manager.unload("data/ui.atlas");
+ }
+
public void switchToOptions()
{
factory.assetsLoaded();
@@ -128,6 +149,7 @@ public class TankOnTank extends Game
debug("TankOnTank", "dispose()");
getScreen().dispose();
factory.dispose();
+ unloadUiAssets();
unloadAssets();
}
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index c72ae91..8b96696 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -33,8 +33,6 @@ public class Hud implements Disposable, Animation
private final Ctrl ctrl;
private Object hit;
- private BitmapFont fontB;
- private BitmapFont fontW;
public PlayerInfo playerInfo;
public ActionButtons actionButtons;
@@ -51,23 +49,18 @@ public class Hud implements Disposable, Animation
this.ctrl = ctrl;
TextureAtlas hudAtlas = game.factory.hudAtlas;
- TextureAtlas uiAtlas = game.manager.get("data/ui.atlas", TextureAtlas.class);
- fontB = new BitmapFont(Gdx.files.internal("skin/veteran.fnt"), uiAtlas.findRegion("veteran-black"));
- fontW = new BitmapFont(Gdx.files.internal("skin/veteran.fnt"), uiAtlas.findRegion("veteran-white"));
- playerInfo = new PlayerInfo(ctrl, fontW, uiAtlas, hudAtlas);
- actionButtons = new ActionButtons(ctrl, uiAtlas, hudAtlas);
+ playerInfo = new PlayerInfo(ctrl, game.fontW, game.uiAtlas, hudAtlas);
+ actionButtons = new ActionButtons(ctrl, game.uiAtlas, hudAtlas);
actionButtons.hide();
- msg = new Msg(fontB, uiAtlas);
- okCancel = new OkCancel(fontB, uiAtlas);
- stats = new Statistics(fontB, uiAtlas);
- engagement = new Engagement(fontB, uiAtlas, hudAtlas);
+ msg = new Msg(game.fontB, game.uiAtlas);
+ okCancel = new OkCancel(game.fontB, game.uiAtlas);
+ stats = new Statistics(game.fontB, game.uiAtlas);
+ engagement = new Engagement(game.fontB, game.uiAtlas, hudAtlas);
}
@Override
public void dispose()
{
- fontB.dispose();
- fontW.dispose();
playerInfo.dispose();
actionButtons.dispose();
msg.dispose();
@@ -107,7 +100,7 @@ public class Hud implements Disposable, Animation
{
draw(batch);
if (debug)
- fontB.draw(batch, String.format("FPS: %d", Gdx.graphics.getFramesPerSecond()), 80, 25);
+ game.fontB.draw(batch, String.format("FPS: %d", Gdx.graphics.getFramesPerSecond()), 80, 25);
}
@Override