diff --git a/Mage.Client/plugins/mage-card-plugin.jar b/Mage.Client/plugins/mage-card-plugin.jar
index 69201b2f75d..d46415592f3 100644
Binary files a/Mage.Client/plugins/mage-card-plugin.jar and b/Mage.Client/plugins/mage-card-plugin.jar differ
diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index 1d66bf123db..15c5a0264b5 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -88,7 +88,7 @@
${project.groupId}
Mage-Card-Plugin
- 0.5
+ 0.6
runtime
diff --git a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
index 677a6e9827b..316b61ecb8f 100644
--- a/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
+++ b/Mage.Client/src/main/java/mage/client/dialog/PreferencesDialog.java
@@ -55,6 +55,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards";
public static final String KEY_HAND_SHOW_TOOLTIPS = "handShowTooltips";
+ public static final String KEY_PERMANENTS_IN_ONE_PILE = "nonLandPermanentsInOnePile";
public static final String KEY_CARD_IMAGES_USE_DEFAULT = "cardImagesUseDefault";
public static final String KEY_CARD_IMAGES_PATH = "cardImagesPath";
@@ -86,7 +87,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
jTabbedPane1 = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
jPanel3 = new javax.swing.JPanel();
+ jPanel6 = new javax.swing.JPanel();
showToolTipsInHand = new javax.swing.JCheckBox();
+ nonLandPermanentsInOnePile = new javax.swing.JCheckBox();
displayBigCardsInHand = new javax.swing.JCheckBox();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
@@ -141,6 +144,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
}
});
+ jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Battlefield"));
+
+ nonLandPermanentsInOnePile.setSelected(false);
+ nonLandPermanentsInOnePile.setText("Put non-land permanents in one pile.");
+
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
@@ -165,19 +173,37 @@ public class PreferencesDialog extends javax.swing.JDialog {
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addContainerGap())
- );
+ .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ );
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap()
+ .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(173, Short.MAX_VALUE))
);
+ javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
+ jPanel6.setLayout(jPanel6Layout);
+ jPanel6Layout.setHorizontalGroup(
+ jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel6Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(nonLandPermanentsInOnePile)
+ )
+ .addContainerGap(170, Short.MAX_VALUE))
+ );
+ jPanel6Layout.setVerticalGroup(
+ jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel6Layout.createSequentialGroup()
+ .addComponent(nonLandPermanentsInOnePile)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
jTabbedPane1.addTab("Main", jPanel1);
jLabel1.setText("Choose phases MAGE will stop on:");
@@ -430,6 +456,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
save(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true", "false", UPDATE_CACHE_POLICY);
save(prefs, dialog.showToolTipsInHand, KEY_HAND_SHOW_TOOLTIPS, "true", "false", UPDATE_CACHE_POLICY);
+ save(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true", "false", UPDATE_CACHE_POLICY);
saveImagesPath(prefs);
try {
prefs.flush();
@@ -507,6 +534,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
load(prefs, dialog.showToolTipsInHand, KEY_HAND_SHOW_TOOLTIPS, "true");
+ load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
loadImagesPath(prefs);
dialog.setLocation(300, 200);
dialog.reset();
@@ -619,10 +647,12 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
+ private javax.swing.JPanel jPanel6;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JButton saveButton;
private javax.swing.JCheckBox showToolTipsInHand;
private javax.swing.JCheckBox useDefaultImageFolder;
+ private javax.swing.JCheckBox nonLandPermanentsInOnePile;
// End of variables declaration//GEN-END:variables
private static final PreferencesDialog dialog = new PreferencesDialog(new javax.swing.JFrame(), true);
diff --git a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java
index 7e10bf51ff5..633e84a9e1d 100644
--- a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java
+++ b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java
@@ -11,6 +11,7 @@ import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.MagePlugins;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.util.Config;
+import mage.client.util.SettingsManager;
import mage.constants.Constants;
import mage.interfaces.PluginException;
import mage.interfaces.plugin.CardPlugin;
@@ -26,10 +27,7 @@ import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
public class Plugins implements MagePlugins {
@@ -42,6 +40,7 @@ public class Plugins implements MagePlugins {
private CardPlugin cardPlugin = null;
private CounterPlugin counterPlugin = null;
private static final MageActionCallback mageActionCallback = new MageActionCallback();
+ private Map sortingOptions = new HashMap();
public static MagePlugins getInstance() {
return fINSTANCE;
@@ -104,7 +103,8 @@ public class Plugins implements MagePlugins {
@Override
public void sortPermanents(Map ui, Collection permanents) {
- if (this.cardPlugin != null) this.cardPlugin.sortPermanents(ui, permanents);
+ sortingOptions.put("nonLandPermanentsInOnePile", PreferencesDialog.getCachedValue("nonLandPermanentsInOnePile", "false"));
+ if (this.cardPlugin != null) this.cardPlugin.sortPermanents(ui, permanents, sortingOptions);
}
@Override
diff --git a/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java b/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java
index 36369a98651..7aa2985b9c3 100644
--- a/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java
+++ b/Mage.Common/src/mage/interfaces/plugin/CardPlugin.java
@@ -19,7 +19,8 @@ import net.xeoh.plugins.base.Plugin;
/**
* Interface for card plugins
- *
+ *
+ * @version 0.6 17,07.2011 added options to #sortPermanents
* @version 0.3 21.11.2010 #getMageCard
* @version 0.2 07.11.2010 #downloadImages
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
@@ -28,7 +29,7 @@ import net.xeoh.plugins.base.Plugin;
public interface CardPlugin extends Plugin {
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage);
- void sortPermanents(Map ui, Collection cards);
+ void sortPermanents(Map ui, Collection cards, Map options);
/**
* Download images.
diff --git a/Mage.Plugins/Mage.Card.Plugin/pom.xml b/Mage.Plugins/Mage.Card.Plugin/pom.xml
index 97c5e369a3c..e905c82823f 100644
--- a/Mage.Plugins/Mage.Card.Plugin/pom.xml
+++ b/Mage.Plugins/Mage.Card.Plugin/pom.xml
@@ -76,7 +76,7 @@
- 0.5
+ 0.6
0.9.1
diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java
index aa851df5e0f..2c11513da2a 100644
--- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java
+++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java
@@ -38,6 +38,7 @@ import java.util.List;
*
* @author nantuko
* @version 0.1 01.11.2010 Mage permanents. Sorting card layout.
+ * @version 0.6 17,07.2011 #sortPermanents got option to display non-land permanents in one pile
*/
@PluginImplementation
@Author(name = "nantuko")
@@ -75,7 +76,7 @@ public class CardPluginImpl implements CardPlugin {
@Override
public String toString() {
- return "[Card plugin, version 0.5]";
+ return "[Card plugin, version 0.6]";
}
@Override
@@ -99,8 +100,12 @@ public class CardPluginImpl implements CardPlugin {
}
@Override
- public void sortPermanents(Map ui, Collection permanents) {
- if (ui == null)
+ public void sortPermanents(Map ui, Collection permanents, Map options) {
+ //TODO: add caching
+ //requires to find out is position have been changed that includes:
+ //adding/removing permanents, type change
+
+ if (ui == null)
throw new RuntimeException("Error: no components");
JComponent component = ui.get("jScrollPane");
JComponent component2 = ui.get("battlefieldPanel");
@@ -157,6 +162,16 @@ public class CardPluginImpl implements CardPlugin {
Row allCreatures = new Row(permanents, RowType.creature);
Row allOthers = new Row(permanents, RowType.other);
+ boolean othersOnTheRight = true;
+ if (options != null && options.containsKey("nonLandPermanentsInOnePile")) {
+ if (options.get("nonLandPermanentsInOnePile").equals("true")) {
+ System.out.println("in one pile");
+ othersOnTheRight = false;
+ allCreatures.addAll(allOthers);
+ allOthers.clear();
+ }
+ }
+
cardWidth = cardWidthMax;
Rectangle rect = jScrollPane.getVisibleRect();
playAreaWidth = rect.width;
@@ -198,6 +213,7 @@ public class CardPluginImpl implements CardPlugin {
if (creatures.isEmpty() && lands.isEmpty() && others.isEmpty())
break;
//cardWidth = (int)(cardWidth / 1.2);
+ //FIXME: -1 is too slow. why not binary search?
cardWidth--;
}
@@ -227,7 +243,7 @@ public class CardPluginImpl implements CardPlugin {
for (int stackIndex = 0, stackCount = row.size(); stackIndex < stackCount; stackIndex++) {
Stack stack = row.get(stackIndex);
// Align others to the right.
- if (RowType.other.isType(stack.get(0))) {
+ if (othersOnTheRight && RowType.other.isType(stack.get(0))) {
x = playAreaWidth - GUTTER_X + extraCardSpacingX;
for (int i = stackIndex, n = row.size(); i < n; i++)
x -= row.get(i).getWidth();
@@ -340,8 +356,9 @@ public class CardPluginImpl implements CardPlugin {
private void addAll(Collection permanents, RowType type) {
for (MagePermanent panel : permanents) {
- if (!type.isType(panel))
+ if (!type.isType(panel)) {
continue;
+ }
Stack stack = new Stack();
stack.add(panel);
add(stack);