mirror of
https://github.com/correl/mage.git
synced 2025-04-10 01:01:05 -09:00
* Battlefield layout - Permanents getting creatures and vice versa move now always immediately to the correct area / row on the battlefield (fixes #387).
This commit is contained in:
parent
9ca014b10e
commit
17253fa099
4 changed files with 48 additions and 27 deletions
Mage.Client/src/main/java
mage/client
org/mage/card/arcane
|
@ -34,9 +34,6 @@
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import static mage.constants.Constants.DAMAGE_MAX_LEFT;
|
|
||||||
import static mage.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
|
@ -48,15 +45,15 @@ import java.awt.image.BufferedImage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.PopupFactory;
|
import javax.swing.PopupFactory;
|
||||||
|
|
||||||
import mage.constants.CardType;
|
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
import mage.cards.MagePermanent;
|
import mage.cards.MagePermanent;
|
||||||
|
import mage.cards.Sets;
|
||||||
|
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
|
||||||
|
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
import mage.cards.Sets;
|
import mage.constants.CardType;
|
||||||
import mage.view.CounterView;
|
import mage.view.CounterView;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
|
@ -68,12 +65,16 @@ public class Permanent extends Card {
|
||||||
|
|
||||||
protected PermanentView permanent;
|
protected PermanentView permanent;
|
||||||
|
|
||||||
protected List<MagePermanent> links = new ArrayList<MagePermanent>();
|
protected List<MagePermanent> links = new ArrayList<>();
|
||||||
protected boolean linked;
|
protected boolean linked;
|
||||||
protected BufferedImage tappedImage;
|
protected BufferedImage tappedImage;
|
||||||
protected BufferedImage flippedImage;
|
protected BufferedImage flippedImage;
|
||||||
|
|
||||||
/** Creates new form Permanent */
|
/** Creates new form Permanent
|
||||||
|
* @param permanent
|
||||||
|
* @param bigCard
|
||||||
|
* @param dimensions
|
||||||
|
* @param gameId */
|
||||||
public Permanent(PermanentView permanent, BigCard bigCard, CardDimensions dimensions, UUID gameId) {
|
public Permanent(PermanentView permanent, BigCard bigCard, CardDimensions dimensions, UUID gameId) {
|
||||||
super(permanent, bigCard, dimensions, gameId);
|
super(permanent, bigCard, dimensions, gameId);
|
||||||
this.setSize(this.getPreferredSize());
|
this.setSize(this.getPreferredSize());
|
||||||
|
@ -85,6 +86,7 @@ public class Permanent extends Card {
|
||||||
return permanent.getId();
|
return permanent.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<MagePermanent> getLinks() {
|
public List<MagePermanent> getLinks() {
|
||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
@ -134,9 +136,10 @@ public class Permanent extends Card {
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getRules() {
|
protected List<String> getRules() {
|
||||||
if (permanent.getCounters() != null) {
|
if (permanent.getCounters() != null) {
|
||||||
List<String> rules = new ArrayList<String>(permanent.getRules());
|
List<String> rules = new ArrayList<>(permanent.getRules());
|
||||||
for (CounterView counter: permanent.getCounters())
|
for (CounterView counter: permanent.getCounters()) {
|
||||||
rules.add(counter.getCount() + " x " + counter.getName());
|
rules.add(counter.getCount() + " x " + counter.getName());
|
||||||
|
}
|
||||||
return rules;
|
return rules;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -158,8 +161,12 @@ public class Permanent extends Card {
|
||||||
Rectangle r = this.getBounds();
|
Rectangle r = this.getBounds();
|
||||||
r.x += dx;
|
r.x += dx;
|
||||||
r.y += dy;
|
r.y += dy;
|
||||||
if (r.x < 0) r.x = 0;
|
if (r.x < 0) {
|
||||||
if (r.y < 0) r.y = 0;
|
r.x = 0;
|
||||||
|
}
|
||||||
|
if (r.y < 0) {
|
||||||
|
r.y = 0;
|
||||||
|
}
|
||||||
this.setBounds(r);
|
this.setBounds(r);
|
||||||
this.repaint();
|
this.repaint();
|
||||||
for (MagePermanent perm: links) {
|
for (MagePermanent perm: links) {
|
||||||
|
@ -213,6 +220,7 @@ public class Permanent extends Card {
|
||||||
g.dispose();
|
g.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(PermanentView permanent) {
|
public void update(PermanentView permanent) {
|
||||||
this.permanent = permanent;
|
this.permanent = permanent;
|
||||||
super.update(permanent);
|
super.update(permanent);
|
||||||
|
@ -247,8 +255,9 @@ public class Permanent extends Card {
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered(MouseEvent arg0) {
|
public void mouseEntered(MouseEvent arg0) {
|
||||||
if (!popupShowing) {
|
if (!popupShowing) {
|
||||||
if (popup != null)
|
if (popup != null) {
|
||||||
popup.hide();
|
popup.hide();
|
||||||
|
}
|
||||||
PopupFactory factory = PopupFactory.getSharedInstance();
|
PopupFactory factory = PopupFactory.getSharedInstance();
|
||||||
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth);
|
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()?Config.dimensions.frameHeight:Config.dimensions.frameWidth);
|
||||||
int y = (int) this.getLocationOnScreen().getY() + 40;
|
int y = (int) this.getLocationOnScreen().getY() + 40;
|
||||||
|
@ -262,6 +271,11 @@ public class Permanent extends Card {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PermanentView getOriginalPermanent() {
|
||||||
|
return permanent;
|
||||||
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
public static final String KEY_AVATAR = "selectedId";
|
public static final String KEY_AVATAR = "selectedId";
|
||||||
|
|
||||||
private static final Map<String, String> cache = new HashMap<String, String>();
|
private static final Map<String, String> cache = new HashMap<>();
|
||||||
|
|
||||||
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
|
||||||
|
|
||||||
|
@ -190,8 +190,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
||||||
|
|
||||||
public static final int DEFAULT_AVATAR_ID = 51;
|
public static final int DEFAULT_AVATAR_ID = 51;
|
||||||
private static int selectedAvatarId = DEFAULT_AVATAR_ID;
|
private static int selectedAvatarId = DEFAULT_AVATAR_ID;
|
||||||
private static final Set<Integer> available_avatars = new HashSet<Integer>();
|
private static final Set<Integer> available_avatars = new HashSet<>();
|
||||||
private static final Map<Integer, JPanel> panels = new HashMap<Integer, JPanel>();
|
private static final Map<Integer, JPanel> panels = new HashMap<>();
|
||||||
|
|
||||||
private static final Border GREEN_BORDER = BorderFactory.createLineBorder(Color.GREEN, 3);
|
private static final Border GREEN_BORDER = BorderFactory.createLineBorder(Color.GREEN, 3);
|
||||||
private static final Border BLACK_BORDER = BorderFactory.createLineBorder(Color.BLACK, 3);
|
private static final Border BLACK_BORDER = BorderFactory.createLineBorder(Color.BLACK, 3);
|
||||||
|
|
|
@ -59,6 +59,7 @@ import mage.client.plugins.impl.Plugins;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.audio.AudioManager;
|
import mage.client.util.audio.AudioManager;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
|
import mage.utils.CardUtil;
|
||||||
import mage.view.PermanentView;
|
import mage.view.PermanentView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +118,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
permanents.clear();
|
permanents.clear();
|
||||||
Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
|
// Plugins.getInstance().sortPermanents(uiComponentsList, permanents.values());
|
||||||
this.bigCard = null;
|
this.bigCard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,19 +127,23 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
||||||
|
|
||||||
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
List<PermanentView> permanentsToAdd = new ArrayList<>();
|
||||||
for (PermanentView permanent: battlefield.values()) {
|
for (PermanentView permanent: battlefield.values()) {
|
||||||
if (!permanents.containsKey(permanent.getId())) {
|
MagePermanent oldMagePermanent = permanents.get(permanent.getId());
|
||||||
|
if (oldMagePermanent == null) {
|
||||||
permanentsToAdd.add(permanent);
|
permanentsToAdd.add(permanent);
|
||||||
changed = true;
|
changed = true;
|
||||||
} else {
|
} else {
|
||||||
MagePermanent p = permanents.get(permanent.getId());
|
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
changed = CardUtil.isCreature(oldMagePermanent.getOriginalPermanent()) != CardUtil.isCreature(permanent);
|
||||||
int s2 = p.getLinks().size();
|
if (!changed) {
|
||||||
if (s1 != s2) {
|
int s1 = permanent.getAttachments() == null ? 0 : permanent.getAttachments().size();
|
||||||
changed = true;
|
int s2 = oldMagePermanent.getLinks().size();
|
||||||
|
if (s1 != s2) {
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
permanents.get(permanent.getId()).update(permanent);
|
oldMagePermanent.update(permanent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
||||||
|
|
||||||
// for two faced cards
|
// for two faced cards
|
||||||
public CardView temporary;
|
public CardView temporary;
|
||||||
|
|
||||||
private List<MagePermanent> links = new ArrayList<>();
|
private List<MagePermanent> links = new ArrayList<>();
|
||||||
|
|
||||||
public double tappedAngle = 0;
|
public double tappedAngle = 0;
|
||||||
|
@ -915,6 +914,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PermanentView getOriginalPermanent() {
|
public PermanentView getOriginalPermanent() {
|
||||||
|
if (isPermanent) {
|
||||||
|
return (PermanentView) this.gameCard;
|
||||||
|
}
|
||||||
throw new IllegalStateException("Is not permanent.");
|
throw new IllegalStateException("Is not permanent.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue