mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-13 01:08:06 +00:00
catch unloaded images
- either due to being corrupted, invalid header or libgdx failed to load dependency (wrong path, etc..)
This commit is contained in:
@@ -146,15 +146,20 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
PaperCard card = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(false));
|
PaperCard card = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(false));
|
||||||
File frontFace = ImageKeys.getImageFile(card.getCardImageKey());
|
File frontFace = ImageKeys.getImageFile(card.getCardImageKey());
|
||||||
if (frontFace != null) {
|
if (frontFace != null) {
|
||||||
if (!Forge.getAssets().manager().contains(frontFace.getPath())) {
|
try {
|
||||||
Forge.getAssets().manager().load(frontFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
if (!Forge.getAssets().manager().contains(frontFace.getPath())) {
|
||||||
Forge.getAssets().manager().finishLoadingAsset(frontFace.getPath());
|
Forge.getAssets().manager().load(frontFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||||
count+=1;
|
Forge.getAssets().manager().finishLoadingAsset(frontFace.getPath());
|
||||||
}
|
count+=1;
|
||||||
Texture front = Forge.getAssets().manager().get(frontFace.getPath(), Texture.class, false);
|
}
|
||||||
if (front != null) {
|
Texture front = Forge.getAssets().manager().get(frontFace.getPath(), Texture.class, false);
|
||||||
setCardImage(front);
|
if (front != null) {
|
||||||
} else {
|
setCardImage(front);
|
||||||
|
} else {
|
||||||
|
loaded = false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Failed to load image: "+frontFace.getPath());
|
||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -166,10 +171,14 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
PaperCard cardBack = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(true));
|
PaperCard cardBack = ImageUtil.getPaperCardFromImageKey(reward.getCard().getImageKey(true));
|
||||||
File backFace = ImageKeys.getImageFile(cardBack.getCardAltImageKey());
|
File backFace = ImageKeys.getImageFile(cardBack.getCardAltImageKey());
|
||||||
if (backFace != null) {
|
if (backFace != null) {
|
||||||
if (!Forge.getAssets().manager().contains(backFace.getPath())) {
|
try {
|
||||||
Forge.getAssets().manager().load(backFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
if (!Forge.getAssets().manager().contains(backFace.getPath())) {
|
||||||
Forge.getAssets().manager().finishLoadingAsset(backFace.getPath());
|
Forge.getAssets().manager().load(backFace.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||||
ImageCache.updateSynqCount(backFace, 1);
|
Forge.getAssets().manager().finishLoadingAsset(backFace.getPath());
|
||||||
|
ImageCache.updateSynqCount(backFace, 1);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Failed to load image: "+backFace.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,18 +187,23 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
|
|||||||
File lookup = ImageKeys.hasSetLookup(imagePath) ? ImageKeys.setLookUpFile(imagePath, imagePath+"border") : null;
|
File lookup = ImageKeys.hasSetLookup(imagePath) ? ImageKeys.setLookUpFile(imagePath, imagePath+"border") : null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (lookup != null) {
|
if (lookup != null) {
|
||||||
if (!Forge.getAssets().manager().contains(lookup.getPath())) {
|
try {
|
||||||
Forge.getAssets().manager().load(lookup.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
if (!Forge.getAssets().manager().contains(lookup.getPath())) {
|
||||||
Forge.getAssets().manager().finishLoadingAsset(lookup.getPath());
|
Forge.getAssets().manager().load(lookup.getPath(), Texture.class, Forge.getAssets().getTextureFilter());
|
||||||
count+=1;
|
Forge.getAssets().manager().finishLoadingAsset(lookup.getPath());
|
||||||
}
|
count += 1;
|
||||||
Texture replacement = Forge.getAssets().manager().get(lookup.getPath(), Texture.class, false);
|
}
|
||||||
if (replacement != null) {
|
Texture replacement = Forge.getAssets().manager().get(lookup.getPath(), Texture.class, false);
|
||||||
setCardImage(replacement);
|
if (replacement != null) {
|
||||||
} else {
|
setCardImage(replacement);
|
||||||
|
} else {
|
||||||
|
loaded = false;
|
||||||
|
}
|
||||||
|
ImageCache.updateSynqCount(lookup, count);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Failed to load image: "+lookup.getPath());
|
||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
||||||
ImageCache.updateSynqCount(lookup, count);
|
|
||||||
} else if (!ImageCache.imageKeyFileExists(reward.getCard().getImageKey(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.
|
//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.
|
T = renderPlaceholder(getGraphics(), reward.getCard()); //Now we can render the card.
|
||||||
|
|||||||
Reference in New Issue
Block a user