forked from External/mage
GUI enchancements (themes, sound notification, deck validation) (#6755)
GUI enchancements (themes, sound notification, deck validation)
This commit is contained in:
parent
8c4c2728d6
commit
99d5eafc8a
128 changed files with 1988 additions and 11320 deletions
|
|
@ -12,7 +12,6 @@ import mage.components.ImagePanel;
|
|||
import mage.components.ImagePanelStyle;
|
||||
import mage.interfaces.plugin.ThemePlugin;
|
||||
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;
|
||||
|
|
@ -27,10 +26,6 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
private final List flist = new List();
|
||||
private final String BackgroundDir = "backgrounds" + File.separator;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@PluginLoaded
|
||||
public void newPlugin(ThemePlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
|
|
@ -104,10 +99,11 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
}
|
||||
}
|
||||
|
||||
// Sets background for in-battle
|
||||
// loadbuffer_default - Only apply theme background if no custom user background set
|
||||
private BufferedImage loadbuffer_default() throws IOException {
|
||||
String filename = "/dragon.png";
|
||||
BufferedImage res;
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
InputStream is = this.getClass().getResourceAsStream(PreferencesDialog.getCurrentTheme().getBattleBackgroundPath());
|
||||
res = ImageIO.read(is);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -150,43 +146,44 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
return bgPanel;
|
||||
}
|
||||
|
||||
// Sets background for logged in user for tables/deck editor/card viewer/etc
|
||||
private synchronized ImagePanel createImagePanelInstance() {
|
||||
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 {
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
|
||||
if (path != null && !path.isEmpty()) {
|
||||
try {
|
||||
File f = new File(path);
|
||||
if (f != null) {
|
||||
background = ImageIO.read(f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
background = null;
|
||||
try {
|
||||
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE_DEFAULT, "true").equals("true")) {
|
||||
InputStream is = this.getClass().getResourceAsStream(PreferencesDialog.getCurrentTheme().getBackgroundPath());
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + PreferencesDialog.getCurrentTheme().getBackgroundPath() + " in resources.");
|
||||
}
|
||||
background = ImageIO.read(is);
|
||||
} else {
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_BACKGROUND_IMAGE, "");
|
||||
if (path != null && !path.isEmpty()) {
|
||||
try {
|
||||
File f = new File(path);
|
||||
if (f != null) {
|
||||
background = ImageIO.read(f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
background = null;
|
||||
}
|
||||
}
|
||||
if (background == null) {
|
||||
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) {
|
||||
String filename = "/background/background.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 " + filename + " in resources.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new ImagePanel(background, ImagePanelStyle.SCALED);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue