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