Merge origin/master

This commit is contained in:
LevelX2 2013-11-27 23:47:52 +01:00
commit 9a68a2cea3
3 changed files with 36 additions and 10 deletions

View file

@ -61,6 +61,8 @@ import java.io.Serializable;
import java.util.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import mage.cards.Card;
import mage.client.util.CardsViewUtil;
/**
@ -86,6 +88,9 @@ public final class GamePanel extends javax.swing.JPanel {
private String chosenHandKey = "You";
private boolean smallMode = false;
private boolean initialized = false;
private Map<String, Card> loadedCards = new HashMap<String, Card>();
private int storedHeight;
@ -412,12 +417,12 @@ public final class GamePanel extends javax.swing.JPanel {
this.handContainer.setVisible(false);
} else {
handCards.clear();
handCards.put(YOUR_HAND, game.getHand());
handCards.put(YOUR_HAND, CardsViewUtil.convertSimple(game.getHand(), loadedCards));
// Get opponents hand cards if available
if (game.getOpponentHands() != null) {
for (Map.Entry<String, SimpleCardsView> hand: game.getOpponentHands().entrySet()) {
handCards.put(hand.getKey(), hand.getValue());
handCards.put(hand.getKey(), CardsViewUtil.convertSimple(game.getHand(), loadedCards));
}
}
@ -544,7 +549,7 @@ public final class GamePanel extends javax.swing.JPanel {
ShowCardsDialog newReveal = new ShowCardsDialog();
revealed.put(reveal.getName(), newReveal);
}
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), reveal.getCards(), bigCard, Config.dimensions, gameId, false);
revealed.get(reveal.getName()).loadCards("Revealed " + reveal.getName(), CardsViewUtil.convertSimple(reveal.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
}
}
@ -557,7 +562,7 @@ public final class GamePanel extends javax.swing.JPanel {
ShowCardsDialog newReveal = new ShowCardsDialog();
lookedAt.put(looked.getName(), newReveal);
}
lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), looked.getCards(), bigCard, Config.dimensions, gameId, false);
lookedAt.get(looked.getName()).loadCards("Looked at by " + looked.getName(), CardsViewUtil.convertSimple(looked.getCards(), loadedCards), bigCard, Config.dimensions, gameId, false);
}
}
@ -723,7 +728,7 @@ public final class GamePanel extends javax.swing.JPanel {
jSplitPane2 = new javax.swing.JSplitPane();
handContainer = new HandPanel();
handCards = new HashMap<String, SimpleCardsView>();
handCards = new HashMap<String, CardsView>();
jSplitPane1.setBorder(null);
jSplitPane1.setDividerSize(7);
@ -1184,7 +1189,7 @@ public final class GamePanel extends javax.swing.JPanel {
if (newChosenHandKey != null && newChosenHandKey.length() > 0) {
this.chosenHandKey = newChosenHandKey;
SimpleCardsView cards = handCards.get(chosenHandKey);
CardsView cards = handCards.get(chosenHandKey);
handContainer.loadCards(cards, bigCard, gameId);
}
}
@ -1290,7 +1295,7 @@ public final class GamePanel extends javax.swing.JPanel {
private javax.swing.JLabel txtStep;
private javax.swing.JLabel txtTurn;
private Map<String, SimpleCardsView> handCards;
private Map<String, CardsView> handCards;
private mage.client.cards.Cards stack;
private HandPanel handContainer;

View file

@ -5,13 +5,13 @@ import mage.client.cards.BigCard;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.Config;
import mage.constants.Zone;
import mage.view.SimpleCardsView;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.UUID;
import mage.view.CardsView;
public class HandPanel extends JPanel {
@ -58,8 +58,8 @@ public class HandPanel extends JPanel {
hand.setZone(Zone.HAND.toString());
}
public void loadCards(SimpleCardsView cards, BigCard bigCard, UUID gameId) {
hand.loadCards(cards, bigCard, gameId);
public void loadCards(CardsView cards, BigCard bigCard, UUID gameId) {
hand.loadCards(cards, bigCard, gameId, null);
hand.sizeCards(getHandCardDimension());
}

View file

@ -29,6 +29,7 @@
package mage.client.util;
import java.util.List;
import java.util.Map;
import mage.cards.Card;
import mage.cards.repository.CardInfo;
import mage.cards.repository.CardRepository;
@ -53,6 +54,26 @@ public class CardsViewUtil {
return cards;
}
public static CardsView convertSimple(SimpleCardsView view, Map<String, Card> loadedCards) {
CardsView cards = new CardsView();
for (SimpleCardView simple: view.values()) {
String key = simple.getExpansionSetCode() + "_" + simple.getCardNumber();
Card card = loadedCards.get(key);
if(card == null)
{
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
card = cardInfo != null ? cardInfo.getMockCard() : null;
loadedCards.put(key, card);
}
if (card != null) {
cards.put(simple.getId(), new CardView(card, simple.getId()));
}
}
return cards;
}
public static CardsView convertCommandObject(List<CommandObjectView> view) {
CardsView cards = new CardsView();