From b3737c2b49f7ec64fa8d6b46c621bd3689054e7d Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 5 Dec 2006 00:02:55 +0000 Subject: [PATCH] When loading images, have getdown looking for a localized version of the files, but then fall back to the generic ones. --- .../threerings/getdown/launcher/Getdown.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/java/com/threerings/getdown/launcher/Getdown.java b/src/java/com/threerings/getdown/launcher/Getdown.java index 1c1b0b4..2b7c972 100644 --- a/src/java/com/threerings/getdown/launcher/Getdown.java +++ b/src/java/com/threerings/getdown/launcher/Getdown.java @@ -20,6 +20,8 @@ package com.threerings.getdown.launcher; +import java.util.Locale; + import java.awt.BorderLayout; import java.awt.Container; 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 + * _ in front of the "." in the filename. + */ protected BufferedImage loadImage (String path) { + String localeStr = Locale.getDefault().getLanguage(); + if (StringUtil.isBlank(path)) { return null; } - File imgpath = _app.getLocalPath(path); + + File imgpath = null; try { + // First try for a localized image. + imgpath = + _app.getLocalPath(path.replace(".", "_" + localeStr + ".")); return ImageIO.read(imgpath); } catch (IOException ioe) { - Log.warning("Failed to load image [path=" + imgpath + - ", error=" + ioe + "]."); - return null; + // If that didn't work, try a generic one. + try { + imgpath = _app.getLocalPath(path); + return ImageIO.read(imgpath); + } catch (IOException ioe2) { + Log.warning("Failed to load image [path=" + imgpath + + ", error=" + ioe2 + "]."); + return null; + } } }