mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 11:02:00 -08:00
* Fixed null pointer exception problems in client.
This commit is contained in:
parent
4d60685c05
commit
3cc157bc2c
2 changed files with 25 additions and 27 deletions
|
|
@ -22,7 +22,6 @@ import javax.swing.JPopupMenu;
|
||||||
import javax.swing.Popup;
|
import javax.swing.Popup;
|
||||||
import javax.swing.PopupFactory;
|
import javax.swing.PopupFactory;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import mage.cards.MageCard;
|
import mage.cards.MageCard;
|
||||||
import mage.cards.action.ActionCallback;
|
import mage.cards.action.ActionCallback;
|
||||||
import mage.cards.action.TransferData;
|
import mage.cards.action.TransferData;
|
||||||
|
|
@ -177,21 +176,21 @@ public class MageActionCallback implements ActionCallback {
|
||||||
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
|
public void showPopup(final Component popupContainer, final Component infoPane) throws InterruptedException {
|
||||||
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (!popupTextWindowOpen
|
if (!popupTextWindowOpen
|
||||||
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
|| enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (data.locationOnScreen == null) {
|
if (data.locationOnScreen == null) {
|
||||||
data.locationOnScreen = data.component.getLocationOnScreen();
|
data.locationOnScreen = data.component.getLocationOnScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
Point location = new Point((int) data.locationOnScreen.getX() + data.popupOffsetX - 40, (int) data.locationOnScreen.getY() + data.popupOffsetY - 40);
|
||||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
|
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, infoPane, parentComponent);
|
||||||
location.translate(-parentPoint.x, -parentPoint.y);
|
location.translate(-parentPoint.x, -parentPoint.y);
|
||||||
popupContainer.setLocation(location);
|
popupContainer.setLocation(location);
|
||||||
popupContainer.setVisible(true);
|
popupContainer.setVisible(true);
|
||||||
c.repaint();
|
c.repaint();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -463,7 +462,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
|
if (enlargedWindowState != EnlargedWindowState.CLOSED) {
|
||||||
// same move direction will be ignored, opposite direction closes the enlarged window
|
// same move direction will be ignored, opposite direction closes the enlarged window
|
||||||
if (new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
|
if (enlargeredViewOpened != null && new Date().getTime() - enlargeredViewOpened.getTime() > 1000) {
|
||||||
// if the opening is back more than 1 seconds close anyway
|
// if the opening is back more than 1 seconds close anyway
|
||||||
hideEnlargedCard();
|
hideEnlargedCard();
|
||||||
handleOverNewView(transferData);
|
handleOverNewView(transferData);
|
||||||
|
|
@ -491,7 +490,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
* Show the big card image on mouse position while hovering over a card
|
* Show the big card image on mouse position while hovering over a card
|
||||||
*
|
*
|
||||||
* @param showAlternative defines if the original image (if it's a copied
|
* @param showAlternative defines if the original image (if it's a copied
|
||||||
* card) or the opposite side of a transformable card will be shown
|
* card) or the opposite side of a transformable card will be shown
|
||||||
*/
|
*/
|
||||||
public void enlargeCard(EnlargeMode showAlternative) {
|
public void enlargeCard(EnlargeMode showAlternative) {
|
||||||
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
|
if (enlargedWindowState == EnlargedWindowState.CLOSED) {
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,6 @@ package mage.view;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.ObjectColor;
|
import mage.ObjectColor;
|
||||||
import mage.abilities.Abilities;
|
import mage.abilities.Abilities;
|
||||||
|
|
@ -66,7 +65,7 @@ public class CardView extends SimpleCardView {
|
||||||
protected List<String> rules;
|
protected List<String> rules;
|
||||||
protected String power;
|
protected String power;
|
||||||
protected String toughness;
|
protected String toughness;
|
||||||
protected String loyalty;
|
protected String loyalty = "";
|
||||||
protected String startingLoyalty;
|
protected String startingLoyalty;
|
||||||
protected EnumSet<CardType> cardTypes;
|
protected EnumSet<CardType> cardTypes;
|
||||||
protected List<String> subTypes;
|
protected List<String> subTypes;
|
||||||
|
|
@ -220,8 +219,8 @@ public class CardView extends SimpleCardView {
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
* @param controlled is the card view created for the card controller - used
|
* @param controlled is the card view created for the card controller - used
|
||||||
* for morph / face down cards to know which player may see information for
|
* for morph / face down cards to know which player may see information for
|
||||||
* the card
|
* the card
|
||||||
*/
|
*/
|
||||||
public CardView(Card card, Game game, boolean controlled) {
|
public CardView(Card card, Game game, boolean controlled) {
|
||||||
this(card, game, controlled, false, false);
|
this(card, game, controlled, false, false);
|
||||||
|
|
@ -247,12 +246,12 @@ public class CardView extends SimpleCardView {
|
||||||
/**
|
/**
|
||||||
* @param card
|
* @param card
|
||||||
* @param game
|
* @param game
|
||||||
* @param controlled is the card view created for the card controller - used
|
* @param controlled is the card view created for the card controller - used
|
||||||
* for morph / face down cards to know which player may see information for
|
* for morph / face down cards to know which player may see information for
|
||||||
* the card
|
* the card
|
||||||
* @param showFaceDownCard if true and the card is not on the battlefield,
|
* @param showFaceDownCard if true and the card is not on the battlefield,
|
||||||
* also a face down card is shown in the view, face down cards will be shown
|
* also a face down card is shown in the view, face down cards will be shown
|
||||||
* @param storeZone if true the card zone will be set in the zone attribute.
|
* @param storeZone if true the card zone will be set in the zone attribute.
|
||||||
*/
|
*/
|
||||||
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard, boolean storeZone) {
|
public CardView(Card card, Game game, boolean controlled, boolean showFaceDownCard, boolean storeZone) {
|
||||||
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null, card.getTokenDescriptor());
|
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode(), game != null, card.getTokenDescriptor());
|
||||||
|
|
@ -967,7 +966,7 @@ public class CardView extends SimpleCardView {
|
||||||
public String getColorText() {
|
public String getColorText() {
|
||||||
|
|
||||||
String color = getColor().getDescription();
|
String color = getColor().getDescription();
|
||||||
return color.substring(0,1).toUpperCase() + color.substring(1);
|
return color.substring(0, 1).toUpperCase() + color.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeText() {
|
public String getTypeText() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue