mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
refactor FSkin Texture loading
- this should clear up unused texture - fix startup on empty res/skins folder
This commit is contained in:
@@ -2,7 +2,6 @@ package forge.adventure.scene;
|
||||
|
||||
import com.badlogic.gdx.Input;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.google.common.base.Function;
|
||||
@@ -40,7 +39,6 @@ import java.util.Map;
|
||||
|
||||
public class AdventureDeckEditor extends TabPageScreen<AdventureDeckEditor> {
|
||||
private static final FileHandle deckIcon = Config.instance().getFile("ui/maindeck.png");
|
||||
private static Texture deckTexture = deckIcon.exists() ? new Texture(deckIcon) : null;
|
||||
private static FImage MAIN_DECK_ICON = deckIcon.exists() ? new FImage() {
|
||||
@Override
|
||||
public float getWidth() {
|
||||
@@ -52,11 +50,10 @@ import java.util.Map;
|
||||
}
|
||||
@Override
|
||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||
g.drawImage(deckTexture, x, y, w, h);
|
||||
g.drawImage(Forge.getAssets().getDeckImage(deckIcon), x, y, w, h);
|
||||
}
|
||||
} : Forge.hdbuttons ? FSkinImage.HDLIBRARY :FSkinImage.DECKLIST;
|
||||
private static final FileHandle sideIcon = Config.instance().getFile("ui/sideboard.png");
|
||||
private static Texture sideTexture = sideIcon.exists() ? new Texture(sideIcon) : null;
|
||||
private static FImage SIDEBOARD_ICON = sideIcon.exists() ? new FImage() {
|
||||
@Override
|
||||
public float getWidth() {
|
||||
@@ -68,12 +65,11 @@ import java.util.Map;
|
||||
}
|
||||
@Override
|
||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||
g.drawImage(sideTexture, x, y, w, h);
|
||||
g.drawImage(Forge.getAssets().getSideboardImage(sideIcon), x, y, w, h);
|
||||
}
|
||||
} : Forge.hdbuttons ? FSkinImage.HDSIDEBOARD : FSkinImage.FLASHBACK;
|
||||
private static final float HEADER_HEIGHT = Math.round(Utils.AVG_FINGER_HEIGHT * 0.8f);
|
||||
private static final FileHandle binderIcon = Config.instance().getFile("ui/binder.png");
|
||||
private static Texture binderTexture = binderIcon.exists() ? new Texture(binderIcon) : null;
|
||||
private static FImage CATALOG_ICON = binderIcon.exists() ? new FImage() {
|
||||
@Override
|
||||
public float getWidth() {
|
||||
@@ -85,12 +81,11 @@ import java.util.Map;
|
||||
}
|
||||
@Override
|
||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||
g.drawImage(binderTexture, x, y, w, h);
|
||||
g.drawImage(Forge.getAssets().getBinderImage(binderIcon), x, y, w, h);
|
||||
}
|
||||
} : FSkinImage.QUEST_BOX;
|
||||
private static final FileHandle sellIcon = Config.instance().getFile("ui/sell.png");
|
||||
private static Texture sellIconTexture = sellIcon.exists() ? new Texture(sellIcon) : null;
|
||||
private static final FLabel lblGold = new FLabel.Builder().text("0").icon( sellIconTexture == null ? FSkinImage.QUEST_COINSTACK :
|
||||
private static final FLabel lblGold = new FLabel.Builder().text("0").icon( Forge.getAssets().getSellIconImage(sellIcon) == null ? FSkinImage.QUEST_COINSTACK :
|
||||
new FImage() {
|
||||
@Override
|
||||
public float getWidth() {
|
||||
@@ -102,7 +97,7 @@ import java.util.Map;
|
||||
}
|
||||
@Override
|
||||
public void draw(Graphics g, float x, float y, float w, float h) {
|
||||
g.drawImage(sellIconTexture, x, y, w, h);
|
||||
g.drawImage(Forge.getAssets().getSellIconImage(sellIcon), x, y, w, h);
|
||||
}
|
||||
}
|
||||
).font(FSkinFont.get(16)).insets(new Vector2(Utils.scale(5), 0)).build();
|
||||
@@ -453,7 +448,7 @@ import java.util.Map;
|
||||
}
|
||||
|
||||
protected void addCommanderItems(final FDropDownMenu menu, final PaperCard card, boolean isAddMenu, boolean isAddSource) {
|
||||
if (parentScreen.getCommanderPage() == null) {
|
||||
if (parentScreen.getCommanderPage() == null || card == null) {
|
||||
return;
|
||||
}
|
||||
boolean isLegalCommander;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.assets;
|
||||
|
||||
import com.badlogic.gdx.Files.FileType;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetLoaderParameters;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
@@ -42,7 +43,8 @@ public class Assets implements Disposable {
|
||||
private ObjectMap<String, Texture> generatedCards;
|
||||
private ObjectMap<String, Texture> fallback_skins;
|
||||
private ObjectMap<String, Texture> tmxMap;
|
||||
private Texture defaultImage, dummy;
|
||||
private Texture defaultImage, dummy, deckImage, sideboardImage, binderImage, sellIconImage;
|
||||
private Texture hdLogoTexture, advLogoTexture, overlay_alpha, splatter;
|
||||
private TextureParameter textureParameter;
|
||||
private ObjectMap<String, Font> textrafonts;
|
||||
private int cGen = 0, cGenVal = 0, cFB = 0, cFBVal = 0, cTM = 0, cTMVal = 0, cSF = 0, cSFVal = 0, cCF = 0, cCFVal = 0, aDF = 0, cDFVal = 0;
|
||||
@@ -51,15 +53,15 @@ public class Assets implements Disposable {
|
||||
String titleFilename = Forge.isLandscapeMode() ? "title_bg_lq.png" : "title_bg_lq_portrait.png";
|
||||
try {
|
||||
//init titleLQ
|
||||
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("title", titleBG_LQ == null ? getDummy() : titleBG_LQ);
|
||||
if (GuiBase.isAndroid())
|
||||
getTexture(Gdx.files.internal("fallback_skin").child(titleFilename));
|
||||
else
|
||||
getTexture(Gdx.files.classpath("fallback_skin").child(titleFilename));
|
||||
//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("transition", transitionLQ == null ? getDummy() : transitionLQ);
|
||||
if (GuiBase.isAndroid())
|
||||
getTexture(Gdx.files.internal("fallback_skin").child("transition.png"));
|
||||
else
|
||||
getTexture(Gdx.files.classpath("fallback_skin").child("transition.png"));
|
||||
} catch (Exception e) {
|
||||
fallback_skins().clear();
|
||||
fallback_skins().put("title", getDummy());
|
||||
@@ -108,7 +110,7 @@ public class Assets implements Disposable {
|
||||
tmxMap.clear();
|
||||
manager.dispose();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +128,7 @@ public class Assets implements Disposable {
|
||||
|
||||
public HashMap<String, FImageComplex> cardArtCache() {
|
||||
if (cardArtCache == null)
|
||||
cardArtCache = new HashMap<>(1024);
|
||||
cardArtCache = new HashMap<>();
|
||||
return cardArtCache;
|
||||
}
|
||||
|
||||
@@ -138,37 +140,37 @@ public class Assets implements Disposable {
|
||||
|
||||
public HashMap<String, FSkinImage> manaImages() {
|
||||
if (manaImages == null)
|
||||
manaImages = new HashMap<>(128);
|
||||
manaImages = new HashMap<>();
|
||||
return manaImages;
|
||||
}
|
||||
|
||||
public HashMap<String, FSkinImage> symbolLookup() {
|
||||
if (symbolLookup == null)
|
||||
symbolLookup = new HashMap<>(64);
|
||||
symbolLookup = new HashMap<>();
|
||||
return symbolLookup;
|
||||
}
|
||||
|
||||
public HashMap<FSkinProp, FSkinImage> images() {
|
||||
if (images == null)
|
||||
images = new HashMap<>(512);
|
||||
images = new HashMap<>();
|
||||
return images;
|
||||
}
|
||||
|
||||
public HashMap<Integer, TextureRegion> avatars() {
|
||||
if (avatars == null)
|
||||
avatars = new HashMap<>(150);
|
||||
avatars = new HashMap<>();
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public HashMap<Integer, TextureRegion> sleeves() {
|
||||
if (sleeves == null)
|
||||
sleeves = new HashMap<>(64);
|
||||
sleeves = new HashMap<>();
|
||||
return sleeves;
|
||||
}
|
||||
|
||||
public HashMap<Integer, TextureRegion> cracks() {
|
||||
if (cracks == null)
|
||||
cracks = new HashMap<>(16);
|
||||
cracks = new HashMap<>();
|
||||
return cracks;
|
||||
}
|
||||
|
||||
@@ -198,13 +200,21 @@ public class Assets implements Disposable {
|
||||
|
||||
public ObjectMap<String, Texture> generatedCards() {
|
||||
if (generatedCards == null)
|
||||
generatedCards = new ObjectMap<>(512);
|
||||
generatedCards = new ObjectMap<>();
|
||||
return generatedCards;
|
||||
}
|
||||
|
||||
public ObjectMap<String, Texture> fallback_skins() {
|
||||
if (fallback_skins == null)
|
||||
fallback_skins = new ObjectMap<>();
|
||||
fallback_skins = new ObjectMap<String, Texture>() {
|
||||
@Override
|
||||
public Texture put(String key, Texture value) {
|
||||
Texture old = remove(key);
|
||||
if (old != null)
|
||||
old.dispose();
|
||||
return super.put(key, value);
|
||||
}
|
||||
};
|
||||
return fallback_skins;
|
||||
}
|
||||
|
||||
@@ -230,23 +240,29 @@ public class Assets implements Disposable {
|
||||
}
|
||||
|
||||
public Texture getTexture(FileHandle file) {
|
||||
return getTexture(file, true);
|
||||
}
|
||||
public Texture getTexture(FileHandle file, boolean required) {
|
||||
if (file == null || !file.exists()) {
|
||||
if (!required)
|
||||
return null;
|
||||
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")) {
|
||||
if (!FileType.Absolute.equals(file.type()) || file.path().contains("fallback_skin")) {
|
||||
Texture f = fallback_skins().get(file.path());
|
||||
if (f == null) {
|
||||
fallback_skins().put(file.path(), new Texture(file));
|
||||
f = new Texture(file);
|
||||
fallback_skins().put(file.path(), f);
|
||||
}
|
||||
return f;
|
||||
}
|
||||
Texture t = manager.get(file.path(), Texture.class, false);
|
||||
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);
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
t = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return t;
|
||||
}
|
||||
@@ -255,19 +271,118 @@ public class Assets implements Disposable {
|
||||
if (defaultImage == null) {
|
||||
FileHandle blankImage = Gdx.files.absolute(ForgeConstants.NO_CARD_FILE);
|
||||
if (blankImage.exists()) {
|
||||
defaultImage = manager.get(blankImage.path(), Texture.class, false);
|
||||
defaultImage = manager().get(blankImage.path(), Texture.class, false);
|
||||
if (defaultImage != null)
|
||||
return defaultImage;
|
||||
//if not loaded yet, load to assetmanager
|
||||
manager.load(blankImage.path(), Texture.class, getTextureFilter());
|
||||
manager.finishLoadingAsset(blankImage.path());
|
||||
defaultImage = manager.get(blankImage.path());
|
||||
manager().load(blankImage.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(blankImage.path());
|
||||
defaultImage = manager().get(blankImage.path());
|
||||
} else {
|
||||
defaultImage = getDummy();
|
||||
}
|
||||
}
|
||||
return defaultImage;
|
||||
}
|
||||
|
||||
public Texture getDeckImage(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
deckImage = manager().get(file.path(), Texture.class, false);
|
||||
if (deckImage == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
deckImage = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return deckImage;
|
||||
}
|
||||
|
||||
public Texture getSideboardImage(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
sideboardImage = manager().get(file.path(), Texture.class, false);
|
||||
if (sideboardImage == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
sideboardImage = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return sideboardImage;
|
||||
}
|
||||
|
||||
public Texture getBinderImage(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
binderImage = manager().get(file.path(), Texture.class, false);
|
||||
if (binderImage == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
binderImage = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return binderImage;
|
||||
}
|
||||
|
||||
public Texture getSellIconImage(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
sellIconImage = manager().get(file.path(), Texture.class, false);
|
||||
if (sellIconImage == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
sellIconImage = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return sellIconImage;
|
||||
}
|
||||
|
||||
public Texture getHdLogoTexture(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
if (hdLogoTexture == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
hdLogoTexture = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return hdLogoTexture;
|
||||
}
|
||||
|
||||
public Texture getAdvLogoTexture(FileHandle file) {
|
||||
if (file == null || !file.exists())
|
||||
return null;
|
||||
if (advLogoTexture == null) {
|
||||
manager().load(file.path(), Texture.class, getTextureFilter());
|
||||
manager().finishLoadingAsset(file.path());
|
||||
advLogoTexture = manager().get(file.path(), Texture.class);
|
||||
}
|
||||
return advLogoTexture;
|
||||
}
|
||||
|
||||
public Texture getSplatter() {
|
||||
return splatter;
|
||||
}
|
||||
|
||||
public Texture getOverlay_alpha() {
|
||||
return overlay_alpha;
|
||||
}
|
||||
|
||||
public void loadTexture(FileHandle file) {
|
||||
loadTexture(file, getTextureFilter());
|
||||
}
|
||||
public void loadTexture(FileHandle file, TextureParameter parameter) {
|
||||
try {
|
||||
if (file == null || !file.exists())
|
||||
return;
|
||||
if (!FileType.Absolute.equals(file.type()))
|
||||
return;
|
||||
manager().load(file.path(), Texture.class, parameter);
|
||||
manager().finishLoadingAsset(file.path());
|
||||
if (file.path().contains("overlay_alpha.png"))
|
||||
overlay_alpha = manager().get(file.path(), Texture.class, false);
|
||||
if (file.path().contains("splatter.png"))
|
||||
splatter = manager().get(file.path(), Texture.class, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Texture getDummy() {
|
||||
if (dummy == null) {
|
||||
Pixmap P = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
|
||||
@@ -352,9 +467,8 @@ public class Assets implements Disposable {
|
||||
}
|
||||
memoryPerFile.put(fileName, textureSize);
|
||||
|
||||
int sum = memoryPerFile.values().stream().mapToInt(Integer::intValue).sum() + calcFonts() + calcCounterFonts()
|
||||
return memoryPerFile.values().stream().mapToInt(Integer::intValue).sum() + calcFonts() + calcCounterFonts()
|
||||
+ calculateObjectMaps(generatedCards()) + calculateObjectMaps(fallback_skins()) + calculateObjectMaps(tmxMap());
|
||||
return sum;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.assets;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.assets.loaders.TextureLoader;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
@@ -32,14 +31,11 @@ public class FSkin {
|
||||
private static FileHandle preferredDir;
|
||||
private static String preferredName;
|
||||
private static boolean loaded = false;
|
||||
public static Texture hdLogoTexture = null;
|
||||
public static Texture advLogoTexture = null;
|
||||
public static Texture overlay_alpha = null;
|
||||
public static Texture splatter = null;
|
||||
|
||||
public static Texture getLogo() {
|
||||
if (Forge.isMobileAdventureMode)
|
||||
return advLogoTexture;
|
||||
return hdLogoTexture;
|
||||
return Forge.getAssets().getAdvLogoTexture(getDefaultSkinFile("adv_logo.png"));
|
||||
return Forge.getAssets().getHdLogoTexture(getSkinFile("hd_logo.png"));
|
||||
}
|
||||
|
||||
public static void changeSkin(final String skinName) {
|
||||
@@ -77,7 +73,6 @@ public class FSkin {
|
||||
* the skin name
|
||||
*/
|
||||
public static void loadLight(String skinName, final SplashScreen splashScreen) {
|
||||
AssetManager manager = Forge.getAssets().manager();
|
||||
preferredName = skinName.toLowerCase().replace(' ', '_');
|
||||
|
||||
//reset hd buttons/icons
|
||||
@@ -117,38 +112,10 @@ public class FSkin {
|
||||
FSkinTexture.BG_TEXTURE.load(); //load background texture early for splash screen
|
||||
|
||||
//load theme logo while changing skins
|
||||
final FileHandle theme_logo = getSkinFile("hd_logo.png");
|
||||
if (theme_logo.exists()) {
|
||||
manager.load(theme_logo.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(theme_logo.path());
|
||||
hdLogoTexture = manager.get(theme_logo.path());
|
||||
} else {
|
||||
hdLogoTexture = null;
|
||||
}
|
||||
final FileHandle adv_logo = getDefaultSkinFile("adv_logo.png");
|
||||
if (adv_logo.exists()) {
|
||||
manager.load(adv_logo.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(adv_logo.path());
|
||||
advLogoTexture = manager.get(adv_logo.path());
|
||||
} else {
|
||||
advLogoTexture = null;
|
||||
}
|
||||
final FileHandle duals_overlay = getDefaultSkinFile("overlay_alpha.png");
|
||||
if (duals_overlay.exists()) {
|
||||
manager.load(duals_overlay.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(duals_overlay.path());
|
||||
overlay_alpha = manager.get(duals_overlay.path());
|
||||
} else {
|
||||
overlay_alpha = null;
|
||||
}
|
||||
final FileHandle splatter_overlay = getDefaultSkinFile("splatter.png");
|
||||
if (splatter_overlay.exists()) {
|
||||
manager.load(splatter_overlay.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(splatter_overlay.path());
|
||||
splatter = manager.get(splatter_overlay.path());
|
||||
} else {
|
||||
splatter = null;
|
||||
}
|
||||
Forge.getAssets().loadTexture(getSkinFile("hd_logo.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("adv_logo.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("overlay_alpha.png"));
|
||||
Forge.getAssets().loadTexture(getDefaultSkinFile("splatter.png"));
|
||||
|
||||
if (splashScreen != null) {
|
||||
final FileHandle f = getSkinFile("bg_splash.png");
|
||||
@@ -168,39 +135,24 @@ public class FSkin {
|
||||
}
|
||||
|
||||
try {
|
||||
int w, h;
|
||||
if (f.path().contains("fallback_skin")) {
|
||||
//the file is not accesible by the assetmanager using absolute fileresolver since it resides on internal path or classpath
|
||||
Texture txSplash = new Texture(f);
|
||||
w = txSplash.getWidth();
|
||||
h = txSplash.getHeight();
|
||||
splashScreen.setSplashTexture(new TextureRegion(txSplash, 0, 0, w, h - 100));
|
||||
} else {
|
||||
manager.load(f.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f.path());
|
||||
w = manager.get(f.path(), Texture.class).getWidth();
|
||||
h = manager.get(f.path(), Texture.class).getHeight();
|
||||
|
||||
if (f2.exists()) {
|
||||
manager.load(f2.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f2.path());
|
||||
splashScreen.setSplashTexture(new TextureRegion(manager.get(f2.path(), Texture.class)));
|
||||
} else {
|
||||
splashScreen.setSplashTexture(new TextureRegion(manager.get(f.path(), Texture.class), 0, 0, w, h - 100));
|
||||
}
|
||||
}
|
||||
int w, h, mod;
|
||||
mod = f2.exists() ? 0 : 100;
|
||||
Texture txSplash = Forge.getAssets().getTexture(f2.exists() ? f2 : f);
|
||||
w = txSplash.getWidth();
|
||||
h = txSplash.getHeight();
|
||||
splashScreen.setSplashTexture(new TextureRegion(txSplash, 0, 0, w, h - mod));
|
||||
Pixmap pxSplash = new Pixmap(f);
|
||||
//override splashscreen startup
|
||||
if (Forge.selector.equals("Adventure")) {
|
||||
if (f3.exists()) {
|
||||
Texture advSplash = new Texture(f3);
|
||||
Texture advSplash = Forge.getAssets().getTexture(f3);
|
||||
w = advSplash.getWidth();
|
||||
h = advSplash.getHeight();
|
||||
splashScreen.setSplashTexture(new TextureRegion(advSplash, 0, 0, w, h - 100));
|
||||
pxSplash = new Pixmap(f3);
|
||||
}
|
||||
if (f4.exists()) {
|
||||
Texture advBG = new Texture(f4);
|
||||
Texture advBG = Forge.getAssets().getTexture(f4);
|
||||
advBG.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
|
||||
splashScreen.setSplashBGTexture(advBG);
|
||||
}
|
||||
@@ -211,7 +163,7 @@ public class FSkin {
|
||||
FProgressBar.SEL_FORE_COLOR = new Color(pxSplash.getPixel(75, h - 25));
|
||||
}
|
||||
catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
loaded = true;
|
||||
}
|
||||
@@ -246,8 +198,6 @@ public class FSkin {
|
||||
Forge.getAssets().avatars().clear();
|
||||
Forge.getAssets().sleeves().clear();
|
||||
|
||||
AssetManager manager = Forge.getAssets().manager();
|
||||
|
||||
// Grab and test various sprite files.
|
||||
final FileHandle f1 = getDefaultSkinFile(SourceFile.ICONS.getFilename());
|
||||
final FileHandle f2 = getSkinFile(SourceFile.ICONS.getFilename());
|
||||
@@ -279,8 +229,7 @@ public class FSkin {
|
||||
*/
|
||||
|
||||
try {
|
||||
manager.load(f1.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f1.path());
|
||||
Forge.getAssets().loadTexture(f1);
|
||||
Pixmap adventureButtons;
|
||||
if (f23.exists()) {
|
||||
adventureButtons = new Pixmap(f23);
|
||||
@@ -290,35 +239,25 @@ public class FSkin {
|
||||
|
||||
Pixmap preferredIcons = new Pixmap(f1);
|
||||
if (f2.exists()) {
|
||||
manager.load(f2.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f2.path());
|
||||
Forge.getAssets().loadTexture(f2);
|
||||
preferredIcons = new Pixmap(f2);
|
||||
}
|
||||
|
||||
manager.load(f3.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f3.path());
|
||||
if (f6.exists()) {
|
||||
manager.load(f6.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f6.path());
|
||||
}
|
||||
if (f7.exists()){
|
||||
manager.load(f7.path(), Texture.class, new TextureLoader.TextureParameter(){{genMipMaps = true;}});
|
||||
manager.finishLoadingAsset(f7.path());
|
||||
}
|
||||
Forge.getAssets().loadTexture(f3);
|
||||
Forge.getAssets().loadTexture(f6);
|
||||
Forge.getAssets().loadTexture(f7, new TextureLoader.TextureParameter(){{genMipMaps = true;}});
|
||||
|
||||
//hdbuttons
|
||||
if (f11.exists()) {
|
||||
if (!Forge.allowCardBG) {
|
||||
Forge.hdbuttons = false;
|
||||
} else {
|
||||
manager.load(f11.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f11.path());
|
||||
Forge.getAssets().loadTexture(f11);
|
||||
Forge.hdbuttons = true;
|
||||
}
|
||||
} else if (f11b.exists() && Forge.allowCardBG) {
|
||||
if (FSkin.preferredName.isEmpty() || FSkin.preferredName.equalsIgnoreCase("default")) {
|
||||
manager.load(f11b.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f11b.path());
|
||||
Forge.getAssets().loadTexture(f11b);
|
||||
Forge.hdbuttons = true;
|
||||
} else {
|
||||
Forge.hdbuttons = false;
|
||||
@@ -328,14 +267,12 @@ public class FSkin {
|
||||
if (!Forge.allowCardBG) {
|
||||
Forge.hdstart = false;
|
||||
} else {
|
||||
manager.load(f12.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f12.path());
|
||||
Forge.getAssets().loadTexture(f12);
|
||||
Forge.hdstart = true;
|
||||
}
|
||||
} else if (f12b.exists() && Forge.allowCardBG) {
|
||||
if (FSkin.preferredName.isEmpty() || FSkin.preferredName.equalsIgnoreCase("default")) {
|
||||
manager.load(f12b.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f12b.path());
|
||||
Forge.getAssets().loadTexture(f12b);
|
||||
Forge.hdstart = true;
|
||||
} else {
|
||||
Forge.hdstart = false;
|
||||
@@ -353,13 +290,13 @@ public class FSkin {
|
||||
for (FSkinImage image : FSkinImage.values()) {
|
||||
if (GuiBase.isAndroid()) {
|
||||
if (Forge.allowCardBG)
|
||||
image.load(manager, preferredIcons);
|
||||
image.load(preferredIcons);
|
||||
else if (image.toString().equals("HDMULTI"))
|
||||
image.load(manager, preferredIcons);
|
||||
image.load(preferredIcons);
|
||||
else if (!image.toString().startsWith("HD"))
|
||||
image.load(manager, preferredIcons);
|
||||
image.load(preferredIcons);
|
||||
} else {
|
||||
image.load(manager, preferredIcons);
|
||||
image.load(preferredIcons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,16 +309,13 @@ public class FSkin {
|
||||
pxDefaultAvatars = new Pixmap(f4);
|
||||
pxDefaultSleeves = new Pixmap(f8);
|
||||
//default avatar
|
||||
manager.load(f4.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f4.path());
|
||||
Forge.getAssets().loadTexture(f4);
|
||||
//sleeves first set
|
||||
manager.load(f8.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f8.path());
|
||||
Forge.getAssets().loadTexture(f8);
|
||||
//preferred avatar
|
||||
if (f5.exists()) {
|
||||
pxPreferredAvatars = new Pixmap(f5);
|
||||
manager.load(f5.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f5.path());
|
||||
Forge.getAssets().loadTexture(f5);
|
||||
|
||||
final int pw = pxPreferredAvatars.getWidth();
|
||||
final int ph = pxPreferredAvatars.getHeight();
|
||||
@@ -391,7 +325,7 @@ public class FSkin {
|
||||
if (i == 0 && j == 0) { continue; }
|
||||
pxTest = new Color(pxPreferredAvatars.getPixel(i + 50, j + 50));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().avatars().put(counter++, new TextureRegion(manager.get(f5.path(), Texture.class), i, j, 100, 100));
|
||||
Forge.getAssets().avatars().put(counter++, new TextureRegion(Forge.getAssets().getTexture(f5), i, j, 100, 100));
|
||||
}
|
||||
}
|
||||
pxPreferredAvatars.dispose();
|
||||
@@ -406,14 +340,13 @@ public class FSkin {
|
||||
if (i == 0 && j == 0) { continue; }
|
||||
pxTest = new Color(pxDefaultAvatars.getPixel(i + 50, j + 50));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().avatars().put(counter++, new TextureRegion(manager.get(f4.path(), Texture.class), i, j, 100, 100));
|
||||
Forge.getAssets().avatars().put(counter++, new TextureRegion(Forge.getAssets().getTexture(f4), i, j, 100, 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f20.exists()) {
|
||||
pxPreferredSleeves = new Pixmap(f20);
|
||||
manager.load(f20.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f20.path());
|
||||
Forge.getAssets().loadTexture(f20);
|
||||
|
||||
final int sw = pxPreferredSleeves.getWidth();
|
||||
final int sh = pxPreferredSleeves.getHeight();
|
||||
@@ -422,7 +355,7 @@ public class FSkin {
|
||||
for (int i = 0; i < sw; i += 360) {
|
||||
pxTest = new Color(pxPreferredSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(manager.get(f20.path(), Texture.class), i, j, 360, 500));
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(Forge.getAssets().getTexture(f20), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
pxPreferredSleeves.dispose();
|
||||
@@ -434,14 +367,13 @@ public class FSkin {
|
||||
for (int i = 0; i < sw; i += 360) {
|
||||
pxTest = new Color(pxDefaultSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(manager.get(f8.path(), Texture.class), i, j, 360, 500));
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(Forge.getAssets().getTexture(f8), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f21.exists()) {
|
||||
pxPreferredSleeves = new Pixmap(f21);
|
||||
manager.load(f21.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f21.path());
|
||||
Forge.getAssets().loadTexture(f21);
|
||||
|
||||
final int sw = pxPreferredSleeves.getWidth();
|
||||
final int sh = pxPreferredSleeves.getHeight();
|
||||
@@ -450,15 +382,14 @@ public class FSkin {
|
||||
for (int i = 0; i < sw; i += 360) {
|
||||
pxTest = new Color(pxPreferredSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(manager.get(f21.path(), Texture.class), i, j, 360, 500));
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(Forge.getAssets().getTexture(f21), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
pxPreferredSleeves.dispose();
|
||||
} else {
|
||||
//re init second set of sleeves
|
||||
pxDefaultSleeves = new Pixmap(f9);
|
||||
manager.load(f9.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f9.path());
|
||||
Forge.getAssets().loadTexture(f9);
|
||||
|
||||
final int sw2 = pxDefaultSleeves.getWidth();
|
||||
final int sh2 = pxDefaultSleeves.getHeight();
|
||||
@@ -467,43 +398,39 @@ public class FSkin {
|
||||
for (int i = 0; i < sw2; i += 360) {
|
||||
pxTest = new Color(pxDefaultSleeves.getPixel(i + 180, j + 250));
|
||||
if (pxTest.a == 0) { continue; }
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(manager.get(f9.path(), Texture.class), i, j, 360, 500));
|
||||
Forge.getAssets().sleeves().put(scount++, new TextureRegion(Forge.getAssets().getTexture(f9), i, j, 360, 500));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//cracks
|
||||
manager.load(f17.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f17.path());
|
||||
Forge.getAssets().loadTexture(f17);
|
||||
int crackCount = 0;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
int x = j * 200;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
int y = i * 279;
|
||||
Forge.getAssets().cracks().put(crackCount++, new TextureRegion(manager.get(f17.path(), Texture.class), x, y, 200, 279));
|
||||
Forge.getAssets().cracks().put(crackCount++, new TextureRegion(Forge.getAssets().getTexture(f17), x, y, 200, 279));
|
||||
}
|
||||
}
|
||||
|
||||
//borders
|
||||
manager.load(f10.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f10.path());
|
||||
Forge.getAssets().borders().put(0, new TextureRegion(manager.get(f10.path(), Texture.class), 2, 2, 672, 936));
|
||||
Forge.getAssets().borders().put(1, new TextureRegion(manager.get(f10.path(), Texture.class), 676, 2, 672, 936));
|
||||
Forge.getAssets().loadTexture(f10);
|
||||
Forge.getAssets().borders().put(0, new TextureRegion(Forge.getAssets().getTexture(f10), 2, 2, 672, 936));
|
||||
Forge.getAssets().borders().put(1, new TextureRegion(Forge.getAssets().getTexture(f10), 676, 2, 672, 936));
|
||||
//deckboxes
|
||||
manager.load(f13.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(f13.path());
|
||||
Forge.getAssets().loadTexture(f13);
|
||||
//gold bg
|
||||
Forge.getAssets().deckbox().put(0, new TextureRegion(manager.get(f13.path(), Texture.class), 2, 2, 488, 680));
|
||||
Forge.getAssets().deckbox().put(0, new TextureRegion(Forge.getAssets().getTexture(f13), 2, 2, 488, 680));
|
||||
//deck box for card art
|
||||
Forge.getAssets().deckbox().put(1, new TextureRegion(manager.get(f13.path(), Texture.class), 492, 2, 488, 680));
|
||||
Forge.getAssets().deckbox().put(1, new TextureRegion(Forge.getAssets().getTexture(f13), 492, 2, 488, 680));
|
||||
//generic deck box
|
||||
Forge.getAssets().deckbox().put(2, new TextureRegion(manager.get(f13.path(), Texture.class), 982, 2, 488, 680));
|
||||
Forge.getAssets().deckbox().put(2, new TextureRegion(Forge.getAssets().getTexture(f13), 982, 2, 488, 680));
|
||||
//cursor
|
||||
manager.load(f19.path(), Texture.class);
|
||||
manager.finishLoadingAsset(f19.path());
|
||||
Forge.getAssets().cursor().put(0, new TextureRegion(manager.get(f19.path(), Texture.class), 0, 0, 32, 32)); //default
|
||||
Forge.getAssets().cursor().put(1, new TextureRegion(manager.get(f19.path(), Texture.class), 32, 0, 32, 32)); //magnify on
|
||||
Forge.getAssets().cursor().put(2, new TextureRegion(manager.get(f19.path(), Texture.class), 64, 0, 32, 32)); // magnify off
|
||||
Forge.getAssets().loadTexture(f19);
|
||||
Forge.getAssets().cursor().put(0, new TextureRegion(Forge.getAssets().getTexture(f19), 0, 0, 32, 32)); //default
|
||||
Forge.getAssets().cursor().put(1, new TextureRegion(Forge.getAssets().getTexture(f19), 32, 0, 32, 32)); //magnify on
|
||||
Forge.getAssets().cursor().put(2, new TextureRegion(Forge.getAssets().getTexture(f19), 64, 0, 32, 32)); // magnify off
|
||||
|
||||
Forge.setCursor(Forge.getAssets().cursor().get(0), "0");
|
||||
//set adv_progress bar colors
|
||||
@@ -520,7 +447,7 @@ public class FSkin {
|
||||
catch (final Exception e) {
|
||||
System.err.println("FSkin$loadFull: Missing a sprite (default icons, "
|
||||
+ "preferred icons, or foils.");
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
// Run through enums and load their coords.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package forge.assets;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
@@ -521,20 +520,18 @@ public enum FSkinImage implements FImage {
|
||||
FSkin.getImages().put(skinProp, this);
|
||||
}
|
||||
|
||||
public void load(AssetManager manager, Pixmap preferredIcons) {
|
||||
public void load(Pixmap preferredIcons) {
|
||||
String filename = sourceFile.getFilename();
|
||||
FileHandle preferredFile = FSkin.getSkinFile(filename);
|
||||
Texture texture = manager.get(preferredFile.path(), Texture.class, false);
|
||||
Texture texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
if (texture == null) {
|
||||
if (preferredFile.exists()) {
|
||||
try {
|
||||
manager.load(preferredFile.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(preferredFile.path());
|
||||
texture = manager.get(preferredFile.path(), Texture.class);
|
||||
texture = Forge.getAssets().getTexture(preferredFile, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + preferredFile);
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -597,17 +594,15 @@ public enum FSkinImage implements FImage {
|
||||
|
||||
//use default file if can't use preferred file
|
||||
FileHandle defaultFile = FSkin.getDefaultSkinFile(filename);
|
||||
texture = manager.get(defaultFile.path(), Texture.class, false);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
if (texture == null) {
|
||||
if (defaultFile.exists()) {
|
||||
try {
|
||||
manager.load(defaultFile.path(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||
manager.finishLoadingAsset(defaultFile.path());
|
||||
texture = manager.get(defaultFile.path(), Texture.class);
|
||||
texture = Forge.getAssets().getTexture(defaultFile, false);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
System.err.println("Failed to load skin file: " + defaultFile);
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,9 +697,7 @@ public class CardImageRenderer {
|
||||
}
|
||||
|
||||
private static void drawAlphaLines(Graphics g, float x, float y, float w, float h) {
|
||||
if (FSkin.overlay_alpha != null) {
|
||||
g.drawImage(FSkin.overlay_alpha, x, y, w, h);
|
||||
}
|
||||
g.drawImage(Forge.getAssets().getOverlay_alpha(), x, y, w, h);
|
||||
}
|
||||
|
||||
private static void drawPtBox(Graphics g, CardView card, CardStateView state, Color[] colors, float x, float y, float w, float h, boolean noText) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.FImage;
|
||||
import forge.assets.FSkin;
|
||||
import forge.assets.FSkinColor;
|
||||
import forge.assets.FSkinFont;
|
||||
import forge.game.card.CounterEnumType;
|
||||
@@ -46,7 +45,7 @@ public class VAvatar extends FDisplayObject {
|
||||
private class AvatarAnimation extends ForgeAnimation {
|
||||
private static final float DURATION = 1.2f;
|
||||
private float progress = 0;
|
||||
Texture splatter = FSkin.splatter;
|
||||
Texture splatter = Forge.getAssets().getSplatter();
|
||||
|
||||
private void drawAvatar(Graphics g, FImage image, float x, float y, float w, float h) {
|
||||
float percentage = progress / DURATION;
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Texture;
|
||||
import forge.Forge;
|
||||
import forge.Graphics;
|
||||
import forge.animation.ForgeAnimation;
|
||||
import forge.assets.FSkin;
|
||||
import forge.card.CardImageRenderer;
|
||||
import forge.card.CardRenderer;
|
||||
import forge.card.CardRenderer.CardStackPosition;
|
||||
@@ -179,7 +178,7 @@ public class FCardPanel extends FDisplayObject {
|
||||
private class CardDestroyedAnimation extends ForgeAnimation {
|
||||
private static final float DURATION = 0.6f;
|
||||
private float progress = 0;
|
||||
private Texture splatter = FSkin.splatter;
|
||||
private Texture splatter = Forge.getAssets().getSplatter();
|
||||
|
||||
private void drawCard(Graphics g, CardView card, float x, float y, float w, float h, float edgeOffset) {
|
||||
float percentage = progress / DURATION;
|
||||
|
||||
Reference in New Issue
Block a user