Merge pull request #1140 from kevlahnota/master

refactor Assets
This commit is contained in:
Anthony Calosa
2022-07-19 12:34:32 +08:00
committed by GitHub
15 changed files with 484 additions and 306 deletions

View File

@@ -79,7 +79,7 @@ public class Forge implements ApplicationListener {
protected static TransitionScreen transitionScreen;
public static KeyInputAdapter keyInputAdapter;
private static boolean exited;
private boolean needsUpdate = false;
public boolean needsUpdate = false;
public static boolean safeToClose = true;
public static boolean magnify = false;
public static boolean magnifyToggle = true;
@@ -110,7 +110,7 @@ public class Forge implements ApplicationListener {
public static boolean gameInProgress = false;
public static boolean disposeTextures = false;
public static boolean isMobileAdventureMode = false;
public static int cacheSize = 400;
public static int cacheSize = 300;
public static int totalDeviceRAM = 0;
public static int androidVersion = 0;
public static boolean autoCache = false;
@@ -208,9 +208,9 @@ public class Forge implements ApplicationListener {
CJK_Font = prefs.getPref(FPref.UI_CJK_FONT);
if (autoCache) {
//increase cacheSize for devices with RAM more than 5GB, default is 400. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
if (totalDeviceRAM > 5000) //devices with more than 10GB RAM will have 800 Cache size, 600 Cache size for morethan 5GB RAM
cacheSize = totalDeviceRAM > 10000 ? 800 : 600;
//increase cacheSize for devices with RAM more than 5GB, default is 300. Some phones have more than 10GB RAM (Mi 10, OnePlus 8, S20, etc..)
if (totalDeviceRAM > 5000) //devices with more than 10GB RAM will have 600 Cache size, 400 Cache size for morethan 5GB RAM
cacheSize = totalDeviceRAM > 10000 ? 600 : 400;
}
//init cache
ImageCache.initCache(cacheSize);
@@ -781,7 +781,7 @@ public class Forge implements ApplicationListener {
@Override
public void render() {
if (showFPS)
frameRate.update();
frameRate.update(ImageCache.counter, Forge.getAssets().manager().getMemoryInMegabytes());
try {
ImageCache.allowSingleLoad();
@@ -817,8 +817,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(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.end();
if (animationTimeout < 0) {
currentScene.render();
@@ -837,8 +837,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(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.end();
return;
}
@@ -878,7 +878,7 @@ public class Forge implements ApplicationListener {
}
//update here
if (needsUpdate) {
if (getAssets().manager.update())
if (getAssets().manager().update())
needsUpdate = false;
}
graphics.end();
@@ -928,7 +928,7 @@ public class Forge implements ApplicationListener {
@Override
public void resume() {
try {
Texture.setAssetManager(getAssets().manager);
Texture.setAssetManager(getAssets().manager());
needsUpdate = true;
} catch (Exception e) {
//the application context must have been recreated from its last state.

View File

@@ -16,6 +16,8 @@ import com.badlogic.gdx.utils.TimeUtils;
public class FrameRate implements Disposable{
long lastTimeCounted;
int cardsLoaded = 0;
int allocT = 0;
private float sinceChange;
private float frameRate;
private BitmapFont font;
@@ -38,7 +40,10 @@ public class FrameRate implements Disposable{
batch.setProjectionMatrix(cam.combined);
}
public void update() {
public void update(int loadedCardSize, float toAlloc) {
if (toAlloc > 300f)
allocT = (int) toAlloc;
cardsLoaded = loadedCardSize;
long delta = TimeUtils.timeSinceMillis(lastTimeCounted);
lastTimeCounted = TimeUtils.millis();
sinceChange += delta;
@@ -50,7 +55,7 @@ public class FrameRate implements Disposable{
public void render() {
batch.begin();
font.draw(batch, (int)frameRate + " fps", 3, Gdx.graphics.getHeight() - 3);
font.draw(batch, (int)frameRate + " FPS | " + cardsLoaded + " cards re/loaded - " + allocT + " vMem", 3, Gdx.graphics.getHeight() - 3);
batch.end();
}

View File

@@ -8,7 +8,6 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Array;
import com.google.common.base.Predicates;
import forge.Forge;
import forge.adventure.data.DialogData;
import forge.adventure.data.EffectData;
@@ -19,8 +18,6 @@ import forge.adventure.util.Current;
import forge.adventure.util.MapDialog;
import forge.adventure.util.Reward;
import forge.card.CardRarity;
import forge.card.CardRulesPredicates;
import forge.deck.CardPool;
import forge.deck.Deck;
import forge.item.PaperCard;
import forge.util.Aggregates;
@@ -106,10 +103,11 @@ public class EnemySprite extends CharacterSprite {
ret.add(new Reward(Reward.Type.Life, 1));
} else {
if(data.rewards != null) { //Collect standard rewards.
Deck enemyDeck = Current.latestDeck(); // By popular demand, remove basic lands from the reward pool.
CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND), PaperCard.FN_GET_RULES));
Deck enemyDeck = Current.latestDeck();
/*// By popular demand, remove basic lands from the reward pool.
CardPool deckNoBasicLands = enemyDeck.getMain().getFilteredPool(Predicates.compose(Predicates.not(CardRulesPredicates.Presets.IS_BASIC_LAND), PaperCard.FN_GET_RULES));*/
for (RewardData rdata : data.rewards) {
ret.addAll(rdata.generate(false, deckNoBasicLands.toFlatList() ));
ret.addAll(rdata.generate(false, enemyDeck == null ? null : enemyDeck.getMain().toFlatList() ));
}
}
if(rewards != null) { //Collect additional rewards.

View File

@@ -120,11 +120,11 @@ public class Config {
public TextureAtlas getAtlas(String spriteAtlas) {
String fileName = getFile(spriteAtlas).path();
if (!Forge.getAssets().manager.contains(fileName, TextureAtlas.class)) {
Forge.getAssets().manager.load(fileName, TextureAtlas.class);
Forge.getAssets().manager.finishLoadingAsset(fileName);
if (!Forge.getAssets().manager().contains(fileName, TextureAtlas.class)) {
Forge.getAssets().manager().load(fileName, TextureAtlas.class);
Forge.getAssets().manager().finishLoadingAsset(fileName);
}
return Forge.getAssets().manager.get(fileName);
return Forge.getAssets().manager().get(fileName);
}
public SettingData getSettingData()
{

View File

@@ -39,11 +39,11 @@ public class TemplateTmxMapLoader extends TmxMapLoader {
for (FileHandle textureFile : textureFiles) {
Texture texture = new Texture(textureFile, parameter.generateMipMaps);
texture.setFilter(parameter.textureMinFilter, parameter.textureMagFilter);
Forge.getAssets().tmxMap.put(textureFile.path(), texture);
Forge.getAssets().tmxMap().put(textureFile.path(), texture);
}
TiledMap map = loadTiledMap(tmxFile, parameter, new ImageResolver.DirectImageResolver(Forge.getAssets().tmxMap));
map.setOwnedResources(Forge.getAssets().tmxMap.values().toArray());
TiledMap map = loadTiledMap(tmxFile, parameter, new ImageResolver.DirectImageResolver(Forge.getAssets().tmxMap()));
map.setOwnedResources(Forge.getAssets().tmxMap().values().toArray());
return map;
}

View File

@@ -1,37 +1,43 @@
package forge.assets;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetLoaderParameters;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.FileHandleResolver;
import com.badlogic.gdx.assets.loaders.TextureLoader;
import com.badlogic.gdx.assets.loaders.resolvers.AbsoluteFileHandleResolver;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.utils.Disposable;
import com.badlogic.gdx.utils.ObjectMap;
import forge.Forge;
import forge.gui.GuiBase;
import forge.localinstance.skin.FSkinProp;
import java.util.HashMap;
import java.util.Map;
public class Assets implements Disposable {
public AssetManager manager = new AssetManager(new AbsoluteFileHandleResolver());
public HashMap<Integer, FSkinFont> fonts = new HashMap<>();
public HashMap<String, FImageComplex> cardArtCache = new HashMap<>(1024);
public HashMap<String, FImage> avatarImages = new HashMap<>();
public HashMap<String, FSkinImage> MANA_IMAGES = new HashMap<>(128);
public HashMap<String, FSkinImage> symbolLookup = new HashMap<>(64);
public HashMap<FSkinProp, FSkinImage> images = new HashMap<>(512);
public HashMap<Integer, TextureRegion> avatars = new HashMap<>(150);
public HashMap<Integer, TextureRegion> sleeves = new HashMap<>(64);
public HashMap<Integer, TextureRegion> cracks = new HashMap<>(16);
public HashMap<Integer, TextureRegion> borders = new HashMap<>();
public HashMap<Integer, TextureRegion> deckbox = new HashMap<>();
public HashMap<Integer, TextureRegion> cursor = new HashMap<>();
public ObjectMap<Integer, BitmapFont> counterFonts = new ObjectMap<>();
public ObjectMap<String, Texture> generatedCards = new ObjectMap<>(512);
public ObjectMap<Integer, Texture> fallback_skins = new ObjectMap<>();
public ObjectMap<String, Texture> tmxMap = new ObjectMap<String, Texture>();
private MemoryTrackingAssetManager manager = new MemoryTrackingAssetManager(new AbsoluteFileHandleResolver());
private HashMap<Integer, FSkinFont> fonts = new HashMap<>();
private HashMap<String, FImageComplex> cardArtCache = new HashMap<>(1024);
private HashMap<String, FImage> avatarImages = new HashMap<>();
private HashMap<String, FSkinImage> manaImages = new HashMap<>(128);
private HashMap<String, FSkinImage> symbolLookup = new HashMap<>(64);
private HashMap<FSkinProp, FSkinImage> images = new HashMap<>(512);
private HashMap<Integer, TextureRegion> avatars = new HashMap<>(150);
private HashMap<Integer, TextureRegion> sleeves = new HashMap<>(64);
private HashMap<Integer, TextureRegion> cracks = new HashMap<>(16);
private HashMap<Integer, TextureRegion> borders = new HashMap<>();
private HashMap<Integer, TextureRegion> deckbox = new HashMap<>();
private HashMap<Integer, TextureRegion> cursor = new HashMap<>();
private ObjectMap<Integer, BitmapFont> counterFonts = new ObjectMap<>();
private ObjectMap<String, Texture> generatedCards = new ObjectMap<>(512);
private ObjectMap<Integer, Texture> fallback_skins = new ObjectMap<>();
private ObjectMap<String, Texture> tmxMap = new ObjectMap<>();
public Skin skin;
public BitmapFont advDefaultFont, advBigFont;
public Assets() {
@@ -64,4 +70,165 @@ public class Assets implements Disposable {
if (skin != null)
skin.dispose();
}
public MemoryTrackingAssetManager manager() {
if (manager == null)
manager = new MemoryTrackingAssetManager(new AbsoluteFileHandleResolver());
return manager;
}
public HashMap<Integer, FSkinFont> fonts() {
if (fonts == null)
fonts = new HashMap<>();
return fonts;
}
public HashMap<String, FImageComplex> cardArtCache() {
if (cardArtCache == null)
cardArtCache = new HashMap<>(1024);
return cardArtCache;
}
public HashMap<String, FImage> avatarImages() {
if (avatarImages == null)
avatarImages = new HashMap<>();
return avatarImages;
}
public HashMap<String, FSkinImage> manaImages() {
if (manaImages == null)
manaImages = new HashMap<>(128);
return manaImages;
}
public HashMap<String, FSkinImage> symbolLookup() {
if (symbolLookup == null)
symbolLookup = new HashMap<>(64);
return symbolLookup;
}
public HashMap<FSkinProp, FSkinImage> images() {
if (images == null)
images = new HashMap<>(512);
return images;
}
public HashMap<Integer, TextureRegion> avatars() {
if (avatars == null)
avatars = new HashMap<>(150);
return avatars;
}
public HashMap<Integer, TextureRegion> sleeves() {
if (sleeves == null)
sleeves = new HashMap<>(64);
return sleeves;
}
public HashMap<Integer, TextureRegion> cracks() {
if (cracks == null)
cracks = new HashMap<>(16);
return cracks;
}
public HashMap<Integer, TextureRegion> borders() {
if (borders == null)
borders = new HashMap<>();
return borders;
}
public HashMap<Integer, TextureRegion> deckbox() {
if (deckbox == null)
deckbox = new HashMap<>();
return deckbox;
}
public HashMap<Integer, TextureRegion> cursor() {
if (cursor == null)
cursor = new HashMap<>();
return cursor;
}
public ObjectMap<Integer, BitmapFont> counterFonts() {
if (counterFonts == null)
counterFonts = new ObjectMap<>();
return counterFonts;
}
public ObjectMap<String, Texture> generatedCards() {
if (generatedCards == null)
generatedCards = new ObjectMap<>(512);
return generatedCards;
}
public ObjectMap<Integer, Texture> fallback_skins() {
if (fallback_skins == null)
fallback_skins = new ObjectMap<>();
return fallback_skins;
}
public ObjectMap<String, Texture> tmxMap() {
if (tmxMap == null)
tmxMap = new ObjectMap<>();
return tmxMap;
}
public class MemoryTrackingAssetManager extends AssetManager {
private int currentMemory;
private Map<String, Integer> memoryPerFile;
public MemoryTrackingAssetManager(FileHandleResolver resolver) {
super(resolver);
currentMemory = 0;
memoryPerFile = new HashMap<String, Integer>();
}
@SuppressWarnings("unchecked")
private int calculateTextureSize(AssetManager assetManager, String fileName, Class type) {
if (memoryPerFile.containsKey(fileName)) {
return memoryPerFile.get(fileName);
}
Texture texture = (Texture) assetManager.get(fileName, type);
TextureData textureData = texture.getTextureData();
int textureSize = textureData.getWidth() * textureData.getHeight();
if (Forge.isTextureFilteringEnabled())
textureSize = textureSize + (textureSize/3);
switch (textureData.getFormat()) {
case RGB565:
textureSize *= 2;
break;
case RGB888:
textureSize *= 3;
break;
case RGBA4444:
textureSize *= 2;
break;
case RGBA8888:
textureSize *= 4;
break;
}
memoryPerFile.put(fileName, textureSize);
return textureSize;
}
@SuppressWarnings("unchecked")
@Override
public synchronized <T> void load(String fileName, Class<T> type, AssetLoaderParameters<T> parameter) {
if (type.equals(Texture.class)) {
if (parameter == null) {
parameter = (AssetLoaderParameters<T>) new TextureLoader.TextureParameter();
}
final AssetLoaderParameters.LoadedCallback prevCallback = parameter.loadedCallback;
parameter.loadedCallback = (assetManager, fileName1, type1) -> {
if (prevCallback != null) {
prevCallback.finishedLoading(assetManager, fileName1, type1);
}
currentMemory += calculateTextureSize(assetManager, fileName1, type1);
};
}
super.load(fileName, type, parameter);
}
@Override
public synchronized void unload(String fileName) {
super.unload(fileName);
if (memoryPerFile.containsKey(fileName)) {
currentMemory -= memoryPerFile.get(fileName);
}
}
public float getMemoryInMegabytes() {
return (float) currentMemory / 1024f / 1024f;
}
}
}

View File

@@ -71,7 +71,7 @@ public class FSkin {
* the skin name
*/
public static void loadLight(String skinName, final SplashScreen splashScreen) {
AssetManager manager = Forge.getAssets().manager;
AssetManager manager = Forge.getAssets().manager();
preferredName = skinName.toLowerCase().replace(' ', '_');
//reset hd buttons/icons
@@ -209,8 +209,8 @@ public class FSkin {
if (FSkin.preferredName.isEmpty()) { FSkin.loadLight("default", splashScreen); }
}
Forge.getAssets().avatars.clear();
Forge.getAssets().sleeves.clear();
Forge.getAssets().avatars().clear();
Forge.getAssets().sleeves().clear();
TextureLoader.TextureParameter parameter = new TextureLoader.TextureParameter();
if (Forge.isTextureFilteringEnabled()) {
@@ -219,7 +219,7 @@ public class FSkin {
parameter.magFilter = Texture.TextureFilter.Linear;
}
AssetManager manager = Forge.getAssets().manager;
AssetManager manager = Forge.getAssets().manager();
// Grab and test various sprite files.
final FileHandle f1 = getDefaultSkinFile(SourceFile.ICONS.getFilename());
@@ -339,7 +339,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(manager.get(f5.path(), Texture.class), i, j, 100, 100));
}
}
pxPreferredAvatars.dispose();
@@ -354,7 +354,7 @@ 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(manager.get(f4.path(), Texture.class), i, j, 100, 100));
}
}
}
@@ -370,7 +370,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(manager.get(f20.path(), Texture.class), i, j, 360, 500));
}
}
pxPreferredSleeves.dispose();
@@ -382,7 +382,7 @@ 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(manager.get(f8.path(), Texture.class), i, j, 360, 500));
}
}
}
@@ -398,7 +398,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(f21.path(), Texture.class), i, j, 360, 500));
Forge.getAssets().sleeves().put(scount++, new TextureRegion(manager.get(f21.path(), Texture.class), i, j, 360, 500));
}
}
pxPreferredSleeves.dispose();
@@ -415,7 +415,7 @@ 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(manager.get(f9.path(), Texture.class), i, j, 360, 500));
}
}
}
@@ -428,32 +428,32 @@ public class FSkin {
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(manager.get(f17.path(), Texture.class), 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().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));
//deckboxes
manager.load(f13.path(), Texture.class, parameter);
manager.finishLoadingAsset(f13.path());
//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(manager.get(f13.path(), Texture.class), 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(manager.get(f13.path(), Texture.class), 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(manager.get(f13.path(), Texture.class), 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().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.setCursor(Forge.getAssets().cursor.get(0), "0");
Forge.setCursor(Forge.getAssets().cursor().get(0), "0");
preferredIcons.dispose();
pxDefaultAvatars.dispose();
@@ -543,31 +543,31 @@ public class FSkin {
}
public static Map<FSkinProp, FSkinImage> getImages() {
return Forge.getAssets().images;
return Forge.getAssets().images();
}
public static Map<Integer, TextureRegion> getAvatars() {
return Forge.getAssets().avatars;
return Forge.getAssets().avatars();
}
public static Map<Integer, TextureRegion> getSleeves() {
return Forge.getAssets().sleeves;
return Forge.getAssets().sleeves();
}
public static Map<Integer, TextureRegion> getCracks() {
return Forge.getAssets().cracks;
return Forge.getAssets().cracks();
}
public static Map<Integer, TextureRegion> getBorders() {
return Forge.getAssets().borders;
return Forge.getAssets().borders();
}
public static Map<Integer, TextureRegion> getDeckbox() {
return Forge.getAssets().deckbox;
return Forge.getAssets().deckbox();
}
public static Map<Integer, TextureRegion> getCursor() {
return Forge.getAssets().cursor;
return Forge.getAssets().cursor();
}
public static boolean isLoaded() { return loaded; }

View File

@@ -47,10 +47,10 @@ public class FSkinFont {
return _get((int)Utils.scale(unscaledSize));
}
public static FSkinFont _get(final int scaledSize) {
FSkinFont skinFont = Forge.getAssets().fonts.get(scaledSize);
FSkinFont skinFont = Forge.getAssets().fonts().get(scaledSize);
if (skinFont == null) {
skinFont = new FSkinFont(scaledSize);
Forge.getAssets().fonts.put(scaledSize, skinFont);
Forge.getAssets().fonts().put(scaledSize, skinFont);
}
return skinFont;
}
@@ -87,7 +87,7 @@ public class FSkinFont {
}
public static void updateAll() {
for (FSkinFont skinFont : Forge.getAssets().fonts.values()) {
for (FSkinFont skinFont : Forge.getAssets().fonts().values()) {
skinFont.updateFont();
}
}

View File

@@ -131,9 +131,9 @@ public enum FSkinTexture implements FImage {
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);
Forge.getAssets().manager().load(preferredFile.path(), Texture.class);
Forge.getAssets().manager().finishLoadingAsset(preferredFile.path());
texture = Forge.getAssets().manager().get(preferredFile.path(), Texture.class);
}
}
catch (final Exception e) {
@@ -155,9 +155,9 @@ public enum FSkinTexture implements FImage {
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);
Forge.getAssets().manager().load(defaultFile.path(), Texture.class);
Forge.getAssets().manager().finishLoadingAsset(defaultFile.path());
texture = Forge.getAssets().manager().get(defaultFile.path(), Texture.class);
}
}
catch (final Exception e) {

View File

@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Queue;
import java.util.Set;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.Pixmap;
@@ -34,6 +33,7 @@ import com.google.common.collect.EvictingQueue;
import com.google.common.collect.Queues;
import com.google.common.collect.Sets;
import forge.gui.FThreads;
import forge.gui.GuiBase;
import forge.util.FileUtil;
import forge.util.TextUtil;
import org.apache.commons.lang3.StringUtils;
@@ -76,9 +76,10 @@ import forge.util.ImageUtil;
public class ImageCache {
private static final HashSet<String> missingIconKeys = new HashSet<>();
private static List<String> borderlessCardlistKey = FileUtil.readFile(ForgeConstants.BORDERLESS_CARD_LIST_FILE);
static int maxCardCapacity = 400; //default card capacity
public static int counter = 0;
static int maxCardCapacity = 300; //default card capacity
static EvictingQueue<String> q;
static Set<String> cardsLoaded = new HashSet<>(800);
static Set<String> cardsLoaded;
static Queue<String> syncQ;
static TextureParameter defaultParameter = new TextureParameter();
static TextureParameter filtered = new TextureParameter();
@@ -93,6 +94,9 @@ public class ImageCache {
q = EvictingQueue.create(capacity);
//init syncQ for threadsafe use
syncQ = Queues.synchronizedQueue(q);
//cap
int cl = GuiBase.isAndroid() ? maxCardCapacity+(capacity/3) : 400;
cardsLoaded = new HashSet<>(cl);
}
public static final Texture defaultImage;
public static FImage BlackBorder = FSkinImage.IMG_BORDER_BLACK;
@@ -112,7 +116,7 @@ public class ImageCache {
} catch (Exception ex) {
System.err.println("could not load default card image");
} finally {
defaultImage = (null == defImage) ? new Texture(10, 10, Format.RGBA8888) : defImage;
defaultImage = (null == defImage) ? new Texture(10, 10, Format.RGBA4444) : defImage;
}
}
@@ -121,16 +125,18 @@ public class ImageCache {
ImageKeys.clearMissingCards();
}
public static void clearGeneratedCards() {
Forge.getAssets().generatedCards.clear();
Forge.getAssets().generatedCards().clear();
}
public static void disposeTextures(){
CardRenderer.clearcardArtCache();
//unload all cardsLoaded
for (String fileName : cardsLoaded) {
if (Forge.getAssets().manager.contains(fileName))
Forge.getAssets().manager.unload(fileName);
if (Forge.getAssets().manager().contains(fileName)) {
Forge.getAssets().manager().unload(fileName);
}
}
cardsLoaded.clear();
((Forge)Gdx.app.getApplicationListener()).needsUpdate = true;
}
public static Texture getImage(InventoryItem ii) {
@@ -270,8 +276,8 @@ public class ImageCache {
if (file == null)
return null;
if (!others && Forge.enableUIMask.equals("Full") && isBorderless(imageKey))
return Forge.getAssets().generatedCards.get(imageKey);
return Forge.getAssets().manager.get(file.getPath(), Texture.class, false);
return Forge.getAssets().generatedCards().get(imageKey);
return Forge.getAssets().manager().get(file.getPath(), Texture.class, false);
}
static Texture loadAsset(String imageKey, File file, boolean others) {
if (file == null)
@@ -284,44 +290,46 @@ public class ImageCache {
cardsLoaded.add(file.getPath());
}
if (!others && cardsLoaded.size() > maxCardCapacity) {
unloadCardTextures(Forge.getAssets().manager);
unloadCardTextures(Forge.getAssets().manager());
return null;
}
String fileName = file.getPath();
//load to assetmanager
Forge.getAssets().manager.load(fileName, Texture.class, Forge.isTextureFilteringEnabled() ? filtered : defaultParameter);
Forge.getAssets().manager.finishLoadingAsset(fileName);
Forge.getAssets().manager().load(fileName, Texture.class, Forge.isTextureFilteringEnabled() ? filtered : defaultParameter);
Forge.getAssets().manager().finishLoadingAsset(fileName);
//return loaded assets
if (others) {
return Forge.getAssets().manager.get(fileName, Texture.class, false);
return Forge.getAssets().manager().get(fileName, Texture.class, false);
} else {
Texture cardTexture = Forge.getAssets().manager.get(fileName, Texture.class, false);
Texture cardTexture = Forge.getAssets().manager().get(fileName, Texture.class, false);
//if full bordermasking is enabled, update the border color
if (Forge.enableUIMask.equals("Full")) {
boolean borderless = isBorderless(imageKey);
updateBorders(cardTexture.toString(), borderless ? Pair.of(Color.valueOf("#171717").toString(), false): isCloserToWhite(getpixelColor(cardTexture)));
//if borderless, generate new texture from the asset and store
if (borderless) {
Forge.getAssets().generatedCards.put(imageKey, generateTexture(new FileHandle(file), cardTexture, Forge.isTextureFilteringEnabled()));
Forge.getAssets().generatedCards().put(imageKey, generateTexture(new FileHandle(file), cardTexture, Forge.isTextureFilteringEnabled()));
}
}
return cardTexture;
}
}
static void unloadCardTextures(AssetManager manager) {
static void unloadCardTextures(Assets.MemoryTrackingAssetManager manager) {
//get latest images from syncQ
Set<String> newQ = Sets.newHashSet(syncQ);
//get all images not in newQ (cardLists to unload)
Set<String> toUnload = Sets.difference(cardsLoaded, newQ);
//unload from assetmanager to save RAM
for (String asset : toUnload) {
if(manager.contains(asset))
if(manager.contains(asset)) {
manager.unload(asset);
}
cardsLoaded.remove(asset);
}
//clear cachedArt since this is dependant to the loaded texture
CardRenderer.clearcardArtCache();
((Forge)Gdx.app.getApplicationListener()).needsUpdate = true;
}
public static void preloadCache(Iterable<String> keys) {
if (FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_DISABLE_CARD_IMAGES))
@@ -434,7 +442,7 @@ public class ImageCache {
drawPixelstoMask(pImage, pMask);
TextureData textureData = new PixmapTextureData(
pMask, //pixmap to use
Format.RGBA8888,
Format.RGBA4444,
textureFilter, //use mipmaps
false, true);
placeholder[0] = new Texture(textureData);
@@ -446,8 +454,8 @@ public class ImageCache {
return placeholder[0];
}
public static Pixmap createRoundedRectangle(int width, int height, int cornerRadius, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
Pixmap ret = new Pixmap(width, height, Pixmap.Format.RGBA8888);
Pixmap pixmap = new Pixmap(width, height, Format.RGBA4444);
Pixmap ret = new Pixmap(width, height, Format.RGBA4444);
pixmap.setColor(color);
//round corners
pixmap.fillCircle(cornerRadius, cornerRadius, cornerRadius);

View File

@@ -19,62 +19,62 @@ import forge.util.TextBounds;
//Encodes text for drawing with symbols and reminder text
public class TextRenderer {
static {
Forge.getAssets().symbolLookup.put("C", FSkinImage.MANA_COLORLESS);
Forge.getAssets().symbolLookup.put("W", FSkinImage.MANA_W);
Forge.getAssets().symbolLookup.put("U", FSkinImage.MANA_U);
Forge.getAssets().symbolLookup.put("B", FSkinImage.MANA_B);
Forge.getAssets().symbolLookup.put("R", FSkinImage.MANA_R);
Forge.getAssets().symbolLookup.put("G", FSkinImage.MANA_G);
Forge.getAssets().symbolLookup.put("W/U", FSkinImage.MANA_HYBRID_WU);
Forge.getAssets().symbolLookup.put("U/B", FSkinImage.MANA_HYBRID_UB);
Forge.getAssets().symbolLookup.put("B/R", FSkinImage.MANA_HYBRID_BR);
Forge.getAssets().symbolLookup.put("R/G", FSkinImage.MANA_HYBRID_RG);
Forge.getAssets().symbolLookup.put("G/W", FSkinImage.MANA_HYBRID_GW);
Forge.getAssets().symbolLookup.put("W/B", FSkinImage.MANA_HYBRID_WB);
Forge.getAssets().symbolLookup.put("U/R", FSkinImage.MANA_HYBRID_UR);
Forge.getAssets().symbolLookup.put("B/G", FSkinImage.MANA_HYBRID_BG);
Forge.getAssets().symbolLookup.put("R/W", FSkinImage.MANA_HYBRID_RW);
Forge.getAssets().symbolLookup.put("G/U", FSkinImage.MANA_HYBRID_GU);
Forge.getAssets().symbolLookup.put("2/W", FSkinImage.MANA_2W);
Forge.getAssets().symbolLookup.put("2/U", FSkinImage.MANA_2U);
Forge.getAssets().symbolLookup.put("2/B", FSkinImage.MANA_2B);
Forge.getAssets().symbolLookup.put("2/R", FSkinImage.MANA_2R);
Forge.getAssets().symbolLookup.put("2/G", FSkinImage.MANA_2G);
Forge.getAssets().symbolLookup.put("P", FSkinImage.MANA_PHRYX);
Forge.getAssets().symbolLookup.put("P/W", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().symbolLookup.put("P/U", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().symbolLookup.put("P/B", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().symbolLookup.put("P/R", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().symbolLookup.put("P/G", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().symbolLookup.put("W/P", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().symbolLookup.put("U/P", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().symbolLookup.put("B/P", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().symbolLookup.put("R/P", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().symbolLookup.put("G/P", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().symbolLookup.put("P/B/G", FSkinImage.MANA_PHRYX_BG);
Forge.getAssets().symbolLookup.put("P/B/R", FSkinImage.MANA_PHRYX_BR);
Forge.getAssets().symbolLookup.put("P/G/U", FSkinImage.MANA_PHRYX_GU);
Forge.getAssets().symbolLookup.put("P/G/W", FSkinImage.MANA_PHRYX_GW);
Forge.getAssets().symbolLookup.put("P/R/G", FSkinImage.MANA_PHRYX_RG);
Forge.getAssets().symbolLookup.put("P/R/W", FSkinImage.MANA_PHRYX_RW);
Forge.getAssets().symbolLookup.put("P/U/B", FSkinImage.MANA_PHRYX_UB);
Forge.getAssets().symbolLookup.put("P/U/R", FSkinImage.MANA_PHRYX_UR);
Forge.getAssets().symbolLookup.put("P/W/B", FSkinImage.MANA_PHRYX_WB);
Forge.getAssets().symbolLookup.put("P/W/U", FSkinImage.MANA_PHRYX_WU);
Forge.getAssets().symbolLookup().put("C", FSkinImage.MANA_COLORLESS);
Forge.getAssets().symbolLookup().put("W", FSkinImage.MANA_W);
Forge.getAssets().symbolLookup().put("U", FSkinImage.MANA_U);
Forge.getAssets().symbolLookup().put("B", FSkinImage.MANA_B);
Forge.getAssets().symbolLookup().put("R", FSkinImage.MANA_R);
Forge.getAssets().symbolLookup().put("G", FSkinImage.MANA_G);
Forge.getAssets().symbolLookup().put("W/U", FSkinImage.MANA_HYBRID_WU);
Forge.getAssets().symbolLookup().put("U/B", FSkinImage.MANA_HYBRID_UB);
Forge.getAssets().symbolLookup().put("B/R", FSkinImage.MANA_HYBRID_BR);
Forge.getAssets().symbolLookup().put("R/G", FSkinImage.MANA_HYBRID_RG);
Forge.getAssets().symbolLookup().put("G/W", FSkinImage.MANA_HYBRID_GW);
Forge.getAssets().symbolLookup().put("W/B", FSkinImage.MANA_HYBRID_WB);
Forge.getAssets().symbolLookup().put("U/R", FSkinImage.MANA_HYBRID_UR);
Forge.getAssets().symbolLookup().put("B/G", FSkinImage.MANA_HYBRID_BG);
Forge.getAssets().symbolLookup().put("R/W", FSkinImage.MANA_HYBRID_RW);
Forge.getAssets().symbolLookup().put("G/U", FSkinImage.MANA_HYBRID_GU);
Forge.getAssets().symbolLookup().put("2/W", FSkinImage.MANA_2W);
Forge.getAssets().symbolLookup().put("2/U", FSkinImage.MANA_2U);
Forge.getAssets().symbolLookup().put("2/B", FSkinImage.MANA_2B);
Forge.getAssets().symbolLookup().put("2/R", FSkinImage.MANA_2R);
Forge.getAssets().symbolLookup().put("2/G", FSkinImage.MANA_2G);
Forge.getAssets().symbolLookup().put("P", FSkinImage.MANA_PHRYX);
Forge.getAssets().symbolLookup().put("P/W", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().symbolLookup().put("P/U", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().symbolLookup().put("P/B", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().symbolLookup().put("P/R", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().symbolLookup().put("P/G", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().symbolLookup().put("W/P", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().symbolLookup().put("U/P", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().symbolLookup().put("B/P", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().symbolLookup().put("R/P", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().symbolLookup().put("G/P", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().symbolLookup().put("P/B/G", FSkinImage.MANA_PHRYX_BG);
Forge.getAssets().symbolLookup().put("P/B/R", FSkinImage.MANA_PHRYX_BR);
Forge.getAssets().symbolLookup().put("P/G/U", FSkinImage.MANA_PHRYX_GU);
Forge.getAssets().symbolLookup().put("P/G/W", FSkinImage.MANA_PHRYX_GW);
Forge.getAssets().symbolLookup().put("P/R/G", FSkinImage.MANA_PHRYX_RG);
Forge.getAssets().symbolLookup().put("P/R/W", FSkinImage.MANA_PHRYX_RW);
Forge.getAssets().symbolLookup().put("P/U/B", FSkinImage.MANA_PHRYX_UB);
Forge.getAssets().symbolLookup().put("P/U/R", FSkinImage.MANA_PHRYX_UR);
Forge.getAssets().symbolLookup().put("P/W/B", FSkinImage.MANA_PHRYX_WB);
Forge.getAssets().symbolLookup().put("P/W/U", FSkinImage.MANA_PHRYX_WU);
for (int i = 0; i <= 20; i++) {
Forge.getAssets().symbolLookup.put(String.valueOf(i), FSkinImage.valueOf("MANA_" + i));
Forge.getAssets().symbolLookup().put(String.valueOf(i), FSkinImage.valueOf("MANA_" + i));
}
Forge.getAssets().symbolLookup.put("X", FSkinImage.MANA_X);
Forge.getAssets().symbolLookup.put("Y", FSkinImage.MANA_Y);
Forge.getAssets().symbolLookup.put("Z", FSkinImage.MANA_Z);
Forge.getAssets().symbolLookup.put("CHAOS", FSkinImage.CHAOS);
Forge.getAssets().symbolLookup.put("Q", FSkinImage.UNTAP);
Forge.getAssets().symbolLookup.put("S", FSkinImage.MANA_SNOW);
Forge.getAssets().symbolLookup.put("T", FSkinImage.TAP);
Forge.getAssets().symbolLookup.put("E", FSkinImage.ENERGY);
Forge.getAssets().symbolLookup.put("AE", FSkinImage.AETHER_SHARD);
Forge.getAssets().symbolLookup.put("PW", FSkinImage.PW_BADGE_COMMON);
Forge.getAssets().symbolLookup.put("CR", FSkinImage.QUEST_COINSTACK);
Forge.getAssets().symbolLookup().put("X", FSkinImage.MANA_X);
Forge.getAssets().symbolLookup().put("Y", FSkinImage.MANA_Y);
Forge.getAssets().symbolLookup().put("Z", FSkinImage.MANA_Z);
Forge.getAssets().symbolLookup().put("CHAOS", FSkinImage.CHAOS);
Forge.getAssets().symbolLookup().put("Q", FSkinImage.UNTAP);
Forge.getAssets().symbolLookup().put("S", FSkinImage.MANA_SNOW);
Forge.getAssets().symbolLookup().put("T", FSkinImage.TAP);
Forge.getAssets().symbolLookup().put("E", FSkinImage.ENERGY);
Forge.getAssets().symbolLookup().put("AE", FSkinImage.AETHER_SHARD);
Forge.getAssets().symbolLookup().put("PW", FSkinImage.PW_BADGE_COMMON);
Forge.getAssets().symbolLookup().put("CR", FSkinImage.QUEST_COINSTACK);
}
public static String startColor(Color color) {
@@ -189,7 +189,7 @@ public class TextRenderer {
if (inSymbolCount > 0) {
inSymbolCount--;
if (text.length() > 0) {
FSkinImage symbol = Forge.getAssets().symbolLookup.get(text.toString());
FSkinImage symbol = Forge.getAssets().symbolLookup().get(text.toString());
if (symbol != null) {
pieceWidth = lineHeight * CardFaceSymbols.FONT_SIZE_FACTOR;
if (x + pieceWidth > width) {

View File

@@ -32,137 +32,137 @@ public class CardFaceSymbols {
public static void loadImages() {
for (int i = 0; i <= 20; i++) {
Forge.getAssets().MANA_IMAGES.put(String.valueOf(i), FSkinImage.valueOf("MANA_" + i));
Forge.getAssets().manaImages().put(String.valueOf(i), FSkinImage.valueOf("MANA_" + i));
}
Forge.getAssets().MANA_IMAGES.put("X", FSkinImage.MANA_X);
Forge.getAssets().MANA_IMAGES.put("Y", FSkinImage.MANA_Y);
Forge.getAssets().MANA_IMAGES.put("Z", FSkinImage.MANA_Z);
Forge.getAssets().manaImages().put("X", FSkinImage.MANA_X);
Forge.getAssets().manaImages().put("Y", FSkinImage.MANA_Y);
Forge.getAssets().manaImages().put("Z", FSkinImage.MANA_Z);
Forge.getAssets().MANA_IMAGES.put("C", FSkinImage.MANA_COLORLESS);
Forge.getAssets().MANA_IMAGES.put("B", FSkinImage.MANA_B);
Forge.getAssets().MANA_IMAGES.put("BG", FSkinImage.MANA_HYBRID_BG);
Forge.getAssets().MANA_IMAGES.put("BR", FSkinImage.MANA_HYBRID_BR);
Forge.getAssets().MANA_IMAGES.put("G", FSkinImage.MANA_G);
Forge.getAssets().MANA_IMAGES.put("GU", FSkinImage.MANA_HYBRID_GU);
Forge.getAssets().MANA_IMAGES.put("GW", FSkinImage.MANA_HYBRID_GW);
Forge.getAssets().MANA_IMAGES.put("R", FSkinImage.MANA_R);
Forge.getAssets().MANA_IMAGES.put("RG", FSkinImage.MANA_HYBRID_RG);
Forge.getAssets().MANA_IMAGES.put("RW", FSkinImage.MANA_HYBRID_RW);
Forge.getAssets().MANA_IMAGES.put("U", FSkinImage.MANA_U);
Forge.getAssets().MANA_IMAGES.put("UB", FSkinImage.MANA_HYBRID_UB);
Forge.getAssets().MANA_IMAGES.put("UR", FSkinImage.MANA_HYBRID_UR);
Forge.getAssets().MANA_IMAGES.put("W", FSkinImage.MANA_W);
Forge.getAssets().MANA_IMAGES.put("WB", FSkinImage.MANA_HYBRID_WB);
Forge.getAssets().MANA_IMAGES.put("WU", FSkinImage.MANA_HYBRID_WU);
Forge.getAssets().MANA_IMAGES.put("P", FSkinImage.MANA_PHRYX);
Forge.getAssets().MANA_IMAGES.put("PW", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().MANA_IMAGES.put("PR", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().MANA_IMAGES.put("PU", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().MANA_IMAGES.put("PB", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().MANA_IMAGES.put("PG", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().MANA_IMAGES.put("PBG", FSkinImage.MANA_PHRYX_BG);
Forge.getAssets().MANA_IMAGES.put("PBR", FSkinImage.MANA_PHRYX_BR);
Forge.getAssets().MANA_IMAGES.put("PGU", FSkinImage.MANA_PHRYX_GU);
Forge.getAssets().MANA_IMAGES.put("PGW", FSkinImage.MANA_PHRYX_GW);
Forge.getAssets().MANA_IMAGES.put("PRG", FSkinImage.MANA_PHRYX_RG);
Forge.getAssets().MANA_IMAGES.put("PRW", FSkinImage.MANA_PHRYX_RW);
Forge.getAssets().MANA_IMAGES.put("PUB", FSkinImage.MANA_PHRYX_UB);
Forge.getAssets().MANA_IMAGES.put("PUR", FSkinImage.MANA_PHRYX_UR);
Forge.getAssets().MANA_IMAGES.put("PWB", FSkinImage.MANA_PHRYX_WB);
Forge.getAssets().MANA_IMAGES.put("PWU", FSkinImage.MANA_PHRYX_WU);
Forge.getAssets().MANA_IMAGES.put("2W", FSkinImage.MANA_2W);
Forge.getAssets().MANA_IMAGES.put("2U", FSkinImage.MANA_2U);
Forge.getAssets().MANA_IMAGES.put("2R", FSkinImage.MANA_2R);
Forge.getAssets().MANA_IMAGES.put("2G", FSkinImage.MANA_2G);
Forge.getAssets().MANA_IMAGES.put("2B", FSkinImage.MANA_2B);
Forge.getAssets().manaImages().put("C", FSkinImage.MANA_COLORLESS);
Forge.getAssets().manaImages().put("B", FSkinImage.MANA_B);
Forge.getAssets().manaImages().put("BG", FSkinImage.MANA_HYBRID_BG);
Forge.getAssets().manaImages().put("BR", FSkinImage.MANA_HYBRID_BR);
Forge.getAssets().manaImages().put("G", FSkinImage.MANA_G);
Forge.getAssets().manaImages().put("GU", FSkinImage.MANA_HYBRID_GU);
Forge.getAssets().manaImages().put("GW", FSkinImage.MANA_HYBRID_GW);
Forge.getAssets().manaImages().put("R", FSkinImage.MANA_R);
Forge.getAssets().manaImages().put("RG", FSkinImage.MANA_HYBRID_RG);
Forge.getAssets().manaImages().put("RW", FSkinImage.MANA_HYBRID_RW);
Forge.getAssets().manaImages().put("U", FSkinImage.MANA_U);
Forge.getAssets().manaImages().put("UB", FSkinImage.MANA_HYBRID_UB);
Forge.getAssets().manaImages().put("UR", FSkinImage.MANA_HYBRID_UR);
Forge.getAssets().manaImages().put("W", FSkinImage.MANA_W);
Forge.getAssets().manaImages().put("WB", FSkinImage.MANA_HYBRID_WB);
Forge.getAssets().manaImages().put("WU", FSkinImage.MANA_HYBRID_WU);
Forge.getAssets().manaImages().put("P", FSkinImage.MANA_PHRYX);
Forge.getAssets().manaImages().put("PW", FSkinImage.MANA_PHRYX_W);
Forge.getAssets().manaImages().put("PR", FSkinImage.MANA_PHRYX_R);
Forge.getAssets().manaImages().put("PU", FSkinImage.MANA_PHRYX_U);
Forge.getAssets().manaImages().put("PB", FSkinImage.MANA_PHRYX_B);
Forge.getAssets().manaImages().put("PG", FSkinImage.MANA_PHRYX_G);
Forge.getAssets().manaImages().put("PBG", FSkinImage.MANA_PHRYX_BG);
Forge.getAssets().manaImages().put("PBR", FSkinImage.MANA_PHRYX_BR);
Forge.getAssets().manaImages().put("PGU", FSkinImage.MANA_PHRYX_GU);
Forge.getAssets().manaImages().put("PGW", FSkinImage.MANA_PHRYX_GW);
Forge.getAssets().manaImages().put("PRG", FSkinImage.MANA_PHRYX_RG);
Forge.getAssets().manaImages().put("PRW", FSkinImage.MANA_PHRYX_RW);
Forge.getAssets().manaImages().put("PUB", FSkinImage.MANA_PHRYX_UB);
Forge.getAssets().manaImages().put("PUR", FSkinImage.MANA_PHRYX_UR);
Forge.getAssets().manaImages().put("PWB", FSkinImage.MANA_PHRYX_WB);
Forge.getAssets().manaImages().put("PWU", FSkinImage.MANA_PHRYX_WU);
Forge.getAssets().manaImages().put("2W", FSkinImage.MANA_2W);
Forge.getAssets().manaImages().put("2U", FSkinImage.MANA_2U);
Forge.getAssets().manaImages().put("2R", FSkinImage.MANA_2R);
Forge.getAssets().manaImages().put("2G", FSkinImage.MANA_2G);
Forge.getAssets().manaImages().put("2B", FSkinImage.MANA_2B);
Forge.getAssets().MANA_IMAGES.put("S", FSkinImage.MANA_SNOW);
Forge.getAssets().MANA_IMAGES.put("T", FSkinImage.TAP);
Forge.getAssets().MANA_IMAGES.put("E", FSkinImage.ENERGY);
Forge.getAssets().MANA_IMAGES.put("slash", FSkinImage.SLASH);
Forge.getAssets().MANA_IMAGES.put("attack", FSkinImage.ATTACK);
Forge.getAssets().MANA_IMAGES.put("defend", FSkinImage.DEFEND);
Forge.getAssets().MANA_IMAGES.put("summonsick", FSkinImage.SUMMONSICK);
Forge.getAssets().MANA_IMAGES.put("phasing", FSkinImage.PHASING);
Forge.getAssets().MANA_IMAGES.put("sacrifice", FSkinImage.COSTRESERVED);
Forge.getAssets().MANA_IMAGES.put("counters1", FSkinImage.COUNTERS1);
Forge.getAssets().MANA_IMAGES.put("counters2", FSkinImage.COUNTERS2);
Forge.getAssets().MANA_IMAGES.put("counters3", FSkinImage.COUNTERS3);
Forge.getAssets().MANA_IMAGES.put("countersMulti", FSkinImage.COUNTERS_MULTI);
Forge.getAssets().manaImages().put("S", FSkinImage.MANA_SNOW);
Forge.getAssets().manaImages().put("T", FSkinImage.TAP);
Forge.getAssets().manaImages().put("E", FSkinImage.ENERGY);
Forge.getAssets().manaImages().put("slash", FSkinImage.SLASH);
Forge.getAssets().manaImages().put("attack", FSkinImage.ATTACK);
Forge.getAssets().manaImages().put("defend", FSkinImage.DEFEND);
Forge.getAssets().manaImages().put("summonsick", FSkinImage.SUMMONSICK);
Forge.getAssets().manaImages().put("phasing", FSkinImage.PHASING);
Forge.getAssets().manaImages().put("sacrifice", FSkinImage.COSTRESERVED);
Forge.getAssets().manaImages().put("counters1", FSkinImage.COUNTERS1);
Forge.getAssets().manaImages().put("counters2", FSkinImage.COUNTERS2);
Forge.getAssets().manaImages().put("counters3", FSkinImage.COUNTERS3);
Forge.getAssets().manaImages().put("countersMulti", FSkinImage.COUNTERS_MULTI);
Forge.getAssets().MANA_IMAGES.put("foil01", FSkinImage.FOIL_01);
Forge.getAssets().MANA_IMAGES.put("foil02", FSkinImage.FOIL_02);
Forge.getAssets().MANA_IMAGES.put("foil03", FSkinImage.FOIL_03);
Forge.getAssets().MANA_IMAGES.put("foil04", FSkinImage.FOIL_04);
Forge.getAssets().MANA_IMAGES.put("foil05", FSkinImage.FOIL_05);
Forge.getAssets().MANA_IMAGES.put("foil06", FSkinImage.FOIL_06);
Forge.getAssets().MANA_IMAGES.put("foil07", FSkinImage.FOIL_07);
Forge.getAssets().MANA_IMAGES.put("foil08", FSkinImage.FOIL_08);
Forge.getAssets().MANA_IMAGES.put("foil09", FSkinImage.FOIL_09);
Forge.getAssets().MANA_IMAGES.put("foil10", FSkinImage.FOIL_10);
Forge.getAssets().manaImages().put("foil01", FSkinImage.FOIL_01);
Forge.getAssets().manaImages().put("foil02", FSkinImage.FOIL_02);
Forge.getAssets().manaImages().put("foil03", FSkinImage.FOIL_03);
Forge.getAssets().manaImages().put("foil04", FSkinImage.FOIL_04);
Forge.getAssets().manaImages().put("foil05", FSkinImage.FOIL_05);
Forge.getAssets().manaImages().put("foil06", FSkinImage.FOIL_06);
Forge.getAssets().manaImages().put("foil07", FSkinImage.FOIL_07);
Forge.getAssets().manaImages().put("foil08", FSkinImage.FOIL_08);
Forge.getAssets().manaImages().put("foil09", FSkinImage.FOIL_09);
Forge.getAssets().manaImages().put("foil10", FSkinImage.FOIL_10);
Forge.getAssets().MANA_IMAGES.put("foil11", FSkinImage.FOIL_11);
Forge.getAssets().MANA_IMAGES.put("foil12", FSkinImage.FOIL_12);
Forge.getAssets().MANA_IMAGES.put("foil13", FSkinImage.FOIL_13);
Forge.getAssets().MANA_IMAGES.put("foil14", FSkinImage.FOIL_14);
Forge.getAssets().MANA_IMAGES.put("foil15", FSkinImage.FOIL_15);
Forge.getAssets().MANA_IMAGES.put("foil16", FSkinImage.FOIL_16);
Forge.getAssets().MANA_IMAGES.put("foil17", FSkinImage.FOIL_17);
Forge.getAssets().MANA_IMAGES.put("foil18", FSkinImage.FOIL_18);
Forge.getAssets().MANA_IMAGES.put("foil19", FSkinImage.FOIL_19);
Forge.getAssets().MANA_IMAGES.put("foil20", FSkinImage.FOIL_20);
Forge.getAssets().manaImages().put("foil11", FSkinImage.FOIL_11);
Forge.getAssets().manaImages().put("foil12", FSkinImage.FOIL_12);
Forge.getAssets().manaImages().put("foil13", FSkinImage.FOIL_13);
Forge.getAssets().manaImages().put("foil14", FSkinImage.FOIL_14);
Forge.getAssets().manaImages().put("foil15", FSkinImage.FOIL_15);
Forge.getAssets().manaImages().put("foil16", FSkinImage.FOIL_16);
Forge.getAssets().manaImages().put("foil17", FSkinImage.FOIL_17);
Forge.getAssets().manaImages().put("foil18", FSkinImage.FOIL_18);
Forge.getAssets().manaImages().put("foil19", FSkinImage.FOIL_19);
Forge.getAssets().manaImages().put("foil20", FSkinImage.FOIL_20);
Forge.getAssets().MANA_IMAGES.put("commander", FSkinImage.IMG_ABILITY_COMMANDER);
Forge.getAssets().manaImages().put("commander", FSkinImage.IMG_ABILITY_COMMANDER);
Forge.getAssets().MANA_IMAGES.put("deathtouch", FSkinImage.IMG_ABILITY_DEATHTOUCH);
Forge.getAssets().MANA_IMAGES.put("defender", FSkinImage.IMG_ABILITY_DEFENDER);
Forge.getAssets().MANA_IMAGES.put("doublestrike", FSkinImage.IMG_ABILITY_DOUBLE_STRIKE);
Forge.getAssets().MANA_IMAGES.put("firststrike", FSkinImage.IMG_ABILITY_FIRST_STRIKE);
Forge.getAssets().MANA_IMAGES.put("fear", FSkinImage.IMG_ABILITY_FEAR);
Forge.getAssets().MANA_IMAGES.put("flash", FSkinImage.IMG_ABILITY_FLASH);
Forge.getAssets().MANA_IMAGES.put("flying", FSkinImage.IMG_ABILITY_FLYING);
Forge.getAssets().MANA_IMAGES.put("haste", FSkinImage.IMG_ABILITY_HASTE);
Forge.getAssets().MANA_IMAGES.put("hexproof", FSkinImage.IMG_ABILITY_HEXPROOF);
Forge.getAssets().MANA_IMAGES.put("horsemanship", FSkinImage.IMG_ABILITY_HORSEMANSHIP);
Forge.getAssets().MANA_IMAGES.put("indestructible", FSkinImage.IMG_ABILITY_INDESTRUCTIBLE);
Forge.getAssets().MANA_IMAGES.put("intimidate", FSkinImage.IMG_ABILITY_INTIMIDATE);
Forge.getAssets().MANA_IMAGES.put("landwalk", FSkinImage.IMG_ABILITY_LANDWALK);
Forge.getAssets().MANA_IMAGES.put("lifelink", FSkinImage.IMG_ABILITY_LIFELINK);
Forge.getAssets().MANA_IMAGES.put("menace", FSkinImage.IMG_ABILITY_MENACE);
Forge.getAssets().MANA_IMAGES.put("reach", FSkinImage.IMG_ABILITY_REACH);
Forge.getAssets().MANA_IMAGES.put("shadow", FSkinImage.IMG_ABILITY_SHADOW);
Forge.getAssets().MANA_IMAGES.put("shroud", FSkinImage.IMG_ABILITY_SHROUD);
Forge.getAssets().MANA_IMAGES.put("trample", FSkinImage.IMG_ABILITY_TRAMPLE);
Forge.getAssets().MANA_IMAGES.put("vigilance", FSkinImage.IMG_ABILITY_VIGILANCE);
Forge.getAssets().manaImages().put("deathtouch", FSkinImage.IMG_ABILITY_DEATHTOUCH);
Forge.getAssets().manaImages().put("defender", FSkinImage.IMG_ABILITY_DEFENDER);
Forge.getAssets().manaImages().put("doublestrike", FSkinImage.IMG_ABILITY_DOUBLE_STRIKE);
Forge.getAssets().manaImages().put("firststrike", FSkinImage.IMG_ABILITY_FIRST_STRIKE);
Forge.getAssets().manaImages().put("fear", FSkinImage.IMG_ABILITY_FEAR);
Forge.getAssets().manaImages().put("flash", FSkinImage.IMG_ABILITY_FLASH);
Forge.getAssets().manaImages().put("flying", FSkinImage.IMG_ABILITY_FLYING);
Forge.getAssets().manaImages().put("haste", FSkinImage.IMG_ABILITY_HASTE);
Forge.getAssets().manaImages().put("hexproof", FSkinImage.IMG_ABILITY_HEXPROOF);
Forge.getAssets().manaImages().put("horsemanship", FSkinImage.IMG_ABILITY_HORSEMANSHIP);
Forge.getAssets().manaImages().put("indestructible", FSkinImage.IMG_ABILITY_INDESTRUCTIBLE);
Forge.getAssets().manaImages().put("intimidate", FSkinImage.IMG_ABILITY_INTIMIDATE);
Forge.getAssets().manaImages().put("landwalk", FSkinImage.IMG_ABILITY_LANDWALK);
Forge.getAssets().manaImages().put("lifelink", FSkinImage.IMG_ABILITY_LIFELINK);
Forge.getAssets().manaImages().put("menace", FSkinImage.IMG_ABILITY_MENACE);
Forge.getAssets().manaImages().put("reach", FSkinImage.IMG_ABILITY_REACH);
Forge.getAssets().manaImages().put("shadow", FSkinImage.IMG_ABILITY_SHADOW);
Forge.getAssets().manaImages().put("shroud", FSkinImage.IMG_ABILITY_SHROUD);
Forge.getAssets().manaImages().put("trample", FSkinImage.IMG_ABILITY_TRAMPLE);
Forge.getAssets().manaImages().put("vigilance", FSkinImage.IMG_ABILITY_VIGILANCE);
//hexproof from
Forge.getAssets().MANA_IMAGES.put("hexproofR", FSkinImage.IMG_ABILITY_HEXPROOF_R);
Forge.getAssets().MANA_IMAGES.put("hexproofG", FSkinImage.IMG_ABILITY_HEXPROOF_G);
Forge.getAssets().MANA_IMAGES.put("hexproofB", FSkinImage.IMG_ABILITY_HEXPROOF_B);
Forge.getAssets().MANA_IMAGES.put("hexproofU", FSkinImage.IMG_ABILITY_HEXPROOF_U);
Forge.getAssets().MANA_IMAGES.put("hexproofW", FSkinImage.IMG_ABILITY_HEXPROOF_W);
Forge.getAssets().MANA_IMAGES.put("hexproofC", FSkinImage.IMG_ABILITY_HEXPROOF_C);
Forge.getAssets().MANA_IMAGES.put("hexproofUB", FSkinImage.IMG_ABILITY_HEXPROOF_UB);
Forge.getAssets().manaImages().put("hexproofR", FSkinImage.IMG_ABILITY_HEXPROOF_R);
Forge.getAssets().manaImages().put("hexproofG", FSkinImage.IMG_ABILITY_HEXPROOF_G);
Forge.getAssets().manaImages().put("hexproofB", FSkinImage.IMG_ABILITY_HEXPROOF_B);
Forge.getAssets().manaImages().put("hexproofU", FSkinImage.IMG_ABILITY_HEXPROOF_U);
Forge.getAssets().manaImages().put("hexproofW", FSkinImage.IMG_ABILITY_HEXPROOF_W);
Forge.getAssets().manaImages().put("hexproofC", FSkinImage.IMG_ABILITY_HEXPROOF_C);
Forge.getAssets().manaImages().put("hexproofUB", FSkinImage.IMG_ABILITY_HEXPROOF_UB);
//token icon
Forge.getAssets().MANA_IMAGES.put("token", FSkinImage.IMG_ABILITY_TOKEN);
Forge.getAssets().manaImages().put("token", FSkinImage.IMG_ABILITY_TOKEN);
//protection from
Forge.getAssets().MANA_IMAGES.put("protectAll", FSkinImage.IMG_ABILITY_PROTECT_ALL);
Forge.getAssets().MANA_IMAGES.put("protectB", FSkinImage.IMG_ABILITY_PROTECT_B);
Forge.getAssets().MANA_IMAGES.put("protectBU", FSkinImage.IMG_ABILITY_PROTECT_BU);
Forge.getAssets().MANA_IMAGES.put("protectBW", FSkinImage.IMG_ABILITY_PROTECT_BW);
Forge.getAssets().MANA_IMAGES.put("protectColoredSpells", FSkinImage.IMG_ABILITY_PROTECT_COLOREDSPELLS);
Forge.getAssets().MANA_IMAGES.put("protectG", FSkinImage.IMG_ABILITY_PROTECT_G);
Forge.getAssets().MANA_IMAGES.put("protectGB", FSkinImage.IMG_ABILITY_PROTECT_GB);
Forge.getAssets().MANA_IMAGES.put("protectGU", FSkinImage.IMG_ABILITY_PROTECT_GU);
Forge.getAssets().MANA_IMAGES.put("protectGW", FSkinImage.IMG_ABILITY_PROTECT_GW);
Forge.getAssets().MANA_IMAGES.put("protectGeneric", FSkinImage.IMG_ABILITY_PROTECT_GENERIC);
Forge.getAssets().MANA_IMAGES.put("protectR", FSkinImage.IMG_ABILITY_PROTECT_R);
Forge.getAssets().MANA_IMAGES.put("protectRB", FSkinImage.IMG_ABILITY_PROTECT_RB);
Forge.getAssets().MANA_IMAGES.put("protectRG", FSkinImage.IMG_ABILITY_PROTECT_RG);
Forge.getAssets().MANA_IMAGES.put("protectRU", FSkinImage.IMG_ABILITY_PROTECT_RU);
Forge.getAssets().MANA_IMAGES.put("protectRW", FSkinImage.IMG_ABILITY_PROTECT_RW);
Forge.getAssets().MANA_IMAGES.put("protectU", FSkinImage.IMG_ABILITY_PROTECT_U);
Forge.getAssets().MANA_IMAGES.put("protectUW", FSkinImage.IMG_ABILITY_PROTECT_UW);
Forge.getAssets().MANA_IMAGES.put("protectW", FSkinImage.IMG_ABILITY_PROTECT_W);
Forge.getAssets().manaImages().put("protectAll", FSkinImage.IMG_ABILITY_PROTECT_ALL);
Forge.getAssets().manaImages().put("protectB", FSkinImage.IMG_ABILITY_PROTECT_B);
Forge.getAssets().manaImages().put("protectBU", FSkinImage.IMG_ABILITY_PROTECT_BU);
Forge.getAssets().manaImages().put("protectBW", FSkinImage.IMG_ABILITY_PROTECT_BW);
Forge.getAssets().manaImages().put("protectColoredSpells", FSkinImage.IMG_ABILITY_PROTECT_COLOREDSPELLS);
Forge.getAssets().manaImages().put("protectG", FSkinImage.IMG_ABILITY_PROTECT_G);
Forge.getAssets().manaImages().put("protectGB", FSkinImage.IMG_ABILITY_PROTECT_GB);
Forge.getAssets().manaImages().put("protectGU", FSkinImage.IMG_ABILITY_PROTECT_GU);
Forge.getAssets().manaImages().put("protectGW", FSkinImage.IMG_ABILITY_PROTECT_GW);
Forge.getAssets().manaImages().put("protectGeneric", FSkinImage.IMG_ABILITY_PROTECT_GENERIC);
Forge.getAssets().manaImages().put("protectR", FSkinImage.IMG_ABILITY_PROTECT_R);
Forge.getAssets().manaImages().put("protectRB", FSkinImage.IMG_ABILITY_PROTECT_RB);
Forge.getAssets().manaImages().put("protectRG", FSkinImage.IMG_ABILITY_PROTECT_RG);
Forge.getAssets().manaImages().put("protectRU", FSkinImage.IMG_ABILITY_PROTECT_RU);
Forge.getAssets().manaImages().put("protectRW", FSkinImage.IMG_ABILITY_PROTECT_RW);
Forge.getAssets().manaImages().put("protectU", FSkinImage.IMG_ABILITY_PROTECT_U);
Forge.getAssets().manaImages().put("protectUW", FSkinImage.IMG_ABILITY_PROTECT_UW);
Forge.getAssets().manaImages().put("protectW", FSkinImage.IMG_ABILITY_PROTECT_W);
}
public static void drawManaCost(Graphics g, ManaCost manaCost, float x, float y, final float imageSize) {
@@ -226,7 +226,7 @@ public class CardFaceSymbols {
StringTokenizer tok = new StringTokenizer(s, " ");
while (tok.hasMoreTokens()) {
String symbol = tok.nextToken();
FSkinImage image = Forge.getAssets().MANA_IMAGES.get(symbol);
FSkinImage image = Forge.getAssets().manaImages().get(symbol);
if (image == null) {
BugReporter.reportBug("Symbol not recognized \"" + symbol + "\" in string: " + s);
continue;
@@ -243,7 +243,7 @@ public class CardFaceSymbols {
}
public static void drawSymbol(final String imageName, final Graphics g, final float x, final float y, final float w, final float h) {
g.drawImage(Forge.getAssets().MANA_IMAGES.get(imageName), x, y, w, h);
g.drawImage(Forge.getAssets().manaImages().get(imageName), x, y, w, h);
}
public static float getWidth(final ManaCost manaCost, float imageSize) {

View File

@@ -67,28 +67,28 @@ public class CardRenderer {
// class that simplifies the callback logic of CachedCardImage
static class RendererCachedCardImage extends CachedCardImage {
boolean clearCardArtCache = false;
boolean clearcardArtCache = false;
public RendererCachedCardImage(CardView card, boolean clearArtCache) {
super(card);
this.clearCardArtCache = clearArtCache;
this.clearcardArtCache = clearArtCache;
}
public RendererCachedCardImage(InventoryItem ii, boolean clearArtCache) {
super(ii);
this.clearCardArtCache = clearArtCache;
this.clearcardArtCache = clearArtCache;
}
public RendererCachedCardImage(String key, boolean clearArtCache) {
super(key);
this.clearCardArtCache = clearArtCache;
this.clearcardArtCache = clearArtCache;
}
@Override
public void onImageFetched() {
ImageCache.clear();
if (clearCardArtCache) {
Forge.getAssets().cardArtCache.remove(key);
if (clearcardArtCache) {
Forge.getAssets().cardArtCache().remove(key);
}
}
}
@@ -194,7 +194,7 @@ public class CardRenderer {
private static List<String> classicModuleCardtoCrop = FileUtil.readFile(ForgeConstants.CLASSIC_MODULE_CARD_TO_CROP_FILE);
public static void clearcardArtCache(){
Forge.getAssets().cardArtCache.clear();
Forge.getAssets().cardArtCache().clear();
}
//extract card art from the given card
@@ -218,7 +218,7 @@ public class CardRenderer {
}
public static FImageComplex getCardArt(String imageKey, boolean isSplitCard, boolean isHorizontalCard, boolean isAftermathCard, boolean isSaga, boolean isClass, boolean isDungeon, boolean isFlipCard, boolean isPlanesWalker, boolean isModernFrame) {
FImageComplex cardArt = Forge.getAssets().cardArtCache.get(imageKey);
FImageComplex cardArt = Forge.getAssets().cardArtCache().get(imageKey);
boolean isClassicModule = imageKey != null && imageKey.length() > 2 && classicModuleCardtoCrop.contains(imageKey.substring(ImageKeys.CARD_PREFIX.length()).replace(".jpg", "").replace(".png", ""));
if (cardArt == null) {
Texture image = new RendererCachedCardImage(imageKey, true).getImage();
@@ -279,7 +279,7 @@ public class CardRenderer {
w *= artH / srcH;
h *= artW / srcW;
cardArt = new FRotatedImage(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h), true);
Forge.getAssets().cardArtCache.put(imageKey, cardArt);
Forge.getAssets().cardArtCache().put(imageKey, cardArt);
return cardArt;
}
} else {
@@ -302,7 +302,7 @@ public class CardRenderer {
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
}
if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache.put(imageKey, cardArt);
Forge.getAssets().cardArtCache().put(imageKey, cardArt);
}
}
//fix display for effect
@@ -312,13 +312,13 @@ public class CardRenderer {
}
public static FImageComplex getAftermathSecondCardArt(final String imageKey) {
FImageComplex cardArt = Forge.getAssets().cardArtCache.get("Aftermath_second_"+imageKey);
FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Aftermath_second_"+imageKey);
if (cardArt == null) {
Texture image = new CachedCardImage(imageKey) {
@Override
public void onImageFetched() {
ImageCache.clear();
Forge.getAssets().cardArtCache.remove("Aftermath_second_" + imageKey);
Forge.getAssets().cardArtCache().remove("Aftermath_second_" + imageKey);
}
}.getImage();
if (image != null) {
@@ -338,20 +338,20 @@ public class CardRenderer {
}
if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache.put("Aftermath_second_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Aftermath_second_"+imageKey, cardArt);
}
}
return cardArt;
}
public static FImageComplex getAlternateCardArt(final String imageKey, boolean isPlanesWalker) {
FImageComplex cardArt = Forge.getAssets().cardArtCache.get("Alternate_"+imageKey);
FImageComplex cardArt = Forge.getAssets().cardArtCache().get("Alternate_"+imageKey);
if (cardArt == null) {
Texture image = new CachedCardImage(imageKey) {
@Override
public void onImageFetched() {
ImageCache.clear();
Forge.getAssets().cardArtCache.remove("Alternate_" + imageKey);
Forge.getAssets().cardArtCache().remove("Alternate_" + imageKey);
}
}.getImage();
if (image != null) {
@@ -385,7 +385,7 @@ public class CardRenderer {
cardArt = new FTextureRegionImage(new TextureRegion(image, Math.round(x), Math.round(y), Math.round(w), Math.round(h)));
}
if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache.put("Alternate_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Alternate_"+imageKey, cardArt);
}
}
return cardArt;
@@ -394,9 +394,9 @@ public class CardRenderer {
public static FImageComplex getMeldCardParts(final String imageKey, boolean bottom) {
FImageComplex cardArt;
if (!bottom) {
cardArt = Forge.getAssets().cardArtCache.get("Meld_primary_"+imageKey);
cardArt = Forge.getAssets().cardArtCache().get("Meld_primary_"+imageKey);
} else {
cardArt = Forge.getAssets().cardArtCache.get("Meld_secondary_"+imageKey);
cardArt = Forge.getAssets().cardArtCache().get("Meld_secondary_"+imageKey);
}
if (cardArt == null) {
@@ -404,8 +404,8 @@ public class CardRenderer {
@Override
public void onImageFetched() {
ImageCache.clear();
Forge.getAssets().cardArtCache.remove("Meld_primary_" + imageKey);
Forge.getAssets().cardArtCache.remove("Meld_secondary_" + imageKey);
Forge.getAssets().cardArtCache().remove("Meld_primary_" + imageKey);
Forge.getAssets().cardArtCache().remove("Meld_secondary_" + imageKey);
}
}.getImage();
if (image != null) {
@@ -420,9 +420,9 @@ public class CardRenderer {
}
if (!bottom && !CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache.put("Meld_primary_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Meld_primary_"+imageKey, cardArt);
else if (!CardImageRenderer.forgeArt.equals(cardArt))
Forge.getAssets().cardArtCache.put("Meld_secondary_"+imageKey, cardArt);
Forge.getAssets().cardArtCache().put("Meld_secondary_"+imageKey, cardArt);
}
}
return cardArt;
@@ -1098,7 +1098,7 @@ public class CardRenderer {
private static void drawCounterTabs(final CardView card, final Graphics g, final float x, final float y, final float w, final float h) {
int fontSize = Math.max(11, Math.min(22, (int) (h * 0.08)));
BitmapFont font = Forge.getAssets().counterFonts.get(fontSize);
BitmapFont font = Forge.getAssets().counterFonts().get(fontSize);
final float additionalXOffset = 3f * ((fontSize - 11) / 11f);
final float variableWidth = ((fontSize - 11) / 11f) * 44f;
@@ -1215,7 +1215,7 @@ public class CardRenderer {
private static void drawMarkersTabs(final List<String> markers, final Graphics g, final float x, final float y, final float w, final float h, boolean larger) {
int fontSize = larger ? Math.max(9, Math.min(22, (int) (h * 0.08))) : Math.max(8, Math.min(22, (int) (h * 0.05)));
BitmapFont font = Forge.getAssets().counterFonts.get(fontSize);
BitmapFont font = Forge.getAssets().counterFonts().get(fontSize);
final float additionalXOffset = 3f * ((fontSize - 8) / 8f);
@@ -1407,7 +1407,7 @@ public class CardRenderer {
textureRegions.add(new TextureRegion(texture));
}
Forge.getAssets().counterFonts.put(fontSize, new BitmapFont(fontData, textureRegions, true));
Forge.getAssets().counterFonts().put(fontSize, new BitmapFont(fontData, textureRegions, true));
generator.dispose();
packer.dispose();

View File

@@ -169,7 +169,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(0));
if (!Forge.isLandscapeMode() && tr != null) {
float ar = 1.78f;
int w = (int) (tr.getRegionHeight() / ar);

View File

@@ -111,7 +111,7 @@ public class MatchController extends AbstractGuiGame {
public static FImage getPlayerAvatar(final PlayerView p) {
final String lp = p.getLobbyPlayerName();
FImage avatar = Forge.getAssets().avatarImages.get(lp);
FImage avatar = Forge.getAssets().avatarImages().get(lp);
if (avatar == null) {
if (StringUtils.isEmpty(p.getAvatarCardImageKey())) {
avatar = new FTextureRegionImage(FSkin.getAvatars().get(p.getAvatarIndex()));
@@ -696,7 +696,7 @@ public class MatchController extends AbstractGuiGame {
@Override
public void setPlayerAvatar(final LobbyPlayer player, final IHasIcon ihi) {
Forge.getAssets().avatarImages.put(player.getName(), ImageCache.getIcon(ihi));
Forge.getAssets().avatarImages().put(player.getName(), ImageCache.getIcon(ihi));
}
@Override