When loading images, have getdown looking for a localized version of the files, but then fall back to the generic ones.
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
package com.threerings.getdown.launcher;
|
package com.threerings.getdown.launcher;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
@@ -682,18 +684,35 @@ public abstract class Getdown extends Thread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the image at the path. Before trying the exact path/file specified
|
||||||
|
* we will look to see if we can find a localized version by sticking a
|
||||||
|
* _<language> in front of the "." in the filename.
|
||||||
|
*/
|
||||||
protected BufferedImage loadImage (String path)
|
protected BufferedImage loadImage (String path)
|
||||||
{
|
{
|
||||||
|
String localeStr = Locale.getDefault().getLanguage();
|
||||||
|
|
||||||
if (StringUtil.isBlank(path)) {
|
if (StringUtil.isBlank(path)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
File imgpath = _app.getLocalPath(path);
|
|
||||||
|
File imgpath = null;
|
||||||
try {
|
try {
|
||||||
|
// First try for a localized image.
|
||||||
|
imgpath =
|
||||||
|
_app.getLocalPath(path.replace(".", "_" + localeStr + "."));
|
||||||
return ImageIO.read(imgpath);
|
return ImageIO.read(imgpath);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Failed to load image [path=" + imgpath +
|
// If that didn't work, try a generic one.
|
||||||
", error=" + ioe + "].");
|
try {
|
||||||
return null;
|
imgpath = _app.getLocalPath(path);
|
||||||
|
return ImageIO.read(imgpath);
|
||||||
|
} catch (IOException ioe2) {
|
||||||
|
Log.warning("Failed to load image [path=" + imgpath +
|
||||||
|
", error=" + ioe2 + "].");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user