mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
commit
1660f482ff
2 changed files with 35 additions and 37 deletions
|
@ -180,8 +180,10 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
if(extend.equals(".png") || extend.equals(".bmp"))
|
||||
return "Image File(*.png, *.bmp)";
|
||||
if(extend.equals(".png"))
|
||||
return "Image File(*.png)";
|
||||
if(extend.equals(".bmp"))
|
||||
return "Image File(*.bmp)";
|
||||
if(extend.equals(".jpg") || extend.equals(".jpg"))
|
||||
return "JEGP file(*.jpg,*.jepg)";
|
||||
return "";
|
||||
|
|
|
@ -78,25 +78,12 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
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.");
|
||||
background = loadbuffer_default();
|
||||
}
|
||||
if (background == null){
|
||||
throw new FileNotFoundException("Couldn't find in resources.");
|
||||
}
|
||||
|
||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||
|
||||
|
@ -143,9 +130,13 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
BufferedImage res;
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BATTLEFIELD_IMAGE, "");
|
||||
if(path != null){
|
||||
if(path != null && !path.equals("")){
|
||||
try{
|
||||
res = ImageIO.read(new File(path));
|
||||
return res;
|
||||
}catch(Exception e){
|
||||
res = null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -176,22 +167,27 @@ public class ThemePluginImpl implements ThemePlugin {
|
|||
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{
|
||||
String path = PreferencesDialog.getCachedValue(PreferencesDialog.
|
||||
KEY_BACKGROUND_IMAGE, "");
|
||||
if(path != null && !path.equals("")){
|
||||
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)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
if(background == null) throw new
|
||||
FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue