mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Updated Theme plugin interface and implementation (still in progress).
This commit is contained in:
parent
a731fba667
commit
2cb1136a52
5 changed files with 48 additions and 32 deletions
|
@ -13,5 +13,6 @@ import net.xeoh.plugins.base.Plugin;
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
*/
|
*/
|
||||||
public interface ThemePlugin extends Plugin {
|
public interface ThemePlugin extends Plugin {
|
||||||
void apply(Map<String, JComponent> ui);
|
void applyInGame(Map<String, JComponent> ui);
|
||||||
|
void applyOnTable(Map<String, JComponent> ui);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,29 +45,6 @@
|
||||||
<target>1.6</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
|
|
||||||
<finalName>mage-theme-plugin</finalName>
|
<finalName>mage-theme-plugin</finalName>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.mage.plugins.theme;
|
package org.mage.plugins.theme;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
@ -31,16 +32,21 @@ public class ThemePluginImpl implements ThemePlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "[Theme plugin, version 0.2]";
|
return "[Theme plugin, version 0.3]";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void apply(Map<String, JComponent> ui) {
|
public void applyInGame(Map<String, JComponent> ui) {
|
||||||
//log.info("Adding background...");
|
String filename = "/wood.png";
|
||||||
try {
|
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)
|
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")) {
|
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||||
|
@ -61,8 +67,40 @@ public class ThemePluginImpl implements ThemePlugin {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return;
|
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) {
|
private void unsetOpaque(JComponent c) {
|
||||||
|
|
BIN
Mage.Plugins/Mage.Theme.Plugin/src/main/resources/wood.png
Normal file
BIN
Mage.Plugins/Mage.Theme.Plugin/src/main/resources/wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 798 KiB |
|
@ -9,5 +9,5 @@
|
||||||
hand:player:Fireball:2
|
hand:player:Fireball:2
|
||||||
battlefield:player:Plains:5
|
battlefield:player:Plains:5
|
||||||
battlefield:player:Brindle Boar:1
|
battlefield:player:Brindle Boar:1
|
||||||
battlefield:computer:Brindle Boar:1
|
battlefield:computer:Bloodbraid Elf:1
|
||||||
hand:player:Holy Strength:2
|
hand:player:Holy Strength:2
|
||||||
|
|
Loading…
Reference in a new issue