mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Fix so color sets rendered in the correct order
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.common.collect.UnmodifiableIterator;
|
||||
|
||||
import forge.card.MagicColor.Color;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.util.BinaryUtil;
|
||||
|
||||
/**
|
||||
@@ -357,4 +358,69 @@ public final class ColorSet implements Comparable<ColorSet>, Iterable<Byte>, Ser
|
||||
return MagicColor.WUBRG[currentBit];
|
||||
}
|
||||
}
|
||||
|
||||
//Get array of mana cost shards for color set in the proper order
|
||||
public ManaCostShard[] getOrderedShards() {
|
||||
return shardOrderLookup[myColor];
|
||||
}
|
||||
|
||||
private static final ManaCostShard[][] shardOrderLookup = new ManaCostShard[ALL_COLORS_MASK + 1][];
|
||||
static {
|
||||
byte COLORLESS = MagicColor.COLORLESS;
|
||||
byte WHITE = MagicColor.WHITE;
|
||||
byte BLUE = MagicColor.BLUE;
|
||||
byte BLACK = MagicColor.BLACK;
|
||||
byte RED = MagicColor.RED;
|
||||
byte GREEN = MagicColor.GREEN;
|
||||
ManaCostShard C = ManaCostShard.COLORLESS;
|
||||
ManaCostShard W = ManaCostShard.WHITE;
|
||||
ManaCostShard U = ManaCostShard.BLUE;
|
||||
ManaCostShard B = ManaCostShard.BLACK;
|
||||
ManaCostShard R = ManaCostShard.RED;
|
||||
ManaCostShard G = ManaCostShard.GREEN;
|
||||
|
||||
//colorless
|
||||
shardOrderLookup[COLORLESS] = new ManaCostShard[] { C };
|
||||
|
||||
//mono-color
|
||||
shardOrderLookup[WHITE] = new ManaCostShard[] { W };
|
||||
shardOrderLookup[BLUE] = new ManaCostShard[] { U };
|
||||
shardOrderLookup[BLACK] = new ManaCostShard[] { B };
|
||||
shardOrderLookup[RED] = new ManaCostShard[] { R };
|
||||
shardOrderLookup[GREEN] = new ManaCostShard[] { G };
|
||||
|
||||
//two-color
|
||||
shardOrderLookup[WHITE | BLUE] = new ManaCostShard[] { W, U };
|
||||
shardOrderLookup[WHITE | BLACK] = new ManaCostShard[] { W, B };
|
||||
shardOrderLookup[BLUE | BLACK] = new ManaCostShard[] { U, B };
|
||||
shardOrderLookup[BLUE | RED] = new ManaCostShard[] { U, R };
|
||||
shardOrderLookup[BLACK | RED] = new ManaCostShard[] { B, R };
|
||||
shardOrderLookup[BLACK | GREEN] = new ManaCostShard[] { B, G };
|
||||
shardOrderLookup[RED | GREEN] = new ManaCostShard[] { R, G };
|
||||
shardOrderLookup[RED | WHITE] = new ManaCostShard[] { R, W };
|
||||
shardOrderLookup[GREEN | WHITE] = new ManaCostShard[] { G, W };
|
||||
shardOrderLookup[GREEN | BLUE] = new ManaCostShard[] { G, U };
|
||||
|
||||
//three-color
|
||||
shardOrderLookup[WHITE | BLUE | BLACK] = new ManaCostShard[] { W, U, B };
|
||||
shardOrderLookup[WHITE | BLACK | RED] = new ManaCostShard[] { W, B, R };
|
||||
shardOrderLookup[BLUE | BLACK | RED] = new ManaCostShard[] { U, B, R };
|
||||
shardOrderLookup[BLUE | RED | GREEN] = new ManaCostShard[] { U, R, G };
|
||||
shardOrderLookup[BLACK | RED | GREEN] = new ManaCostShard[] { B, R, G };
|
||||
shardOrderLookup[BLACK | GREEN | WHITE] = new ManaCostShard[] { B, G, W };
|
||||
shardOrderLookup[RED | GREEN | WHITE] = new ManaCostShard[] { R, G, W };
|
||||
shardOrderLookup[RED | WHITE | BLUE] = new ManaCostShard[] { R, W, U };
|
||||
shardOrderLookup[GREEN | WHITE | BLUE] = new ManaCostShard[] { G, W, U };
|
||||
shardOrderLookup[GREEN | BLUE | BLACK] = new ManaCostShard[] { G, U, B };
|
||||
|
||||
//four-color
|
||||
shardOrderLookup[WHITE | BLUE | BLACK | RED] = new ManaCostShard[] { W, U, B, R };
|
||||
shardOrderLookup[BLUE | BLACK | RED | GREEN] = new ManaCostShard[] { U, B, R, G };
|
||||
shardOrderLookup[BLACK | RED | GREEN | WHITE] = new ManaCostShard[] { B, R, G, W };
|
||||
shardOrderLookup[RED | GREEN | WHITE | BLUE] = new ManaCostShard[] { R, G, W, U };
|
||||
shardOrderLookup[GREEN | WHITE | BLUE | BLACK] = new ManaCostShard[] { G, W, U, B };
|
||||
|
||||
//five-color
|
||||
shardOrderLookup[ALL_COLORS_MASK] = new ManaCostShard[] { W, U, B, R, G };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,16 +56,9 @@ public class ColorSetRenderer extends ItemCellRenderer {
|
||||
final int offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding0 - elemtWidth) / (cntGlyphs - 1) : elemtWidth + elemtGap;
|
||||
final int dx = Math.min(elemtWidth + elemtGap, offsetIfNoSpace);
|
||||
|
||||
// Display generic mana before colored mana
|
||||
if (cntGlyphs == 0) {
|
||||
CardFaceSymbols.drawSymbol(ManaCostShard.X.getImageKey(), g, x, y);
|
||||
for (final ManaCostShard s : cs.getOrderedShards()) {
|
||||
CardFaceSymbols.drawSymbol(s.getImageKey(), g, x, y);
|
||||
x += dx;
|
||||
}
|
||||
|
||||
if (cs.hasWhite()) { CardFaceSymbols.drawSymbol(ManaCostShard.WHITE.getImageKey(), g, x, y); x += dx; }
|
||||
if (cs.hasBlue()) { CardFaceSymbols.drawSymbol(ManaCostShard.BLUE.getImageKey(), g, x, y); x += dx; }
|
||||
if (cs.hasBlack()) { CardFaceSymbols.drawSymbol(ManaCostShard.BLACK.getImageKey(), g, x, y); x += dx; }
|
||||
if (cs.hasRed()) { CardFaceSymbols.drawSymbol(ManaCostShard.RED.getImageKey(), g, x, y); x += dx; }
|
||||
if (cs.hasGreen()) { CardFaceSymbols.drawSymbol(ManaCostShard.GREEN.getImageKey(), g, x, y); x += dx; }
|
||||
}
|
||||
}
|
||||
@@ -140,31 +140,12 @@ public class CardFaceSymbols {
|
||||
}
|
||||
|
||||
public static void drawColorSet(Graphics g, ColorSet colorSet, float x, float y, final float imageSize) {
|
||||
if (colorSet.isColorless()) {
|
||||
g.drawImage(FSkinImage.MANA_COLORLESS, x, y, imageSize, imageSize);
|
||||
return;
|
||||
}
|
||||
|
||||
final float dx = imageSize;
|
||||
if (colorSet.hasWhite()) {
|
||||
g.drawImage(FSkinImage.MANA_W, x, y, imageSize, imageSize);
|
||||
|
||||
for (final ManaCostShard s : colorSet.getOrderedShards()) {
|
||||
drawSymbol(s.getImageKey(), g, x, y, imageSize, imageSize);
|
||||
x += dx;
|
||||
}
|
||||
if (colorSet.hasBlue()) {
|
||||
g.drawImage(FSkinImage.MANA_U, x, y, imageSize, imageSize);
|
||||
x += dx;
|
||||
}
|
||||
if (colorSet.hasBlack()) {
|
||||
g.drawImage(FSkinImage.MANA_B, x, y, imageSize, imageSize);
|
||||
x += dx;
|
||||
}
|
||||
if (colorSet.hasRed()) {
|
||||
g.drawImage(FSkinImage.MANA_R, x, y, imageSize, imageSize);
|
||||
x += dx;
|
||||
}
|
||||
if (colorSet.hasGreen()) {
|
||||
g.drawImage(FSkinImage.MANA_G, x, y, imageSize, imageSize);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawOther(final Graphics g, String s, float x, final float y, final float w, final float h) {
|
||||
|
||||
Reference in New Issue
Block a user