From be77ecea849329f71a95eb711e293f0bdece8fb2 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 3 Feb 2021 11:32:15 +0400 Subject: [PATCH] GUI: fixed not working single and double clicks on the card's second side (draft, deck editor, see #7472); --- .../main/java/mage/client/cards/DraftGrid.java | 2 -- .../java/mage/client/draft/DraftPanel.java | 4 ++-- .../java/org/mage/card/arcane/CardPanel.java | 18 ++++++++++++------ .../mage/server/draft/DraftController.java | 4 ---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java index 0e67709188..cd15a455d0 100644 --- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java +++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java @@ -46,13 +46,11 @@ public class DraftGrid extends javax.swing.JPanel implements CardEventProducer { @Override public void event(Event event) { if (event.getEventType() == ClientEventType.CARD_DOUBLE_CLICK) { - logger.info("draft grid: catch double click"); CardView card = (CardView) event.getSource(); cardEventSource.fireEvent(card, ClientEventType.DRAFT_PICK_CARD); hidePopup(); AudioManager.playOnDraftSelect(); } else if (event.getEventType() == ClientEventType.CARD_CLICK) { - logger.info("draft grid: catch single click"); CardView card = (CardView) event.getSource(); MageCard cardPanel = (MageCard) event.getComponent(); if (markedCard != null) { diff --git a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java index 5c377edddd..61df041b6a 100644 --- a/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java +++ b/Mage.Client/src/main/java/mage/client/draft/DraftPanel.java @@ -271,7 +271,7 @@ if (this.pickingCardsListener == null) { this.pickingCardsListener = event -> { if (event.getEventType() == ClientEventType.DRAFT_PICK_CARD) { - logger.info("draft panel: catch pick card"); + // PICK card SimpleCardView source = (SimpleCardView) event.getSource(); DraftPickView view = SessionHandler.sendCardPick(draftId, source.getId(), cardsHidden); if (view != null) { @@ -281,7 +281,7 @@ setMessage("Waiting for other players"); } } else if (event.getEventType() == ClientEventType.DRAFT_MARK_CARD) { - logger.info("draft panel: catch mark card"); + // MARK card SimpleCardView source = (SimpleCardView) event.getSource(); SessionHandler.sendCardMark(draftId, source.getId()); } diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java index 5f478e8ed1..0bc70c2193 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanel.java @@ -26,7 +26,7 @@ import java.util.UUID; /** * Main class for drawing Mage card object. - * + *

* WARNING, if you want to catch mouse events then use cardEventSource and related code. You can't use outer listeners. * * @author arcane, nantuko, noxx, JayDi85 @@ -48,10 +48,11 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen private static final float ROT_CENTER_TO_TOP_CORNER = 1.0295630140987000315797369464196f; private static final float ROT_CENTER_TO_BOTTOM_CORNER = 0.7071067811865475244008443621048f; - private CardView gameCard; + private CardView gameCard; // current card side, can be different for double faces cards (it's a gui sides, not mtg - so mdf cards will have second side too) private CardView updateCard; - // for two faced cards + // if null then gameCard contains main card + // if not null then gameCard contains second side private CardView temporary; private double tappedAngle = 0; @@ -584,7 +585,13 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen @Override public CardView getOriginal() { - return this.getGameCard(); + if (this.temporary == null) { + // current side: main, return: main + return this.getGameCard(); + } else { + // current side: second, return: main + return this.temporary; + } } @Override @@ -646,7 +653,7 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen } } - @Override + @Override public void mouseExited(MouseEvent e) { if (getGameCard().hideInfo()) { return; @@ -836,7 +843,6 @@ public abstract class CardPanel extends MagePermanent implements ComponentListen BufferedImage day = ImageManagerImpl.instance.getDayImage(); dayNightButton.setIcon(new ImageIcon(day)); } - if (!isPermanent) { // use only for custom transformation (when pressing day-night button) copySelections(this.getGameCard().getSecondCardFace(), this.getGameCard()); update(this.getTemporary()); diff --git a/Mage.Server/src/main/java/mage/server/draft/DraftController.java b/Mage.Server/src/main/java/mage/server/draft/DraftController.java index 2bead233f7..18da1ae240 100644 --- a/Mage.Server/src/main/java/mage/server/draft/DraftController.java +++ b/Mage.Server/src/main/java/mage/server/draft/DraftController.java @@ -12,7 +12,6 @@ import mage.server.managers.ManagerFactory; import mage.view.DraftPickView; import org.apache.log4j.Logger; -import java.io.File; import java.util.Map.Entry; import java.util.Optional; import java.util.Set; @@ -26,7 +25,6 @@ import java.util.concurrent.ConcurrentMap; public class DraftController { private static final Logger logger = Logger.getLogger(GameController.class); - public static final String INIT_FILE_PATH = "config" + File.separator + "init.txt"; private final ManagerFactory managerFactory; private final ConcurrentMap draftSessions = new ConcurrentHashMap<>(); @@ -34,7 +32,6 @@ public class DraftController { private final UUID draftSessionId; private final Draft draft; private final UUID tableId; - private final UUID markedCard; public DraftController(ManagerFactory managerFactory, Draft draft, ConcurrentHashMap userPlayerMap, UUID tableId) { this.managerFactory = managerFactory; @@ -42,7 +39,6 @@ public class DraftController { this.userPlayerMap = userPlayerMap; this.draft = draft; this.tableId = tableId; - this.markedCard = null; init(); }