forked from External/mage
Card Plugin implementation. Added displaying card and card layout.
This commit is contained in:
parent
b223d83be5
commit
48e3a65d3a
25 changed files with 687 additions and 72 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package mage.client.plugins.impl;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -10,10 +12,14 @@ import javax.swing.JComponent;
|
|||
|
||||
import mage.cards.CardDimensions;
|
||||
import mage.cards.MagePermanent;
|
||||
import mage.cards.interfaces.ActionCallback;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.cards.BigCard;
|
||||
import mage.client.cards.Permanent;
|
||||
import mage.client.plugins.MagePlugins;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.Config;
|
||||
import mage.client.util.DefaultActionCallback;
|
||||
import mage.constants.Constants;
|
||||
import mage.interfaces.plugin.CardPlugin;
|
||||
import mage.interfaces.plugin.ThemePlugin;
|
||||
|
|
@ -29,6 +35,8 @@ public class Plugins implements MagePlugins {
|
|||
private static final MagePlugins fINSTANCE = new Plugins();
|
||||
private static PluginManager pm;
|
||||
private final static Logger logger = Logging.getLogger(Plugins.class.getName());
|
||||
private CardPlugin cardPlugin = null;
|
||||
protected static DefaultActionCallback defaultCallback = new DefaultActionCallback();
|
||||
|
||||
public static MagePlugins getInstance() {
|
||||
return fINSTANCE;
|
||||
|
|
@ -39,6 +47,7 @@ public class Plugins implements MagePlugins {
|
|||
logger.log(Level.INFO, "Loading plugins...");
|
||||
pm = PluginManagerFactory.createPluginManager();
|
||||
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
|
||||
this.cardPlugin = pm.getPlugin(CardPlugin.class);
|
||||
logger.log(Level.INFO, "Done.");
|
||||
}
|
||||
|
||||
|
|
@ -57,12 +66,26 @@ public class Plugins implements MagePlugins {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||
CardPlugin cp = pm.getPlugin(CardPlugin.class);
|
||||
if (cp != null) {
|
||||
return cp.getMagePermanent(card, dimension, gameId);
|
||||
public MagePermanent getMagePermanent(final PermanentView card, BigCard bigCard, CardDimensions dimension, final UUID gameId) {
|
||||
if (cardPlugin != null) {
|
||||
return cardPlugin.getMagePermanent(card, dimension, gameId, new ActionCallback() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
defaultCallback.mouseClicked(e, gameId, MageFrame.getSession(), card);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return new Permanent(card, bigCard, Config.dimensions, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCardPluginLoaded() {
|
||||
return this.cardPlugin != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents) {
|
||||
if (this.cardPlugin != null) this.cardPlugin.sortPermanents(ui, permanents);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue