diff --git a/Mage.Client/plugins/mage-theme-plugin.jar b/Mage.Client/plugins/mage-theme-plugin.jar index c4caa7f3f9..39303733c7 100644 Binary files a/Mage.Client/plugins/mage-theme-plugin.jar and b/Mage.Client/plugins/mage-theme-plugin.jar differ diff --git a/Mage.Client/src/main/java/mage/client/plugins/MagePlugins.java b/Mage.Client/src/main/java/mage/client/plugins/MagePlugins.java index 63297de613..a07e2f30e8 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/MagePlugins.java +++ b/Mage.Client/src/main/java/mage/client/plugins/MagePlugins.java @@ -17,8 +17,9 @@ public interface MagePlugins { void loadPlugins(); void shutdown(); void updateGamePanel(Map ui); - void updateOnTable(Map ui); + JComponent updateTablePanel(Map ui); MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId); + boolean isThemePluginLoaded(); boolean isCardPluginLoaded(); boolean isCounterPluginLoaded(); void sortPermanents(Map ui, Collection permanents); diff --git a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java index 0afe865eff..c3bfa509ec 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java +++ b/Mage.Client/src/main/java/mage/client/plugins/impl/Plugins.java @@ -36,6 +36,7 @@ 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 ThemePlugin themePlugin = null; private CardPlugin cardPlugin = null; private CounterPlugin counterPlugin = null; protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance(); @@ -52,6 +53,7 @@ public class Plugins implements MagePlugins { pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI()); this.cardPlugin = pm.getPlugin(CardPlugin.class); this.counterPlugin = pm.getPlugin(CounterPlugin.class); + this.themePlugin = pm.getPlugin(ThemePlugin.class); logger.log(Level.INFO, "Done."); } @@ -62,20 +64,12 @@ public class Plugins implements MagePlugins { @Override public void updateGamePanel(Map ui) { - PluginManagerUtil pmu = new PluginManagerUtil(pm); - - for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) { - pl.applyInGame(ui); - } + themePlugin.applyInGame(ui); } @Override - public void updateOnTable(Map ui) { - PluginManagerUtil pmu = new PluginManagerUtil(pm); - - for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) { - pl.applyOnTable(ui); - } + public JComponent updateTablePanel(Map ui) { + return themePlugin.updateTable(ui); } @Override @@ -136,4 +130,9 @@ public class Plugins implements MagePlugins { public boolean isCounterPluginLoaded() { return this.counterPlugin != null; } + + @Override + public boolean isThemePluginLoaded() { + return this.themePlugin != null; + } } diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPane.java b/Mage.Client/src/main/java/mage/client/table/TablesPane.java index 010fb427a3..f01e33848a 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPane.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPane.java @@ -34,9 +34,22 @@ package mage.client.table; +import java.awt.Color; +import java.awt.image.BufferedImage; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; + +import javax.imageio.ImageIO; +import javax.swing.JComponent; +import javax.swing.JLayeredPane; + import mage.client.MageFrame; import mage.client.MagePane; +import mage.client.plugins.impl.Plugins; +import mage.client.util.gui.ImagePanel; /** * @@ -46,9 +59,24 @@ public class TablesPane extends MagePane { /** Creates new form TablesPane */ public TablesPane() { - initComponents(); + boolean initialized = false; + if (Plugins.getInstance().isThemePluginLoaded()) { + tablesPanel = new mage.client.table.TablesPanel(); + Map ui = tablesPanel.getUIComponents(); + JComponent container = Plugins.getInstance().updateTablePanel(ui); + if (container != null) { + initComponents(container); + container.add(tablesPanel); + //ui.get("jScrollPane1ViewPort").setBackground(new Color(20,20,20,50)); + container.setOpaque(false); + initialized = true; + } + } + if (!initialized) { + initComponents(); + } } - + public void showTables() { UUID roomId = MageFrame.getSession().getMainRoomId(); if (roomId != null) { @@ -86,6 +114,20 @@ public class TablesPane extends MagePane { pack(); }// //GEN-END:initComponents + + private void initComponents(JComponent container) { + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(container, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE) + ); + pack(); + } // Variables declaration - do not modify//GEN-BEGIN:variables diff --git a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java index 3771b0bf92..d20ac8d71d 100644 --- a/Mage.Client/src/main/java/mage/client/table/TablesPanel.java +++ b/Mage.Client/src/main/java/mage/client/table/TablesPanel.java @@ -37,18 +37,32 @@ package mage.client.table; import mage.client.dialog.NewTableDialog; import mage.client.dialog.JoinTableDialog; import mage.client.dialog.TableWaitingDialog; + +import java.awt.BorderLayout; +import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.image.BufferedImage; +import java.io.InputStream; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Observable; import java.util.Observer; import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; + +import javax.imageio.ImageIO; import javax.swing.AbstractAction; import javax.swing.Action; +import javax.swing.JComponent; +import javax.swing.JLayeredPane; import javax.swing.JOptionPane; +import javax.swing.JPanel; import javax.swing.Timer; import javax.swing.table.AbstractTableModel; import mage.cards.decks.DeckCardLists; @@ -56,6 +70,8 @@ import mage.client.MageFrame; import mage.client.remote.MageRemoteException; import mage.client.remote.Session; import mage.client.util.ButtonColumn; +import mage.client.util.gui.ArrowBuilder; +import mage.client.util.gui.ImagePanel; import mage.util.Logging; import mage.view.TableView; @@ -113,9 +129,24 @@ public class TablesPanel extends javax.swing.JPanel implements Observer { }; ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 4); - + + jSplitPane1.setOpaque(false); + jScrollPane1.setOpaque(false); + jPanel1.setOpaque(false); + jScrollPane1.getViewport().setBackground(new Color(20,20,20,150)); } + public Map getUIComponents() { + Map components = new HashMap(); + + components.put("jScrollPane1", jScrollPane1); + components.put("jScrollPane1ViewPort", jScrollPane1.getViewport()); + components.put("jPanel1", jPanel1); + components.put("tablesPanel", this); + + return components; + } + @Override public void update(Observable arg0, Object arg1) { try { diff --git a/Mage.Common/src/mage/interfaces/plugin/ThemePlugin.java b/Mage.Common/src/mage/interfaces/plugin/ThemePlugin.java index b5dbda9c49..4f0c661b41 100644 --- a/Mage.Common/src/mage/interfaces/plugin/ThemePlugin.java +++ b/Mage.Common/src/mage/interfaces/plugin/ThemePlugin.java @@ -14,5 +14,5 @@ import net.xeoh.plugins.base.Plugin; */ public interface ThemePlugin extends Plugin { void applyInGame(Map ui); - void applyOnTable(Map ui); + JComponent updateTable(Map ui); } diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java b/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java index 4e83c656d4..0935966d51 100644 --- a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java +++ b/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java @@ -1,4 +1,7 @@ package org.mage.plugins.theme; + +import java.awt.Color; +import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.FileNotFoundException; import java.io.InputStream; @@ -6,6 +9,7 @@ import java.util.Map; import javax.imageio.ImageIO; import javax.swing.JComponent; +import javax.swing.JPanel; import mage.interfaces.plugin.ThemePlugin; import net.xeoh.plugins.base.annotations.PluginImplementation; @@ -17,37 +21,39 @@ import org.apache.log4j.Logger; import org.mage.plugins.component.ImagePanel; @PluginImplementation -@Author(name="nantuko") +@Author(name = "nantuko") public class ThemePluginImpl implements ThemePlugin { - + private final static Logger log = Logger.getLogger(ThemePluginImpl.class); - + @Init - public void init() { - } - + public void init() { + } + @PluginLoaded - public void newPlugin(ThemePlugin plugin) { - log.info(plugin.toString() + " has been loaded."); - } - + public void newPlugin(ThemePlugin plugin) { + log.info(plugin.toString() + " has been loaded."); + } + public String toString() { return "[Theme plugin, version 0.3]"; } - + public void applyInGame(Map ui) { String filename = "/wood.png"; try { InputStream is = this.getClass().getResourceAsStream(filename); - - if (is == null) + + if (is == null) { throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - + } + BufferedImage background = ImageIO.read(is); - - if (background == null) + + if (background == null) { throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - + } + if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) { ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED); @@ -68,42 +74,39 @@ public class ThemePluginImpl implements ThemePlugin { return; } } - - public void applyOnTable(Map ui) { + + public JComponent updateTable(Map ui) { String filename = "/regret.jpg"; try { InputStream is = this.getClass().getResourceAsStream(filename); - + if (is == null) throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - + BufferedImage background = ImageIO.read(is); - + if (background == null) throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - - if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) { - ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED); - unsetOpaque(ui.get("jSplitPane1")); - unsetOpaque(ui.get("pnlBattlefield")); - unsetOpaque(ui.get("jPanel3")); - unsetOpaque(ui.get("hand")); - unsetOpaque(ui.get("chatPanel")); + ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED); - ui.get("gamePanel").remove(ui.get("jLayeredPane")); - bgPanel.add(ui.get("jLayeredPane")); - ui.get("gamePanel").add(bgPanel); - } else { - log.error("error: no components"); + unsetOpaque(ui.get("jScrollPane1")); + unsetOpaque(ui.get("jPanel1")); + unsetOpaque(ui.get("tablesPanel")); + JComponent viewport = ui.get("jScrollPane1ViewPort"); + if (viewport != null) { + viewport.setBackground(new Color(20,20,20,50)); } + return bgPanel; } catch (Exception e) { log.error(e.getMessage(), e); - return; + return null; } } - + private void unsetOpaque(JComponent c) { - if (c != null) c.setOpaque(false); + if (c != null) { + c.setOpaque(false); + } } } diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/regret.jpg b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/regret.jpg new file mode 100644 index 0000000000..8489d3b8b2 Binary files /dev/null and b/Mage.Plugins/Mage.Theme.Plugin/src/main/resources/regret.jpg differ