mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Added some descriptions for non-card items in the quest shop
This commit is contained in:
@@ -320,6 +320,10 @@ public final class CardSet implements Comparable<CardSet> { // immutable
|
||||
return this.nLand;
|
||||
}
|
||||
|
||||
public final int getTotal() {
|
||||
return nCommon + nUncommon + nRare + nSpecial + nDoubleFaced + nLand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the foil chance.
|
||||
*
|
||||
|
||||
@@ -17,17 +17,27 @@
|
||||
*/
|
||||
package forge.gui.deckeditor;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.Card;
|
||||
import forge.SetUtils;
|
||||
import forge.card.CardSet;
|
||||
import forge.gui.game.CardDetailPanel;
|
||||
import forge.gui.game.CardPicturePanel;
|
||||
import forge.item.BoosterPack;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PreconDeck;
|
||||
|
||||
/**
|
||||
* This panel is to be placed in the right part of a deck editor.
|
||||
@@ -42,6 +52,8 @@ public class CardPanelLite extends CardPanelBase {
|
||||
private final CardDetailPanel detail = new CardDetailPanel(null);
|
||||
private final CardPicturePanel picture = new CardPicturePanel(null);
|
||||
private final JButton bChangeState = new JButton();
|
||||
private final JLabel descLabel = new JLabel();
|
||||
private final JScrollPane description;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -57,12 +69,19 @@ public class CardPanelLite extends CardPanelBase {
|
||||
});
|
||||
this.bChangeState.setFont(new java.awt.Font("Dialog", 0, 10));
|
||||
|
||||
description = new JScrollPane( descLabel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );
|
||||
descLabel.setSize(descLabel.getWidth() - description.getVerticalScrollBar().getWidth(), descLabel.getHeight());
|
||||
|
||||
this.setLayout(new MigLayout("fill, ins 0"));
|
||||
this.add(this.detail, "w 239, h 303, grow, flowy, wrap");
|
||||
this.add(this.description, "w 239, h 303, grow, flowy, wrap");
|
||||
this.add(this.bChangeState, "align 50% 0%, wrap");
|
||||
this.add(this.picture, "wmin 239, hmin 323, grow");
|
||||
}
|
||||
|
||||
private static Dimension shrinkedComponent = new Dimension(239, 0);
|
||||
private static Dimension expandedComponent = new Dimension(239, 303);
|
||||
|
||||
/**
|
||||
*
|
||||
* ShowCard.
|
||||
@@ -75,6 +94,9 @@ public class CardPanelLite extends CardPanelBase {
|
||||
this.picture.setCard(card);
|
||||
final boolean isCard = (card != null) && (card instanceof CardPrinted);
|
||||
this.detail.setVisible(isCard);
|
||||
this.description.setVisible(!isCard);
|
||||
description.setMaximumSize(isCard ? shrinkedComponent : expandedComponent);
|
||||
detail.setMaximumSize(!isCard ? shrinkedComponent : expandedComponent);
|
||||
if (isCard) {
|
||||
final Card toSet = ((CardPrinted) card).toForgeCard();
|
||||
|
||||
@@ -87,6 +109,21 @@ public class CardPanelLite extends CardPanelBase {
|
||||
this.bChangeState.setText("Transform");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( card instanceof BoosterPack )
|
||||
{
|
||||
BoosterPack booster = (BoosterPack) card;
|
||||
CardSet set = SetUtils.getSetByCodeOrThrow(booster.getSet());
|
||||
String tpl = "<html><b>%s booster pack.</b><br>Contains %d cards.<br><br>Buy it to reveal the cards and add them to your inventory.</html>";
|
||||
descLabel.setText(String.format(tpl, set.getName(), set.getBoosterData().getTotal()));
|
||||
} else if ( card instanceof PreconDeck )
|
||||
{
|
||||
PreconDeck deck = (PreconDeck) card;
|
||||
String desc = deck.getDescription();
|
||||
String tpl = "<html><center>%s</center>%s<br><br>This deck contains the following cards:<br>%s</html>";
|
||||
String decklist = StringUtils.join( deck.getDeck().getMain().toItemListString(), "<br>");
|
||||
descLabel.setText(String.format(tpl, deck.getName(), desc, decklist ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import net.slightlymagic.braids.util.lambda.Lambda1;
|
||||
import forge.CardList;
|
||||
import forge.card.CardRules;
|
||||
@@ -334,4 +336,13 @@ public class ItemPoolView<T extends InventoryItem> implements Iterable<Entry<T,
|
||||
public Lambda1<T, Entry<T, Integer>> getFnToPrinted() {
|
||||
return this.fnToPrinted;
|
||||
}
|
||||
|
||||
|
||||
public Iterable<String> toItemListString() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(Entry<T, Integer> e : cards.entrySet()) {
|
||||
list.add(String.format("%d x %s", e.getValue(), e.getKey().getName()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
private final Deck deck;
|
||||
private final String imageFilename;
|
||||
private final String set;
|
||||
private final String description;
|
||||
|
||||
private final SellRules recommendedDeals;
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -77,6 +79,7 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
|
||||
String filenameProxy = null;
|
||||
String setProxy = "n/a";
|
||||
String descriptionProxy = "";
|
||||
List<String> metadata = sections.get("metadata");
|
||||
if (null != metadata && !metadata.isEmpty()) {
|
||||
for (String s : metadata) {
|
||||
@@ -84,14 +87,18 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
if ("Image".equalsIgnoreCase(kv[0])) {
|
||||
filenameProxy = kv[1];
|
||||
}
|
||||
if ("set".equalsIgnoreCase(kv[0]) && SetUtils.getSetByCode(kv[1].toUpperCase()) != null) {
|
||||
else if ("set".equalsIgnoreCase(kv[0]) && SetUtils.getSetByCode(kv[1].toUpperCase()) != null) {
|
||||
setProxy = kv[1];
|
||||
}
|
||||
else if ("description".equalsIgnoreCase(kv[0]) && SetUtils.getSetByCode(kv[1].toUpperCase()) != null) {
|
||||
descriptionProxy = kv[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
imageFilename = filenameProxy;
|
||||
set = setProxy;
|
||||
recommendedDeals = new SellRules(sections.get("shop"));
|
||||
description = descriptionProxy;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,4 +128,9 @@ public class PreconDeck implements InventoryItemFromSet {
|
||||
public String getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
public final String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user