Fixed a problem that show cards window was not closed (e.g. for libraray card selection).

This commit is contained in:
LevelX2 2015-08-26 16:30:32 +02:00
parent 0ee22d90ca
commit 97a8b351b4

View file

@ -199,14 +199,14 @@ public final class GamePanel extends javax.swing.JPanel {
// CardView popupMenu was invoked last
private CardView cardViewPopupMenu;
// popup menu for a card
private JPopupMenu popupMenuCardPanel;
// popup menu for triggered abilities order
private JPopupMenu popupMenuTriggerOrder;
public GamePanel() {
initComponents();
createTriggerOrderPupupMenu();
this.add(popupMenuCardPanel);
initPopupMenuTriggerOrder();
//this.add(popupMenuTriggerOrder);
pickNumber = new PickNumberDialog();
MageFrame.getDesktop().add(pickNumber, JLayeredPane.MODAL_LAYER);
@ -1107,12 +1107,10 @@ public final class GamePanel extends javax.swing.JPanel {
hideAll();
ShowCardsDialog showCards = new ShowCardsDialog();
JPopupMenu popupMenu = null;
Listener<Event> eventListener = null;
if (PopUpMenuType.TRIGGER_ORDER.equals(popupMenuType)) {
popupMenu = getTriggerOrderPopupMenu();
eventListener = getTriggerOrderEventListener(showCards);
popupMenu = popupMenuTriggerOrder;
}
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required, options, popupMenu, eventListener);
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required, options, popupMenu, getShowCardsEventListener(showCards));
return showCards;
}
@ -1985,8 +1983,8 @@ public final class GamePanel extends javax.swing.JPanel {
hoverButtons.put(name, button);
}
// TriggerOrderPopupMenu
private Listener<Event> getTriggerOrderEventListener(final ShowCardsDialog dialog) {
// Event listener for the ShowCardsDialog
private Listener<Event> getShowCardsEventListener(final ShowCardsDialog dialog) {
return new Listener<Event>() {
@Override
public void event(Event event) {
@ -2011,7 +2009,8 @@ public final class GamePanel extends javax.swing.JPanel {
String abilityRuleText = null;
if (cardViewPopupMenu instanceof CardView && cardViewPopupMenu.getAbility() != null) {
abilityId = cardViewPopupMenu.getAbility().getId();
if (!cardViewPopupMenu.getAbility().getRules().isEmpty() && !cardViewPopupMenu.getAbility().getRules().equals("")) {
if (!cardViewPopupMenu.getAbility().getRules().isEmpty()
&& !cardViewPopupMenu.getAbility().getRules().get(0).isEmpty()) {
abilityRuleText = cardViewPopupMenu.getAbility().getRules().get(0);
}
}
@ -2038,11 +2037,7 @@ public final class GamePanel extends javax.swing.JPanel {
}
}
public JPopupMenu getTriggerOrderPopupMenu() {
return popupMenuCardPanel;
}
private void createTriggerOrderPupupMenu() {
private void initPopupMenuTriggerOrder() {
ActionListener actionListener = new ActionListener() {
@Override
@ -2051,34 +2046,34 @@ public final class GamePanel extends javax.swing.JPanel {
}
};
popupMenuCardPanel = new JPopupMenu();
popupMenuTriggerOrder = new JPopupMenu();
// String tooltipText = "";
JMenuItem menuItem;
menuItem = new JMenuItem("Put this ability always first on the stack");
menuItem.setActionCommand(CMD_AUTO_ORDER_FIRST);
menuItem.addActionListener(actionListener);
popupMenuCardPanel.add(menuItem);
popupMenuTriggerOrder.add(menuItem);
menuItem = new JMenuItem("Put this ability always last on the stack");
menuItem.setActionCommand(CMD_AUTO_ORDER_LAST);
menuItem.addActionListener(actionListener);
popupMenuCardPanel.add(menuItem);
popupMenuTriggerOrder.add(menuItem);
menuItem = new JMenuItem("Put all abilities with that rule text always first on the stack");
menuItem.setActionCommand(CMD_AUTO_ORDER_NAME_FIRST);
menuItem.addActionListener(actionListener);
popupMenuCardPanel.add(menuItem);
popupMenuTriggerOrder.add(menuItem);
menuItem = new JMenuItem("Put all abilities with that rule text always last on the stack");
menuItem.setActionCommand(CMD_AUTO_ORDER_NAME_LAST);
menuItem.addActionListener(actionListener);
popupMenuCardPanel.add(menuItem);
popupMenuTriggerOrder.add(menuItem);
menuItem = new JMenuItem("Reset all order settings for triggered abilities");
menuItem.setActionCommand(CMD_AUTO_ORDER_RESET_ALL);
menuItem.addActionListener(actionListener);
popupMenuCardPanel.add(menuItem);
popupMenuTriggerOrder.add(menuItem);
}
public String getGameLog() {