Fixed random stack abilities display order in client

This commit is contained in:
magenoxx 2012-06-05 17:26:17 +04:00
parent d07236352b
commit 2c175dadf4
6 changed files with 53 additions and 34 deletions

View file

@ -34,22 +34,19 @@
package mage.client.cards;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.view.*;
import javax.swing.border.Border;
import java.awt.*;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.swing.border.Border;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.view.CardView;
import mage.view.CardsView;
import mage.view.PermanentView;
import mage.view.SimpleCardsView;
import mage.view.StackAbilityView;
/**
*
@ -111,10 +108,10 @@ public class Cards extends javax.swing.JPanel {
}
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId);
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, null);
}
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, java.util.List<UUID> order) {
boolean changed = false;
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
@ -148,7 +145,7 @@ public class Cards extends javax.swing.JPanel {
}
if (changed) {
layoutCards(getCardDimension());
layoutCards(getCardDimension(), cards, order);
}
if (!isVisibleIfEmpty) {
@ -195,14 +192,27 @@ public class Cards extends javax.swing.JPanel {
}
}
private void layoutCards(Dimension dimension) {
private void layoutCards(Dimension dimension, Map<UUID, MageCard> cards, java.util.List<UUID> order) {
if (Plugins.getInstance().isCardPluginLoaded()) {
int dx = GAP_X;
for (MageCard card: cards.values()) {
card.setLocation(dx, 0);
card.setCardBounds(dx, 0, dimension.width, dimension.height);
dx += dimension.width + GAP_X;
}
if (order != null) {
for (UUID cardId : order) {
MageCard card = cards.get(cardId);
if (card != null) {
card.setLocation(dx, 0);
card.setCardBounds(dx, 0, dimension.width, dimension.height);
dx += dimension.width + GAP_X;
} else {
System.err.println("[ERROR] Cards.java: couldn't find a card from ordered list!");
}
}
} else {
for (MageCard card: cards.values()) {
card.setLocation(dx, 0);
card.setCardBounds(dx, 0, dimension.width, dimension.height);
dx += dimension.width + GAP_X;
}
}
}
}
@ -254,7 +264,7 @@ public class Cards extends javax.swing.JPanel {
public void setCardDimension(Dimension dimension) {
this.cardDimension = dimension;
layoutCards(cardDimension);
layoutCards(cardDimension, cards, null);
}
public void setZone(String zone) {

View file

@ -34,12 +34,12 @@
package mage.client.game;
import java.util.UUID;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.view.CombatGroupView;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -62,9 +62,9 @@ public class CombatGroup extends javax.swing.JPanel {
public void update(CombatGroupView combatGroup) {
this.lblDefender.setText(combatGroup.getDefenderName());
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId);
this.attackers.loadCards(combatGroup.getAttackers(), bigCard, gameId, null);
// attackers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId);
this.blockers.loadCards(combatGroup.getBlockers(), bigCard, gameId, null);
// blockers.setPreferredSize(new Dimension(Config.dimensions.frameWidth + 6, Config.dimensions.frameHeight + 6));
this.attackers.setVisible(true);
this.blockers.setVisible(true);

View file

@ -397,7 +397,7 @@ public class GamePanel extends javax.swing.JPanel {
}
}
this.stack.loadCards(game.getStack(), bigCard, gameId);
this.stack.loadCards(game.getStack(), bigCard, gameId, game.getStackOrder());
GameManager.getInstance().setStackSize(game.getStack().size());
for (ExileView exile: game.getExile()) {