mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Now there plugin updates table dialog. Updated mage-theme-plugin.jar in Mage.Client.
This commit is contained in:
parent
2cb1136a52
commit
9c4fb8ed90
8 changed files with 130 additions and 54 deletions
Binary file not shown.
|
@ -17,8 +17,9 @@ public interface MagePlugins {
|
||||||
void loadPlugins();
|
void loadPlugins();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void updateGamePanel(Map<String, JComponent> ui);
|
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);
|
MagePermanent getMagePermanent(PermanentView card, BigCard bigCard, CardDimensions dimension, UUID gameId);
|
||||||
|
boolean isThemePluginLoaded();
|
||||||
boolean isCardPluginLoaded();
|
boolean isCardPluginLoaded();
|
||||||
boolean isCounterPluginLoaded();
|
boolean isCounterPluginLoaded();
|
||||||
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
void sortPermanents(Map<String, JComponent> ui, Collection<MagePermanent> permanents);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class Plugins implements MagePlugins {
|
||||||
private static final MagePlugins fINSTANCE = new Plugins();
|
private static final MagePlugins fINSTANCE = new Plugins();
|
||||||
private static PluginManager pm;
|
private static PluginManager pm;
|
||||||
private final static Logger logger = Logging.getLogger(Plugins.class.getName());
|
private final static Logger logger = Logging.getLogger(Plugins.class.getName());
|
||||||
|
private ThemePlugin themePlugin = null;
|
||||||
private CardPlugin cardPlugin = null;
|
private CardPlugin cardPlugin = null;
|
||||||
private CounterPlugin counterPlugin = null;
|
private CounterPlugin counterPlugin = null;
|
||||||
protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
protected static DefaultActionCallback defaultCallback = DefaultActionCallback.getInstance();
|
||||||
|
@ -52,6 +53,7 @@ public class Plugins implements MagePlugins {
|
||||||
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
|
pm.addPluginsFrom(new File(Constants.PLUGINS_DIRECTORY).toURI());
|
||||||
this.cardPlugin = pm.getPlugin(CardPlugin.class);
|
this.cardPlugin = pm.getPlugin(CardPlugin.class);
|
||||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||||
|
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||||
logger.log(Level.INFO, "Done.");
|
logger.log(Level.INFO, "Done.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,20 +64,12 @@ public class Plugins implements MagePlugins {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateGamePanel(Map<String, JComponent> ui) {
|
public void updateGamePanel(Map<String, JComponent> ui) {
|
||||||
PluginManagerUtil pmu = new PluginManagerUtil(pm);
|
themePlugin.applyInGame(ui);
|
||||||
|
|
||||||
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
|
|
||||||
pl.applyInGame(ui);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateOnTable(Map<String, JComponent> ui) {
|
public JComponent updateTablePanel(Map<String, JComponent> ui) {
|
||||||
PluginManagerUtil pmu = new PluginManagerUtil(pm);
|
return themePlugin.updateTable(ui);
|
||||||
|
|
||||||
for (ThemePlugin pl : pmu.getPlugins(ThemePlugin.class)) {
|
|
||||||
pl.applyOnTable(ui);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,4 +130,9 @@ public class Plugins implements MagePlugins {
|
||||||
public boolean isCounterPluginLoaded() {
|
public boolean isCounterPluginLoaded() {
|
||||||
return this.counterPlugin != null;
|
return this.counterPlugin != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isThemePluginLoaded() {
|
||||||
|
return this.themePlugin != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,22 @@
|
||||||
|
|
||||||
package mage.client.table;
|
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 java.util.UUID;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLayeredPane;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.MagePane;
|
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 */
|
/** Creates new form TablesPane */
|
||||||
public 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();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void showTables() {
|
public void showTables() {
|
||||||
UUID roomId = MageFrame.getSession().getMainRoomId();
|
UUID roomId = MageFrame.getSession().getMainRoomId();
|
||||||
|
@ -87,6 +115,20 @@ public class TablesPane extends MagePane {
|
||||||
pack();
|
pack();
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </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
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private mage.client.table.TablesPanel tablesPanel;
|
private mage.client.table.TablesPanel tablesPanel;
|
||||||
|
|
|
@ -37,18 +37,32 @@ package mage.client.table;
|
||||||
import mage.client.dialog.NewTableDialog;
|
import mage.client.dialog.NewTableDialog;
|
||||||
import mage.client.dialog.JoinTableDialog;
|
import mage.client.dialog.JoinTableDialog;
|
||||||
import mage.client.dialog.TableWaitingDialog;
|
import mage.client.dialog.TableWaitingDialog;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
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.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.AbstractAction;
|
import javax.swing.AbstractAction;
|
||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JLayeredPane;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
@ -56,6 +70,8 @@ import mage.client.MageFrame;
|
||||||
import mage.client.remote.MageRemoteException;
|
import mage.client.remote.MageRemoteException;
|
||||||
import mage.client.remote.Session;
|
import mage.client.remote.Session;
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
|
import mage.client.util.gui.ArrowBuilder;
|
||||||
|
import mage.client.util.gui.ImagePanel;
|
||||||
import mage.util.Logging;
|
import mage.util.Logging;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
|
||||||
|
@ -114,6 +130,21 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
||||||
|
|
||||||
ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 4);
|
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
|
@Override
|
||||||
|
|
|
@ -14,5 +14,5 @@ import net.xeoh.plugins.base.Plugin;
|
||||||
*/
|
*/
|
||||||
public interface ThemePlugin extends Plugin {
|
public interface ThemePlugin extends Plugin {
|
||||||
void applyInGame(Map<String, JComponent> ui);
|
void applyInGame(Map<String, JComponent> ui);
|
||||||
void applyOnTable(Map<String, JComponent> ui);
|
JComponent updateTable(Map<String, JComponent> ui);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
package org.mage.plugins.theme;
|
package org.mage.plugins.theme;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -6,6 +9,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import mage.interfaces.plugin.ThemePlugin;
|
import mage.interfaces.plugin.ThemePlugin;
|
||||||
import net.xeoh.plugins.base.annotations.PluginImplementation;
|
import net.xeoh.plugins.base.annotations.PluginImplementation;
|
||||||
|
@ -40,13 +44,15 @@ public class ThemePluginImpl implements ThemePlugin {
|
||||||
try {
|
try {
|
||||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||||
|
|
||||||
if (is == null)
|
if (is == null) {
|
||||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||||
|
}
|
||||||
|
|
||||||
BufferedImage background = ImageIO.read(is);
|
BufferedImage background = ImageIO.read(is);
|
||||||
|
|
||||||
if (background == null)
|
if (background == null) {
|
||||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||||
|
}
|
||||||
|
|
||||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
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";
|
String filename = "/regret.jpg";
|
||||||
try {
|
try {
|
||||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||||
|
@ -82,28 +88,25 @@ public class ThemePluginImpl implements ThemePlugin {
|
||||||
if (background == null)
|
if (background == null)
|
||||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||||
|
|
||||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
|
||||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||||
|
|
||||||
unsetOpaque(ui.get("jSplitPane1"));
|
unsetOpaque(ui.get("jScrollPane1"));
|
||||||
unsetOpaque(ui.get("pnlBattlefield"));
|
unsetOpaque(ui.get("jPanel1"));
|
||||||
unsetOpaque(ui.get("jPanel3"));
|
unsetOpaque(ui.get("tablesPanel"));
|
||||||
unsetOpaque(ui.get("hand"));
|
JComponent viewport = ui.get("jScrollPane1ViewPort");
|
||||||
unsetOpaque(ui.get("chatPanel"));
|
if (viewport != null) {
|
||||||
|
viewport.setBackground(new Color(20,20,20,50));
|
||||||
ui.get("gamePanel").remove(ui.get("jLayeredPane"));
|
|
||||||
bgPanel.add(ui.get("jLayeredPane"));
|
|
||||||
ui.get("gamePanel").add(bgPanel);
|
|
||||||
} else {
|
|
||||||
log.error("error: no components");
|
|
||||||
}
|
}
|
||||||
|
return bgPanel;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unsetOpaque(JComponent c) {
|
private void unsetOpaque(JComponent c) {
|
||||||
if (c != null) c.setOpaque(false);
|
if (c != null) {
|
||||||
|
c.setOpaque(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
Mage.Plugins/Mage.Theme.Plugin/src/main/resources/regret.jpg
Normal file
BIN
Mage.Plugins/Mage.Theme.Plugin/src/main/resources/regret.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 MiB |
Loading…
Reference in a new issue