mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix so new cards appear on top in inventory
Fix so *NEW* appears next to new card names in spell shop
This commit is contained in:
@@ -221,29 +221,43 @@ public class CardRenderer {
|
||||
return cardArt;
|
||||
}
|
||||
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, Card card, int count, float x, float y, float w, float h) {
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, Card card, int count, String suffix, float x, float y, float w, float h) {
|
||||
CardRules cardRules = card.getRules();
|
||||
if (cardRules != null) {
|
||||
drawCardListItem(g, font, foreColor, getCardArt(card), cardRules, card.getCurSetCode(),
|
||||
card.getRarity(), card.getNetAttack(), card.getNetDefense(),
|
||||
card.getCurrentLoyalty(), count, x, y, w, h);
|
||||
card.getCurrentLoyalty(), count, suffix, x, y, w, h);
|
||||
}
|
||||
else { //if fake card, just draw card name centered
|
||||
g.drawText(card.getName(), font, foreColor, x, y, w, h, false, HAlignment.CENTER, true);
|
||||
String name = card.getName();
|
||||
if (count > 0) { //preface name with count if applicable
|
||||
name = count + " " + name;
|
||||
}
|
||||
if (suffix != null) {
|
||||
name += suffix;
|
||||
}
|
||||
g.drawText(name, font, foreColor, x, y, w, h, false, HAlignment.CENTER, true);
|
||||
}
|
||||
}
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, PaperCard paperCard, int count, float x, float y, float w, float h) {
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, PaperCard paperCard, int count, String suffix, float x, float y, float w, float h) {
|
||||
CardRules cardRules = paperCard.getRules();
|
||||
if (cardRules != null) {
|
||||
drawCardListItem(g, font, foreColor, getCardArt(paperCard), cardRules, paperCard.getEdition(),
|
||||
paperCard.getRarity(), cardRules.getIntPower(), cardRules.getIntToughness(),
|
||||
cardRules.getInitialLoyalty(), count, x, y, w, h);
|
||||
cardRules.getInitialLoyalty(), count, suffix, x, y, w, h);
|
||||
}
|
||||
else { //if fake card, just draw card name centered
|
||||
g.drawText(paperCard.getName(), font, foreColor, x, y, w, h, false, HAlignment.CENTER, true);
|
||||
String name = paperCard.getName();
|
||||
if (count > 0) { //preface name with count if applicable
|
||||
name = count + " " + name;
|
||||
}
|
||||
if (suffix != null) {
|
||||
name += suffix;
|
||||
}
|
||||
g.drawText(name, font, foreColor, x, y, w, h, false, HAlignment.CENTER, true);
|
||||
}
|
||||
}
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, TextureRegion cardArt, CardRules cardRules, String set, CardRarity rarity, int power, int toughness, int loyalty, int count, float x, float y, float w, float h) {
|
||||
public static void drawCardListItem(Graphics g, FSkinFont font, FSkinColor foreColor, TextureRegion cardArt, CardRules cardRules, String set, CardRarity rarity, int power, int toughness, int loyalty, int count, String suffix, float x, float y, float w, float h) {
|
||||
float cardArtHeight = h + 2 * FList.PADDING;
|
||||
float cardArtWidth = cardArtHeight * CARD_ART_RATIO;
|
||||
if (cardArt != null) {
|
||||
@@ -284,6 +298,9 @@ public class CardRenderer {
|
||||
if (count > 0) { //preface name with count if applicable
|
||||
name = count + " " + name;
|
||||
}
|
||||
if (suffix != null) {
|
||||
name += suffix;
|
||||
}
|
||||
g.drawText(name, font, foreColor, x, y, w - manaCostWidth - cardArtWidth - FList.PADDING, MANA_SYMBOL_SIZE, false, HAlignment.LEFT, true);
|
||||
|
||||
y += MANA_SYMBOL_SIZE + FList.PADDING + SET_BOX_MARGIN;
|
||||
|
||||
@@ -162,7 +162,7 @@ public class CardManager extends ItemManager<PaperCard> {
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, Entry<PaperCard, Integer> value, FSkinFont font, FSkinColor foreColor, FSkinColor backColor, boolean pressed, float x, float y, float w, float h) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, value.getKey(), isInfinite() ? 0 : value.getValue(), x, y, w, h);
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, value.getKey(), isInfinite() ? 0 : value.getValue(), null, x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.filters.ItemFilter;
|
||||
import forge.menu.FPopupMenu;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestSpellShop;
|
||||
import forge.toolbox.FList;
|
||||
|
||||
@@ -61,11 +62,12 @@ public final class SpellShopManager extends ItemManager<InventoryItem> {
|
||||
float totalHeight = h + 2 * FList.PADDING;
|
||||
float cardArtWidth = totalHeight * CardRenderer.CARD_ART_RATIO;
|
||||
|
||||
String suffix = FModel.getQuest().getCards().isNew(value.getKey()) ? " *NEW*" : null;
|
||||
if (value.getKey() instanceof PaperCard) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value.getKey(), value.getValue(), x, y, w, h);
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value.getKey(), value.getValue(), suffix, x, y, w, h);
|
||||
}
|
||||
else {
|
||||
g.drawText(value.getValue().toString() + " " + value.getKey().toString(), font, foreColor, x + cardArtWidth, y, w - cardArtWidth, h, false, HAlignment.LEFT, true);
|
||||
g.drawText(value.getValue().toString() + " " + value.getKey().toString() + (suffix == null ? "" : suffix), font, foreColor, x + cardArtWidth, y, w - cardArtWidth, h, false, HAlignment.LEFT, true);
|
||||
Texture image = ImageCache.getImage(value.getKey());
|
||||
if (image != null) {
|
||||
float imageRatio = (float)image.getWidth() / (float)image.getHeight();
|
||||
|
||||
@@ -366,7 +366,7 @@ public class DualListBox<T> extends FDialog {
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (Card)value, 0, x, y, w, h);
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (Card)value, 0, null, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ public class ListChooser<T> extends FContainer {
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value, 0, x, y, w, h);
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (PaperCard)value, 0, null, x, y, w, h);
|
||||
}
|
||||
}
|
||||
//special renderer for cards
|
||||
@@ -296,7 +296,7 @@ public class ListChooser<T> extends FContainer {
|
||||
|
||||
@Override
|
||||
public void drawValue(Graphics g, T value, FSkinFont font, FSkinColor foreColor, boolean pressed, float x, float y, float w, float h) {
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (Card)value, 0, x, y, w, h);
|
||||
CardRenderer.drawCardListItem(g, font, foreColor, (Card)value, 0, null, x, y, w, h);
|
||||
}
|
||||
}
|
||||
//special renderer for SpellAbilities
|
||||
|
||||
@@ -231,7 +231,7 @@ public enum ColumnDef {
|
||||
return from.getValue();
|
||||
}
|
||||
}),
|
||||
NEW("New", "New", 30, true, SortState.ASC,
|
||||
NEW("New", "New", 30, true, SortState.DESC,
|
||||
null, null), //functions will be set later
|
||||
PRICE("Price", "Price", 35, true, SortState.DESC,
|
||||
null, null),
|
||||
|
||||
@@ -736,6 +736,10 @@ public final class QuestUtilCards {
|
||||
return this.fnNewGet;
|
||||
}
|
||||
|
||||
public boolean isNew(InventoryItem item) {
|
||||
return qa.getNewCardList().contains(item);
|
||||
}
|
||||
|
||||
// These functions provide a way to sort and compare cards in a table
|
||||
// according to their new-ness
|
||||
// It might be a good idea to store them in a base class for both quest-mode
|
||||
@@ -746,8 +750,7 @@ public final class QuestUtilCards {
|
||||
new Function<Entry<InventoryItem, Integer>, Comparable<?>>() {
|
||||
@Override
|
||||
public Comparable<?> apply(final Entry<InventoryItem, Integer> from) {
|
||||
return QuestUtilCards.this.qa.getNewCardList().contains(from.getKey()) ? Integer.valueOf(1) : Integer
|
||||
.valueOf(0);
|
||||
return isNew(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -756,7 +759,7 @@ public final class QuestUtilCards {
|
||||
new Function<Entry<? extends InventoryItem, Integer>, Object>() {
|
||||
@Override
|
||||
public Object apply(final Entry<? extends InventoryItem, Integer> from) {
|
||||
return QuestUtilCards.this.qa.getNewCardList().contains(from.getKey()) ? "NEW" : "";
|
||||
return isNew(from.getKey()) ? "NEW" : "";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user