[card.plugin] first version (at the moment replaces only cards on battlefield) (should be installed manually)

This commit is contained in:
magenoxx 2010-11-06 21:23:21 +00:00
parent d022c251f6
commit 5771691972
18 changed files with 1093 additions and 33 deletions

View file

@ -37,19 +37,24 @@ package mage.client;
import java.awt.Cursor;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDesktopPane;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JToolBar.Separator;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import mage.cards.Card;
import mage.cards.ExpansionSet;
import mage.client.dialog.AboutDialog;
import mage.client.dialog.CombatDialog;
import mage.client.dialog.ConnectDialog;
@ -57,11 +62,8 @@ import mage.client.dialog.PickNumberDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.remote.Session;
import mage.client.util.EDTExceptionHandler;
import mage.interfaces.plugin.ThemePlugin;
import mage.sets.Sets;
import mage.util.Logging;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.PluginManagerUtil;
/**
*
@ -127,7 +129,31 @@ public class MageFrame extends javax.swing.JFrame {
enableButtons();
else
disableButtons();
//TODO:
Separator separator = new javax.swing.JToolBar.Separator();
mageToolbar.add(separator);
JButton btnDownload = new JButton("Images");
btnDownload.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
btnDownload.setFocusable(false);
btnDownload.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnDownload.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDownload.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImagesActionPerformed(evt);
}
});
mageToolbar.add(btnDownload);
}
private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
Set<Card> allCards = new LinkedHashSet<Card>();
for (ExpansionSet set: Sets.getInstance().values()) {
allCards.addAll(set.createCards());
}
Plugins.getInstance().downloadImage(allCards);
}
public void showGame(UUID gameId, UUID playerId) {
this.tablesPane.hideTables();

View file

@ -84,9 +84,6 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
ui.put("jScrollPane", jScrollPane);
ui.put("battlefieldPanel", this);
initComponents();
addMouseListener(new MageMouseAdapter(this, gameId));
addMouseMotionListener(new MageMouseMotionAdapter(this, bigCard));
}
public void init(UUID gameId, BigCard bigCard) {
@ -95,13 +92,13 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
if (Plugins.getInstance().isCardPluginLoaded()) {
bigCard.removeTextComponent();
}
addMouseListener(new MageMouseAdapter(this, gameId));
addMouseMotionListener(new MageMouseMotionAdapter(this, bigCard));
}
public void update(Map<UUID, PermanentView> battlefield) {
for (PermanentView permanent: battlefield.values()) {
if (!permanents.containsKey(permanent.getId())) {
//TODO: remove me
//System.out.println("Add permanent: " + permanent.getCardNumber());
addPermanent(permanent);
}
else {
@ -133,8 +130,10 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
}
permanents.put(permanent.getId(), perm);
this.add(perm, 10);
moveToFront(perm);
perm.update(permanent);
if (!Plugins.getInstance().isCardPluginLoaded()) {
moveToFront(perm);
perm.update(permanent);
}
}
private void groupAttachments(PermanentView permanent) {
@ -228,7 +227,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
}
private void resizeBattlefield() {
Dimension area = new Dimension(0, 0);
/*Dimension area = new Dimension(0, 0);
Dimension size = getPreferredSize();
for (Component comp: getComponents()) {
@ -244,7 +243,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
setPreferredSize(area);
revalidate();
repaint();
}
}*/
}

View file

@ -2,10 +2,12 @@ package mage.client.plugins;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.Card;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.client.cards.BigCard;
@ -18,4 +20,5 @@ public interface MagePlugins {
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
boolean isCardPluginLoaded();
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
void downloadImage(Set<Card> allCards);
}

View file

@ -24,6 +24,7 @@ public class MageMouseMotionAdapter extends MouseMotionAdapter {
@Override
public void mouseMoved(MouseEvent e) {
if (!Plugins.getInstance().isCardPluginLoaded()) return;
if (bigCard == null) return;
Object o = parent.getComponentAt(e.getPoint());
if (o instanceof MagePermanent) {
MagePermanent card = (MagePermanent) o;

View file

@ -2,14 +2,18 @@ package mage.client.plugins.impl;
import java.io.File;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import mage.cards.Card;
import mage.cards.CardDimensions;
import mage.cards.ExpansionSet;
import mage.cards.MagePermanent;
import mage.cards.action.impl.EmptyCallback;
import mage.client.cards.BigCard;
@ -20,6 +24,7 @@ import mage.client.util.DefaultActionCallback;
import mage.constants.Constants;
import mage.interfaces.plugin.CardPlugin;
import mage.interfaces.plugin.ThemePlugin;
import mage.sets.Sets;
import mage.util.Logging;
import mage.view.PermanentView;
import net.xeoh.plugins.base.PluginManager;
@ -81,4 +86,9 @@ public class Plugins implements MagePlugins {
public void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents) {
if (this.cardPlugin != null) this.cardPlugin.sortPermanents(ui, permanents);
}
@Override
public void downloadImage(Set<Card> allCards) {
if (this.cardPlugin != null) this.cardPlugin.downloadImages(allCards);
}
}