Improve rendering of basic lands

This commit is contained in:
drdev
2014-07-28 02:09:45 +00:00
parent 425ebeadeb
commit a63e8419f2
3 changed files with 34 additions and 10 deletions

View File

@@ -22,7 +22,6 @@ import com.badlogic.gdx.graphics.Pixmap.Format;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import forge.ImageKeys; import forge.ImageKeys;
import forge.game.card.Card; import forge.game.card.Card;

View File

@@ -103,7 +103,7 @@ final class ImageLoader extends CacheLoader<String, Texture> {
idx--; idx--;
} }
if (dotIdx > idx) { if (dotIdx > idx) {
artIndex = Integer.parseInt(cardName.substring(dotIdx, idx)); artIndex = Integer.parseInt(cardName.substring(idx, dotIdx));
} }
cardName = cardName.substring(0, idx); cardName = cardName.substring(0, idx);
} }

View File

@@ -175,6 +175,30 @@ public class CardImageRenderer {
} }
renderer.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h); renderer.drawRect(BORDER_THICKNESS, Color.BLACK, x, y, w, h);
if (card.isBasicLand()) {
//draw icons for basic lands
FSkinImage image;
switch (card.getName()) {
case "Plains":
image = FSkinImage.MANA_W;
break;
case "Island":
image = FSkinImage.MANA_U;
break;
case "Swamp":
image = FSkinImage.MANA_B;
break;
case "Mountain":
image = FSkinImage.MANA_R;
break;
default:
image = FSkinImage.MANA_G;
break;
}
float iconSize = h * 0.75f;
renderer.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize);
}
else {
float padding = TEXT_FONT.getCapHeight() * 0.75f; float padding = TEXT_FONT.getCapHeight() * 0.75f;
x += padding; x += padding;
y += padding; y += padding;
@@ -184,6 +208,7 @@ public class CardImageRenderer {
text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters
cardTextRenderer.drawText(renderer, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, true); cardTextRenderer.drawText(renderer, text, TEXT_FONT, Color.BLACK, x, y, w, h, y, h, true, HAlignment.LEFT, true);
} }
}
private static void drawPtBox(TextureRenderer renderer, Card card, Color color1, Color color2, float x, float y, float w, float h) { private static void drawPtBox(TextureRenderer renderer, Card card, Color color1, Color color2, float x, float y, float w, float h) {
List<String> pieces = new ArrayList<String>(); List<String> pieces = new ArrayList<String>();