Fixed Issue 167.

This commit is contained in:
magenoxx 2011-06-26 18:46:23 +04:00
parent 51e3e238af
commit 74b9b53091
8 changed files with 77 additions and 5 deletions

View file

@ -487,6 +487,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
return false; return false;
} }
@Override
public void setZone(String zone) {
//To change body of implemented methods use File | Settings | File Templates.
}
@Override
public String getZone() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override @Override
public PermanentView getOriginalPermanent() { public PermanentView getOriginalPermanent() {
return null; return null;

View file

@ -63,6 +63,7 @@ public class Cards extends javax.swing.JPanel {
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>(); private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
private boolean dontDisplayTapped = false; private boolean dontDisplayTapped = false;
private static final int GAP_X = 5; private static final int GAP_X = 5;
private String zone;
/** /**
* Defines whether component should be visible whenever there is no objects within. * Defines whether component should be visible whenever there is no objects within.
@ -170,6 +171,7 @@ public class Cards extends javax.swing.JPanel {
private void addCard(CardView card, BigCard bigCard, UUID gameId) { private void addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true); MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true);
if (zone != null) cardImg.setZone(zone);
cards.put(card.getId(), cardImg); cards.put(card.getId(), cardImg);
cardArea.add(cardImg); cardArea.add(cardImg);
} }
@ -248,4 +250,8 @@ public class Cards extends javax.swing.JPanel {
public void setCardDimension(Dimension dimension) { public void setCardDimension(Dimension dimension) {
this.cardDimension = dimension; this.cardDimension = dimension;
} }
public void setZone(String zone) {
this.zone = zone;
}
} }

View file

@ -33,7 +33,11 @@
*/ */
package mage.client.dialog; package mage.client.dialog;
import java.util.HashMap;
import java.util.Map;
import java.util.prefs.BackingStoreException; import java.util.prefs.BackingStoreException;
import com.sun.deploy.cache.Cache;
import mage.client.MageFrame; import mage.client.MageFrame;
import javax.swing.*; import javax.swing.*;
@ -50,6 +54,10 @@ import static mage.client.util.PhaseManager.END_OF_TURN_OTHERS;
public class PreferencesDialog extends javax.swing.JDialog { public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards"; public static final String KEY_HAND_USE_BIG_CARDS = "handUseBigCards";
public static final String KEY_HAND_SHOW_TOOLTIPS = "handShowTooltips";
private static Map<String, String> cache = new HashMap<String, String>();
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
/** Creates new form PreferencesDialog */ /** Creates new form PreferencesDialog */
public PreferencesDialog(java.awt.Frame parent, boolean modal) { public PreferencesDialog(java.awt.Frame parent, boolean modal) {
@ -343,7 +351,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
save(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS); save(prefs, dialog.checkBoxEndOfCOthers, END_OF_COMBAT_OTHERS);
save(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS); save(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
save(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS); save(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
save(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true", "false"); 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);
try { try {
prefs.flush(); prefs.flush();
} catch (BackingStoreException ex) { } catch (BackingStoreException ex) {
@ -389,6 +398,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS); load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS); load(prefs, dialog.checkBoxEndTurnOthers, END_OF_TURN_OTHERS);
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true"); load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
load(prefs, dialog.showToolTipsInHand, KEY_HAND_SHOW_TOOLTIPS, "true");
dialog.setLocation(300, 200); dialog.setLocation(300, 200);
dialog.reset(); dialog.reset();
dialog.setVisible(true); dialog.setVisible(true);
@ -409,17 +419,35 @@ public class PreferencesDialog extends javax.swing.JDialog {
} }
private static void save(Preferences prefs, JCheckBox checkBox, String propName) { private static void save(Preferences prefs, JCheckBox checkBox, String propName) {
save(prefs, checkBox, propName, PHASE_ON, PHASE_OFF); save(prefs, checkBox, propName, PHASE_ON, PHASE_OFF, false);
} }
private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String onValue) { private static void save(Preferences prefs, JCheckBox checkBox, String propName, String yesValue, String onValue, boolean updateCache) {
prefs.put(propName, checkBox.isSelected() ? yesValue : onValue); prefs.put(propName, checkBox.isSelected() ? yesValue : onValue);
if (updateCache) {
updateCache(propName, checkBox.isSelected() ? yesValue : onValue);
}
} }
public void reset() { public void reset() {
jTabbedPane1.setSelectedIndex(0); jTabbedPane1.setSelectedIndex(0);
} }
public static String getCachedValue(String key, String def) {
if (cache.containsKey(key)) {
return cache.get(key);
} else {
Preferences prefs = MageFrame.getPreferences();
String value = prefs.get(key, def);
cache.put(key, value);
return value;
}
}
private static void updateCache(String key, String value) {
cache.put(key, value);
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox checkBoxBeforeCOthers; private javax.swing.JCheckBox checkBoxBeforeCOthers;
private javax.swing.JCheckBox checkBoxBeforeCYou; private javax.swing.JCheckBox checkBoxBeforeCYou;

View file

@ -759,6 +759,7 @@ public class GamePanel extends javax.swing.JPanel {
//hand.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 20)); // for scroll //hand.setPreferredSize(new java.awt.Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight + 20)); // for scroll
hand.setBorder(emptyBorder); hand.setBorder(emptyBorder);
hand.setZone(Constants.Zone.HAND.toString());
HandContainer handContainer = new HandContainer(hand); HandContainer handContainer = new HandContainer(hand);
jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM); jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);

View file

@ -5,6 +5,7 @@ import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.prefs.Preferences;
import javax.swing.*; import javax.swing.*;
@ -16,6 +17,7 @@ import mage.cards.action.TransferData;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.components.MageComponents; import mage.client.components.MageComponents;
import mage.client.dialog.PreferencesDialog;
import mage.client.game.PlayAreaPanel; import mage.client.game.PlayAreaPanel;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.remote.Session; import mage.remote.Session;
@ -123,6 +125,18 @@ public class MageActionCallback implements ActionCallback {
if (data.card.getRarity().equals(Constants.Rarity.NA)) { if (data.card.getRarity().equals(Constants.Rarity.NA)) {
return; return;
} }
if (data.component instanceof MageCard) {
String zone = ((MageCard)(data.component)).getZone();
if (zone != null && zone.equals(Constants.Zone.HAND.toString())) {
// for performance getting cached value
String showTooltips = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_HAND_SHOW_TOOLTIPS, "false");
if (showTooltips.equals("false")) {
return;
}
}
}
if (cardInfoPane == null) { if (cardInfoPane == null) {
PopupFactory factory = PopupFactory.getSharedInstance(); PopupFactory factory = PopupFactory.getSharedInstance();
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40); popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);

View file

@ -20,4 +20,6 @@ public abstract class MageCard extends JPanel {
abstract public Image getImage(); abstract public Image getImage();
abstract public void setFoil(boolean foil); abstract public void setFoil(boolean foil);
abstract public boolean isFoil(); abstract public boolean isFoil();
abstract public void setZone(String zone);
abstract public String getZone();
} }

View file

@ -85,6 +85,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private boolean isPermanent; private boolean isPermanent;
private boolean hasSickness; private boolean hasSickness;
private boolean isFoil; private boolean isFoil;
private String zone;
public CardPanel(CardView newGameCard, UUID gameId, boolean loadImage, ActionCallback callback, final boolean foil) { public CardPanel(CardView newGameCard, UUID gameId, boolean loadImage, ActionCallback callback, final boolean foil) {
this.gameCard = newGameCard; this.gameCard = newGameCard;
@ -192,6 +193,16 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
return this.isFoil; return this.isFoil;
} }
@Override
public void setZone(String zone) {
this.zone = zone;
}
@Override
public String getZone() {
return zone;
}
public void setFoil(boolean foil) { public void setFoil(boolean foil) {
this.isFoil = foil; this.isFoil = foil;
if (foil) { if (foil) {