Now there plugin updates table dialog. Updated mage-theme-plugin.jar in Mage.Client.

This commit is contained in:
magenoxx 2010-11-16 23:32:51 +00:00
parent 2cb1136a52
commit 9c4fb8ed90
8 changed files with 130 additions and 54 deletions

View file

@ -17,8 +17,9 @@ public interface MagePlugins {
void loadPlugins();
void shutdown();
void updateGamePanel(Map<String, JComponent> ui);
void updateOnTable(Map<String, JComponent> ui);
JComponent updateTablePanel(Map<String, JComponent> ui);
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
boolean isThemePluginLoaded();
boolean isCardPluginLoaded();
boolean isCounterPluginLoaded();
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);

View file

@ -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<String, JComponent> ui) {
PluginManagerUtil pmu = new PluginManagerUtil(pm);
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
pl.applyInGame(ui);
}
themePlugin.applyInGame(ui);
}
@Override
public void updateOnTable(Map<String, JComponent> ui) {
PluginManagerUtil pmu = new PluginManagerUtil(pm);
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
pl.applyOnTable(ui);
}
public JComponent updateTablePanel(Map<String, JComponent> 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;
}
}

View file

@ -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,8 +59,23 @@ public class TablesPane extends MagePane {
/** Creates new form TablesPane */
public TablesPane() {
boolean initialized = false;
if (Plugins.getInstance().isThemePluginLoaded()) {
tablesPanel = new mage.client.table.TablesPanel();
Map<String, JComponent> 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();
@ -87,6 +115,20 @@ public class TablesPane extends MagePane {
pack();
}// </editor-fold>//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
private mage.client.table.TablesPanel tablesPanel;

View file

@ -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;
@ -114,6 +130,21 @@ 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<String, JComponent> getUIComponents() {
Map<String, JComponent> components = new HashMap<String, JComponent>();
components.put("jScrollPane1", jScrollPane1);
components.put("jScrollPane1ViewPort", jScrollPane1.getViewport());
components.put("jPanel1", jPanel1);
components.put("tablesPanel", this);
return components;
}
@Override

View file

@ -14,5 +14,5 @@ import net.xeoh.plugins.base.Plugin;
*/
public interface ThemePlugin extends Plugin {
void applyInGame(Map<String, JComponent> ui);
void applyOnTable(Map<String, JComponent> ui);
JComponent updateTable(Map<String, JComponent> ui);
}

View file

@ -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,7 +21,7 @@ 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);
@ -40,13 +44,15 @@ public class ThemePluginImpl implements ThemePlugin {
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);
@ -69,7 +75,7 @@ public class ThemePluginImpl implements ThemePlugin {
}
}
public void applyOnTable(Map<String, JComponent> ui) {
public JComponent updateTable(Map<String, JComponent> ui) {
String filename = "/regret.jpg";
try {
InputStream is = this.getClass().getResourceAsStream(filename);
@ -82,28 +88,25 @@ public class ThemePluginImpl implements ThemePlugin {
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"));
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);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB