Updated Theme plugin interface and implementation (still in progress).

This commit is contained in:
magenoxx 2010-11-16 18:32:49 +00:00
parent a731fba667
commit 2cb1136a52
5 changed files with 48 additions and 32 deletions

View file

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

View file

@ -45,29 +45,6 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<artifactSet>
<includes>
<include>log4j:log4j:jar:</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<finalName>mage-theme-plugin</finalName>

View file

@ -1,6 +1,7 @@
package org.mage.plugins.theme;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Map;
import javax.imageio.ImageIO;
@ -31,16 +32,21 @@ public class ThemePluginImpl implements ThemePlugin {
}
public String toString() {
return "[Theme plugin, version 0.2]";
return "[Theme plugin, version 0.3]";
}
public void apply(Map<String, JComponent> ui) {
//log.info("Adding background...");
public void applyInGame(Map<String, JComponent> ui) {
String filename = "/wood.png";
try {
BufferedImage background = ImageIO.read(this.getClass().getResourceAsStream("/dk_gray.jpg"));
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 dk_gray.jpg 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);
@ -61,8 +67,40 @@ public class ThemePluginImpl implements ThemePlugin {
log.error(e.getMessage(), e);
return;
}
}
//log.info("Done.");
public void applyOnTable(Map<String, JComponent> 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"));
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 void unsetOpaque(JComponent c) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

View file

@ -9,5 +9,5 @@
hand:player:Fireball:2
battlefield:player:Plains:5
battlefield:player:Brindle Boar:1
battlefield:computer:Brindle Boar:1
battlefield:computer:Bloodbraid Elf:1
hand:player:Holy Strength:2