make DefaulActionCallback an enum and remove unused parameter

This commit is contained in:
igoudt 2017-04-26 10:23:49 +02:00
parent ce26e5c8dd
commit 0528555075
3 changed files with 6 additions and 14 deletions

View file

@ -68,7 +68,6 @@ import static mage.client.constants.Constants.*;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener { public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
protected static final DefaultActionCallback callback = DefaultActionCallback.getInstance();
protected Point p; protected Point p;
protected final CardDimensions dimension; protected final CardDimensions dimension;
@ -367,7 +366,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
requestFocusInWindow(); requestFocusInWindow();
callback.mouseClicked(e, gameId, card); DefaultActionCallback.instance.mouseClicked(gameId, card);
} }
@Override @Override

View file

@ -67,7 +67,6 @@ public class MageActionCallback implements ActionCallback {
private Popup tooltipPopup; private Popup tooltipPopup;
private JPopupMenu jPopupMenu; private JPopupMenu jPopupMenu;
private BigCard bigCard; private BigCard bigCard;
protected static final DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
private CardView tooltipCard; private CardView tooltipCard;
private TransferData popupData; private TransferData popupData;
@ -236,14 +235,14 @@ public class MageActionCallback implements ActionCallback {
this.startedDragging = false; this.startedDragging = false;
if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements if (maxXOffset < MIN_X_OFFSET_REQUIRED) { // we need this for protection from small card movements
transferData.component.requestFocusInWindow(); transferData.component.requestFocusInWindow();
defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card);
// Closes popup & enlarged view if a card/Permanent is selected // Closes popup & enlarged view if a card/Permanent is selected
hideTooltipPopup(); hideTooltipPopup();
} }
e.consume(); e.consume();
} else { } else {
transferData.component.requestFocusInWindow(); transferData.component.requestFocusInWindow();
defaultCallback.mouseClicked(e, transferData.gameId, transferData.card); DefaultActionCallback.instance.mouseClicked(transferData.gameId, transferData.card);
// Closes popup & enlarged view if a card/Permanent is selected // Closes popup & enlarged view if a card/Permanent is selected
hideTooltipPopup(); hideTooltipPopup();
e.consume(); e.consume();

View file

@ -7,17 +7,11 @@ import mage.client.SessionHandler;
import mage.view.CardView; import mage.view.CardView;
public class DefaultActionCallback { public enum DefaultActionCallback {
private static final DefaultActionCallback INSTANCE = new DefaultActionCallback(); instance;
private DefaultActionCallback() {} public void mouseClicked(UUID gameId, CardView card) {
public static DefaultActionCallback getInstance() {
return INSTANCE;
}
public void mouseClicked(MouseEvent e, UUID gameId, CardView card) {
if (gameId != null) { if (gameId != null) {
if (card.isAbility() && card.getAbility() != null) { if (card.isAbility() && card.getAbility() != null) {
SessionHandler.sendPlayerUUID(gameId, card.getAbility().getId()); SessionHandler.sendPlayerUUID(gameId, card.getAbility().getId());