Loads a "light" version of FSkin, just enough for the splash screen: skin name. Generates custom skin settings, fonts, and backgrounds. @param skinName the skin name
(final String skinName, final boolean onInit)
| 1165 | * the skin name |
| 1166 | */ |
| 1167 | public static void loadLight(final String skinName, final boolean onInit) { |
| 1168 | if (onInit) { |
| 1169 | // No need for this method to be loaded while on the EDT. |
| 1170 | FThreads.assertExecutedByEdt(false); |
| 1171 | |
| 1172 | if (allSkins == null) { //initialize |
| 1173 | allSkins = new ArrayList<>(); |
| 1174 | allSkins.add("Default");//init default |
| 1175 | final List<String> skinDirectoryNames = getSkinDirectoryNames(); |
| 1176 | for (String skinDirectoryName : skinDirectoryNames) { |
| 1177 | allSkins.add(WordUtil.capitalize(skinDirectoryName.replace('_', ' '))); |
| 1178 | } |
| 1179 | Collections.sort(allSkins); |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | currentSkinIndex = allSkins.indexOf(skinName); |
| 1184 | |
| 1185 | // Non-default (preferred) skin name and dir. |
| 1186 | preferredName = skinName.toLowerCase().replace(' ', '_'); |
| 1187 | preferredDir = preferredName.equalsIgnoreCase("default") || preferredName.isEmpty() ? ForgeConstants.DEFAULT_SKINS_DIR : ForgeConstants.CACHE_SKINS_DIR + preferredName + "/"; |
| 1188 | |
| 1189 | if (onInit) { |
| 1190 | final File f = new File(preferredDir + ForgeConstants.SPLASH_BG_FILE); |
| 1191 | if (!f.exists()) { |
| 1192 | if (skinName.equals("default")) { |
| 1193 | throw new RuntimeException(String.format("Cannot find default skin at %s", f.getAbsolutePath())); |
| 1194 | } |
| 1195 | loadLight("default", true); |
| 1196 | return; |
| 1197 | } |
| 1198 | |
| 1199 | final BufferedImage img; |
| 1200 | try { |
| 1201 | img = ImageIO.read(f); |
| 1202 | |
| 1203 | final int h = img.getHeight(); |
| 1204 | final int w = img.getWidth(); |
| 1205 | |
| 1206 | SkinIcon.setIcon(FSkinProp.BG_SPLASH, img.getSubimage(0, 0, w, h - 100)); |
| 1207 | |
| 1208 | UIManager.put("ProgressBar.background", getColorFromPixel(img.getRGB(25, h - 75))); |
| 1209 | UIManager.put("ProgressBar.selectionBackground", getColorFromPixel(img.getRGB(75, h - 75))); |
| 1210 | UIManager.put("ProgressBar.foreground", getColorFromPixel(img.getRGB(25, h - 25))); |
| 1211 | UIManager.put("ProgressBar.selectionForeground", getColorFromPixel(img.getRGB(75, h - 25))); |
| 1212 | UIManager.put("ProgressBar.border", new LineBorder(Color.BLACK, 0)); |
| 1213 | } |
| 1214 | catch (final IOException e) { |
| 1215 | e.printStackTrace(); |
| 1216 | } |
| 1217 | loaded = true; |
| 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | /** |
| 1222 | * Loads two sprites: the default (which should be a complete |
no test coverage detected