Fixed a bug that during sideboarding the display of the card the mouse hoovered on did stop to show in the big card panel.

This commit is contained in:
LevelX2 2014-02-26 20:41:27 +01:00
parent 62b92f1c5d
commit 4bd4ad3d8a
5 changed files with 53 additions and 36 deletions

View file

@ -56,7 +56,7 @@ public class Cards extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(Cards.class);
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
private boolean dontDisplayTapped = false;
private static final int GAP_X = 5;
private String zone;
@ -89,10 +89,10 @@ public class Cards extends javax.swing.JPanel {
}
public void cleanUp() {
ActionCallback actionCallback = Plugins.getInstance().getActionCallback();
if (actionCallback instanceof MageActionCallback) {
((MageActionCallback) actionCallback).setCardPreviewComponent(null);
}
// ActionCallback actionCallback = Plugins.getInstance().getActionCallback();
// if (actionCallback instanceof MageActionCallback) {
// ((MageActionCallback) actionCallback).setCardPreviewComponent(null);
// }
}
/**

View file

@ -61,9 +61,7 @@ import mage.client.constants.Constants.DeckEditorMode;
import static mage.client.constants.Constants.DeckEditorMode.Constructed;
import static mage.client.constants.Constants.DeckEditorMode.Limited;
import static mage.client.constants.Constants.DeckEditorMode.Sideboard;
import mage.client.constants.Constants.SortBy;
import mage.client.dialog.AddLandDialog;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Event;
@ -142,9 +140,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
this.cardSelector.cleanUp();
this.deckArea.cleanUp();
this.remove(bigCard);
this.bigCard = null;
((MageActionCallback) Plugins.getInstance().getActionCallback()).setCardPreviewComponent(null);
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {

View file

@ -67,10 +67,10 @@ import mage.view.PermanentView;
*/
public class BattlefieldPanel extends javax.swing.JLayeredPane {
private final Map<UUID, MagePermanent> permanents = new LinkedHashMap<UUID, MagePermanent>();
private final Map<UUID, MagePermanent> permanents = new LinkedHashMap<>();
private UUID gameId;
private BigCard bigCard;
private final Map<String, JComponent> uiComponentsList = new HashMap<String, JComponent>();
private final Map<String, JComponent> uiComponentsList = new HashMap<>();
protected Map<UUID, PermanentView> battlefield;
private Dimension cardDimension;
@ -118,12 +118,13 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
}
permanents.clear();
Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
this.bigCard = null;
}
public void update(Map<UUID, PermanentView> battlefield) {
boolean changed = false;
List<PermanentView> permanentsToAdd = new ArrayList<PermanentView>();
List<PermanentView> permanentsToAdd = new ArrayList<>();
for (PermanentView permanent: battlefield.values()) {
if (!permanents.containsKey(permanent.getId())) {
permanentsToAdd.add(permanent);

View file

@ -50,7 +50,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -94,6 +93,16 @@ import mage.client.util.GameManager;
import mage.client.util.PhaseManager;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.PhaseStep;
import static mage.constants.PhaseStep.BEGIN_COMBAT;
import static mage.constants.PhaseStep.COMBAT_DAMAGE;
import static mage.constants.PhaseStep.DECLARE_ATTACKERS;
import static mage.constants.PhaseStep.DECLARE_BLOCKERS;
import static mage.constants.PhaseStep.DRAW;
import static mage.constants.PhaseStep.END_COMBAT;
import static mage.constants.PhaseStep.END_TURN;
import static mage.constants.PhaseStep.FIRST_COMBAT_DAMAGE;
import static mage.constants.PhaseStep.UNTAP;
import static mage.constants.PhaseStep.UPKEEP;
import mage.remote.Session;
import mage.view.AbilityPickerView;
import mage.view.CardsView;
@ -116,11 +125,11 @@ public final class GamePanel extends javax.swing.JPanel {
private static final Logger logger = Logger.getLogger(GamePanel.class);
private static final String YOUR_HAND = "Your hand";
private static final int X_PHASE_WIDTH = 55;
private final Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
private final Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
private final Map<String, ShowCardsDialog> revealed = new HashMap<String, ShowCardsDialog>();
private final Map<String, ShowCardsDialog> lookedAt = new HashMap<String, ShowCardsDialog>();
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<ShowCardsDialog>();
private final Map<UUID, PlayAreaPanel> players = new HashMap<>();
private final Map<UUID, ExileZoneDialog> exiles = new HashMap<>();
private final Map<String, ShowCardsDialog> revealed = new HashMap<>();
private final Map<String, ShowCardsDialog> lookedAt = new HashMap<>();
private final ArrayList<ShowCardsDialog> pickTarget = new ArrayList<>();
private UUID gameId;
private UUID playerId;
private Session session;
@ -133,7 +142,7 @@ public final class GamePanel extends javax.swing.JPanel {
private int lastUpdatedTurn;
private Map<String, Card> loadedCards = new HashMap<String, Card>();
private Map<String, Card> loadedCards = new HashMap<>();
private int storedHeight;
@ -186,7 +195,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
Map<String, JComponent> components = new HashMap<String, JComponent>();
Map<String, JComponent> components = new HashMap<>();
components.put("jSplitPane1", jSplitPane1);
components.put("pnlBattlefield", pnlBattlefield);
@ -247,6 +256,8 @@ public final class GamePanel extends javax.swing.JPanel {
} catch (InterruptedException ex) {
logger.fatal("popupContainer error:", ex);
}
jPanel2.remove(bigCard);
this.bigCard = null;
}
private void saveDividerLocations() {
@ -685,7 +696,7 @@ public final class GamePanel extends javax.swing.JPanel {
for (PlayerView playerView : gameView.getPlayers()) {
if (playerView.getPlayerId().equals(playerId)) {
if (playerView.isActive()) {
options = new HashMap<String, Serializable>();
options = new HashMap<>();
options.put("your_turn", true);
messageToDisplay = message + " <div style='font-size:11pt'>Your turn</div>";
}
@ -817,7 +828,7 @@ public final class GamePanel extends javax.swing.JPanel {
jSplitPane2 = new javax.swing.JSplitPane();
handContainer = new HandPanel();
handCards = new HashMap<String, CardsView>();
handCards = new HashMap<>();
jSplitPane1.setBorder(null);
jSplitPane1.setDividerSize(7);
@ -1384,7 +1395,7 @@ public final class GamePanel extends javax.swing.JPanel {
private void createPhaseButton(String name) {
if (hoverButtons == null) {
hoverButtons = new LinkedHashMap<String, HoverButton>();
hoverButtons = new LinkedHashMap<>();
}
Rectangle rect = new Rectangle(36, 36);
HoverButton button = new HoverButton("", ImageManagerImpl.getInstance().getPhaseImage(name), rect);

View file

@ -1,5 +1,23 @@
package mage.client.plugins.adapters;
import java.awt.Color;
import java.awt.Component;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback;
@ -21,23 +39,13 @@ import mage.utils.ThreadUtils;
import mage.view.CardView;
import mage.view.PlayerView;
import mage.view.SimpleCardsView;
import org.apache.log4j.Logger;
import org.jdesktop.swingx.JXPanel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseWheelEvent;
import java.awt.image.BufferedImage;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import org.jboss.logging.Logger;
public class MageActionCallback implements ActionCallback {
private static final Logger logger = Logger.getLogger(ActionCallback.class);
private Popup popup;
private JPopupMenu jPopupMenu;
private BigCard bigCard;
@ -185,7 +193,6 @@ public class MageActionCallback implements ActionCallback {
target.translate(-parentPoint.x, -parentPoint.y);
int yOffset = p.isSmallMode() ? (PlayAreaPanel.PANEL_HEIGHT - PlayAreaPanel.PANEL_HEIGHT_SMALL) : 0;
ArrowBuilder.getBuilder().addArrow(data.gameId, (int) me.getX() + 35, (int) me.getY(), (int) target.getX() + 15, (int) target.getY() + 145 - yOffset, Color.red, ArrowBuilder.Type.TARGET);
continue;
}
}
}