Displayint card name in choice dialog. Bigger cards for choice many.

This commit is contained in:
magenoxx 2012-06-27 18:07:13 +04:00
parent 8f0159d706
commit 638a6368d2
8 changed files with 51 additions and 31 deletions

View file

@ -8,6 +8,7 @@ resource-path=/home/loki/.wine/drive_c/Program Files/Wizards of the Coast/Magic
#symbols-resource-path=resources/images/symbols/
#resource-path=resources/images/
card-scaling-factor=0.4
card-scaling-factor-enlarged=0.5
hand-scaling-factor=1.3
# parameters for debugging and testing faster

View file

@ -276,7 +276,7 @@ public class BigCard extends JComponent {
}// </editor-fold>//GEN-END:initComponents
public void setDefaultImage() {
bigImage = ImageHelper.getImageFromResources("/empty.png");
bigImage = ImageHelper.getImageFromResources("/empty.png");
bigImage = ImageHelper.getResizedImage((BufferedImage) bigImage, getWidth(), getHeight());
}

View file

@ -499,4 +499,8 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
public boolean isTransformed() {
return false;
}
@Override
public void showCardTitle() {
}
}

View file

@ -28,16 +28,6 @@
package mage.client.cards;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.MouseListener;
import java.util.UUID;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
@ -48,6 +38,11 @@ import mage.view.CardView;
import mage.view.CardsView;
import mage.view.SimpleCardsView;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseListener;
import java.util.UUID;
public class CardArea extends JPanel {
private boolean reloaded = false;
@ -78,7 +73,7 @@ public class CardArea extends JPanel {
if (showCards != null && showCards.size() < 10)
loadCardsFew(showCards, bigCard, gameId, listener);
else
loadCardsMany(showCards, bigCard, gameId, listener);
loadCardsMany(showCards, bigCard, gameId, listener, dimension);
cardArea.revalidate();
this.revalidate();
@ -88,7 +83,7 @@ public class CardArea extends JPanel {
public void loadCardsNarrow(CardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
this.reloaded = true;
cardArea.removeAll();
loadCardsMany(showCards, bigCard, gameId, listener);
loadCardsMany(showCards, bigCard, gameId, listener, dimension);
cardArea.revalidate();
this.revalidate();
@ -99,13 +94,13 @@ public class CardArea extends JPanel {
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle, dimension, listener);
addCard(card, bigCard, gameId, rectangle, dimension, Config.dimensions, listener);
rectangle.translate(Config.dimensions.frameWidth, 0);
}
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * showCards.size(), Config.dimensions.frameHeight));
}
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, MouseListener listener) {
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle, Dimension dimension, CardDimensions cardDimensions, MouseListener listener) {
if (card instanceof AbilityView) {
CardView tmp = ((AbilityView) card).getSourceCard();
tmp.overrideRules(card.getRules());
@ -115,25 +110,27 @@ public class CardArea extends JPanel {
card = tmp;
}
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, gameId, true);
cardImg.setBounds(rectangle);
if (listener != null)
cardImg.addMouseListener(listener);
cardArea.add(cardImg);
cardArea.moveToFront(cardImg);
cardImg.update(card);
cardImg.setCardBounds(rectangle.x, rectangle.y, Config.dimensions.frameWidth, Config.dimensions.frameHeight);
cardImg.setCardBounds(rectangle.x, rectangle.y, cardDimensions.frameWidth, cardDimensions.frameHeight);
cardImg.showCardTitle();
}
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener) {
private void loadCardsMany(CardsView showCards, BigCard bigCard, UUID gameId, MouseListener listener, CardDimensions cardDimensions) {
int columns = 1;
if (showCards != null && showCards.size() > 0) {
Rectangle rectangle = new Rectangle(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
Dimension dimension = new Dimension(Config.dimensions.frameWidth, Config.dimensions.frameHeight);
Rectangle rectangle = new Rectangle(cardDimensions.frameWidth, cardDimensions.frameHeight);
Dimension dimension = new Dimension(cardDimensions.frameWidth, cardDimensions.frameHeight);
int count = 0;
for (CardView card : showCards.values()) {
addCard(card, bigCard, gameId, rectangle, dimension, listener);
addCard(card, bigCard, gameId, rectangle, dimension, cardDimensions, listener);
if (count >= 20) {
rectangle.translate(Config.dimensions.frameWidth, -400);
rectangle.translate(cardDimensions.frameWidth, -400);
columns++;
count = 0;
} else {
@ -142,7 +139,7 @@ public class CardArea extends JPanel {
}
}
}
cardArea.setPreferredSize(new Dimension(Config.dimensions.frameWidth * columns, Config.dimensions.frameHeight + 400));
cardArea.setPreferredSize(new Dimension(cardDimensions.frameWidth * columns, cardDimensions.frameHeight + 400));
}
public boolean isReloaded() {

View file

@ -591,7 +591,7 @@ public class GamePanel extends javax.swing.JPanel {
private ShowCardsDialog showCards(String title, CardsView cards, boolean required) {
ShowCardsDialog showCards = new ShowCardsDialog();
showCards.loadCards(title, cards, bigCard, Config.dimensions, gameId, required);
showCards.loadCards(title, cards, bigCard, Config.dimensionsEnlarged, gameId, required);
return showCards;
}

View file

@ -28,14 +28,14 @@
package mage.client.util;
import mage.cards.CardDimensions;
import org.apache.log4j.Logger;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import mage.cards.CardDimensions;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
@ -48,8 +48,10 @@ public class Config {
public static final String serverName;
public static final int port;
public static final double cardScalingFactor;
public static final double cardScalingFactorEnlarged;
public static final double handScalingFactor;
public static final CardDimensions dimensions;
public static final CardDimensions dimensionsEnlarged;
public static final String defaultGameType;
public static final String defaultDeckPath;
@ -67,6 +69,7 @@ public class Config {
port = Integer.parseInt(p.getProperty("port"));
remoteServer = p.getProperty("remote-server");
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
cardScalingFactorEnlarged = Double.valueOf(p.getProperty("card-scaling-factor-enlarged"));
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = p.getProperty("default-deck-path");
@ -74,6 +77,7 @@ public class Config {
defaultComputerName = p.getProperty("default-computer-name");
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
}
}

View file

@ -94,6 +94,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private boolean animationInProgress = false;
private JButton dayNightButton;
private boolean displayTitleAnyway;
public CardPanel(CardView newGameCard, UUID gameId, final boolean loadImage, ActionCallback callback, final boolean foil) {
this.gameCard = newGameCard;
this.callback = callback;
@ -197,6 +199,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
if (gameCard.isTransformed()) {
toggleTransformed();
}
setText(gameCard);
} catch (Exception e) {
e.printStackTrace();
} catch (Error err) {
@ -207,6 +210,11 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
private void setText(CardView card) {
if (displayTitleAnyway) {
titleText.setText(card.getName());
return;
}
if (hasImage) {
titleText.setText("");
} else {
@ -595,6 +603,12 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
return false;
}
@Override
public void showCardTitle() {
displayTitleAnyway = true;
setText(gameCard);
}
@Override
public void onBeginAnimation() {
animationInProgress = true;

View file

@ -1,13 +1,12 @@
package mage.cards;
import java.awt.Image;
import java.util.UUID;
import javax.swing.JPanel;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
import javax.swing.*;
import java.awt.*;
import java.util.UUID;
public abstract class MageCard extends JPanel {
private static final long serialVersionUID = 6089945326434301879L;
@ -29,4 +28,5 @@ public abstract class MageCard extends JPanel {
abstract public void updateCallback(ActionCallback callback, UUID gameId);
abstract public void toggleTransformed();
abstract public boolean isTransformed();
abstract public void showCardTitle();
}