UI: improved card render test dialog (added render mode and size choose);

This commit is contained in:
Oleg Agafonov 2019-05-06 23:16:58 +04:00
parent 998044068d
commit c45f64bdec
18 changed files with 1710 additions and 1547 deletions

View file

@ -1,6 +1,7 @@
package mage.client.cards; package mage.client.cards;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.ClientEventType; import mage.client.util.ClientEventType;
import mage.client.util.Event; import mage.client.util.Event;
@ -30,6 +31,9 @@ public class CardArea extends JPanel implements MouseListener {
private Dimension cardDimension; private Dimension cardDimension;
private int verticalCardOffset; private int verticalCardOffset;
private int customRenderMode = -1; // custom render mode tests
private Dimension customCardSize = null; // custom size for tests
/** /**
* Create the panel. * Create the panel.
*/ */
@ -62,8 +66,12 @@ public class CardArea extends JPanel implements MouseListener {
} }
private void setGUISize() { private void setGUISize() {
if (customCardSize != null) {
setCardDimension(customCardSize, GUISizeHelper.otherZonesCardVerticalOffset);
} else {
setCardDimension(GUISizeHelper.otherZonesCardDimension, GUISizeHelper.otherZonesCardVerticalOffset); setCardDimension(GUISizeHelper.otherZonesCardDimension, GUISizeHelper.otherZonesCardVerticalOffset);
} }
}
public void setCardDimension(Dimension dimension, int verticalCardOffset) { public void setCardDimension(Dimension dimension, int verticalCardOffset) {
this.cardDimension = dimension; this.cardDimension = dimension;
@ -129,7 +137,8 @@ public class CardArea extends JPanel implements MouseListener {
tmp.setAbility(card); // cross-reference, required for ability picker tmp.setAbility(card); // cross-reference, required for ability picker
card = tmp; card = tmp;
} }
MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true); MageCard cardPanel = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true,
customRenderMode != -1 ? customRenderMode : PreferencesDialog.getRenderMode());
cardPanel.setBounds(rectangle); cardPanel.setBounds(rectangle);
cardPanel.addMouseListener(this); cardPanel.addMouseListener(this);
@ -265,6 +274,14 @@ public class CardArea extends JPanel implements MouseListener {
} }
} }
public void setCustomRenderMode(int customRenderMode) {
this.customRenderMode = customRenderMode;
}
public void setCustomCardSize(Dimension customCardSize) {
this.customCardSize = customCardSize;
}
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
} }

View file

@ -2,6 +2,7 @@ package mage.client.cards;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.MagePane; import mage.client.MagePane;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.view.CardView; import mage.view.CardView;
@ -72,7 +73,7 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
currentCards = new ArrayList<>(source.dragCardList()); currentCards = new ArrayList<>(source.dragCardList());
// Make a view for the first one and add it to us // Make a view for the first one and add it to us
dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false); dragView = Plugins.instance.getMageCard(currentCards.get(0), null, new Dimension(100, 140), null, true, false, PreferencesDialog.getRenderMode());
for (MouseListener l : dragView.getMouseListeners()) { for (MouseListener l : dragView.getMouseListeners()) {
dragView.removeMouseListener(l); dragView.removeMouseListener(l);
} }
@ -164,13 +165,22 @@ public class CardDraggerGlassPane implements MouseListener, MouseMotionListener
} }
@Override @Override
public void mouseClicked(MouseEvent e) {} public void mouseClicked(MouseEvent e) {
@Override }
public void mousePressed(MouseEvent e) {}
@Override @Override
public void mouseEntered(MouseEvent e) {} public void mousePressed(MouseEvent e) {
@Override }
public void mouseExited(MouseEvent e) {}
@Override @Override
public void mouseMoved(MouseEvent e) {} public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseMoved(MouseEvent e) {
}
} }

View file

@ -9,6 +9,7 @@ package mage.client.cards;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.deckeditor.SortSetting; import mage.client.deckeditor.SortSetting;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.ClientEventType; import mage.client.util.ClientEventType;
import mage.client.util.Event; import mage.client.util.Event;
@ -22,12 +23,11 @@ import org.mage.card.arcane.CardPanel;
import java.awt.*; import java.awt.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid { public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
@ -101,7 +101,7 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
} }
private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) { private void addCard(CardView card, BigCard bigCard, UUID gameId, boolean drawImage) {
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, drawImage, true, PreferencesDialog.getRenderMode());
cards.put(card.getId(), cardImg); cards.put(card.getId(), cardImg);
cardImg.addMouseListener(this); cardImg.addMouseListener(this);
add(cardImg); add(cardImg);

View file

@ -8,6 +8,7 @@
package mage.client.cards; package mage.client.cards;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil; import mage.client.util.CardsViewUtil;
import mage.client.util.Config; import mage.client.util.Config;
@ -227,7 +228,7 @@
} }
private void addCard(CardView card, BigCard bigCard, UUID gameId) { private void addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true); MageCard mageCard = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
if (zone != null) { if (zone != null) {
mageCard.setZone(zone); mageCard.setZone(zone);
} }

View file

@ -15,8 +15,8 @@ import mage.client.deckeditor.table.TableModel;
import mage.client.deckeditor.table.UpdateCountsCallback; import mage.client.deckeditor.table.UpdateCountsCallback;
import mage.client.dialog.PreferencesDialog; import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.*;
import mage.client.util.Event; import mage.client.util.Event;
import mage.client.util.*;
import mage.client.util.gui.TableSpinnerEditor; import mage.client.util.gui.TableSpinnerEditor;
import mage.view.CardView; import mage.view.CardView;
import mage.view.CardsView; import mage.view.CardsView;
@ -33,8 +33,8 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
import java.beans.Beans; import java.beans.Beans;
import java.util.*;
import java.util.List; import java.util.List;
import java.util.*;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -389,7 +389,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
} }
private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) { private MageCard addCard(CardView card, BigCard bigCard, UUID gameId) {
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true, PreferencesDialog.getRenderMode());
cardArea.add(cardImg); cardArea.add(cardImg);
cardImg.update(card); cardImg.update(card);
cardImg.addMouseListener(this); cardImg.addMouseListener(this);

View file

@ -10,6 +10,7 @@ package mage.client.cards;
import mage.cards.CardDimensions; import mage.cards.CardDimensions;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.CardViewRarityComparator; import mage.client.util.CardViewRarityComparator;
import mage.client.util.ClientEventType; import mage.client.util.ClientEventType;
@ -28,7 +29,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class DraftGrid extends javax.swing.JPanel implements MouseListener { public class DraftGrid extends javax.swing.JPanel implements MouseListener {
@ -40,7 +40,9 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
protected MageCard markedCard; protected MageCard markedCard;
protected boolean emptyGrid; protected boolean emptyGrid;
/** Creates new form DraftGrid */ /**
* Creates new form DraftGrid
*/
public DraftGrid() { public DraftGrid() {
initComponents(); initComponents();
markedCard = null; markedCard = null;
@ -101,7 +103,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
List<CardView> sortedCards = new ArrayList<>(booster.values()); List<CardView> sortedCards = new ArrayList<>(booster.values());
sortedCards.sort(new CardViewRarityComparator()); sortedCards.sort(new CardViewRarityComparator());
for (CardView card : sortedCards) { for (CardView card : sortedCards) {
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, dimension, null, true, true, PreferencesDialog.getRenderMode());
cardImg.addMouseListener(this); cardImg.addMouseListener(this);
add(cardImg); add(cardImg);
cardImg.update(card); cardImg.update(card);
@ -133,7 +135,8 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
Plugins.instance.getActionCallback().mouseExited(null, null); Plugins.instance.getActionCallback().mouseExited(null, null);
} }
/** 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
* always regenerated by the Form Editor. * always regenerated by the Form Editor.

View file

@ -1,16 +1,5 @@
package mage.client.cards; package mage.client.cards;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.swing.*;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo; import mage.cards.decks.DeckCardInfo;
@ -31,6 +20,18 @@ import mage.view.CardsView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.card.arcane.CardRenderer; import org.mage.card.arcane.CardRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* Created by StravantUser on 2016-09-20. * Created by StravantUser on 2016-09-20.
*/ */
@ -456,6 +457,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
--count; --count;
} }
} }
private int count = 0; private int count = 0;
} }
@ -659,7 +661,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
@Override @Override
public String toString() { public String toString() {
return '(' + sort.toString() + ',' + Boolean.toString(separateCreatures) + ',' + Integer.toString(cardSize) + ')'; return '(' + sort.toString() + ',' + separateCreatures + ',' + cardSize + ')';
} }
} }
@ -1767,7 +1769,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
updateCounts(); updateCounts();
// Create the card view // Create the card view
final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true); final MageCard cardPanel = Plugins.instance.getMageCard(card, lastBigCard, new Dimension(getCardWidth(), getCardHeight()), null, true, true, PreferencesDialog.getRenderMode());
cardPanel.update(card); cardPanel.update(card);
cardPanel.setCardCaptionTopOffset(0); cardPanel.setCardCaptionTopOffset(0);

View file

@ -8,6 +8,7 @@ import mage.client.components.ext.dlg.DialogContainer;
import mage.client.components.ext.dlg.DialogManager; import mage.client.components.ext.dlg.DialogManager;
import mage.client.components.ext.dlg.DlgParams; import mage.client.components.ext.dlg.DlgParams;
import mage.client.components.ext.dlg.IDialogPanel; import mage.client.components.ext.dlg.IDialogPanel;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.Command; import mage.client.util.Command;
import mage.client.util.SettingsManager; import mage.client.util.SettingsManager;
@ -162,7 +163,7 @@ public class ChoiceDialog extends IDialogPanel {
} }
CardView card = cardList.get(i); CardView card = cardList.get(i);
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
cardImg.setLocation(dx, dy + j * (height + 30)); cardImg.setLocation(dx, dy + j * (height + 30));
add(cardImg); add(cardImg);

View file

@ -7,6 +7,7 @@ import mage.client.components.ext.dlg.DialogContainer;
import mage.client.components.ext.dlg.DialogManager; import mage.client.components.ext.dlg.DialogManager;
import mage.client.components.ext.dlg.DlgParams; import mage.client.components.ext.dlg.DlgParams;
import mage.client.components.ext.dlg.IDialogPanel; import mage.client.components.ext.dlg.IDialogPanel;
import mage.client.dialog.PreferencesDialog;
import mage.client.game.FeedbackPanel; import mage.client.game.FeedbackPanel;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.Command; import mage.client.util.Command;
@ -119,7 +120,7 @@ public class StackDialog extends IDialogPanel {
card = tmp; card = tmp;
} }
MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true); MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, getCardDimension(), gameId, true, true, PreferencesDialog.getRenderMode());
//cardImg.setBorder(BorderFactory.createLineBorder(Color.red)); //cardImg.setBorder(BorderFactory.createLineBorder(Color.red));
cardImg.setLocation(dx, dy); cardImg.setLocation(dx, dy);
@ -147,6 +148,7 @@ public class StackDialog extends IDialogPanel {
//GameManager.getInputControl().getInput().selectButtonOK(); //GameManager.getInputControl().getInput().selectButtonOK();
StackDialog.this.feedbackPanel.doClick(); StackDialog.this.feedbackPanel.doClick();
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
}); });
} }
@ -168,6 +170,7 @@ public class StackDialog extends IDialogPanel {
public void execute() { public void execute() {
DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent()); DialogManager.getManager(gameId).fadeOut((DialogContainer) getParent());
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
}); });
} }

View file

@ -8,6 +8,7 @@ import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.components.HoverButton; import mage.client.components.HoverButton;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
@ -406,7 +407,7 @@ public class MageBook extends JComponent {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()); cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true); final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true, PreferencesDialog.getRenderMode());
cardImg.setBounds(rectangle); cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(card); cardImg.update(card);
@ -447,7 +448,7 @@ public class MageBook extends JComponent {
newToken.removeSummoningSickness(); newToken.removeSummoningSickness();
PermanentView theToken = new PermanentView(newToken, null, null, null); PermanentView theToken = new PermanentView(newToken, null, null, null);
theToken.setInViewerOnly(true); theToken.setInViewerOnly(true);
final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true); final MageCard cardImg = Plugins.instance.getMagePermanent(theToken, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode());
cardImg.setBounds(rectangle); cardImg.setBounds(rectangle);
jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10); jLayeredPane.add(cardImg, JLayeredPane.DEFAULT_LAYER, 10);
cardImg.update(theToken); cardImg.update(theToken);

View file

@ -3714,6 +3714,14 @@ public class PreferencesDialog extends javax.swing.JDialog {
} }
} }
public static int getRenderMode() {
if (getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false").equals("false")) {
return 0; // mtgo
} else {
return 1; // image
}
}
private static int getDefaultControlMofier(String key) { private static int getDefaultControlMofier(String key) {
switch (key) { switch (key) {
default: default:

View file

@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties> <SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties> </SyntheticProperties>
<AuxValues> <AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
@ -30,9 +26,17 @@
<EmptySpace min="0" pref="578" max="32767" attributes="0"/> <EmptySpace min="0" pref="578" max="32767" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/> <Component id="buttonCancel" min="-2" pref="100" max="-2" attributes="0"/>
</Group> </Group>
<Component id="cardArea1" alignment="0" max="32767" attributes="0"/> <Component id="cardsPanel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/> <Component id="buttonReloadCards" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="labelRenderMode" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboRenderMode" min="-2" pref="131" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="labelSize" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="sliderSize" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -44,9 +48,17 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0">
<EmptySpace pref="88" max="32767" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cardArea1" min="-2" pref="327" max="-2" attributes="0"/> <Component id="buttonReloadCards" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelRenderMode" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboRenderMode" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelSize" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="sliderSize" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="cardsPanel" pref="421" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/> <Component id="buttonCancel" min="-2" pref="30" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -63,15 +75,49 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="mage.client.cards.CardArea" name="cardArea1"> <Component class="mage.client.cards.CardArea" name="cardsPanel">
</Component> </Component>
<Component class="javax.swing.JButton" name="jButton1"> <Component class="javax.swing.JButton" name="buttonReloadCards">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="jButton1"/> <Property name="text" type="java.lang.String" value="Reload cards"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReloadCardsActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="labelRenderMode">
<Properties>
<Property name="text" type="java.lang.String" value="Render mode:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboRenderMode">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="2">
<StringItem index="0" value="MTGO"/>
<StringItem index="1" value="Image"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="comboRenderModeItemStateChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JSlider" name="sliderSize">
<Properties>
<Property name="value" type="int" value="25"/>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="sliderSizeStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="labelSize">
<Properties>
<Property name="text" type="java.lang.String" value="Card size:"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -11,6 +11,7 @@ import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository; import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.util.GUISizeHelper;
import mage.constants.MultiplayerAttackOption; import mage.constants.MultiplayerAttackOption;
import mage.constants.RangeOfInfluence; import mage.constants.RangeOfInfluence;
import mage.game.Game; import mage.game.Game;
@ -26,6 +27,7 @@ import mage.view.PermanentView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.UUID; import java.util.UUID;
@ -35,6 +37,7 @@ import java.util.UUID;
public class TestCardRenderDialog extends MageDialog { public class TestCardRenderDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class); private static final Logger logger = Logger.getLogger(TestCardRenderDialog.class);
float cardSizeMod = 1.0f;
public TestCardRenderDialog() { public TestCardRenderDialog() {
initComponents(); initComponents();
@ -43,6 +46,7 @@ public class TestCardRenderDialog extends MageDialog {
public void showDialog() { public void showDialog() {
this.setModal(false); this.setModal(false);
getRootPane().setDefaultButton(buttonCancel); getRootPane().setDefaultButton(buttonCancel);
reloadCards();
// windows settings // windows settings
MageFrame.getDesktop().remove(this); MageFrame.getDesktop().remove(this);
@ -74,77 +78,17 @@ public class TestCardRenderDialog extends MageDialog {
if (damage > 0) { if (damage > 0) {
perm.damage(damage, null, game); perm.damage(damage, null, game);
} }
perm.removeSummoningSickness();
PermanentView cardView = new PermanentView(perm, card, controllerId, game); PermanentView cardView = new PermanentView(perm, card, controllerId, game);
cardView.setInViewerOnly(true); cardView.setInViewerOnly(true);
return cardView; return cardView;
} }
/** private void reloadCards() {
* This method is called from within the constructor to initialize the form. cardsPanel.cleanUp();
* WARNING: Do NOT modify this code. The content of this method is always cardsPanel.setCustomRenderMode(comboRenderMode.getSelectedIndex());
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonCancel = new javax.swing.JButton();
cardArea1 = new mage.client.cards.CardArea();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 578, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cardArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 88, Short.MAX_VALUE)
.addComponent(cardArea1, javax.swing.GroupLayout.PREFERRED_SIZE, 327, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20); Game game = new TestGame(MultiplayerAttackOption.MULTIPLE, RangeOfInfluence.ALL, new VancouverMulligan(0), 20);
Player player = new StubPlayer("player1", RangeOfInfluence.ALL); Player player = new StubPlayer("player1", RangeOfInfluence.ALL);
Deck deck = new Deck(); Deck deck = new Deck();
@ -160,13 +104,147 @@ public class TestCardRenderDialog extends MageDialog {
card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows card = createCard(game, player.getId(), "RNA", "14", 1); // Knight of Sorrows
view.put(card.getId(), card); view.put(card.getId(), card);
cardArea1.loadCards(view, big, null); cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
}//GEN-LAST:event_jButton1ActionPerformed cardsPanel.changeGUISize();
cardsPanel.loadCards(view, big, null);
}
private int getCardWidth() {
if (GUISizeHelper.editorCardDimension == null) {
return 200;
}
return (int) (GUISizeHelper.editorCardDimension.width * cardSizeMod);
}
private int getCardHeight() {
return (int) (1.4 * getCardWidth());
}
/**
* 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() {
buttonCancel = new javax.swing.JButton();
cardsPanel = new mage.client.cards.CardArea();
buttonReloadCards = new javax.swing.JButton();
labelRenderMode = new javax.swing.JLabel();
comboRenderMode = new javax.swing.JComboBox<>();
sliderSize = new javax.swing.JSlider();
labelSize = new javax.swing.JLabel();
buttonCancel.setText("Close");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
buttonReloadCards.setText("Reload cards");
buttonReloadCards.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonReloadCardsActionPerformed(evt);
}
});
labelRenderMode.setText("Render mode:");
comboRenderMode.setModel(new javax.swing.DefaultComboBoxModel<>(new String[]{"MTGO", "Image"}));
comboRenderMode.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
comboRenderModeItemStateChanged(evt);
}
});
sliderSize.setValue(25);
sliderSize.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sliderSizeStateChanged(evt);
}
});
labelSize.setText("Card size:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 578, Short.MAX_VALUE)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(buttonReloadCards)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelRenderMode)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(labelSize)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonReloadCards)
.addComponent(labelRenderMode)
.addComponent(comboRenderMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelSize))
.addComponent(sliderSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cardsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
onCancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonReloadCardsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReloadCardsActionPerformed
reloadCards();
}//GEN-LAST:event_buttonReloadCardsActionPerformed
private void comboRenderModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboRenderModeItemStateChanged
reloadCards();
}//GEN-LAST:event_comboRenderModeItemStateChanged
private void sliderSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderSizeStateChanged
// from DragCardGrid
// Fraction in [-1, 1]
float sliderFrac = ((float) (sliderSize.getValue() - 50)) / 50;
// Convert to frac in [0.5, 2.0] exponentially
cardSizeMod = (float) Math.pow(2, sliderFrac);
reloadCards();
}//GEN-LAST:event_sliderSizeStateChanged
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel; private javax.swing.JButton buttonCancel;
private mage.client.cards.CardArea cardArea1; private javax.swing.JButton buttonReloadCards;
private javax.swing.JButton jButton1; private mage.client.cards.CardArea cardsPanel;
private javax.swing.JComboBox<String> comboRenderMode;
private javax.swing.JLabel labelRenderMode;
private javax.swing.JLabel labelSize;
private javax.swing.JSlider sliderSize;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View file

@ -7,28 +7,10 @@
*/ */
package mage.client.game; package mage.client.game;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.cards.Permanent; import mage.client.cards.Permanent;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
@ -38,8 +20,17 @@ import mage.client.util.layout.impl.OldCardLayoutStrategy;
import mage.view.CounterView; import mage.view.CounterView;
import mage.view.PermanentView; import mage.view.PermanentView;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.List;
import java.util.*;
import java.util.Map.Entry;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class BattlefieldPanel extends javax.swing.JLayeredPane { public class BattlefieldPanel extends javax.swing.JLayeredPane {
@ -237,7 +228,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
if (cardDimension == null) { if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()); cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
} }
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true); final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode());
permanents.put(permanent.getId(), perm); permanents.put(permanent.getId(), perm);

View file

@ -1,10 +1,5 @@
package mage.client.plugins; package mage.client.plugins;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback; import mage.cards.action.ActionCallback;
@ -12,6 +7,12 @@ import mage.client.cards.BigCard;
import mage.view.CardView; import mage.view.CardView;
import mage.view.PermanentView; import mage.view.PermanentView;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.UUID;
public interface MagePlugins { public interface MagePlugins {
void loadPlugins(); void loadPlugins();
@ -22,9 +23,9 @@ public interface MagePlugins {
JComponent updateTablePanel(Map<String, JComponent> ui); JComponent updateTablePanel(Map<String, JComponent> ui);
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage); MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, int renderMode);
MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable); MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable, int renderMode);
boolean isThemePluginLoaded(); boolean isThemePluginLoaded();

View file

@ -1,12 +1,5 @@
package mage.client.plugins.impl; package mage.client.plugins.impl;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.MageCard; import mage.cards.MageCard;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback; import mage.cards.action.ActionCallback;
@ -27,12 +20,20 @@ import mage.view.PermanentView;
import net.xeoh.plugins.base.PluginManager; import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory; import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.uri.ClassURI; import net.xeoh.plugins.base.util.uri.ClassURI;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.mage.plugins.card.CardPluginImpl; import org.mage.plugins.card.CardPluginImpl;
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
import org.mage.plugins.theme.ThemePluginImpl; import org.mage.plugins.theme.ThemePluginImpl;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import static org.mage.plugins.card.utils.CardImageUtils.getImagesDir;
public enum Plugins implements MagePlugins { public enum Plugins implements MagePlugins {
instance; instance;
public static final String PLUGINS_DIRECTORY = "plugins"; public static final String PLUGINS_DIRECTORY = "plugins";
@ -92,24 +93,24 @@ public enum Plugins implements MagePlugins {
} }
@Override @Override
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage) { public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, int renderMode) {
if (cardPlugin != null) { if (cardPlugin != null) {
mageActionCallback.refreshSession(); mageActionCallback.refreshSession();
mageActionCallback.setCardPreviewComponent(bigCard); mageActionCallback.setCardPreviewComponent(bigCard);
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage); return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode);
} else { } else {
return new Permanent(card, bigCard, Config.dimensions, gameId); return new Permanent(card, bigCard, Config.dimensions, gameId);
} }
} }
@Override @Override
public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable) { public MageCard getMageCard(CardView card, BigCard bigCard, Dimension dimension, UUID gameId, boolean loadImage, boolean previewable, int renderMode) {
if (cardPlugin != null) { if (cardPlugin != null) {
if (previewable) { if (previewable) {
mageActionCallback.refreshSession(); mageActionCallback.refreshSession();
mageActionCallback.setCardPreviewComponent(bigCard); mageActionCallback.setCardPreviewComponent(bigCard);
} }
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage); return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode);
} else { } else {
return new Card(card, bigCard, Config.dimensions, gameId); return new Card(card, bigCard, Config.dimensions, gameId);
} }

View file

@ -2,7 +2,6 @@ package org.mage.plugins.card;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback; import mage.cards.action.ActionCallback;
import mage.client.dialog.PreferencesDialog;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import mage.interfaces.plugin.CardPlugin; import mage.interfaces.plugin.CardPlugin;
import mage.view.CardView; import mage.view.CardView;
@ -99,25 +98,28 @@ public class CardPluginImpl implements CardPlugin {
* Temporary card rendering shim. Split card rendering isn't implemented * Temporary card rendering shim. Split card rendering isn't implemented
* yet, so use old component based rendering for the split cards. * yet, so use old component based rendering for the split cards.
*/ */
private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension) { private CardPanel makePanel(CardView view, UUID gameId, boolean loadImage, ActionCallback callback, boolean isFoil, Dimension dimension, int renderMode) {
String fallback = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_RENDERING_FALLBACK, "false"); switch (renderMode) {
if (fallback.equals("true")) { case 0:
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
} else {
return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension); return new CardPanelRenderImpl(view, gameId, loadImage, callback, isFoil, dimension);
case 1:
return new CardPanelComponentImpl(view, gameId, loadImage, callback, isFoil, dimension);
default:
throw new IllegalStateException("Unknown render mode " + renderMode);
} }
} }
@Override @Override
public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) { public MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension); CardPanel cardPanel = makePanel(permanent, gameId, loadImage, callback, false, dimension, renderMode);
cardPanel.setShowCastingCost(true); cardPanel.setShowCastingCost(true);
return cardPanel; return cardPanel;
} }
@Override @Override
public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage) { public MagePermanent getMageCard(CardView cardView, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode) {
CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension); CardPanel cardPanel = makePanel(cardView, gameId, loadImage, callback, false, dimension, renderMode);
cardPanel.setShowCastingCost(true); cardPanel.setShowCastingCost(true);
return cardPanel; return cardPanel;
} }

View file

@ -1,30 +1,28 @@
package mage.interfaces.plugin; package mage.interfaces.plugin;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.UUID;
import javax.swing.*;
import mage.cards.MagePermanent; import mage.cards.MagePermanent;
import mage.cards.action.ActionCallback; import mage.cards.action.ActionCallback;
import mage.view.CardView; import mage.view.CardView;
import mage.view.PermanentView; import mage.view.PermanentView;
import net.xeoh.plugins.base.Plugin; import net.xeoh.plugins.base.Plugin;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.UUID;
/** /**
* Interface for card plugins * Interface for card plugins
* *
* @version 0.6 17.07.2011 added options to #sortPermanents
* @version 0.3 21.11.2010 #getMageCard
* @version 0.2 07.11.2010 #downloadImages
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
* @author nantuko * @author nantuko
* @version 0.1 31.10.2010 #getMagePermanent, #sortPermanents
*/ */
public interface CardPlugin extends Plugin { public interface CardPlugin extends Plugin {
MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage); MagePermanent getMagePermanent(PermanentView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode);
MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage); MagePermanent getMageCard(CardView permanent, Dimension dimension, UUID gameId, ActionCallback callback, boolean canBeFoil, boolean loadImage, int renderMode);
int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel); int sortPermanents(Map<String, JComponent> ui, Map<UUID, MagePermanent> cards, boolean nonPermanentsOwnRow, boolean topPanel);