catch unloaded images

- either due to being corrupted, invalid header or libgdx failed to load dependency (wrong path, etc..)
This commit is contained in:
Anthony Calosa
2022-08-08 16:28:15 +08:00
parent d1f06e0353
commit 91e89c6c97

View File

@@ -146,6 +146,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
PaperCard card = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(false));
File frontFace = ImageKeys.getImageFile(card.getCardImageKey());
if (frontFace != null) {
try {
if (!Forge.getAssets().manager().contains(frontFace.getPath())) {
Forge.getAssets().manager().load(frontFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
Forge.getAssets().manager().finishLoadingAsset(frontFace.getPath());
@@ -157,6 +158,10 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
} else {
loaded = false;
}
} catch (Exception e) {
System.err.println("Failed to load image: "+frontFace.getPath());
loaded = false;
}
} else {
loaded = false;
}
@@ -166,11 +171,15 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
PaperCard cardBack = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(true));
File backFace = ImageKeys.getImageFile(cardBack.getCardAltImageKey());
if (backFace != null) {
try {
if (!Forge.getAssets().manager().contains(backFace.getPath())) {
Forge.getAssets().manager().load(backFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
Forge.getAssets().manager().finishLoadingAsset(backFace.getPath());
ImageCache.updateSynqCount(backFace, 1);
}
} catch (Exception e) {
System.err.println("Failed to load image: "+backFace.getPath());
}
}
}
} else {
@@ -178,6 +187,7 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
File lookup = ImageKeys.hasSetLookup(imagePath) ? ImageKeys.setLookUpFile(imagePath, imagePath+"border") : null;
int count = 0;
if (lookup != null) {
try {
if (!Forge.getAssets().manager().contains(lookup.getPath())) {
Forge.getAssets().manager().load(lookup.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
Forge.getAssets().manager().finishLoadingAsset(lookup.getPath());
@@ -190,6 +200,10 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
loaded = false;
}
ImageCache.updateSynqCount(lookup, count);
} catch (Exception e) {
System.err.println("Failed to load image: "+lookup.getPath());
loaded = false;
}
} else if (!ImageCache.imageKeyFileExists(reward.getCard().getImageKey(false))) {
//Cannot find an image file, set up a rendered card until (if) a file is downloaded.
T = renderPlaceholder(getGraphics(), reward.getCard()); //Now we can render the card.