update DefaultItemRenderer title/ability name

- support spaces on ability/title with cost
This commit is contained in:
Anthony Calosa
2023-11-05 20:51:29 +08:00
parent 6c60a4bdfd
commit 881ccf81b1

View File

@@ -362,12 +362,13 @@ public class FChoiceList<T> extends FList<T> implements ActivateHandler {
} }
//update manacost text to draw symbols instead //update manacost text to draw symbols instead
else if (value != null && value.toString().contains(" {")) { else if (value != null && value.toString().contains(" {")) {
String[] values = value.toString().split(" "); int manaStringindex = value.toString().indexOf(" {");
String cost = TextUtil.fastReplace(value.toString().substring(value.toString().indexOf(" {")), "}{", " "); String title = value.toString().substring(0, manaStringindex - 1); //support ability/name with spaces...
String cost = TextUtil.fastReplace(value.toString().substring(manaStringindex), "}{", " ");
cost = TextUtil.fastReplace(TextUtil.fastReplace(cost, "{", ""), "}", ""); cost = TextUtil.fastReplace(TextUtil.fastReplace(cost, "{", ""), "}", "");
ManaCost manaCost = new ManaCost(new ManaCostParser(cost)); ManaCost manaCost = new ManaCost(new ManaCostParser(cost));
CardFaceSymbols.drawManaCost(g, manaCost, x + font.getBounds(values[0] + " ").width, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE); CardFaceSymbols.drawManaCost(g, manaCost, x + font.getBounds(title).width, y + (h - MANA_SYMBOL_SIZE) / 2, MANA_SYMBOL_SIZE);
g.drawText(values[0], font, foreColor, x, y, w, h, allowDefaultItemWrap(), Align.left, true); g.drawText(title, font, foreColor, x, y, w, h, allowDefaultItemWrap(), Align.left, true);
} else { } else {
if (value != null) if (value != null)
g.drawText(getChoiceText(value), font, foreColor, x, y, w, h, allowDefaultItemWrap(), Align.left, true); g.drawText(getChoiceText(value), font, foreColor, x, y, w, h, allowDefaultItemWrap(), Align.left, true);