mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
Fix crash when certain types of tokens are rendered using card image generator
This commit is contained in:
@@ -3,6 +3,8 @@ package forge.card;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.HAlignment;
|
||||||
@@ -247,13 +249,17 @@ public class CardImageRenderer {
|
|||||||
g.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize);
|
g.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (card.getRules() == null) { return; } //this can happen with certain tokens
|
||||||
|
String text = card.getRules().getOracleText();
|
||||||
|
if (StringUtils.isEmpty(text)) { return; }
|
||||||
|
|
||||||
|
text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters
|
||||||
|
|
||||||
float padding = TEXT_FONT.getCapHeight() * 0.75f;
|
float padding = TEXT_FONT.getCapHeight() * 0.75f;
|
||||||
x += padding;
|
x += padding;
|
||||||
y += padding;
|
y += padding;
|
||||||
w -= 2 * padding;
|
w -= 2 * padding;
|
||||||
h -= 2 * padding;
|
h -= 2 * padding;
|
||||||
String text = card.getRules().getOracleText();
|
|
||||||
text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters
|
|
||||||
cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, true);
|
cardTextRenderer.drawText(g, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user