mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Added attraction light icons (#5663)
Refactored functional variants to be merged in the card face rather than the card factory Some variant characteristics now show in deck builder columns Fixed loading progress amount "[card] has neither ManaCost nor Color" warning now actually displays when these are missing. Co-authored-by: Jetz <Jetz722@gmail.com> Co-authored-by: tool4ever <therealtoolkit@hotmail.com>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import forge.Forge;
|
||||
@@ -194,6 +195,16 @@ public class CardFaceSymbols {
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawAttractionLights(Graphics g, Set<Integer> lights, float x, float y, final float imageSize, boolean vertical) {
|
||||
for(int i = 1; i <= 6; i++) {
|
||||
drawSymbol("AL" + i + (lights.contains(i) ? "ON" : "OFF"), g, x, y, imageSize, imageSize);
|
||||
if (!vertical)
|
||||
x += imageSize;
|
||||
else
|
||||
y += imageSize;
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawOther(final Graphics g, String s, float x, final float y, final float w, final float h, boolean rotate) {
|
||||
if (s.length() == 0) {
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.ImageKeys;
|
||||
import forge.assets.*;
|
||||
import forge.item.PaperCard;
|
||||
import forge.util.ImageUtil;
|
||||
import forge.util.TextBounds;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
@@ -1173,14 +1174,15 @@ public class CardImageRenderer {
|
||||
return;
|
||||
}
|
||||
|
||||
TextBounds bounds = cardTextRenderer.getBounds(ptText, PT_FONT);
|
||||
float padding = PT_FONT.getCapHeight() / 2;
|
||||
float boxWidth = Math.min(PT_FONT.getBounds(ptText).width + 2 * padding,
|
||||
float boxWidth = Math.min(bounds.width + 2 * padding,
|
||||
w - idWidth - padding); //prevent box overlapping ID
|
||||
x += w - boxWidth;
|
||||
w = boxWidth;
|
||||
|
||||
fillColorBackground(g, colors, x, y, w, h);
|
||||
g.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
|
||||
g.drawText(ptText, PT_FONT, Color.BLACK, x, y, w, h, false, Align.center, true);
|
||||
cardTextRenderer.drawText(g, ptText, PT_FONT, Color.BLACK, x, y, w, h, y, h, false, Align.center, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,18 +497,25 @@ public class CardRenderer {
|
||||
//render card name and mana cost on first line
|
||||
float manaCostWidth = 0;
|
||||
ManaCost mainManaCost = cardCurrentState.getManaCost();
|
||||
if (card.isSplitCard()) {
|
||||
//handle rendering both parts of split card
|
||||
mainManaCost = card.getLeftSplitState().getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternateState().getManaCost();
|
||||
manaCostWidth = CardFaceSymbols.getWidth(otherManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth + MANA_COST_PADDING, y, MANA_SYMBOL_SIZE);
|
||||
//draw "//" between two parts of mana cost
|
||||
manaCostWidth += font.getBounds("//").width + MANA_COST_PADDING;
|
||||
g.drawText("//", font, foreColor, x + w - manaCostWidth + MANA_COST_PADDING, y, w, MANA_SYMBOL_SIZE, false, Align.left, true);
|
||||
if (!mainManaCost.isNoCost() || (card.isSplitCard() && !card.getLeftSplitState().getManaCost().isNoCost())) {
|
||||
if (card.isSplitCard()) {
|
||||
//handle rendering both parts of split card
|
||||
mainManaCost = card.getLeftSplitState().getManaCost();
|
||||
ManaCost otherManaCost = card.getAlternateState().getManaCost();
|
||||
manaCostWidth = CardFaceSymbols.getWidth(otherManaCost, MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawManaCost(g, otherManaCost, x + w - manaCostWidth + MANA_COST_PADDING, y, MANA_SYMBOL_SIZE);
|
||||
//draw "//" between two parts of mana cost
|
||||
manaCostWidth += font.getBounds("//").width + MANA_COST_PADDING;
|
||||
g.drawText("//", font, foreColor, x + w - manaCostWidth + MANA_COST_PADDING, y, w, MANA_SYMBOL_SIZE, false, Align.left, true);
|
||||
}
|
||||
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE);
|
||||
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y, MANA_SYMBOL_SIZE);
|
||||
}
|
||||
else if(cardCurrentState.isAttraction()) {
|
||||
//For attractions, draw their lights instead of a mana cost.
|
||||
float lightWidth = (6 * MANA_SYMBOL_SIZE) + MANA_COST_PADDING;
|
||||
CardFaceSymbols.drawAttractionLights(g, cardCurrentState.getAttractionLights(), x + w - lightWidth, y, MANA_SYMBOL_SIZE, false);
|
||||
}
|
||||
manaCostWidth += CardFaceSymbols.getWidth(mainManaCost, MANA_SYMBOL_SIZE);
|
||||
CardFaceSymbols.drawManaCost(g, mainManaCost, x + w - manaCostWidth, y, MANA_SYMBOL_SIZE);
|
||||
|
||||
x += cardArtWidth;
|
||||
String name = CardTranslation.getTranslatedName(card.getCurrentState().getName());
|
||||
@@ -544,9 +551,6 @@ public class CardRenderer {
|
||||
type += String.format(" [%s / %s]", power, toughness);
|
||||
} else if (cardCurrentState.isBattle()) {
|
||||
type += " (" + cardCurrentState.getDefense() + ")";
|
||||
} else if (cardCurrentState.isAttraction()) {
|
||||
//TODO: Probably shouldn't be non-localized text here? Not sure what to do if someone makes an attraction with no lights...
|
||||
type += " (" + (cardCurrentState.getAttractionLights().isEmpty() ? "No Lights" : StringUtils.join(cardCurrentState.getAttractionLights(), ", ")) + ")";
|
||||
}
|
||||
g.drawText(type, typeFont, foreColor, x, y, availableTypeWidth, lineHeight, false, Align.left, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user