mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
remove Mage.Theme.Plugin module
it has been a included in Mage.Client since 8ac58cfc
This commit is contained in:
parent
ce3a70d3cf
commit
c25e45095e
8 changed files with 1 additions and 264 deletions
|
@ -30,7 +30,6 @@ import net.xeoh.plugins.base.PluginManager;
|
|||
import net.xeoh.plugins.base.impl.PluginManagerFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.mage.plugins.card.CardPluginImpl;
|
||||
import org.mage.plugins.theme.ThemePluginImpl;
|
||||
|
||||
|
||||
public class Plugins implements MagePlugins {
|
||||
|
@ -58,8 +57,7 @@ public class Plugins implements MagePlugins {
|
|||
pm.addPluginsFrom(new File(PLUGINS_DIRECTORY).toURI());
|
||||
this.cardPlugin = new CardPluginImpl();
|
||||
this.counterPlugin = pm.getPlugin(CounterPlugin.class);
|
||||
//this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
this.themePlugin = new ThemePluginImpl();
|
||||
this.themePlugin = pm.getPlugin(ThemePlugin.class);
|
||||
logger.info("Done.");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>1.4.4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-theme-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.5</version>
|
||||
<name>Mage Theme Plugin</name>
|
||||
<description>Contains resources for drawing background</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-common</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-client</artifactId>
|
||||
<version>1.4.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<finalName>mage-theme-plugin</finalName>
|
||||
</build>
|
||||
</project>
|
|
@ -1,210 +0,0 @@
|
|||
package org.mage.plugins.theme;
|
||||
|
||||
import mage.components.ImagePanel;
|
||||
import mage.interfaces.plugin.ThemePlugin;
|
||||
import mage.client.dialog.PreferencesDialog;
|
||||
import net.xeoh.plugins.base.annotations.PluginImplementation;
|
||||
import net.xeoh.plugins.base.annotations.events.Init;
|
||||
import net.xeoh.plugins.base.annotations.events.PluginLoaded;
|
||||
import net.xeoh.plugins.base.annotations.meta.Author;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.*;
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
@PluginImplementation
|
||||
@Author(name = "nantuko")
|
||||
public class ThemePluginImpl implements ThemePlugin {
|
||||
|
||||
private static final Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static BufferedImage background;
|
||||
private List flist = new List();
|
||||
private String BackgroundDir = "plugins" + File.separator + "plugin.data" + File.separator
|
||||
+ "background" + File.separator;
|
||||
@Init
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@PluginLoaded
|
||||
public void newPlugin(ThemePlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Theme plugin, version 0.5]";
|
||||
}
|
||||
|
||||
public boolean loadimages(){
|
||||
File filedir = new File(BackgroundDir);
|
||||
File[] filelist = filedir.listFiles();
|
||||
if(filelist == null) return false;
|
||||
if(filelist.length == 0) return false;
|
||||
for(File f:filelist){
|
||||
String filename = f.getName().toLowerCase();
|
||||
if(filename != null && (filename.endsWith(".png") || filename.endsWith(".jpg")
|
||||
|| filename.endsWith(".bmp"))){
|
||||
flist.add(filename);
|
||||
}
|
||||
}
|
||||
if(flist.getItemCount() == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void applyInGame(Map<String, JComponent> ui) {
|
||||
BufferedImage background;
|
||||
try {
|
||||
|
||||
if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_DEFAULT,
|
||||
"true").equals("true")){
|
||||
|
||||
background = loadbuffer_default();
|
||||
|
||||
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE_RANDOM,
|
||||
"true").equals("true")){
|
||||
|
||||
background = loadbuffer_random();
|
||||
|
||||
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BATTLEFIELD_IMAGE, "") != null){
|
||||
|
||||
background = loadbuffer_selected();
|
||||
|
||||
}else{
|
||||
background = loadbuffer_default();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if(loadimages()){
|
||||
int it = (int)Math.abs(Math.random()*(flist.getItemCount()));
|
||||
filename = BackgroundDir + flist.getItem(it);
|
||||
background = ImageIO.read(new File(filename));
|
||||
}else{
|
||||
filename = "/dragon.png";
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
background = ImageIO.read(is);
|
||||
}
|
||||
*/
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find background file 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("gameChatPanel"));
|
||||
unsetOpaque(ui.get("userChatPanel"));
|
||||
|
||||
ui.get("gamePanel").remove(ui.get("jLayeredPane"));
|
||||
bgPanel.add(ui.get("jLayeredPane"));
|
||||
ui.get("gamePanel").add(bgPanel);
|
||||
} else {
|
||||
log.error("error: no components");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BufferedImage loadbuffer_default() throws IOException{
|
||||
String filename = "/dragon.png";
|
||||
BufferedImage res;
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
res = ImageIO.read(is);
|
||||
return res;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_random() throws IOException{
|
||||
BufferedImage res;
|
||||
if(loadimages()){
|
||||
int it = (int)Math.abs(Math.random()*(flist.getItemCount()));
|
||||
String filename = BackgroundDir + flist.getItem(it);
|
||||
res = ImageIO.read(new File(filename));
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private BufferedImage loadbuffer_selected() throws IOException{
|
||||
BufferedImage res;
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BATTLEFIELD_IMAGE, "");
|
||||
if(path != null){
|
||||
res = ImageIO.read(new File(path));
|
||||
return res;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public JComponent updateTable(Map<String, JComponent> ui) {
|
||||
ImagePanel bgPanel = createImagePanelInstance();
|
||||
|
||||
unsetOpaque(ui.get("jScrollPane1"));
|
||||
unsetOpaque(ui.get("jPanel1"));
|
||||
unsetOpaque(ui.get("tablesPanel"));
|
||||
JComponent viewport = ui.get("jScrollPane1ViewPort");
|
||||
if (viewport != null) {
|
||||
viewport.setBackground(new Color(255,255,255,50));
|
||||
}
|
||||
return bgPanel;
|
||||
}
|
||||
|
||||
private ImagePanel createImagePanelInstance() {
|
||||
if (background == null) {
|
||||
synchronized (ThemePluginImpl.class) {
|
||||
if (background == null) {
|
||||
String filename = "/background.png";
|
||||
try {
|
||||
if(PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")){
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
background = ImageIO.read(is);
|
||||
}else if(PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BACKGROUND_IMAGE, "") != null){
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BATTLEFIELD_IMAGE, "");
|
||||
if(path != null){
|
||||
background = ImageIO.read(new File(path));
|
||||
}else{
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
background = ImageIO.read(is);
|
||||
}
|
||||
}
|
||||
|
||||
if (background == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ImagePanel(background, ImagePanel.SCALED);
|
||||
}
|
||||
|
||||
private void unsetOpaque(JComponent c) {
|
||||
if (c != null) {
|
||||
c.setOpaque(false);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 575 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB |
|
@ -16,7 +16,6 @@
|
|||
<description>Mage Plugins POM</description>
|
||||
|
||||
<modules>
|
||||
<module>Mage.Theme.Plugin</module>
|
||||
<module>Mage.Counter.Plugin</module>
|
||||
</modules>
|
||||
|
||||
|
|
Loading…
Reference in a new issue