diff --git a/forge-gui-mobile/pom.xml b/forge-gui-mobile/pom.xml
index 989b5144609..94c382bac3a 100644
--- a/forge-gui-mobile/pom.xml
+++ b/forge-gui-mobile/pom.xml
@@ -28,6 +28,10 @@
gdx-nightlies
https://oss.sonatype.org/content/repositories/snapshots/
+
+ jitpack.io
+ https://jitpack.io
+
@@ -50,6 +54,11 @@
forge-gui
${project.version}
+
+ com.github.tommyettinger
+ textratypist
+ 0.7.9
+
com.badlogicgames.gdx-controllers
gdx-controllers-core
diff --git a/forge-gui-mobile/src/forge/Forge.java b/forge-gui-mobile/src/forge/Forge.java
index d0e3073e22f..6e93c9a9c01 100644
--- a/forge-gui-mobile/src/forge/Forge.java
+++ b/forge-gui-mobile/src/forge/Forge.java
@@ -253,7 +253,7 @@ public class Forge implements ApplicationListener {
public static boolean hasGamepad() {
//Classic Mode Various Screen GUI are not yet supported, needs control mapping for each screens
if (isMobileAdventureMode) {
- return hasGamepad && Forge.isLandscapeMode(); //portrait is not supported for Gamepad
+ return hasGamepad && isLandscapeMode(); //portrait is not supported for Gamepad
}
return false;
}
@@ -348,14 +348,14 @@ public class Forge implements ApplicationListener {
//override transition & title bg
try {
FileHandle transitionFile = Config.instance().getFile("ui/transition.png");
- FileHandle titleBGFile = Forge.isLandscapeMode() ? Config.instance().getFile("ui/title_bg.png") : Config.instance().getFile("ui/title_bg_portrait.png");
+ FileHandle titleBGFile = isLandscapeMode() ? Config.instance().getFile("ui/title_bg.png") : Config.instance().getFile("ui/title_bg_portrait.png");
FileHandle vsIcon = Config.instance().getFile("ui/vs.png");
if (vsIcon.exists())
- Forge.getAssets().fallback_skins().put(2, new Texture(vsIcon));
+ getAssets().fallback_skins().put("vs", new Texture(vsIcon));
if (transitionFile.exists())
- Forge.getAssets().fallback_skins().put(1, new Texture(transitionFile));
+ getAssets().fallback_skins().put("transition", new Texture(transitionFile));
if (titleBGFile.exists())
- Forge.getAssets().fallback_skins().put(0, new Texture(titleBGFile));
+ getAssets().fallback_skins().put("title", new Texture(titleBGFile));
AdventureScreen.preload();
} catch (Exception e) {
e.printStackTrace();
@@ -383,7 +383,7 @@ public class Forge implements ApplicationListener {
if (selector.equals("Adventure")) {
//preload adventure resources to speedup startup if selector is adventure. Needs in edt when setting up worldstage
loadAdventureResources(false);
- Forge.isMobileAdventureMode = true;
+ isMobileAdventureMode = true;
}
//selection transition
setTransitionScreen(new TransitionScreen(() -> {
@@ -408,7 +408,7 @@ public class Forge implements ApplicationListener {
SoundSystem.instance.setBackgroundMusic(MusicPlaylist.MENUS);
safeToClose = true;
clearTransitionScreen();
- }, Forge.takeScreenshot(), false, false, true, false));
+ }, takeScreenshot(), false, false, true, false));
});
});
}));
@@ -829,7 +829,7 @@ public class Forge implements ApplicationListener {
@Override
public void render() {
if (showFPS)
- frameRate.update(ImageCache.counter, Forge.getAssets().manager().getMemoryInMegabytes());
+ frameRate.update(ImageCache.counter, getAssets().manager().getMemoryInMegabytes());
try {
ImageCache.allowSingleLoad();
@@ -865,8 +865,8 @@ public class Forge implements ApplicationListener {
animationBatch.setColor(1, 1, 1, 1);
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
animationBatch.setColor(1, 1, 1, 1 - (1 / transitionTime) * animationTimeout);
- animationBatch.draw(getAssets().fallback_skins().get(1), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- animationBatch.draw(getAssets().fallback_skins().get(1), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ animationBatch.draw(getAssets().fallback_skins().get("transition"), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ animationBatch.draw(getAssets().fallback_skins().get("transition"), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
animationBatch.end();
if (animationTimeout < 0) {
currentScene.render();
@@ -885,8 +885,8 @@ public class Forge implements ApplicationListener {
animationBatch.setColor(1, 1, 1, 1);
animationBatch.draw(lastScreenTexture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
animationBatch.setColor(1, 1, 1, (1 / transitionTime) * (animationTimeout + transitionTime));
- animationBatch.draw(getAssets().fallback_skins().get(1), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
- animationBatch.draw(getAssets().fallback_skins().get(1), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ animationBatch.draw(getAssets().fallback_skins().get("transition"), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ animationBatch.draw(getAssets().fallback_skins().get("transition"), 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
animationBatch.end();
return;
}
diff --git a/forge-gui-mobile/src/forge/GuiMobile.java b/forge-gui-mobile/src/forge/GuiMobile.java
index ab3700a617f..e1056a21896 100644
--- a/forge-gui-mobile/src/forge/GuiMobile.java
+++ b/forge-gui-mobile/src/forge/GuiMobile.java
@@ -105,7 +105,7 @@ public class GuiMobile implements IGuiBase {
@Override
public ISkinImage getUnskinnedIcon(final String path) {
if (isGuiThread()) {
- return new FTextureImage(new Texture(Gdx.files.absolute(path)));
+ return new FTextureImage(Forge.getAssets().getTexture(Gdx.files.absolute(path)));
}
//use a delay load image to avoid an error if called from background thread
@@ -131,7 +131,7 @@ public class GuiMobile implements IGuiBase {
if (FileUtil.doesFileExist(overlayFilename)) {
try {
- final Texture overlay = new Texture(Gdx.files.absolute(overlayFilename));
+ final Texture overlay = Forge.getAssets().getTexture(Gdx.files.absolute(overlayFilename));
g.drawImage(overlay, (background.getWidth() - overlay.getWidth()) / 2, (background.getHeight() - overlay.getHeight()) / 2, overlay.getWidth(), overlay.getHeight());
} catch (final Exception e) {
}
diff --git a/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java b/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java
index f988d5069cd..cebf22a5b30 100644
--- a/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java
+++ b/forge-gui-mobile/src/forge/adventure/scene/InventoryScene.java
@@ -37,7 +37,7 @@ public class InventoryScene extends UIScene {
public InventoryScene() {
super(Forge.isLandscapeMode() ? "ui/inventory.json" : "ui/inventory_portrait.json");
- equipOverlay = new Texture(Config.instance().getFile(Paths.ITEMS_EQUIP));
+ equipOverlay = Forge.getAssets().getTexture(Config.instance().getFile(Paths.ITEMS_EQUIP));
ui.onButtonPress("return", () -> done());
leave = ui.findActor("return");
ui.onButtonPress("delete", () -> showConfirm());
diff --git a/forge-gui-mobile/src/forge/adventure/scene/RewardScene.java b/forge-gui-mobile/src/forge/adventure/scene/RewardScene.java
index 7d3dd5e62c4..109a7e75306 100644
--- a/forge-gui-mobile/src/forge/adventure/scene/RewardScene.java
+++ b/forge-gui-mobile/src/forge/adventure/scene/RewardScene.java
@@ -305,7 +305,6 @@ public class RewardScene extends UIScene {
if(background!=null)
background.setVisible(false);
}
- // card.setDrawable(new TextureRegionDrawable(new Texture(Res.CurrentRes.GetFile("ui/transition.png"))));
float targetWidth = card.getWidth();
float targetHeight = card.getHeight();
diff --git a/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java b/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java
index c64c29f86cb..35b37e4f34a 100644
--- a/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java
+++ b/forge-gui-mobile/src/forge/adventure/stage/GameHUD.java
@@ -95,7 +95,7 @@ public class GameHUD extends Stage {
exitToWorldMapActor = ui.findActor("exittoworldmap");
dialog = Controls.newDialog("");
- miniMapPlayer = new Image(new Texture(Config.instance().getFile("ui/minimap_player.png")));
+ miniMapPlayer = new Image(Forge.getAssets().getTexture(Config.instance().getFile("ui/minimap_player.png")));
//create touchpad
touchpad = new Touchpad(10, Controls.getSkin());
touchpad.setBounds(15, 15, TOUCHPAD_SCALE, TOUCHPAD_SCALE);
diff --git a/forge-gui-mobile/src/forge/adventure/util/UIActor.java b/forge-gui-mobile/src/forge/adventure/util/UIActor.java
index c1115b19975..f1deec90ac1 100644
--- a/forge-gui-mobile/src/forge/adventure/util/UIActor.java
+++ b/forge-gui-mobile/src/forge/adventure/util/UIActor.java
@@ -287,7 +287,7 @@ public class UIActor extends Group {
for (ObjectMap.Entry property : entries) {
switch (property.key.toString()) {
case "image":
- Texture t = new Texture(Config.instance().getFile(property.value.toString()));
+ Texture t = Forge.getAssets().getTexture(Config.instance().getFile(property.value.toString()));
TextureRegion tr = new TextureRegion(t);
newActor.setDrawable(new TextureRegionDrawable(tr));
break;
diff --git a/forge-gui-mobile/src/forge/adventure/world/World.java b/forge-gui-mobile/src/forge/adventure/world/World.java
index f32d507dfae..a94706bc3b1 100644
--- a/forge-gui-mobile/src/forge/adventure/world/World.java
+++ b/forge-gui-mobile/src/forge/adventure/world/World.java
@@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.Json;
+import forge.Forge;
import forge.adventure.data.*;
import forge.adventure.pointofintrest.PointOfInterest;
import forge.adventure.pointofintrest.PointOfInterestMap;
@@ -912,7 +913,7 @@ public class World implements Disposable, SaveFileContent {
public Texture getGlobalTexture() {
if (globalTexture == null) {
- globalTexture = new Texture(Config.instance().getFile("ui/sprite_markers.png"));
+ globalTexture = Forge.getAssets().getTexture(Config.instance().getFile("ui/sprite_markers.png"));
System.out.print("Loading auxiliary sprites.\n");
}
return globalTexture;
diff --git a/forge-gui-mobile/src/forge/assets/Assets.java b/forge-gui-mobile/src/forge/assets/Assets.java
index 8b71e85eae1..70727026140 100644
--- a/forge-gui-mobile/src/forge/assets/Assets.java
+++ b/forge-gui-mobile/src/forge/assets/Assets.java
@@ -40,7 +40,7 @@ public class Assets implements Disposable {
private HashMap cursor;
private ObjectMap counterFonts;
private ObjectMap generatedCards;
- private ObjectMap fallback_skins;
+ private ObjectMap fallback_skins;
private ObjectMap tmxMap;
private Texture defaultImage, dummy;
private TextureParameter textureParameter;
@@ -54,16 +54,16 @@ public class Assets implements Disposable {
Texture titleBG_LQ = GuiBase.isAndroid() ?
new Texture(Gdx.files.internal("fallback_skin").child(titleFilename)) :
new Texture(Gdx.files.classpath("fallback_skin").child(titleFilename));
- fallback_skins().put(0, titleBG_LQ == null ? getDummy() : titleBG_LQ);
+ fallback_skins().put("title", titleBG_LQ == null ? getDummy() : titleBG_LQ);
//init transition
Texture transitionLQ = GuiBase.isAndroid() ?
new Texture(Gdx.files.internal("fallback_skin").child("transition.png")) :
new Texture(Gdx.files.classpath("fallback_skin").child("transition.png"));
- fallback_skins().put(1, transitionLQ == null ? getDummy() : transitionLQ);
+ fallback_skins().put("transition", transitionLQ == null ? getDummy() : transitionLQ);
} catch (Exception e) {
fallback_skins().clear();
- fallback_skins().put(0, getDummy());
- fallback_skins().put(1, getDummy());
+ fallback_skins().put("title", getDummy());
+ fallback_skins().put("transition", getDummy());
}
}
@@ -202,7 +202,7 @@ public class Assets implements Disposable {
return generatedCards;
}
- public ObjectMap fallback_skins() {
+ public ObjectMap fallback_skins() {
if (fallback_skins == null)
fallback_skins = new ObjectMap<>();
return fallback_skins;
@@ -229,6 +229,28 @@ public class Assets implements Disposable {
return textureParameter;
}
+ public Texture getTexture(FileHandle file) {
+ if (file == null || !file.exists()) {
+ System.err.println("Failed to load: " + file +"!. Creating dummy texture.");
+ return getDummy();
+ }
+ //internal path can be inside apk or jar..
+ if (file.path().contains("fallback_skin")) {
+ Texture f = fallback_skins().get(file.path());
+ if (f == null) {
+ fallback_skins().put(file.path(), new Texture(file));
+ }
+ return f;
+ }
+ Texture t = manager.get(file.path(), Texture.class, false);
+ if (t == null) {
+ manager.load(file.path(), Texture.class, getTextureFilter());
+ manager.finishLoadingAsset(file.path());
+ t = manager.get(file.path(), Texture.class);
+ }
+ return t;
+ }
+
public Texture getDefaultImage() {
if (defaultImage == null) {
FileHandle blankImage = Gdx.files.absolute(ForgeConstants.NO_CARD_FILE);
diff --git a/forge-gui-mobile/src/forge/assets/FDelayLoadImage.java b/forge-gui-mobile/src/forge/assets/FDelayLoadImage.java
index 10a339f59ba..0433f617396 100644
--- a/forge-gui-mobile/src/forge/assets/FDelayLoadImage.java
+++ b/forge-gui-mobile/src/forge/assets/FDelayLoadImage.java
@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
+import forge.Forge;
import forge.Graphics;
//Special wrapper for a texture to be loaded later when it's needed
@@ -28,7 +29,7 @@ public class FDelayLoadImage extends FImageComplex {
@Override
public Texture getTexture() {
if (texture == null) {
- texture = new Texture(Gdx.files.absolute(filename));
+ texture = Forge.getAssets().getTexture(Gdx.files.absolute(filename));
}
return texture;
}
@@ -36,7 +37,7 @@ public class FDelayLoadImage extends FImageComplex {
@Override
public TextureRegion getTextureRegion() {
if (texture == null) {
- texture = new Texture(Gdx.files.absolute(filename));
+ texture = Forge.getAssets().getTexture(Gdx.files.absolute(filename));
}
return new TextureRegion(texture);
}
diff --git a/forge-gui-mobile/src/forge/assets/FSkinTexture.java b/forge-gui-mobile/src/forge/assets/FSkinTexture.java
index 4437f8d7e66..c9a9ec9c39f 100644
--- a/forge-gui-mobile/src/forge/assets/FSkinTexture.java
+++ b/forge-gui-mobile/src/forge/assets/FSkinTexture.java
@@ -202,13 +202,7 @@ public enum FSkinTexture implements FImage {
FileHandle preferredFile = isPlanechaseBG ? FSkin.getCachePlanechaseFile(filename) : FSkin.getSkinFile(filename);
if (preferredFile.exists()) {
try {
- if (preferredFile.path().contains("fallback_skin")) {
- texture = new Texture(preferredFile);
- } else {
- Forge.getAssets().manager().load(preferredFile.path(), Texture.class);
- Forge.getAssets().manager().finishLoadingAsset(preferredFile.path());
- texture = Forge.getAssets().manager().get(preferredFile.path(), Texture.class);
- }
+ texture = Forge.getAssets().getTexture(preferredFile);
isloaded = true;
}
catch (final Exception e) {
@@ -229,13 +223,7 @@ public enum FSkinTexture implements FImage {
if (defaultFile.exists()) {
try {
- if (defaultFile.path().contains("fallback_skin")) {
- texture = new Texture(defaultFile);
- } else {
- Forge.getAssets().manager().load(defaultFile.path(), Texture.class);
- Forge.getAssets().manager().finishLoadingAsset(defaultFile.path());
- texture = Forge.getAssets().manager().get(defaultFile.path(), Texture.class);
- }
+ texture = Forge.getAssets().getTexture(defaultFile);
isloaded = true;
}
catch (final Exception e) {
diff --git a/forge-gui-mobile/src/forge/screens/ClosingScreen.java b/forge-gui-mobile/src/forge/screens/ClosingScreen.java
index f99f301a4ad..9e0a55d3767 100644
--- a/forge-gui-mobile/src/forge/screens/ClosingScreen.java
+++ b/forge-gui-mobile/src/forge/screens/ClosingScreen.java
@@ -21,7 +21,7 @@ public class ClosingScreen extends FContainer {
private boolean drawStatic = false;
private FileHandle adv_logo = getSkinFile("adv_logo.png");
private FileHandle existingLogo = adv_logo.exists() ? adv_logo : getDefaultSkinFile("adv_logo.png");
- private Texture logo = existingLogo.exists() && Forge.advStartup ? new Texture(existingLogo) : FSkin.getLogo();
+ private Texture logo = existingLogo.exists() && Forge.advStartup ? Forge.getAssets().getTexture(existingLogo) : FSkin.getLogo();
public ClosingScreen(boolean restart0) {
bgAnimation = new BGAnimation();
diff --git a/forge-gui-mobile/src/forge/screens/SplashScreen.java b/forge-gui-mobile/src/forge/screens/SplashScreen.java
index 72e3c0d3991..aa764e4b458 100644
--- a/forge-gui-mobile/src/forge/screens/SplashScreen.java
+++ b/forge-gui-mobile/src/forge/screens/SplashScreen.java
@@ -239,7 +239,7 @@ public class SplashScreen extends FContainer {
}
void drawTransition(Graphics g, boolean openAdventure, float percentage) {
- TextureRegion tr = new TextureRegion(Forge.getAssets().fallback_skins().get(0));
+ TextureRegion tr = new TextureRegion(Forge.getAssets().fallback_skins().get("title"));
float oldAlpha = g.getfloatAlphaComposite();
g.setAlphaComposite(percentage);
if (openAdventure) {
diff --git a/forge-gui-mobile/src/forge/screens/TransitionScreen.java b/forge-gui-mobile/src/forge/screens/TransitionScreen.java
index 43efb939349..3d3b8ba18ea 100644
--- a/forge-gui-mobile/src/forge/screens/TransitionScreen.java
+++ b/forge-gui-mobile/src/forge/screens/TransitionScreen.java
@@ -67,7 +67,7 @@ public class TransitionScreen extends FContainer {
playerAvatarName = playerName;
enemyAvatarName = enemyName;
enemyAtlasPath = enemyAtlas;
- vsTexture = Forge.getAssets().fallback_skins().get(2);
+ vsTexture = Forge.getAssets().fallback_skins().get("vs");
layout = new GlyphLayout();
}
@@ -207,7 +207,7 @@ public class TransitionScreen extends FContainer {
} else if (isIntro) {
if (textureRegion != null) {
if (Forge.advStartup) {
- g.drawGrayTransitionImage(Forge.getAssets().fallback_skins().get(0), 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), false, percentage);
+ g.drawGrayTransitionImage(Forge.getAssets().fallback_skins().get("title"), 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight(), false, percentage);
g.setAlphaComposite(1-percentage);
g.drawImage(textureRegion, 0, 0, Forge.getScreenWidth(), Forge.getScreenHeight());
g.setAlphaComposite(oldAlpha);
diff --git a/forge-gui/pom.xml b/forge-gui/pom.xml
index ab47fee1ce4..3ed71c12f2d 100644
--- a/forge-gui/pom.xml
+++ b/forge-gui/pom.xml
@@ -40,11 +40,6 @@
forge-ai
${project.version}
-
- com.github.tommyettinger
- textratypist
- 0.7.9
-
com.thoughtworks.xstream
xstream