mirror of
https://github.com/correl/mage.git
synced 2025-03-31 01:07:39 -09:00
Added an option to display non land cards in one pile. Fixed Issue 166.
This commit is contained in:
parent
b78629c842
commit
f65634796b
7 changed files with 67 additions and 19 deletions
Mage.Client
Mage.Common/src/mage/interfaces/plugin
Mage.Plugins/Mage.Card.Plugin
Binary file not shown.
|
@ -88,7 +88,7 @@
|
|||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>Mage-Card-Plugin</artifactId>
|
||||
<version>0.5</version>
|
||||
<version>0.6</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<String, String> sortingOptions = new HashMap<String, String>();
|
||||
|
||||
public static MagePlugins getInstance() {
|
||||
return fINSTANCE;
|
||||
|
@ -104,7 +103,8 @@ public class Plugins implements MagePlugins {
|
|||
|
||||
@Override
|
||||
public void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> 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
|
||||
|
|
|
@ -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<String, JComponent> ui, Collection<MagePermanent> cards);
|
||||
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> cards, Map<String, String> options);
|
||||
|
||||
/**
|
||||
* Download images.
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<plugin-version>0.5</plugin-version>
|
||||
<plugin-version>0.6</plugin-version>
|
||||
<jspf-version>0.9.1</jspf-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
@ -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<String, JComponent> ui, Collection<MagePermanent> permanents) {
|
||||
if (ui == null)
|
||||
public void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents, Map<String, String> 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<MagePermanent> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue