mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
Fixed Issue 167.
This commit is contained in:
parent
51e3e238af
commit
74b9b53091
8 changed files with 77 additions and 5 deletions
|
|
@ -487,6 +487,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
|
|||
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
|
||||
public PermanentView getOriginalPermanent() {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ public class Cards extends javax.swing.JPanel {
|
|||
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
|
||||
private boolean dontDisplayTapped = false;
|
||||
private static final int GAP_X = 5;
|
||||
private String zone;
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, getCardDimension(), gameId, true);
|
||||
if (zone != null) cardImg.setZone(zone);
|
||||
cards.put(card.getId(), cardImg);
|
||||
cardArea.add(cardImg);
|
||||
}
|
||||
|
|
@ -248,4 +250,8 @@ public class Cards extends javax.swing.JPanel {
|
|||
public void setCardDimension(Dimension dimension) {
|
||||
this.cardDimension = dimension;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@
|
|||
*/
|
||||
package mage.client.dialog;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.prefs.BackingStoreException;
|
||||
|
||||
import com.sun.deploy.cache.Cache;
|
||||
import mage.client.MageFrame;
|
||||
|
||||
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 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 */
|
||||
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.checkBoxMain2Others, MAIN_2_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 {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException ex) {
|
||||
|
|
@ -389,8 +398,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
load(prefs, dialog.checkBoxMain2Others, MAIN_2_OTHERS);
|
||||
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");
|
||||
dialog.setLocation(300, 200);
|
||||
dialog.reset();
|
||||
dialog.reset();
|
||||
dialog.setVisible(true);
|
||||
} else {
|
||||
dialog.requestFocus();
|
||||
|
|
@ -409,17 +419,35 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
}
|
||||
|
||||
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);
|
||||
if (updateCache) {
|
||||
updateCache(propName, checkBox.isSelected() ? yesValue : onValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
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
|
||||
private javax.swing.JCheckBox checkBoxBeforeCOthers;
|
||||
private javax.swing.JCheckBox checkBoxBeforeCYou;
|
||||
|
|
|
|||
|
|
@ -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.setBorder(emptyBorder);
|
||||
hand.setZone(Constants.Zone.HAND.toString());
|
||||
HandContainer handContainer = new HandContainer(hand);
|
||||
|
||||
jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ import mage.cards.action.TransferData;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.components.MageComponents;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import mage.client.game.PlayAreaPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.remote.Session;
|
||||
|
|
@ -123,6 +125,18 @@ public class MageActionCallback implements ActionCallback {
|
|||
if (data.card.getRarity().equals(Constants.Rarity.NA)) {
|
||||
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) {
|
||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||
popup = factory.getPopup(data.component, data.popupText, (int) data.locationOnScreen.getX() + data.popupOffsetX, (int) data.locationOnScreen.getY() + data.popupOffsetY + 40);
|
||||
|
|
|
|||
|
|
@ -20,4 +20,6 @@ public abstract class MageCard extends JPanel {
|
|||
abstract public Image getImage();
|
||||
abstract public void setFoil(boolean foil);
|
||||
abstract public boolean isFoil();
|
||||
abstract public void setZone(String zone);
|
||||
abstract public String getZone();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class CardView implements Serializable {
|
|||
}
|
||||
this.expansionSetCode = card.getExpansionSetCode();
|
||||
this.cardNumber = card.getCardNumber();
|
||||
|
||||
|
||||
if (card instanceof Spell) {
|
||||
Spell<?> spell = (Spell<?>)card;
|
||||
if (spell.getSpellAbility().getTargets().size() > 0) {
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
private boolean isPermanent;
|
||||
private boolean hasSickness;
|
||||
private boolean isFoil;
|
||||
private String zone;
|
||||
|
||||
public CardPanel(CardView newGameCard, UUID gameId, boolean loadImage, ActionCallback callback, final boolean foil) {
|
||||
this.gameCard = newGameCard;
|
||||
|
|
@ -192,6 +193,16 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
|||
return this.isFoil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setFoil(boolean foil) {
|
||||
this.isFoil = foil;
|
||||
if (foil) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue