GUI: fixed not working single and double clicks on the card's second side (draft, deck editor, see #7472);

This commit is contained in:
Oleg Agafonov 2021-02-03 11:32:15 +04:00
parent 3b7e01d687
commit be77ecea84
4 changed files with 14 additions and 14 deletions

View file

@ -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) {

View file

@ -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());
}

View file

@ -26,7 +26,7 @@ import java.util.UUID;
/**
* Main class for drawing Mage card object.
*
* <p>
* 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() {
if (this.temporary == null) {
// current side: main, return: main
return this.getGameCard();
} else {
// current side: second, return: main
return this.temporary;
}
}
@Override
@ -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());

View file

@ -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<UUID, DraftSession> 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<UUID, UUID> 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();
}