mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* UI: fixed graveyard and other cards window size (removed unnecessary scrolls, #5659);
This commit is contained in:
parent
893e9384b1
commit
16efc350b4
4 changed files with 323 additions and 358 deletions
|
@ -1,349 +1,339 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cards.java
|
* Cards.java
|
||||||
*
|
*
|
||||||
* Created on Dec 18, 2009, 10:40:12 AM
|
* Created on Dec 18, 2009, 10:40:12 AM
|
||||||
*/
|
*/
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import java.awt.Color;
|
import mage.cards.MageCard;
|
||||||
import java.awt.Component;
|
import mage.client.plugins.impl.Plugins;
|
||||||
import java.awt.Dimension;
|
import mage.client.util.CardsViewUtil;
|
||||||
import java.util.ArrayList;
|
import mage.client.util.Config;
|
||||||
import java.util.Iterator;
|
import mage.client.util.GUISizeHelper;
|
||||||
import java.util.LinkedHashMap;
|
import mage.view.*;
|
||||||
import java.util.Map;
|
import org.apache.log4j.Logger;
|
||||||
import java.util.Map.Entry;
|
import org.mage.card.arcane.CardPanel;
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
import mage.cards.MageCard;
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
|
||||||
import mage.client.util.CardsViewUtil;
|
|
||||||
import mage.client.util.Config;
|
|
||||||
import mage.client.util.GUISizeHelper;
|
|
||||||
import mage.view.CardView;
|
|
||||||
import mage.view.CardsView;
|
|
||||||
import mage.view.PermanentView;
|
|
||||||
import mage.view.SimpleCardsView;
|
|
||||||
import mage.view.StackAbilityView;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.mage.card.arcane.CardPanel;
|
|
||||||
|
|
||||||
/**
|
import javax.swing.border.Border;
|
||||||
*
|
import javax.swing.border.EmptyBorder;
|
||||||
* @author BetaSteward_at_googlemail.com
|
import java.awt.*;
|
||||||
*/
|
import java.util.*;
|
||||||
public class Cards extends javax.swing.JPanel {
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(Cards.class);
|
/**
|
||||||
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
*/
|
||||||
|
public class Cards extends javax.swing.JPanel {
|
||||||
|
|
||||||
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
|
private static final Logger LOGGER = Logger.getLogger(Cards.class);
|
||||||
private boolean dontDisplayTapped = false;
|
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
|
||||||
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
|
||||||
private String zone;
|
|
||||||
|
|
||||||
private int minOffsetY = 0;
|
private final Map<UUID, MageCard> cards = new LinkedHashMap<>();
|
||||||
|
private boolean dontDisplayTapped = false;
|
||||||
|
private static final int GAP_X = 5; // needed for marking cards with coloured fram (e.g. on hand)
|
||||||
|
private String zone;
|
||||||
|
|
||||||
/**
|
private int minOffsetY = 0;
|
||||||
* Defines whether component should be visible whenever there is no objects
|
|
||||||
* within. True by default.
|
|
||||||
*/
|
|
||||||
private boolean isVisibleIfEmpty = true;
|
|
||||||
|
|
||||||
private Dimension cardDimension;
|
/**
|
||||||
|
* Defines whether component should be visible whenever there is no objects
|
||||||
|
* within. True by default.
|
||||||
|
*/
|
||||||
|
private boolean isVisibleIfEmpty = true;
|
||||||
|
|
||||||
/**
|
private Dimension cardDimension;
|
||||||
* Creates new form Cards
|
|
||||||
*/
|
|
||||||
public Cards() {
|
|
||||||
this(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cards(boolean skipAddingScrollPane) {
|
/**
|
||||||
initComponents(skipAddingScrollPane);
|
* Creates new form Cards
|
||||||
setOpaque(false);
|
*/
|
||||||
//cardArea.setOpaque(false);
|
public Cards() {
|
||||||
setBackgroundColor(new Color(0, 0, 0, 100));
|
this(false);
|
||||||
if (!skipAddingScrollPane) {
|
}
|
||||||
jScrollPane1.setOpaque(false);
|
|
||||||
jScrollPane1.getViewport().setOpaque(false);
|
|
||||||
jScrollPane1.setBorder(EMPTY_BORDER);
|
|
||||||
}
|
|
||||||
if (Plugins.instance.isCardPluginLoaded()) {
|
|
||||||
cardArea.setLayout(null);
|
|
||||||
}
|
|
||||||
cardArea.setBorder(EMPTY_BORDER);
|
|
||||||
setGUISize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanUp() {
|
public Cards(boolean skipAddingScrollPane) {
|
||||||
}
|
initComponents(skipAddingScrollPane);
|
||||||
|
setOpaque(false);
|
||||||
|
//cardArea.setOpaque(false);
|
||||||
|
setBackgroundColor(new Color(0, 0, 0, 100));
|
||||||
|
if (!skipAddingScrollPane) {
|
||||||
|
jScrollPane1.setOpaque(false);
|
||||||
|
jScrollPane1.getViewport().setOpaque(false);
|
||||||
|
jScrollPane1.setBorder(EMPTY_BORDER);
|
||||||
|
}
|
||||||
|
if (Plugins.instance.isCardPluginLoaded()) {
|
||||||
|
cardArea.setLayout(null);
|
||||||
|
}
|
||||||
|
cardArea.setBorder(EMPTY_BORDER);
|
||||||
|
setGUISize();
|
||||||
|
}
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void cleanUp() {
|
||||||
setGUISize();
|
}
|
||||||
for (MageCard mageCard : cards.values()) {
|
|
||||||
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
|
|
||||||
mageCard.updateArtImage();
|
|
||||||
mageCard.doLayout();
|
|
||||||
}
|
|
||||||
layoutCards();
|
|
||||||
sizeCards(cardDimension);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setGUISize() {
|
public void changeGUISize() {
|
||||||
if (jScrollPane1 != null) {
|
setGUISize();
|
||||||
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
for (MageCard mageCard : cards.values()) {
|
||||||
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
mageCard.setCardBounds(0, 0, getCardDimension().width, getCardDimension().height);
|
||||||
}
|
mageCard.updateArtImage();
|
||||||
}
|
mageCard.doLayout();
|
||||||
|
}
|
||||||
|
layoutCards();
|
||||||
|
sizeCards(getCardDimension());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private void setGUISize() {
|
||||||
* Sets components background color
|
if (jScrollPane1 != null) {
|
||||||
*
|
jScrollPane1.getVerticalScrollBar().setPreferredSize(new Dimension(GUISizeHelper.scrollBarSize, 0));
|
||||||
* @param color
|
jScrollPane1.getHorizontalScrollBar().setPreferredSize(new Dimension(0, GUISizeHelper.scrollBarSize));
|
||||||
*/
|
}
|
||||||
public void setBackgroundColor(Color color) {
|
}
|
||||||
setBackground(color);
|
|
||||||
cardArea.setOpaque(true);
|
|
||||||
cardArea.setBackground(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
/**
|
||||||
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
* Sets components background color
|
||||||
}
|
*
|
||||||
|
* @param color
|
||||||
|
*/
|
||||||
|
public void setBackgroundColor(Color color) {
|
||||||
|
setBackground(color);
|
||||||
|
cardArea.setOpaque(true);
|
||||||
|
cardArea.setBackground(color);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public void setVisibleIfEmpty(boolean isVisibleIfEmpty) {
|
||||||
public void setBorder(Border border) {
|
this.isVisibleIfEmpty = isVisibleIfEmpty;
|
||||||
super.setBorder(border);
|
}
|
||||||
if (jScrollPane1 != null) {
|
|
||||||
jScrollPane1.setViewportBorder(border);
|
|
||||||
jScrollPane1.setBorder(border);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
@Override
|
||||||
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true);
|
public void setBorder(Border border) {
|
||||||
}
|
super.setBorder(border);
|
||||||
|
if (jScrollPane1 != null) {
|
||||||
|
jScrollPane1.setViewportBorder(border);
|
||||||
|
jScrollPane1.setBorder(border);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) {
|
public boolean loadCards(SimpleCardsView cardsView, BigCard bigCard, UUID gameId) {
|
||||||
boolean changed = false;
|
return loadCards(CardsViewUtil.convertSimple(cardsView), bigCard, gameId, true);
|
||||||
|
}
|
||||||
|
|
||||||
// remove objects no longer on the stack from display
|
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId, boolean revertOrder) {
|
||||||
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext();) {
|
boolean changed = false;
|
||||||
Entry<UUID, MageCard> entry = i.next();
|
|
||||||
if (!cardsView.containsKey(entry.getKey())) {
|
|
||||||
removeCard(entry.getKey());
|
|
||||||
i.remove();
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213)
|
// remove objects no longer on the stack from display
|
||||||
if (cardsView.isEmpty() && countCards() > 0) {
|
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i.hasNext(); ) {
|
||||||
// problem happens with transformable cards
|
Entry<UUID, MageCard> entry = i.next();
|
||||||
LOGGER.fatal("Card object on the cards panel was not removed");
|
if (!cardsView.containsKey(entry.getKey())) {
|
||||||
for (Component comp : cardArea.getComponents()) {
|
removeCard(entry.getKey());
|
||||||
if (comp instanceof Card) {
|
i.remove();
|
||||||
Card card = (Card) comp;
|
changed = true;
|
||||||
LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
}
|
||||||
} else if (comp instanceof MageCard) {
|
}
|
||||||
MageCard mageCard = (MageCard) comp;
|
|
||||||
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
|
||||||
} else {
|
|
||||||
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
|
||||||
}
|
|
||||||
cardArea.remove(comp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
java.util.List<CardView> orderedList = new ArrayList<>();
|
// Workaround for bug leaving display of objects on the stack (issue #213 https://github.com/magefree/mage/issues/213)
|
||||||
if (revertOrder) {
|
if (cardsView.isEmpty() && countCards() > 0) {
|
||||||
// order objects for display
|
// problem happens with transformable cards
|
||||||
for (CardView card : cardsView.values()) {
|
LOGGER.fatal("Card object on the cards panel was not removed");
|
||||||
orderedList.add(0, card);
|
for (Component comp : cardArea.getComponents()) {
|
||||||
}
|
if (comp instanceof Card) {
|
||||||
} else {
|
Card card = (Card) comp;
|
||||||
orderedList.addAll(cardsView.values());
|
LOGGER.fatal("Card name:" + card.getName() + " type:" + card.getType(null));
|
||||||
}
|
} else if (comp instanceof MageCard) {
|
||||||
|
MageCard mageCard = (MageCard) comp;
|
||||||
|
LOGGER.fatal("MageCard name:" + mageCard.getName() + " toolTiptext:" + mageCard.getToolTipText());
|
||||||
|
} else {
|
||||||
|
LOGGER.fatal("Unknown object:" + comp.getName() + " className:" + comp.getClass().getName());
|
||||||
|
}
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add objects to the panel
|
java.util.List<CardView> orderedList = new ArrayList<>();
|
||||||
for (CardView card : orderedList) {
|
if (revertOrder) {
|
||||||
if (dontDisplayTapped) {
|
// order objects for display
|
||||||
if (card instanceof PermanentView) {
|
for (CardView card : cardsView.values()) {
|
||||||
((PermanentView) card).overrideTapped(false);
|
orderedList.add(0, card);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if (card instanceof StackAbilityView) {
|
orderedList.addAll(cardsView.values());
|
||||||
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
}
|
||||||
tmp.overrideRules(card.getRules());
|
|
||||||
tmp.setIsAbility(true);
|
|
||||||
tmp.overrideTargets(card.getTargets());
|
|
||||||
tmp.overrideId(card.getId());
|
|
||||||
tmp.setAbilityType(card.getAbilityType());
|
|
||||||
card = tmp;
|
|
||||||
} else {
|
|
||||||
card.setAbilityType(null);
|
|
||||||
}
|
|
||||||
if (!cards.containsKey(card.getId())) {
|
|
||||||
addCard(card, bigCard, gameId);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
cards.get(card.getId()).update(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changed) {
|
// add objects to the panel
|
||||||
layoutCards();
|
for (CardView card : orderedList) {
|
||||||
}
|
if (dontDisplayTapped) {
|
||||||
|
if (card instanceof PermanentView) {
|
||||||
|
((PermanentView) card).overrideTapped(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (card instanceof StackAbilityView) {
|
||||||
|
CardView tmp = ((StackAbilityView) card).getSourceCard();
|
||||||
|
tmp.overrideRules(card.getRules());
|
||||||
|
tmp.setIsAbility(true);
|
||||||
|
tmp.overrideTargets(card.getTargets());
|
||||||
|
tmp.overrideId(card.getId());
|
||||||
|
tmp.setAbilityType(card.getAbilityType());
|
||||||
|
card = tmp;
|
||||||
|
} else {
|
||||||
|
card.setAbilityType(null);
|
||||||
|
}
|
||||||
|
if (!cards.containsKey(card.getId())) {
|
||||||
|
addCard(card, bigCard, gameId);
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
cards.get(card.getId()).update(card);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isVisibleIfEmpty) {
|
if (changed) {
|
||||||
cardArea.setVisible(!cards.isEmpty());
|
layoutCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
sizeCards(getCardDimension());
|
if (!isVisibleIfEmpty) {
|
||||||
this.revalidate();
|
cardArea.setVisible(!cards.isEmpty());
|
||||||
this.repaint();
|
}
|
||||||
|
|
||||||
return changed;
|
sizeCards(getCardDimension());
|
||||||
}
|
this.revalidate();
|
||||||
|
this.repaint();
|
||||||
|
|
||||||
public void sizeCards(Dimension cardDimension) {
|
return changed;
|
||||||
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
|
}
|
||||||
cardArea.revalidate();
|
|
||||||
cardArea.repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfCards() {
|
public void sizeCards(Dimension cardDimension) {
|
||||||
return cards.size();
|
cardArea.setPreferredSize(new Dimension((int) ((cards.size()) * (cardDimension.getWidth() + GAP_X)) + 20, (int) (cardDimension.getHeight()) + 20));
|
||||||
}
|
cardArea.revalidate();
|
||||||
|
cardArea.repaint();
|
||||||
|
}
|
||||||
|
|
||||||
private Dimension getCardDimension() {
|
public int getNumberOfCards() {
|
||||||
if (cardDimension == null) {
|
return cards.size();
|
||||||
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
}
|
||||||
}
|
|
||||||
return cardDimension;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCardDimension(Dimension dimension) {
|
private Dimension getCardDimension() {
|
||||||
this.cardDimension = dimension;
|
if (cardDimension == null) {
|
||||||
for (Component component : cardArea.getComponents()) {
|
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
|
||||||
if (component instanceof CardPanel) {
|
}
|
||||||
component.setBounds(0, 0, dimension.width, dimension.height);
|
return cardDimension;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
layoutCards();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
public void setCardDimension(Dimension dimension) {
|
||||||
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
this.cardDimension = dimension;
|
||||||
if (zone != null) {
|
for (Component component : cardArea.getComponents()) {
|
||||||
mageCard.setZone(zone);
|
if (component instanceof CardPanel) {
|
||||||
}
|
component.setBounds(0, 0, dimension.width, dimension.height);
|
||||||
cards.put(card.getId(), mageCard);
|
}
|
||||||
cardArea.add(mageCard);
|
}
|
||||||
definePosition(mageCard);
|
layoutCards();
|
||||||
mageCard.setCardAreaRef(cardArea);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void definePosition(MageCard card) {
|
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
|
||||||
int dx = 0;
|
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true);
|
||||||
for (Component comp : cardArea.getComponents()) {
|
if (zone != null) {
|
||||||
if (!comp.equals(card)) {
|
mageCard.setZone(zone);
|
||||||
dx = Math.max(dx, (int) comp.getLocation().getX());
|
}
|
||||||
}
|
cards.put(card.getId(), mageCard);
|
||||||
}
|
cardArea.add(mageCard);
|
||||||
dx += ((CardPanel) card).getCardWidth() + GAP_X;
|
definePosition(mageCard);
|
||||||
card.setLocation(dx, (int) card.getLocation().getY());
|
mageCard.setCardAreaRef(cardArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeCard(UUID cardId) {
|
private void definePosition(MageCard card) {
|
||||||
for (Component comp : cardArea.getComponents()) {
|
int dx = 0;
|
||||||
if (comp instanceof Card) {
|
for (Component comp : cardArea.getComponents()) {
|
||||||
if (((Card) comp).getCardId().equals(cardId)) {
|
if (!comp.equals(card)) {
|
||||||
cardArea.remove(comp);
|
dx = Math.max(dx, (int) comp.getLocation().getX());
|
||||||
}
|
}
|
||||||
} else if (comp instanceof MageCard) {
|
}
|
||||||
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
dx += ((CardPanel) card).getCardWidth() + GAP_X;
|
||||||
cardArea.remove(comp);
|
card.setLocation(dx, (int) card.getLocation().getY());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int countCards() {
|
private void removeCard(UUID cardId) {
|
||||||
return cardArea.getComponentCount();
|
for (Component comp : cardArea.getComponents()) {
|
||||||
}
|
if (comp instanceof Card) {
|
||||||
|
if (((Card) comp).getCardId().equals(cardId)) {
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
} else if (comp instanceof MageCard) {
|
||||||
|
if (((MageCard) comp).getOriginal().getId().equals(cardId)) {
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private int countCards() {
|
||||||
* This method is called from within the constructor to initialize the form.
|
return cardArea.getComponentCount();
|
||||||
* WARNING: Do NOT modify this code. The content of this method is always
|
}
|
||||||
* regenerated by the Form Editor.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
|
||||||
private void initComponents(boolean skipAddingScrollPane) {
|
|
||||||
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
|
|
||||||
setLayout(new java.awt.BorderLayout());
|
|
||||||
|
|
||||||
cardArea = new javax.swing.JPanel();
|
/**
|
||||||
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents(boolean skipAddingScrollPane) {
|
||||||
|
setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0, 0)));
|
||||||
|
setLayout(new java.awt.BorderLayout());
|
||||||
|
|
||||||
if (skipAddingScrollPane) {
|
cardArea = new javax.swing.JPanel();
|
||||||
add(cardArea, java.awt.BorderLayout.CENTER);
|
cardArea.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));
|
||||||
} else{
|
|
||||||
jScrollPane1 = new javax.swing.JScrollPane();
|
|
||||||
jScrollPane1.setViewportView(cardArea);
|
|
||||||
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
|
||||||
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
|
||||||
}
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
if (skipAddingScrollPane) {
|
||||||
private javax.swing.JPanel cardArea;
|
add(cardArea, java.awt.BorderLayout.CENTER);
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
} else {
|
||||||
// End of variables declaration//GEN-END:variables
|
jScrollPane1 = new javax.swing.JScrollPane();
|
||||||
|
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
|
||||||
|
jScrollPane1.setViewportView(cardArea);
|
||||||
|
add(jScrollPane1, java.awt.BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
public void setDontDisplayTapped(boolean dontDisplayTapped) {
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
this.dontDisplayTapped = dontDisplayTapped;
|
private javax.swing.JPanel cardArea;
|
||||||
}
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
public void setHScrollSpeed(int unitIncrement) {
|
public void setDontDisplayTapped(boolean dontDisplayTapped) {
|
||||||
if (jScrollPane1 != null) {
|
this.dontDisplayTapped = dontDisplayTapped;
|
||||||
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVScrollSpeed(int unitIncrement) {
|
public void setHScrollSpeed(int unitIncrement) {
|
||||||
if (jScrollPane1 != null) {
|
if (jScrollPane1 != null) {
|
||||||
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
jScrollPane1.getHorizontalScrollBar().setUnitIncrement(unitIncrement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void layoutCards() {
|
public void setVScrollSpeed(int unitIncrement) {
|
||||||
java.util.List<CardPanel> cardsToLayout = new ArrayList<>();
|
if (jScrollPane1 != null) {
|
||||||
// get all the card panels
|
jScrollPane1.getVerticalScrollBar().setUnitIncrement(unitIncrement);
|
||||||
for (Component component : cardArea.getComponents()) {
|
}
|
||||||
if (component instanceof CardPanel) {
|
}
|
||||||
cardsToLayout.add((CardPanel) component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// sort the cards
|
|
||||||
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
|
|
||||||
// relocate the cards
|
|
||||||
int dx = 0;
|
|
||||||
for (Component component : cardsToLayout) {
|
|
||||||
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
|
|
||||||
dx += ((CardPanel) component).getCardWidth() + GAP_X;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZone(String zone) {
|
private void layoutCards() {
|
||||||
this.zone = zone;
|
java.util.List<CardPanel> cardsToLayout = new ArrayList<>();
|
||||||
}
|
// get all the card panels
|
||||||
|
for (Component component : cardArea.getComponents()) {
|
||||||
|
if (component instanceof CardPanel) {
|
||||||
|
cardsToLayout.add((CardPanel) component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// sort the cards
|
||||||
|
cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
|
||||||
|
// relocate the cards
|
||||||
|
int dx = 0;
|
||||||
|
for (Component component : cardsToLayout) {
|
||||||
|
component.setLocation(dx, Math.max(component.getLocation().y, minOffsetY));
|
||||||
|
dx += ((CardPanel) component).getCardWidth() + GAP_X;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setMinOffsetY(int minOffsetY) {
|
public void setZone(String zone) {
|
||||||
this.minOffsetY = minOffsetY;
|
this.zone = zone;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void setMinOffsetY(int minOffsetY) {
|
||||||
|
this.minOffsetY = minOffsetY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<Property name="iconifiable" type="boolean" value="true"/>
|
<Property name="iconifiable" type="boolean" value="true"/>
|
||||||
<Property name="resizable" type="boolean" value="true"/>
|
<Property name="resizable" type="boolean" value="true"/>
|
||||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||||
<Connection code="new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3),
 (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2))" type="code"/>
|
<Connection code="new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.4),
 (int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.4))" type="code"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<SyntheticProperties>
|
<SyntheticProperties>
|
||||||
|
@ -21,31 +21,20 @@
|
||||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,0,0,0,1,112"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
|
|
||||||
<Layout>
|
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||||
<DimensionLayout dim="0">
|
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<Group type="102" alignment="0" attributes="0">
|
|
||||||
<Component id="cards" max="32767" attributes="0"/>
|
|
||||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
</DimensionLayout>
|
|
||||||
<DimensionLayout dim="1">
|
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
|
||||||
<Group type="102" alignment="0" attributes="0">
|
|
||||||
<Component id="cards" max="32767" attributes="0"/>
|
|
||||||
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
|
||||||
</Group>
|
|
||||||
</DimensionLayout>
|
|
||||||
</Layout>
|
|
||||||
<SubComponents>
|
<SubComponents>
|
||||||
<Component class="mage.client.cards.Cards" name="cards">
|
<Component class="mage.client.cards.Cards" name="cards">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CardInfoWindowDialog_cards"/>
|
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="CardInfoWindowDialog_cards"/>
|
||||||
</AuxValues>
|
</AuxValues>
|
||||||
|
<Constraints>
|
||||||
|
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||||
|
<BorderConstraints direction="Center"/>
|
||||||
|
</Constraint>
|
||||||
|
</Constraints>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
@ -1,23 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* CardInfoWindowDialog.java
|
|
||||||
*
|
|
||||||
* Created on Feb 1, 2010, 3:00:35 PM
|
|
||||||
*/
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.event.InternalFrameAdapter;
|
|
||||||
import javax.swing.event.InternalFrameEvent;
|
|
||||||
|
|
||||||
import mage.client.cards.BigCard;
|
import mage.client.cards.BigCard;
|
||||||
import mage.client.util.GUISizeHelper;
|
import mage.client.util.GUISizeHelper;
|
||||||
import mage.client.util.ImageHelper;
|
import mage.client.util.ImageHelper;
|
||||||
|
@ -31,8 +13,17 @@ import mage.view.SimpleCardsView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
import org.mage.plugins.card.utils.impl.ImageManagerImpl;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.InternalFrameAdapter;
|
||||||
|
import javax.swing.event.InternalFrameEvent;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||||
*/
|
*/
|
||||||
public class CardInfoWindowDialog extends MageDialog {
|
public class CardInfoWindowDialog extends MageDialog {
|
||||||
|
|
||||||
|
@ -151,6 +142,7 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.show();
|
super.show();
|
||||||
if (positioned) { // check if in frame rectangle
|
if (positioned) { // check if in frame rectangle
|
||||||
showAndPositionWindow();
|
showAndPositionWindow();
|
||||||
|
@ -201,23 +193,10 @@ public class CardInfoWindowDialog extends MageDialog {
|
||||||
|
|
||||||
setIconifiable(true);
|
setIconifiable(true);
|
||||||
setResizable(true);
|
setResizable(true);
|
||||||
setPreferredSize(new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.3),
|
setPreferredSize(new Dimension((int) Math.round(GUISizeHelper.otherZonesCardDimension.width * 1.4),
|
||||||
(int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.2)));
|
(int) Math.round(GUISizeHelper.otherZonesCardDimension.height * 1.4)));
|
||||||
|
getContentPane().setLayout(new java.awt.BorderLayout());
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
getContentPane().add(cards, java.awt.BorderLayout.CENTER);
|
||||||
getContentPane().setLayout(layout);
|
|
||||||
layout.setHorizontalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGap(0, 0, 0))
|
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addGroup(layout.createSequentialGroup()
|
|
||||||
.addComponent(cards, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
.addGap(0, 0, 0))
|
|
||||||
);
|
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
|
@ -133,6 +133,7 @@ class UrzaAcademyHeadmasterRandomEffect extends OneShotEffect {
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
switch (selection) {
|
switch (selection) {
|
||||||
|
|
||||||
// ABILITY +1
|
// ABILITY +1
|
||||||
case 1:
|
case 1:
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
@ -228,8 +229,10 @@ class UrzaAcademyHeadmasterRandomEffect extends OneShotEffect {
|
||||||
case 20: // (altered) XENAGOS 1
|
case 20: // (altered) XENAGOS 1
|
||||||
sb.append("Add X mana in any combination of colors to your mana pool, where X is the number of creatures you control.");
|
sb.append("Add X mana in any combination of colors to your mana pool, where X is the number of creatures you control.");
|
||||||
effects.add(new UrzaAcademyHeadmasterManaEffect());
|
effects.add(new UrzaAcademyHeadmasterManaEffect());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ABILITY -1
|
// ABILITY -1
|
||||||
case 2:
|
case 2:
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
@ -325,8 +328,10 @@ class UrzaAcademyHeadmasterRandomEffect extends OneShotEffect {
|
||||||
sb.append("Draw four cards and discard two cards.");
|
sb.append("Draw four cards and discard two cards.");
|
||||||
effects.add(new DrawCardSourceControllerEffect(4));
|
effects.add(new DrawCardSourceControllerEffect(4));
|
||||||
effects.add(new DiscardControllerEffect(2));
|
effects.add(new DiscardControllerEffect(2));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ABILITY -6
|
// ABILITY -6
|
||||||
case 3:
|
case 3:
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
@ -421,7 +426,9 @@ class UrzaAcademyHeadmasterRandomEffect extends OneShotEffect {
|
||||||
case 20: // UGIN 3
|
case 20: // UGIN 3
|
||||||
sb.append("You gain 7 life, draw seven cards, then put up to seven permanent cards from your hand onto the battlefield.");
|
sb.append("You gain 7 life, draw seven cards, then put up to seven permanent cards from your hand onto the battlefield.");
|
||||||
effects.add(new mage.cards.u.UginTheSpiritDragonEffect3());
|
effects.add(new mage.cards.u.UginTheSpiritDragonEffect3());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
game.informPlayers(sb.toString());
|
game.informPlayers(sb.toString());
|
||||||
|
|
Loading…
Reference in a new issue